Re: Call for an EDID parsing library

2021-04-08 Thread Hans Verkuil
On 07/04/2021 12:31, Jani Nikula wrote:
> On Wed, 07 Apr 2021, Hans Verkuil  wrote:
>> It is the most complete EDID parser I know based on the various standards.
> 
> Does it support pure DisplayID in addition to DisplayID blocks embedded
> to EDID extension blocks? I think we'll be needing that sometime in the
> near future. (We don't yet support that in the kernel either.)

It doesn't, but that shouldn't be too hard to implement.

Do you have examples of that? If I had some, then I could implement support
for it in edid-decode.

Regards,

Hans
___
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


Re: Call for an EDID parsing library

2021-04-08 Thread Hans Verkuil
Hi Pekka,

On 07/04/2021 10:44, Pekka Paalanen wrote:
> Hi all,
> 
> with display servers proliferating thanks to Wayland, and the Linux
> kernel exposing only a very limited set of information based on EDID
> (rightfully so!), the need to interpret EDID blobs is spreading even
> more. I would like to start the discussion about starting a project to
> develop a shared library for parsing EDID blobs. This is not the first
> time either, other people have suggested it years and years ago already,
> but apparently it didn't quite materialise as far as I know.
> 
> Right now, it seems that more or less every display server and other
> KMS application is hand-rolling its own EDID parsing code, even for the
> most trivial information (monitor make, model, and serial number). With
> HDR and color management support coming to Wayland, the need to parse
> more things out of EDID will only increase. These things are not
> exposed by the kernel, and most of these things have no use for the
> kernel either.
> 
> My personal motivation for this is that I don't want to be developing
> or reviewing yet another partial EDID parser implementation in Weston.
> 
> I recall ponderings about sharing the same EDID parsing code between
> the kernel and userspace, but I got the feeling that it would be a
> hindrance in process more than a benefit from sharing code. It would
> need to live in the kernel tree, to be managed with the kernel
> development process, use the kernel "standard libraries", and adhere to
> kernel programming style - all which are good and fine, but maybe also
> more restricting than useful in this case. Therefore I would suggest a
> userspace-only library.
> 
> Everyone hand-rolling their own parsing code has the obvious
> disadvantages. In the opposite, I would expect a new shared EDID
> parsing library and project to:
> - be hosted under gitlab.freedesktop.org
> - be MIT licensed
> - offer at least a C ABI
> - employ mandatory Gitlab CI to ensure with sample EDID blobs that it
>   cannot regress
> 
> Prior art can be found in various places. I believe Xorg xserver has
> its battle-tested EDID parsing code. Ajax once played with the idea in
> https://cgit.freedesktop.org/~ajax/libminitru/ . Then we have
> https://git.linuxtv.org/edid-decode.git too which has code and test
> data but not a C ABI (right?).

Correct, I moved it to C++. It was never designed to be a library, it
was primarily meant to turn an EDID into a human readable format.

And these days it is also a very powerful tool to verify EDIDs.

It is the most complete EDID parser I know based on the various standards.

> It does not necessarily need to be a new project. Would edid-decode
> project be open to adding a C library ABI?

I would be open to that. The best way would be to create a C library that
turns the EDID blocks into C structures, while edid-decode itself remains
C++ and uses the C library to do the parsing. While edid-decode supports
a large range of Extension Blocks, a C library could probably limit itself
to the base block, CTA-861 blocks and DisplayID blocks.

> 
> edid-decode is already MIT licensed and seems to have a lot of code,
> too, but that's all I know for now.

It is as far as I know the most complete parser.

> 
> Would there be anyone interested to take lead or work on a project like
> this?

I can assist/advice and do code reviews, but I don't have the time myself
to do the actual work.

> 
> Personally I don't think I'd be working on it, but I would be really
> happy to use it in Weston.
> 
> Should it be a new project, or grow inside edid-decode or something
> else?

I think it would make sense if it is grown as a library used by edid-decode.
The edid-decode utility is under active maintenance and follows the latest
EDID standards, so that will probably help the quality of the library. My
main requirement would be that the edid-decode functionality is not
affected, especially the conformity checks are still performed. And that
support for new/updated EDID standards can easily be implemented, but that's
exactly what you would want in an edid library.

> 
> I believe MIT license is important to have wide adoption of it. C ABI
> similarly. Also that it would be a "small" library without heavy
> dependencies.

It shouldn't need any dependencies. edid-decode doesn't need any either
except for -lm, which is probably not needed for the library part.

> What do you think? Could anyone spare their time for this?

Didn't you just volunteer? :-) :-)

Regards,

Hans

> 
> Who would be interested in using it if this library appeared?
> 
> 
> Thanks,
> pq
> 

___
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


Re: [ANN] edid-decode maintenance info

2018-08-13 Thread Hans Verkuil
On 13/08/18 08:13, Daniel Stone wrote:
> Hi,
> 
> On Sun, 12 Aug 2018 at 21:53, Alan Coopersmith
>  wrote:
>> On 06/22/18 01:12 AM, Hans Verkuil wrote:
>>> Thank you for this information. I looked through all the bug reports and
>>> 100607, 100340 and 93366 were already fixed before I took over maintenance.
>>>
>>> I just fixed 89348 and 93777 in my git repo, so those can be marked as
>>> resolved.
>>
>> Since no one else has, I marked all of these resolved now with links to your
>> repo for the fixes.
>>
>>> The edid-decode component should probably be removed from the freedesktop
>>> bugzilla.
>>
>> I don't know how to do that without deleting the bugs, so I'm hoping Adam
>> or Daniel can do that, much as they've been doing for the stuff migrating
>> to gitlab.
> 
> edid-decode is already marked as inactive; the old bugs aren't deleted
> and it's possible to search by component, but you can't file new bugs
> against it.

Much appreciated for taking care of this!

Regards,

Hans
___
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

Re: [ANN] edid-decode maintenance info

2018-06-22 Thread Hans Verkuil
On 06/22/2018 01:36 AM, Alan Coopersmith wrote:
> On 06/21/18 01:59 AM, Hans Verkuil wrote:
>> Hi all,
>>
>> As Adam already announced earlier this week I'm taking over maintenance of
>> the edid-decode utility.
>>
>> Since I am already maintaining other utilities on git.linuxtv.org I decided
>> to move the edid-decode git repo to linuxtv.org as well. It is now available
>> here: https://git.linuxtv.org/edid-decode.git/
>>
>> Patches, bug reports, etc. should be mailed to linux-me...@vger.kernel.org
>> (see https://linuxtv.org/lists.php). Please make sure the subject line
>> contains 'edid-decode'.
>>
>> One thing I would like to tackle in the very near future is to add support 
>> for
>> the new HDMI 2.1b EDID additions.
>>
>> I also know that some patches for edid-decode were posted to xorg-devel that
>> were never applied. I will try to find them, but to be safe it is best to
>> repost them to linux-media.
> 
> Thanks - there's also a handful of open bug reports against edid-decode in
> our bugzilla as well, some of which have patches attached:
> 
> https://bugs.freedesktop.org/buglist.cgi?component=App%2Fedid-decode
> 

Thank you for this information. I looked through all the bug reports and
100607, 100340 and 93366 were already fixed before I took over maintenance.

I just fixed 89348 and 93777 in my git repo, so those can be marked as
resolved.

The edid-decode component should probably be removed from the freedesktop
bugzilla.

Regards,

Hans
___
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

[ANN] edid-decode maintenance info

2018-06-21 Thread Hans Verkuil
Hi all,

As Adam already announced earlier this week I'm taking over maintenance of
the edid-decode utility.

Since I am already maintaining other utilities on git.linuxtv.org I decided
to move the edid-decode git repo to linuxtv.org as well. It is now available
here: https://git.linuxtv.org/edid-decode.git/

Patches, bug reports, etc. should be mailed to linux-me...@vger.kernel.org
(see https://linuxtv.org/lists.php). Please make sure the subject line
contains 'edid-decode'.

One thing I would like to tackle in the very near future is to add support for
the new HDMI 2.1b EDID additions.

I also know that some patches for edid-decode were posted to xorg-devel that
were never applied. I will try to find them, but to be safe it is best to
repost them to linux-media.

Regards,

Hans Verkuil
___
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 13/12] edid-decode: Speaker location typo

2017-09-12 Thread Hans Verkuil
TpFH -> TpFR

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 edid-decode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/edid-decode.c b/edid-decode.c
index 92dbfcf1..5592227d 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -1693,7 +1693,7 @@ static const char *speaker_map[] = {
 "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",
+"TpFL/TpFR - Top Front Left/Right",
 "TpC - Top Center",
 "TpFC - Top Front Center",
 "LS/RS - Left/Right Surround",
@@ -1778,7 +1778,7 @@ static const char *speaker_location[] = {
 "SiL - Side Left",
 "SiR - Side Right",
 "TpFL - Top Front Left",
-"TpFH - Top Front Right",
+"TpFR - Top Front Right",
 "TpFC - Top Front Center",
 "TpC - Top Center",
 "TpBL - Top Back Left",
-- 
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 06/12] edid-decode: add DCI-P3 support in colorimetry block

2017-09-09 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

This bit was added in CTA-861-G.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 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

2017-09-09 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

This was introduced in HDMI 2.0.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 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

2017-09-09 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

The CTA-861-G standard (successor to CEA-861-F) adds new VIC codes.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 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) {
switc

[PATCHv3 07/12] edid-decode: support HLG, decode luminance values

2017-09-09 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

Add 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 <hans.verk...@cisco.com>
---
 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

2017-09-09 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

Add support for extended audio formats and report the format
specific information.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 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

2017-09-09 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

'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 <hans.verk...@cisco.com>
---
 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

2017-09-09 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

Support this CTA-861-G data block.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 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

2017-09-09 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

The names where a bit irregular, sync them up with the CTA-861-G
standard.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 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

2017-09-09 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

More bits are now in use, implement support for those.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 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

2017-09-09 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

Support the Room Configuration Data Block and the Speaker Location
Data Block.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 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

2017-09-09 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

The Consumer Electronics Association was renamed to Consumer Technology
Association. Update all cea references to cta.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 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, le

[PATCHv3 00/12] edid-decode: support new blocks, fix bad bit tests

2017-09-09 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

This 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

2017-09-09 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

Support this CTA-861 block.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 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

Re: [PATCHv2 5/8] edid-decode: add new CTA-861-G VIC codes

2017-09-08 Thread Hans Verkuil
On 09/08/17 15:13, walter harms wrote:
> 
> 
> Am 08.09.2017 12:32, schrieb Hans Verkuil:
>> From: Hans Verkuil <hans.verk...@cisco.com>
>>
>> The CTA-861-G standard (successor to CEA-861-F) adds new VIC codes.
>>
>> Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
>> ---
>>  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

Re: [PATCHv2 4/8] edid-decode: add support for Room/Speaker data blocks

2017-09-08 Thread Hans Verkuil
On 09/08/17 15:05, walter harms wrote:
> 
> 
> Am 08.09.2017 12:32, schrieb Hans Verkuil:
>> From: Hans Verkuil <hans.verk...@cisco.com>
>>
>> Support the Room Configuration Data Block and the Speaker Location
>> Data Block.
>>
>> Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
>> ---
>>  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]);
> 
> length >= 7)  ... x[8]);
> off by one ?
> 
>> +}
>> +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]));
> 
> off by one ?

No to both. It's confusing: the length does not include the first two bytes
in the x array. So if length == 1, then x is three bytes long.

It's something for a follow-up patch to clean this up: i.e. instead of
calling cea_rcdb(x) from cea_block(), it might be better to do:

cea_rcdb(x + 2, x[0] & 0x1f);

So cea_rcdb is just given the length and it starts at the correct beginning of
the data.

Same with using 'const unsigned char *x', that too is suitable as a follow-up
patch.

Regards,

Hans

> 
>> +}
>> +}
>> +
>> +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",
>> +  

[PATCHv2 5/8] edid-decode: add new CTA-861-G VIC codes

2017-09-08 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

The CTA-861-G standard (successor to CEA-861-F) adds new VIC codes.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 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) {
switc

[PATCHv2 8/8] edid-decode: add HDR Dynamic Metadata Data Block

2017-09-08 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

Support this CTA-861-G data block.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 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

[PATCHv2 6/8] edid-decode: add DCI-P3 support in colorimetry block

2017-09-08 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

This bit was added in CTA-861-G.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 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

[PATCHv2 7/8] edid-decode: support HLG, decode luminance values

2017-09-08 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

Add 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 <hans.verk...@cisco.com>
---
 Makefile  |  2 +-
 edid-decode.c | 15 ++-
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 21b811ed..b698c579 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 -lm -o $@ $<
 
 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

[PATCHv2 2/8] edid-decode: update Audio Block with CEA-861.2

2017-09-08 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

Add support for extended audio formats and report the format
specific information.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 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

[PATCHv2 1/8] edid-decode: fix broken bit tests

2017-09-08 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

'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 <hans.verk...@cisco.com>
---
 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

[PATCHv2 4/8] edid-decode: add support for Room/Speaker data blocks

2017-09-08 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

Support the Room Configuration Data Block and the Speaker Location
Data Block.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 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

[PATCHv2 0/8] edid-decode: support new blocks, fix bad bit tests

2017-09-08 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

This second round of patches adds support for new post-CEA-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 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 (8):
  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

 Makefile  |   2 +-
 edid-decode.c | 349 ++
 2 files changed, 306 insertions(+), 45 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

[PATCHv2 3/8] edid-decode: update Speaker Allocation data block

2017-09-08 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

More bits are now in use, implement support for those.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 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

Re: [PATCH 2/8] edid-decode: update Speaker Allocation data block

2017-09-08 Thread Hans Verkuil
On 09/08/17 10:50, walter harms wrote:
> 
> 
> Am 07.09.2017 20:03, schrieb Hans Verkuil:
>> From: Hans Verkuil <hans.verk...@cisco.com>
>>
>> More bits are now in use, implement support for those.
>>
>> Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
>> ---
>>  edid-decode.c | 38 ++
>>  1 file changed, 22 insertions(+), 16 deletions(-)
>>
>> diff --git a/edid-decode.c b/edid-decode.c
>> index 26550423..9b6c297e 100644
>> --- a/edid-decode.c
>> +++ b/edid-decode.c
>> @@ -1615,17 +1615,25 @@ 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",
>> +"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 +1643,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]);
>>  }
> 
> just a remark:
>  if (sad & 1)
>   
>  sad >>=1 ;
>  if (sad == 0) break;
> 
> to avoid testing empty bits ..

I believe that makes the code harder to read for no real performance
advantage (it wouldn't surprise me if it would actually be slower
in some cases!).

So I leave this as-is.

Regards,

Hans
___
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

Re: [PATCH 7/8] edid-decode: add HDR Dynamic Metadata Data Block

2017-09-08 Thread Hans Verkuil
On 09/08/17 10:22, walter harms wrote:
> 
> 
> Am 07.09.2017 20:03, schrieb Hans Verkuil:
>> From: Hans Verkuil <hans.verk...@cisco.com>
>>
>> Support this CTA-861-G data block.
>>
>> Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
>> ---
>>  edid-decode.c | 33 +
>>  1 file changed, 33 insertions(+)
>>
>> diff --git a/edid-decode.c b/edid-decode.c
>> index effcf777..cdba099d 100644
>> --- a/edid-decode.c
>> +++ b/edid-decode.c
>> @@ -1865,6 +1865,35 @@ 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 < 1)
>> +return;
> 
> complicated way to say if (length == 0)

Will fix this.

> 
> 
>> +length--;
>> +x--;
>> +while (length >= 3) {
>> +int type_len = x[0];
>> +int type = x[1] | (x[2] << 8);
>> +
> 
> Do you expect that x[?] will change ? otherwise this is const
> and the loop print the same data over and over again, or did i miss something 
> ?

It's a bug, I'm about to post a v2 of this series. (I found more bugs as well 
:-( ).

Regards,

Hans

> 
> hope that helps,
> re,
>  wh
> 
>> +if (length < type_len)
>> +return;
>> +printf("HDR Dynamic Metadata Type %d\n", type);
>> +switch (type) {
>> +case 1:
>> +case 2:
>> +case 4:
>> +printf("  Version: %d\n", x[3] & 0xf);
>> +break;
>> +default:
>> +break;
>> +}
>> +length -= type_len;
>> +}
>> +}
>> +
>>  static void
>>  cea_block(unsigned char *x)
>>  {
>> @@ -1931,6 +1960,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);
> ___
> 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

Re: [PATCH 6/8] edid-decode: support HLG, decode luminance values

2017-09-08 Thread Hans Verkuil
On 09/08/17 10:28, walter harms wrote:
> 
> 
> Am 07.09.2017 20:03, schrieb Hans Verkuil:
>> From: Hans Verkuil <hans.verk...@cisco.com>
>>
>> Add 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 <hans.verk...@cisco.com>
>> ---
>>  Makefile  |  2 +-
>>  edid-decode.c | 15 ++-
>>  2 files changed, 11 insertions(+), 6 deletions(-)
>>
>> diff --git a/Makefile b/Makefile
>> index 21b811ed..b698c579 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 -lm -o $@ $<
>>  
>>  clean:
>>  rm -f edid-decode
>> diff --git a/edid-decode.c b/edid-decode.c
>> index d0da48e2..effcf777 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))
>> @@ -1827,10 +1828,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;
>> @@ -1851,13 +1853,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);
> 
> are you sure that pow(x[6] / 255.0, 2) is correct ? other terms are pow( 2, 
> ...).

Yes, it's correct. I double checked this.

Regards,

Hans

> 
> re,
>  wh
> 
>>  }
>>  
>>  static void
>> @@ -1924,7 +1929,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");
> ___
> 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

Re: [PATCH 0/8] edid-decode: support new blocks, fix bad bit tests

2017-09-08 Thread Hans Verkuil
On 09/07/2017 08:03 PM, Hans Verkuil wrote:
> From: Hans Verkuil <hans.verk...@cisco.com>
> 
> This second round of patches adds support for new post-CEA-861-F
> EDID additions. The last 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.

Please ignore this patch series for now, I found a bug in the HDR dynamic
metadata block handling, and I think I need to do a few more tests first.

Regards,

Hans

> 
> Regards,
> 
>   Hans
> 
> Hans Verkuil (8):
>   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: fix broken bit tests
> 
>  Makefile  |   2 +-
>  edid-decode.c | 307 
> ++
>  2 files changed, 267 insertions(+), 42 deletions(-)
> 

___
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

[PATCH 9/8] edid-decode: increase indentation for audio properties

2017-09-08 Thread Hans Verkuil
When printing the audio properties of an audio format, indent the
text a bit further to the right to make it easier to see where
each audio format starts and to which audio format the properties
belong.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 edid-decode.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/edid-decode.c b/edid-decode.c
index ca6f57b9..0ab3f866 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -1085,7 +1085,7 @@ cea_audio_block(unsigned char *x)
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",
+   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" : "",
@@ -1094,21 +1094,21 @@ cea_audio_block(unsigned char *x)
   (x[i+1] & 0x02) ? " 44.1" : "",
   (x[i+1] & 0x01) ? " 32" : "");
if (format == 1 || ext_format == 13) {
-   printf("Supported sample sizes (bits):%s%s%s\n",
+   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);
+   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",
+   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",
+   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

Re: [PATCH 00/27] edid-decode: fixes and new features and checks

2017-09-07 Thread Hans Verkuil
On 09/07/2017 06:47 PM, Adam Jackson wrote:
> On Thu, 2017-09-07 at 08:53 +0200, Hans Verkuil wrote:
> 
>> Just wondering who will pick this up and (hopefully) merge it and
>> when?
>> I have more edid-decode patches pending and I was wondering whether I
>> should post those new patches only, or wait until this set is merged
>> (my preference).
> 
> Apologies, I took a rather longer Labor Day break than most and hadn't
> gotten to these yet. But this all looks great, thanks!

Thank you! A very, very good reason BTW :-)

I just posted my second (and last) round of edid-decode patches. This brings it
in line with the latest CTA-861-G standard.

BTW, if anyone has a Hybrid Log-Gamma capable TV, then I'd love to see the edid!

Regards,

Hans

> 
> remote: Updating patchwork state for 
> https://patchwork.freedesktop.org/project/Xorg/list/
> remote: I: patch #174536 updated using rev 
> 56767cfbe67f19fecb355d790f35887ad0c5c991.
> remote: I: patch #174529 updated using rev 
> b120a093f38aebaf146a3ed45b39b8eeb6fd0747.
> remote: I: patch #174533 updated using rev 
> b4f8eefc0c58fc40450f0233bae1d621d87843ca.
> remote: I: patch #174513 updated using rev 
> 5ee6ed76270a0dd9334c01b69136dcbd09644a12.
> remote: I: patch #174521 updated using rev 
> 277bcbd2a4110fed9200e97797e7cded348822f2.
> remote: I: patch #174525 updated using rev 
> f8397bb24d920ca23e80df25f0f3052998295c3f.
> remote: I: patch #174517 updated using rev 
> 876ff5e51ac48abe5a4e290fda51cd6e6b2568dc.
> remote: I: patch #174535 updated using rev 
> 4e3780670a33a7394f59c54fe2fa7bce7db914b9.
> remote: I: patch #174510 updated using rev 
> ca252201ddfbf7ed99d54759b5b6a0e6274d87c7.
> remote: I: patch #174515 updated using rev 
> 83cd9713a3eb07e687471d117d3cde017a3ae58b.
> remote: I: patch #174519 updated using rev 
> b0d44a8b55f9d961e8af02d74411afae1ce687c2.
> remote: I: patch #174514 updated using rev 
> 5e7fc7ba19d74bb66d26b232068952bad10fea15.
> remote: I: patch #174516 updated using rev 
> 0cdf932cef9f9d2a4b38895939bc85d0fcddbf28.
> remote: E: failed to find patch for rev 
> 0f3958e1bd00283e793a5762ebdbc4ff9775a545.
> remote: I: patch #174527 updated using rev 
> 5c98e1965968f387f9b98602e37d45fa79c4d49b.
> remote: E: failed to find patch for rev 
> 86a43ab066079e63b1f22f6954b31a55c9877aed.
> remote: I: patch #174534 updated using rev 
> 918bdf78c518465485a232df0ddac39e602d4965.
> remote: I: patch #174511 updated using rev 
> 4798aef8b6f16d86e6d03f8e1667fc2da6ad37d1.
> remote: I: patch #174530 updated using rev 
> f1799a90e4a7ff114cfb24ad6ea0660159dd94a5.
> remote: I: patch #174522 updated using rev 
> 4f30798e0306309add1f273bb9aca7f5a00c8464.
> remote: I: patch #174512 updated using rev 
> 1ea2b1fef85cdaba11db519eda8c4e1d294022be.
> remote: I: patch #174531 updated using rev 
> 3f134e35f0953ee13202b7a23948f207393167e3.
> remote: I: patch #174523 updated using rev 
> d3fc557cd790b2473aa219426fd77eec746f3297.
> remote: I: patch #174528 updated using rev 
> 9c1817ea8f1092abb212f4256d4a20d57311d952.
> remote: I: patch #174520 updated using rev 
> 6b29ce0137baa50fa68ad9f892120d9d09aae410.
> remote: I: patch #174526 updated using rev 
> 90d904a64d4ba86e8c768c26ae498b1d69ca1d57.
> remote: I: patch #174532 updated using rev 
> 60a67872f213fda03df4968ca61d2eb17a8cb8a8.
> remote: I: 25 patch(es) updated to state Accepted.
> To ssh://git.freedesktop.org/git/xorg/app/edid-decode
>b202b67..60a6787  master -> master
> 
> - ajax
> ___
> 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

[PATCH 5/8] edid-decode: add DCI-P3 support in colorimetry block

2017-09-07 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

This bit was added in CTA-861-G.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 edid-decode.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/edid-decode.c b/edid-decode.c
index caf35907..d0da48e2 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -1818,6 +1818,8 @@ cea_colorimetry_block(unsigned char *x)
if (x[2] >> 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

[PATCH 6/8] edid-decode: support HLG, decode luminance values

2017-09-07 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

Add 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 <hans.verk...@cisco.com>
---
 Makefile  |  2 +-
 edid-decode.c | 15 ++-
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 21b811ed..b698c579 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 -lm -o $@ $<
 
 clean:
rm -f edid-decode
diff --git a/edid-decode.c b/edid-decode.c
index d0da48e2..effcf777 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))
@@ -1827,10 +1828,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;
@@ -1851,13 +1853,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
@@ -1924,7 +1929,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

[PATCH 4/8] edid-decode: add new CTA-861-G VIC codes

2017-09-07 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

The CTA-861-G standard (successor to CEA-861-F) adds new VIC codes.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 edid-decode.c | 93 +++
 1 file changed, 81 insertions(+), 12 deletions(-)

diff --git a/edid-decode.c b/edid-decode.c
index bdeb0c49..caf35907 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) {
switc

[PATCH 0/8] edid-decode: support new blocks, fix bad bit tests

2017-09-07 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

This second round of patches adds support for new post-CEA-861-F
EDID additions. The last 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.

Regards,

Hans

Hans Verkuil (8):
  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: fix broken bit tests

 Makefile  |   2 +-
 edid-decode.c | 307 ++
 2 files changed, 267 insertions(+), 42 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

[PATCH 2/8] edid-decode: update Speaker Allocation data block

2017-09-07 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

More bits are now in use, implement support for those.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 edid-decode.c | 38 ++
 1 file changed, 22 insertions(+), 16 deletions(-)

diff --git a/edid-decode.c b/edid-decode.c
index 26550423..9b6c297e 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -1615,17 +1615,25 @@ 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",
+"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 +1643,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

[PATCH 3/8] edid-decode: add support for Room/Speaker data blocks

2017-09-07 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

Support the Room Configuration Data Block and the Speaker Location
Data Block.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 edid-decode.c | 79 ---
 1 file changed, 76 insertions(+), 3 deletions(-)

diff --git a/edid-decode.c b/edid-decode.c
index 9b6c297e..bdeb0c49 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",
@@ -1647,13 +1647,78 @@ 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
+uchar_to_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 < 12)
+   return;
+
+if (x[2] & 0x40)
+   printf("Speaker count: %d\n", x[2] & 0x1f);
+
+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) {
+   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) {
+   printf("DisplayX: %.3f * Xmax\n", uchar_to_float(x[9]));
+   printf("DisplayY: %.3f * Ymax\n", uchar_to_float(x[10]));
+   printf("DisplayZ: %.3f * Zmax\n", uchar_to_float(x[11]));
+}
+}
+
+static void
+cea_sldb(unsigned char *x)
+{
+int length = x[0] & 0x1f;
+
+if (length < 2)
+   return;
+
+x += 2;
+length -= 2;
+
+while (length >= 2) {
+   printf("Channel: %d (%sactive)\n", x[0] & 0x1f,
+  (x[0] & 0x20) ? "" : "not ");
+   if ((x[1] & 0x1f) < ARRAY_SIZE(speaker_map))
+   printf("Speaker: %s\n", speaker_map[x[1] & 0x1f]);
+   if (length >= 5 && (x[0] & 0x40)) {
+   printf("X: %.3f * Xmax\n", uchar_to_float(x[2]));
+   printf("Y: %.3f * Ymax\n", uchar_to_float(x[3]));
+   printf("Z: %.3f * Zmax\n", uchar_to_float(x[4]));
+   length -= 3;
+   }
+
+   length -= 2;
+}
+}
+
 static void
 cea_vcdb(unsigned char *x)
 {
@@ -1811,6 +1876,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

[PATCH 8/8] edid-decode: fix broken bit tests

2017-09-07 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

'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 <hans.verk...@cisco.com>
---
 edid-decode.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/edid-decode.c b/edid-decode.c
index cdba099d..ca6f57b9 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -1816,7 +1816,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]);
}
if (x[3] & 0x80)
@@ -1840,14 +1840,14 @@ cea_hdr_static_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

[PATCH 1/8] edid-decode: update Audio Block with CEA-861.2

2017-09-07 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

Add support for extended audio formats and report the format
specific information.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 edid-decode.c | 45 +
 1 file changed, 41 insertions(+), 4 deletions(-)

diff --git a/edid-decode.c b/edid-decode.c
index 7aaeacee..26550423 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,8 +1073,17 @@ 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);
+   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" : "",
@@ -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) {
+   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);
+   } 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

[PATCH 7/8] edid-decode: add HDR Dynamic Metadata Data Block

2017-09-07 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

Support this CTA-861-G data block.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 edid-decode.c | 33 +
 1 file changed, 33 insertions(+)

diff --git a/edid-decode.c b/edid-decode.c
index effcf777..cdba099d 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -1865,6 +1865,35 @@ 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 < 1)
+   return;
+length--;
+x--;
+while (length >= 3) {
+   int type_len = x[0];
+   int type = x[1] | (x[2] << 8);
+
+   if (length < type_len)
+   return;
+   printf("HDR Dynamic Metadata Type %d\n", type);
+   switch (type) {
+   case 1:
+   case 2:
+   case 4:
+   printf("  Version: %d\n", x[3] & 0xf);
+   break;
+   default:
+   break;
+   }
+   length -= type_len;
+}
+}
+
 static void
 cea_block(unsigned char *x)
 {
@@ -1931,6 +1960,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

Re: [PATCH 00/27] edid-decode: fixes and new features and checks

2017-09-07 Thread Hans Verkuil
Hi all,

On 08/31/2017 01:40 PM, Hans Verkuil wrote:
> From: Hans Verkuil <hans.verk...@cisco.com>
> 
> This edid-decode patch series has been sitting in my git repo for
> way too long, so it is time to upstream this.
> 
> We (that is Cisco Systems Norway) have been using this to verify
> both our own and others EDIDs. So besides adding support for new
> data blocks and correcting little bugs all over it also improves
> compliance checks. Especially making sure that the reported
> timings are not out of range of the reported monitor frequency
> range.

Just wondering who will pick this up and (hopefully) merge it and when?
I have more edid-decode patches pending and I was wondering whether I
should post those new patches only, or wait until this set is merged
(my preference).

Regards,

    Hans

> 
> Regards,
> 
>   Hans Verkuil
> 
> Hans Verkuil (27):
>   edid-decode: add HDMI Forum VSDB support
>   edid-decode: print the chromaticities
>   edid-decode: report picture aspect ratio
>   edid-decode: add check for both serial number and string
>   edid-decode: verify 640x480p60 is defined for CEA-861
>   edid-decode: bit 0, byte 0x18 has been renamed for EDID 1.4
>   edid-decode: fix CVT version
>   edid-decode: fix "Supports CVT standard blanking"
>   edid-decode: add support for the "More standard timings" block
>   edid-decode: add Display Color Management support
>   edid-decode: add support for the Color Point
>   edid-decode: add support for Established Timings III
>   edid-decode: add horizontal freq and pixelclock
>   edid-decode: check monitor min/max range against supported timings
>   edid-decode: SVDs in the 4:2:0 Data Block have half the pixclk
>   edid-decode: YCbCr 4:2:0 Capability Map support
>   edid-decode: fix has_preferred_timing handling for 1.4
>   edid-decode: fix week/year interpretation.
>   edid-decode: fix 1.3/1.4 differences in Model Year and Feature Support
>   edid-decode: return 1 if no edid was found
>   edid-decode: improve the hex dump parser to be more generic
>   edid-decode: allow for comma separated hex values
>   edid-decode: allow the year to be one year in the future
>   edid-decode: check Max TMDS Rates
>   edid-decode: check if HDMI VICs are also in the VSB
>   edid-decode: calculate hfreq and clock from CVT
>   edid-decode: show correct EDID version in string
> 
>  edid-decode.c | 1080 
> -
>  1 file changed, 833 insertions(+), 247 deletions(-)
> 

___
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

[PATCH 26/27] edid-decode: calculate hfreq and clock from CVT

2017-08-31 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

Support CVT 3 byte codes and calculate the horizontal frequencies
and max clock from them. Use this to improve the range checking.

Also always print the hfreq and clock for the timings to help
figuring out which timings are out of the monitor range.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 edid-decode.c | 236 ++
 1 file changed, 204 insertions(+), 32 deletions(-)

diff --git a/edid-decode.c b/edid-decode.c
index 6a9b6850..815e26ab 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -177,6 +177,138 @@ static char *manufacturer_name(unsigned char *x)
 return name;
 }
 
+/*
+ * Copied from xserver/hw/xfree86/modes/xf86cvt.c
+ */
+static void edid_cvt_mode(int HDisplay, int VDisplay,
+ int VRefresh, int Reduced,
+ unsigned *MinHFreq, unsigned *MaxHFreq,
+ unsigned *MaxClock)
+{
+/* 1) top/bottom margin size (% of height) - default: 1.8 */
+#define CVT_MARGIN_PERCENTAGE 1.8
+
+/* 2) character cell horizontal granularity (pixels) - default 8 */
+#define CVT_H_GRANULARITY 8
+
+/* 4) Minimum vertical porch (lines) - default 3 */
+#define CVT_MIN_V_PORCH 3
+
+/* 4) Minimum number of vertical back porch lines - default 6 */
+#define CVT_MIN_V_BPORCH 6
+
+/* Pixel Clock step (kHz) */
+#define CVT_CLOCK_STEP 250
+
+float HPeriod;
+unsigned HTotal, Clock, HorFreq;
+int VSync;
+
+/* 2. Horizontal pixels */
+HDisplay = HDisplay - (HDisplay % CVT_H_GRANULARITY);
+
+/* Determine VSync Width from aspect ratio */
+if (!(VDisplay % 3) && ((VDisplay * 4 / 3) == HDisplay))
+VSync = 4;
+else if (!(VDisplay % 9) && ((VDisplay * 16 / 9) == HDisplay))
+VSync = 5;
+else if (!(VDisplay % 10) && ((VDisplay * 16 / 10) == HDisplay))
+VSync = 6;
+else if (!(VDisplay % 4) && ((VDisplay * 5 / 4) == HDisplay))
+VSync = 7;
+else if (!(VDisplay % 9) && ((VDisplay * 15 / 9) == HDisplay))
+VSync = 7;
+else/* Custom */
+VSync = 10;
+
+if (!Reduced) { /* simplified GTF calculation */
+
+/* 4) Minimum time of vertical sync + back porch interval (µs)
+ * default 550.0 */
+#define CVT_MIN_VSYNC_BP 550.0
+
+/* 3) Nominal HSync width (% of line period) - default 8 */
+#define CVT_HSYNC_PERCENTAGE 8
+
+float HBlankPercentage;
+int HBlank;
+
+/* 8. Estimated Horizontal period */
+HPeriod = ((float) (100.0 / VRefresh - CVT_MIN_VSYNC_BP)) /
+(VDisplay + CVT_MIN_V_PORCH);
+
+/* 5) Definition of Horizontal blanking time limitation */
+/* Gradient (%/kHz) - default 600 */
+#define CVT_M_FACTOR 600
+
+/* Offset (%) - default 40 */
+#define CVT_C_FACTOR 40
+
+/* Blanking time scaling factor - default 128 */
+#define CVT_K_FACTOR 128
+
+/* Scaling factor weighting - default 20 */
+#define CVT_J_FACTOR 20
+
+#define CVT_M_PRIME CVT_M_FACTOR * CVT_K_FACTOR / 256
+#define CVT_C_PRIME (CVT_C_FACTOR - CVT_J_FACTOR) * CVT_K_FACTOR / 256 + \
+CVT_J_FACTOR
+
+/* 12. Find ideal blanking duty cycle from formula */
+HBlankPercentage = CVT_C_PRIME - CVT_M_PRIME * HPeriod / 1000.0;
+
+/* 13. Blanking time */
+if (HBlankPercentage < 20)
+HBlankPercentage = 20;
+
+HBlank = HDisplay * HBlankPercentage / (100.0 - HBlankPercentage);
+HBlank -= HBlank % (2 * CVT_H_GRANULARITY);
+
+/* 14. Find total number of pixels in a line. */
+HTotal = HDisplay + HBlank;
+}
+else {  /* Reduced blanking */
+/* Minimum vertical blanking interval time (µs) - default 460 */
+#define CVT_RB_MIN_VBLANK 460.0
+
+/* Fixed number of clocks for horizontal sync */
+#define CVT_RB_H_SYNC 32.0
+
+/* Fixed number of clocks for horizontal blanking */
+#define CVT_RB_H_BLANK 160.0
+
+/* Fixed number of lines for vertical front porch - default 3 */
+#define CVT_RB_VFPORCH 3
+
+int VBILines;
+
+/* 8. Estimate Horizontal period. */
+HPeriod = ((float) (100.0 / VRefresh - CVT_RB_MIN_VBLANK)) / 
VDisplay;
+
+/* 9. Find number of lines in vertical blanking */
+VBILines = ((float) CVT_RB_MIN_VBLANK) / HPeriod + 1;
+
+/* 10. Check if vertical blanking is sufficient */
+if (VBILines < (CVT_RB_VFPORCH + VSync + CVT_MIN_V_BPORCH))
+VBILines = CVT_RB_VFPORCH + VSync + CVT_MIN_V_BPORCH;
+
+/* 12. Find total number of pixels in a line */
+HTotal = HDisplay + CVT_RB_H_BLANK;
+}
+
+/* 15/13. Find pixel clock frequency (kHz for xf86) */
+Clock = HTotal * 1000.0 / HPeriod;
+Clock -= Clock % CVT_CLOCK_STEP;
+HorFreq = (Clock * 1000) / HTotal;
+
+*MinHFreq = min(*M

[PATCH 24/27] edid-decode: check Max TMDS Rates

2017-08-31 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

The max TMDS rate in the HDMI VSDB is 340 MHz and the max TMDS
rate in the HDMI Forum VSDB is 0 or in the range 341-600 MHz.
Check for this.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 edid-decode.c | 22 +++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/edid-decode.c b/edid-decode.c
index 5a5fb5bd..f106ce5e 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -77,6 +77,8 @@ 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_hdmi_vsdb_tmds_rate = 0;
+static int nonconformant_hf_vsdb_tmds_rate = 0;
 
 static int min_hor_freq_hz = 0xfff;
 static int max_hor_freq_hz = 0;
@@ -1171,8 +1173,11 @@ cea_hdmi_block(unsigned char *x)
printf("DVI_Dual\n");
 }
 
-if (length > 6)
+if (length > 6) {
printf("Maximum TMDS clock: %dMHz\n", x[7] * 5);
+   if (x[7] * 5 > 340)
+   nonconformant_hdmi_vsdb_tmds_rate = 1;
+}
 
 /* XXX the walk here is really ugly, and needs to be length-checked */
 if (length > 7) {
@@ -1328,8 +1333,13 @@ cea_hf_block(unsigned char *x)
 {
 printf(" (HDMI Forum)\n");
 printf("Version: %u\n", x[4]);
-if (x[5])
-   printf("Maximum TMDS Character Rate: %uMHz\n", x[5] * 5);
+if (x[5]) {
+   unsigned rate = x[5] * 5;
+
+   printf("Maximum TMDS Character Rate: %uMHz\n", rate);
+   if ((rate && rate <= 340) || rate > 600)
+   nonconformant_hf_vsdb_tmds_rate = 1;
+}
 if (x[6] & 0x80)
printf("SCDC Present\n");
 if (x[6] & 0x40)
@@ -2404,6 +2414,8 @@ int main(int argc, char **argv)
 if (claims_one_point_three) {
if (nonconformant_digital_display ||
nonconformant_hf_vsdb_position ||
+   nonconformant_hdmi_vsdb_tmds_rate ||
+   nonconformant_hf_vsdb_tmds_rate ||
nonconformant_srgb_chromaticity ||
nonconformant_cea861_640x480 ||
!has_valid_string_termination ||
@@ -2425,6 +2437,10 @@ int main(int argc, char **argv)
   "\tand/or in the SVD list (VIC 1)\n");
if (nonconformant_hf_vsdb_position)
printf("\tHDMI Forum VSDB did not immediately follow the HDMI 
VSDB\n");
+   if (nonconformant_hdmi_vsdb_tmds_rate)
+   printf("\tHDMI VSDB Max TMDS rate is > 340\n");
+   if (nonconformant_hf_vsdb_tmds_rate)
+   printf("\tHDMI Forum VSDB Max TMDS rate is > 0 and <= 340 or > 
600\n");
if (!has_name_descriptor)
printf("\tMissing name descriptor\n");
else if (!name_descriptor_terminated)
-- 
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

[PATCH 08/27] edid-decode: fix "Supports CVT standard blanking"

2017-08-31 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

The wrong bit was tested.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 edid-decode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/edid-decode.c b/edid-decode.c
index 4105700f..5a162b14 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -460,7 +460,7 @@ detailed_block(unsigned char *x, int in_extension)
}
printf("\n");
 
-   if (x[15] & 0x04)
+   if (x[15] & 0x08)
printf("Supports CVT standard blanking\n");
if (x[15] & 0x10)
printf("Supports CVT reduced blanking\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

[PATCH 02/27] edid-decode: print the chromaticities

2017-08-31 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

Also warn if the sRGB bit is set but the chromaticities do not
match sRGB.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 edid-decode.c | 38 --
 1 file changed, 36 insertions(+), 2 deletions(-)

diff --git a/edid-decode.c b/edid-decode.c
index 47765801..4deceba4 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -68,6 +68,7 @@ static int seen_non_detailed_descriptor = 0;
 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 conformant = 1;
 
@@ -1822,6 +1823,7 @@ int main(int argc, char **argv)
 time_t the_time;
 struct tm *ptm;
 int analog, i;
+unsigned col_x, col_y;
 
 switch (argc) {
case 1:
@@ -2021,8 +2023,21 @@ int main(int argc, char **argv)
printf("\n");
 }
 
-if (edid[0x18] & 0x04)
+if (edid[0x18] & 0x04) {
+   /*
+* The sRGB chromaticities are (x, y):
+* red:   0.640,  0.330
+* green: 0.300,  0.600
+* blue:  0.150,  0.060
+* white: 0.3127, 0.3290
+*/
+   static const unsigned char srgb_chromaticity[10] = {
+   0xee, 0x91, 0xa3, 0x54, 0x4c, 0x99, 0x26, 0x0f, 0x50, 0x54
+   };
printf("Default (sRGB) color space is primary color space\n");
+   nonconformant_srgb_chromaticity =
+   memcmp(edid + 0x19, srgb_chromaticity, sizeof(srgb_chromaticity));
+}
 if (edid[0x18] & 0x02) {
printf("First detailed timing is preferred timing\n");
has_preferred_timing = 1;
@@ -2030,7 +2045,23 @@ int main(int argc, char **argv)
 if (edid[0x18] & 0x01)
printf("Supports GTF timings within operating range\n");
 
-/* XXX color section */
+printf("Display x,y Chromaticity:\n");
+col_x = (edid[0x1b] << 2) | (edid[0x19] >> 6);
+col_y = (edid[0x1c] << 2) | ((edid[0x19] >> 4) & 3);
+printf("  Red:   0.%04u, 0.%04u\n",
+  (col_x * 1) / 1024, (col_y * 1) / 1024);
+col_x = (edid[0x1d] << 2) | ((edid[0x19] >> 2) & 3);
+col_y = (edid[0x1e] << 2) | (edid[0x19] & 3);
+printf("  Green: 0.%04u, 0.%04u\n",
+  (col_x * 1) / 1024, (col_y * 1) / 1024);
+col_x = (edid[0x1f] << 2) | (edid[0x1a] >> 6);
+col_y = (edid[0x20] << 2) | ((edid[0x1a] >> 4) & 3);
+printf("  Blue:  0.%04u, 0.%04u\n",
+  (col_x * 1) / 1024, (col_y * 1) / 1024);
+col_x = (edid[0x21] << 2) | ((edid[0x1a] >> 2) & 3);
+col_y = (edid[0x22] << 2) | (edid[0x1a] & 3);
+printf("  White: 0.%04u, 0.%04u\n",
+  (col_x * 1) / 1024, (col_y * 1) / 1024);
 
 printf("Established timings supported:\n");
 for (i = 0; i < 17; i++) {
@@ -2097,6 +2128,7 @@ int main(int argc, char **argv)
 if (claims_one_point_three) {
if (nonconformant_digital_display ||
nonconformant_hf_vsdb_position ||
+   nonconformant_srgb_chromaticity ||
!has_valid_string_termination ||
!has_valid_descriptor_pad ||
!has_name_descriptor ||
@@ -2106,6 +2138,8 @@ int main(int argc, char **argv)
conformant = 0;
if (!conformant)
printf("EDID block does NOT conform to EDID 1.3!\n");
+   if (nonconformant_srgb_chromaticity)
+   printf("\tsRGB is signaled, but the chromaticities do not match\n");
if (nonconformant_digital_display)
printf("\tDigital display field contains garbage: %x\n",
   nonconformant_digital_display);
-- 
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

[PATCH 15/27] edid-decode: SVDs in the 4:2:0 Data Block have half the pixclk

2017-08-31 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

SVDs in the 4:2:0 Capability Data Block run at half the normal
pixelclock. Take that into consideration when updating the max
pixelclock.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 edid-decode.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/edid-decode.c b/edid-decode.c
index a3f23401..0ae465f2 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -1035,7 +1035,7 @@ static struct {
 };
 
 static void
-cea_svd(unsigned char *x, int n)
+cea_svd(unsigned char *x, int n, int for_ycbcr420)
 {
 int i;
 
@@ -1062,7 +1062,8 @@ cea_svd(unsigned char *x, int n)
max_vert_freq_hz = max(max_vert_freq_hz, edid_cea_modes[vic - 
1].refresh);
min_hor_freq_hz = min(min_hor_freq_hz, edid_cea_modes[vic - 
1].hor_freq_hz);
max_hor_freq_hz = max(max_hor_freq_hz, edid_cea_modes[vic - 
1].hor_freq_hz);
-   max_pixclk_khz = max(max_pixclk_khz, edid_cea_modes[vic - 
1].pixclk_khz);
+   max_pixclk_khz = max(max_pixclk_khz,
+edid_cea_modes[vic - 1].pixclk_khz / 
(for_ycbcr420 ? 2 : 1));
} else {
mode = "Unknown mode";
}
@@ -1078,7 +1079,7 @@ cea_video_block(unsigned char *x)
 {
 int length = x[0] & 0x1f;
 
-cea_svd(x + 1, length);
+cea_svd(x + 1, length, 0);
 }
 
 static void
@@ -1086,7 +1087,7 @@ cea_y420vdb(unsigned char *x)
 {
 int length = x[0] & 0x1f;
 
-cea_svd(x + 2, length - 1);
+cea_svd(x + 2, length - 1, 1);
 }
 
 static void
-- 
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

[PATCH 27/27] edid-decode: show correct EDID version in string

2017-08-31 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

Show correct EDID version in a string. Also turn the monitor range
check into a warning for EDID 1.4 (an 1.4 Errata says that explicitly
mentioned timings supersede the monitor range definition).

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 edid-decode.c | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/edid-decode.c b/edid-decode.c
index 815e26ab..7aaeacee 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -40,6 +40,7 @@ enum {
 EDID_PAGE_SIZE = 128u
 };
 
+static int edid_minor = 0;
 static int claims_one_point_oh = 0;
 static int claims_one_point_two = 0;
 static int claims_one_point_three = 0;
@@ -2359,6 +2360,7 @@ int main(int argc, char **argv)
printf("Claims > 1.4, assuming 1.4 conformance\n");
edid[0x13] = 4;
}
+   edid_minor = edid[0x13];
switch (edid[0x13]) {
case 4:
claims_one_point_four = 1;
@@ -2611,10 +2613,10 @@ int main(int argc, char **argv)
!has_name_descriptor ||
!name_descriptor_terminated ||
!has_preferred_timing ||
-   !has_range_descriptor)
+   (!claims_one_point_four && !has_range_descriptor))
conformant = 0;
if (!conformant)
-   printf("EDID block does NOT conform to EDID 1.3!\n");
+   printf("EDID block does NOT conform to EDID 1.%d!\n", edid_minor);
if (nonconformant_srgb_chromaticity)
printf("\tsRGB is signaled, but the chromaticities do not match\n");
if (nonconformant_digital_display)
@@ -2667,7 +2669,14 @@ int main(int argc, char **argv)
 min_hor_freq_hz < mon_min_hor_freq_hz ||
 max_hor_freq_hz > mon_max_hor_freq_hz ||
 max_pixclk_khz > mon_max_pixclk_khz)) {
-   conformant = 0;
+   /*
+* EDID 1.4 states (in an Errata) that explicitly defined
+* timings supersede the monitor range definition.
+*/
+   if (!claims_one_point_four)
+   conformant = 0;
+   else
+   printf("Warning: ");
printf("One or more of the timings is out of range of the Monitor 
Ranges:\n");
printf("  Vertical Freq: %d - %d Hz\n", min_vert_freq_hz, 
max_vert_freq_hz);
printf("  Horizontal Freq: %d - %d Hz\n", min_hor_freq_hz, 
max_hor_freq_hz);
-- 
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

[PATCH 19/27] edid-decode: fix 1.3/1.4 differences in Model Year and Feature Support

2017-08-31 Thread Hans Verkuil
From: Hans Verkuil <hansv...@cisco.com>

The Model Year is only available in 1.4. And in 1.3 bits 4-3 are always
for the Display Type.

Signed-off-by: Hans Verkuil <hansv...@cisco.com>
---
 edid-decode.c | 43 +--
 1 file changed, 21 insertions(+), 22 deletions(-)

diff --git a/edid-decode.c b/edid-decode.c
index ed725ff4..660ae7a9 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -2157,6 +2157,25 @@ int main(int argc, char **argv)
// return 1;
 }
 
+printf("EDID version: %hd.%hd\n", edid[0x12], edid[0x13]);
+if (edid[0x12] == 1) {
+   if (edid[0x13] > 4) {
+   printf("Claims > 1.4, assuming 1.4 conformance\n");
+   edid[0x13] = 4;
+   }
+   switch (edid[0x13]) {
+   case 4:
+   claims_one_point_four = 1;
+   case 3:
+   claims_one_point_three = 1;
+   case 2:
+   claims_one_point_two = 1;
+   default:
+   break;
+   }
+   claims_one_point_oh = 1;
+}
+
 printf("Manufacturer: %s Model %x Serial Number %u\n",
manufacturer_name(edid + 0x08),
(unsigned short)(edid[0x0A] + (edid[0x0B] << 8)),
@@ -2167,7 +2186,7 @@ int main(int argc, char **argv)
 
 time(_time);
 ptm = localtime(_time);
-if (edid[0x10] < 55 || edid[0x10] == 0xff) {
+if (edid[0x10] < 55 || (edid[0x10] == 0xff && claims_one_point_four)) {
has_valid_week = 1;
if (edid[0x11] > 0x0f) {
if (edid[0x10] == 0xff) {
@@ -2183,25 +2202,6 @@ int main(int argc, char **argv)
}
 }
 
-printf("EDID version: %hd.%hd\n", edid[0x12], edid[0x13]);
-if (edid[0x12] == 1) {
-   if (edid[0x13] > 4) {
-   printf("Claims > 1.4, assuming 1.4 conformance\n");
-   edid[0x13] = 4;
-   }
-   switch (edid[0x13]) {
-   case 4:
-   claims_one_point_four = 1;
-   case 3:
-   claims_one_point_three = 1;
-   case 2:
-   claims_one_point_two = 1;
-   default:
-   break;
-   }
-   claims_one_point_oh = 1;
-}
-
 /* display section */
 
 if (edid[0x14] & 0x80) {
@@ -2294,8 +2294,7 @@ int main(int argc, char **argv)
printf("\n");
 }
 
-/* FIXME: this is from 1.4 spec, check earlier */
-if (analog) {
+if (analog || !claims_one_point_four) {
switch (edid[0x18] & 0x18) {
case 0x00: printf("Monochrome or grayscale display\n"); break;
case 0x08: printf("RGB color display\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

[PATCH 22/27] edid-decode: allow for comma separated hex values

2017-08-31 Thread Hans Verkuil
From: Hans Verkuil <hansv...@cisco.com>

Useful when the hex dump comes from source code.

Signed-off-by: Hans Verkuil <hansv...@cisco.com>
---
 edid-decode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/edid-decode.c b/edid-decode.c
index d38d2a3d..ea443259 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -1976,7 +1976,7 @@ extract_edid(int fd)
 }
 
 /* Is the EDID provided in hex? */
-for (i = 0; i < 32 && (isspace(ret[i]) || tolower(ret[i]) == 'x' || 
isxdigit(ret[i])); i++);
+for (i = 0; i < 32 && (isspace(ret[i]) || ret[i] == ',' || tolower(ret[i]) 
== 'x' || isxdigit(ret[i])); i++);
 if (i == 32) {
out = malloc(size >> 1);
if (out == NULL) {
-- 
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

[PATCH 03/27] edid-decode: report picture aspect ratio

2017-08-31 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 edid-decode.c | 296 +++---
 1 file changed, 157 insertions(+), 139 deletions(-)

diff --git a/edid-decode.c b/edid-decode.c
index 4deceba4..31aca8aa 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -158,6 +158,7 @@ static int
 detailed_cvt_descriptor(unsigned char *x, int first)
 {
 const unsigned char empty[3] = { 0, 0, 0 };
+const char *ratio;
 char *names[] = { "50", "60", "75", "85" };
 int width, height;
 int valid = 1;
@@ -173,13 +174,21 @@ detailed_cvt_descriptor(unsigned char *x, int first)
 
 switch (x[1] & 0x0c) {
 case 0x00:
-   width = (height * 4) / 3; break;
+   width = (height * 4) / 3;
+   ratio = "4:3";
+   break;
 case 0x04:
-   width = (height * 16) / 9; break;
+   width = (height * 16) / 9;
+   ratio = "16:9";
+   break;
 case 0x08:
-   width = (height * 16) / 10; break;
+   width = (height * 16) / 10;
+   ratio = "16:10";
+   break;
 case 0x0c:
-   width = (height * 15) / 9; break;
+   width = (height * 15) / 9;
+   ratio = "15:9";
+   break;
 }
 
 if (x[1] & 0x03)
@@ -198,12 +207,13 @@ detailed_cvt_descriptor(unsigned char *x, int first)
 if (!valid) {
printf("(broken)\n");
 } else {
-   printf("%dx%d @ ( %s%s%s%s%s) Hz (%s%s preferred)\n", width, height,
+   printf("%dx%d @ ( %s%s%s%s%s) Hz %s (%s%s preferred)\n", width, 
height,
fifty ? "50 " : "",
sixty ? "60 " : "",
seventyfive ? "75 " : "",
eightyfive ? "85 " : "",
reduced ? "60RB " : "",
+   ratio,
names[(x[2] & 0x60) >> 5],
(((x[2] & 0x60) == 0x20) && reduced) ? "RB" : "");
 }
@@ -652,113 +662,113 @@ cea_audio_block(unsigned char *x)
 }
 
 static const char *edid_cea_modes[] = {
-"640x480@60Hz",
-"720x480@60Hz",
-"720x480@60Hz",
-"1280x720@60Hz",
-"1920x1080i@60Hz",
-"1440x480i@60Hz",
-"1440x480i@60Hz",
-"1440x240@60Hz",
-"1440x240@60Hz",
-"2880x480i@60Hz",
-"2880x480i@60Hz",
-"2880x240@60Hz",
-"2880x240@60Hz",
-"1440x480@60Hz",
-"1440x480@60Hz",
-"1920x1080@60Hz",
-"720x576@50Hz",
-"720x576@50Hz",
-"1280x720@50Hz",
-"1920x1080i@50Hz",
-"1440x576i@50Hz",
-"1440x576i@50Hz",
-"1440x288@50Hz",
-"1440x288@50Hz",
-"2880x576i@50Hz",
-"2880x576i@50Hz",
-"2880x288@50Hz",
-"2880x288@50Hz",
-"1440x576@50Hz",
-"1440x576@50Hz",
-"1920x1080@50Hz",
-"1920x1080@24Hz",
-"1920x1080@25Hz",
-"1920x1080@30Hz",
-"2880x480@60Hz",
-"2880x480@60Hz",
-"2880x576@50Hz",
-"2880x576@50Hz",
-"1920x1080i@50Hz",
-"1920x1080i@100Hz",
-"1280x720@100Hz",
-"720x576@100Hz",
-"720x576@100Hz",
-"1440x576@100Hz",
-"1440x576@100Hz",
-"1920x1080i@120Hz",
-"1280x720@120Hz",
-"720x480@120Hz",
-"720x480@120Hz",
-"1440x480i@120Hz",
-"1440x480i@120Hz",
-"720x576@200Hz",
-"720x576@200Hz",
-"1440x576i@200Hz",
-"1440x576i@200Hz",
-"720x480@240Hz",
-"720x480@240Hz",
-"1440x480i@240Hz",
-"1440x480i@240Hz",
-"1280x720@24Hz",
-"1280x720@25Hz",
-"1280x720@30Hz",
-"1920x1080@120Hz",
-"1920x1080@100Hz",
-"1280x720@24Hz",
-"1280x720@25Hz",
-"1280x720@30Hz",
-"1280x720@50Hz",
-"1280x720@60Hz",
-"1280x720@100Hz",
-"1280x720@120Hz",
-"1920x1080@24Hz",
-"1920x1080@25Hz",
-"1920x1080@30Hz",
-"1920x1080@50Hz",
-"1920x1080@60Hz",
-"1920x1080@100Hz",
-"1920x1080@120Hz",
-"1680x720@24Hz",
-"1680x720@25Hz",
-"1680x720@30Hz",
-"1680x720@50Hz",
-"1680x720@60Hz",
-  

[PATCH 01/27] edid-decode: add HDMI Forum VSDB support

2017-08-31 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

Besides printing the contents of that data block, also check
that the HF VSDB comes immediately after the HDMI VSDB as per the
spec.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 edid-decode.c | 45 +++--
 1 file changed, 43 insertions(+), 2 deletions(-)

diff --git a/edid-decode.c b/edid-decode.c
index ba710f05..47765801 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -67,6 +67,7 @@ static int seen_non_detailed_descriptor = 0;
 
 static int warning_excessive_dotclock_correction = 0;
 static int warning_zero_preferred_refresh = 0;
+static int nonconformant_hf_vsdb_position = 0;
 
 static int conformant = 1;
 
@@ -1014,6 +1015,33 @@ cea_hdmi_block(unsigned char *x)
 }
 }
 
+static void
+cea_hf_block(unsigned char *x)
+{
+printf(" (HDMI Forum)\n");
+printf("Version: %u\n", x[4]);
+if (x[5])
+   printf("Maximum TMDS Character Rate: %uMHz\n", x[5] * 5);
+if (x[6] & 0x80)
+   printf("SCDC Present\n");
+if (x[6] & 0x40)
+   printf("SCDC Read Request Capable\n");
+if (x[6] & 0x08)
+   printf("Supports scrambling for <= 340 Mcsc\n");
+if (x[6] & 0x04)
+   printf("Supports 3D Independent View signaling\n");
+if (x[6] & 0x02)
+   printf("Supports 3D Dual View signaling\n");
+if (x[6] & 0x01)
+   printf("Supports 3D OSD Disparity signaling\n");
+if (x[7] & 0x04)
+   printf("Supports 16-bits/component Deep Color 4:2:0 Pixel 
Encoding\n");
+if (x[7] & 0x02)
+   printf("Supports 12-bits/component Deep Color 4:2:0 Pixel 
Encoding\n");
+if (x[7] & 0x01)
+   printf("Supports 10-bits/component Deep Color 4:2:0 Pixel 
Encoding\n");
+}
+
 DEFINE_FIELD("YCbCr quantization", YCbCr_quantization, 7, 7,
  { 0, "No Data" },
  { 1, "Selectable (via AVI YQ)" });
@@ -1151,6 +1179,7 @@ cea_hdr_metadata_block(unsigned char *x)
 static void
 cea_block(unsigned char *x)
 {
+static int last_block_was_hdmi_vsdb;
 unsigned int oui;
 
 switch ((x[0] & 0xe0) >> 5) {
@@ -1166,10 +1195,18 @@ cea_block(unsigned char *x)
/* yes really, endianness lols */
oui = (x[3] << 16) + (x[2] << 8) + x[1];
printf("  Vendor-specific data block, OUI %06x", oui);
-   if (oui == 0x000c03)
+   if (oui == 0x000c03) {
cea_hdmi_block(x);
-   else
+   last_block_was_hdmi_vsdb = 1;
+   return;
+   }
+   if (oui == 0xc45dd8) {
+   if (!last_block_was_hdmi_vsdb)
+   nonconformant_hf_vsdb_position = 1;
+   cea_hf_block(x);
+   } else {
printf("\n");
+   }
break;
case 0x04:
printf("  Speaker allocation data block\n");
@@ -1246,6 +1283,7 @@ cea_block(unsigned char *x)
break;
}
 }
+last_block_was_hdmi_vsdb = 0;
 }
 
 static int
@@ -2058,6 +2096,7 @@ int main(int argc, char **argv)
 
 if (claims_one_point_three) {
if (nonconformant_digital_display ||
+   nonconformant_hf_vsdb_position ||
!has_valid_string_termination ||
!has_valid_descriptor_pad ||
!has_name_descriptor ||
@@ -2070,6 +2109,8 @@ int main(int argc, char **argv)
if (nonconformant_digital_display)
printf("\tDigital display field contains garbage: %x\n",
   nonconformant_digital_display);
+   if (nonconformant_hf_vsdb_position)
+   printf("\tHDMI Forum VSDB did not immediately follow the HDMI 
VSDB\n");
if (!has_name_descriptor)
printf("\tMissing name descriptor\n");
else if (!name_descriptor_terminated)
-- 
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

[PATCH 17/27] edid-decode: fix has_preferred_timing handling for 1.4

2017-08-31 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

The meaning of the preferred timing bit changed in 1.4. In that case
there is always a preferred timing, but how it is interpreted depends
on this bit.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 edid-decode.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/edid-decode.c b/edid-decode.c
index c1503366..38cd72b6 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -2325,9 +2325,16 @@ int main(int argc, char **argv)
memcmp(edid + 0x19, srgb_chromaticity, sizeof(srgb_chromaticity));
 }
 if (edid[0x18] & 0x02) {
-   printf("First detailed timing is preferred timing\n");
+   if (claims_one_point_four)
+   printf("First detailed timing includes the native pixel format 
and preferred refresh rate\n");
+   else
+   printf("First detailed timing is preferred timing\n");
+   has_preferred_timing = 1;
+} else if (claims_one_point_four) {
+   /* 1.4 always has a preferred timing and this bit means something else. 
*/
has_preferred_timing = 1;
 }
+
 if (edid[0x18] & 0x01) {
if (claims_one_point_four)
printf("Display is continuous frequency\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

[PATCH 23/27] edid-decode: allow the year to be one year in the future

2017-08-31 Thread Hans Verkuil
From: Hans Verkuil <hansv...@cisco.com>

Prototypes may have a year that is in the future, so give this a bit more
slack.

Signed-off-by: Hans Verkuil <hansv...@cisco.com>
---
 edid-decode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/edid-decode.c b/edid-decode.c
index ea443259..5a5fb5bd 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -2192,7 +2192,7 @@ int main(int argc, char **argv)
if (edid[0x10] == 0xff) {
has_valid_year = 1;
printf("Model year %hd\n", edid[0x11] + 1990);
-   } else if (edid[0x11] + 90 <= ptm->tm_year) {
+   } else if (edid[0x11] + 90 <= ptm->tm_year + 1) {
has_valid_year = 1;
if (edid[0x10])
printf("Made in week %hd of %hd\n", edid[0x10], 
edid[0x11] + 1990);
-- 
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

[PATCH 25/27] edid-decode: check if HDMI VICs are also in the VSB

2017-08-31 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

Issue a warning if that is not the case.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 edid-decode.c | 36 +++-
 1 file changed, 27 insertions(+), 9 deletions(-)

diff --git a/edid-decode.c b/edid-decode.c
index f106ce5e..6a9b6850 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -90,6 +90,8 @@ static int mon_max_hor_freq_hz = 0;
 static int mon_min_vert_freq_hz = 0;
 static int mon_max_vert_freq_hz = 0;
 static int mon_max_pixclk_khz = 0;
+static unsigned supported_hdmi_vic_codes = 0;
+static unsigned supported_hdmi_vic_vsb_codes = 0;
 
 static int conformant = 1;
 
@@ -1059,6 +1061,20 @@ cea_svd(unsigned char *x, int n, int for_ycbcr420)
}
 
if (vic > 0 && vic <= ARRAY_SIZE(edid_cea_modes)) {
+   switch (vic) {
+   case 95:
+   supported_hdmi_vic_vsb_codes |= 1 << 0;
+   break;
+   case 94:
+   supported_hdmi_vic_vsb_codes |= 1 << 1;
+   break;
+   case 93:
+   supported_hdmi_vic_vsb_codes |= 1 << 2;
+   break;
+   case 98:
+   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);
@@ -1141,7 +1157,7 @@ cea_vfpdb(unsigned char *x)
 static struct {
 const char *name;
 int refresh, hor_freq_hz, pixclk_khz;
-} edid_cea_hdmi_modes[] = {
+} edid_hdmi_modes[] = {
 {"3840x2160@30Hz 16:9", 30, 67500, 297000},
 {"3840x2160@25Hz 16:9", 25, 56250, 297000},
 {"3840x2160@24Hz 16:9", 24, 54000, 297000},
@@ -1233,14 +1249,14 @@ cea_hdmi_block(unsigned char *x)
 unsigned char vic = x[9 + b + i];
 const char *mode;
 
-vic--;
-if (vic < ARRAY_SIZE(edid_cea_hdmi_modes)) {
-   mode = edid_cea_hdmi_modes[vic].name;
-   min_vert_freq_hz = min(min_vert_freq_hz, 
edid_cea_hdmi_modes[vic].refresh);
-   max_vert_freq_hz = max(max_vert_freq_hz, 
edid_cea_hdmi_modes[vic].refresh);
-   min_hor_freq_hz = min(min_hor_freq_hz, 
edid_cea_hdmi_modes[vic].hor_freq_hz);
-   max_hor_freq_hz = max(max_hor_freq_hz, 
edid_cea_hdmi_modes[vic].hor_freq_hz);
-   max_pixclk_khz = max(max_pixclk_khz, 
edid_cea_hdmi_modes[vic].pixclk_khz);
+if (vic && vic <= ARRAY_SIZE(edid_hdmi_modes)) {
+   supported_hdmi_vic_codes |= 1 << (vic - 1);
+   mode = edid_hdmi_modes[vic - 1].name;
+   min_vert_freq_hz = min(min_vert_freq_hz, 
edid_hdmi_modes[vic - 1].refresh);
+   max_vert_freq_hz = max(max_vert_freq_hz, 
edid_hdmi_modes[vic - 1].refresh);
+   min_hor_freq_hz = min(min_hor_freq_hz, 
edid_hdmi_modes[vic - 1].hor_freq_hz);
+   max_hor_freq_hz = max(max_hor_freq_hz, 
edid_hdmi_modes[vic - 1].hor_freq_hz);
+   max_pixclk_khz = max(max_pixclk_khz, 
edid_hdmi_modes[vic - 1].pixclk_khz);
} else {
mode = "Unknown mode";
}
@@ -2539,6 +2555,8 @@ int main(int argc, char **argv)
printf("Warning: CVT block corrects dotclock by more than 9.75MHz\n");
 if (warning_zero_preferred_refresh)
printf("Warning: CVT block does not set preferred refresh rate\n");
+if ((supported_hdmi_vic_vsb_codes & supported_hdmi_vic_codes) != 
supported_hdmi_vic_codes)
+   printf("Warning: HDMI VIC Codes must have their CEA-861 VIC equivalents 
in the VSB\n");
 
 free(edid);
 
-- 
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

[PATCH 06/27] edid-decode: bit 0, byte 0x18 has been renamed for EDID 1.4

2017-08-31 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

This bit was "Supports GTF timings within operating range", but for
EDID 1.4 it has been renamed to "Display is continuous frequency".

Update the text accordingly.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 edid-decode.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/edid-decode.c b/edid-decode.c
index 693e29d8..251b8358 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -2064,8 +2064,12 @@ int main(int argc, char **argv)
printf("First detailed timing is preferred timing\n");
has_preferred_timing = 1;
 }
-if (edid[0x18] & 0x01)
-   printf("Supports GTF timings within operating range\n");
+if (edid[0x18] & 0x01) {
+   if (claims_one_point_four)
+   printf("Display is continuous frequency\n");
+   else
+   printf("Supports GTF timings within operating range\n");
+}
 
 printf("Display x,y Chromaticity:\n");
 col_x = (edid[0x1b] << 2) | (edid[0x19] >> 6);
-- 
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

[PATCH 16/27] edid-decode: YCbCr 4:2:0 Capability Map support

2017-08-31 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 edid-decode.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/edid-decode.c b/edid-decode.c
index 0ae465f2..c1503366 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -1090,6 +1090,22 @@ cea_y420vdb(unsigned char *x)
 cea_svd(x + 2, length - 1, 1);
 }
 
+static void
+cea_y420cmdb(unsigned char *x)
+{
+int length = x[0] & 0x1f;
+int i;
+
+for (i = 0; i < length - 1; i++) {
+   uint8_t v = x[2 + i];
+   int j;
+
+   for (j = 0; j < 8; j++)
+   if (v & (1 << j))
+   printf("VSD Index %d\n", i * 8 + j);
+}
+}
+
 static void
 cea_vfpdb(unsigned char *x)
 {
@@ -1544,6 +1560,7 @@ cea_block(unsigned char *x)
break;
case 0x0f:
printf("YCbCr 4:2:0 capability map data block\n");
+   cea_y420cmdb(x);
break;
case 0x10:
printf("CEA miscellaneous audio fields\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

[PATCH 05/27] edid-decode: verify 640x480p60 is defined for CEA-861

2017-08-31 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

Support for this format is required by the CEA-861 spec.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 edid-decode.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/edid-decode.c b/edid-decode.c
index e40a33ff..693e29d8 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -65,6 +65,8 @@ 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_640x480p60_est_timing = 0;
+static int has_cea861_vic_1 = 0;
 static int manufacturer_name_well_formed = 0;
 static int seen_non_detailed_descriptor = 0;
 
@@ -72,6 +74,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 conformant = 1;
 
@@ -803,6 +806,8 @@ cea_svd(unsigned char *x, int n)
mode = "Unknown mode";
 
printf("VIC %3d %s %s\n", vic, mode, native ? "(native)" : "");
+   if (vic == 1)
+   has_cea861_vic_1 = 1;
 }
 }
 
@@ -1347,6 +1352,7 @@ parse_cea(unsigned char *x)
 
 has_valid_cea_checksum = do_checksum(x, EDID_PAGE_SIZE);
 has_cea861 = 1;
+nonconformant_cea861_640x480 = !has_cea861_vic_1 && 
!has_640x480p60_est_timing;
 
 return ret;
 }
@@ -2087,6 +2093,7 @@ int main(int argc, char **argv)
   established_timings[i].ratio_w, established_timings[i].ratio_h);
   }
 }
+has_640x480p60_est_timing = edid[0x23] & 0x20;
 
 printf("Standard timings supported:\n");
 for (i = 0; i < 8; i++) {
@@ -2153,6 +2160,7 @@ int main(int argc, char **argv)
if (nonconformant_digital_display ||
nonconformant_hf_vsdb_position ||
nonconformant_srgb_chromaticity ||
+   nonconformant_cea861_640x480 ||
!has_valid_string_termination ||
!has_valid_descriptor_pad ||
!has_name_descriptor ||
@@ -2167,6 +2175,9 @@ int main(int argc, char **argv)
if (nonconformant_digital_display)
printf("\tDigital display field contains garbage: %x\n",
   nonconformant_digital_display);
+   if (nonconformant_cea861_640x480)
+   printf("\tRequired 640x480p60 timings are missing in the 
established timings\n"
+  "\tand/or in the SVD list (VIC 1)\n");
if (nonconformant_hf_vsdb_position)
printf("\tHDMI Forum VSDB did not immediately follow the HDMI 
VSDB\n");
if (!has_name_descriptor)
-- 
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

[PATCH 13/27] edid-decode: add horizontal freq and pixelclock

2017-08-31 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

Add the horizontal frequency and pixelclock information to the
established timings and VIC codes.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 edid-decode.c | 381 +++---
 1 file changed, 201 insertions(+), 180 deletions(-)

diff --git a/edid-decode.c b/edid-decode.c
index 25b8ed81..a7875a6b 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -301,58 +301,59 @@ extract_string(unsigned char *x, int *valid_termination, 
int len)
 }
 
 static const struct {
-  int x, y, refresh, ratio_w, ratio_h, rb;
+  int x, y, refresh, ratio_w, ratio_h;
+  int hor_freq_hz, pixclk_khz, rb;
 } established_timings3[] = {
   /* 0x06 bit 7 - 0 */
-  {640, 350, 85, 64, 35},
-  {640, 400, 85, 16, 10},
-  {720, 400, 85, 9, 5},
-  {640, 480, 85, 4, 3},
-  {848, 480, 60, 53, 30},
-  {800, 600, 85, 4, 3},
-  {1024, 768, 85, 4, 3},
-  {1152, 864, 75, 4, 3},
+  {640, 350, 85, 64, 35, 37900, 31500},
+  {640, 400, 85, 16, 10, 37900, 31500},
+  {720, 400, 85, 9, 5, 37900, 35500},
+  {640, 480, 85, 4, 3, 43300, 36000},
+  {848, 480, 60, 53, 30, 31000, 33750},
+  {800, 600, 85, 4, 3, 53700, 56250},
+  {1024, 768, 85, 4, 3, 68700, 94500},
+  {1152, 864, 75, 4, 3, 67500, 108000},
   /* 0x07 bit 7 - 0 */
-  {1280, 768, 60, 5, 3, 1},
-  {1280, 768, 60, 5, 3},
-  {1280, 768, 75, 5, 3},
-  {1280, 768, 85, 5, 3},
-  {1280, 960, 60, 4, 3},
-  {1280, 960, 85, 4, 3},
-  {1280, 1024, 60, 5, 4},
-  {1280, 1024, 85, 5, 4},
+  {1280, 768, 60, 5, 3, 47400, 68250, 1},
+  {1280, 768, 60, 5, 3, 47800, 79500},
+  {1280, 768, 75, 5, 3, 60300, 102250},
+  {1280, 768, 85, 5, 3, 68600, 117500},
+  {1280, 960, 60, 4, 3, 6, 108000},
+  {1280, 960, 85, 4, 3, 85900, 148500},
+  {1280, 1024, 60, 5, 4, 64000, 108000},
+  {1280, 1024, 85, 5, 4, 91100, 157500},
   /* 0x08 bit 7 - 0 */
-  {1360, 768, 60, 85, 48},
-  {1440, 900, 60, 16, 10, 1},
-  {1440, 900, 60, 16, 10},
-  {1440, 900, 75, 16, 10},
-  {1440, 900, 85, 16, 10},
-  {1400, 1050, 60, 4, 3, 1},
-  {1400, 1050, 60, 4, 3},
-  {1400, 1050, 75, 4, 3},
+  {1360, 768, 60, 85, 48, 47700, 85500},
+  {1440, 900, 60, 16, 10, 55500, 88750, 1},
+  {1440, 900, 60, 16, 10, 65300, 121750},
+  {1440, 900, 75, 16, 10, 82300, 156000},
+  {1440, 900, 85, 16, 10, 93900, 179500},
+  {1400, 1050, 60, 4, 3, 64700, 101000, 1},
+  {1400, 1050, 60, 4, 3, 65300, 121750},
+  {1400, 1050, 75, 4, 3, 82300, 156000},
   /* 0x09 bit 7 - 0 */
-  {1400, 1050, 85, 4, 3},
-  {1680, 1050, 60, 16, 10, 1},
-  {1680, 1050, 60, 16, 10},
-  {1680, 1050, 75, 16, 10},
-  {1680, 1050, 85, 16, 10},
-  {1600, 1200, 60, 4, 3},
-  {1600, 1200, 65, 4, 3},
-  {1600, 1200, 70, 4, 3},
+  {1400, 1050, 85, 4, 3, 93900, 179500},
+  {1680, 1050, 60, 16, 10, 64700, 119000, 1},
+  {1680, 1050, 60, 16, 10, 65300, 146250},
+  {1680, 1050, 75, 16, 10, 82300, 187000},
+  {1680, 1050, 85, 16, 10, 93900, 214750},
+  {1600, 1200, 60, 4, 3, 75000, 162000},
+  {1600, 1200, 65, 4, 3, 81300, 175500},
+  {1600, 1200, 70, 4, 3, 87500, 189000},
   /* 0x0a bit 7 - 0 */
-  {1600, 1200, 75, 4, 3},
-  {1600, 1200, 85, 4, 3},
-  {1792, 1344, 60, 4, 3},
-  {1792, 1344, 75, 4, 3},
-  {1856, 1392, 60, 4, 3},
-  {1856, 1392, 75, 4, 3},
-  {1920, 1200, 60, 16, 10, 1},
-  {1920, 1200, 60, 16, 10},
+  {1600, 1200, 75, 4, 3, 93800, 202500},
+  {1600, 1200, 85, 4, 3, 106300, 229500},
+  {1792, 1344, 60, 4, 3, 83600, 204750},
+  {1792, 1344, 75, 4, 3, 106300, 261000},
+  {1856, 1392, 60, 4, 3, 86300, 218250},
+  {1856, 1392, 75, 4, 3, 112500, 288000},
+  {1920, 1200, 60, 16, 10, 74000, 154000, 1},
+  {1920, 1200, 60, 16, 10, 74600, 193250},
   /* 0x0b bit 7 - 4 */
-  {1920, 1200, 75, 16, 10},
-  {1920, 1200, 85, 16, 10},
-  {1920, 1440, 60, 4, 3},
-  {1920, 1440, 75, 4, 3},
+  {1920, 1200, 75, 16, 10, 94000, 245250},
+  {1920, 1200, 85, 16, 10, 107200, 281250},
+  {1920, 1440, 60, 4, 3, 9, 234000},
+  {1920, 1440, 75, 4, 3, 112500, 297000},
 };
 
 /* 1 means valid data */
@@ -804,114 +805,128 @@ cea_audio_block(unsigned char *x)
 }
 }
 
-static const char *edid_cea_modes[] = {
-"640x480@60Hz 4:3",
-"720x480@60Hz 4:3",
-"720x480@60Hz 16:9",
-"1280x720@60Hz 16:9",
-"1920x1080i@60Hz 16:9",
-"1440x480i@60Hz 4:3",
-"1440x480i@60Hz 16:9",
-"1440x240@60Hz 4:3",
-"1440x240@60Hz 16:9",
-"2880x480i@60Hz 4:3",
-"2880x480i@60Hz 16:9",
-"2880x240@60Hz 4:3",
-"2880x240@60Hz 16:9",
-"1440x480@60Hz 4:3",
-"1440x480@60Hz 16:9",
-"1920x1080@60Hz 16:9",
-"720x576@50Hz 4:3",
-"720x576@50Hz 16:9",
-"1280x720@50Hz 16:9",
-"1920x1080i@50Hz 16:9",
-"1440x576i@50Hz 4:3",
-"1440x576i@50Hz 16:9",
-"1440x288@50Hz 4:3",
-"1440x288@50Hz 16:9",
-"2880x57

[PATCH 07/27] edid-decode: fix CVT version

2017-08-31 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

Parenthesis are needed to correctly report the CVT version.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 edid-decode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/edid-decode.c b/edid-decode.c
index 251b8358..4105700f 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -423,7 +423,7 @@ detailed_block(unsigned char *x, int in_extension)
if (is_cvt) {
int max_h_pixels = 0;
 
-   printf("CVT version %d.%d\n", x[11] & 0xf0 >> 4, x[11] & 0x0f);
+   printf("CVT version %d.%d\n", (x[11] & 0xf0) >> 4, x[11] & 
0x0f);
 
if (x[12] & 0xfc) {
int raw_offset = (x[12] & 0xfc) >> 2;
-- 
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

[PATCH 10/27] edid-decode: add Display Color Management support

2017-08-31 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

Print the contents of the DCM definition.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 edid-decode.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/edid-decode.c b/edid-decode.c
index 3ea3cb78..e4d70e8e 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -366,8 +366,14 @@ detailed_block(unsigned char *x, int in_extension)
return valid_cvt;
}
case 0xF9:
-   /* TODO */
-   printf("Color management data\n");
+   printf("Color management data:\n");
+   printf("  Version:  %d\n", x[5]);
+   printf("  Red a3:   %.2f\n", (short)(x[6] | (x[7] << 8)) / 100.0);
+   printf("  Red a2:   %.2f\n", (short)(x[8] | (x[9] << 8)) / 100.0);
+   printf("  Green a3: %.2f\n", (short)(x[10] | (x[11] << 8)) / 100.0);
+   printf("  Green a2: %.2f\n", (short)(x[12] | (x[13] << 8)) / 100.0);
+   printf("  Blue a3:  %.2f\n", (short)(x[14] | (x[15] << 8)) / 100.0);
+   printf("  Blue a2:  %.2f\n", (short)(x[16] | (x[17] << 8)) / 100.0);
return 1;
case 0xFA:
printf("More standard timings:\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

[PATCH 09/27] edid-decode: add support for the "More standard timings" block

2017-08-31 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

Support display descriptor tag 0xFA which reports more standard timings.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 edid-decode.c | 88 +++
 1 file changed, 46 insertions(+), 42 deletions(-)

diff --git a/edid-decode.c b/edid-decode.c
index 5a162b14..3ea3cb78 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -227,6 +227,47 @@ detailed_cvt_descriptor(unsigned char *x, int first)
 return valid;
 }
 
+static void print_standard_timing(uint8_t b1, uint8_t b2)
+{
+const char *ratio;
+unsigned int x, y, refresh;
+
+if (b1 == 0x01 && b2 == 0x01)
+  return;
+
+if (b1 == 0) {
+  printf("non-conformant standard timing (0 horiz)\n");
+  return;
+}
+x = (b1 + 31) * 8;
+switch ((b2 >> 6) & 0x3) {
+case 0x00:
+  if (claims_one_point_three) {
+y = x * 10 / 16;
+ratio = "16:10";
+  } else {
+y = x;
+ratio = "1:1";
+  }
+  break;
+case 0x01:
+  y = x * 3 / 4;
+  ratio = "4:3";
+  break;
+case 0x02:
+  y = x * 4 / 5;
+  ratio = "5:4";
+  break;
+case 0x03:
+  y = x * 9 / 16;
+  ratio = "16:9";
+  break;
+}
+refresh = 60 + (b2 & 0x3f);
+
+printf("  %dx%d@%dHz %s\n", x, y, refresh, ratio);
+}
+
 /* extract a string from a detailed subblock, checking for termination */
 static char *
 extract_string(unsigned char *x, int *valid_termination, int len)
@@ -329,8 +370,9 @@ detailed_block(unsigned char *x, int in_extension)
printf("Color management data\n");
return 1;
case 0xFA:
-   /* TODO */
-   printf("More standard timings\n");
+   printf("More standard timings:\n");
+   for (i = 0; i < 6; i++)
+   print_standard_timing(x[5 + i * 2], x[5 + i * 2 + 1]);
return 1;
case 0xFB:
/* TODO */
@@ -2100,46 +2142,8 @@ int main(int argc, char **argv)
 has_640x480p60_est_timing = edid[0x23] & 0x20;
 
 printf("Standard timings supported:\n");
-for (i = 0; i < 8; i++) {
-  const char *ratio;
-  uint8_t b1 = edid[0x26 + i * 2], b2 = edid[0x26 + i * 2 + 1];
-  unsigned int x, y, refresh;
-
-  if (b1 == 0x01 && b2 == 0x01)
-   continue;
-
-  if (b1 == 0) {
-   printf("non-conformant standard timing (0 horiz)\n");
-   continue;
-  }
-  x = (b1 + 31) * 8;
-  switch ((b2 >> 6) & 0x3) {
-  case 0x00:
-   if (claims_one_point_three) {
- y = x * 10 / 16;
- ratio = "16:10";
-   } else {
- y = x;
- ratio = "1:1";
-   }
-   break;
-  case 0x01:
-   y = x * 3 / 4;
-   ratio = "4:3";
-   break;
-  case 0x02:
-   y = x * 4 / 5;
-   ratio = "5:4";
-   break;
-  case 0x03:
-   y = x * 9 / 16;
-   ratio = "16:9";
-   break;
-  }
-  refresh = 60 + (b2 & 0x3f);
-
-  printf("  %dx%d@%dHz %s\n", x, y, refresh, ratio);
-}
+for (i = 0; i < 8; i++)
+  print_standard_timing(edid[0x26 + i * 2], edid[0x26 + i * 2 + 1]);
 
 /* detailed timings */
 has_valid_detailed_blocks = detailed_block(edid + 0x36, 0);
-- 
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

[PATCH 12/27] edid-decode: add support for Established Timings III

2017-08-31 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 edid-decode.c | 66 +--
 1 file changed, 64 insertions(+), 2 deletions(-)

diff --git a/edid-decode.c b/edid-decode.c
index e2041048..25b8ed81 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -300,6 +300,61 @@ extract_string(unsigned char *x, int *valid_termination, 
int len)
 return ret;
 }
 
+static const struct {
+  int x, y, refresh, ratio_w, ratio_h, rb;
+} established_timings3[] = {
+  /* 0x06 bit 7 - 0 */
+  {640, 350, 85, 64, 35},
+  {640, 400, 85, 16, 10},
+  {720, 400, 85, 9, 5},
+  {640, 480, 85, 4, 3},
+  {848, 480, 60, 53, 30},
+  {800, 600, 85, 4, 3},
+  {1024, 768, 85, 4, 3},
+  {1152, 864, 75, 4, 3},
+  /* 0x07 bit 7 - 0 */
+  {1280, 768, 60, 5, 3, 1},
+  {1280, 768, 60, 5, 3},
+  {1280, 768, 75, 5, 3},
+  {1280, 768, 85, 5, 3},
+  {1280, 960, 60, 4, 3},
+  {1280, 960, 85, 4, 3},
+  {1280, 1024, 60, 5, 4},
+  {1280, 1024, 85, 5, 4},
+  /* 0x08 bit 7 - 0 */
+  {1360, 768, 60, 85, 48},
+  {1440, 900, 60, 16, 10, 1},
+  {1440, 900, 60, 16, 10},
+  {1440, 900, 75, 16, 10},
+  {1440, 900, 85, 16, 10},
+  {1400, 1050, 60, 4, 3, 1},
+  {1400, 1050, 60, 4, 3},
+  {1400, 1050, 75, 4, 3},
+  /* 0x09 bit 7 - 0 */
+  {1400, 1050, 85, 4, 3},
+  {1680, 1050, 60, 16, 10, 1},
+  {1680, 1050, 60, 16, 10},
+  {1680, 1050, 75, 16, 10},
+  {1680, 1050, 85, 16, 10},
+  {1600, 1200, 60, 4, 3},
+  {1600, 1200, 65, 4, 3},
+  {1600, 1200, 70, 4, 3},
+  /* 0x0a bit 7 - 0 */
+  {1600, 1200, 75, 4, 3},
+  {1600, 1200, 85, 4, 3},
+  {1792, 1344, 60, 4, 3},
+  {1792, 1344, 75, 4, 3},
+  {1856, 1392, 60, 4, 3},
+  {1856, 1392, 75, 4, 3},
+  {1920, 1200, 60, 16, 10, 1},
+  {1920, 1200, 60, 16, 10},
+  /* 0x0b bit 7 - 4 */
+  {1920, 1200, 75, 16, 10},
+  {1920, 1200, 85, 16, 10},
+  {1920, 1440, 60, 4, 3},
+  {1920, 1440, 75, 4, 3},
+};
+
 /* 1 means valid data */
 static int
 detailed_block(unsigned char *x, int in_extension)
@@ -349,8 +404,15 @@ detailed_block(unsigned char *x, int in_extension)
has_valid_dummy_block = 0;
return 1;
case 0xF7:
-   /* TODO */
-   printf("Established timings III\n");
+   printf("Established timings III:\n");
+   for (i = 0; i < 44; i++) {
+ if (x[6 + i / 8] & (1 << (7 - i % 8))) {
+   printf("  %dx%d@%dHz %s%u:%u\n", established_timings3[i].x,
+  established_timings3[i].y, 
established_timings3[i].refresh,
+  established_timings3[i].rb ? "RB " : "",
+  established_timings3[i].ratio_w, 
established_timings3[i].ratio_h);
+ }
+   }
return 1;
case 0xF8:
{
-- 
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

[PATCH 04/27] edid-decode: add check for both serial number and string

2017-08-31 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

According to CEA-861-F if the serial string is provided in the detailed
block, then the serial number should be 0.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 edid-decode.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/edid-decode.c b/edid-decode.c
index 31aca8aa..e40a33ff 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -54,6 +54,8 @@ static int has_valid_cea_checksum = 1;
 static int has_valid_displayid_checksum = 1;
 static int has_valid_cvt = 1;
 static int has_valid_dummy_block = 1;
+static int has_valid_serial_number = 0;
+static int has_valid_serial_string = 0;
 static int has_valid_week = 0;
 static int has_valid_year = 0;
 static int has_valid_detailed_blocks = 0;
@@ -62,6 +64,7 @@ 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 manufacturer_name_well_formed = 0;
 static int seen_non_detailed_descriptor = 0;
 
@@ -500,6 +503,7 @@ detailed_block(unsigned char *x, int in_extension)
case 0xFF:
printf("Serial number: %s\n",
   extract_string(x + 5, _valid_string_termination, 13));
+   has_valid_serial_string = 1;
return 1;
default:
printf("Unknown monitor description type %d\n", x[3]);
@@ -1342,6 +1346,7 @@ parse_cea(unsigned char *x)
 } while (0);
 
 has_valid_cea_checksum = do_checksum(x, EDID_PAGE_SIZE);
+has_cea861 = 1;
 
 return ret;
 }
@@ -1887,6 +1892,7 @@ int main(int argc, char **argv)
(unsigned short)(edid[0x0A] + (edid[0x0B] << 8)),
(unsigned int)(edid[0x0C] + (edid[0x0D] << 8)
   + (edid[0x0E] << 16) + (edid[0x0F] << 24)));
+has_valid_serial_number = edid[0x0C] || edid[0x0D] || edid[0x0E] || 
edid[0x0F];
 /* XXX need manufacturer ID table */
 
 time(_time);
@@ -2200,6 +2206,7 @@ int main(int argc, char **argv)
!has_valid_cvt ||
!has_valid_year ||
!has_valid_week ||
+   (has_cea861 && has_valid_serial_number && has_valid_serial_string) ||
!has_valid_detailed_blocks ||
!has_valid_dummy_block ||
!has_valid_descriptor_ordering ||
@@ -2218,6 +2225,8 @@ int main(int argc, char **argv)
printf("\tBad year of manufacture\n");
if (!has_valid_week)
printf("\tBad week of manufacture\n");
+   if (has_cea861 && has_valid_serial_number && has_valid_serial_string)
+   printf("\tBoth the serial number and the serial string are set\n");
if (!has_valid_detailed_blocks)
printf("\tDetailed blocks filled with garbage\n");
if (!has_valid_dummy_block)
-- 
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

[PATCH 21/27] edid-decode: improve the hex dump parser to be more generic

2017-08-31 Thread Hans Verkuil
From: Hans Verkuil <hansv...@cisco.com>

Allow for spaces and '0x' prefixes.

Signed-off-by: Hans Verkuil <hansv...@cisco.com>
---
 edid-decode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/edid-decode.c b/edid-decode.c
index 58dc1c13..d38d2a3d 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -1976,7 +1976,7 @@ extract_edid(int fd)
 }
 
 /* Is the EDID provided in hex? */
-for (i = 0; i < 32 && isxdigit(ret[i]); i++);
+for (i = 0; i < 32 && (isspace(ret[i]) || tolower(ret[i]) == 'x' || 
isxdigit(ret[i])); i++);
 if (i == 32) {
out = malloc(size >> 1);
if (out == NULL) {
@@ -1987,7 +1987,7 @@ extract_edid(int fd)
for (c=ret; *c; c++) {
char buf[3];
 
-   if (*c == '\n')
+   if (!isxdigit(*c) || (*c == '0' && tolower(c[1]) == 'x'))
continue;
 
/* Read a %02x from the log */
-- 
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

[PATCH 00/27] edid-decode: fixes and new features and checks

2017-08-31 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

This edid-decode patch series has been sitting in my git repo for
way too long, so it is time to upstream this.

We (that is Cisco Systems Norway) have been using this to verify
both our own and others EDIDs. So besides adding support for new
data blocks and correcting little bugs all over it also improves
compliance checks. Especially making sure that the reported
timings are not out of range of the reported monitor frequency
range.

Regards,

    Hans Verkuil

Hans Verkuil (27):
  edid-decode: add HDMI Forum VSDB support
  edid-decode: print the chromaticities
  edid-decode: report picture aspect ratio
  edid-decode: add check for both serial number and string
  edid-decode: verify 640x480p60 is defined for CEA-861
  edid-decode: bit 0, byte 0x18 has been renamed for EDID 1.4
  edid-decode: fix CVT version
  edid-decode: fix "Supports CVT standard blanking"
  edid-decode: add support for the "More standard timings" block
  edid-decode: add Display Color Management support
  edid-decode: add support for the Color Point
  edid-decode: add support for Established Timings III
  edid-decode: add horizontal freq and pixelclock
  edid-decode: check monitor min/max range against supported timings
  edid-decode: SVDs in the 4:2:0 Data Block have half the pixclk
  edid-decode: YCbCr 4:2:0 Capability Map support
  edid-decode: fix has_preferred_timing handling for 1.4
  edid-decode: fix week/year interpretation.
  edid-decode: fix 1.3/1.4 differences in Model Year and Feature Support
  edid-decode: return 1 if no edid was found
  edid-decode: improve the hex dump parser to be more generic
  edid-decode: allow for comma separated hex values
  edid-decode: allow the year to be one year in the future
  edid-decode: check Max TMDS Rates
  edid-decode: check if HDMI VICs are also in the VSB
  edid-decode: calculate hfreq and clock from CVT
  edid-decode: show correct EDID version in string

 edid-decode.c | 1080 -
 1 file changed, 833 insertions(+), 247 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

[PATCH 18/27] edid-decode: fix week/year interpretation.

2017-08-31 Thread Hans Verkuil
From: Hans Verkuil <hans.verk...@cisco.com>

Correctly interpret the week/year bytes.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 edid-decode.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/edid-decode.c b/edid-decode.c
index 38cd72b6..ed725ff4 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -2172,11 +2172,13 @@ int main(int argc, char **argv)
if (edid[0x11] > 0x0f) {
if (edid[0x10] == 0xff) {
has_valid_year = 1;
-   printf("Made week %hd of model year %hd\n", edid[0x10],
-  edid[0x11]);
+   printf("Model year %hd\n", edid[0x11] + 1990);
} else if (edid[0x11] + 90 <= ptm->tm_year) {
has_valid_year = 1;
-   printf("Made week %hd of %hd\n", edid[0x10], edid[0x11] + 1990);
+   if (edid[0x10])
+   printf("Made in week %hd of %hd\n", edid[0x10], 
edid[0x11] + 1990);
+   else
+   printf("Made in year %hd\n", edid[0x11] + 1990);
}
}
 }
-- 
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