Skip to content

Commit e85959d

Browse files
uma-intelvsyrjala
authored andcommitted
drm: Parse HDR metadata info from EDID
HDR metadata block is introduced in CEA-861.3 spec. Parsing the same to get the panel's HDR metadata. v2: Rebase and added Ville's POC changes to the patch. v3: No Change v4: Addressed Shashank's review comments v5: Addressed Shashank's comment and added his RB. v6: Addressed Jonas Karlman review comments. v7: Adressed Ville's review comments and fixed the issue with length handling. v8: Put the length check as per the convention followed in existing code, as suggested by Ville. Signed-off-by: Uma Shankar <[email protected]> Reviewed-by: Shashank Sharma <[email protected]> Signed-off-by: Ville Syrjälä <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent c0b0ebb commit e85959d

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

drivers/gpu/drm/drm_edid.c

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2852,6 +2852,7 @@ add_detailed_modes(struct drm_connector *connector, struct edid *edid,
28522852
#define VIDEO_BLOCK 0x02
28532853
#define VENDOR_BLOCK 0x03
28542854
#define SPEAKER_BLOCK 0x04
2855+
#define HDR_STATIC_METADATA_BLOCK 0x6
28552856
#define USE_EXTENDED_TAG 0x07
28562857
#define EXT_VIDEO_CAPABILITY_BLOCK 0x00
28572858
#define EXT_VIDEO_DATA_BLOCK_420 0x0E
@@ -3834,6 +3835,54 @@ static void fixup_detailed_cea_mode_clock(struct drm_display_mode *mode)
38343835
mode->clock = clock;
38353836
}
38363837

3838+
static bool cea_db_is_hdmi_hdr_metadata_block(const u8 *db)
3839+
{
3840+
if (cea_db_tag(db) != USE_EXTENDED_TAG)
3841+
return false;
3842+
3843+
if (db[1] != HDR_STATIC_METADATA_BLOCK)
3844+
return false;
3845+
3846+
if (cea_db_payload_len(db) < 3)
3847+
return false;
3848+
3849+
return true;
3850+
}
3851+
3852+
static uint8_t eotf_supported(const u8 *edid_ext)
3853+
{
3854+
return edid_ext[2] &
3855+
(BIT(HDMI_EOTF_TRADITIONAL_GAMMA_SDR) |
3856+
BIT(HDMI_EOTF_TRADITIONAL_GAMMA_HDR) |
3857+
BIT(HDMI_EOTF_SMPTE_ST2084));
3858+
}
3859+
3860+
static uint8_t hdr_metadata_type(const u8 *edid_ext)
3861+
{
3862+
return edid_ext[3] &
3863+
BIT(HDMI_STATIC_METADATA_TYPE1);
3864+
}
3865+
3866+
static void
3867+
drm_parse_hdr_metadata_block(struct drm_connector *connector, const u8 *db)
3868+
{
3869+
u16 len;
3870+
3871+
len = cea_db_payload_len(db);
3872+
3873+
connector->hdr_sink_metadata.hdmi_type1.eotf =
3874+
eotf_supported(db);
3875+
connector->hdr_sink_metadata.hdmi_type1.metadata_type =
3876+
hdr_metadata_type(db);
3877+
3878+
if (len >= 4)
3879+
connector->hdr_sink_metadata.hdmi_type1.max_cll = db[4];
3880+
if (len >= 5)
3881+
connector->hdr_sink_metadata.hdmi_type1.max_fall = db[5];
3882+
if (len >= 6)
3883+
connector->hdr_sink_metadata.hdmi_type1.min_cll = db[6];
3884+
}
3885+
38373886
static void
38383887
drm_parse_hdmi_vsdb_audio(struct drm_connector *connector, const u8 *db)
38393888
{
@@ -4461,6 +4510,8 @@ static void drm_parse_cea_ext(struct drm_connector *connector,
44614510
drm_parse_y420cmdb_bitmap(connector, db);
44624511
if (cea_db_is_vcdb(db))
44634512
drm_parse_vcdb(connector, db);
4513+
if (cea_db_is_hdmi_hdr_metadata_block(db))
4514+
drm_parse_hdr_metadata_block(connector, db);
44644515
}
44654516
}
44664517

0 commit comments

Comments
 (0)