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



commit 5aa3089065910a3eace10a5159d7171b449ec5f4
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Sat Aug 13 15:47:54 2022 +0300

    edid: Parse CTA-861 HDR Static Metadata Data Block
    
    Based on mutter commit:
    https://gitlab.gnome.org/GNOME/mutter/-/commit/64362fcd76ea4c15b1af

 backends/gf-edid-parse.c   | 28 ++++++++++++++++++++++++++++
 backends/gf-edid-private.h | 25 +++++++++++++++++++++++++
 2 files changed, 53 insertions(+)
---
diff --git a/backends/gf-edid-parse.c b/backends/gf-edid-parse.c
index 5c1d16e..d4ef1ea 100644
--- a/backends/gf-edid-parse.c
+++ b/backends/gf-edid-parse.c
@@ -44,6 +44,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)
@@ -567,6 +568,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,
+                                    GfEdidInfo    *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,
                 GfEdidInfo    *info)
@@ -618,6 +641,11 @@ decode_ext_cta (const uint8_t *cta_block,
               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;
+
           default:
             break;
         }
diff --git a/backends/gf-edid-private.h b/backends/gf-edid-private.h
index 5a7f7dd..e1df8fd 100644
--- a/backends/gf-edid-private.h
+++ b/backends/gf-edid-private.h
@@ -28,6 +28,7 @@ G_BEGIN_DECLS
 typedef struct _GfEdidInfo GfEdidInfo;
 typedef struct _GfEdidTiming GfEdidTiming;
 typedef struct _GfEdidDetailedTiming GfEdidDetailedTiming;
+typedef struct _GfEdidHdrStaticMetadata GfEdidHdrStaticMetadata;
 
 typedef enum
 {
@@ -72,6 +73,19 @@ typedef enum
   GF_EDID_COLORIMETRY_ICTCP       = (1 << 15),
 } GfEdidColorimetry;
 
+typedef enum
+{
+  GF_EDID_TF_TRADITIONAL_GAMMA_SDR = (1 << 0),
+  GF_EDID_TF_TRADITIONAL_GAMMA_HDR = (1 << 1),
+  GF_EDID_TF_PQ                    = (1 << 2),
+  GF_EDID_TF_HLG                   = (1 << 3),
+} GfEdidTransferFunction;
+
+typedef enum
+{
+  GF_EDID_STATIC_METADATA_TYPE1 = 0,
+} GfEdidStaticMetadataType;
+
 struct _GfEdidTiming
 {
   int width;
@@ -117,6 +131,16 @@ struct _GfEdidDetailedTiming
   } connector;
 };
 
+struct _GfEdidHdrStaticMetadata
+{
+  int                      available;
+  int                      max_luminance;
+  int                      min_luminance;
+  int                      max_fal;
+  GfEdidTransferFunction   tf;
+  GfEdidStaticMetadataType sm;
+};
+
 struct _GfEdidInfo
 {
   int            checksum;
@@ -201,6 +225,7 @@ struct _GfEdidInfo
   char           dsc_string[14];        /* Unspecified ASCII data */
 
   GfEdidColorimetry colorimetry;
+  GfEdidHdrStaticMetadata hdr_static_metadata;
 };
 
 GfEdidInfo *gf_edid_info_new_parse (const uint8_t *data);


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