From: "Mario Limonciello (AMD)" <[email protected]>

[Why]
The AMD VSDB contains two bits that indicate the type of panel connected.
This can be useful for policy decisions based upon panel technology.

[How]
Read the bits for the panel type when parsing VSDB and store them in
the dc_link.

Reviewed-by: Harry Wentland <[email protected]>
Signed-off-by: Mario Limonciello (AMD) <[email protected]>
Signed-off-by: Matthew Stewart <[email protected]>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 15 +++++++++++++++
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 11 +++++++++++
 drivers/gpu/drm/amd/display/dc/dc.h               |  1 +
 drivers/gpu/drm/amd/display/dc/dc_types.h         |  7 +++++++
 4 files changed, 34 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index fc5ceec5459f..b22925d1a59f 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -13110,9 +13110,24 @@ static int parse_amd_vsdb(struct amdgpu_dm_connector 
*aconnector,
 
                if (ieeeId == 
HDMI_AMD_VENDOR_SPECIFIC_DATA_BLOCK_IEEE_REGISTRATION_ID &&
                                amd_vsdb->version == 
HDMI_AMD_VENDOR_SPECIFIC_DATA_BLOCK_VERSION_3) {
+                       u8 panel_type;
                        vsdb_info->replay_mode = (amd_vsdb->feature_caps & 
AMD_VSDB_VERSION_3_FEATURECAP_REPLAYMODE) ? true : false;
                        vsdb_info->amd_vsdb_version = 
HDMI_AMD_VENDOR_SPECIFIC_DATA_BLOCK_VERSION_3;
                        drm_dbg_kms(aconnector->base.dev, "Panel supports 
Replay Mode: %d\n", vsdb_info->replay_mode);
+                       panel_type = (amd_vsdb->color_space_eotf_support & 
AMD_VDSB_VERSION_3_PANEL_TYPE_MASK) >> AMD_VDSB_VERSION_3_PANEL_TYPE_SHIFT;
+                       switch (panel_type) {
+                       case AMD_VSDB_PANEL_TYPE_OLED:
+                               aconnector->dc_link->panel_type = 
PANEL_TYPE_OLED;
+                               break;
+                       case AMD_VSDB_PANEL_TYPE_MINILED:
+                               aconnector->dc_link->panel_type = 
PANEL_TYPE_MINILED;
+                               break;
+                       default:
+                               aconnector->dc_link->panel_type = 
PANEL_TYPE_NONE;
+                               break;
+                       }
+                       drm_dbg_kms(aconnector->base.dev, "Panel type: %d\n",
+                                   aconnector->dc_link->panel_type);
 
                        return true;
                }
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
index 5775c722dd92..0855237ff048 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
@@ -55,8 +55,17 @@
 
 #define HDMI_AMD_VENDOR_SPECIFIC_DATA_BLOCK_IEEE_REGISTRATION_ID 0x00001A
 #define AMD_VSDB_VERSION_3_FEATURECAP_REPLAYMODE 0x40
+#define AMD_VDSB_VERSION_3_PANEL_TYPE_MASK 0xC0
+#define AMD_VDSB_VERSION_3_PANEL_TYPE_SHIFT 6
 #define HDMI_AMD_VENDOR_SPECIFIC_DATA_BLOCK_VERSION_3 0x3
 
+enum amd_vsdb_panel_type {
+       AMD_VSDB_PANEL_TYPE_DEFAULT = 0,
+       AMD_VSDB_PANEL_TYPE_MINILED,
+       AMD_VSDB_PANEL_TYPE_OLED,
+       AMD_VSDB_PANEL_TYPE_RESERVED,
+};
+
 #define AMDGPU_HDR_MULT_DEFAULT (0x100000000LL)
 
 #define AMDGPU_DM_HDMI_HPD_DEBOUNCE_MS 1500
@@ -89,6 +98,8 @@ struct amd_vsdb_block {
        unsigned char ieee_id[3];
        unsigned char version;
        unsigned char feature_caps;
+       unsigned char reserved[3];
+       unsigned char color_space_eotf_support;
 };
 
 struct common_irq_params {
diff --git a/drivers/gpu/drm/amd/display/dc/dc.h 
b/drivers/gpu/drm/amd/display/dc/dc.h
index 6daa35cd96a8..94f62cf2cd30 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -1734,6 +1734,7 @@ struct dc_scratch_space {
        bool link_powered_externally;   // Used to bypass hardware sequencing 
delays when panel is powered down forcibly
 
        struct dc_panel_config panel_config;
+       enum dc_panel_type panel_type;
        struct phy_state phy_state;
        uint32_t phy_transition_bitmask;
        // BW ALLOCATON USB4 ONLY
diff --git a/drivers/gpu/drm/amd/display/dc/dc_types.h 
b/drivers/gpu/drm/amd/display/dc/dc_types.h
index bb1387233bd8..0e953059ff6d 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_types.h
+++ b/drivers/gpu/drm/amd/display/dc/dc_types.h
@@ -964,6 +964,13 @@ struct display_endpoint_id {
        enum display_endpoint_type ep_type;
 };
 
+enum dc_panel_type {
+       PANEL_TYPE_NONE = 0, // UNKONWN, not determined yet
+       PANEL_TYPE_LCD = 1,
+       PANEL_TYPE_OLED = 2,
+       PANEL_TYPE_MINILED = 3,
+};
+
 enum backlight_control_type {
        BACKLIGHT_CONTROL_PWM = 0,
        BACKLIGHT_CONTROL_VESA_AUX = 1,
-- 
2.52.0

Reply via email to