[mutter] edid: Parse CTA-861 Colorimetry Data Block (CDB)



commit 80626edfea576c440e4f612fc34b965340fc537b
Author: Sebastian Wick <sebastian wick redhat com>
Date:   Tue Mar 29 15:25:31 2022 +0200

    edid: Parse CTA-861 Colorimetry Data Block (CDB)
    
    Parses the CTA-861 extensions data blocks to extract the supported
    colorimetry which can be set with the KMS connectors `Colorspace`
    property.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2351>

 src/backends/edid-parse.c | 14 ++++++++++++++
 src/backends/edid.h       | 16 ++++++++++++++++
 2 files changed, 30 insertions(+)
---
diff --git a/src/backends/edid-parse.c b/src/backends/edid-parse.c
index c3c3f0a94a..fe262a6259 100644
--- a/src/backends/edid-parse.c
+++ b/src/backends/edid-parse.c
@@ -44,6 +44,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)
@@ -554,6 +555,15 @@ decode_descriptors (const uint8_t *edid,
   return TRUE;
 }
 
+static gboolean
+decode_ext_cta_colorimetry (const uint8_t *data_block,
+                            MetaEdidInfo  *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,
                 MetaEdidInfo  *info)
@@ -600,6 +610,10 @@ 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;
         }
     }
 
diff --git a/src/backends/edid.h b/src/backends/edid.h
index 52d9f7841b..91ac0ddb16 100644
--- a/src/backends/edid.h
+++ b/src/backends/edid.h
@@ -60,6 +60,20 @@ typedef enum
   META_EDID_STEREO_TYPE_SIDE_BY_SIDE
 } MetaEdidStereoType;
 
+typedef enum
+{
+  META_EDID_COLORIMETRY_XVYCC601    = (1 << 0),
+  META_EDID_COLORIMETRY_XVYCC709    = (1 << 1),
+  META_EDID_COLORIMETRY_SYCC601     = (1 << 2),
+  META_EDID_COLORIMETRY_OPYCC601    = (1 << 3),
+  META_EDID_COLORIMETRY_OPRGB       = (1 << 4),
+  META_EDID_COLORIMETRY_BT2020CYCC  = (1 << 5),
+  META_EDID_COLORIMETRY_BT2020YCC   = (1 << 6),
+  META_EDID_COLORIMETRY_BT2020RGB   = (1 << 7),
+  META_EDID_COLORIMETRY_ST2113RGB   = (1 << 14),
+  META_EDID_COLORIMETRY_ICTCP       = (1 << 15),
+} MetaEdidColorimetry;
+
 struct _MetaEdidTiming
 {
   int width;
@@ -187,6 +201,8 @@ struct _MetaEdidInfo
   char         dsc_serial_number[14];
   char         dsc_product_name[14];
   char         dsc_string[14];         /* Unspecified ASCII data */
+
+  MetaEdidColorimetry colorimetry;
 };
 
 MetaEdidInfo *meta_edid_info_new_parse (const uint8_t *data);


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