Re: [PATCH libXrender 1/2] Avoid OOB write in XRenderQueryFilters
Anyone? This still looks wrong to me. Cheers, Julien On Sat, Jan 7, 2017 at 18:46:57 +0100, Julien Cristau wrote: > On Sun, Sep 25, 2016 at 22:50:45 +0200, Matthieu Herrb wrote: > > > From: Tobias Stoeckmann> > > > The memory for filter names is reserved right after receiving the reply. > > After that, filters are iterated and each individual filter name is > > stored in that reserved memory. > > > > The individual name lengths are not checked for validity, which means > > that a malicious server can reserve less memory than it will write to > > during each iteration. > > > > v2: consume remaining bytes in reply buffer on error. > > > > Signed-off-by: Tobias Stoeckmann > > Reviewed-by: Matthieu Herrb > > --- > > src/Filter.c | 13 - > > 1 file changed, 12 insertions(+), 1 deletion(-) > > > > diff --git a/src/Filter.c b/src/Filter.c > > index edfa572..8d701eb 100644 > > --- a/src/Filter.c > > +++ b/src/Filter.c > > @@ -38,7 +38,7 @@ XRenderQueryFilters (Display *dpy, Drawable drawable) > > char *name; > > char len; > > inti; > > -unsigned long nbytes, nbytesAlias, nbytesName; > > +unsigned long nbytes, nbytesAlias, nbytesName, reply_left; > > > > if (!RenderHasExtension (info)) > > return NULL; > > @@ -114,6 +114,7 @@ XRenderQueryFilters (Display *dpy, Drawable drawable) > > * Read the filter aliases > > */ > > _XRead16Pad (dpy, filters->alias, 2 * rep.numAliases); > > +reply_left = 8 + rep.length - 2 * rep.numAliases;; > > > reply_left looks like a byte count, in which case shouldn't rep.length > be multiplied by 4? I don't get where that 8 comes from, either, any > chance you could explain? In fact I wonder if this couldn't use > nbytesName instead? > > Cheers, > Julien > ___ > xorg-devel@lists.x.org: X.Org development > Archives: http://lists.x.org/archives/xorg-devel > Info: https://lists.x.org/mailman/listinfo/xorg-devel ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCHv3 06/12] edid-decode: add DCI-P3 support in colorimetry block
From: Hans VerkuilThis bit was added in CTA-861-G. Signed-off-by: Hans Verkuil --- edid-decode.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/edid-decode.c b/edid-decode.c index 074cb821..2727fd18 100644 --- a/edid-decode.c +++ b/edid-decode.c @@ -1852,6 +1852,8 @@ cea_colorimetry_block(unsigned char *x) if (x[2] & (1 << i)) printf("%s\n", colorimetry_map[i]); } + if (x[3] & 0x80) + printf("DCI-P3\n"); } } -- 2.14.1 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCHv3 12/12] edid-decode: add support for the HDMI Audio Data Block
From: Hans VerkuilThis was introduced in HDMI 2.0. Signed-off-by: Hans Verkuil --- edid-decode.c | 70 ++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/edid-decode.c b/edid-decode.c index c61fde8a..92dbfcf1 100644 --- a/edid-decode.c +++ b/edid-decode.c @@ -1705,6 +1705,7 @@ static const char *speaker_map[] = { "BtFC - Bottom Front Center", "BtFL/BtBR - Bottom Front Left/Right", "TpLS/TpRS - Top Left/Right Surround", +"LSd/RSd - Left/Right Surround Direct", }; static void @@ -1961,6 +1962,72 @@ cta_ifdb(unsigned char *x) } } +static void +cta_hdmi_audio_block(unsigned char *x) +{ +int length = x[0] & 0x1f; +int num_descs; + +if (length <= 3) + return; +if (x[2] & 3) + printf("Max Stream Count: %d\n", (x[2] & 3) + 1); +if (x[2] & 4) + printf("Supports MS NonMixed\n"); + +num_descs = x[3] & 7; +if (num_descs == 0) + return; +length -= 3; +x += 4; +while (length >= 4) { + if (length > 4) { + int format = x[0] & 0xf; + + printf("%s, max channels %d\n", audio_format(format), + (x[1] & 0x1f)+1); + printf(" Supported sample rates (kHz):%s%s%s%s%s%s%s\n", + (x[2] & 0x40) ? " 192" : "", + (x[2] & 0x20) ? " 176.4" : "", + (x[2] & 0x10) ? " 96" : "", + (x[2] & 0x08) ? " 88.2" : "", + (x[2] & 0x04) ? " 48" : "", + (x[2] & 0x02) ? " 44.1" : "", + (x[2] & 0x01) ? " 32" : ""); + if (format == 1) + printf(" Supported sample sizes (bits):%s%s%s\n", + (x[3] & 0x04) ? " 24" : "", + (x[3] & 0x02) ? " 20" : "", + (x[3] & 0x01) ? " 16" : ""); + } else { + uint32_t sad = ((x[2] << 16) | (x[1] << 8) | x[0]); + int i; + + switch (x[3] >> 4) { + case 1: + printf("Speaker Allocation for 10.2 channels:\n"); + break; + case 2: + printf("Speaker Allocation for 22.2 channels:\n"); + break; + case 3: + printf("Speaker Allocation for 30.2 channels:\n"); + break; + default: + printf("Unknown Speaker Allocation (%d)\n", x[3] >> 4); + return; + } + + for (i = 0; i < ARRAY_SIZE(speaker_map); i++) { + if ((sad >> i) & 1) + printf(" %s\n", speaker_map[i]); + } + } + length -= 4; + x += 4; +} +} + static void cta_block(unsigned char *x) { @@ -2050,7 +2117,8 @@ cta_block(unsigned char *x) printf("Vendor-specific audio data block\n"); break; case 0x12: - printf("Reserved for HDMI audio data block\n"); + printf("HDMI audio data block\n"); + cta_hdmi_audio_block(x); break; case 0x13: printf("Room configuration data block\n"); -- 2.14.1 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCHv3 05/12] edid-decode: add new CTA-861-G VIC codes
From: Hans VerkuilThe CTA-861-G standard (successor to CEA-861-F) adds new VIC codes. Signed-off-by: Hans Verkuil --- edid-decode.c | 93 +++ 1 file changed, 81 insertions(+), 12 deletions(-) diff --git a/edid-decode.c b/edid-decode.c index 4534d58f..074cb821 100644 --- a/edid-decode.c +++ b/edid-decode.c @@ -1113,10 +1113,12 @@ cea_audio_block(unsigned char *x) } } -static struct { +struct edid_cea_mode { const char *name; int refresh, hor_freq_hz, pixclk_khz; -} edid_cea_modes[] = { +}; + +static struct edid_cea_mode edid_cea_modes1[] = { /* VIC 1 */ {"640x480@60Hz 4:3", 60, 31469, 25175}, {"720x480@60Hz 4:3", 60, 31469, 27000}, @@ -1235,14 +1237,80 @@ static struct { {"3840x2160@30Hz 64:27", 30, 67500, 297000}, {"3840x2160@50Hz 64:27", 50, 112500, 594000}, {"3840x2160@60Hz 64:27", 60, 135000, 594000}, +{"1280x720@48Hz 16:9", 48, 36000, 9}, +{"1280x720@48Hz 64:27", 48, 36000, 9}, +{"1680x720@48Hz 64:27", 48, 36000, 99000}, +/* VIC 111 */ +{"1920x1080@48Hz 16:9", 48, 54000, 148500}, +{"1920x1080@48Hz 64:27", 48, 54000, 148500}, +{"2560x1080@48Hz 64:27", 48, 52800, 198000}, +{"3840x2160@48Hz 16:9", 48, 108000, 594000}, +{"4096x2160@48Hz 256:135", 48, 108000, 594000}, +{"3840x2160@48Hz 64:27", 48, 108000, 594000}, +{"3840x2160@100Hz 16:9", 100, 225000, 1188000}, +{"3840x2160@120Hz 16:9", 120, 27, 1188000}, +{"3840x2160@100Hz 64:27", 100, 225000, 1188000}, +{"3840x2160@120Hz 64:27", 120, 27, 1188000}, +/* VIC 121 */ +{"5120x2160@24Hz 64:27", 24, 52800, 396000}, +{"5120x2160@25Hz 64:27", 25, 55000, 396000}, +{"5120x2160@30Hz 64:27", 30, 66000, 396000}, +{"5120x2160@48Hz 64:27", 48, 118800, 742500}, +{"5120x2160@50Hz 64:27", 50, 112500, 742500}, +{"5120x2160@60Hz 64:27", 60, 135000, 742500}, +{"5120x2160@100Hz 64:27", 100, 225000, 1485000}, +}; + +static struct edid_cea_mode edid_cea_modes2[] = { +/* VIC 193 */ +{"5120x2160@120Hz 64:27", 120, 27, 1485000}, +{"7680x4320@24Hz 16:9", 24, 108000, 1188000}, +{"7680x4320@25Hz 16:9", 25, 11, 1188000}, +{"7680x4320@30Hz 16:9", 30, 132000, 1188000}, +{"7680x4320@48Hz 16:9", 48, 216000, 2376000}, +{"7680x4320@50Hz 16:9", 50, 22, 2376000}, +{"7680x4320@60Hz 16:9", 60, 264000, 2376000}, +{"7680x4320@100Hz 16:9", 100, 45, 4752000}, +/* VIC 201 */ +{"7680x4320@120Hz 16:9", 120, 54, 4752000}, +{"7680x4320@24Hz 64:27", 24, 108000, 1188000}, +{"7680x4320@25Hz 64:27", 25, 11, 1188000}, +{"7680x4320@30Hz 64:27", 30, 132000, 1188000}, +{"7680x4320@48Hz 64:27", 48, 216000, 2376000}, +{"7680x4320@50Hz 64:27", 50, 22, 2376000}, +{"7680x4320@60Hz 64:27", 60, 264000, 2376000}, +{"7680x4320@100Hz 64:27", 100, 45, 4752000}, +{"7680x4320@120Hz 64:27", 120, 54, 4752000}, +{"10240x4320@24Hz 64:27", 24, 118800, 1485000}, +/* VIC 211 */ +{"10240x4320@25Hz 64:27", 25, 11, 1485000}, +{"10240x4320@30Hz 64:27", 30, 135000, 1485000}, +{"10240x4320@48Hz 64:27", 48, 237600, 297}, +{"10240x4320@50Hz 64:27", 50, 22, 297}, +{"10240x4320@60Hz 64:27", 60, 27, 297}, +{"10240x4320@100Hz 64:27", 100, 45, 594}, +{"10240x4320@120Hz 64:27", 120, 54, 594}, +{"4096x2160@100Hz 256:135", 100, 225000, 1188000}, +{"4096x2160@120Hz 256:135", 120, 27, 1188000}, }; +static const struct edid_cea_mode * +vic_to_mode(unsigned char vic) +{ +if (vic > 0 && vic <= ARRAY_SIZE(edid_cea_modes1)) + return edid_cea_modes1 + vic - 1; +if (vic >= 193 && vic <= ARRAY_SIZE(edid_cea_modes2) + 193) + return edid_cea_modes2 + vic - 193; +return NULL; +} + static void cea_svd(unsigned char *x, int n, int for_ycbcr420) { int i; for (i = 0; i < n; i++) { + const struct edid_cea_mode *vicmode = NULL; unsigned char svd = x[i]; unsigned char native; unsigned char vic; @@ -1261,7 +1329,8 @@ cea_svd(unsigned char *x, int n, int for_ycbcr420) native = svd & 0x80; } - if (vic > 0 && vic <= ARRAY_SIZE(edid_cea_modes)) { + vicmode = vic_to_mode(vic); + if (vicmode) { switch (vic) { case 95: supported_hdmi_vic_vsb_codes |= 1 << 0; @@ -1276,13 +1345,13 @@ cea_svd(unsigned char *x, int n, int for_ycbcr420) supported_hdmi_vic_vsb_codes |= 1 << 3; break; } - mode = edid_cea_modes[vic - 1].name; - min_vert_freq_hz = min(min_vert_freq_hz, edid_cea_modes[vic - 1].refresh); - max_vert_freq_hz = max(max_vert_freq_hz, edid_cea_modes[vic - 1].refresh); - hfreq = edid_cea_modes[vic - 1].hor_freq_hz; + mode = vicmode->name; +
[PATCHv3 07/12] edid-decode: support HLG, decode luminance values
From: Hans VerkuilAdd support for the new CTA-861-G Hybrid Log-Gamma transfer function. Also decode the luminance values in the static metadata block to cd/m^2 values. Signed-off-by: Hans Verkuil --- Makefile | 2 +- edid-decode.c | 15 ++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 21b811ed..75c436ea 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ bindir ?= /usr/bin mandir ?= /usr/share/man edid-decode: edid-decode.c - $(CC) $(CFLAGS) -g -Wall -o $@ $< + $(CC) $(CFLAGS) -g -Wall -o $@ $< -lm clean: rm -f edid-decode diff --git a/edid-decode.c b/edid-decode.c index 2727fd18..b2b116f3 100644 --- a/edid-decode.c +++ b/edid-decode.c @@ -31,6 +31,7 @@ #include #include #include +#include #define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x))) #define min(a, b) ((a) < (b) ? (a) : (b)) @@ -1861,10 +1862,11 @@ static const char *eotf_map[] = { "Traditional gamma - SDR luminance range", "Traditional gamma - HDR luminance range", "SMPTE ST2084", +"Hybrid Log-Gamma", }; static void -cea_hdr_metadata_block(unsigned char *x) +cea_hdr_static_metadata_block(unsigned char *x) { int length = x[0] & 0x1f; int i; @@ -1885,13 +1887,16 @@ cea_hdr_metadata_block(unsigned char *x) } if (length >= 4) - printf("Desired content max luminance: %d\n", x[4]); + printf("Desired content max luminance: %d (%.3f cd/m^2)\n", + x[4], 50.0 * pow(2, x[4] / 32.0)); if (length >= 5) - printf("Desired content max frame-average luminance: %d\n", x[5]); + printf("Desired content max frame-average luminance: %d (%.3f cd/m^2)\n", + x[5], 50.0 * pow(2, x[5] / 32.0)); if (length >= 6) - printf("Desired content min luminance: %d\n", x[6]); + printf("Desired content min luminance: %d (%.3f cd/m^2)\n", + x[6], (50.0 * pow(2, x[4] / 32.0)) * pow(x[6] / 255.0, 2) / 100.0); } static void @@ -1958,7 +1963,7 @@ cea_block(unsigned char *x) break; case 0x06: printf("HDR static metadata data block\n"); - cea_hdr_metadata_block(x); + cea_hdr_static_metadata_block(x); break; case 0x0d: printf("Video format preference data block\n"); -- 2.14.1 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCHv3 02/12] edid-decode: update Audio Block with CEA-861.2
From: Hans VerkuilAdd support for extended audio formats and report the format specific information. Signed-off-by: Hans Verkuil --- edid-decode.c | 51 --- 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/edid-decode.c b/edid-decode.c index 0c93d104..c5de5f6e 100644 --- a/edid-decode.c +++ b/edid-decode.c @@ -1017,6 +1017,24 @@ do_checksum(unsigned char *x, size_t len) /* CEA extension */ +static const char * +audio_ext_format(unsigned char x) +{ +switch (x) { +case 4: return "MPEG-4 HE AAC"; +case 5: return "MPEG-4 HE AAC v2"; +case 6: return "MPEG-4 AAC LC"; +case 7: return "DRA"; +case 8: return "MPEG-4 HE AAC + MPEG Surround"; +case 10: return "MPEG-4 AAC + MPEG Surround"; +case 11: return "MPEG-H 3D Audio"; +case 12: return "AC-4"; +case 13: return "L-PCM 3D Audio"; +default: return "RESERVED"; +} +return "BROKEN"; /* can't happen */ +} + static const char * audio_format(unsigned char x) { @@ -1044,7 +1062,7 @@ audio_format(unsigned char x) static void cea_audio_block(unsigned char *x) { -int i, format; +int i, format, ext_format = 0; int length = x[0] & 0x1f; if (length % 3) { @@ -1055,9 +1073,18 @@ cea_audio_block(unsigned char *x) for (i = 1; i < length; i += 3) { format = (x[i] & 0x78) >> 3; - printf("%s, max channels %d\n", audio_format(format), - (x[i] & 0x07)+1); - printf("Supported sample rates (kHz):%s%s%s%s%s%s%s\n", + ext_format = (x[i + 2] & 0xf8) >> 3; + if (format != 15) + printf("%s, max channels %d\n", audio_format(format), + (x[i] & 0x07)+1); + else if (ext_format == 13) + printf("%s, max channels %d\n", audio_ext_format(ext_format), + (((x[i + 1] & 0x80) >> 3) | ((x[i] & 0x80) >> 4) | + (x[i] & 0x07))+1); + else + printf("%s, max channels %d\n", audio_ext_format(ext_format), + (x[i] & 0x07)+1); + printf(" Supported sample rates (kHz):%s%s%s%s%s%s%s\n", (x[i+1] & 0x40) ? " 192" : "", (x[i+1] & 0x20) ? " 176.4" : "", (x[i+1] & 0x10) ? " 96" : "", @@ -1065,13 +1092,23 @@ cea_audio_block(unsigned char *x) (x[i+1] & 0x04) ? " 48" : "", (x[i+1] & 0x02) ? " 44.1" : "", (x[i+1] & 0x01) ? " 32" : ""); - if (format == 1) { - printf("Supported sample sizes (bits):%s%s%s\n", + if (format == 1 || ext_format == 13) { + printf(" Supported sample sizes (bits):%s%s%s\n", (x[i+2] & 0x04) ? " 24" : "", (x[i+2] & 0x02) ? " 20" : "", (x[i+2] & 0x01) ? " 16" : ""); } else if (format <= 8) { - printf("Maximum bit rate: %d kHz\n", x[i+2] * 8); + printf(" Maximum bit rate: %d kHz\n", x[i+2] * 8); + } else if (format == 14) { + printf(" Profile: %d\n", x[i+2] & 7); + } else if ((ext_format >= 4 && ext_format <= 6) || + ext_format == 8 || ext_format == 10) { + printf(" AAC audio frame lengths:%s%s\n", + (x[i+2] & 4) ? " 1024_TL" : "", + (x[i+2] & 2) ? " 960_TL" : ""); + if (ext_format >= 8 && (x[i+2] & 1)) + printf(" Supports %s signaled MPEG Surround data\n", + (x[i+2] & 1) ? "implicitly and explicitly" : "only implicitly"); } } } -- 2.14.1 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCHv3 01/12] edid-decode: fix broken bit tests
From: Hans Verkuil'if (x[0] >> i)' is not how you test if bit i is set. 'if (x[0] & (1 << i))' works a lot better! Signed-off-by: Hans Verkuil --- edid-decode.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/edid-decode.c b/edid-decode.c index 7aaeacee..0c93d104 100644 --- a/edid-decode.c +++ b/edid-decode.c @@ -1638,7 +1638,7 @@ cea_colorimetry_block(unsigned char *x) if (length >= 3) { for (i = 0; i < ARRAY_SIZE(colorimetry_map); i++) { - if (x[2] >> i) + if (x[2] & (1 << i)) printf("%s\n", colorimetry_map[i]); } } @@ -1659,14 +1659,14 @@ cea_hdr_metadata_block(unsigned char *x) if (length >= 3) { printf("Electro optical transfer functions:\n"); for (i = 0; i < 6; i++) { - if (x[2] >> i) { + if (x[2] & (1 << i)) { printf(" %s\n", i < ARRAY_SIZE(eotf_map) ? eotf_map[i] : "Unknown"); } } printf("Supported static metadata descriptors:\n"); for (i = 0; i < 8; i++) { - if (x[3] >> i) + if (x[3] & (1 << i)) printf(" Static metadata type %d\n", i + 1); } } -- 2.14.1 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCHv3 08/12] edid-decode: add HDR Dynamic Metadata Data Block
From: Hans VerkuilSupport this CTA-861-G data block. Signed-off-by: Hans Verkuil --- edid-decode.c | 35 +++ 1 file changed, 35 insertions(+) diff --git a/edid-decode.c b/edid-decode.c index b2b116f3..0fe126cd 100644 --- a/edid-decode.c +++ b/edid-decode.c @@ -1899,6 +1899,37 @@ cea_hdr_static_metadata_block(unsigned char *x) x[6], (50.0 * pow(2, x[4] / 32.0)) * pow(x[6] / 255.0, 2) / 100.0); } +static void +cea_hdr_dyn_metadata_block(unsigned char *x) +{ +int length = x[0] & 0x1f; + +if (!length) + return; +length--; +x += 2; +while (length >= 3) { + int type_len = x[0]; + int type = x[1] | (x[2] << 8); + + if (length < type_len + 1) + return; + printf("HDR Dynamic Metadata Type %d\n", type); + switch (type) { + case 1: + case 2: + case 4: + if (type_len > 2) + printf(" Version: %d\n", x[3] & 0xf); + break; + default: + break; + } + length -= type_len + 1; + x += type_len + 1; +} +} + static void cea_block(unsigned char *x) { @@ -1965,6 +1996,10 @@ cea_block(unsigned char *x) printf("HDR static metadata data block\n"); cea_hdr_static_metadata_block(x); break; + case 0x07: + printf("HDR dynamic metadata data block\n"); + cea_hdr_dyn_metadata_block(x); + break; case 0x0d: printf("Video format preference data block\n"); cea_vfpdb(x); -- 2.14.1 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCHv3 09/12] edid-decode: sync cea_block data block names with standard
From: Hans VerkuilThe names where a bit irregular, sync them up with the CTA-861-G standard. Signed-off-by: Hans Verkuil --- edid-decode.c | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/edid-decode.c b/edid-decode.c index 0fe126cd..5de90cc5 100644 --- a/edid-decode.c +++ b/edid-decode.c @@ -1973,20 +1973,20 @@ cea_block(unsigned char *x) printf(" Extended tag: "); switch (x[1]) { case 0x00: - printf("video capability data block\n"); + printf("Video capability data block\n"); cea_vcdb(x); break; case 0x01: - printf("vendor-specific video data block\n"); + printf("Vendor-specific video data block\n"); break; case 0x02: - printf("VESA video display device information data block\n"); + printf("VESA video display device data block\n"); break; case 0x03: - printf("VESA video data block\n"); + printf("VESA video timing block extension\n"); break; case 0x04: - printf("HDMI video data block\n"); + printf("Reserved for HDMI video data block\n"); break; case 0x05: printf("Colorimetry data block\n"); @@ -2013,13 +2013,13 @@ cea_block(unsigned char *x) cea_y420cmdb(x); break; case 0x10: - printf("CEA miscellaneous audio fields\n"); + printf("Reserved for CTA miscellaneous audio fields\n"); break; case 0x11: printf("Vendor-specific audio data block\n"); break; case 0x12: - printf("HDMI audio data block\n"); + printf("Reserved for HDMI audio data block\n"); break; case 0x13: printf("Room configuration data block\n"); @@ -2034,11 +2034,11 @@ cea_block(unsigned char *x) break; default: if (x[1] >= 6 && x[1] <= 12) - printf("Reserved video block (%02x)\n", x[1]); + printf("Reserved for video-related blocks (%02x)\n", x[1]); else if (x[1] >= 19 && x[1] <= 31) - printf("Reserved audio block (%02x)\n", x[1]); + printf("Reserved for audio-related blocks (%02x)\n", x[1]); else - printf("Unknown (%02x)\n", x[1]); + printf("Reserved (%02x)\n", x[1]); break; } break; -- 2.14.1 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCHv3 03/12] edid-decode: update Speaker Allocation data block
From: Hans VerkuilMore bits are now in use, implement support for those. Signed-off-by: Hans Verkuil --- edid-decode.c | 39 +++ 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/edid-decode.c b/edid-decode.c index c5de5f6e..8d47a5fc 100644 --- a/edid-decode.c +++ b/edid-decode.c @@ -1615,17 +1615,26 @@ static struct field *vcdb_fields[] = { }; static const char *sadb_map[] = { -"FL/FR", -"LFE", -"FC", -"RL/RR", -"RC", -"FLC/FRC", -"RLC/RRC", -"FLW/FRW", -"FLH/FRH", -"TC", -"FCH", +"FL/FR - Front Left/Right", +"LFE - Low Frequency Effects", +"FC - Front Center", +"BL/BR - Back Left/Right", +"BC - Back Center", +"FLC/FRC - Front Left/Right of Center", +"RLC/RRC - Rear Left/Right of Center", +"FLW/FRW - Front Left/Right Wide", +"TpFL/TpFH - Top Front Left/Right", +"TpC - Top Center", +"TpFC - Top Front Center", +"LS/RS - Left/Right Surround", +"LFE2 - Low Frequency Effects 2", +"TpBC - Top Back Center", +"SiL/SiR - Side Left/Right", +"TpSiL/TpSiR - Top Side Left/Right", +"TpBL/TpBR - Top Back Left/Right", +"BtFC - Bottom Front Center", +"BtFL/BtBR - Bottom Front Left/Right", +"TpLS/TpRS - Top Left/Right Surround", }; static void @@ -1635,16 +1644,14 @@ cea_sadb(unsigned char *x) int i; if (length >= 3) { - uint16_t sad = ((x[2] << 8) | x[1]); + uint32_t sad = ((x[3] << 16) | (x[2] << 8) | x[1]); - printf("Speaker map:"); + printf("Speaker map:\n"); for (i = 0; i < ARRAY_SIZE(sadb_map); i++) { if ((sad >> i) & 1) - printf(" %s", sadb_map[i]); + printf(" %s\n", sadb_map[i]); } - - printf("\n"); } } -- 2.14.1 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCHv3 04/12] edid-decode: add support for Room/Speaker data blocks
From: Hans VerkuilSupport the Room Configuration Data Block and the Speaker Location Data Block. Signed-off-by: Hans Verkuil --- edid-decode.c | 112 -- 1 file changed, 109 insertions(+), 3 deletions(-) diff --git a/edid-decode.c b/edid-decode.c index 8d47a5fc..4534d58f 100644 --- a/edid-decode.c +++ b/edid-decode.c @@ -1614,7 +1614,7 @@ static struct field *vcdb_fields[] = { _scan, }; -static const char *sadb_map[] = { +static const char *speaker_map[] = { "FL/FR - Front Left/Right", "LFE - Low Frequency Effects", "FC - Front Center", @@ -1648,13 +1648,111 @@ cea_sadb(unsigned char *x) printf("Speaker map:\n"); - for (i = 0; i < ARRAY_SIZE(sadb_map); i++) { + for (i = 0; i < ARRAY_SIZE(speaker_map); i++) { if ((sad >> i) & 1) - printf(" %s\n", sadb_map[i]); + printf(" %s\n", speaker_map[i]); } } } +static float +decode_uchar_as_float(unsigned char x) +{ +signed char s = (signed char)x; + +return s / 64.0; +} + +static void +cea_rcdb(unsigned char *x) +{ +int length = x[0] & 0x1f; +uint32_t spm = ((x[5] << 16) | (x[4] << 8) | x[3]); +int i; + +if (length < 4) + return; + +if (x[2] & 0x40) + printf("Speaker count: %d\n", (x[2] & 0x1f) + 1); + +printf("Speaker Presence Mask:\n"); +for (i = 0; i < ARRAY_SIZE(speaker_map); i++) { + if ((spm >> i) & 1) + printf(" %s\n", speaker_map[i]); +} +if ((x[2] & 0x20) && length >= 7) { + printf("Xmax: %d dm\n", x[6]); + printf("Ymax: %d dm\n", x[7]); + printf("Zmax: %d dm\n", x[8]); +} +if ((x[2] & 0x80) && length >= 10) { + printf("DisplayX: %.3f * Xmax\n", decode_uchar_as_float(x[9])); + printf("DisplayY: %.3f * Ymax\n", decode_uchar_as_float(x[10])); + printf("DisplayZ: %.3f * Zmax\n", decode_uchar_as_float(x[11])); +} +} + +static const char *speaker_location[] = { +"FL - Front Left", +"FR - Front Right", +"FC - Front Center", +"LFE1 - Low Frequency Effects 1", +"BL - Back Left", +"BR - Back Right", +"FLC - Front Left of Center", +"FRC - Front Right of Center", +"BC - Back Center", +"LFE2 - Low Frequency Effects 2", +"SiL - Side Left", +"SiR - Side Right", +"TpFL - Top Front Left", +"TpFH - Top Front Right", +"TpFC - Top Front Center", +"TpC - Top Center", +"TpBL - Top Back Left", +"TpBR - Top Back Right", +"TpSiL - Top Side Left", +"TpSiR - Top Side Right", +"TpBC - Top Back Center", +"BtFC - Bottom Front Center", +"BtFL - Bottom Front Left", +"BtBR - Bottom Front Right", +"FLW - Front Left Wide", +"FRW - Front Right Wide", +"LS - Left Surround", +"RS - Right Surround", +}; + +static void +cea_sldb(unsigned char *x) +{ +int length = x[0] & 0x1f; + +if (!length) + return; + +x += 2; +length--; + +while (length >= 2) { + printf("Channel: %d (%sactive)\n", x[0] & 0x1f, + (x[0] & 0x20) ? "" : "not "); + if ((x[1] & 0x1f) < ARRAY_SIZE(speaker_location)) + printf(" Speaker: %s\n", speaker_location[x[1] & 0x1f]); + if (length >= 5 && (x[0] & 0x40)) { + printf(" X: %.3f * Xmax\n", decode_uchar_as_float(x[2])); + printf(" Y: %.3f * Ymax\n", decode_uchar_as_float(x[3])); + printf(" Z: %.3f * Zmax\n", decode_uchar_as_float(x[4])); + length -= 3; + x += 3; + } + + length -= 2; + x += 2; +} +} + static void cea_vcdb(unsigned char *x) { @@ -1812,6 +1910,14 @@ cea_block(unsigned char *x) case 0x12: printf("HDMI audio data block\n"); break; + case 0x13: + printf("Room configuration data block\n"); + cea_rcdb(x); + break; + case 0x14: + printf("Speaker location data block\n"); + cea_sldb(x); + break; case 0x20: printf("InfoFrame data block\n"); break; -- 2.14.1 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCHv3 10/12] edid-decode: rename CEA/cea to CTA/cta
From: Hans VerkuilThe Consumer Electronics Association was renamed to Consumer Technology Association. Update all cea references to cta. Signed-off-by: Hans Verkuil --- edid-decode.c | 130 +- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/edid-decode.c b/edid-decode.c index 5de90cc5..550c2d58 100644 --- a/edid-decode.c +++ b/edid-decode.c @@ -54,7 +54,7 @@ static int name_descriptor_terminated = 0; static int has_range_descriptor = 0; static int has_preferred_timing = 0; static int has_valid_checksum = 1; -static int has_valid_cea_checksum = 1; +static int has_valid_cta_checksum = 1; static int has_valid_displayid_checksum = 1; static int has_valid_cvt = 1; static int has_valid_dummy_block = 1; @@ -68,9 +68,9 @@ static int has_valid_descriptor_pad = 1; static int has_valid_range_descriptor = 1; static int has_valid_max_dotclock = 1; static int has_valid_string_termination = 1; -static int has_cea861 = 0; +static int has_cta861 = 0; static int has_640x480p60_est_timing = 0; -static int has_cea861_vic_1 = 0; +static int has_cta861_vic_1 = 0; static int manufacturer_name_well_formed = 0; static int seen_non_detailed_descriptor = 0; @@ -78,7 +78,7 @@ static int warning_excessive_dotclock_correction = 0; static int warning_zero_preferred_refresh = 0; static int nonconformant_hf_vsdb_position = 0; static int nonconformant_srgb_chromaticity = 0; -static int nonconformant_cea861_640x480 = 0; +static int nonconformant_cta861_640x480 = 0; static int nonconformant_hdmi_vsdb_tmds_rate = 0; static int nonconformant_hf_vsdb_tmds_rate = 0; @@ -1016,7 +1016,7 @@ do_checksum(unsigned char *x, size_t len) return 1; } -/* CEA extension */ +/* CTA extension */ static const char * audio_ext_format(unsigned char x) @@ -1061,13 +1061,13 @@ audio_format(unsigned char x) } static void -cea_audio_block(unsigned char *x) +cta_audio_block(unsigned char *x) { int i, format, ext_format = 0; int length = x[0] & 0x1f; if (length % 3) { - printf("Broken CEA audio block length %d\n", length); + printf("Broken CTA audio block length %d\n", length); /* XXX non-conformant */ return; } @@ -1114,12 +1114,12 @@ cea_audio_block(unsigned char *x) } } -struct edid_cea_mode { +struct edid_cta_mode { const char *name; int refresh, hor_freq_hz, pixclk_khz; }; -static struct edid_cea_mode edid_cea_modes1[] = { +static struct edid_cta_mode edid_cta_modes1[] = { /* VIC 1 */ {"640x480@60Hz 4:3", 60, 31469, 25175}, {"720x480@60Hz 4:3", 60, 31469, 27000}, @@ -1262,7 +1262,7 @@ static struct edid_cea_mode edid_cea_modes1[] = { {"5120x2160@100Hz 64:27", 100, 225000, 1485000}, }; -static struct edid_cea_mode edid_cea_modes2[] = { +static struct edid_cta_mode edid_cta_modes2[] = { /* VIC 193 */ {"5120x2160@120Hz 64:27", 120, 27, 1485000}, {"7680x4320@24Hz 16:9", 24, 108000, 1188000}, @@ -1295,23 +1295,23 @@ static struct edid_cea_mode edid_cea_modes2[] = { {"4096x2160@120Hz 256:135", 120, 27, 1188000}, }; -static const struct edid_cea_mode * +static const struct edid_cta_mode * vic_to_mode(unsigned char vic) { -if (vic > 0 && vic <= ARRAY_SIZE(edid_cea_modes1)) - return edid_cea_modes1 + vic - 1; -if (vic >= 193 && vic <= ARRAY_SIZE(edid_cea_modes2) + 193) - return edid_cea_modes2 + vic - 193; +if (vic > 0 && vic <= ARRAY_SIZE(edid_cta_modes1)) + return edid_cta_modes1 + vic - 1; +if (vic >= 193 && vic <= ARRAY_SIZE(edid_cta_modes2) + 193) + return edid_cta_modes2 + vic - 193; return NULL; } static void -cea_svd(unsigned char *x, int n, int for_ycbcr420) +cta_svd(unsigned char *x, int n, int for_ycbcr420) { int i; for (i = 0; i < n; i++) { - const struct edid_cea_mode *vicmode = NULL; + const struct edid_cta_mode *vicmode = NULL; unsigned char svd = x[i]; unsigned char native; unsigned char vic; @@ -1361,28 +1361,28 @@ cea_svd(unsigned char *x, int n, int for_ycbcr420) printf("VIC %3d %s %s HorFreq: %d Hz Clock: %.3f MHz\n", vic, mode, native ? "(native)" : "", hfreq, clock_khz / 1000.0); if (vic == 1) - has_cea861_vic_1 = 1; + has_cta861_vic_1 = 1; } } static void -cea_video_block(unsigned char *x) +cta_video_block(unsigned char *x) { int length = x[0] & 0x1f; -cea_svd(x + 1, length, 0); +cta_svd(x + 1, length, 0); } static void -cea_y420vdb(unsigned char *x) +cta_y420vdb(unsigned char *x) { int length = x[0] & 0x1f; -cea_svd(x + 2, length - 1, 1); +cta_svd(x + 2, length - 1, 1); } static void -cea_y420cmdb(unsigned char *x) +cta_y420cmdb(unsigned char *x) { int length = x[0] & 0x1f; int i; @@ -1398,7 +1398,7 @@ cea_y420cmdb(unsigned char *x) }
[PATCHv3 00/12] edid-decode: support new blocks, fix bad bit tests
From: Hans VerkuilThis second round of patches adds support for new post-CTA-861-F EDID additions. The first patch fixes three badly broken bit-tests. Arnaud Vrac caught one of those three as well: https://patchwork.freedesktop.org/patch/174655/ But this patch fixes all three. As far as I am aware after this patch series is applied the edid-decode tool is fully up to date with the latest CTA-861-G standard. Changes since v2: - fixed Makefile change in patch 7 (-lm should be at the end) - added patches 9-12. I thought I had added support for all CTA/HDMI data blocks but I missed two (InfoFrame and HDMI Audio). These are now also supported. Changes since v1: - moved the fix to the front of the series, so that can be applied even if other patches are still under discussion. - added a missing speaker entry to the speaker_map - the speaker locations != the speaker map, so made a new array for that (I misread the spec) - fixed various incorrect length and array offsets in handling the new data blocks. - incorporated some of the suggestions from Walter Harms. Regards, Hans Hans Verkuil (12): edid-decode: fix broken bit tests edid-decode: update Audio Block with CEA-861.2 edid-decode: update Speaker Allocation data block edid-decode: add support for Room/Speaker data blocks edid-decode: add new CTA-861-G VIC codes edid-decode: add DCI-P3 support in colorimetry block edid-decode: support HLG, decode luminance values edid-decode: add HDR Dynamic Metadata Data Block edid-decode: sync cea_block data block names with standard edid-decode: rename CEA/cea to CTA/cta edid-decode: add support for InfoFrame data block edid-decode: add support for the HDMI Audio Data Block Makefile | 2 +- edid-decode.c | 561 +++--- 2 files changed, 462 insertions(+), 101 deletions(-) -- 2.14.1 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCHv3 11/12] edid-decode: add support for InfoFrame data block
From: Hans VerkuilSupport this CTA-861 block. Signed-off-by: Hans Verkuil --- edid-decode.c | 32 1 file changed, 32 insertions(+) diff --git a/edid-decode.c b/edid-decode.c index 550c2d58..c61fde8a 100644 --- a/edid-decode.c +++ b/edid-decode.c @@ -1930,6 +1930,37 @@ cta_hdr_dyn_metadata_block(unsigned char *x) } } +static void +cta_ifdb(unsigned char *x) +{ +int length = x[0] & 0x1f; +int len_hdr = x[2] >> 5; + +if (length < 2) + return; +if (length < len_hdr + 4) + return; +printf("VSIFs: %d\n", x[3]); +length -= len_hdr + 3; +x += len_hdr + 4; +while (length > 0) { + int payload_len = x[0] >> 5; + + if ((x[0] & 0x1f) == 1 && length >= 4) { + printf("InfoFrame Type Code %d IEEE OUI: %02x%02x%02x\n", + x[0] & 0x1f, x[3], x[2], x[1]); + x += 4; + length -= 4; + } else { + printf("InfoFrame Type Code %d\n", x[0] & 0x1f); + x++; + length--; + } + x += payload_len; + length -= payload_len; +} +} + static void cta_block(unsigned char *x) { @@ -2031,6 +2062,7 @@ cta_block(unsigned char *x) break; case 0x20: printf("InfoFrame data block\n"); + cta_ifdb(x); break; default: if (x[1] >= 6 && x[1] <= 12) -- 2.14.1 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel