From 32d679e8a423e1aa5aec4f262a69396eaa9d2476 Mon Sep 17 00:00:00 2001 From: Matt DeVillier Date: Fri, 26 Jan 2024 14:57:11 -0600 Subject: [PATCH] drivers/gfx/generic: Add display type field Add an enum for the Display Type, which if set, can be used to generate the Device ID value dynamically when the addr field is not set. This will allow devicetree entries to specify the display type instead of a hex value for the address which requires referencing the ACPI spec to decode. For an internal panel connected to the first port on the graphics chip, currently an addr value of 0x80010400 is specified. Replacing the 'addr' field with the 'type' field and setting it to 'panel' will generate the same DID value. Change-Id: Id0294a14606b410a13fa22eeb240df9e409a7ca3 Signed-off-by: Matt DeVillier Reviewed-on: https://review.coreboot.org/c/coreboot/+/80199 Tested-by: build bot (Jenkins) Reviewed-by: Eric Lai Reviewed-by: Felix Singer --- src/drivers/gfx/generic/chip.h | 16 +++++++++++++++- src/drivers/gfx/generic/generic.c | 10 +++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/drivers/gfx/generic/chip.h b/src/drivers/gfx/generic/chip.h index 1a666a27eb..2710367a3c 100644 --- a/src/drivers/gfx/generic/chip.h +++ b/src/drivers/gfx/generic/chip.h @@ -6,6 +6,17 @@ #include #include +/* ACPI spec 6.5 table B-2, Display Output Device */ +#define DOD_FW_DETECT BIT(16) /* Platform boot firmware can detect the device. */ +#define DOD_DID_STD BIT(31) /* DID Scheme: Use standard bit-field definitions */ +enum display_type { + other = 0, + vga = 1, /* VGA, CRT, VESA monitor */ + tv = 2, /* TV/HDTV or analog monitor */ + ext = 3, /* External digital monitor (DVI, HDMI, DP) */ + panel = 4, /* Internal/integrated digital flat panel */ +}; + /* Config for electronic privacy screen */ struct drivers_gfx_generic_privacy_screen_config { /* Is privacy screen available on this graphics device */ @@ -32,7 +43,10 @@ struct drivers_gfx_generic_device_config { const char *name; /* Value to use for _HID Name, will take precedence over _ADR */ const char *hid; - /* The address of the output device. See section A.3.2 */ + /* The display type of the output device. See definition above */ + enum display_type type; + /* The address of the output device. + Will be dynamically generated if not set and display_type is set */ unsigned int addr; /* Electronic privacy screen specific config */ struct drivers_gfx_generic_privacy_screen_config privacy; diff --git a/src/drivers/gfx/generic/generic.c b/src/drivers/gfx/generic/generic.c index e3ae62f588..cd323142da 100644 --- a/src/drivers/gfx/generic/generic.c +++ b/src/drivers/gfx/generic/generic.c @@ -114,8 +114,16 @@ static void gfx_fill_ssdt_generator(const struct device *dev) acpigen_write_method("_DOD", 0); acpigen_emit_byte(RETURN_OP); acpigen_write_package(config->device_count); - for (i = 0; i < config->device_count; i++) + for (i = 0; i < config->device_count; i++) { + /* Generate the Device ID if addr = 0 and type != 0 */ + if (!config->device[i].addr && config->device[i].type) + /* Though not strictly necessary, set the display index and + port attachment to the device index, to ensure uniqueness */ + config->device[i].addr = DOD_DID_STD | DOD_FW_DETECT | \ + (config->device[i].type << 8) | \ + (i << 4) | (i); acpigen_write_dword(config->device[i].addr); + } acpigen_pop_len(); /* End Package. */ acpigen_pop_len(); /* End Method. */