[mutter] edid: Parse CTA-861 HDR Static Metadata Data Block



commit 64362fcd76ea4c15b1afd0b4563d765b56497034
Author: Sebastian Wick <sebastian wick redhat com>
Date:   Fri Mar 18 22:02:13 2022 +0100

    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>

 src/backends/edid-parse.c | 27 +++++++++++++++++++++++++++
 src/backends/edid.h       | 25 +++++++++++++++++++++++++
 2 files changed, 52 insertions(+)
---
diff --git a/src/backends/edid-parse.c b/src/backends/edid-parse.c
index fe262a6259..f0bc6de67a 100644
--- a/src/backends/edid-parse.c
+++ b/src/backends/edid-parse.c
@@ -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;
         }
     }
 
diff --git a/src/backends/edid.h b/src/backends/edid.h
index 91ac0ddb16..dda63dbd86 100644
--- a/src/backends/edid.h
+++ b/src/backends/edid.h
@@ -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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]