* [PATCH v2 1/2] lib/igt_hdr: switch to libdisplay-info for EDID parsing
@ 2026-11-26 10:02 Simon Ser
2026-11-26 10:02 ` [PATCH v2 2/2] meson: require libdisplay-info v0.4.0 Simon Ser
2026-12-01 20:26 ` [PATCH v2 1/2] lib/igt_hdr: switch to libdisplay-info for EDID parsing Gil Dekel
0 siblings, 2 replies; 4+ messages in thread
From: Simon Ser @ 2026-11-26 10:02 UTC (permalink / raw)
To: igt-dev
Cc: Jani Nikula, Gil Dekel, Swati Sharma, Karthik B S, Mark Yacoub,
Kamil Konieczny, Ryszard Knop
Replace manual EDID/CTA parsing with libdisplay-info [1].
libdisplay-info is an EDID and DisplayID library. It's widely used
across Wayland compositors. It exposes both a high-level API
(with information collected across EDID/DisplayID/CTA blocks) and
a low-level API (exposing individual parsed fields from the
specifications).
Using libdisplay-info will allow IGT to drop all of its custom
parsing code. libdisplay-info takes care of the bitshifting and
value decoding. libdisplay-info has documentation, a test suite,
fuzzing, and a clone of edid-decode which can serve as an example
to figure out how to use the low-level API.
IGT has already quite a bit of hand-rolled parsing code, and we
need to start somewhere, so here is a patch leveraging
libdisplay-info for igt_hdr.
As a bonus, igt_hdr now extracts HDR static metadata from CTA
DisplayID blocks for free, because the high-level libdisplay-info
helper does this already (since version 0.4.0).
v2: drop unnecessary igt_edid.h includes, adjust doc comment (Gil)
[1]: https://gitlab.freedesktop.org/emersion/libdisplay-info
Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Cc: Gil Dekel <gildekel@google.com>
Cc: Swati Sharma <swati2.sharma@intel.com>
Cc: Karthik B S <karthik.b.s@intel.com>
Cc: Mark Yacoub <markyacoub@google.com>
Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>
Cc: Ryszard Knop <ryszard.knop@intel.com>
---
Dockerfile.build-debian-arm64 | 1 +
Dockerfile.build-debian-armhf | 1 +
Dockerfile.build-debian-minimal | 1 +
Dockerfile.build-fedora | 1 +
lib/igt_hdr.c | 71 +++++++--------------------------
lib/igt_hdr.h | 1 -
lib/meson.build | 1 +
meson.build | 1 +
8 files changed, 21 insertions(+), 57 deletions(-)
diff --git a/Dockerfile.build-debian-arm64 b/Dockerfile.build-debian-arm64
index 114b9760d1f6..7a9cd1915825 100644
--- a/Dockerfile.build-debian-arm64
+++ b/Dockerfile.build-debian-arm64
@@ -26,6 +26,7 @@ RUN apt-get install -y \
libpci-dev:arm64 \
libpixman-1-dev:arm64 \
libudev-dev:arm64 \
+ libdisplay-info-dev:arm64 \
libgsl-dev:arm64 \
libasound2-dev:arm64 \
libjansson-dev:arm64 \
diff --git a/Dockerfile.build-debian-armhf b/Dockerfile.build-debian-armhf
index c6527ea1eb2f..375f3e185bba 100644
--- a/Dockerfile.build-debian-armhf
+++ b/Dockerfile.build-debian-armhf
@@ -26,6 +26,7 @@ RUN apt-get install -y \
libpci-dev:armhf \
libpixman-1-dev:armhf \
libudev-dev:armhf \
+ libdisplay-info-dev:armhf \
libgsl-dev:armhf \
libasound2-dev:armhf \
libjansson-dev:armhf \
diff --git a/Dockerfile.build-debian-minimal b/Dockerfile.build-debian-minimal
index 573bb5139ceb..1d326250eef9 100644
--- a/Dockerfile.build-debian-minimal
+++ b/Dockerfile.build-debian-minimal
@@ -17,6 +17,7 @@ RUN apt-get install -y \
libpci-dev \
libpixman-1-dev \
libudev-dev \
+ libdisplay-info-dev \
libxrandr-dev \
libxv-dev \
x11proto-dri2-dev \
diff --git a/Dockerfile.build-fedora b/Dockerfile.build-fedora
index aacc6a87c844..db7618325a67 100644
--- a/Dockerfile.build-fedora
+++ b/Dockerfile.build-fedora
@@ -14,6 +14,7 @@ RUN dnf install -y \
'pkgconfig(cairo)' \
'pkgconfig(libpci)' \
'pkgconfig(libudev)' \
+ 'pkgconfig(libdisplay-info)' \
'pkgconfig(glib-2.0)' \
'pkgconfig(gsl)' \
'pkgconfig(alsa)' \
diff --git a/lib/igt_hdr.c b/lib/igt_hdr.c
index c0ed9e843163..c8d9c6ab0cd0 100644
--- a/lib/igt_hdr.c
+++ b/lib/igt_hdr.c
@@ -4,13 +4,14 @@
*/
#include "igt.h"
-#include "igt_edid.h"
#include "igt_hdr.h"
#include <fcntl.h>
#include <termios.h>
#include <unistd.h>
+#include <libdisplay-info/info.h>
+
/**
* SECTION:igt_hdr
* @short_description: HDR metadata helpers
@@ -22,54 +23,25 @@
* output metadata construction, and blob programming utilities.
*/
-/* HDR EDID parsing. */
-#define CTA_EXTENSION_VERSION 0x03
-#define HDR_STATIC_METADATA_BLOCK 0x06
-#define USE_EXTENDED_TAG 0x07
-
-static bool cta_block(const char *edid_ext)
-{
- /*
- * Byte 1: 0x07 indicates Extended Tag
- * Byte 2: 0x06 indicates HDMI Static Metadata Block
- * Byte 3: bits 0 to 5 identify EOTF functions supported by sink
- * where ET_0: Traditional Gamma - SDR Luminance Range
- * ET_1: Traditional Gamma - HDR Luminance Range
- * ET_2: SMPTE ST 2084
- * ET_3: Hybrid Log-Gamma (HLG)
- * ET_4 to ET_5: Reserved for future use
- */
-
- if ((((edid_ext[0] & 0xe0) >> 5 == USE_EXTENDED_TAG) &&
- (edid_ext[1] == HDR_STATIC_METADATA_BLOCK)) &&
- (edid_ext[2] & ((1 << HDMI_EOTF_TRADITIONAL_GAMMA_HDR) |
- (1 << HDMI_EOTF_SMPTE_ST2084))))
- return true;
-
- return false;
-}
-
/**
* igt_is_panel_hdr:
* @fd: DRM file descriptor
* @output: output to check
*
* Parses the EDID of the given output looking for an HDR Static Metadata
- * Block in the CTA extension. A panel is considered HDR-capable when it
- * advertises support for Traditional Gamma HDR or SMPTE ST 2084 EOTFs.
+ * Block in a CTA extension (either from EDID, or nested inside a DisplayID
+ * extension). A panel is considered HDR-capable when it advertises support
+ * for Traditional Gamma HDR or SMPTE ST 2084 EOTFs.
*
* Returns: true if the panel supports HDR, false otherwise.
*/
bool igt_is_panel_hdr(int fd, igt_output_t *output)
{
bool ok;
- int i, j, offset;
uint64_t edid_blob_id;
drmModePropertyBlobRes *edid_blob;
- const struct edid_ext *edid_ext;
- const struct edid *edid;
- const struct edid_cea *edid_cea;
- const char *cea_data;
+ struct di_info *info;
+ const struct di_hdr_static_metadata *hdr_static_metadata;
bool ret = false;
ok = kmstest_get_property(fd, output->id,
@@ -82,30 +54,17 @@ bool igt_is_panel_hdr(int fd, igt_output_t *output)
edid_blob = drmModeGetPropertyBlob(fd, edid_blob_id);
igt_assert(edid_blob);
- edid = (const struct edid *) edid_blob->data;
- igt_assert(edid);
-
- for (i = 0; i < edid->extensions_len; i++) {
- edid_ext = &edid->extensions[i];
- edid_cea = &edid_ext->data.cea;
-
- /* HDR not defined in CTA Extension Version < 3. */
- if ((edid_ext->tag != EDID_EXT_CEA) ||
- (edid_cea->revision != CTA_EXTENSION_VERSION))
- continue;
- else {
- offset = edid_cea->dtd_start;
- cea_data = edid_cea->data;
+ info = di_info_parse_edid(edid_blob->data, edid_blob->length);
+ if (!info) {
+ igt_warn("Failed to parse EDID for output %s\n", output->name);
+ return ret;
+ }
- for (j = 0; j < offset; j += (cea_data[j] & 0x1f) + 1) {
- ret = cta_block(cea_data + j);
+ hdr_static_metadata = di_info_get_hdr_static_metadata(info);
- if (ret)
- break;
- }
- }
- }
+ ret = hdr_static_metadata->traditional_hdr || hdr_static_metadata->pq;
+ di_info_destroy(info);
drmModeFreePropertyBlob(edid_blob);
return ret;
diff --git a/lib/igt_hdr.h b/lib/igt_hdr.h
index 15ce5f11734e..59b425ebe5c1 100644
--- a/lib/igt_hdr.h
+++ b/lib/igt_hdr.h
@@ -1,7 +1,6 @@
#ifndef IGT_HDR_H
#define IGT_HDR_H
-#include "igt_edid.h"
#include "igt_kms.h"
enum hdmi_eotf {
diff --git a/lib/meson.build b/lib/meson.build
index 3ed1369b53d1..cb861c472808 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -156,6 +156,7 @@ lib_deps = [
libkmod,
libpci,
libudev,
+ libdisplay_info,
math,
pciaccess,
pixman,
diff --git a/meson.build b/meson.build
index eec131375e06..e7c685116b13 100644
--- a/meson.build
+++ b/meson.build
@@ -151,6 +151,7 @@ build_info += 'Valgrind annotations: @0@'.format(valgrind.found())
cairo = dependency('cairo', version : '>1.12.0', required : true)
libpci = dependency('libpci', required : true)
libudev = dependency('libudev', required : true)
+libdisplay_info = dependency('libdisplay-info', required : true)
glib = dependency('glib-2.0', required : true)
libtsi = cc.find_library('TSI', required : false)
--
2.56.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH v2 2/2] meson: require libdisplay-info v0.4.0
2026-11-26 10:02 [PATCH v2 1/2] lib/igt_hdr: switch to libdisplay-info for EDID parsing Simon Ser
@ 2026-11-26 10:02 ` Simon Ser
2026-12-01 20:26 ` Gil Dekel
2026-12-01 20:26 ` [PATCH v2 1/2] lib/igt_hdr: switch to libdisplay-info for EDID parsing Gil Dekel
1 sibling, 1 reply; 4+ messages in thread
From: Simon Ser @ 2026-11-26 10:02 UTC (permalink / raw)
To: igt-dev
Cc: Gil Dekel, Jani Nikula, Swati Sharma, Karthik B S, Mark Yacoub,
Kamil Konieczny, Ryszard Knop
This version looks up CTA extension blocks nested inside a DisplayID
extension block. This is required for upcoming tests leveraging
igt_hdr helpers.
On systems not shipping a new enough libdisplay-info, a wrap file [1] is
provided so that Meson can automatically download and link to an
up-to-date subproject [2]. This eases developer setup when IGT is built
on distributions such as Debian. This behavior is typically disabled
when packaging software via the wrap_mode=nodownload option (see e.g.
the arch-meson wrapper [3] used for Arch Linux packaging).
A slightly newer commit is pulled in by the wrap to avoid compiling
a bunch of unnecessary v4l-utils code when libdisplay-info is used
as a subproject [4].
v2: new commit (Gil)
[1]: https://mesonbuild.com/Wrap-dependency-system-manual.html
[2]: https://mesonbuild.com/Subprojects.html
[3]: https://gitlab.archlinux.org/archlinux/packaging/packages/meson/-/blob/9fe4433580978cc020c813019b77238ce65ab38d/arch-meson#L19
[4]: https://gitlab.freedesktop.org/emersion/libdisplay-info/-/merge_requests/219
Signed-off-by: Simon Ser <contact@emersion.fr>
Cc: Gil Dekel <gildekel@google.com>
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Swati Sharma <swati2.sharma@intel.com>
Cc: Karthik B S <karthik.b.s@intel.com>
Cc: Mark Yacoub <markyacoub@google.com>
Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>
Cc: Ryszard Knop <ryszard.knop@intel.com>
---
meson.build | 2 +-
subprojects/libdisplay-info.wrap | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
create mode 100644 subprojects/libdisplay-info.wrap
diff --git a/meson.build b/meson.build
index e7c685116b13..ead7be9c5eb0 100644
--- a/meson.build
+++ b/meson.build
@@ -151,7 +151,7 @@ build_info += 'Valgrind annotations: @0@'.format(valgrind.found())
cairo = dependency('cairo', version : '>1.12.0', required : true)
libpci = dependency('libpci', required : true)
libudev = dependency('libudev', required : true)
-libdisplay_info = dependency('libdisplay-info', required : true)
+libdisplay_info = dependency('libdisplay-info', version : '>=0.4.0', required : true)
glib = dependency('glib-2.0', required : true)
libtsi = cc.find_library('TSI', required : false)
diff --git a/subprojects/libdisplay-info.wrap b/subprojects/libdisplay-info.wrap
new file mode 100644
index 000000000000..6a771b10030f
--- /dev/null
+++ b/subprojects/libdisplay-info.wrap
@@ -0,0 +1,3 @@
+[wrap-git]
+url = https://gitlab.freedesktop.org/emersion/libdisplay-info.git
+revision = 548330bca9bd3c6518cf4c6b38c954cfaabe782d
--
2.56.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v2 2/2] meson: require libdisplay-info v0.4.0
2026-11-26 10:02 ` [PATCH v2 2/2] meson: require libdisplay-info v0.4.0 Simon Ser
@ 2026-12-01 20:26 ` Gil Dekel
0 siblings, 0 replies; 4+ messages in thread
From: Gil Dekel @ 2026-12-01 20:26 UTC (permalink / raw)
To: Simon Ser
Cc: igt-dev, Jani Nikula, Swati Sharma, Karthik B S, Mark Yacoub,
Kamil Konieczny, Ryszard Knop
Hi Simon,
Keeping this as a separate commit makes sense to me.
Once v3 lands with the edid_blob fix in 1/2, happy to add my R-b here
(and I can test it for a T-b as well).
Thanks,
Gil
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/2] lib/igt_hdr: switch to libdisplay-info for EDID parsing
2026-11-26 10:02 [PATCH v2 1/2] lib/igt_hdr: switch to libdisplay-info for EDID parsing Simon Ser
2026-11-26 10:02 ` [PATCH v2 2/2] meson: require libdisplay-info v0.4.0 Simon Ser
@ 2026-12-01 20:26 ` Gil Dekel
1 sibling, 0 replies; 4+ messages in thread
From: Gil Dekel @ 2026-12-01 20:26 UTC (permalink / raw)
To: Simon Ser
Cc: igt-dev, Jani Nikula, Swati Sharma, Karthik B S, Mark Yacoub,
Kamil Konieczny, Ryszard Knop
Hi Simon,
Sorry for the late reply -- I was out for the US Thanksgiving holiday.
Thanks for addressing the v1 comments. One small leak spotted below on
the !info path; once that's fixed, feel free to add my Reviewed-by and
Tested-by.
On Thu, Nov 26, 2026 at 10:02:12AM +0000, Simon Ser wrote:
> + info = di_info_parse_edid(edid_blob->data, edid_blob->length);
> + if (!info) {
> + igt_warn("Failed to parse EDID for output %s\n", output->name);
> + return ret;
> + }
This returns early without calling drmModeFreePropertyBlob(edid_blob).
Jumping via goto out (placed right before drmModeFreePropertyBlob)
would keep the cleanup in one place.
Thanks,
Gil
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-12-01 20:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 10:02 [PATCH v2 1/2] lib/igt_hdr: switch to libdisplay-info for EDID parsing Simon Ser
2026-11-26 10:02 ` [PATCH v2 2/2] meson: require libdisplay-info v0.4.0 Simon Ser
2026-12-01 20:26 ` Gil Dekel
2026-12-01 20:26 ` [PATCH v2 1/2] lib/igt_hdr: switch to libdisplay-info for EDID parsing Gil Dekel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox