edid: Parse CTA-861 HDR Static Metadata Data Block

Extract the supported HDR metadata type, supported Transfer Functions,
and display luminance characteristics.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2351>
This commit is contained in:
Sebastian Wick 2022-03-18 22:02:13 +01:00 committed by Jonas Ådahl
parent 80626edfea
commit 64362fcd76
2 changed files with 52 additions and 0 deletions

View File

@ -45,6 +45,7 @@
#define EDID_EXT_CTA_DATA_BLOCK_OFFSET 0x04
#define EDID_EXT_CTA_TAG_EXTENDED 0x07
#define EDID_EXT_CTA_TAG_EXTENDED_COLORIMETRY 0x0705
#define EDID_EXT_CTA_TAG_EXTENDED_HDR_STATIC_METADATA 0x0706
static int
get_bit (int in, int bit)
@ -564,6 +565,28 @@ decode_ext_cta_colorimetry (const uint8_t *data_block,
return TRUE;
}
static gboolean
decode_ext_cta_hdr_static_metadata (const uint8_t *data_block,
MetaEdidInfo *info)
{
/* CTA-861-H: Table 92 - HDR Static Metadata Data Block (HDR SMDB) */
int size;
info->hdr_static_metadata.available = TRUE;
info->hdr_static_metadata.tf = data_block[2];
info->hdr_static_metadata.sm = data_block[3];
size = get_bits (data_block[0], 0, 5);
if (size > 3)
info->hdr_static_metadata.max_luminance = data_block[4];
if (size > 4)
info->hdr_static_metadata.max_fal = data_block[5];
if (size > 5)
info->hdr_static_metadata.min_luminance = data_block[6];
return TRUE;
}
static gboolean
decode_ext_cta (const uint8_t *cta_block,
MetaEdidInfo *info)
@ -614,6 +637,10 @@ decode_ext_cta (const uint8_t *cta_block,
if (!decode_ext_cta_colorimetry (data_block, info))
return FALSE;
break;
case EDID_EXT_CTA_TAG_EXTENDED_HDR_STATIC_METADATA:
if (!decode_ext_cta_hdr_static_metadata (data_block, info))
return FALSE;
break;
}
}

View File

@ -30,6 +30,7 @@
typedef struct _MetaEdidInfo MetaEdidInfo;
typedef struct _MetaEdidTiming MetaEdidTiming;
typedef struct _MetaEdidDetailedTiming MetaEdidDetailedTiming;
typedef struct _MetaEdidHdrStaticMetadata MetaEdidHdrStaticMetadata;
typedef enum
{
@ -74,6 +75,19 @@ typedef enum
META_EDID_COLORIMETRY_ICTCP = (1 << 15),
} MetaEdidColorimetry;
typedef enum
{
META_EDID_TF_TRADITIONAL_GAMMA_SDR = (1 << 0),
META_EDID_TF_TRADITIONAL_GAMMA_HDR = (1 << 1),
META_EDID_TF_PQ = (1 << 2),
META_EDID_TF_HLG = (1 << 3),
} MetaEdidTransferFunction;
typedef enum
{
META_EDID_STATIC_METADATA_TYPE1 = 0,
} MetaEdidStaticMetadataType;
struct _MetaEdidTiming
{
int width;
@ -119,6 +133,16 @@ struct _MetaEdidDetailedTiming
} connector;
};
struct _MetaEdidHdrStaticMetadata
{
int available;
int max_luminance;
int min_luminance;
int max_fal;
MetaEdidTransferFunction tf;
MetaEdidStaticMetadataType sm;
};
struct _MetaEdidInfo
{
int checksum;
@ -203,6 +227,7 @@ struct _MetaEdidInfo
char dsc_string[14]; /* Unspecified ASCII data */
MetaEdidColorimetry colorimetry;
MetaEdidHdrStaticMetadata hdr_static_metadata;
};
MetaEdidInfo *meta_edid_info_new_parse (const uint8_t *data);