[gnome-flashback] edid: parse CTA-861 Colorimetry Data Block (CDB)



commit 5d64fad9476ed4a43914b8dc197328fccd989c2c
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Sat Aug 13 15:44:50 2022 +0300

    edid: parse CTA-861 Colorimetry Data Block (CDB)
    
    Based on mutter commit:
    https://gitlab.gnome.org/GNOME/mutter/-/commit/80626edfea576c440e4f

 backends/gf-edid-parse.c   | 15 +++++++++++++++
 backends/gf-edid-private.h | 16 ++++++++++++++++
 2 files changed, 31 insertions(+)
---
diff --git a/backends/gf-edid-parse.c b/backends/gf-edid-parse.c
index 10eab99..5c1d16e 100644
--- a/backends/gf-edid-parse.c
+++ b/backends/gf-edid-parse.c
@@ -43,6 +43,7 @@
 #define EDID_EXT_CTA_DESCRIPTOR_OFFSET_ADDR               0x02
 #define EDID_EXT_CTA_DATA_BLOCK_OFFSET                    0x04
 #define EDID_EXT_CTA_TAG_EXTENDED                         0x07
+#define EDID_EXT_CTA_TAG_EXTENDED_COLORIMETRY             0x0705
 
 static int
 get_bit (int in, int bit)
@@ -557,6 +558,15 @@ decode_descriptors (const uint8_t *edid,
   return TRUE;
 }
 
+static gboolean
+decode_ext_cta_colorimetry (const uint8_t *data_block,
+                            GfEdidInfo    *info)
+{
+  /* CTA-861-H: Table 78 - Colorimetry Data Block (CDB) */
+  info->colorimetry = (data_block[3] << 8) + data_block[2];
+  return TRUE;
+}
+
 static gboolean
 decode_ext_cta (const uint8_t *cta_block,
                 GfEdidInfo    *info)
@@ -603,6 +613,11 @@ decode_ext_cta (const uint8_t *cta_block,
 
       switch (tag)
         {
+          case EDID_EXT_CTA_TAG_EXTENDED_COLORIMETRY:
+            if (!decode_ext_cta_colorimetry (data_block, info))
+              return FALSE;
+            break;
+
           default:
             break;
         }
diff --git a/backends/gf-edid-private.h b/backends/gf-edid-private.h
index 14e95a5..5a7f7dd 100644
--- a/backends/gf-edid-private.h
+++ b/backends/gf-edid-private.h
@@ -58,6 +58,20 @@ typedef enum
   GF_EDID_STEREO_TYPE_SIDE_BY_SIDE
 } GfEdidStereoType;
 
+typedef enum
+{
+  GF_EDID_COLORIMETRY_XVYCC601    = (1 << 0),
+  GF_EDID_COLORIMETRY_XVYCC709    = (1 << 1),
+  GF_EDID_COLORIMETRY_SYCC601     = (1 << 2),
+  GF_EDID_COLORIMETRY_OPYCC601    = (1 << 3),
+  GF_EDID_COLORIMETRY_OPRGB       = (1 << 4),
+  GF_EDID_COLORIMETRY_BT2020CYCC  = (1 << 5),
+  GF_EDID_COLORIMETRY_BT2020YCC   = (1 << 6),
+  GF_EDID_COLORIMETRY_BT2020RGB   = (1 << 7),
+  GF_EDID_COLORIMETRY_ST2113RGB   = (1 << 14),
+  GF_EDID_COLORIMETRY_ICTCP       = (1 << 15),
+} GfEdidColorimetry;
+
 struct _GfEdidTiming
 {
   int width;
@@ -185,6 +199,8 @@ struct _GfEdidInfo
   char           dsc_serial_number[14];
   char           dsc_product_name[14];
   char           dsc_string[14];        /* Unspecified ASCII data */
+
+  GfEdidColorimetry colorimetry;
 };
 
 GfEdidInfo *gf_edid_info_new_parse (const uint8_t *data);


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