Skip to contentSkip to conversation

edid-decode: support parsing EDID-Like Data

PATCH New Dmitry Baryshkov 1 participant 1 message Jan 24, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 edid-decode: support parsing EDID-Like Data

High Definition Audio spec defines a special data block, ELD, used to provide audio-related information for the connected monitors. HDMI Codec in Linux reuses ELD to provide data to userspace. Add support for parsing ELD blobs.

---
Changes in v2:
- Mentioned HDA standard in the manual page (Hans)
- Described new option in the manual page (Hans)
- Described how to extract ELD on a running system (Hans)
- Dropped unused variable in parse_eld_baseline().
- Handle hex-encoded ELD and stdin as an argument.
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 utils/edid-decode/edid-decode.1.in     |  25 ++++
 utils/edid-decode/edid-decode.cpp      | 237 ++++++++++++++++++++++++++++++++-
 utils/edid-decode/edid-decode.h        |   6 +
 utils/edid-decode/meson.build          |   1 +
 utils/edid-decode/parse-base-block.cpp |   2 +-
 utils/edid-decode/parse-cta-block.cpp  |   4 +-
 utils/edid-decode/parse-eld.cpp        |  97 ++++++++++++++
 7 files changed, 367 insertions(+), 5 deletions(-)
utils/edid-decode/edid-decode.1.in +25 -0
index 04edf5ff3fed7e24fb4668f8870f6729fa7d8f15..1e4cd6ae1418a8ce5757bab13836f9ab7df520c9 100644
@@ -161,6 +161,8 @@ CVT 1.2: VESA Coordinated Video Timings (CVT) Standard, Version 1.2
 CVT 1.2: VESA CVT v1.2 Errata E2
 .TP
 GTF 1.1: VESA Generalized Timing Formula Standard, Version: 1.1
+.TP
+HDA 1.0a: High Definition Audio Specification, Version 1.0a
 .RE
 
 .SH OPTIONS
@@ -215,6 +217,29 @@ HDMI Specification. Otherwise it is assumed to be a regular CTA-861 InfoFrame
 without a checksum.
 
 Note: this is still work-in-progress, specifically for the AVI and HDMI InfoFrames.
+.TP
+\fB\-E\fR, \fB\-\-eld\fR \fI<file>\fR
+Parse the given EDID-Like Data (ELD) file. This option can be used multiple
+times to parse multiple ELD files. Read data from stdin if '-' was passed as a
+filename.  If the EDID of the display to which these ELD files are generated is
+also given, then the conformity checks will take that EDID into account.
+
+On Linux systems ELD can be extracted via the amixer command (copy all hex after the 'values='):
+  $ amixer -c 0 controls | grep ELD
+  numid=6,iface=PCM,name='ELD',device=3
+  numid=12,iface=PCM,name='ELD',device=7
+  numid=18,iface=PCM,name='ELD',device=8
+  numid=24,iface=PCM,name='ELD',device=9
+  $ amixer -c 0 cget iface=PCM,name=ELD,device=3
+  numid=6,iface=PCM,name='ELD',device=3
+    ; type=BYTES,access=r--v----,values=95
+    : values=0x10,0x00,0x08,0x00,0x6d,0x10,0x00,0x01,0x00,0x02,0x00,0x00,0x00,0x00,
+    0x00,0x00,0x30,0xae,0xf1,0x61,0x4c,0x45,0x4e,0x20,0x54,0x33,0x32,0x68,0x2d,0x32,
+    0x30,0x0a,0x20,0x09,0x7f,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+
 .TP
 \fB\-\-diagonal\fR \fI<inches>\fR
 Specify the diagonal of the display in inches. This will enable additional checks
utils/edid-decode/edid-decode.cpp +235 -2

297 lines not on this page · raw message

utils/edid-decode/edid-decode.h +6 -0
index 0d71d544145ee6e55d1e50270c3317bb69c0fcf4..e64143deb79a7e58aba87c41a0d582e7bb236a2f 100644
@@ -423,6 +423,7 @@ struct edid_state {
 	void check_base_block(const unsigned char *x);
 	void list_dmts();
 	void list_established_timings();
+	char *manufacturer_name(const unsigned char *x);
 
 	void data_block_oui(std::string block_name, const unsigned char *x, unsigned length, unsigned *ouinum,
 	                    bool ignorezeros = false, bool do_ascii = false, bool big_endian = false,
@@ -449,6 +450,8 @@ struct edid_state {
 	void cta_displayid_type_8(const unsigned char *x, unsigned length);
 	void cta_displayid_type_10(const unsigned char *x, unsigned length);
 	void cta_block(const unsigned char *x, std::vector<unsigned> &found_tags);
+	void cta_sadb(const unsigned char *x, unsigned length);
+	void cta_audio_block(const unsigned char *x, unsigned length);
 	void preparse_cta_block(unsigned char *x);
 	void parse_cta_block(const unsigned char *x);
 	void cta_resolve_svr(timings_ext &t_ext);
@@ -532,6 +535,9 @@ struct edid_state {
 	void parse_if_mpeg_source(const unsigned char *x, unsigned size);
 	void parse_if_ntsc_vbi(const unsigned char *x, unsigned size);
 	void parse_if_drm(const unsigned char *x, unsigned size);
+
+	int parse_eld(const std::string &fname);
+	void parse_eld_baseline(const unsigned char *x, unsigned size);
 };
 
 static inline void add_str(std::string &s, const std::string &add)
utils/edid-decode/meson.build +1 -0
index 807d4e873c05d944acbc4924a7e34bb30d97c3f0..d1ed5179413a4e464e6f3c946d714bbbdc0ea9e2 100644
@@ -9,6 +9,7 @@ edid_decode_sources = [
 	'parse-ls-ext-block.cpp',
 	'parse-vtb-ext-block.cpp',
 	'parse-if.cpp',
+	'parse-eld.cpp',
 ]
 
 edid_decode_args = []
utils/edid-decode/parse-base-block.cpp +1 -1
index a2f0e7408ef8c87fd218a2dfcf5e2ee3eb55e3f6..0d7f7c212f65d7a81e5e771387e4e679b1e2e2f5 100644
@@ -14,7 +14,7 @@
 
 #include "edid-decode.h"
 
-static char *manufacturer_name(const unsigned char *x)
+char *edid_state::manufacturer_name(const unsigned char *x)
 {
 	static char name[4];
 
utils/edid-decode/parse-cta-block.cpp +2 -2
index 06bc07d30b0fb7a8ed73320e9cf91b9aca84cd73..ce47be7135272e8e81f3269f469e27c6c7b5e583 100644
@@ -464,7 +464,7 @@ static std::string mpeg_h_3d_audio_level(unsigned char x)
 	return std::string("Unknown MPEG-H 3D Audio Level (") + utohex(x) + ")";
 }
 
-static void cta_audio_block(const unsigned char *x, unsigned length)
+void edid_state::cta_audio_block(const unsigned char *x, unsigned length)
 {
 	unsigned i, format, ext_format;
 
@@ -1824,7 +1824,7 @@ const char *cta_speaker_map[] = {
 	NULL
 };
 
-static void cta_sadb(const unsigned char *x, unsigned length)
+void edid_state::cta_sadb(const unsigned char *x, unsigned length)
 {
 	unsigned sad_deprecated = 0x7f000;
 	unsigned sad;
utils/edid-decode/parse-eld.cpp new file +97 -0

97 lines not on this page · raw message

---
base-commit: 8fb667bc4ec202529799cca28fff5b69d34cee19
change-id: 20250106-eld-support-4a243e37981c

Best regards,

Signature · 1 line
Dmitry Baryshkov <[email protected]>