Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Gil Dekel <gildekel@google.com>
To: igt-dev@lists.freedesktop.org
Cc: Gil Dekel <gildekel@google.com>,
	Swati Sharma <swati2.sharma@intel.com>,
	 Karthik B S <karthik.b.s@intel.com>,
	Mark Yacoub <markyacoub@google.com>
Subject: [PATCH i-g-t v2 2/3] lib/igt_hdr: Parse DisplayID CTA data blocks
Date: Sat, 14 Nov 2026 19:19:03 -0500	[thread overview]
Message-ID: <20261115001917.2933254-3-gildekel@google.com> (raw)
In-Reply-To: <20261115001917.2933254-1-gildekel@google.com>

Some eDP OLED panels carry DisplayID 2.0 extensions with a CTA data
block (tag 0x81) containing an HDR Static Metadata Data Block instead
of a CTA-861 extension block. igt_is_edid_hdr() only inspects CTA-861
extensions, so it reports such panels as SDR. kms_hdr then runs the
negative invalid-hdr subtest on them, which fails because the panel
accepts the SMPTE ST 2084 EOTF.

Also walk DisplayID extensions and scan each CTA data block (tag 0x81)
with cta_data_blocks_have_hdr(), bounded by the DisplayID section
length before the trailing section checksum.

Extend lib/tests/igt_hdr with synthetic DisplayID CTA test cases for
HDR, SDR-only, and a CTA data block that overflows the DisplayID
section.

Cc: Swati Sharma <swati2.sharma@intel.com>
Cc: Karthik B S <karthik.b.s@intel.com>
Cc: Mark Yacoub <markyacoub@google.com>
Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Gil Dekel <gildekel@google.com>
---

Notes:
    v2: Apologies for the v1 bloat from agent-assisted drafting;
        replace the raw panel EDID dump with a synthetic
        make_displayid_cta_edid() helper.

 lib/igt_hdr.c       | 40 +++++++++++++++++++++++++++++++++++++--
 lib/tests/igt_hdr.c | 46 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 84 insertions(+), 2 deletions(-)

diff --git a/lib/igt_hdr.c b/lib/igt_hdr.c
index 8c36a035e..2d2893588 100644
--- a/lib/igt_hdr.c
+++ b/lib/igt_hdr.c
@@ -27,6 +27,7 @@
 #define CTA_DATA_BLOCK_OFFSET		4
 #define HDR_STATIC_METADATA_BLOCK	0x06
 #define USE_EXTENDED_TAG		0x07
+#define DISPLAYID_DATA_BLOCK_CTA	0x81
 
 static bool cta_block(const char *edid_ext)
 {
@@ -88,14 +89,45 @@ static bool cta_ext_has_hdr(const struct edid_cea *cea)
 	       cta_data_blocks_have_hdr((const uint8_t *)cea->data, len);
 }
 
+/*
+ * Some eDP OLED panels advertise HDR through a CTA data block (tag 0x81)
+ * inside a DisplayID extension rather than a CTA-861 extension block.
+ */
+static bool displayid_ext_has_hdr(const struct edid_dispid *dispid)
+{
+	/* The section checksum follows the data blocks inside data[]. */
+	int end = min_t(int, dispid->header.num_bytes,
+			sizeof(dispid->data) - 1);
+	const uint8_t *data = (const uint8_t *)dispid->data;
+	int i = 0;
+
+	while (i + (int)sizeof(struct dispid_block_header) <= end) {
+		const struct dispid_block_header *block =
+			(const struct dispid_block_header *)&data[i];
+		int payload = i + sizeof(*block);
+
+		if (payload + block->num_bytes > end)
+			break;
+
+		if (block->tag == DISPLAYID_DATA_BLOCK_CTA &&
+		    cta_data_blocks_have_hdr(&data[payload], block->num_bytes))
+			return true;
+
+		i = payload + block->num_bytes;
+	}
+
+	return false;
+}
+
 /**
  * igt_is_edid_hdr:
  * @data: raw EDID, the base block followed by its extension blocks
  * @size: size of @data in bytes
  *
  * Looks for an HDR Static Metadata Block in the CTA extensions of an
- * EDID. A sink is considered HDR-capable when it advertises support for
- * Traditional Gamma HDR or SMPTE ST 2084 EOTFs. Never reads past @size.
+ * EDID, and in the CTA data blocks of its DisplayID extensions. A sink is
+ * considered HDR-capable when it advertises support for Traditional
+ * Gamma HDR or SMPTE ST 2084 EOTFs. Never reads past @size.
  *
  * Returns: true if the EDID advertises HDR support, false otherwise.
  */
@@ -116,6 +148,10 @@ bool igt_is_edid_hdr(const void *data, size_t size)
 
 		if (ext->tag == EDID_EXT_CEA && cta_ext_has_hdr(&ext->data.cea))
 			return true;
+
+		if (ext->tag == EDID_EXT_DISPLAYID &&
+		    displayid_ext_has_hdr(&ext->data.dispid))
+			return true;
 	}
 
 	return false;
diff --git a/lib/tests/igt_hdr.c b/lib/tests/igt_hdr.c
index 628d4b2e6..c24f7c94b 100644
--- a/lib/tests/igt_hdr.c
+++ b/lib/tests/igt_hdr.c
@@ -33,6 +33,37 @@ static void make_cta_edid(uint8_t edid[2 * EDID_BLOCK_SIZE], uint8_t eotf)
 	cta[7] = 0x01;	/* static metadata descriptor type 1 */
 }
 
+/*
+ * Base block plus one DisplayID 2.0 extension carrying a non-CTA data
+ * block followed by a CTA data block (tag 0x81) whose HDR Static Metadata
+ * Data Block advertises @eotf.
+ */
+static void make_displayid_cta_edid(uint8_t edid[2 * EDID_BLOCK_SIZE],
+				    uint8_t eotf, uint8_t cta_block_len)
+{
+	uint8_t *ext = edid + EDID_BLOCK_SIZE;
+
+	memset(edid, 0, 2 * EDID_BLOCK_SIZE);
+	memcpy(edid, edid_header, sizeof(edid_header));
+	edid[126] = 1;	/* extension count */
+
+	ext[0] = 0x70;	/* DisplayID extension tag */
+	ext[1] = 0x20;	/* DisplayID 2.0 revision */
+	ext[2] = 0x0b;	/* section payload size: 4-byte block + 7-byte CTA block */
+
+	/* Preceding non-CTA DisplayID data block (tag 0x20, 1 payload byte). */
+	ext[5] = 0x20;
+	ext[7] = 0x01;
+
+	/* DisplayID CTA data block (tag 0x81) containing a 4-byte HDR block. */
+	ext[9] = 0x81;
+	ext[11] = cta_block_len;
+	ext[12] = 0xe3;	/* extended tag data block, 3 payload bytes */
+	ext[13] = 0x06;	/* HDR Static Metadata Data Block */
+	ext[14] = eotf;
+	ext[15] = 0x01;	/* static metadata descriptor type 1 */
+}
+
 int igt_main()
 {
 	uint8_t edid[2 * EDID_BLOCK_SIZE];
@@ -51,4 +82,19 @@ int igt_main()
 		make_cta_edid(edid, 0x05);
 		igt_assert(!igt_is_edid_hdr(edid, EDID_BLOCK_SIZE));
 	}
+
+	igt_subtest("displayid-cta-hdr") {
+		make_displayid_cta_edid(edid, 0x05, 4);
+		igt_assert(igt_is_edid_hdr(edid, sizeof(edid)));
+	}
+
+	igt_subtest("displayid-cta-sdr-only") {
+		make_displayid_cta_edid(edid, 0x01, 4);
+		igt_assert(!igt_is_edid_hdr(edid, sizeof(edid)));
+	}
+
+	igt_subtest("displayid-cta-block-overflow") {
+		make_displayid_cta_edid(edid, 0x05, 0x7f);
+		igt_assert(!igt_is_edid_hdr(edid, sizeof(edid)));
+	}
 }
-- 
Gil Dekel, Software Engineer, Google / ChromeOS Display and Graphics


  parent reply	other threads:[~2026-11-16  5:21 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-14 22:29 [PATCH i-g-t 0/3] lib/igt_hdr: Find HDR in DisplayID EDIDs Gil Dekel
2026-11-14 22:29 ` [PATCH i-g-t 1/3] lib/igt_hdr: Add a testable igt_is_edid_hdr() Gil Dekel
2026-11-14 22:29 ` [PATCH i-g-t 2/3] lib/igt_hdr: Parse DisplayID CTA data blocks Gil Dekel
2026-11-14 22:29 ` [PATCH i-g-t 3/3] tests/kms_hdr: Use /dev/kmsg in invalid-hdr Gil Dekel
2026-11-15  0:19 ` [PATCH i-g-t v2 0/3] lib/igt_hdr: Find HDR in DisplayID EDIDs Gil Dekel
2026-11-15  0:19   ` [PATCH i-g-t v2 1/3] lib/igt_hdr: Add a testable igt_is_edid_hdr() Gil Dekel
2026-11-15  0:19   ` Gil Dekel [this message]
2026-11-15  0:19   ` [PATCH i-g-t v2 3/3] tests/kms_hdr: Use /dev/kmsg in invalid-hdr Gil Dekel
2026-11-16  7:51 ` ✓ Xe.CI.BAT: success for lib/igt_hdr: Find HDR in DisplayID EDIDs Patchwork
2026-11-16  8:07 ` ✓ i915.CI.BAT: " Patchwork
2026-11-16  9:07 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-11-16  9:40 ` [PATCH i-g-t 0/3] " Jani Nikula
2026-11-17  3:13   ` Gil Dekel
2026-11-16 11:26 ` ✗ i915.CI.Full: failure for " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261115001917.2933254-3-gildekel@google.com \
    --to=gildekel@google.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=karthik.b.s@intel.com \
    --cc=markyacoub@google.com \
    --cc=swati2.sharma@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox