From patchwork Sun Sep 26 08:33:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: joevt X-Patchwork-Id: 12518051 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6200C433EF for ; Sun, 26 Sep 2021 08:33:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C8C3360F11 for ; Sun, 26 Sep 2021 08:33:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229700AbhIZIfJ (ORCPT ); Sun, 26 Sep 2021 04:35:09 -0400 Received: from omta002.cacentral1.a.cloudfilter.net ([3.97.99.33]:39161 "EHLO omta002.cacentral1.a.cloudfilter.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229574AbhIZIfI (ORCPT ); Sun, 26 Sep 2021 04:35:08 -0400 Received: from shw-obgw-4004a.ext.cloudfilter.net ([10.228.9.227]) by cmsmtp with ESMTP id U6LtmGvqbps7PUPbImzSGg; Sun, 26 Sep 2021 08:33:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=shaw.ca; s=s20180605; t=1632645212; bh=Mkg+GCSYsSnciL68UVjFtP1sBc1Y/KxIcQK8ksuCn7s=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WX3eevdvCPsm++LhileEdAYsoKxbck0tZFP0lEPvTxhO7ZOWRNhMZmUOwUa1mcNl+ 24gJY+ulJ1XaAL68TrDmkaTslDEr9Pe6anwpzRv6XFPZRHRZ8sGfvQP/V9ZiLEn7xU HOG8y2eXSnJNQjMQsou3Dob46V9csx0u2aeuoulewPApgAl3Rdv8BJFiaFlpe05ipP cHR/UyFcugX6RM3wDgk7bhToKT+coU6TegOCxuIa6M4dPxS5VIVoeC55QakuoNW/jx kVhqgXRLMTGnvLnfa9V+xppSOEzqcUfhNNtMc2fsL6CSEm4u2HqH+m8rLsk0pbbiZ0 4a1dyyDIWqn7Q== Received: from shaw.ca ([70.71.78.228]) by cmsmtp with ESMTPA id UPbGmpVUmdCHGUPbIm6iEA; Sun, 26 Sep 2021 08:33:32 +0000 Authentication-Results: ; auth=pass (LOGIN) smtp.auth=joevt@shaw.ca X-Authority-Analysis: v=2.4 cv=SdyUytdu c=1 sm=1 tr=0 ts=6150305c a=qDatE6m/3wxSEG8Wq7h0zQ==:117 a=qDatE6m/3wxSEG8Wq7h0zQ==:17 a=_Dj-zB-qAAAA:8 a=2mh5z2ImN-xkmkKSv0IA:9 a=c-cOe7UV8MviEfHuAVEQ:22 From: joevt To: Hans Verkuil Cc: linux-media@vger.kernel.org Subject: [PATCH v2 01/29] edid-decode: remove unnecessary length check Date: Sun, 26 Sep 2021 01:33:02 -0700 Message-Id: <20210926083330.5206-2-joevt@shaw.ca> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210926083330.5206-1-joevt@shaw.ca> References: <20210926083330.5206-1-joevt@shaw.ca> MIME-Version: 1.0 X-CMAE-Envelope: MS4xfCwsqoQToehvrwTgF2jkvt73Ak5WocNz1xLu1j8a9055jJ5AiZFhJ+ZZZZRktTUtxEV04TjMvqifMZDXR337K24pFGhQfbG1qUjy22BR0HI4McHEFp4N AKsavrqRiySDbX4h+HXUvVTdCG7v6ZI/NMIdQR2/id59D7R3V+TRGM8hVtQRZj0v3eCIp1u6HFtxZ4CprM7Xtwu29n199GicNbU= Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The for loop also checks the length. Nothing will happen if length is zero as expected. Signed-off-by: Joe van Tunen --- edid-decode.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/edid-decode.cpp b/edid-decode.cpp index d5062dd..d77646d 100644 --- a/edid-decode.cpp +++ b/edid-decode.cpp @@ -700,9 +700,6 @@ void hex_block(const char *prefix, const unsigned char *x, { unsigned i, j; - if (!length) - return; - for (i = 0; i < length; i += step) { unsigned len = min(step, length - i); From patchwork Sun Sep 26 08:33:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: joevt X-Patchwork-Id: 12518053 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F257DC433FE for ; Sun, 26 Sep 2021 08:33:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D25C86103B for ; Sun, 26 Sep 2021 08:33:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229713AbhIZIfJ (ORCPT ); Sun, 26 Sep 2021 04:35:09 -0400 Received: from omta002.cacentral1.a.cloudfilter.net ([3.97.99.33]:46574 "EHLO omta002.cacentral1.a.cloudfilter.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229691AbhIZIfJ (ORCPT ); Sun, 26 Sep 2021 04:35:09 -0400 Received: from shw-obgw-4004a.ext.cloudfilter.net ([10.228.9.227]) by cmsmtp with ESMTP id UA72mHBH9ps7PUPbImzSGi; Sun, 26 Sep 2021 08:33:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=shaw.ca; s=s20180605; t=1632645212; bh=ovZtVaWTCfAoDAgt+l/yTO5EoQzPB5vB+xXZhhZTSVA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=anbdp5/4FWe6s8t49xjgGXYD3Xpw4FYODJou8tYLMLgMhyB9LgXtRCy+wQ0SmAZ6E Jedm3ZP621vNvv2MVZlEcapjBAHbHywc2wdjL+jqQfExVoVkfPWeoakt8ggVfdIaIm 87pRLDlKefJ+HH0qZ5/aHsm0acW328aDRWtlFP6Ff3KEOXnY9w7YasZGtcBvSZmeK8 JvwyNQ09DTB9Bb8cX9ZPc8Xc8HSa4YT+RuSW0oVNCL9lanlXk5y7V/voB1ekWciyje ubm2hbn4m1dtngUllywDVEcpddZLJdTqtzoe+NgV2B9TRpnHauGOdWKaU4y7R+9faz G0H2gsfCFVRxg== Received: from shaw.ca ([70.71.78.228]) by cmsmtp with ESMTPA id UPbGmpVUmdCHGUPbIm6iEF; Sun, 26 Sep 2021 08:33:32 +0000 Authentication-Results: ; auth=pass (LOGIN) smtp.auth=joevt@shaw.ca X-Authority-Analysis: v=2.4 cv=SdyUytdu c=1 sm=1 tr=0 ts=6150305c a=qDatE6m/3wxSEG8Wq7h0zQ==:117 a=qDatE6m/3wxSEG8Wq7h0zQ==:17 a=_Dj-zB-qAAAA:8 a=ywt57WX9DDL8cH32plEA:9 a=c-cOe7UV8MviEfHuAVEQ:22 From: joevt To: Hans Verkuil Cc: linux-media@vger.kernel.org Subject: [PATCH v2 02/29] edid-decode: fix standard timing vertical pixels Date: Sun, 26 Sep 2021 01:33:03 -0700 Message-Id: <20210926083330.5206-3-joevt@shaw.ca> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210926083330.5206-1-joevt@shaw.ca> References: <20210926083330.5206-1-joevt@shaw.ca> MIME-Version: 1.0 X-CMAE-Envelope: MS4xfCwsqoQToehvrwTgF2jkvt73Ak5WocNz1xLu1j8a9055jJ5AiZFhJ+ZZZZRktTUtxEV04TjMvqifMZDXR337K24pFGhQfbG1qUjy22BR0HI4McHEFp4N AKsavrqRiySDbX4h+HXUvVTdCG7v6ZI/NMIdQR2/id59D7R3V+TRGM8hVtQRZj0v3eCIp1u6HFtxZ4CprM7Xtwu29n199GicNbU= Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Don't do ceiling to nearest 8 pixels for active vertical lines. See examples elo-4600l-hdmi and kogan-kaled24144f-hdmi. Section 3.9 and 3.10.3.6 of EDID 1.4 does not say vertical lines must be a multiple of 8. This line of code appears to have been added to satisfy the 3rd example in VTB-EXT spec but that example has an incorrect HAP indicator decimal value so it cannot be trusted. Also, all 3 examples have an incorrect vertical refresh value as noted in parse-vtb-ext-block.cpp. The VESA DMT spec has the following examples that are not a multiple of 8 lines which support this change: 1400x1050 4:3 1440x900 16:10 1600x900 16:9 1680x1050 16:10 Finally, Ref. D-8 of EDID 1.4 says about Section 3.9 that "The Standard Timings Identification code may not be used to identify timings which do not match one of these standard aspect ratios." If vertical lines is odd then a warning is output. That way an attempt to use ST to describe 1360x768 (a common resolution) will result in a warning (since the nearest result that can be described by an ST is 1360x765). Signed-off-by: Joe van Tunen --- parse-base-block.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/parse-base-block.cpp b/parse-base-block.cpp index 174af51..dd56eed 100644 --- a/parse-base-block.cpp +++ b/parse-base-block.cpp @@ -573,7 +573,6 @@ void edid_state::print_standard_timing(const char *prefix, unsigned char b1, uns break; } vact = (double)hact * vratio / hratio; - vact = 8 * ((vact + 7) / 8); refresh = (b2 & 0x3f) + 60; formula.hact = hact; @@ -605,6 +604,10 @@ void edid_state::print_standard_timing(const char *prefix, unsigned char b1, uns min_vert_freq_hz = min(min_vert_freq_hz, refresh); max_vert_freq_hz = max(max_vert_freq_hz, refresh); } + + // See Ref. D-8 in the EDID-1.4 spec + if (vact & 1) + warn("Standard Timing %ux%u has a dubious odd vertical resolution.\n", hact, vact); } void edid_state::detailed_display_range_limits(const unsigned char *x) From patchwork Sun Sep 26 08:33:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: joevt X-Patchwork-Id: 12518059 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E999FC4332F for ; Sun, 26 Sep 2021 08:33:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CC8D160EE0 for ; Sun, 26 Sep 2021 08:33:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229727AbhIZIfK (ORCPT ); Sun, 26 Sep 2021 04:35:10 -0400 Received: from omta001.cacentral1.a.cloudfilter.net ([3.97.99.32]:51462 "EHLO omta001.cacentral1.a.cloudfilter.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229702AbhIZIfJ (ORCPT ); Sun, 26 Sep 2021 04:35:09 -0400 Received: from shw-obgw-4004a.ext.cloudfilter.net ([10.228.9.227]) by cmsmtp with ESMTP id U9QQmfBXuczbLUPbJmV5U5; Sun, 26 Sep 2021 08:33:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=shaw.ca; s=s20180605; t=1632645213; bh=gFbDDxOgee2gOpNVUtGyNrUW62pABNLukqGlzqIIfKM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=a7G2aTYiXucuoM/aVKIyonQ7QqmwUoJ1cQjeMqwWyCMOfsbYF7WnewsGrmTLvSbx1 aQMJlv9ZpjmRTWSVKSflC9r3nBAdWnnmxloSUHBccXai4wlLW1QZsYzvSa0wftqfdO pIk/eMtt45A7CmPVCrspaZps4RN9rx/dgEPDxYINrfs75xhJnWSXPfwF+gfkRAiIpv lY2DMU+YJuGLO0j5XwmdpxEqhg3WVhzCABIZWjeNZ5t6xlxz6P1A+Hx+pBxb0/2bJF Y3fT69pI+lYIc3G8El3JhTsJq+KQxDzutNAdWkq6enSFu33NnQKA7CqSmXuAIN906Z E5WGY0sAYEUuQ== Received: from shaw.ca ([70.71.78.228]) by cmsmtp with ESMTPA id UPbGmpVUmdCHGUPbIm6iEJ; Sun, 26 Sep 2021 08:33:33 +0000 Authentication-Results: ; auth=pass (LOGIN) smtp.auth=joevt@shaw.ca X-Authority-Analysis: v=2.4 cv=SdyUytdu c=1 sm=1 tr=0 ts=6150305d a=qDatE6m/3wxSEG8Wq7h0zQ==:117 a=qDatE6m/3wxSEG8Wq7h0zQ==:17 a=_Dj-zB-qAAAA:8 a=r_64EQOmvbVPSZJ-B9QA:9 a=c-cOe7UV8MviEfHuAVEQ:22 From: joevt To: Hans Verkuil Cc: linux-media@vger.kernel.org Subject: [PATCH v2 03/29] edid-decode: exclude oui from _block functions Date: Sun, 26 Sep 2021 01:33:04 -0700 Message-Id: <20210926083330.5206-4-joevt@shaw.ca> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210926083330.5206-1-joevt@shaw.ca> References: <20210926083330.5206-1-joevt@shaw.ca> MIME-Version: 1.0 X-CMAE-Envelope: MS4xfH1a1i2nab8Y6fWipNfzUqYoVOh9Ft04cnZYaQdhyWsuELAXuQ1gqma5X4oCY1LgfB1NlX7hFx2yYCteXMP5NbIkuWKxUGqxhCT1VenChuFN+ECc98mw /9xHwMi9p/ztavgh7fuwS6r4atsJRiCZMHdziuRiLLj0bT8jhF3zoW3nRRHXT+9rupmxJ+4DaX/dfg+IIgXdA36AMKcFJuLDg9Q= Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org cta_hdmi_block is the only function that has oui included. Make it like all the other functions by increasing x by 3 (the size of the oui) and decreasing length by the same amount. Signed-off-by: Joe van Tunen --- parse-cta-block.cpp | 48 ++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/parse-cta-block.cpp b/parse-cta-block.cpp index ee0b01d..f018df5 100644 --- a/parse-cta-block.cpp +++ b/parse-cta-block.cpp @@ -652,57 +652,57 @@ void edid_state::cta_hdmi_block(const unsigned char *x, unsigned length) { unsigned len_vic, len_3d; - if (length < 4) { + if (length < 1) { fail("Empty Data Block with length %u.\n", length); return; } - printf(" Source physical address: %x.%x.%x.%x\n", x[3] >> 4, x[3] & 0x0f, - x[4] >> 4, x[4] & 0x0f); + printf(" Source physical address: %x.%x.%x.%x\n", x[0] >> 4, x[0] & 0x0f, + x[1] >> 4, x[1] & 0x0f); - if (length < 6) + if (length < 3) return; - if (x[5] & 0x80) + if (x[2] & 0x80) printf(" Supports_AI\n"); - if (x[5] & 0x40) + if (x[2] & 0x40) printf(" DC_48bit\n"); - if (x[5] & 0x20) + if (x[2] & 0x20) printf(" DC_36bit\n"); - if (x[5] & 0x10) + if (x[2] & 0x10) printf(" DC_30bit\n"); - if (x[5] & 0x08) + if (x[2] & 0x08) printf(" DC_Y444\n"); /* two reserved bits */ - if (x[5] & 0x01) + if (x[2] & 0x01) printf(" DVI_Dual\n"); - if (length < 7) + if (length < 4) return; - printf(" Maximum TMDS clock: %u MHz\n", x[6] * 5); - if (x[6] * 5 > 340) + printf(" Maximum TMDS clock: %u MHz\n", x[3] * 5); + if (x[3] * 5 > 340) fail("HDMI VSDB Max TMDS rate is > 340.\n"); - if (length < 8) + if (length < 5) return; - if (x[7] & 0x0f) { + if (x[4] & 0x0f) { printf(" Supported Content Types:\n"); - if (x[7] & 0x01) + if (x[4] & 0x01) printf(" Graphics\n"); - if (x[7] & 0x02) + if (x[4] & 0x02) printf(" Photo\n"); - if (x[7] & 0x04) + if (x[4] & 0x04) printf(" Cinema\n"); - if (x[7] & 0x08) + if (x[4] & 0x08) printf(" Game\n"); } - unsigned b = 8; - if (x[7] & 0x80) { + unsigned b = 5; + if (x[4] & 0x80) { hdmi_latency(x[b], x[b + 1], false); - if (x[7] & 0x40) { + if (x[4] & 0x40) { if (x[b] == x[b + 2] && x[b + 1] == x[b + 3]) warn("Progressive and Interlaced latency values are identical, no need for both.\n"); @@ -712,7 +712,7 @@ void edid_state::cta_hdmi_block(const unsigned char *x, unsigned length) b += 2; } - if (!(x[7] & 0x20)) + if (!(x[4] & 0x20)) return; bool mask = false; @@ -2248,7 +2248,7 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) fail((std::string("OUI ") + ouitohex(oui) + " is in the wrong byte order\n").c_str()); printf(" %s, OUI %s:\n", data_block.c_str(), ouitohex(oui).c_str()); if (oui == 0x000c03) { - cta_hdmi_block(x + 1, length); + cta_hdmi_block(x + 4, length - 3); cta.last_block_was_hdmi_vsdb = 1; cta.first_block = 0; // The HDMI OUI is present, so this EDID represents an HDMI From patchwork Sun Sep 26 08:33:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: joevt X-Patchwork-Id: 12518057 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B78DC433F5 for ; Sun, 26 Sep 2021 08:33:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DD82961090 for ; Sun, 26 Sep 2021 08:33:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229734AbhIZIfK (ORCPT ); Sun, 26 Sep 2021 04:35:10 -0400 Received: from omta002.cacentral1.a.cloudfilter.net ([3.97.99.33]:39161 "EHLO omta002.cacentral1.a.cloudfilter.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229710AbhIZIfK (ORCPT ); Sun, 26 Sep 2021 04:35:10 -0400 Received: from shw-obgw-4004a.ext.cloudfilter.net ([10.228.9.227]) by cmsmtp with ESMTP id UEfmmHVpnps7PUPbKmzSGj; Sun, 26 Sep 2021 08:33:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=shaw.ca; s=s20180605; t=1632645214; bh=gpMQCUiAoUBInqFer6nzvC+KEO+kz0NlrPrqMyZg8jg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IuMuUxUJSNXEHo4ZZ4ZfzgkjoG6zbfS/nJvxYVsXgM8qLtWaTAAgov59mW+9NJqux Q33ABGQuKMG7jIr8ywe20kWmxnGVM8t/si3lUb4YYBF4lAOxSHAzckirX0Os5I7PTD Ht3S9AuLb3nr5Ij7i6OyOi9/jppOib78dTQTbg0cUtVWFKtypvUa7/v9nFtpJ7VF2F MziPRof9JgMuLPetwXLILmFvVhO3TpsCNZhhjQqg9/yyrE6tCv63LNpOYt+faTP15H GFcDVOJX0UflOHqk1Ti7InUygNIRg92t2Saey725pEV4SbKEgI1jvp2fEfSxK5TcSv 7c8NrrugnxzDQ== Received: from shaw.ca ([70.71.78.228]) by cmsmtp with ESMTPA id UPbGmpVUmdCHGUPbJm6iEP; Sun, 26 Sep 2021 08:33:34 +0000 Authentication-Results: ; auth=pass (LOGIN) smtp.auth=joevt@shaw.ca X-Authority-Analysis: v=2.4 cv=SdyUytdu c=1 sm=1 tr=0 ts=6150305e a=qDatE6m/3wxSEG8Wq7h0zQ==:117 a=qDatE6m/3wxSEG8Wq7h0zQ==:17 a=_Dj-zB-qAAAA:8 a=adv3DReEIzELzf3bmRAA:9 a=c-cOe7UV8MviEfHuAVEQ:22 From: joevt To: Hans Verkuil Cc: linux-media@vger.kernel.org Subject: [PATCH v2 04/29] edid-decode: check cta_hdr10plus length Date: Sun, 26 Sep 2021 01:33:05 -0700 Message-Id: <20210926083330.5206-5-joevt@shaw.ca> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210926083330.5206-1-joevt@shaw.ca> References: <20210926083330.5206-1-joevt@shaw.ca> MIME-Version: 1.0 X-CMAE-Envelope: MS4xfLFoTLRz3bL6MEACqf5noFWedrUsQesKX3P2nBg2JMk54cJSGqwKRlDp2CFqCHORbp/agYABii3BsPR6oukkXGjAhcw5OlXKJ4k5WbETDh+sHTQU6QCW C/3SBgAZihneSmLIN1UUbsmBolvT9QmP4T6NhvWk5qnv07YJ9fUiS1iEHlxEFTQ9YNt4vcopluRqCyTXqKk8fMgI0a0AlMezoO4= Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org - if the length is 0 then it cannot get Application Version. Output a fail message. - cta_hdr10plus may output hex after "Application Version: %u". If the hex is longer than 16 characters, then more lines of hex will be output and they won't align with the first line. Instead, always start the hex on a new line. Signed-off-by: Joe van Tunen --- parse-cta-block.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/parse-cta-block.cpp b/parse-cta-block.cpp index f018df5..6607426 100644 --- a/parse-cta-block.cpp +++ b/parse-cta-block.cpp @@ -1133,11 +1133,12 @@ static void cta_microsoft(const unsigned char *x, unsigned length) static void cta_hdr10plus(const unsigned char *x, unsigned length) { - printf(" Application Version: %u", x[0]); - if (length > 1) - hex_block(" ", x + 1, length - 1); - else - printf("\n"); + if (length == 0) { + fail("Empty Data Block with length %u.\n", length); + return; + } + printf(" Application Version: %u\n", x[0]); + hex_block(" ", x + 1, length - 1); } // Convert a PQ value (0-1) to cd/m^2 aka nits (0-10000) From patchwork Sun Sep 26 08:33:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: joevt X-Patchwork-Id: 12518055 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5EB41C43219 for ; Sun, 26 Sep 2021 08:33:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4661B60EE0 for ; Sun, 26 Sep 2021 08:33:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229753AbhIZIfL (ORCPT ); Sun, 26 Sep 2021 04:35:11 -0400 Received: from omta002.cacentral1.a.cloudfilter.net ([3.97.99.33]:46574 "EHLO omta002.cacentral1.a.cloudfilter.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229716AbhIZIfK (ORCPT ); Sun, 26 Sep 2021 04:35:10 -0400 Received: from shw-obgw-4004a.ext.cloudfilter.net ([10.228.9.227]) by cmsmtp with ESMTP id U6LtmGvqSps7PUPbKmzSGl; Sun, 26 Sep 2021 08:33:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=shaw.ca; s=s20180605; t=1632645214; bh=JnmMHffmExTq6ajnRT9gP/3SxBqgbqFCz1GMZjd/UWk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ulQC/Y0u3r7bAN2ymthrNNazj8ZY5+oT6+WqvyciELRbLmvHnynj5TLOiO1xyNpbo Hi0lW//MNvS1bjoahKtf1RJF481IKYVFMTRAd2/c1FSxw290H3ivaeg8imNiKBXsnI /AAXZdR7vJ65AbzMokVVFSQNzLXh55LiG/4D3Rjsd0pEth9ov0yC2oM1uRBp0LYq/H tL3/dmDZhv30D8xv+GKnFKRHEgi6aT5/PjHAEVQjmhFuSNMQi3t4jw9Il63Tkd42WO 8GTLFcW9HkPh5bqKpX8SwedUgyJ+JXSZ6AFIWrfeWfOfrNVD5QtbVgE2HOUJCL7ckc IudA8rTzEiEYw== Received: from shaw.ca ([70.71.78.228]) by cmsmtp with ESMTPA id UPbGmpVUmdCHGUPbKm6iET; Sun, 26 Sep 2021 08:33:34 +0000 Authentication-Results: ; auth=pass (LOGIN) smtp.auth=joevt@shaw.ca X-Authority-Analysis: v=2.4 cv=SdyUytdu c=1 sm=1 tr=0 ts=6150305e a=qDatE6m/3wxSEG8Wq7h0zQ==:117 a=qDatE6m/3wxSEG8Wq7h0zQ==:17 a=_Dj-zB-qAAAA:8 a=3lAKzEw-IZXX5DbEWQ4A:9 a=c-cOe7UV8MviEfHuAVEQ:22 From: joevt To: Hans Verkuil Cc: linux-media@vger.kernel.org Subject: [PATCH v2 05/29] edid-decode: Capitalize fail sentence Date: Sun, 26 Sep 2021 01:33:06 -0700 Message-Id: <20210926083330.5206-6-joevt@shaw.ca> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210926083330.5206-1-joevt@shaw.ca> References: <20210926083330.5206-1-joevt@shaw.ca> MIME-Version: 1.0 X-CMAE-Envelope: MS4xfLFoTLRz3bL6MEACqf5noFWedrUsQesKX3P2nBg2JMk54cJSGqwKRlDp2CFqCHORbp/agYABii3BsPR6oukkXGjAhcw5OlXKJ4k5WbETDh+sHTQU6QCW C/3SBgAZihneSmLIN1UUbsmBolvT9QmP4T6NhvWk5qnv07YJ9fUiS1iEHlxEFTQ9YNt4vcopluRqCyTXqKk8fMgI0a0AlMezoO4= Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org - Most fail messages are a sentence that starts with a capital letter and ends with a period. - Remove unnessary break from last switch case. - Remove extra line. Signed-off-by: Joe van Tunen --- parse-cta-block.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/parse-cta-block.cpp b/parse-cta-block.cpp index 6607426..042b933 100644 --- a/parse-cta-block.cpp +++ b/parse-cta-block.cpp @@ -2091,13 +2091,11 @@ void edid_state::cta_ext_block(const unsigned char *x, unsigned length, case 0x79: if (duplicate) fail("Only one instance of this Data Block is allowed.\n"); - break; } - // See Table 52 of CTA-861-G for a description of Byte 3 if (audio_block && !(cta.byte3 & 0x40)) - fail("audio information is present, but bit 6 of Byte 3 of the CTA-861 Extension header indicates no Basic Audio support.\n"); + fail("Audio information is present, but bit 6 of Byte 3 of the CTA-861 Extension header indicates no Basic Audio support.\n"); if (data_block.length()) printf(" %s:\n", data_block.c_str()); From patchwork Sun Sep 26 08:33:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: joevt X-Patchwork-Id: 12518063 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06051C433EF for ; Sun, 26 Sep 2021 08:33:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E007E60EE0 for ; Sun, 26 Sep 2021 08:33:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229768AbhIZIfL (ORCPT ); Sun, 26 Sep 2021 04:35:11 -0400 Received: from omta001.cacentral1.a.cloudfilter.net ([3.97.99.32]:51462 "EHLO omta001.cacentral1.a.cloudfilter.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229730AbhIZIfL (ORCPT ); Sun, 26 Sep 2021 04:35:11 -0400 Received: from shw-obgw-4004a.ext.cloudfilter.net ([10.228.9.227]) by cmsmtp with ESMTP id U6mYmf0pJczbLUPbLmV5U9; Sun, 26 Sep 2021 08:33:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=shaw.ca; s=s20180605; t=1632645215; bh=wdkOL7mRmZXM5cZIdE/n+C/nxawk/Weu4v15MsU89H8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lzubybFAZopCF2UmbAvOxroPaLDlqbB5YRhcyEUg4LWErzDrlInwxjAp02OZ7EE0V oStq0XCfET/EbpRBVNmFp2SOcVjcEsT0SUbqa2nb2cKlmADIHQVWriJrpvbVCK+TvN otxdzbna1wH99lfPeeBeylvcr53dpkx9dbA9/XIijNEnrdfPLCJ7OkkKbWteoSHXrq xJYe43EeRMEFab9CPOaD8TRt50EP/KHdxLGMlJ35/APrmbGid/ItA2vz4m9AfKGG08 2sDptn7H01CMl+6rQedRPUs5WzYI9FglmpT3yVz9VVcbaUx8Q0z03y/0Ng3KJhlsdH BXwa9GKJeOeWg== Received: from shaw.ca ([70.71.78.228]) by cmsmtp with ESMTPA id UPbGmpVUmdCHGUPbKm6iEV; Sun, 26 Sep 2021 08:33:35 +0000 Authentication-Results: ; auth=pass (LOGIN) smtp.auth=joevt@shaw.ca X-Authority-Analysis: v=2.4 cv=SdyUytdu c=1 sm=1 tr=0 ts=6150305f a=qDatE6m/3wxSEG8Wq7h0zQ==:117 a=qDatE6m/3wxSEG8Wq7h0zQ==:17 a=_Dj-zB-qAAAA:8 a=HJMu6jesDG4n_MRZF-gA:9 a=c-cOe7UV8MviEfHuAVEQ:22 From: joevt To: Hans Verkuil Cc: linux-media@vger.kernel.org Subject: [PATCH v2 06/29] edid-decode: Replace return with break in switch Date: Sun, 26 Sep 2021 01:33:07 -0700 Message-Id: <20210926083330.5206-7-joevt@shaw.ca> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210926083330.5206-1-joevt@shaw.ca> References: <20210926083330.5206-1-joevt@shaw.ca> MIME-Version: 1.0 X-CMAE-Envelope: MS4xfDj+u4Nplv7rCIWEO8fSNAHUhse0sWW7L1c1b8VNooIKeApJNtz20q+KTHy7q10ZDWcMiJYKfkluw5pMjlJExmDuMnYicmLNwN7xT8LD0RY0Xj8Z2wON YN79n8UCzbIhb7GAfJAFiJelA+UWiwzaIqjl5ZCVFU4i2sYXYcT4DQdZCvBm+aSzhNpp+y160Rofk6osHkIdtmcWFmcdwiY12l0= Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Use break to leave a switch instead of return. Move code that was after switch to default statement in switch. This way, we can move switch or have other code after switch. Signed-off-by: Joe van Tunen --- parse-cta-block.cpp | 51 +++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/parse-cta-block.cpp b/parse-cta-block.cpp index 042b933..bba3af2 100644 --- a/parse-cta-block.cpp +++ b/parse-cta-block.cpp @@ -2101,12 +2101,12 @@ void edid_state::cta_ext_block(const unsigned char *x, unsigned length, printf(" %s:\n", data_block.c_str()); switch (x[0]) { - case 0x00: cta_vcdb(x + 1, length); return; + case 0x00: cta_vcdb(x + 1, length); break; case 0x01: if (length < 3) { data_block = std::string("Vendor-Specific Video Data Block"); fail("Invalid length %u < 3.\n", length); - return; + break; } oui = (x[3] << 16) + (x[2] << 8) + x[1]; name = oui_name(oui); @@ -2122,7 +2122,7 @@ void edid_state::cta_ext_block(const unsigned char *x, unsigned length, data_block.clear(); warn("Unknown Extended Vendor-Specific Video Data Block, OUI %s.\n", ouitohex(oui).c_str()); - return; + break; } data_block = std::string("Vendor-Specific Video Data Block (") + name + ")"; if (reverse) @@ -2134,19 +2134,19 @@ void edid_state::cta_ext_block(const unsigned char *x, unsigned length, cta_dolby_video(x + 4, length - 3); else hex_block(" ", x + 4, length - 3); - return; - case 0x02: cta_vesa_vdddb(x + 1, length); return; - case 0x05: cta_colorimetry_block(x + 1, length); return; - case 0x06: cta_hdr_static_metadata_block(x + 1, length); return; - case 0x07: cta_hdr_dyn_metadata_block(x + 1, length); return; - case 0x0d: cta_vfpdb(x + 1, length); return; - case 0x0e: cta_svd(x + 1, length, true); return; - case 0x0f: cta_y420cmdb(x + 1, length); return; + break; + case 0x02: cta_vesa_vdddb(x + 1, length); break; + case 0x05: cta_colorimetry_block(x + 1, length); break; + case 0x06: cta_hdr_static_metadata_block(x + 1, length); break; + case 0x07: cta_hdr_dyn_metadata_block(x + 1, length); break; + case 0x0d: cta_vfpdb(x + 1, length); break; + case 0x0e: cta_svd(x + 1, length, true); break; + case 0x0f: cta_y420cmdb(x + 1, length); break; case 0x11: if (length < 3) { data_block = std::string("Vendor-Specific Audio Data Block"); fail("Invalid length %u < 3.\n", length); - return; + break; } oui = (x[3] << 16) + (x[2] << 8) + x[1]; name = oui_name(oui); @@ -2162,7 +2162,7 @@ void edid_state::cta_ext_block(const unsigned char *x, unsigned length, data_block.clear(); warn("Unknown Extended Vendor-Specific Audio Data Block, OUI %s.\n", ouitohex(oui).c_str()); - return; + break; } data_block = std::string("Vendor-Specific Audio Data Block (") + name + ")"; if (reverse) @@ -2172,20 +2172,20 @@ void edid_state::cta_ext_block(const unsigned char *x, unsigned length, cta_dolby_audio(x + 4, length - 3); else hex_block(" ", x + 4, length - 3); - return; - case 0x12: cta_hdmi_audio_block(x + 1, length); return; - case 0x13: cta_rcdb(x + 1, length); return; - case 0x14: cta_sldb(x + 1, length); return; - case 0x20: cta_ifdb(x + 1, length); return; - case 0x34: cta_displayid_type_7(x + 1, length); return; - case 0x35: cta_displayid_type_8(x + 1, length); return; - case 0x42: cta_displayid_type_10(x + 1, length); return; + break; + case 0x12: cta_hdmi_audio_block(x + 1, length); break; + case 0x13: cta_rcdb(x + 1, length); break; + case 0x14: cta_sldb(x + 1, length); break; + case 0x20: cta_ifdb(x + 1, length); break; + case 0x34: cta_displayid_type_7(x + 1, length); break; + case 0x35: cta_displayid_type_8(x + 1, length); break; + case 0x42: cta_displayid_type_10(x + 1, length); break; case 0x78: cta_hf_eeodb(x + 1, length); // This must be the first CTA-861 block if (!cta.first_block) fail("Block starts at a wrong offset.\n"); - return; + break; case 0x79: if (!cta.last_block_was_hdmi_vsdb) fail("HDMI Forum SCDB did not immediately follow the HDMI VSDB.\n"); @@ -2194,16 +2194,17 @@ void edid_state::cta_ext_block(const unsigned char *x, unsigned length, if (length < 2) { data_block = std::string("HDMI Forum SCDB"); fail("Invalid length %u < 2.\n", length); - return; + break; } if (x[1] || x[2]) printf(" Non-zero SCDB reserved fields!\n"); cta_hf_scdb(x + 3, length - 2); cta.have_hf_scdb = 1; - return; + break; + default: + hex_block(" ", x + 1, length); } - hex_block(" ", x + 1, length); } void edid_state::cta_block(const unsigned char *x, bool duplicate) From patchwork Sun Sep 26 08:33:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: joevt X-Patchwork-Id: 12518061 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DF91C43217 for ; Sun, 26 Sep 2021 08:33:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6344F60EE0 for ; Sun, 26 Sep 2021 08:33:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229783AbhIZIfM (ORCPT ); Sun, 26 Sep 2021 04:35:12 -0400 Received: from omta001.cacentral1.a.cloudfilter.net ([3.97.99.32]:51462 "EHLO omta001.cacentral1.a.cloudfilter.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229716AbhIZIfM (ORCPT ); Sun, 26 Sep 2021 04:35:12 -0400 Received: from shw-obgw-4004a.ext.cloudfilter.net ([10.228.9.227]) by cmsmtp with ESMTP id U8Srmf7ImczbLUPbLmV5UA; Sun, 26 Sep 2021 08:33:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=shaw.ca; s=s20180605; t=1632645215; bh=IeG+TOkGXSbHeUsXujnXeXAEfg1Y72ROA6DPtfl4sg8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ZVBHBtwDxGmJZYN9q+06yfmx2qGRpFYqqLVP5mw31SReVafqod3+/kYDx5rbwjUUG N3mibIcPbCvLy0ehde4QPRghOL4o2aARm/JscCWGgLS7Q5ho5RBJIljC867ho+6D6i 3IsIyW7UVuUWLd9jf8I7FDgxuxYnPu4bmwNSbgoPqG5bQaWi4kTZE8g4DmwSaufkRC LM8P0FI8k/INfcFlek1y3JGux5No5bVhwynLrYy0jEu33wXas2YOXlqklRxaqcALKp bnp/HpwQCDSg05BaSOaSXQL33+JEFsNFNMpbmPwZyo9QhcaaTFzrnJrCWWcaRexiZw gqDtBx1HRk3sQ== Received: from shaw.ca ([70.71.78.228]) by cmsmtp with ESMTPA id UPbGmpVUmdCHGUPbLm6iEY; Sun, 26 Sep 2021 08:33:35 +0000 Authentication-Results: ; auth=pass (LOGIN) smtp.auth=joevt@shaw.ca X-Authority-Analysis: v=2.4 cv=SdyUytdu c=1 sm=1 tr=0 ts=6150305f a=qDatE6m/3wxSEG8Wq7h0zQ==:117 a=qDatE6m/3wxSEG8Wq7h0zQ==:17 a=_Dj-zB-qAAAA:8 a=_UliggVT9reaaKrPQY0A:9 a=c-cOe7UV8MviEfHuAVEQ:22 From: joevt To: Hans Verkuil Cc: linux-media@vger.kernel.org Subject: [PATCH v2 07/29] edid-decode: extended tag length check Date: Sun, 26 Sep 2021 01:33:08 -0700 Message-Id: <20210926083330.5206-8-joevt@shaw.ca> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210926083330.5206-1-joevt@shaw.ca> References: <20210926083330.5206-1-joevt@shaw.ca> MIME-Version: 1.0 X-CMAE-Envelope: MS4xfDj+u4Nplv7rCIWEO8fSNAHUhse0sWW7L1c1b8VNooIKeApJNtz20q+KTHy7q10ZDWcMiJYKfkluw5pMjlJExmDuMnYicmLNwN7xT8LD0RY0Xj8Z2wON YN79n8UCzbIhb7GAfJAFiJelA+UWiwzaIqjl5ZCVFU4i2sYXYcT4DQdZCvBm+aSzhNpp+y160Rofk6osHkIdtmcWFmcdwiY12l0= Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Change: - Don't read extended tag if length of extended block is zero. Report a fail in that case. Modifications that don't change behavior but help with the above change or with changes in later commits: - Differentiate extended tags from normal tags by adding 0x700 to the extended tag byte. - Increase x after parsing each byte (the tag/length byte and the extended tag byte). Decrease length if there's an extended byte. - Change cta_ext_block so that x parameter points to byte after the extended tag. Since x points to after extended tag, pass the extended tag as a parameter. - After reading an OUI, increase x by 3 and decrease length by 3. Signed-off-by: Joe van Tunen --- edid-decode.h | 2 +- parse-cta-block.cpp | 208 ++++++++++++++++++++++++-------------------- 2 files changed, 113 insertions(+), 97 deletions(-) diff --git a/edid-decode.h b/edid-decode.h index aef2bab..57cb6e6 100644 --- a/edid-decode.h +++ b/edid-decode.h @@ -344,7 +344,7 @@ struct edid_state { void cta_displayid_type_7(const unsigned char *x, unsigned length); void cta_displayid_type_8(const unsigned char *x, unsigned length); void cta_displayid_type_10(const unsigned char *x, unsigned length); - void cta_ext_block(const unsigned char *x, unsigned length, bool duplicate); + void cta_ext_block(unsigned tag, const unsigned char *x, unsigned length, bool duplicate); void cta_block(const unsigned char *x, bool duplicate); void preparse_cta_block(const unsigned char *x); void parse_cta_block(const unsigned char *x); diff --git a/parse-cta-block.cpp b/parse-cta-block.cpp index bba3af2..f1ad041 100644 --- a/parse-cta-block.cpp +++ b/parse-cta-block.cpp @@ -2027,7 +2027,7 @@ static void cta_hdmi_audio_block(const unsigned char *x, unsigned length) } } -void edid_state::cta_ext_block(const unsigned char *x, unsigned length, +void edid_state::cta_ext_block(unsigned tag, const unsigned char *x, unsigned length, bool duplicate) { const char *name; @@ -2035,60 +2035,60 @@ void edid_state::cta_ext_block(const unsigned char *x, unsigned length, bool reverse = false; bool audio_block = false; - switch (x[0]) { - case 0x00: data_block = "Video Capability Data Block"; break; - case 0x01: data_block.clear(); break; - case 0x02: data_block = "VESA Video Display Device Data Block"; break; - case 0x03: data_block = "VESA Video Timing Block Extension"; break; - case 0x04: data_block = "Reserved for HDMI Video Data Block"; break; - case 0x05: data_block = "Colorimetry Data Block"; break; - case 0x06: data_block = "HDR Static Metadata Data Block"; break; - case 0x07: data_block = "HDR Dynamic Metadata Data Block"; break; - - case 0x0d: data_block = "Video Format Preference Data Block"; break; - case 0x0e: data_block = "YCbCr 4:2:0 Video Data Block"; break; - case 0x0f: data_block = "YCbCr 4:2:0 Capability Map Data Block"; break; - case 0x10: data_block = "Reserved for CTA-861 Miscellaneous Audio Fields"; break; - case 0x11: data_block.clear(); audio_block = true; break; - case 0x12: data_block = "HDMI Audio Data Block"; audio_block = true; break; - case 0x13: data_block = "Room Configuration Data Block"; audio_block = true; break; - case 0x14: data_block = "Speaker Location Data Block"; audio_block = true; break; - - case 0x20: data_block = "InfoFrame Data Block"; break; - - case 0x34: data_block = "DisplayID Type VII Video Timing Data Block"; break; - case 0x35: data_block = "DisplayID Type VIII Video Timing Data Block"; break; - case 0x42: data_block = "DisplayID Type X Video Timing Data Block"; break; - - case 0x78: data_block = "HDMI Forum EDID Extension Override Data Block"; break; - case 0x79: data_block = "HDMI Forum Sink Capability Data Block"; break; + switch (tag) { + case 0x700: data_block = "Video Capability Data Block"; break; + case 0x701: data_block.clear(); break; + case 0x702: data_block = "VESA Video Display Device Data Block"; break; + case 0x703: data_block = "VESA Video Timing Block Extension"; break; + case 0x704: data_block = "Reserved for HDMI Video Data Block"; break; + case 0x705: data_block = "Colorimetry Data Block"; break; + case 0x706: data_block = "HDR Static Metadata Data Block"; break; + case 0x707: data_block = "HDR Dynamic Metadata Data Block"; break; + + case 0x70d: data_block = "Video Format Preference Data Block"; break; + case 0x70e: data_block = "YCbCr 4:2:0 Video Data Block"; break; + case 0x70f: data_block = "YCbCr 4:2:0 Capability Map Data Block"; break; + case 0x710: data_block = "Reserved for CTA-861 Miscellaneous Audio Fields"; break; + case 0x711: data_block.clear(); audio_block = true; break; + case 0x712: data_block = "HDMI Audio Data Block"; audio_block = true; break; + case 0x713: data_block = "Room Configuration Data Block"; audio_block = true; break; + case 0x714: data_block = "Speaker Location Data Block"; audio_block = true; break; + + case 0x720: data_block = "InfoFrame Data Block"; break; + + case 0x734: data_block = "DisplayID Type VII Video Timing Data Block"; break; + case 0x735: data_block = "DisplayID Type VIII Video Timing Data Block"; break; + case 0x742: data_block = "DisplayID Type X Video Timing Data Block"; break; + + case 0x778: data_block = "HDMI Forum EDID Extension Override Data Block"; break; + case 0x779: data_block = "HDMI Forum Sink Capability Data Block"; break; default: - if (x[0] <= 12) + if (tag < 0x70d) printf(" Unknown CTA-861 Video-Related"); - else if (x[0] <= 31) + else if (tag < 0x720) printf(" Unknown CTA-861 Audio-Related"); - else if (x[0] >= 120 && x[0] <= 127) + else if (tag >= 0x778 && tag <= 0x77f) printf(" Unknown CTA-861 HDMI-Related"); else printf(" Unknown CTA-861"); - printf(" Data Block (extended tag 0x%02x, length %u)\n", x[0], length); - hex_block(" ", x + 1, length); + printf(" Data Block (extended tag 0x%02x)\n", tag & 0xff); + hex_block(" ", x, length); data_block.clear(); - warn("Unknown Extended CTA-861 Data Block 0x%02x.\n", x[0]); + warn("Unknown Extended CTA-861 Data Block 0x%02x.\n", tag & 0xff); return; } - switch (x[0]) { - case 0x00: - case 0x02: - case 0x05: - case 0x06: - case 0x0d: - case 0x0f: - case 0x12: - case 0x13: - case 0x78: - case 0x79: + switch (tag) { + case 0x700: + case 0x702: + case 0x705: + case 0x706: + case 0x70d: + case 0x70f: + case 0x712: + case 0x713: + case 0x778: + case 0x779: if (duplicate) fail("Only one instance of this Data Block is allowed.\n"); } @@ -2100,15 +2100,16 @@ void edid_state::cta_ext_block(const unsigned char *x, unsigned length, if (data_block.length()) printf(" %s:\n", data_block.c_str()); - switch (x[0]) { - case 0x00: cta_vcdb(x + 1, length); break; - case 0x01: + switch (tag) { + case 0x700: cta_vcdb(x, length); break; + case 0x701: if (length < 3) { data_block = std::string("Vendor-Specific Video Data Block"); fail("Invalid length %u < 3.\n", length); break; } - oui = (x[3] << 16) + (x[2] << 8) + x[1]; + oui = (x[2] << 16) + (x[1] << 8) + x[0]; + x += 3; length -=3; name = oui_name(oui); if (!name) { name = oui_name(oui, true); @@ -2118,7 +2119,7 @@ void edid_state::cta_ext_block(const unsigned char *x, unsigned length, if (!name) { printf(" Vendor-Specific Video Data Block, OUI %s:\n", ouitohex(oui).c_str()); - hex_block(" ", x + 4, length - 3); + hex_block(" ", x, length); data_block.clear(); warn("Unknown Extended Vendor-Specific Video Data Block, OUI %s.\n", ouitohex(oui).c_str()); @@ -2129,26 +2130,27 @@ void edid_state::cta_ext_block(const unsigned char *x, unsigned length, fail((std::string("OUI ") + ouitohex(oui) + " is in the wrong byte order\n").c_str()); printf(" %s, OUI %s:\n", data_block.c_str(), ouitohex(oui).c_str()); if (oui == 0x90848b) - cta_hdr10plus(x + 4, length - 3); + cta_hdr10plus(x, length); else if (oui == 0x00d046) - cta_dolby_video(x + 4, length - 3); + cta_dolby_video(x, length); else - hex_block(" ", x + 4, length - 3); + hex_block(" ", x, length); break; - case 0x02: cta_vesa_vdddb(x + 1, length); break; - case 0x05: cta_colorimetry_block(x + 1, length); break; - case 0x06: cta_hdr_static_metadata_block(x + 1, length); break; - case 0x07: cta_hdr_dyn_metadata_block(x + 1, length); break; - case 0x0d: cta_vfpdb(x + 1, length); break; - case 0x0e: cta_svd(x + 1, length, true); break; - case 0x0f: cta_y420cmdb(x + 1, length); break; - case 0x11: + case 0x702: cta_vesa_vdddb(x, length); break; + case 0x705: cta_colorimetry_block(x, length); break; + case 0x706: cta_hdr_static_metadata_block(x, length); break; + case 0x707: cta_hdr_dyn_metadata_block(x, length); break; + case 0x70d: cta_vfpdb(x, length); break; + case 0x70e: cta_svd(x, length, true); break; + case 0x70f: cta_y420cmdb(x, length); break; + case 0x711: if (length < 3) { data_block = std::string("Vendor-Specific Audio Data Block"); fail("Invalid length %u < 3.\n", length); break; } - oui = (x[3] << 16) + (x[2] << 8) + x[1]; + oui = (x[2] << 16) + (x[1] << 8) + x[0]; + x += 3; length -=3; name = oui_name(oui); if (!name) { name = oui_name(oui, true); @@ -2158,7 +2160,7 @@ void edid_state::cta_ext_block(const unsigned char *x, unsigned length, if (!name) { printf(" Vendor-Specific Audio Data Block, OUI %s:\n", ouitohex(oui).c_str()); - hex_block(" ", x + 4, length - 3); + hex_block(" ", x, length); data_block.clear(); warn("Unknown Extended Vendor-Specific Audio Data Block, OUI %s.\n", ouitohex(oui).c_str()); @@ -2169,24 +2171,24 @@ void edid_state::cta_ext_block(const unsigned char *x, unsigned length, fail((std::string("OUI ") + ouitohex(oui) + " is in the wrong byte order\n").c_str()); printf(" %s, OUI %s:\n", data_block.c_str(), ouitohex(oui).c_str()); if (oui == 0x00d046) - cta_dolby_audio(x + 4, length - 3); + cta_dolby_audio(x, length); else - hex_block(" ", x + 4, length - 3); + hex_block(" ", x, length); break; - case 0x12: cta_hdmi_audio_block(x + 1, length); break; - case 0x13: cta_rcdb(x + 1, length); break; - case 0x14: cta_sldb(x + 1, length); break; - case 0x20: cta_ifdb(x + 1, length); break; - case 0x34: cta_displayid_type_7(x + 1, length); break; - case 0x35: cta_displayid_type_8(x + 1, length); break; - case 0x42: cta_displayid_type_10(x + 1, length); break; - case 0x78: - cta_hf_eeodb(x + 1, length); + case 0x712: cta_hdmi_audio_block(x, length); break; + case 0x713: cta_rcdb(x, length); break; + case 0x714: cta_sldb(x, length); break; + case 0x720: cta_ifdb(x, length); break; + case 0x734: cta_displayid_type_7(x, length); break; + case 0x735: cta_displayid_type_8(x, length); break; + case 0x742: cta_displayid_type_10(x, length); break; + case 0x778: + cta_hf_eeodb(x, length); // This must be the first CTA-861 block if (!cta.first_block) fail("Block starts at a wrong offset.\n"); break; - case 0x79: + case 0x779: if (!cta.last_block_was_hdmi_vsdb) fail("HDMI Forum SCDB did not immediately follow the HDMI VSDB.\n"); if (cta.have_hf_scdb || cta.have_hf_vsdb) @@ -2196,13 +2198,13 @@ void edid_state::cta_ext_block(const unsigned char *x, unsigned length, fail("Invalid length %u < 2.\n", length); break; } - if (x[1] || x[2]) + if (x[0] || x[1]) printf(" Non-zero SCDB reserved fields!\n"); - cta_hf_scdb(x + 3, length - 2); + cta_hf_scdb(x + 2, length - 2); cta.have_hf_scdb = 1; break; default: - hex_block(" ", x + 1, length); + hex_block(" ", x, length); } } @@ -2210,25 +2212,36 @@ void edid_state::cta_ext_block(const unsigned char *x, unsigned length, void edid_state::cta_block(const unsigned char *x, bool duplicate) { unsigned length = x[0] & 0x1f; + unsigned tag=(x[0] & 0xe0) >> 5; + unsigned extended = (tag == 0x07) ? 1 : 0; + x++; + if (extended && length) { + tag <<= 8; + tag |= x[0]; + length--; + x++; + } + const char *name; unsigned oui; bool reverse = false; bool audio_block = false; - switch ((x[0] & 0xe0) >> 5) { + switch (tag) { case 0x01: data_block = "Audio Data Block"; printf(" %s:\n", data_block.c_str()); - cta_audio_block(x + 1, length); + cta_audio_block(x, length); audio_block = true; break; case 0x02: data_block = "Video Data Block"; printf(" %s:\n", data_block.c_str()); - cta_svd(x + 1, length, false); + cta_svd(x, length, false); break; case 0x03: - oui = (x[3] << 16) + (x[2] << 8) + x[1]; + oui = (x[2] << 16) + (x[1] << 8) + x[0]; + x += 3; length -=3; name = oui_name(oui); if (!name) { name = oui_name(oui, true); @@ -2237,7 +2250,7 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) } if (!name) { printf(" Vendor-Specific Data Block, OUI %s:\n", ouitohex(oui).c_str()); - hex_block(" ", x + 4, length - 3); + hex_block(" ", x, length); data_block.clear(); warn("Unknown Vendor-Specific Data Block, OUI %s.\n", ouitohex(oui).c_str()); @@ -2248,7 +2261,7 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) fail((std::string("OUI ") + ouitohex(oui) + " is in the wrong byte order\n").c_str()); printf(" %s, OUI %s:\n", data_block.c_str(), ouitohex(oui).c_str()); if (oui == 0x000c03) { - cta_hdmi_block(x + 4, length - 3); + cta_hdmi_block(x, length); cta.last_block_was_hdmi_vsdb = 1; cta.first_block = 0; // The HDMI OUI is present, so this EDID represents an HDMI @@ -2264,24 +2277,24 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) fail("HDMI Forum VSDB did not immediately follow the HDMI VSDB.\n"); if (cta.have_hf_scdb || cta.have_hf_vsdb) fail("Duplicate HDMI Forum VSDB/SCDB.\n"); - cta_hf_scdb(x + 4, length - 3); + cta_hf_scdb(x, length); cta.have_hf_vsdb = 1; break; } if (oui == 0x00001a) { - cta_amd(x + 4, length - 3); + cta_amd(x, length); break; } if (oui == 0xca125c && length == 0x15) { - cta_microsoft(x + 4, length - 3); + cta_microsoft(x, length); break; } - hex_block(" ", x + 4, length - 3); + hex_block(" ", x, length); break; case 0x04: data_block = "Speaker Allocation Data Block"; printf(" %s:\n", data_block.c_str()); - cta_sadb(x + 1, length); + cta_sadb(x, length); audio_block = true; if (duplicate) fail("Only one instance of this Data Block is allowed.\n"); @@ -2289,19 +2302,22 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) case 0x05: data_block = "VESA Display Transfer Characteristics Data Block"; printf(" %s:\n", data_block.c_str()); - cta_vesa_dtcdb(x + 1, length); + cta_vesa_dtcdb(x, length); if (duplicate) fail("Only one instance of this Data Block is allowed.\n"); break; case 0x07: - cta_ext_block(x + 1, length - 1, duplicate); + data_block = "Unknown CTA-861 Data Block (extended tag truncated)"; + printf(" %s:\n", data_block.c_str()); + fail("Extended tag cannot have zero length.\n"); break; default: { - unsigned tag = (*x & 0xe0) >> 5; - unsigned length = *x & 0x1f; - - printf(" Unknown CTA-861 tag 0x%02x, length %u\n", tag, length); - hex_block(" ", x + 1, length); + if (extended) { + cta_ext_block(tag, x, length, duplicate); + break; + } + printf(" Unknown CTA-861 tag 0x%02x\n", tag); + hex_block(" ", x, length); data_block.clear(); warn("Unknown CTA-861 Data Block %u.\n", tag); break; From patchwork Sun Sep 26 08:33:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: joevt X-Patchwork-Id: 12518065 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46179C433F5 for ; Sun, 26 Sep 2021 08:33:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2AC4260EE0 for ; Sun, 26 Sep 2021 08:33:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229797AbhIZIfN (ORCPT ); Sun, 26 Sep 2021 04:35:13 -0400 Received: from omta001.cacentral1.a.cloudfilter.net ([3.97.99.32]:43776 "EHLO omta001.cacentral1.a.cloudfilter.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229730AbhIZIfM (ORCPT ); Sun, 26 Sep 2021 04:35:12 -0400 Received: from shw-obgw-4004a.ext.cloudfilter.net ([10.228.9.227]) by cmsmtp with ESMTP id U9QQmfBXuczbLUPbMmV5UD; Sun, 26 Sep 2021 08:33:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=shaw.ca; s=s20180605; t=1632645216; bh=cxyaxxnK8vlZziWlgCEUEHzp47YRM7TOJ7SNy1QIctw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=oaI9mupkyohfKjO5V14gXwiRZd8BJ9Va58lKLsyufFxCVRXTzrwE0FE7FyimEAJEc Cg5Tmx7eTjzVHaztsGJUt1JkWBcX4ZqtHZzQnjAg34GrcH8WVgZ936nP7VtQQID8t5 W+ycPPac5D4PSP9P9vpg7mosZPqxh12MSlbCudcj9kp4zN6h3CofCMVSVMbMd0OS9H jr7ZkmghAoazdrYBC+vobuaQq5fOBPhqbY9AgieM4vpd+I8SPAwYVNR05ePN1YkYx5 4P9PFZ3k2+3fnRIQHRNd0aboR4aWHgiKZnNx4kZKosq8ujLFjbLYPNbskwbC0TBtwy JSBneuj9EBXnw== Received: from shaw.ca ([70.71.78.228]) by cmsmtp with ESMTPA id UPbGmpVUmdCHGUPbLm6iEd; Sun, 26 Sep 2021 08:33:36 +0000 Authentication-Results: ; auth=pass (LOGIN) smtp.auth=joevt@shaw.ca X-Authority-Analysis: v=2.4 cv=SdyUytdu c=1 sm=1 tr=0 ts=61503060 a=qDatE6m/3wxSEG8Wq7h0zQ==:117 a=qDatE6m/3wxSEG8Wq7h0zQ==:17 a=_Dj-zB-qAAAA:8 a=LIcKB4O_YFRxREVKF7IA:9 a=+jEqtf1s3R9VXZ0wqowq2kgwd+I=:19 a=c-cOe7UV8MviEfHuAVEQ:22 From: joevt To: Hans Verkuil Cc: linux-media@vger.kernel.org Subject: [PATCH v2 08/29] edid-decode: Output block type before fail Date: Sun, 26 Sep 2021 01:33:09 -0700 Message-Id: <20210926083330.5206-9-joevt@shaw.ca> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210926083330.5206-1-joevt@shaw.ca> References: <20210926083330.5206-1-joevt@shaw.ca> MIME-Version: 1.0 X-CMAE-Envelope: MS4xfIOATl9zMXl0FJ50DkXDFGJYe7nugBSE5oX2wPChKlD0XksBv6c6X8Dw95FVxT9xU4jbesc1vc5RNEDuv+Hv4/NJmVdA93rWd8EAmPk4z2polZ0YP+US 20jKE1jZ8LsR11RqNCnnn8k6EvElvpCut1mM8knYpdC3aR/sAfln0T6pOkOCSDAI1fvNs2j5MWXQ0FAkiHhVZ+iZG1cJoYN53i0= Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org For extended tags, block type should be output before fail messages (duplicate failure, or missing audio failure). For normal tags 0x04 and 0x05, fail message should appear after block type instead of block data to be consistent (and also to indicate that the failure is because of the block type and not the contents of the block). Signed-off-by: Joe van Tunen --- parse-cta-block.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/parse-cta-block.cpp b/parse-cta-block.cpp index f1ad041..fb2e9ea 100644 --- a/parse-cta-block.cpp +++ b/parse-cta-block.cpp @@ -2078,6 +2078,9 @@ void edid_state::cta_ext_block(unsigned tag, const unsigned char *x, unsigned le return; } + if (data_block.length()) + printf(" %s:\n", data_block.c_str()); + switch (tag) { case 0x700: case 0x702: @@ -2097,9 +2100,6 @@ void edid_state::cta_ext_block(unsigned tag, const unsigned char *x, unsigned le if (audio_block && !(cta.byte3 & 0x40)) fail("Audio information is present, but bit 6 of Byte 3 of the CTA-861 Extension header indicates no Basic Audio support.\n"); - if (data_block.length()) - printf(" %s:\n", data_block.c_str()); - switch (tag) { case 0x700: cta_vcdb(x, length); break; case 0x701: @@ -2294,17 +2294,17 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) case 0x04: data_block = "Speaker Allocation Data Block"; printf(" %s:\n", data_block.c_str()); - cta_sadb(x, length); - audio_block = true; if (duplicate) fail("Only one instance of this Data Block is allowed.\n"); + cta_sadb(x, length); + audio_block = true; break; case 0x05: data_block = "VESA Display Transfer Characteristics Data Block"; printf(" %s:\n", data_block.c_str()); - cta_vesa_dtcdb(x, length); if (duplicate) fail("Only one instance of this Data Block is allowed.\n"); + cta_vesa_dtcdb(x, length); break; case 0x07: data_block = "Unknown CTA-861 Data Block (extended tag truncated)"; From patchwork Sun Sep 26 08:33:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: joevt X-Patchwork-Id: 12518067 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC992C433FE for ; Sun, 26 Sep 2021 08:33:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C637C60EE0 for ; Sun, 26 Sep 2021 08:33:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229802AbhIZIfN (ORCPT ); Sun, 26 Sep 2021 04:35:13 -0400 Received: from omta001.cacentral1.a.cloudfilter.net ([3.97.99.32]:51462 "EHLO omta001.cacentral1.a.cloudfilter.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229789AbhIZIfM (ORCPT ); Sun, 26 Sep 2021 04:35:12 -0400 Received: from shw-obgw-4004a.ext.cloudfilter.net ([10.228.9.227]) by cmsmtp with ESMTP id UHFtmfkKBczbLUPbMmV5UF; Sun, 26 Sep 2021 08:33:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=shaw.ca; s=s20180605; t=1632645216; bh=zQiDkxoEYRXNy4twOmJPfhCfdi3WE4Jy/ZgnvE7ayAs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=pat5vUFXY03JWT80rJPPH7Rh++tdD/cKQQpAQFqDeVYLvT1RJlIIDQsZ9U6f9dcZk XlMV0dpvLBUsQ37gAH4J32IN7hmPl78FwJlnCq90VnJeYWCXYtWPbSrItX8lxA8xS7 JdnIh4VE5jw2TKFhEE6EK5f0/JMMImNx1Th1xjbth+2C9iPjBKyseDnbqIQcDiIbMe aSb0zrnmJxv18Z57c1Pdr+NBSj8/70A8CX8mJkJ7/XznDB8eMPrCpsQU6XIRhz0OWW 6i/X5xJeOSxtHRkwi0gDY1nRSxFurlAZhkzoWVINr+pAOCB0AiX1JqwXZdyJ8Qa7tA jsBSZdU2r+Hww== Received: from shaw.ca ([70.71.78.228]) by cmsmtp with ESMTPA id UPbGmpVUmdCHGUPbMm6iEl; Sun, 26 Sep 2021 08:33:36 +0000 Authentication-Results: ; auth=pass (LOGIN) smtp.auth=joevt@shaw.ca X-Authority-Analysis: v=2.4 cv=SdyUytdu c=1 sm=1 tr=0 ts=61503060 a=qDatE6m/3wxSEG8Wq7h0zQ==:117 a=qDatE6m/3wxSEG8Wq7h0zQ==:17 a=_Dj-zB-qAAAA:8 a=_zDHQJX43gnR_71ToFUA:9 a=c-cOe7UV8MviEfHuAVEQ:22 From: joevt To: Hans Verkuil Cc: linux-media@vger.kernel.org Subject: [PATCH v2 09/29] edid-decode: update Microsoft expected length Date: Sun, 26 Sep 2021 01:33:10 -0700 Message-Id: <20210926083330.5206-10-joevt@shaw.ca> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210926083330.5206-1-joevt@shaw.ca> References: <20210926083330.5206-1-joevt@shaw.ca> MIME-Version: 1.0 X-CMAE-Envelope: MS4xfIOATl9zMXl0FJ50DkXDFGJYe7nugBSE5oX2wPChKlD0XksBv6c6X8Dw95FVxT9xU4jbesc1vc5RNEDuv+Hv4/NJmVdA93rWd8EAmPk4z2polZ0YP+US 20jKE1jZ8LsR11RqNCnnn8k6EvElvpCut1mM8knYpdC3aR/sAfln0T6pOkOCSDAI1fvNs2j5MWXQ0FAkiHhVZ+iZG1cJoYN53i0= Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Since we excluded the size of the OUI from the length in a previous commit, we need to decrease the expected length accordingly. See example DELA07B/5F1B08ADB0A0, LENB800/61B4B713B745 Really, length checks should probably be done in the parse function. If length is greater than expected then parse up to the expected length and output the rest as hex with a warning. If length is less than expected then parse up to the length and warn that some expected bytes are missing. Signed-off-by: Joe van Tunen --- parse-cta-block.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parse-cta-block.cpp b/parse-cta-block.cpp index fb2e9ea..3b6126a 100644 --- a/parse-cta-block.cpp +++ b/parse-cta-block.cpp @@ -2285,7 +2285,7 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) cta_amd(x, length); break; } - if (oui == 0xca125c && length == 0x15) { + if (oui == 0xca125c && length == 0x12) { cta_microsoft(x, length); break; } From patchwork Sun Sep 26 08:33:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: joevt X-Patchwork-Id: 12518069 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C860C4332F for ; Sun, 26 Sep 2021 08:33:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 53E1560F11 for ; Sun, 26 Sep 2021 08:33:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229814AbhIZIfO (ORCPT ); Sun, 26 Sep 2021 04:35:14 -0400 Received: from omta001.cacentral1.a.cloudfilter.net ([3.97.99.32]:37615 "EHLO omta001.cacentral1.a.cloudfilter.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229792AbhIZIfN (ORCPT ); Sun, 26 Sep 2021 04:35:13 -0400 Received: from shw-obgw-4004a.ext.cloudfilter.net ([10.228.9.227]) by cmsmtp with ESMTP id U6mYmf0pJczbLUPbNmV5UH; Sun, 26 Sep 2021 08:33:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=shaw.ca; s=s20180605; t=1632645217; bh=MYWGij0vHvYGYaXiy0PSj4CP+gM9vPRPHEwl/YD+S/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=RwZ1MN4l1KefbxJptJu5Pk/ZxniRAsjoMaIXRrRA6nhXI4jf+KviHdMYQYv2E3Y47 u28H9zCuMv/TT8wKcd8XN1cxo3OvvTZ3gG1bRLuFgcvLMHnABcOGJI4O56NKNNIlY3 GxRkwDKo/VYBmYOjsgZASUmiW87EjWmCIhDxepv5NRJ3g2VAXFLPF2GstBxgWeCIgj XrH9KTopd+6MZBG65aEFCI4dbw8En7GFAfiswfFeVziaLudvvqVH0MTI6uGDeg5P0/ nwf6lYpxD5N5DsZuETBaW32+V2S+NMueHYzTImH3gI4T5pHDPMU1/Aezg+P7WhkyXQ NLhEy6DsJx4hg== Received: from shaw.ca ([70.71.78.228]) by cmsmtp with ESMTPA id UPbGmpVUmdCHGUPbMm6iEr; Sun, 26 Sep 2021 08:33:37 +0000 Authentication-Results: ; auth=pass (LOGIN) smtp.auth=joevt@shaw.ca X-Authority-Analysis: v=2.4 cv=SdyUytdu c=1 sm=1 tr=0 ts=61503061 a=qDatE6m/3wxSEG8Wq7h0zQ==:117 a=qDatE6m/3wxSEG8Wq7h0zQ==:17 a=_Dj-zB-qAAAA:8 a=NpxgihWcVqL9SJ54IewA:9 a=c-cOe7UV8MviEfHuAVEQ:22 From: joevt To: Hans Verkuil Cc: linux-media@vger.kernel.org Subject: [PATCH v2 10/29] edid-decode: Capitalize fail sentence Date: Sun, 26 Sep 2021 01:33:11 -0700 Message-Id: <20210926083330.5206-11-joevt@shaw.ca> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210926083330.5206-1-joevt@shaw.ca> References: <20210926083330.5206-1-joevt@shaw.ca> MIME-Version: 1.0 X-CMAE-Envelope: MS4xfNWIORIyqyvehAfgCntzQcLClwTSIO8HWG4PTr7A2L0V0pm7Q470aWaz76MpLaUoNqYgeXjF23lXCog6kU6Hvq6UMeAoBCmEm6XKF9nUA6UIBUHKVLbb QFcSkz5N4m7gJ1/hGRoXHwI82wZehx1FRLyFIBilUrcLoQ9scC3hN1diH0mFc5Pt4sMbeP1yOJQLITn5E+s4jnuWoteDGcclNAc= Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Most fail messages are a sentence that starts with a capital letter and ends with a period. Signed-off-by: Joe van Tunen --- parse-cta-block.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parse-cta-block.cpp b/parse-cta-block.cpp index 3b6126a..7568780 100644 --- a/parse-cta-block.cpp +++ b/parse-cta-block.cpp @@ -2326,7 +2326,7 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) // See Table 52 of CTA-861-G for a description of Byte 3 if (audio_block && !(cta.byte3 & 0x40)) - fail("audio information is present, but bit 6 of Byte 3 of the CTA-861 Extension header indicates no Basic Audio support.\n"); + fail("Audio information is present, but bit 6 of Byte 3 of the CTA-861 Extension header indicates no Basic Audio support.\n"); cta.first_block = 0; cta.last_block_was_hdmi_vsdb = 0; } From patchwork Sun Sep 26 08:33:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: joevt X-Patchwork-Id: 12518071 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EFCC9C43217 for ; Sun, 26 Sep 2021 08:33:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D6BD960F11 for ; Sun, 26 Sep 2021 08:33:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229824AbhIZIfO (ORCPT ); Sun, 26 Sep 2021 04:35:14 -0400 Received: from omta002.cacentral1.a.cloudfilter.net ([3.97.99.33]:39161 "EHLO omta002.cacentral1.a.cloudfilter.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229789AbhIZIfO (ORCPT ); Sun, 26 Sep 2021 04:35:14 -0400 Received: from shw-obgw-4004a.ext.cloudfilter.net ([10.228.9.227]) by cmsmtp with ESMTP id UOTkmIDsmps7PUPbOmzSGs; Sun, 26 Sep 2021 08:33:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=shaw.ca; s=s20180605; t=1632645218; bh=nAp33AoMeyx/6b0T6CeO1LGJ7R917Se/lRndXeixL04=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=OqG10YLK6tTrbNhxbIFW7lAgMukXqdB8TYGwwsQdNKBDnL8h0S9L9y4ZskPhD2gBu J/zEdMXv4AqZNR7o/hIZsRBzdNHJwBoWwSxIqbGjv8izhQDuY5fE2HyQpUm6MURC4O z7tPC2p6y9Pq4/Td4tPSqgTKcr8Ex6oV+2D5+V8ZWLRnG2LMC5OHKl5yEI+tixAapU ZSEcpq/Pf/rcuVJh1wZVUp3ha63pxuXD2Dmwifk/Gyj4PoRx9ZBrimJK2Fww1V8BYT BURb3kl+H2QSqSALyokAkCw9Do4+sa7YJTVHSMUjy6yenm6Kgy1cFZ72/AaRXsyJvt wIWZTlELqc7Fw== Received: from shaw.ca ([70.71.78.228]) by cmsmtp with ESMTPA id UPbGmpVUmdCHGUPbNm6iEx; Sun, 26 Sep 2021 08:33:38 +0000 Authentication-Results: ; auth=pass (LOGIN) smtp.auth=joevt@shaw.ca X-Authority-Analysis: v=2.4 cv=SdyUytdu c=1 sm=1 tr=0 ts=61503062 a=qDatE6m/3wxSEG8Wq7h0zQ==:117 a=qDatE6m/3wxSEG8Wq7h0zQ==:17 a=_Dj-zB-qAAAA:8 a=ZfDUfGQU7dOj8CFQmiUA:9 a=c-cOe7UV8MviEfHuAVEQ:22 From: joevt To: Hans Verkuil Cc: linux-media@vger.kernel.org Subject: [PATCH v2 11/29] edid-decode: make all OUI handlers the same Date: Sun, 26 Sep 2021 01:33:12 -0700 Message-Id: <20210926083330.5206-12-joevt@shaw.ca> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210926083330.5206-1-joevt@shaw.ca> References: <20210926083330.5206-1-joevt@shaw.ca> MIME-Version: 1.0 X-CMAE-Envelope: MS4xfFQEtdGkPyR7HojCR5aSKfJ0WtCYp9U5nbd32We80nuxb6WpIbAjZm+AX+4GHWjE4WytjJdSJJ7y26xFUozQ139qcmx60QvuszFvdKj/2e+firTjv1Al xRdrr6oInN37ljyuj4T2f4+Nt9/YRHsR0jCyCW1dnY7fRh3f4iABLckKeteJiRkqqepPn2465mnUcdNXDuwnEZKJCUyvTcbZ1yk= Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Because they are the same but with different block names. For Vendor-Specific Data Block there are a couple fixes: 1) If the length is not enough to contain an OUI, then a fail is output. I have a corrupted EDID that would cause 20000+ lines of hex to be output without this check. 2) The return statement for VSDB with unknown OUI is changed to a break statement. The code after the switch statement will be executed which causes the block to be considered as a first block or as not a hdmi vsdb. Signed-off-by: Joe van Tunen --- parse-cta-block.cpp | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/parse-cta-block.cpp b/parse-cta-block.cpp index 7568780..b4645b4 100644 --- a/parse-cta-block.cpp +++ b/parse-cta-block.cpp @@ -2030,6 +2030,7 @@ static void cta_hdmi_audio_block(const unsigned char *x, unsigned length) void edid_state::cta_ext_block(unsigned tag, const unsigned char *x, unsigned length, bool duplicate) { + const char *block_name; const char *name; unsigned oui; bool reverse = false; @@ -2103,8 +2104,9 @@ void edid_state::cta_ext_block(unsigned tag, const unsigned char *x, unsigned le switch (tag) { case 0x700: cta_vcdb(x, length); break; case 0x701: + block_name = "Vendor-Specific Video Data Block"; if (length < 3) { - data_block = std::string("Vendor-Specific Video Data Block"); + data_block = std::string(block_name); fail("Invalid length %u < 3.\n", length); break; } @@ -2117,15 +2119,13 @@ void edid_state::cta_ext_block(unsigned tag, const unsigned char *x, unsigned le reverse = true; } if (!name) { - printf(" Vendor-Specific Video Data Block, OUI %s:\n", - ouitohex(oui).c_str()); + printf(" %s, OUI %s:\n", block_name, ouitohex(oui).c_str()); hex_block(" ", x, length); data_block.clear(); - warn("Unknown Extended Vendor-Specific Video Data Block, OUI %s.\n", - ouitohex(oui).c_str()); + warn("Unknown %s, OUI %s.\n", block_name, ouitohex(oui).c_str()); break; } - data_block = std::string("Vendor-Specific Video Data Block (") + name + ")"; + data_block = std::string(block_name) + " (" + name + ")"; if (reverse) fail((std::string("OUI ") + ouitohex(oui) + " is in the wrong byte order\n").c_str()); printf(" %s, OUI %s:\n", data_block.c_str(), ouitohex(oui).c_str()); @@ -2144,8 +2144,9 @@ void edid_state::cta_ext_block(unsigned tag, const unsigned char *x, unsigned le case 0x70e: cta_svd(x, length, true); break; case 0x70f: cta_y420cmdb(x, length); break; case 0x711: + block_name = "Vendor-Specific Audio Data Block"; if (length < 3) { - data_block = std::string("Vendor-Specific Audio Data Block"); + data_block = std::string(block_name); fail("Invalid length %u < 3.\n", length); break; } @@ -2158,15 +2159,13 @@ void edid_state::cta_ext_block(unsigned tag, const unsigned char *x, unsigned le reverse = true; } if (!name) { - printf(" Vendor-Specific Audio Data Block, OUI %s:\n", - ouitohex(oui).c_str()); + printf(" %s, OUI %s:\n", block_name, ouitohex(oui).c_str()); hex_block(" ", x, length); data_block.clear(); - warn("Unknown Extended Vendor-Specific Audio Data Block, OUI %s.\n", - ouitohex(oui).c_str()); + warn("Unknown %s, OUI %s.\n", block_name, ouitohex(oui).c_str()); break; } - data_block = std::string("Vendor-Specific Audio Data Block (") + name + ")"; + data_block = std::string(block_name) + " (" + name + ")"; if (reverse) fail((std::string("OUI ") + ouitohex(oui) + " is in the wrong byte order\n").c_str()); printf(" %s, OUI %s:\n", data_block.c_str(), ouitohex(oui).c_str()); @@ -2222,6 +2221,7 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) x++; } + const char *block_name; const char *name; unsigned oui; bool reverse = false; @@ -2240,6 +2240,12 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) cta_svd(x, length, false); break; case 0x03: + block_name = "Vendor-Specific Data Block"; + if (length < 3) { + data_block = std::string(block_name); + fail("Invalid length %u < 3.\n", length); + break; + } oui = (x[2] << 16) + (x[1] << 8) + x[0]; x += 3; length -=3; name = oui_name(oui); @@ -2249,14 +2255,13 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) reverse = true; } if (!name) { - printf(" Vendor-Specific Data Block, OUI %s:\n", ouitohex(oui).c_str()); + printf(" %s, OUI %s:\n", block_name, ouitohex(oui).c_str()); hex_block(" ", x, length); data_block.clear(); - warn("Unknown Vendor-Specific Data Block, OUI %s.\n", - ouitohex(oui).c_str()); - return; + warn("Unknown %s, OUI %s.\n", block_name, ouitohex(oui).c_str()); + break; } - data_block = std::string("Vendor-Specific Data Block (") + name + ")"; + data_block = std::string(block_name) + " (" + name + ")"; if (reverse) fail((std::string("OUI ") + ouitohex(oui) + " is in the wrong byte order\n").c_str()); printf(" %s, OUI %s:\n", data_block.c_str(), ouitohex(oui).c_str()); From patchwork Sun Sep 26 08:33:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: joevt X-Patchwork-Id: 12518073 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AB53C433F5 for ; Sun, 26 Sep 2021 08:33:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 35D9760EE0 for ; Sun, 26 Sep 2021 08:33:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229835AbhIZIfP (ORCPT ); Sun, 26 Sep 2021 04:35:15 -0400 Received: from omta001.cacentral1.a.cloudfilter.net ([3.97.99.32]:43776 "EHLO omta001.cacentral1.a.cloudfilter.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229813AbhIZIfO (ORCPT ); Sun, 26 Sep 2021 04:35:14 -0400 Received: from shw-obgw-4004a.ext.cloudfilter.net ([10.228.9.227]) by cmsmtp with ESMTP id U8Srmf7ImczbLUPbOmV5UJ; Sun, 26 Sep 2021 08:33:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=shaw.ca; s=s20180605; t=1632645218; bh=9dyqK7oic0IBf8wro9GV+2jTpq0NP5bZMc9d9xWqazM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=e1I0Q1g0xznaA18sRAqq4UAjzU5SoOjAm1yFuzmiyHF4pYP0fNAxlDlQeujOgkX+P pAhkvEqH5EomzMmdfIh9lURYkTk/JQmiBjizZp+ewZ9s58pexPRl+HdYK/h0Eo3Sen KInUGfCyi6XiSTqZqpMG4RA0XVeRZDp4o8h1VIWOI1as1ZCUGbPDdvnCVyFeMd28eW pCDX7aaRHSDyH6fb5b33r13jrJ7fYVy9Vx4xGxHgaZts4DWI2xv/ENDxnLTQv/ix25 s9nu8Q+copNpqDTVvM5VtPBCkZvtBuNSyCLpSvgelbFY/CuuwiGPWtzkExJR1C8By5 RTwZ85w8/GI6Q== Received: from shaw.ca ([70.71.78.228]) by cmsmtp with ESMTPA id UPbGmpVUmdCHGUPbOm6iF1; Sun, 26 Sep 2021 08:33:38 +0000 Authentication-Results: ; auth=pass (LOGIN) smtp.auth=joevt@shaw.ca X-Authority-Analysis: v=2.4 cv=SdyUytdu c=1 sm=1 tr=0 ts=61503062 a=qDatE6m/3wxSEG8Wq7h0zQ==:117 a=qDatE6m/3wxSEG8Wq7h0zQ==:17 a=_Dj-zB-qAAAA:8 a=9WAPh8486Br8_YOXBiUA:9 a=c-cOe7UV8MviEfHuAVEQ:22 From: joevt To: Hans Verkuil Cc: linux-media@vger.kernel.org Subject: [PATCH v2 12/29] edid-decode: move OUI parsing to separate function Date: Sun, 26 Sep 2021 01:33:13 -0700 Message-Id: <20210926083330.5206-13-joevt@shaw.ca> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210926083330.5206-1-joevt@shaw.ca> References: <20210926083330.5206-1-joevt@shaw.ca> MIME-Version: 1.0 X-CMAE-Envelope: MS4xfFQEtdGkPyR7HojCR5aSKfJ0WtCYp9U5nbd32We80nuxb6WpIbAjZm+AX+4GHWjE4WytjJdSJJ7y26xFUozQ139qcmx60QvuszFvdKj/2e+firTjv1Al xRdrr6oInN37ljyuj4T2f4+Nt9/YRHsR0jCyCW1dnY7fRh3f4iABLckKeteJiRkqqepPn2465mnUcdNXDuwnEZKJCUyvTcbZ1yk= Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Since all three occurrences of OUI parsing are the same in parse-cta-block.cpp, we can move them to a separate function in edid-decode.cpp (because we may want to use the function for non-CTA parsing as well). data_block_oui contains identical code except for the following: 1) The warning for unknown OUI name is output after the block name instead of after the block contents. Other changes that don't affect output: - oui is set to 0 if the OUI is unknown so that it can't lead to executing any known OUI code by the caller. - A macro is used to call data_block_oui. It updates x and length appropriately for the caller. Signed-off-by: Joe van Tunen --- edid-decode.cpp | 34 +++++++++++++++++ edid-decode.h | 2 + parse-cta-block.cpp | 91 +++++---------------------------------------- 3 files changed, 46 insertions(+), 81 deletions(-) diff --git a/edid-decode.cpp b/edid-decode.cpp index d77646d..ec903f9 100644 --- a/edid-decode.cpp +++ b/edid-decode.cpp @@ -679,6 +679,40 @@ const char *oui_name(unsigned oui, bool reverse) } } +void edid_state::data_block_oui(const char *block_name, const unsigned char *x, unsigned length, unsigned *ouinum) +{ + const char *name; + unsigned oui = 0; + bool reverse = false; + + if (length < 3) { + data_block = std::string(block_name); + fail("Invalid length %u < 3.\n", length); + } + else { + oui = (x[2] << 16) + (x[1] << 8) + x[0]; + x += 3; length -=3; + name = oui_name(oui); + if (!name) { + name = oui_name(oui, true); + if (name) + reverse = true; + } + if (!name) { + printf(" %s, OUI %s:\n", block_name, ouitohex(oui).c_str()); + data_block.clear(); + warn("Unknown %s, OUI %s.\n", block_name, ouitohex(oui).c_str()); + } + else { + data_block = std::string(block_name) + " (" + name + ")"; + if (reverse) + fail((std::string("OUI ") + ouitohex(oui) + " is in the wrong byte order\n").c_str()); + printf(" %s, OUI %s:\n", data_block.c_str(), ouitohex(oui).c_str()); + } + } + if (ouinum) *ouinum = oui; +} + std::string ouitohex(unsigned oui) { char buf[32]; diff --git a/edid-decode.h b/edid-decode.h index 57cb6e6..2409718 100644 --- a/edid-decode.h +++ b/edid-decode.h @@ -331,6 +331,8 @@ struct edid_state { void list_dmts(); void list_established_timings(); + void data_block_oui(const char *block_name, const unsigned char *x, unsigned length, unsigned *ouinum); + void print_vic_index(const char *prefix, unsigned idx, const char *suffix, bool ycbcr420 = false); void hdmi_latency(unsigned char vid_lat, unsigned char aud_lat, bool is_ilaced); void cta_vcdb(const unsigned char *x, unsigned length); diff --git a/parse-cta-block.cpp b/parse-cta-block.cpp index b4645b4..0000249 100644 --- a/parse-cta-block.cpp +++ b/parse-cta-block.cpp @@ -2027,13 +2027,17 @@ static void cta_hdmi_audio_block(const unsigned char *x, unsigned length) } } +#define data_block_o(n) \ + do { \ + data_block_oui(n, x, length, &oui); \ + x += (length < 3) ? length : 3; \ + length -= (length < 3) ? length : 3; \ + } while(0) + void edid_state::cta_ext_block(unsigned tag, const unsigned char *x, unsigned length, bool duplicate) { - const char *block_name; - const char *name; unsigned oui; - bool reverse = false; bool audio_block = false; switch (tag) { @@ -2104,31 +2108,7 @@ void edid_state::cta_ext_block(unsigned tag, const unsigned char *x, unsigned le switch (tag) { case 0x700: cta_vcdb(x, length); break; case 0x701: - block_name = "Vendor-Specific Video Data Block"; - if (length < 3) { - data_block = std::string(block_name); - fail("Invalid length %u < 3.\n", length); - break; - } - oui = (x[2] << 16) + (x[1] << 8) + x[0]; - x += 3; length -=3; - name = oui_name(oui); - if (!name) { - name = oui_name(oui, true); - if (name) - reverse = true; - } - if (!name) { - printf(" %s, OUI %s:\n", block_name, ouitohex(oui).c_str()); - hex_block(" ", x, length); - data_block.clear(); - warn("Unknown %s, OUI %s.\n", block_name, ouitohex(oui).c_str()); - break; - } - data_block = std::string(block_name) + " (" + name + ")"; - if (reverse) - fail((std::string("OUI ") + ouitohex(oui) + " is in the wrong byte order\n").c_str()); - printf(" %s, OUI %s:\n", data_block.c_str(), ouitohex(oui).c_str()); + data_block_o("Vendor-Specific Video Data Block"); if (oui == 0x90848b) cta_hdr10plus(x, length); else if (oui == 0x00d046) @@ -2144,31 +2124,7 @@ void edid_state::cta_ext_block(unsigned tag, const unsigned char *x, unsigned le case 0x70e: cta_svd(x, length, true); break; case 0x70f: cta_y420cmdb(x, length); break; case 0x711: - block_name = "Vendor-Specific Audio Data Block"; - if (length < 3) { - data_block = std::string(block_name); - fail("Invalid length %u < 3.\n", length); - break; - } - oui = (x[2] << 16) + (x[1] << 8) + x[0]; - x += 3; length -=3; - name = oui_name(oui); - if (!name) { - name = oui_name(oui, true); - if (name) - reverse = true; - } - if (!name) { - printf(" %s, OUI %s:\n", block_name, ouitohex(oui).c_str()); - hex_block(" ", x, length); - data_block.clear(); - warn("Unknown %s, OUI %s.\n", block_name, ouitohex(oui).c_str()); - break; - } - data_block = std::string(block_name) + " (" + name + ")"; - if (reverse) - fail((std::string("OUI ") + ouitohex(oui) + " is in the wrong byte order\n").c_str()); - printf(" %s, OUI %s:\n", data_block.c_str(), ouitohex(oui).c_str()); + data_block_o("Vendor-Specific Audio Data Block"); if (oui == 0x00d046) cta_dolby_audio(x, length); else @@ -2221,10 +2177,7 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) x++; } - const char *block_name; - const char *name; unsigned oui; - bool reverse = false; bool audio_block = false; switch (tag) { @@ -2240,31 +2193,7 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) cta_svd(x, length, false); break; case 0x03: - block_name = "Vendor-Specific Data Block"; - if (length < 3) { - data_block = std::string(block_name); - fail("Invalid length %u < 3.\n", length); - break; - } - oui = (x[2] << 16) + (x[1] << 8) + x[0]; - x += 3; length -=3; - name = oui_name(oui); - if (!name) { - name = oui_name(oui, true); - if (name) - reverse = true; - } - if (!name) { - printf(" %s, OUI %s:\n", block_name, ouitohex(oui).c_str()); - hex_block(" ", x, length); - data_block.clear(); - warn("Unknown %s, OUI %s.\n", block_name, ouitohex(oui).c_str()); - break; - } - data_block = std::string(block_name) + " (" + name + ")"; - if (reverse) - fail((std::string("OUI ") + ouitohex(oui) + " is in the wrong byte order\n").c_str()); - printf(" %s, OUI %s:\n", data_block.c_str(), ouitohex(oui).c_str()); + data_block_o("Vendor-Specific Data Block"); if (oui == 0x000c03) { cta_hdmi_block(x, length); cta.last_block_was_hdmi_vsdb = 1; From patchwork Sun Sep 26 08:33:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: joevt X-Patchwork-Id: 12518075 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E70E9C433EF for ; Sun, 26 Sep 2021 08:33:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D2F6560EE0 for ; Sun, 26 Sep 2021 08:33:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229848AbhIZIfP (ORCPT ); Sun, 26 Sep 2021 04:35:15 -0400 Received: from omta002.cacentral1.a.cloudfilter.net ([3.97.99.33]:46574 "EHLO omta002.cacentral1.a.cloudfilter.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229792AbhIZIfP (ORCPT ); Sun, 26 Sep 2021 04:35:15 -0400 Received: from shw-obgw-4004a.ext.cloudfilter.net ([10.228.9.227]) by cmsmtp with ESMTP id U6LtmGvqUps7PUPbPmzSGu; Sun, 26 Sep 2021 08:33:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=shaw.ca; s=s20180605; t=1632645219; bh=3cO8aUEUL9lEz8fE5BO9cPI0Ktj9+r8/w1I/0NNrbeo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=XolwJR3I1NEV/E2+9xho4gP4+ldHLSoaBO7lE8PGt2+QdK3Kf6kMBFGvH+9pDGXPv O1J6jEyqEHilNMn3BdtnoS3+LZ4Obe/gAQJ1MEOHvFxdGZ5KAjciV+yyybXvwbv/fq of6bdfIgGDmVa1DcY4wYwJ9r3iK++8msT0T/RQLPsgSZTKoXlW8lhoh4argO7zNvhE QkC0hZk6XWReBMdRrELlVIECE7R4rHIoZnpZbLDxEqUj0o59vFNPKpYFLzGy8G8H6b pOQarR3adIOvuOTCGIt2r6mmGHClCOeh1FR1ACkG+oudia4Jt+tIQY+z5NC+SfH1dg o5GsAeqYH7zuA== Received: from shaw.ca ([70.71.78.228]) by cmsmtp with ESMTPA id UPbGmpVUmdCHGUPbOm6iF7; Sun, 26 Sep 2021 08:33:39 +0000 Authentication-Results: ; auth=pass (LOGIN) smtp.auth=joevt@shaw.ca X-Authority-Analysis: v=2.4 cv=SdyUytdu c=1 sm=1 tr=0 ts=61503063 a=qDatE6m/3wxSEG8Wq7h0zQ==:117 a=qDatE6m/3wxSEG8Wq7h0zQ==:17 a=_Dj-zB-qAAAA:8 a=YYI2HF2sYqaqsbPvZ5wA:9 a=c-cOe7UV8MviEfHuAVEQ:22 From: joevt To: Hans Verkuil Cc: linux-media@vger.kernel.org Subject: [PATCH v2 13/29] edid-decode: move unknown block warning Date: Sun, 26 Sep 2021 01:33:14 -0700 Message-Id: <20210926083330.5206-14-joevt@shaw.ca> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210926083330.5206-1-joevt@shaw.ca> References: <20210926083330.5206-1-joevt@shaw.ca> MIME-Version: 1.0 X-CMAE-Envelope: MS4xfLWqyMiRrzWtt7TlSBHSBgadNoiD9KrVh5lYWiIHC8GB8yBvRBun3f4h7+fAqMjsD6DmSET3fH72xTTvWI/t5zIfZl1R3QqerJZkQVRAaw/wp8owNpRD On5ORw4a/Tmvttu+TjzHoXMSjXj5DDhU8MNty2c+CUcl0E1rUG0AnJZO/21yKbqTriBSq4L0X9ZXjRlINovI6DZipnEv26A97z4= Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Also, make cta_block like cta_ext_block First, fix the first switch statement in cta_ext_block. The first switch statement sets or clears data_block (the name of the block which is used in the Warnings and Failures section of the output). Remove hex_block because it will be done by the third switch statement that handles outputting the contents of each block. The "Unknown Extended CTA-861 Data Block 0x%02x.\n" warning now appears after the block name instead of after the block contents (because it's not the contents that caused the error). Then, in cta_block: 1) Create a first switch statement like that of cta_ext_block (described above). The "Unknown CTA-861 Data Block %u.\n" warning now appears after the block name instead of after the block contents (because it's not the contents that caused the error). 2) Create a second switch statement like that of cta_ext_block. It handles checking for duplicate blocks. 3) After checking for duplicates, check cta_byte3 / audio_block discrepancy, exactly like cta_ext_block does. These lines come from after the original switch statement of cta_block. 4) The original switch statement of cta_block has lines that are moved to the new first and second switch statements. Signed-off-by: Joe van Tunen --- parse-cta-block.cpp | 82 +++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 44 deletions(-) diff --git a/parse-cta-block.cpp b/parse-cta-block.cpp index 0000249..3503cd1 100644 --- a/parse-cta-block.cpp +++ b/parse-cta-block.cpp @@ -2068,6 +2068,7 @@ void edid_state::cta_ext_block(unsigned tag, const unsigned char *x, unsigned le case 0x778: data_block = "HDMI Forum EDID Extension Override Data Block"; break; case 0x779: data_block = "HDMI Forum Sink Capability Data Block"; break; default: + data_block.clear(); if (tag < 0x70d) printf(" Unknown CTA-861 Video-Related"); else if (tag < 0x720) @@ -2077,10 +2078,7 @@ void edid_state::cta_ext_block(unsigned tag, const unsigned char *x, unsigned le else printf(" Unknown CTA-861"); printf(" Data Block (extended tag 0x%02x)\n", tag & 0xff); - hex_block(" ", x, length); - data_block.clear(); warn("Unknown Extended CTA-861 Data Block 0x%02x.\n", tag & 0xff); - return; } if (data_block.length()) @@ -2161,7 +2159,6 @@ void edid_state::cta_ext_block(unsigned tag, const unsigned char *x, unsigned le default: hex_block(" ", x, length); } - } void edid_state::cta_block(const unsigned char *x, bool duplicate) @@ -2181,17 +2178,37 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) bool audio_block = false; switch (tag) { - case 0x01: - data_block = "Audio Data Block"; - printf(" %s:\n", data_block.c_str()); - cta_audio_block(x, length); - audio_block = true; - break; - case 0x02: - data_block = "Video Data Block"; + case 0x01: data_block = "Audio Data Block"; audio_block = true; break; + case 0x02: data_block = "Video Data Block"; break; + case 0x03: data_block.clear(); break; + case 0x04: data_block = "Speaker Allocation Data Block"; audio_block = true; break; + case 0x05: data_block = "VESA Display Transfer Characteristics Data Block"; break; + + case 0x07: data_block.clear(); break; + default: + data_block.clear(); + if (extended) break; + printf(" Unknown CTA-861 tag 0x%02x\n", tag); + warn("Unknown CTA-861 Data Block %u.\n", tag); + } + + if (data_block.length()) printf(" %s:\n", data_block.c_str()); - cta_svd(x, length, false); - break; + + switch (tag) { + case 0x04: + case 0x05: + if (duplicate) + fail("Only one instance of this Data Block is allowed.\n"); + } + + // See Table 52 of CTA-861-G for a description of Byte 3 + if (audio_block && !(cta.byte3 & 0x40)) + fail("Audio information is present, but bit 6 of Byte 3 of the CTA-861 Extension header indicates no Basic Audio support.\n"); + + switch (tag) { + case 0x01: cta_audio_block(x, length); break; + case 0x02: cta_svd(x, length, false); break; case 0x03: data_block_o("Vendor-Specific Data Block"); if (oui == 0x000c03) { @@ -2225,42 +2242,19 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) } hex_block(" ", x, length); break; - case 0x04: - data_block = "Speaker Allocation Data Block"; - printf(" %s:\n", data_block.c_str()); - if (duplicate) - fail("Only one instance of this Data Block is allowed.\n"); - cta_sadb(x, length); - audio_block = true; - break; - case 0x05: - data_block = "VESA Display Transfer Characteristics Data Block"; - printf(" %s:\n", data_block.c_str()); - if (duplicate) - fail("Only one instance of this Data Block is allowed.\n"); - cta_vesa_dtcdb(x, length); - break; + case 0x04: cta_sadb(x, length); break; + case 0x05: cta_vesa_dtcdb(x, length); break; case 0x07: - data_block = "Unknown CTA-861 Data Block (extended tag truncated)"; - printf(" %s:\n", data_block.c_str()); + printf(" Unknown CTA-861 Data Block (extended tag truncated):\n"); fail("Extended tag cannot have zero length.\n"); break; - default: { - if (extended) { + default: + if (extended) cta_ext_block(tag, x, length, duplicate); - break; - } - printf(" Unknown CTA-861 tag 0x%02x\n", tag); - hex_block(" ", x, length); - data_block.clear(); - warn("Unknown CTA-861 Data Block %u.\n", tag); - break; - } + else + hex_block(" ", x, length); } - // See Table 52 of CTA-861-G for a description of Byte 3 - if (audio_block && !(cta.byte3 & 0x40)) - fail("Audio information is present, but bit 6 of Byte 3 of the CTA-861 Extension header indicates no Basic Audio support.\n"); cta.first_block = 0; cta.last_block_was_hdmi_vsdb = 0; } From patchwork Sun Sep 26 08:33:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: joevt X-Patchwork-Id: 12518077 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6079C433EF for ; Sun, 26 Sep 2021 08:33:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8E42360F93 for ; Sun, 26 Sep 2021 08:33:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229872AbhIZIfQ (ORCPT ); Sun, 26 Sep 2021 04:35:16 -0400 Received: from omta001.cacentral1.a.cloudfilter.net ([3.97.99.32]:51462 "EHLO omta001.cacentral1.a.cloudfilter.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229839AbhIZIfP (ORCPT ); Sun, 26 Sep 2021 04:35:15 -0400 Received: from shw-obgw-4004a.ext.cloudfilter.net ([10.228.9.227]) by cmsmtp with ESMTP id U8Srmf7IlczbLUPbPmV5UO; Sun, 26 Sep 2021 08:33:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=shaw.ca; s=s20180605; t=1632645219; bh=sbHFubHuQ3iiojuyiXpxmDuwGpNgmWqADL8bV2qEjFc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=QVdO9K17tXvKWlm3t2rKC2P8pQrLTJuN2DviiMldcmlckGEn4alOdtCrVJVKVacTm FdKZldh57zsfaJMgijPHPSBXwJUWcGjaaB7Bedvkitr3Ab7QhfFJzDlt7y/K6vwXjX B6eA1u4jZmqDEUo/fS8ZAdBi/L7LMpE8ch6/lRQ3HSYkBk1U5CLQg9KxQzEzc+hZh+ lgoQAwwxNBj4R7LS3RrXsd9yFOc1ogDxlur1gAG8YnpG0Oo9BlNyYxyDcqOWnVKaUn VbO7Uc3UPVwNUhZfW0uGEcTd9AvMUu/DBGLDndWGh+sc1s04HwtQq7IMVIQWYk5Dtr Q/R5P8xt+kzfw== Received: from shaw.ca ([70.71.78.228]) by cmsmtp with ESMTPA id UPbGmpVUmdCHGUPbPm6iFB; Sun, 26 Sep 2021 08:33:39 +0000 Authentication-Results: ; auth=pass (LOGIN) smtp.auth=joevt@shaw.ca X-Authority-Analysis: v=2.4 cv=SdyUytdu c=1 sm=1 tr=0 ts=61503063 a=qDatE6m/3wxSEG8Wq7h0zQ==:117 a=qDatE6m/3wxSEG8Wq7h0zQ==:17 a=_Dj-zB-qAAAA:8 a=RNklyZuhyY-evRvoHewA:9 a=c-cOe7UV8MviEfHuAVEQ:22 From: joevt To: Hans Verkuil Cc: linux-media@vger.kernel.org Subject: [PATCH v2 14/29] edid-decode: remove cta_ext_block Date: Sun, 26 Sep 2021 01:33:15 -0700 Message-Id: <20210926083330.5206-15-joevt@shaw.ca> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210926083330.5206-1-joevt@shaw.ca> References: <20210926083330.5206-1-joevt@shaw.ca> MIME-Version: 1.0 X-CMAE-Envelope: MS4xfLWqyMiRrzWtt7TlSBHSBgadNoiD9KrVh5lYWiIHC8GB8yBvRBun3f4h7+fAqMjsD6DmSET3fH72xTTvWI/t5zIfZl1R3QqerJZkQVRAaw/wp8owNpRD On5ORw4a/Tmvttu+TjzHoXMSjXj5DDhU8MNty2c+CUcl0E1rUG0AnJZO/21yKbqTriBSq4L0X9ZXjRlINovI6DZipnEv26A97z4= Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Since cta_ext_block is exactly like cta_block now, we can move its code (mostly without modification) to cta_block. This way it's easier to ensure that the blocks are handled consistently (order of statements, including fails, warnings, defaults, etc.) This change should not affect output. Signed-off-by: Joe van Tunen --- edid-decode.h | 1 - parse-cta-block.cpp | 187 +++++++++++++++++++------------------------- 2 files changed, 80 insertions(+), 108 deletions(-) diff --git a/edid-decode.h b/edid-decode.h index 2409718..ccf8558 100644 --- a/edid-decode.h +++ b/edid-decode.h @@ -346,7 +346,6 @@ struct edid_state { void cta_displayid_type_7(const unsigned char *x, unsigned length); void cta_displayid_type_8(const unsigned char *x, unsigned length); void cta_displayid_type_10(const unsigned char *x, unsigned length); - void cta_ext_block(unsigned tag, const unsigned char *x, unsigned length, bool duplicate); void cta_block(const unsigned char *x, bool duplicate); void preparse_cta_block(const unsigned char *x); void parse_cta_block(const unsigned char *x); diff --git a/parse-cta-block.cpp b/parse-cta-block.cpp index 3503cd1..79354c5 100644 --- a/parse-cta-block.cpp +++ b/parse-cta-block.cpp @@ -2034,13 +2034,31 @@ static void cta_hdmi_audio_block(const unsigned char *x, unsigned length) length -= (length < 3) ? length : 3; \ } while(0) -void edid_state::cta_ext_block(unsigned tag, const unsigned char *x, unsigned length, - bool duplicate) +void edid_state::cta_block(const unsigned char *x, bool duplicate) { + unsigned length = x[0] & 0x1f; + unsigned tag=(x[0] & 0xe0) >> 5; + unsigned extended = (tag == 0x07) ? 1 : 0; + x++; + if (extended && length) { + tag <<= 8; + tag |= x[0]; + length--; + x++; + } + unsigned oui; bool audio_block = false; switch (tag) { + case 0x01: data_block = "Audio Data Block"; audio_block = true; break; + case 0x02: data_block = "Video Data Block"; break; + case 0x03: data_block.clear(); break; + case 0x04: data_block = "Speaker Allocation Data Block"; audio_block = true; break; + case 0x05: data_block = "VESA Display Transfer Characteristics Data Block"; break; + + case 0x07: data_block.clear(); break; + case 0x700: data_block = "Video Capability Data Block"; break; case 0x701: data_block.clear(); break; case 0x702: data_block = "VESA Video Display Device Data Block"; break; @@ -2067,24 +2085,33 @@ void edid_state::cta_ext_block(unsigned tag, const unsigned char *x, unsigned le case 0x778: data_block = "HDMI Forum EDID Extension Override Data Block"; break; case 0x779: data_block = "HDMI Forum Sink Capability Data Block"; break; + default: data_block.clear(); - if (tag < 0x70d) - printf(" Unknown CTA-861 Video-Related"); - else if (tag < 0x720) - printf(" Unknown CTA-861 Audio-Related"); - else if (tag >= 0x778 && tag <= 0x77f) - printf(" Unknown CTA-861 HDMI-Related"); - else - printf(" Unknown CTA-861"); - printf(" Data Block (extended tag 0x%02x)\n", tag & 0xff); - warn("Unknown Extended CTA-861 Data Block 0x%02x.\n", tag & 0xff); + if (tag < 0x700) { + printf(" Unknown CTA-861 tag 0x%02x\n", tag); + warn("Unknown CTA-861 Data Block %u.\n", tag); + } + else { + if (tag < 0x70d) + printf(" Unknown CTA-861 Video-Related"); + else if (tag < 0x720) + printf(" Unknown CTA-861 Audio-Related"); + else if (tag >= 0x778 && tag <= 0x77f) + printf(" Unknown CTA-861 HDMI-Related"); + else + printf(" Unknown CTA-861"); + printf(" Data Block (extended tag 0x%02x)\n", tag & 0xff); + warn("Unknown Extended CTA-861 Data Block 0x%02x.\n", tag & 0xff); + } } if (data_block.length()) printf(" %s:\n", data_block.c_str()); switch (tag) { + case 0x04: + case 0x05: case 0x700: case 0x702: case 0x705: @@ -2104,6 +2131,47 @@ void edid_state::cta_ext_block(unsigned tag, const unsigned char *x, unsigned le fail("Audio information is present, but bit 6 of Byte 3 of the CTA-861 Extension header indicates no Basic Audio support.\n"); switch (tag) { + case 0x01: cta_audio_block(x, length); break; + case 0x02: cta_svd(x, length, false); break; + case 0x03: + data_block_o("Vendor-Specific Data Block"); + if (oui == 0x000c03) { + cta_hdmi_block(x, length); + cta.last_block_was_hdmi_vsdb = 1; + cta.first_block = 0; + // The HDMI OUI is present, so this EDID represents an HDMI + // interface. And HDMI interfaces must use EDID version 1.3 + // according to the HDMI Specification, so check for this. + if (base.edid_minor != 3) + fail("The HDMI Specification requires EDID 1.3 instead of 1.%u.\n", + base.edid_minor); + return; + } + if (oui == 0xc45dd8) { + if (!cta.last_block_was_hdmi_vsdb) + fail("HDMI Forum VSDB did not immediately follow the HDMI VSDB.\n"); + if (cta.have_hf_scdb || cta.have_hf_vsdb) + fail("Duplicate HDMI Forum VSDB/SCDB.\n"); + cta_hf_scdb(x, length); + cta.have_hf_vsdb = 1; + break; + } + if (oui == 0x00001a) { + cta_amd(x, length); + break; + } + if (oui == 0xca125c && length == 0x12) { + cta_microsoft(x, length); + break; + } + hex_block(" ", x, length); + break; + case 0x04: cta_sadb(x, length); break; + case 0x05: cta_vesa_dtcdb(x, length); break; + case 0x07: + printf(" Unknown CTA-861 Data Block (extended tag truncated):\n"); + fail("Extended tag cannot have zero length.\n"); + break; case 0x700: cta_vcdb(x, length); break; case 0x701: data_block_o("Vendor-Specific Video Data Block"); @@ -2159,101 +2227,6 @@ void edid_state::cta_ext_block(unsigned tag, const unsigned char *x, unsigned le default: hex_block(" ", x, length); } -} - -void edid_state::cta_block(const unsigned char *x, bool duplicate) -{ - unsigned length = x[0] & 0x1f; - unsigned tag=(x[0] & 0xe0) >> 5; - unsigned extended = (tag == 0x07) ? 1 : 0; - x++; - if (extended && length) { - tag <<= 8; - tag |= x[0]; - length--; - x++; - } - - unsigned oui; - bool audio_block = false; - - switch (tag) { - case 0x01: data_block = "Audio Data Block"; audio_block = true; break; - case 0x02: data_block = "Video Data Block"; break; - case 0x03: data_block.clear(); break; - case 0x04: data_block = "Speaker Allocation Data Block"; audio_block = true; break; - case 0x05: data_block = "VESA Display Transfer Characteristics Data Block"; break; - - case 0x07: data_block.clear(); break; - default: - data_block.clear(); - if (extended) break; - printf(" Unknown CTA-861 tag 0x%02x\n", tag); - warn("Unknown CTA-861 Data Block %u.\n", tag); - } - - if (data_block.length()) - printf(" %s:\n", data_block.c_str()); - - switch (tag) { - case 0x04: - case 0x05: - if (duplicate) - fail("Only one instance of this Data Block is allowed.\n"); - } - - // See Table 52 of CTA-861-G for a description of Byte 3 - if (audio_block && !(cta.byte3 & 0x40)) - fail("Audio information is present, but bit 6 of Byte 3 of the CTA-861 Extension header indicates no Basic Audio support.\n"); - - switch (tag) { - case 0x01: cta_audio_block(x, length); break; - case 0x02: cta_svd(x, length, false); break; - case 0x03: - data_block_o("Vendor-Specific Data Block"); - if (oui == 0x000c03) { - cta_hdmi_block(x, length); - cta.last_block_was_hdmi_vsdb = 1; - cta.first_block = 0; - // The HDMI OUI is present, so this EDID represents an HDMI - // interface. And HDMI interfaces must use EDID version 1.3 - // according to the HDMI Specification, so check for this. - if (base.edid_minor != 3) - fail("The HDMI Specification requires EDID 1.3 instead of 1.%u.\n", - base.edid_minor); - return; - } - if (oui == 0xc45dd8) { - if (!cta.last_block_was_hdmi_vsdb) - fail("HDMI Forum VSDB did not immediately follow the HDMI VSDB.\n"); - if (cta.have_hf_scdb || cta.have_hf_vsdb) - fail("Duplicate HDMI Forum VSDB/SCDB.\n"); - cta_hf_scdb(x, length); - cta.have_hf_vsdb = 1; - break; - } - if (oui == 0x00001a) { - cta_amd(x, length); - break; - } - if (oui == 0xca125c && length == 0x12) { - cta_microsoft(x, length); - break; - } - hex_block(" ", x, length); - break; - case 0x04: cta_sadb(x, length); break; - case 0x05: cta_vesa_dtcdb(x, length); break; - case 0x07: - printf(" Unknown CTA-861 Data Block (extended tag truncated):\n"); - fail("Extended tag cannot have zero length.\n"); - break; - default: - if (extended) - cta_ext_block(tag, x, length, duplicate); - else - hex_block(" ", x, length); - } cta.first_block = 0; cta.last_block_was_hdmi_vsdb = 0; From patchwork Sun Sep 26 08:33:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: joevt X-Patchwork-Id: 12518079 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8DCDCC433F5 for ; Sun, 26 Sep 2021 08:33:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 796A460F11 for ; Sun, 26 Sep 2021 08:33:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229907AbhIZIfU (ORCPT ); Sun, 26 Sep 2021 04:35:20 -0400 Received: from omta001.cacentral1.a.cloudfilter.net ([3.97.99.32]:37615 "EHLO omta001.cacentral1.a.cloudfilter.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229792AbhIZIfQ (ORCPT ); Sun, 26 Sep 2021 04:35:16 -0400 Received: from shw-obgw-4004a.ext.cloudfilter.net ([10.228.9.227]) by cmsmtp with ESMTP id UHFtmfkKBczbLUPbQmV5UQ; Sun, 26 Sep 2021 08:33:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=shaw.ca; s=s20180605; t=1632645220; bh=cPwxdcMYDI5ANmgFFYWlf5yKBD/eeVh9Lbci7WuurOg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=J2mx2PXEGQmSanW68D8SRgiWMAXnUT95mwcbDIJK4zE35B8bgyayPK2lDABCaCCWD 1QRhyl3Lm1x8V+VRsOrxLKSZvOUgMBDhARXYY5ot0FXlBZ3HQW2haqRCByKLgtBOUi 22NvvfWxkdE8EvH+iPawJSc0dSnxKngOyn1uRKDm4UnDgia0yWtSBJUUDuuICL+KQi 8g4KKGZkAy7uDlcwuWlc7q/ZOnQsgXzOsVnzDEySoW9HIIVl/W7j5fssRYF8VZlz3D JAaRoOev5mTc7yNUm+yqnsWKhL5Hu22aq31ht8BwS3I62hv4wWWgxALvO1OskAi+3T TR2/+lB8suL8g== Received: from shaw.ca ([70.71.78.228]) by cmsmtp with ESMTPA id UPbGmpVUmdCHGUPbPm6iFE; Sun, 26 Sep 2021 08:33:40 +0000 Authentication-Results: ; auth=pass (LOGIN) smtp.auth=joevt@shaw.ca X-Authority-Analysis: v=2.4 cv=SdyUytdu c=1 sm=1 tr=0 ts=61503064 a=qDatE6m/3wxSEG8Wq7h0zQ==:117 a=qDatE6m/3wxSEG8Wq7h0zQ==:17 a=_Dj-zB-qAAAA:8 a=E4F5njE0240e4IrhLHkA:9 a=c-cOe7UV8MviEfHuAVEQ:22 From: joevt To: Hans Verkuil Cc: linux-media@vger.kernel.org Subject: [PATCH v2 15/29] edid-decode: change unknown CTA block names Date: Sun, 26 Sep 2021 01:33:16 -0700 Message-Id: <20210926083330.5206-16-joevt@shaw.ca> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210926083330.5206-1-joevt@shaw.ca> References: <20210926083330.5206-1-joevt@shaw.ca> MIME-Version: 1.0 X-CMAE-Envelope: MS4xfIKedk/vO9v2MlsS9rBm6JDEQFBBPVGfN3SYJRLjTpZqjbx2srqQbtioKjSnrTi470QZWnyj4qmDQlCYgWoiOz++yWJeTPfQGgsGeEtg+SrHcAdgzCYM ZedvgP+Ej+88skuRaDX4/ccZmJL53ZH07G7oasjbIts5Hp7W6sg8PUrJ8MHX5spbRwTzG2RH4LYs5PRGANHHFjufJ1jG+bMLC6U= Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Make consistent the Unknown CTA-861 Data Block names and warnings. - Add " Data Block" suffix for normal tags (like unknown extended tags and known normal tags have). - Put tag in parenthesis (like unknown extended tags). - Output colon after unknown block name (like known tags). - Make warning same as block name (so the block mentioned in the warning section can be found more easily in the edid output). 1) Unknown normal tags: Before: - name: "Unknown CTA-861 tag 0x$$" - warning: "Unknown CTA-861 Data Block #." After: "Unknown CTA-861 Data Block (tag 0x$$):" (with period instead of colon for warning) 2) Unknown extended tags: Before: - name: "Unknown CTA-861 @Data Block (extended tag 0x$$)" (@ = "", "Video-Related ", "Audio-Related ", "HDMI-Related ") - warning: "Unknown Extended CTA-861 Data Block 0x$$." After: - "Unknown CTA-861 @Data Block (extended tag 0x$$):" (with period instead of colon for warning) We still have the following from a previous commit: 3) Truncated extended tag (when length is not enough to get the extended tag): Before: name: "Unknown CTA-861 Data Block (extended tag truncated):" failure: "Extended tag cannot have zero length." Since the name is different than the failure message, we should set data_block so both are output to the failure section: After: failure: "Unknown CTA-861 Data Block (extended tag truncated): Extended tag cannot have zero length." Signed-off-by: Joe van Tunen --- parse-cta-block.cpp | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/parse-cta-block.cpp b/parse-cta-block.cpp index 79354c5..16c7bee 100644 --- a/parse-cta-block.cpp +++ b/parse-cta-block.cpp @@ -2057,7 +2057,7 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) case 0x04: data_block = "Speaker Allocation Data Block"; audio_block = true; break; case 0x05: data_block = "VESA Display Transfer Characteristics Data Block"; break; - case 0x07: data_block.clear(); break; + case 0x07: data_block = "Unknown CTA-861 Data Block (extended tag truncated)"; break; case 0x700: data_block = "Video Capability Data Block"; break; case 0x701: data_block.clear(); break; @@ -2088,22 +2088,16 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) default: data_block.clear(); - if (tag < 0x700) { - printf(" Unknown CTA-861 tag 0x%02x\n", tag); - warn("Unknown CTA-861 Data Block %u.\n", tag); - } - else { - if (tag < 0x70d) - printf(" Unknown CTA-861 Video-Related"); - else if (tag < 0x720) - printf(" Unknown CTA-861 Audio-Related"); - else if (tag >= 0x778 && tag <= 0x77f) - printf(" Unknown CTA-861 HDMI-Related"); - else - printf(" Unknown CTA-861"); - printf(" Data Block (extended tag 0x%02x)\n", tag & 0xff); - warn("Unknown Extended CTA-861 Data Block 0x%02x.\n", tag & 0xff); - } + std::string unknown_name; + if (tag < 0x700) unknown_name = "Unknown CTA-861 Data Block"; + else if (tag < 0x70d) unknown_name = "Unknown CTA-861 Video-Related Data Block"; + else if (tag < 0x720) unknown_name = "Unknown CTA-861 Audio-Related Data Block"; + else if (tag < 0x778) unknown_name = "Unknown CTA-861 Data Block"; + else if (tag < 0x780) unknown_name = "Unknown CTA-861 HDMI-Related Data Block"; + else unknown_name = "Unknown CTA-861 Data Block"; + unknown_name += std::string(" (") + (extended ? "extended " : "") + "tag " + utohex(tag & 0xff) + ")"; + printf(" %s:\n", unknown_name.c_str()); + warn("%s.\n", unknown_name.c_str()); } if (data_block.length()) @@ -2168,10 +2162,7 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) break; case 0x04: cta_sadb(x, length); break; case 0x05: cta_vesa_dtcdb(x, length); break; - case 0x07: - printf(" Unknown CTA-861 Data Block (extended tag truncated):\n"); - fail("Extended tag cannot have zero length.\n"); - break; + case 0x07: fail("Extended tag cannot have zero length.\n"); break; case 0x700: cta_vcdb(x, length); break; case 0x701: data_block_o("Vendor-Specific Video Data Block"); From patchwork Sun Sep 26 08:33:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: joevt X-Patchwork-Id: 12518083 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B7BEC4332F for ; Sun, 26 Sep 2021 08:33:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 039FE60EE0 for ; Sun, 26 Sep 2021 08:33:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229916AbhIZIfV (ORCPT ); Sun, 26 Sep 2021 04:35:21 -0400 Received: from omta001.cacentral1.a.cloudfilter.net ([3.97.99.32]:43776 "EHLO omta001.cacentral1.a.cloudfilter.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229874AbhIZIfR (ORCPT ); Sun, 26 Sep 2021 04:35:17 -0400 Received: from shw-obgw-4004a.ext.cloudfilter.net ([10.228.9.227]) by cmsmtp with ESMTP id UEfnmfZ1KczbLUPbQmV5US; Sun, 26 Sep 2021 08:33:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=shaw.ca; s=s20180605; t=1632645220; bh=iUUkQmnDGHZ1jEllC8QPebZ4N2NNK/S5fqHXV1yws74=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=waoh2n/Um7D9b+K55E/jMh4FMKh63l5XwYGsiJ8Jnhtux0nr+4S5GMsotrrga+Lw4 cA4edDCkb73a3sgvO7zBvn5BhhqZgwDWMZ92cxgQ8fwfU/SS6dzHaH56Iy1IdV4PvE jTk/zJzGQ1fxmacYyIJgbOStjLdEi3htzN3ViouL31clIu3ktFE42qcmSZqT78QLBG OY5vKckXqJfiF1FNTC9IVwaJ7TztxfQw9XFIyHXA6KY43v2HAvjap20/ECE26XwXCO kwq/w/3lrGmXtEJ1pqY3h0EoHSrxsxb2ICwz+f/pmO18artrAtMSG0OYhf18eXHnza cxaq1HrVpzR/w== Received: from shaw.ca ([70.71.78.228]) by cmsmtp with ESMTPA id UPbGmpVUmdCHGUPbQm6iFH; Sun, 26 Sep 2021 08:33:40 +0000 Authentication-Results: ; auth=pass (LOGIN) smtp.auth=joevt@shaw.ca X-Authority-Analysis: v=2.4 cv=SdyUytdu c=1 sm=1 tr=0 ts=61503064 a=qDatE6m/3wxSEG8Wq7h0zQ==:117 a=qDatE6m/3wxSEG8Wq7h0zQ==:17 a=_Dj-zB-qAAAA:8 a=iaj4zWktxohYcnrZrbkA:9 a=c-cOe7UV8MviEfHuAVEQ:22 From: joevt To: Hans Verkuil Cc: linux-media@vger.kernel.org Subject: [PATCH v2 16/29] edid-decode: move audio fail/warn messages Date: Sun, 26 Sep 2021 01:33:17 -0700 Message-Id: <20210926083330.5206-17-joevt@shaw.ca> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210926083330.5206-1-joevt@shaw.ca> References: <20210926083330.5206-1-joevt@shaw.ca> MIME-Version: 1.0 X-CMAE-Envelope: MS4xfIKedk/vO9v2MlsS9rBm6JDEQFBBPVGfN3SYJRLjTpZqjbx2srqQbtioKjSnrTi470QZWnyj4qmDQlCYgWoiOz++yWJeTPfQGgsGeEtg+SrHcAdgzCYM ZedvgP+Ej+88skuRaDX4/ccZmJL53ZH07G7oasjbIts5Hp7W6sg8PUrJ8MHX5spbRwTzG2RH4LYs5PRGANHHFjufJ1jG+bMLC6U= Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org For tag 0x711, the "Audio information is present" fail message appears before the block name. Output the block name before any fail/warning messages related to the block. For tags that are supposed to have an OUI but are not long enough: - Output the block name before the "Invalid length" fail message. The fail message should include the block name but we don't want cta_block to output data_block so clear it after the fail, before exiting. For tags with a 3 byte OUI: - Since we are calling data_block_oui early (before data_block is output in cta_block), don't output block name in data_block_oui - cta_block will do that for us. - data_block now includes the OUI (the block name in the failure/warning section will match block name in the EDID section). Probably things would be simpler if we always set data_block to the block name, then have fail/warning messages that don't include the block name so they don't look redundant in the failures/warnings sections. For example we could have something like: Unknown CTA-861 Data Block (tag 0x00): Invalid tag. Vendor-Specific Data Block, OUI $$-$$-$$: Unknown OUI. etc. Sample corrupted EDID (combination of vizio-e65e0-hdmi and /System/Library/Displays/Contents/Resources/Overrides/DisplayVendorID-593a/DisplayProductID-1018:edid-patches): 00ffffffffffff00593a181001010101001a0103808f50782a6a6da4554f9e270e474aa5ce00d1c0010101010101010101010101010104740030f2705a80b0588a0048684200001e023a801871382d40582c450048684200001e000000fc004536352d45310a202020202020000000fd00174c0f8c26000a202020202020014502035171575f645d625e631022201f2105041307060302111215160132570600000000000000000000090707150750830100006f030c002000383ca05b5b0060010000000061666065e3060f01e305e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ea Signed-off-by: Joe van Tunen --- edid-decode.cpp | 6 +++--- parse-cta-block.cpp | 11 ++++------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/edid-decode.cpp b/edid-decode.cpp index ec903f9..666a2c6 100644 --- a/edid-decode.cpp +++ b/edid-decode.cpp @@ -686,12 +686,13 @@ void edid_state::data_block_oui(const char *block_name, const unsigned char *x, bool reverse = false; if (length < 3) { + printf(" %s:\n", block_name); data_block = std::string(block_name); fail("Invalid length %u < 3.\n", length); + data_block.clear(); } else { oui = (x[2] << 16) + (x[1] << 8) + x[0]; - x += 3; length -=3; name = oui_name(oui); if (!name) { name = oui_name(oui, true); @@ -704,10 +705,9 @@ void edid_state::data_block_oui(const char *block_name, const unsigned char *x, warn("Unknown %s, OUI %s.\n", block_name, ouitohex(oui).c_str()); } else { - data_block = std::string(block_name) + " (" + name + ")"; + data_block = std::string(block_name) + " (" + name + "), OUI " + ouitohex(oui); if (reverse) fail((std::string("OUI ") + ouitohex(oui) + " is in the wrong byte order\n").c_str()); - printf(" %s, OUI %s:\n", data_block.c_str(), ouitohex(oui).c_str()); } } if (ouinum) *ouinum = oui; diff --git a/parse-cta-block.cpp b/parse-cta-block.cpp index 16c7bee..607e42b 100644 --- a/parse-cta-block.cpp +++ b/parse-cta-block.cpp @@ -2049,18 +2049,19 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) unsigned oui; bool audio_block = false; + data_block.clear(); switch (tag) { case 0x01: data_block = "Audio Data Block"; audio_block = true; break; case 0x02: data_block = "Video Data Block"; break; - case 0x03: data_block.clear(); break; + case 0x03: data_block_o("Vendor-Specific Data Block"); break; case 0x04: data_block = "Speaker Allocation Data Block"; audio_block = true; break; case 0x05: data_block = "VESA Display Transfer Characteristics Data Block"; break; case 0x07: data_block = "Unknown CTA-861 Data Block (extended tag truncated)"; break; case 0x700: data_block = "Video Capability Data Block"; break; - case 0x701: data_block.clear(); break; + case 0x701: data_block_o("Vendor-Specific Video Data Block"); break; case 0x702: data_block = "VESA Video Display Device Data Block"; break; case 0x703: data_block = "VESA Video Timing Block Extension"; break; case 0x704: data_block = "Reserved for HDMI Video Data Block"; break; @@ -2072,7 +2073,7 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) case 0x70e: data_block = "YCbCr 4:2:0 Video Data Block"; break; case 0x70f: data_block = "YCbCr 4:2:0 Capability Map Data Block"; break; case 0x710: data_block = "Reserved for CTA-861 Miscellaneous Audio Fields"; break; - case 0x711: data_block.clear(); audio_block = true; break; + case 0x711: data_block_o("Vendor-Specific Audio Data Block"); audio_block = true; break; case 0x712: data_block = "HDMI Audio Data Block"; audio_block = true; break; case 0x713: data_block = "Room Configuration Data Block"; audio_block = true; break; case 0x714: data_block = "Speaker Location Data Block"; audio_block = true; break; @@ -2087,7 +2088,6 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) case 0x779: data_block = "HDMI Forum Sink Capability Data Block"; break; default: - data_block.clear(); std::string unknown_name; if (tag < 0x700) unknown_name = "Unknown CTA-861 Data Block"; else if (tag < 0x70d) unknown_name = "Unknown CTA-861 Video-Related Data Block"; @@ -2128,7 +2128,6 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) case 0x01: cta_audio_block(x, length); break; case 0x02: cta_svd(x, length, false); break; case 0x03: - data_block_o("Vendor-Specific Data Block"); if (oui == 0x000c03) { cta_hdmi_block(x, length); cta.last_block_was_hdmi_vsdb = 1; @@ -2165,7 +2164,6 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) case 0x07: fail("Extended tag cannot have zero length.\n"); break; case 0x700: cta_vcdb(x, length); break; case 0x701: - data_block_o("Vendor-Specific Video Data Block"); if (oui == 0x90848b) cta_hdr10plus(x, length); else if (oui == 0x00d046) @@ -2181,7 +2179,6 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) case 0x70e: cta_svd(x, length, true); break; case 0x70f: cta_y420cmdb(x, length); break; case 0x711: - data_block_o("Vendor-Specific Audio Data Block"); if (oui == 0x00d046) cta_dolby_audio(x, length); else From patchwork Sun Sep 26 08:33:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: joevt X-Patchwork-Id: 12518081 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2383C43217 for ; Sun, 26 Sep 2021 08:33:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9AA7860EE0 for ; Sun, 26 Sep 2021 08:33:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229918AbhIZIfV (ORCPT ); Sun, 26 Sep 2021 04:35:21 -0400 Received: from omta001.cacentral1.a.cloudfilter.net ([3.97.99.32]:51462 "EHLO omta001.cacentral1.a.cloudfilter.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229876AbhIZIfU (ORCPT ); Sun, 26 Sep 2021 04:35:20 -0400 Received: from shw-obgw-4004a.ext.cloudfilter.net ([10.228.9.227]) by cmsmtp with ESMTP id U8Srmf7ImczbLUPbRmV5UV; Sun, 26 Sep 2021 08:33:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=shaw.ca; s=s20180605; t=1632645221; bh=X+ZNxfdytYuQ+kOgdpzqONaAfXCrd1KgFpphs3NQJP8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FjrtBDog0QxVw0H+JmcZo1mYK7LE78wxT2Bw1A27Psa0U+orkMR5IzHKXHsGKVyX5 LjBrnASbvEhkJXShroabKmMz4IuUHXy0wrW7yuoavV8LwUuIbpvxbsIv28KHz4UARQ +JMKads/BSaEK5y6Qu3bAjbS1LcgNEHKAmLHkEL1W3YHBw/X4z5WUo9qNURdX/Xnh6 tdPQwaqvWnNcj1wsNc7/y44X2IfQnqhVu/Y0Lnn9FCbcfA2pI9nTBO8FtAsQhpA1xu 1kSbfPLQBxlydu5SZu3K4MZGZOa8LKOzH9tyJjKtPsVv4VGXz6KickIz/hL6I5AZwL 2FTHP63KnmQow== Received: from shaw.ca ([70.71.78.228]) by cmsmtp with ESMTPA id UPbGmpVUmdCHGUPbQm6iFL; Sun, 26 Sep 2021 08:33:41 +0000 Authentication-Results: ; auth=pass (LOGIN) smtp.auth=joevt@shaw.ca X-Authority-Analysis: v=2.4 cv=SdyUytdu c=1 sm=1 tr=0 ts=61503065 a=qDatE6m/3wxSEG8Wq7h0zQ==:117 a=qDatE6m/3wxSEG8Wq7h0zQ==:17 a=_Dj-zB-qAAAA:8 a=Kq4NL1YokvzOOEXvYrsA:9 a=c-cOe7UV8MviEfHuAVEQ:22 From: joevt To: Hans Verkuil Cc: linux-media@vger.kernel.org Subject: [PATCH v2 17/29] edid-decode: replace first_block with block_number Date: Sun, 26 Sep 2021 01:33:18 -0700 Message-Id: <20210926083330.5206-18-joevt@shaw.ca> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210926083330.5206-1-joevt@shaw.ca> References: <20210926083330.5206-1-joevt@shaw.ca> MIME-Version: 1.0 X-CMAE-Envelope: MS4xfGWXBY4HvalrRx/3DaJvAGBBeTSVFDda6tc4rcB80y3y6T1C4yyoE9uROdofOyHrUP1OnGZqSYavEPTHEUUqpyL7Qw59Q+VBuzgMostAsbRCXk651a4b b6dBlsTsmtihdblvjJ+XMS5hLiayLoTIJE0HmaqWTbldUVK+KARyuPRZxqOsSe55AzSKJ4OaymBISk/QCClR46HlIYSBiSzjGZw= Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org track progress instead of milestones. With a flag like first_block, you can only know if you're at the first block or not. But with a progressing value like block_number, you can know when you're at the first block or second block etc. and you can know how many blocks have been done. We'll also replace last_block_was_hdmi_vsdb in a later commit. Both of these changes will cleanup the hdmi block. Signed-off-by: Joe van Tunen --- edid-decode.h | 5 +++-- parse-cta-block.cpp | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/edid-decode.h b/edid-decode.h index ccf8558..dbc00c2 100644 --- a/edid-decode.h +++ b/edid-decode.h @@ -154,7 +154,8 @@ struct edid_state { cta.has_vic_1 = cta.first_svd_might_be_preferred = cta.has_sldb = cta.has_hdmi = cta.has_vcdb = cta.has_vfpdb = false; cta.last_block_was_hdmi_vsdb = cta.have_hf_vsdb = cta.have_hf_scdb = false; - cta.first_block = cta.first_svd = true; + cta.block_number = 0; + cta.first_svd = true; cta.supported_hdmi_vic_codes = cta.supported_hdmi_vic_vsb_codes = 0; memset(cta.vics, 0, sizeof(cta.vics)); memset(cta.preparsed_has_vic, 0, sizeof(cta.preparsed_has_vic)); @@ -259,7 +260,7 @@ struct edid_state { unsigned short preparsed_phys_addr; bool last_block_was_hdmi_vsdb; bool have_hf_vsdb, have_hf_scdb; - bool first_block; + unsigned block_number; bool first_svd; unsigned supported_hdmi_vic_codes; unsigned supported_hdmi_vic_vsb_codes; diff --git a/parse-cta-block.cpp b/parse-cta-block.cpp index 607e42b..13b3b73 100644 --- a/parse-cta-block.cpp +++ b/parse-cta-block.cpp @@ -2131,7 +2131,7 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) if (oui == 0x000c03) { cta_hdmi_block(x, length); cta.last_block_was_hdmi_vsdb = 1; - cta.first_block = 0; + cta.block_number++; // The HDMI OUI is present, so this EDID represents an HDMI // interface. And HDMI interfaces must use EDID version 1.3 // according to the HDMI Specification, so check for this. @@ -2194,7 +2194,7 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) case 0x778: cta_hf_eeodb(x, length); // This must be the first CTA-861 block - if (!cta.first_block) + if (cta.block_number > 0) fail("Block starts at a wrong offset.\n"); break; case 0x779: @@ -2216,7 +2216,7 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) hex_block(" ", x, length); } - cta.first_block = 0; + cta.block_number++; cta.last_block_was_hdmi_vsdb = 0; } @@ -2333,11 +2333,11 @@ void edid_state::parse_cta_block(const unsigned char *x) // msg(!cta.has_hdmi, "If YCbCr support is indicated, then both 4:2:2 and 4:4:4 %s be supported.\n", // cta.has_hdmi ? "shall" : "should"); printf(" Native detailed modes: %u\n", x[3] & 0x0f); - if (cta.first_block) + if (cta.block_number == 0) cta.byte3 = x[3]; else if (x[3] != cta.byte3) fail("Byte 3 must be the same for all CTA-861 Extension Blocks.\n"); - if (cta.first_block) { + if (cta.block_number == 0) { unsigned native_dtds = x[3] & 0x0f; cta.native_timings.clear(); From patchwork Sun Sep 26 08:33:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: joevt X-Patchwork-Id: 12518085 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F7F1C433FE for ; Sun, 26 Sep 2021 08:33:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 58CB360EE0 for ; Sun, 26 Sep 2021 08:33:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229922AbhIZIfW (ORCPT ); Sun, 26 Sep 2021 04:35:22 -0400 Received: from omta002.cacentral1.a.cloudfilter.net ([3.97.99.33]:39161 "EHLO omta002.cacentral1.a.cloudfilter.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229894AbhIZIfU (ORCPT ); Sun, 26 Sep 2021 04:35:20 -0400 Received: from shw-obgw-4004a.ext.cloudfilter.net ([10.228.9.227]) by cmsmtp with ESMTP id U6LtmGvqUps7PUPbRmzSH3; Sun, 26 Sep 2021 08:33:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=shaw.ca; s=s20180605; t=1632645222; bh=57g/H0MT18mIwqR5ZwRAz2ZlA/WoXz3S0mUHsZqXyRk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=BMgPO+Jf5D+aj045+ywocMf//gIIEzKhNwLM5TwQSHh1lNtmCO9j0D/hIWVJYHOD+ O4ZWMbt4Kbey8YfTzB6wqugeGLeH0rmwGVtVkDP4f4weYOAkxZUAcxPoy+cPf0YgJB 56DxuaQNeR7p2BppsQWNrHuha0+E7YaMJlD+JyBxwyGe4A44kzKtxaD8HGnhWJRpLA lYAYHUZVMOTe+HQ4jaWFu6r35J1NHpafx1mbzvfxk1SSyaiK1IsTwjvW3i2nr73qLs 18tDS21Gcj1Hug4RyIbQoIOlVoam7Yh4+pA6yVKwHJJB/n8FtSQs7TlDFrwYSbxUun rk2hPbqKV2Syw== Received: from shaw.ca ([70.71.78.228]) by cmsmtp with ESMTPA id UPbGmpVUmdCHGUPbRm6iFN; Sun, 26 Sep 2021 08:33:41 +0000 Authentication-Results: ; auth=pass (LOGIN) smtp.auth=joevt@shaw.ca X-Authority-Analysis: v=2.4 cv=SdyUytdu c=1 sm=1 tr=0 ts=61503065 a=qDatE6m/3wxSEG8Wq7h0zQ==:117 a=qDatE6m/3wxSEG8Wq7h0zQ==:17 a=_Dj-zB-qAAAA:8 a=wA_Q9vgazLIMpfE_LfMA:9 a=c-cOe7UV8MviEfHuAVEQ:22 From: joevt To: Hans Verkuil Cc: linux-media@vger.kernel.org Subject: [PATCH v2 18/29] edid-decode: move parse_displayid_block inner loop Date: Sun, 26 Sep 2021 01:33:19 -0700 Message-Id: <20210926083330.5206-19-joevt@shaw.ca> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210926083330.5206-1-joevt@shaw.ca> References: <20210926083330.5206-1-joevt@shaw.ca> MIME-Version: 1.0 X-CMAE-Envelope: MS4xfGWXBY4HvalrRx/3DaJvAGBBeTSVFDda6tc4rcB80y3y6T1C4yyoE9uROdofOyHrUP1OnGZqSYavEPTHEUUqpyL7Qw59Q+VBuzgMostAsbRCXk651a4b b6dBlsTsmtihdblvjJ+XMS5hLiayLoTIJE0HmaqWTbldUVK+KARyuPRZxqOsSe55AzSKJ4OaymBISk/QCClR46HlIYSBiSzjGZw= Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Move it to a new function displayid_block. Then we can simplify it later. This is mostly just a copy/paste. No output should change. The new function returns 0xff for len to signal a break from the loop in parse_displayid_block. That will be cleaned up later. first_data_block is replaced with dispid.block_number (similar to cta.block_number) Signed-off-by: Joe van Tunen --- edid-decode.h | 3 ++ parse-displayid-block.cpp | 95 +++++++++++++++++++++------------------ 2 files changed, 54 insertions(+), 44 deletions(-) diff --git a/edid-decode.h b/edid-decode.h index dbc00c2..4636978 100644 --- a/edid-decode.h +++ b/edid-decode.h @@ -176,6 +176,7 @@ struct edid_state { dispid.is_display = dispid.has_product_identification = dispid.has_display_parameters = dispid.has_type_1_7 = dispid.has_display_interface_features = false; + dispid.block_number = 0; // Block Map block state block_map.saw_block_1 = false; @@ -283,6 +284,7 @@ struct edid_state { bool has_display_interface_features; vec_timings_ext preferred_timings; unsigned native_width, native_height; + unsigned block_number; // Keep track of the found CTA-861 Tag/Extended Tag pairs. // The unsigned value is equal to: (tag << 8) | ext_tag std::set found_tags; @@ -393,6 +395,7 @@ struct edid_state { void parse_displayid_type_10_timing(const unsigned char *x, unsigned sz, bool is_cta = false); void preparse_displayid_block(const unsigned char *x); + unsigned displayid_block(const unsigned version, const unsigned char *x, unsigned offset, unsigned length); void parse_displayid_block(const unsigned char *x); void parse_displayid_vesa(const unsigned char *x); void parse_displayid_cta_data_block(const unsigned char *x); diff --git a/parse-displayid-block.cpp b/parse-displayid-block.cpp index e4c3bff..0a996bd 100644 --- a/parse-displayid-block.cpp +++ b/parse-displayid-block.cpp @@ -1651,47 +1651,9 @@ void edid_state::preparse_displayid_block(const unsigned char *x) } } -void edid_state::parse_displayid_block(const unsigned char *x) +unsigned edid_state::displayid_block(const unsigned version, const unsigned char *x, unsigned offset, unsigned length) { - unsigned version = x[1]; - unsigned length = x[2]; - unsigned prod_type = x[3]; // future check: based on type, check for required data blocks - unsigned ext_count = x[4]; unsigned i; - - printf(" Version: %u.%u\n Extension Count: %u\n", - version >> 4, version & 0xf, ext_count); - - if (dispid.is_base_block) { - dispid.version = version; - printf(" %s: %s\n", product_type(prod_type, true).c_str(), - product_type(prod_type, false).c_str()); - if (!prod_type) - fail("DisplayID Base Block has no product type.\n"); - if (ext_count != dispid.preparsed_displayid_blocks - 1) - fail("Expected %u DisplayID Extension Block%s, but got %u.\n", - ext_count, - ext_count > 1 ? "s" : "", - dispid.preparsed_displayid_blocks - 1); - } else { - if (prod_type) - fail("Product Type should be 0 in extension block.\n"); - if (ext_count) - fail("Extension Count should be 0 in extension block.\n"); - if (version != dispid.version) - fail("Got version %u.%u, expected %u.%u.\n", - version >> 4, version & 0xf, - dispid.version >> 4, dispid.version & 0xf); - } - - if (length > 121) { - fail("DisplayID length %d is greater than 121.\n", length); - length = 121; - } - - unsigned offset = 5; - bool first_data_block = true; - while (length > 0) { unsigned tag = x[offset]; unsigned oui = 0; @@ -1773,7 +1735,7 @@ void edid_state::parse_displayid_block(const unsigned char *x) if (tag || x[offset + 1]) { fail("Not enough bytes remain (%d) for a DisplayID data block or the DisplayID filler is non-0.\n", length); } - break; + return 0xff; } unsigned block_rev = x[offset + 1] & 0x07; @@ -1781,7 +1743,7 @@ void edid_state::parse_displayid_block(const unsigned char *x) if (length < len + 3) { fail("The length of this DisplayID data block (%d) exceeds the number of bytes remaining (%d).\n", len + 3, length); - break; + return 0xff; } if (!tag && !len) { @@ -1789,7 +1751,7 @@ void edid_state::parse_displayid_block(const unsigned char *x) if (!memchk(x + offset, length)) { fail("Non-0 filler bytes in the DisplayID block.\n"); } - break; + return 0xff; } printf(" %s:\n", data_block.c_str()); @@ -1925,12 +1887,57 @@ void edid_state::parse_displayid_block(const unsigned char *x) } if ((tag == 0x00 || tag == 0x20) && - (!dispid.is_base_block || !first_data_block)) + (!dispid.is_base_block || dispid.block_number > 0)) fail("%s is required to be the first DisplayID Data Block.\n", data_block.c_str()); + + dispid.block_number++; + return len; +} + +void edid_state::parse_displayid_block(const unsigned char *x) +{ + unsigned version = x[1]; + unsigned length = x[2]; + unsigned prod_type = x[3]; // future check: based on type, check for required data blocks + unsigned ext_count = x[4]; + + printf(" Version: %u.%u\n Extension Count: %u\n", + version >> 4, version & 0xf, ext_count); + + if (dispid.is_base_block) { + dispid.version = version; + printf(" %s: %s\n", product_type(prod_type, true).c_str(), + product_type(prod_type, false).c_str()); + if (!prod_type) + fail("DisplayID Base Block has no product type.\n"); + if (ext_count != dispid.preparsed_displayid_blocks - 1) + fail("Expected %u DisplayID Extension Block%s, but got %u.\n", + ext_count, + ext_count > 1 ? "s" : "", + dispid.preparsed_displayid_blocks - 1); + } else { + if (prod_type) + fail("Product Type should be 0 in extension block.\n"); + if (ext_count) + fail("Extension Count should be 0 in extension block.\n"); + if (version != dispid.version) + fail("Got version %u.%u, expected %u.%u.\n", + version >> 4, version & 0xf, + dispid.version >> 4, dispid.version & 0xf); + } + + if (length > 121) { + fail("DisplayID length %d is greater than 121.\n", length); + length = 121; + } + + unsigned offset = 5; + while (length > 0) { + unsigned len = displayid_block(version, x, offset, length); + if (len == 0xff) break; length -= len + 3; offset += len + 3; - first_data_block = false; } /* From patchwork Sun Sep 26 08:33:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: joevt X-Patchwork-Id: 12518087 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE7DEC433F5 for ; Sun, 26 Sep 2021 08:33:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BA69460F11 for ; Sun, 26 Sep 2021 08:33:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229924AbhIZIfW (ORCPT ); Sun, 26 Sep 2021 04:35:22 -0400 Received: from omta001.cacentral1.a.cloudfilter.net ([3.97.99.32]:37615 "EHLO omta001.cacentral1.a.cloudfilter.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229906AbhIZIfU (ORCPT ); Sun, 26 Sep 2021 04:35:20 -0400 Received: from shw-obgw-4004a.ext.cloudfilter.net ([10.228.9.227]) by cmsmtp with ESMTP id UP1ZmgGnWczbLUPbSmV5UW; Sun, 26 Sep 2021 08:33:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=shaw.ca; s=s20180605; t=1632645222; bh=KrtvXEboYOGDEsNsPOIjz4HW6i6GSAhJ7rJp5dws268=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=m7zq/8rTtWVQXRLHDbKND9LawrCR80zNXhKrv+ackzSfn/uEG7vvOvBZhqaQ7qHmA TVd3+pkogDZOSC92luM5EB3kbrmdRmuWPyaGst/O5lsyKaIB1KESAZB8HiUWWExmQv pfWNfbfXFHQeXOARVLSmzowkXKfVLlE7l0aUTOIkijviKfJXGciD0H4bcr/DV/27Im QuPgy8wNzD9HNjSi2EPgwWZ5+FT5A4/gcDGepAcq6P0WZO8ufzC065UuqV45fnBc4L f2W6ADkm63C6yWE86EjHGyy3PmZgkMV8KCgpySz/lC/x8gwQBFEluXehFzOYJSH6OH ZF+lCAa9JO5sA== Received: from shaw.ca ([70.71.78.228]) by cmsmtp with ESMTPA id UPbGmpVUmdCHGUPbSm6iFT; Sun, 26 Sep 2021 08:33:42 +0000 Authentication-Results: ; auth=pass (LOGIN) smtp.auth=joevt@shaw.ca X-Authority-Analysis: v=2.4 cv=SdyUytdu c=1 sm=1 tr=0 ts=61503066 a=qDatE6m/3wxSEG8Wq7h0zQ==:117 a=qDatE6m/3wxSEG8Wq7h0zQ==:17 a=_Dj-zB-qAAAA:8 a=v-YZYUOcdODyg3dACn4A:9 a=c-cOe7UV8MviEfHuAVEQ:22 From: joevt To: Hans Verkuil Cc: linux-media@vger.kernel.org Subject: [PATCH v2 19/29] edid-decode: remove offset from displayid_block Date: Sun, 26 Sep 2021 01:33:20 -0700 Message-Id: <20210926083330.5206-20-joevt@shaw.ca> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210926083330.5206-1-joevt@shaw.ca> References: <20210926083330.5206-1-joevt@shaw.ca> MIME-Version: 1.0 X-CMAE-Envelope: MS4xfEgJBw9xcn6NOBDfW8FMXxOY71iElWgLG6O8NvM9GTPoo1eCA7OSF8jEjx4saWz5Ty/y6OM0YVtTLXaQXkXeoP2F35M/wgxehSMZgDbAwijy0RerK5ye m6wPfo8zfCUoHdnhVCAjvYLXotZJPDZxd6F3Y/aIPGCNs9QjQLW3SI6GfMnw02t27yykn/lyOvCqChL4JDmF3H4r/pY+U2rDyNk= Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Change the function so that x points to the start of the DisplayID block. Signed-off-by: Joe van Tunen --- edid-decode.h | 2 +- parse-displayid-block.cpp | 136 +++++++++++++++++++------------------- 2 files changed, 69 insertions(+), 69 deletions(-) diff --git a/edid-decode.h b/edid-decode.h index 4636978..c53dba3 100644 --- a/edid-decode.h +++ b/edid-decode.h @@ -395,7 +395,7 @@ struct edid_state { void parse_displayid_type_10_timing(const unsigned char *x, unsigned sz, bool is_cta = false); void preparse_displayid_block(const unsigned char *x); - unsigned displayid_block(const unsigned version, const unsigned char *x, unsigned offset, unsigned length); + unsigned displayid_block(const unsigned version, const unsigned char *x, unsigned length); void parse_displayid_block(const unsigned char *x); void parse_displayid_vesa(const unsigned char *x); void parse_displayid_cta_data_block(const unsigned char *x); diff --git a/parse-displayid-block.cpp b/parse-displayid-block.cpp index 0a996bd..17f1805 100644 --- a/parse-displayid-block.cpp +++ b/parse-displayid-block.cpp @@ -1651,10 +1651,10 @@ void edid_state::preparse_displayid_block(const unsigned char *x) } } -unsigned edid_state::displayid_block(const unsigned version, const unsigned char *x, unsigned offset, unsigned length) +unsigned edid_state::displayid_block(const unsigned version, const unsigned char *x, unsigned length) { unsigned i; - unsigned tag = x[offset]; + unsigned tag = x[0]; unsigned oui = 0; switch (tag) { @@ -1698,7 +1698,7 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char case 0x7f: // DisplayID 1.3 if ((tag == 0x7e && version >= 0x20) || (tag == 0x7f && version < 0x20)) { - oui = (x[offset + 3] << 16) + (x[offset + 4] << 8) + x[offset + 5]; + oui = (x[3] << 16) + (x[4] << 8) + x[5]; const char *name = oui_name(oui); bool reversed = false; @@ -1732,14 +1732,14 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char if (length < 3) { // report a problem when the remaining bytes are not 0. - if (tag || x[offset + 1]) { + if (tag || x[1]) { fail("Not enough bytes remain (%d) for a DisplayID data block or the DisplayID filler is non-0.\n", length); } return 0xff; } - unsigned block_rev = x[offset + 1] & 0x07; - unsigned len = x[offset + 2]; + unsigned block_rev = x[1] & 0x07; + unsigned len = x[2]; if (length < len + 3) { fail("The length of this DisplayID data block (%d) exceeds the number of bytes remaining (%d).\n", len + 3, length); @@ -1748,7 +1748,7 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char if (!tag && !len) { // A Product Identification Data Block with no payload bytes is not valid - assume this is the end. - if (!memchk(x + offset, length)) { + if (!memchk(x, length)) { fail("Non-0 filler bytes in the DisplayID block.\n"); } return 0xff; @@ -1757,133 +1757,133 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char printf(" %s:\n", data_block.c_str()); switch (tag) { - case 0x00: parse_displayid_product_id(x + offset); break; - case 0x01: parse_displayid_parameters(x + offset); break; - case 0x02: parse_displayid_color_characteristics(x + offset); break; + case 0x00: parse_displayid_product_id(x); break; + case 0x01: parse_displayid_parameters(x); break; + case 0x02: parse_displayid_color_characteristics(x); break; case 0x03: - check_displayid_datablock_revision(x[offset + 1], 0, block_rev & 1); + check_displayid_datablock_revision(x[1], 0, block_rev & 1); for (i = 0; i < len / 20; i++) - parse_displayid_type_1_7_timing(&x[offset + 3 + (i * 20)], false, block_rev); + parse_displayid_type_1_7_timing(&x[3 + (i * 20)], false, block_rev); break; case 0x04: - check_displayid_datablock_revision(x[offset + 1]); + check_displayid_datablock_revision(x[1]); for (i = 0; i < len / 11; i++) - parse_displayid_type_2_timing(&x[offset + 3 + (i * 11)]); + parse_displayid_type_2_timing(&x[3 + (i * 11)]); break; case 0x05: - check_displayid_datablock_revision(x[offset + 1], 0, block_rev & 1); + check_displayid_datablock_revision(x[1], 0, block_rev & 1); for (i = 0; i < len / 3; i++) - parse_displayid_type_3_timing(&x[offset + 3 + (i * 3)]); + parse_displayid_type_3_timing(&x[3 + (i * 3)]); break; case 0x06: - check_displayid_datablock_revision(x[offset + 1], 0xc0, 1); + check_displayid_datablock_revision(x[1], 0xc0, 1); for (i = 0; i < len; i++) - parse_displayid_type_4_8_timing((x[offset + 1] & 0xc0) >> 6, x[offset + 3 + i]); + parse_displayid_type_4_8_timing((x[1] & 0xc0) >> 6, x[3 + i]); break; case 0x07: - check_displayid_datablock_revision(x[offset + 1]); + check_displayid_datablock_revision(x[1]); for (i = 0; i < min(len, 10) * 8; i++) - if (x[offset + 3 + i / 8] & (1 << (i % 8))) { + if (x[3 + i / 8] & (1 << (i % 8))) { char type[16]; sprintf(type, "DMT 0x%02x", i + 1); print_timings(" ", find_dmt_id(i + 1), type); } break; case 0x08: - check_displayid_datablock_revision(x[offset + 1]); + check_displayid_datablock_revision(x[1]); for (i = 0; i < min(len, 8) * 8; i++) - if (x[offset + 3 + i / 8] & (1 << (i % 8))) { + if (x[3 + i / 8] & (1 << (i % 8))) { char type[16]; sprintf(type, "VIC %3u", i + 1); print_timings(" ", find_vic_id(i + 1), type); } break; - case 0x09: parse_displayid_video_timing_range_limits(x + offset); break; + case 0x09: parse_displayid_video_timing_range_limits(x); break; case 0x0a: - case 0x0b: parse_displayid_string(x + offset); break; - case 0x0c: parse_displayid_display_device(x + offset); break; - case 0x0d: parse_displayid_intf_power_sequencing(x + offset); break; - case 0x0e: parse_displayid_transfer_characteristics(x + offset); break; - case 0x0f: parse_displayid_display_intf(x + offset); break; - case 0x10: parse_displayid_stereo_display_intf(x + offset); break; + case 0x0b: parse_displayid_string(x); break; + case 0x0c: parse_displayid_display_device(x); break; + case 0x0d: parse_displayid_intf_power_sequencing(x); break; + case 0x0e: parse_displayid_transfer_characteristics(x); break; + case 0x0f: parse_displayid_display_intf(x); break; + case 0x10: parse_displayid_stereo_display_intf(x); break; case 0x11: - check_displayid_datablock_revision(x[offset + 1]); + check_displayid_datablock_revision(x[1]); for (i = 0; i < len / 7; i++) - parse_displayid_type_5_timing(&x[offset + 3 + (i * 7)]); + parse_displayid_type_5_timing(&x[3 + (i * 7)]); break; - case 0x12: parse_displayid_tiled_display_topology(x + offset, false); break; + case 0x12: parse_displayid_tiled_display_topology(x, false); break; case 0x13: - check_displayid_datablock_revision(x[offset + 1]); - for (i = 0; i < len; i += (x[offset + 3 + i + 2] & 0x40) ? 17 : 14) - parse_displayid_type_6_timing(&x[offset + 3 + i]); + check_displayid_datablock_revision(x[1]); + for (i = 0; i < len; i += (x[3 + i + 2] & 0x40) ? 17 : 14) + parse_displayid_type_6_timing(&x[3 + i]); break; - case 0x20: parse_displayid_product_id(x + offset); break; + case 0x20: parse_displayid_product_id(x); break; case 0x21: if (block_rev >= 1) - check_displayid_datablock_revision(x[offset + 1], 0x80, 1); + check_displayid_datablock_revision(x[1], 0x80, 1); else - check_displayid_datablock_revision(x[offset + 1], 0x80, 0); - parse_displayid_parameters_v2(x + offset, block_rev); + check_displayid_datablock_revision(x[1], 0x80, 0); + parse_displayid_parameters_v2(x, block_rev); break; case 0x22: { unsigned sz = 20; if (block_rev >= 2) - check_displayid_datablock_revision(x[offset + 1], 0x08, 2); + check_displayid_datablock_revision(x[1], 0x08, 2); else if (block_rev == 1) - check_displayid_datablock_revision(x[offset + 1], 0x08, 1); + check_displayid_datablock_revision(x[1], 0x08, 1); else - check_displayid_datablock_revision(x[offset + 1]); - sz += (x[offset + 1] & 0x70) >> 4; - if (block_rev >= 1 && (x[offset + 1] & 0x08)) + check_displayid_datablock_revision(x[1]); + sz += (x[1] & 0x70) >> 4; + if (block_rev >= 1 && (x[1] & 0x08)) printf(" These timings support DSC pass-through\n"); for (i = 0; i < len / sz; i++) - parse_displayid_type_1_7_timing(&x[offset + 3 + i * sz], true, block_rev); + parse_displayid_type_1_7_timing(&x[3 + i * sz], true, block_rev); break; } case 0x23: if (block_rev) - check_displayid_datablock_revision(x[offset + 1], 0xe8, 1); + check_displayid_datablock_revision(x[1], 0xe8, 1); else - check_displayid_datablock_revision(x[offset + 1], 0xc8); - if (x[offset + 1] & 0x08) { + check_displayid_datablock_revision(x[1], 0xc8); + if (x[1] & 0x08) { for (i = 0; i < len / 2; i++) - parse_displayid_type_4_8_timing((x[offset + 1] & 0xc0) >> 6, - x[offset + 3 + i * 2] | - (x[offset + 4 + i * 2] << 8)); + parse_displayid_type_4_8_timing((x[1] & 0xc0) >> 6, + x[3 + i * 2] | + (x[4 + i * 2] << 8)); } else { for (i = 0; i < len; i++) - parse_displayid_type_4_8_timing((x[offset + 1] & 0xc0) >> 6, - x[offset + 3 + i]); + parse_displayid_type_4_8_timing((x[1] & 0xc0) >> 6, + x[3 + i]); } break; case 0x24: - check_displayid_datablock_revision(x[offset + 1]); + check_displayid_datablock_revision(x[1]); for (i = 0; i < len / 6; i++) - parse_displayid_type_9_timing(&x[offset + 3 + i * 6]); + parse_displayid_type_9_timing(&x[3 + i * 6]); break; - case 0x25: parse_displayid_dynamic_video_timings_range_limits(x + offset); break; - case 0x26: parse_displayid_interface_features(x + offset); break; - case 0x27: parse_displayid_stereo_display_intf(x + offset); break; - case 0x28: parse_displayid_tiled_display_topology(x + offset, true); break; - case 0x29: parse_displayid_ContainerID(x + offset); break; - case 0x2b: parse_displayid_adaptive_sync(x + offset); break; + case 0x25: parse_displayid_dynamic_video_timings_range_limits(x); break; + case 0x26: parse_displayid_interface_features(x); break; + case 0x27: parse_displayid_stereo_display_intf(x); break; + case 0x28: parse_displayid_tiled_display_topology(x, true); break; + case 0x29: parse_displayid_ContainerID(x); break; + case 0x2b: parse_displayid_adaptive_sync(x + offset); break; case 0x32: { - unsigned sz = 6 + ((x[offset + 1] & 0x70) >> 4); + unsigned sz = 6 + ((x[1] & 0x70) >> 4); - check_displayid_datablock_revision(x[offset + 1], 0x70); + check_displayid_datablock_revision(x[1], 0x70); for (i = 0; i < len / sz; i++) - parse_displayid_type_10_timing(&x[offset + 3 + i * sz], sz); + parse_displayid_type_10_timing(&x[3 + i * sz], sz); break; } - case 0x81: parse_displayid_cta_data_block(x + offset); break; + case 0x81: parse_displayid_cta_data_block(x); break; case 0x7e: if (oui == 0x3a0292) { - parse_displayid_vesa(x + offset); + parse_displayid_vesa(x); break; } // fall-through - default: hex_block(" ", x + offset + 3, len); break; + default: hex_block(" ", x + 3, len); break; } if ((tag == 0x00 || tag == 0x20) && @@ -1934,7 +1934,7 @@ void edid_state::parse_displayid_block(const unsigned char *x) unsigned offset = 5; while (length > 0) { - unsigned len = displayid_block(version, x, offset, length); + unsigned len = displayid_block(version, x + offset, length); if (len == 0xff) break; length -= len + 3; offset += len + 3; From patchwork Sun Sep 26 08:33:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: joevt X-Patchwork-Id: 12518091 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99017C433F5 for ; Sun, 26 Sep 2021 08:34:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7801F60EE0 for ; Sun, 26 Sep 2021 08:34:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229687AbhIZIgV (ORCPT ); Sun, 26 Sep 2021 04:36:21 -0400 Received: from omta001.cacentral1.a.cloudfilter.net ([3.97.99.32]:43776 "EHLO omta001.cacentral1.a.cloudfilter.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbhIZIgU (ORCPT ); Sun, 26 Sep 2021 04:36:20 -0400 Received: from shw-obgw-4001a.ext.cloudfilter.net ([10.228.9.142]) by cmsmtp with ESMTP id U6HQmeyzZczbLUPcSmV5Vc; Sun, 26 Sep 2021 08:34:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=shaw.ca; s=s20180605; t=1632645284; bh=eg36BMeLWY/KD9OprJp23smtNkXEzx7j16ZWQmnIlfY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Y964CXB3md42nCWv3kXrvyKdUxHVEKxurpPWhKtnHyEFB3yZpTZvcLqlEsAd+mtaj Tf1bxiI6034Ls5ZVoklClyWTe2C0JS3JAx+FnWgYiah8jcag8K2yEk5Xf9SAlWZVAd 9eNcyoSIFCfQy6mXzRlIFsCTl/+nBPfYBSqteLVJ1yOROgivWRqCCfrKMlaeV+JGuO sjWTIMnWB7nS5wUgNpelzp6H6UkLLoF2TVBy1wub1AUj1Q+Xt4cd+d9e/R8+TXMLOE BZ3DqVKMdyuPD9yMv9zSZtAZRVUF7l87AfN1a0Lz0jTemkxk5056vvkd808r7/P2aS bUGrKLVO2QTpQ== Received: from shaw.ca ([70.71.78.228]) by cmsmtp with ESMTPA id UPcQm9l35U9pxUPcRmdRIs; Sun, 26 Sep 2021 08:34:44 +0000 Authentication-Results: ; auth=pass (LOGIN) smtp.auth=joevt@shaw.ca X-Authority-Analysis: v=2.4 cv=Bbi7bph2 c=1 sm=1 tr=0 ts=615030a4 a=qDatE6m/3wxSEG8Wq7h0zQ==:117 a=qDatE6m/3wxSEG8Wq7h0zQ==:17 a=_Dj-zB-qAAAA:8 a=13305_vfhJ9_Lek99XsA:9 a=c-cOe7UV8MviEfHuAVEQ:22 From: joevt To: Hans Verkuil Cc: linux-media@vger.kernel.org Subject: [PATCH v2 20/29] edid-decode: displayid_block len fixes Date: Sun, 26 Sep 2021 01:33:21 -0700 Message-Id: <20210926083330.5206-21-joevt@shaw.ca> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210926083330.5206-1-joevt@shaw.ca> References: <20210926083330.5206-1-joevt@shaw.ca> MIME-Version: 1.0 X-CMAE-Envelope: MS4xfMJmqFOUP5QcCIvRiYJ9+llvI47OQBVtgC8AuGoreFWffCn8acAZm3DCUmBYOY964MLnFkEy27cmA8zAVjCAU9DORNRVb/PvI4JoPRmsCcgg2Pa1DfmH QNkN2n2J2ioYdILE6pEs4lANasMkwOLUEPIw0KyhCFZcv7TXs2//uYxpZoYAJ7P3pW8UMpyKafHtGLzJ/1W5mWPHdXbdo3M27oc= Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org - Calculate len early like we do for CTA blocks (set to zero if there's no bytes remaining to get len). We'll use this for OUI errors later. - The return value of the displayid_block function is now the entire length of the DisplayID data block. Returning length will thus terminate the loop in parse_displayid_block, so we don't need the 0xff magic number. - Bug fix: For the "Not enough bytes remain (%d) for a DisplayID data block or the DisplayID filler is non-0.\n" fail message, if length remaining is only 1 then don't check the byte beyond that. Also change "or" to "and" in that message. Signed-off-by: Joe van Tunen --- parse-displayid-block.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/parse-displayid-block.cpp b/parse-displayid-block.cpp index 17f1805..c090056 100644 --- a/parse-displayid-block.cpp +++ b/parse-displayid-block.cpp @@ -1656,6 +1656,7 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char unsigned i; unsigned tag = x[0]; unsigned oui = 0; + unsigned len = (length < 3) ? 0 : x[2]; switch (tag) { // DisplayID 1.3: @@ -1732,18 +1733,17 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char if (length < 3) { // report a problem when the remaining bytes are not 0. - if (tag || x[1]) { - fail("Not enough bytes remain (%d) for a DisplayID data block or the DisplayID filler is non-0.\n", length); + if (tag || (length > 1 && x[1])) { + fail("Not enough bytes remain (%d) for a DisplayID data block and the DisplayID filler is non-0.\n", length); } - return 0xff; + return length; } unsigned block_rev = x[1] & 0x07; - unsigned len = x[2]; if (length < len + 3) { fail("The length of this DisplayID data block (%d) exceeds the number of bytes remaining (%d).\n", len + 3, length); - return 0xff; + return length; } if (!tag && !len) { @@ -1751,7 +1751,7 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char if (!memchk(x, length)) { fail("Non-0 filler bytes in the DisplayID block.\n"); } - return 0xff; + return length; } printf(" %s:\n", data_block.c_str()); @@ -1867,7 +1867,7 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char case 0x27: parse_displayid_stereo_display_intf(x); break; case 0x28: parse_displayid_tiled_display_topology(x, true); break; case 0x29: parse_displayid_ContainerID(x); break; - case 0x2b: parse_displayid_adaptive_sync(x + offset); break; + case 0x2b: parse_displayid_adaptive_sync(x); break; case 0x32: { unsigned sz = 6 + ((x[1] & 0x70) >> 4); @@ -1892,7 +1892,7 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char data_block.c_str()); dispid.block_number++; - return len; + return len + 3; } void edid_state::parse_displayid_block(const unsigned char *x) @@ -1932,12 +1932,10 @@ void edid_state::parse_displayid_block(const unsigned char *x) length = 121; } - unsigned offset = 5; - while (length > 0) { - unsigned len = displayid_block(version, x + offset, length); - if (len == 0xff) break; - length -= len + 3; - offset += len + 3; + unsigned len; + for (const unsigned char *y = x + 5; length > 0; y += len) { + len = displayid_block(version, y, length); + length -= len; } /* From patchwork Sun Sep 26 08:33:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: joevt X-Patchwork-Id: 12518093 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F17B6C4332F for ; Sun, 26 Sep 2021 08:34:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D422660F93 for ; Sun, 26 Sep 2021 08:34:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229691AbhIZIgV (ORCPT ); Sun, 26 Sep 2021 04:36:21 -0400 Received: from omta001.cacentral1.a.cloudfilter.net ([3.97.99.32]:51462 "EHLO omta001.cacentral1.a.cloudfilter.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229571AbhIZIgU (ORCPT ); Sun, 26 Sep 2021 04:36:20 -0400 Received: from shw-obgw-4001a.ext.cloudfilter.net ([10.228.9.142]) by cmsmtp with ESMTP id UDIkmfT6IczbLUPcSmV5Vd; Sun, 26 Sep 2021 08:34:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=shaw.ca; s=s20180605; t=1632645284; bh=Jv5cjoJfUV3MNRof2bX9CbbnUzJDlRhmkzR959HzaZo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=YQAYhddPt/XUw9hrhKypd7ffCfqHhCkEna4LBXJ8XHX9SanxkJVV9UQSpQmJWbUQl YbdMOla0EgWEHesZbuHblrj/iIYiB3Tcfr/RGSpjyMwspSmMen9gaYG/kOw+7uQRwp TWqbfZ7so5Xyns+JnJT9nNT4ijyBDR+9eDE9TP3rjpV76wwRO9P3c4om/DKVP1EP2V 6QK2OXe7oX5dvNoco4BkAxjH5VJUD3grSmdirva925V73+GAzECsVayOe1Rx+447K8 fSr99IY63uCmaPMOddAuZK5Fg5EwmVmqtmU7YlK6BREAZ3i5lBH69UmiaaIeMCpJE7 j+Ze+dym9vZnQ== Received: from shaw.ca ([70.71.78.228]) by cmsmtp with ESMTPA id UPcQm9l35U9pxUPcSmdRJ2; Sun, 26 Sep 2021 08:34:44 +0000 Authentication-Results: ; auth=pass (LOGIN) smtp.auth=joevt@shaw.ca X-Authority-Analysis: v=2.4 cv=Bbi7bph2 c=1 sm=1 tr=0 ts=615030a4 a=qDatE6m/3wxSEG8Wq7h0zQ==:117 a=qDatE6m/3wxSEG8Wq7h0zQ==:17 a=_Dj-zB-qAAAA:8 a=Yovvzn6Zekd1wrSMwOgA:9 a=c-cOe7UV8MviEfHuAVEQ:22 From: joevt To: Hans Verkuil Cc: linux-media@vger.kernel.org Subject: [PATCH v2 21/29] edid-decode: ignore DisplayID version for OUI check. Date: Sun, 26 Sep 2021 01:33:22 -0700 Message-Id: <20210926083330.5206-22-joevt@shaw.ca> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210926083330.5206-1-joevt@shaw.ca> References: <20210926083330.5206-1-joevt@shaw.ca> MIME-Version: 1.0 X-CMAE-Envelope: MS4xfMJmqFOUP5QcCIvRiYJ9+llvI47OQBVtgC8AuGoreFWffCn8acAZm3DCUmBYOY964MLnFkEy27cmA8zAVjCAU9DORNRVb/PvI4JoPRmsCcgg2Pa1DfmH QNkN2n2J2ioYdILE6pEs4lANasMkwOLUEPIw0KyhCFZcv7TXs2//uYxpZoYAJ7P3pW8UMpyKafHtGLzJ/1W5mWPHdXbdo3M27oc= Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org - Interpret VESA data block even if DisplayID version is not 2.0. See example apple-xdr-6k. - Remove the "Unknown DisplayID Data Block" fail message for these tags because there's a "Use of DisplayID v#.# tag for DisplayID v%u.%u.\n" fail message for them. - Include tag number for ambiguous DisplayID tags. - Don't need tag number for 0x81 because it's not ambiguous. Signed-off-by: Joe van Tunen --- parse-displayid-block.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/parse-displayid-block.cpp b/parse-displayid-block.cpp index c090056..5266bb3 100644 --- a/parse-displayid-block.cpp +++ b/parse-displayid-block.cpp @@ -1697,8 +1697,7 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char // 0x2a .. 0x7d RESERVED for Additional VESA-defined Data Blocks case 0x7e: // DisplayID 2.0 case 0x7f: // DisplayID 1.3 - if ((tag == 0x7e && version >= 0x20) || - (tag == 0x7f && version < 0x20)) { + { oui = (x[3] << 16) + (x[4] << 8) + x[5]; const char *name = oui_name(oui); bool reversed = false; @@ -1709,17 +1708,15 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char reversed = true; } if (name) - data_block = std::string("Vendor-Specific Data Block (") + name + ")"; + data_block = "Vendor-Specific Data Block (" + utohex(tag) + ") (" + name + ")"; else - data_block = "Vendor-Specific Data Block, OUI " + ouitohex(oui); + data_block = "Vendor-Specific Data Block (" + utohex(tag) + "), OUI " + ouitohex(oui); if (reversed) fail((std::string("OUI ") + ouitohex(oui) + " is in the wrong byte order.\n").c_str()); - } else { - data_block = "Unknown DisplayID Data Block (" + utohex(tag) + ")"; } break; // 0x80 RESERVED - case 0x81: data_block = "CTA-861 DisplayID Data Block (" + utohex(tag) + ")"; break; + case 0x81: data_block = "CTA-861 DisplayID Data Block"; break; // 0x82 .. 0xff RESERVED default: data_block = "Unknown DisplayID Data Block (" + utohex(tag) + ")"; break; } From patchwork Sun Sep 26 08:33:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: joevt X-Patchwork-Id: 12518097 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACCAFC433EF for ; Sun, 26 Sep 2021 08:34:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8DB4360F11 for ; Sun, 26 Sep 2021 08:34:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229695AbhIZIgW (ORCPT ); Sun, 26 Sep 2021 04:36:22 -0400 Received: from omta001.cacentral1.a.cloudfilter.net ([3.97.99.32]:37615 "EHLO omta001.cacentral1.a.cloudfilter.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229574AbhIZIgV (ORCPT ); Sun, 26 Sep 2021 04:36:21 -0400 Received: from shw-obgw-4001a.ext.cloudfilter.net ([10.228.9.142]) by cmsmtp with ESMTP id U6HQmeyzXczbLUPcTmV5Ve; Sun, 26 Sep 2021 08:34:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=shaw.ca; s=s20180605; t=1632645285; bh=7fKbMSEs01uEFsGkVJtcAlEb1v3XpiubqdD722oM1FY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=HF+T7mEjy/rfbBvRKhwHjTEbviwznaJhRGaqJddRdpBWmKfJXUP0skToIiTPAjjG2 SarXOUWnfg+tgnZ5rlhu3jFfe33SMSsWXLLAMZH/CAhzOYQ08vM0+TuNasJac4oAcK 9tgUQpdGmEh24GefIAPnsVxFdS1DlsNSTmrdopoeviDNV6iBd9F5+s/swaBrMHcpyb 7SkAVO7OSdssg108q81HomcCdGjpr+28/ORbOQCnueuzbVKaDujKP2+8JkUwqa7ntk vwXvCSnax6yWEfRR/NlM+dcI3lf2yDyFK7foiIUmUTReoSs1UMY+zgi1uHoYYOD4cm AZxy2arGDdS4g== Received: from shaw.ca ([70.71.78.228]) by cmsmtp with ESMTPA id UPcQm9l35U9pxUPcTmdRJ6; Sun, 26 Sep 2021 08:34:45 +0000 Authentication-Results: ; auth=pass (LOGIN) smtp.auth=joevt@shaw.ca X-Authority-Analysis: v=2.4 cv=Bbi7bph2 c=1 sm=1 tr=0 ts=615030a5 a=qDatE6m/3wxSEG8Wq7h0zQ==:117 a=qDatE6m/3wxSEG8Wq7h0zQ==:17 a=_Dj-zB-qAAAA:8 a=2kVt1EyJOXHpImby__wA:9 a=c-cOe7UV8MviEfHuAVEQ:22 From: joevt To: Hans Verkuil Cc: linux-media@vger.kernel.org Subject: [PATCH v2 22/29] edid-decode: DisplayID non-0 filler fixes Date: Sun, 26 Sep 2021 01:33:23 -0700 Message-Id: <20210926083330.5206-23-joevt@shaw.ca> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210926083330.5206-1-joevt@shaw.ca> References: <20210926083330.5206-1-joevt@shaw.ca> MIME-Version: 1.0 X-CMAE-Envelope: MS4xfMSYf/bEfKSgHZGtRkmNbJlHIJUQlYGecVYv5/+SwrI/lkbVYidu9MToZ9RqszxS29kV6X0MUXaQFkLDvqXDzKXwdYG2NFOq0S302O5Y7TtObb8VRdRV 00OuAkYOOcrTA8jYZ4UrCdUmF5zpJVQzEzRQA5ZkeEYbfrY//Mj17ZBaHeaFWLRHeULRVUpznAXIT3jJcuFv3Xud5/QY635WcyY= Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org It's probably not a Product Identification Data Block or any kind of block so data_block should be cleared (so that the block name doesn't appear in the Failures section for this fail). Output hex data because it might contain interesting data (it's at least known to be not zero). Signed-off-by: Joe van Tunen --- parse-displayid-block.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/parse-displayid-block.cpp b/parse-displayid-block.cpp index 5266bb3..dc2ec7b 100644 --- a/parse-displayid-block.cpp +++ b/parse-displayid-block.cpp @@ -1745,8 +1745,11 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char if (!tag && !len) { // A Product Identification Data Block with no payload bytes is not valid - assume this is the end. + data_block.clear(); // Probably not a Product Identification Data Block so clear this. if (!memchk(x, length)) { + printf(" Filler:\n"); fail("Non-0 filler bytes in the DisplayID block.\n"); + hex_block(" ", x, length); } return length; } From patchwork Sun Sep 26 08:33:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: joevt X-Patchwork-Id: 12518095 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E11BC43217 for ; Sun, 26 Sep 2021 08:34:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E74E760F11 for ; Sun, 26 Sep 2021 08:34:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229716AbhIZIgX (ORCPT ); Sun, 26 Sep 2021 04:36:23 -0400 Received: from omta002.cacentral1.a.cloudfilter.net ([3.97.99.33]:39575 "EHLO omta002.cacentral1.a.cloudfilter.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbhIZIgW (ORCPT ); Sun, 26 Sep 2021 04:36:22 -0400 Received: from shw-obgw-4001a.ext.cloudfilter.net ([10.228.9.142]) by cmsmtp with ESMTP id UBZAmHI0xps7PUPcTmzSIP; Sun, 26 Sep 2021 08:34:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=shaw.ca; s=s20180605; t=1632645285; bh=RIre7ZjEMinoV5K4DUQBqBEtN7eUzwcaElO9OCBt7j8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=MDiPmDxnyaP5NXRQCtwQjayLWrLTmHcmlJ67sZWlAGuoKZ6xruEmgAMjQByGAUFyA eYEUbLksUIpCkWEF11Fd8fciVaBBtSWvwia/AxZYqi9FFtVEjexl7iLB2RBrmz/SF8 GK3Q3jyTRUR5w12hYwXp5xWdWcePuH6ZmXlAfV1wkQNstP5hezdo+BDE52CQAp9pYc cuwD0EzQoF9qxJIVaAi16rNFH3Ho1OUJX6+cuB4Q/qTan0hPc0jqFSphWkUaQ5+Dfk evJcgLB9tSbRwHZRZ+J1Vz5WxjE0CTNK/JxCvZ7zp5kC53x7LfIBvplx44RH9rsSlK T75EhX/04EQ6g== Received: from shaw.ca ([70.71.78.228]) by cmsmtp with ESMTPA id UPcQm9l35U9pxUPcTmdRJ9; Sun, 26 Sep 2021 08:34:45 +0000 Authentication-Results: ; auth=pass (LOGIN) smtp.auth=joevt@shaw.ca X-Authority-Analysis: v=2.4 cv=Bbi7bph2 c=1 sm=1 tr=0 ts=615030a5 a=qDatE6m/3wxSEG8Wq7h0zQ==:117 a=qDatE6m/3wxSEG8Wq7h0zQ==:17 a=_Dj-zB-qAAAA:8 a=lgizLmqXkyJUOuj-0BQA:9 a=c-cOe7UV8MviEfHuAVEQ:22 From: joevt To: Hans Verkuil Cc: linux-media@vger.kernel.org Subject: [PATCH v2 23/29] edid-decode: DisplayID length checks Date: Sun, 26 Sep 2021 01:33:24 -0700 Message-Id: <20210926083330.5206-24-joevt@shaw.ca> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210926083330.5206-1-joevt@shaw.ca> References: <20210926083330.5206-1-joevt@shaw.ca> MIME-Version: 1.0 X-CMAE-Envelope: MS4xfMSYf/bEfKSgHZGtRkmNbJlHIJUQlYGecVYv5/+SwrI/lkbVYidu9MToZ9RqszxS29kV6X0MUXaQFkLDvqXDzKXwdYG2NFOq0S302O5Y7TtObb8VRdRV 00OuAkYOOcrTA8jYZ4UrCdUmF5zpJVQzEzRQA5ZkeEYbfrY//Mj17ZBaHeaFWLRHeULRVUpznAXIT3jJcuFv3Xud5/QY635WcyY= Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org - Only report DisplayID version discrepancy for a data block after verifying that the data block exists and is properly sized. The fail message is output after the block name instead of before the block name. - Output hex bytes of non-zero filler when length is 1 or 2. We did the same for lengths longer than that in a previous commit. - Output hex bytes that are skipped when the block length is longer than the number of bytes remaining in the DisplayID block. Signed-off-by: Joe van Tunen --- parse-displayid-block.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/parse-displayid-block.cpp b/parse-displayid-block.cpp index dc2ec7b..269444b 100644 --- a/parse-displayid-block.cpp +++ b/parse-displayid-block.cpp @@ -1721,25 +1721,22 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char default: data_block = "Unknown DisplayID Data Block (" + utohex(tag) + ")"; break; } - if (version >= 0x20 && (tag < 0x20 || tag == 0x7f)) - fail("Use of DisplayID v1.x tag for DisplayID v%u.%u.\n", - version >> 4, version & 0xf); - if (version < 0x20 && tag >= 0x20 && tag <= 0x7e) - fail("Use of DisplayID v2.0 tag for DisplayID v%u.%u.\n", - version >> 4, version & 0xf); - if (length < 3) { - // report a problem when the remaining bytes are not 0. + // Report a problem when the remaining bytes are not 0. + data_block.clear(); // Probably not a Data Block so clear this. if (tag || (length > 1 && x[1])) { + printf(" Filler:\n"); fail("Not enough bytes remain (%d) for a DisplayID data block and the DisplayID filler is non-0.\n", length); + hex_block(" ", x, length); } return length; } - unsigned block_rev = x[1] & 0x07; - if (length < len + 3) { + data_block.clear(); // Probably not a Data Block so clear this. + printf(" Filler:\n"); fail("The length of this DisplayID data block (%d) exceeds the number of bytes remaining (%d).\n", len + 3, length); + hex_block(" ", x, length); return length; } @@ -1756,6 +1753,15 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char printf(" %s:\n", data_block.c_str()); + if (version >= 0x20 && (tag < 0x20 || tag == 0x7f)) + fail("Use of DisplayID v1.x tag for DisplayID v%u.%u.\n", + version >> 4, version & 0xf); + if (version < 0x20 && tag >= 0x20 && tag <= 0x7e) + fail("Use of DisplayID v2.0 tag for DisplayID v%u.%u.\n", + version >> 4, version & 0xf); + + unsigned block_rev = x[1] & 0x07; + switch (tag) { case 0x00: parse_displayid_product_id(x); break; case 0x01: parse_displayid_parameters(x); break; From patchwork Sun Sep 26 08:33:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: joevt X-Patchwork-Id: 12518101 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C28E8C433FE for ; Sun, 26 Sep 2021 08:34:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A81C960F93 for ; Sun, 26 Sep 2021 08:34:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229755AbhIZIgX (ORCPT ); Sun, 26 Sep 2021 04:36:23 -0400 Received: from omta001.cacentral1.a.cloudfilter.net ([3.97.99.32]:43776 "EHLO omta001.cacentral1.a.cloudfilter.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229702AbhIZIgX (ORCPT ); Sun, 26 Sep 2021 04:36:23 -0400 Received: from shw-obgw-4001a.ext.cloudfilter.net ([10.228.9.142]) by cmsmtp with ESMTP id U65gmeyQJczbLUPcUmV5Vg; Sun, 26 Sep 2021 08:34:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=shaw.ca; s=s20180605; t=1632645286; bh=VBXImBsHU+49GKMeYY06cHOsFA3n0B1e4+/j7UBwk1Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=jbD4AhV/hx5Pt4miblb8XFsKDfEVcjwIHNLc5zeGDADIRWYTpUB+bkFeeaUSs60PT 0Li8MIPNVKCPyVlpbBDS1t7lbfVCj/vb3/wxZj0a0alVfdsy+GLW1VX7Ayra2nlBeJ 7LDmF+OgAMZmS5l85Lp4yN04Migc+3T5p/durw8CbWvIXturlfwc75JUeMdhx7WzHV SFSB4eLBSQytpfMFO2aTsbYRV67LYSZt2WYZr2dF+B/fQq84dTidBr41/NW3ATKj0m oB7UUhd/ipmXC+NQB60M0WVmVV25+WIBJv0PDpjUSjMehpwohslZGojJOCLBsoAsg4 /RyRHVWuwmpGw== Received: from shaw.ca ([70.71.78.228]) by cmsmtp with ESMTPA id UPcQm9l35U9pxUPcTmdRJF; Sun, 26 Sep 2021 08:34:46 +0000 Authentication-Results: ; auth=pass (LOGIN) smtp.auth=joevt@shaw.ca X-Authority-Analysis: v=2.4 cv=Bbi7bph2 c=1 sm=1 tr=0 ts=615030a6 a=qDatE6m/3wxSEG8Wq7h0zQ==:117 a=qDatE6m/3wxSEG8Wq7h0zQ==:17 a=_Dj-zB-qAAAA:8 a=o83nqyVRAAAA:8 a=dw0t6H4-AAAA:8 a=f3f_0qRwYyljyiL5AasA:9 a=c-cOe7UV8MviEfHuAVEQ:22 a=wVJa4CU9-Z26yuRAZDil:22 From: joevt To: Hans Verkuil Cc: linux-media@vger.kernel.org Subject: [PATCH v2 24/29] edid-decode: make OUI enum Date: Sun, 26 Sep 2021 01:33:25 -0700 Message-Id: <20210926083330.5206-25-joevt@shaw.ca> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210926083330.5206-1-joevt@shaw.ca> References: <20210926083330.5206-1-joevt@shaw.ca> MIME-Version: 1.0 X-CMAE-Envelope: MS4xfCsreC3QcxXq/SoWFGulpMsopXd8EuPVqX7NKgOen5+UUM8xCzmSJroEC9xFwtUHyewJEMsPYxL1hwbdS0bV/K1P2h1dZdxnWx8N5Lvicu20HD5M+H2n reYl9EMq9YmTPCdfhO9cN7KfMuTIBfbdV3EEdD3Nn55hyxxwO4OPmLz9TGZyM6/vi231Q/IVMGY2S6LU6BdW+GwoBiuHrXF49Ro= Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Instead of a 3 byte value, create an enumeration of known OUIs. This way, it can be combined with tag value to identify a data block type with a single value. This value can be used in a switch statement or other places (see later commits). - The list of known OUIs is in a new file oui.h. It contains the 3 byte value, a enum base name for the enum, and the OUI name. - The oui.h can be included in other source files for different purposes be changing the oneoui macro. It's used in edid-decode.h to define the enumeration. - Function oui_name uses oui.h to convert an OUI to the enum value. Removed the reverse parameter - OUI byte order is now handled by the caller, data_block_oui. - data_block_oui is modified to do the following: - It will return the oui enumeration. - It is made suitable for OUIs in DisplayID data blocks. - The ignorezeos flag is only true for the DisplayID "Product Identification Data Block". If the data block is zeros then it's probably not a data block so ignore it. For "Product Identification Data Block", the OUI doesn't change the interpretation of the data block so caller (displayid_block) then immediately clears the OUI enum. - The do_ascii flag is true for DisplayID v1.2 data blocks (section 4.1.1 of the DisplayID 1.3 spec says Manufacturer/Vendor ID is ASCII). - The big_endian flag is true for DisplayID v2.0 data blocks and false for CTA-861 data blocks. - It always outputs the block name first so that fails and warnings will appear after the block name instead of before. data_block_oui does the following: - It gets the OUI bytes in the order determined by the big_endian flag. An OUI is a 24 bit number. - It gets a PNP ID value (ASCII) with the same 3 bytes. A PNP ID in oui.h is a 32 bit number (3 characters [A-Z] followed by a NULL) so it cannot be confused with an OUI in the same file. - If bytes of the OUI extend beyond the end of the block then they are assumed to be zero, and it does not try to convert the OUI to a name, and the enum result is 0 which is invalid, and the PNP result is "?" which is invalid. - It tries to match the OUI. If that doesn't match then it tries to match the reversed OUI. If DisplayID v1.2 then it also tries to match PNP if the other two didn't match. - If ASCII is expected (DisplayID v1.2) and found, the output block name is "block_name, PNP ID 'ABC'". It is output with a colon as usual. - The "Unknown block_name, OUI %s." warning message is replaced by "Unknown OUI %s." (or with "Unknown OUI %s (possible PNP %s)." if ASCII is expected and the OUI is valid ASCII). In either case, the warning is prefixed by "block_name, OUI %s:" or "block_name, PNP ID %s:" in the warnings and failures section. - The "Invalid length %u < 3." fail message is replaced by "Data block length (%d) is not enough to contain an OUI.". - The "OUI %s is in the wrong byte order" fail message (which is missing the trailing period) is replaced with "Endian-ness (be|le) of OUI is different than expected (le|be)." - In parse-cta-block.cpp and parse-displayid-block.cpp, in the first switch statement, any tag with an OUI has its block name output by data_block_oui so they'll set dooutputname to false to stop the block name from being output again. - In parse-displayid-block.cpp, don't include OUI in hex dump of unknown data block types. Signed-off-by: Joe van Tunen --- edid-decode.cpp | 117 +++++++++++++++++++++++++------------- edid-decode.h | 8 ++- oui.h | 20 +++++++ parse-cta-block.cpp | 78 ++++++++++--------------- parse-displayid-block.cpp | 46 ++++++--------- 5 files changed, 148 insertions(+), 121 deletions(-) create mode 100644 oui.h diff --git a/edid-decode.cpp b/edid-decode.cpp index 666a2c6..0da7d85 100644 --- a/edid-decode.cpp +++ b/edid-decode.cpp @@ -657,60 +657,95 @@ std::string utohex(unsigned char x) return buf; } -const char *oui_name(unsigned oui, bool reverse) +const char *oui_name(unsigned oui, unsigned *ouinum) { - if (reverse) - oui = (oui >> 16) | (oui & 0xff00) | ((oui & 0xff) << 16); - + unsigned ouinumscratch; + if (!ouinum) ouinum = &ouinumscratch; + const char *name; switch (oui) { - case 0x00001a: return "AMD"; - case 0x000c03: return "HDMI"; - case 0x00044b: return "NVIDIA"; - case 0x000c6e: return "ASUS"; - case 0x0010fa: return "Apple"; - case 0x0014b9: return "MSTAR"; - case 0x00d046: return "Dolby"; - case 0x00e047: return "InFocus"; - case 0x3a0292: return "VESA"; - case 0x90848b: return "HDR10+"; - case 0xc45dd8: return "HDMI Forum"; - case 0xca125c: return "Microsoft"; - default: return NULL; + #define oneoui(c,k,n) case c: *ouinum = kOUI_##k; name = n; break; + #include "oui.h" + default: *ouinum = 0; name = NULL; } + return name; } -void edid_state::data_block_oui(const char *block_name, const unsigned char *x, unsigned length, unsigned *ouinum) +void edid_state::data_block_oui(std::string block_name, const unsigned char *x, + unsigned length, unsigned *ouinum, bool ignorezeros, bool do_ascii, bool big_endian) { - const char *name; - unsigned oui = 0; - bool reverse = false; + std::string buf; + char ascii[4]; + unsigned oui; + const char *ouiname = NULL; + bool matched_reverse = false; + bool matched_ascii = false; + bool valid_ascii = false; + + if (big_endian) + oui = ((length > 0 ? x[0] : 0) << 16) + ((length > 1 ? x[1] : 0) << 8) + (length > 2 ? x[2] : 0); + else + oui = ((length > 2 ? x[2] : 0) << 16) + ((length > 1 ? x[1] : 0) << 8) + (length > 0 ? x[0] : 0); + buf = ouitohex(oui); if (length < 3) { - printf(" %s:\n", block_name); - data_block = std::string(block_name); - fail("Invalid length %u < 3.\n", length); - data_block.clear(); - } - else { - oui = (x[2] << 16) + (x[1] << 8) + x[0]; - name = oui_name(oui); - if (!name) { - name = oui_name(oui, true); - if (name) - reverse = true; + sprintf(ascii, "?"); // some characters are null + if (ouinum) *ouinum = 0; // doesn't match a known OUI + } else { + valid_ascii = (x[0] >= 'A' && x[1] >= 'A' && x[2] >= 'A' && x[0] <= 'Z' && x[1] <= 'Z' && x[2] <= 'Z'); + sprintf(ascii, "%c%c%c", x[0], x[1], x[2]); + + ouiname = oui_name(oui, ouinum); + if (!ouiname) { + big_endian = !big_endian; + unsigned reversedoui = ((oui & 0xff) << 16) + (oui & 0x00ff00) + (oui >> 16); + ouiname = oui_name(reversedoui, ouinum); + if (ouiname) { + oui = reversedoui; + buf = ouitohex(oui); + matched_reverse = true; + } + else if (do_ascii && valid_ascii) + { + unsigned asciioui = (x[0] << 24) + (x[1] << 16) + (x[2] << 8); + ouiname = oui_name(asciioui, ouinum); + if (ouiname) { + matched_ascii = true; + } + } } - if (!name) { - printf(" %s, OUI %s:\n", block_name, ouitohex(oui).c_str()); - data_block.clear(); - warn("Unknown %s, OUI %s.\n", block_name, ouitohex(oui).c_str()); + } + + std::string name; + if (ouiname) { + if (matched_ascii) + name = block_name + " (" + ouiname + ")" + ", PNP ID '" + ascii + "'"; + else + name = block_name + " (" + ouiname + ")" + ", OUI " + buf; + } else if (do_ascii && valid_ascii) { + name = block_name + ", PNP ID '" + ascii + "'"; + } else { + name = block_name + ", OUI " + buf; + } + // assign string to data_block before outputting errors + data_block = name; + + if (oui || !ignorezeros) { + printf(" %s:\n", data_block.c_str()); + if (length < 3) + fail("Data block length (%d) is not enough to contain an OUI.\n", length); + else if (ouiname) { + if (do_ascii && !valid_ascii) + fail("Expected PNP ID but found OUI.\n"); + if (matched_reverse) + fail("Endian-ness (%s) of OUI is different than expected (%s).\n", big_endian ? "be" : "le", big_endian ? "le" : "be"); } else { - data_block = std::string(block_name) + " (" + name + "), OUI " + ouitohex(oui); - if (reverse) - fail((std::string("OUI ") + ouitohex(oui) + " is in the wrong byte order\n").c_str()); + if (valid_ascii) + warn("Unknown OUI %s (possible PNP %s).\n", buf.c_str(), ascii); + else + warn("Unknown OUI %s.\n", buf.c_str()); } } - if (ouinum) *ouinum = oui; } std::string ouitohex(unsigned oui) diff --git a/edid-decode.h b/edid-decode.h index c53dba3..9f73e9c 100644 --- a/edid-decode.h +++ b/edid-decode.h @@ -334,7 +334,8 @@ struct edid_state { void list_dmts(); void list_established_timings(); - void data_block_oui(const char *block_name, const unsigned char *x, unsigned length, unsigned *ouinum); + void data_block_oui(std::string block_name, const unsigned char *x, unsigned length, unsigned *ouinum, + bool ignorezeros = false, bool do_ascii = false, bool big_endian = false); void print_vic_index(const char *prefix, unsigned idx, const char *suffix, bool ycbcr420 = false); void hdmi_latency(unsigned char vid_lat, unsigned char aud_lat, bool is_ilaced); @@ -460,7 +461,7 @@ void hex_block(const char *prefix, const unsigned char *x, unsigned length, bool show_ascii = true, unsigned step = 16); std::string block_name(unsigned char block); void calc_ratio(struct timings *t); -const char *oui_name(unsigned oui, bool reverse = false); +const char *oui_name(unsigned oui, unsigned *ouinum = NULL); bool timings_close_match(const timings &t1, const timings &t2); const struct timings *find_dmt_id(unsigned char dmt_id); @@ -471,4 +472,7 @@ const struct timings *cta_close_match_to_vic(const timings &t, unsigned &vic); unsigned char hdmi_vic_to_vic(unsigned char hdmi_vic); char *extract_string(const unsigned char *x, unsigned len); +#define oneoui(c,k,n) const unsigned kOUI_##k = __LINE__<<12; +#include "oui.h" + #endif diff --git a/oui.h b/oui.h new file mode 100644 index 0000000..c90f025 --- /dev/null +++ b/oui.h @@ -0,0 +1,20 @@ +// http://standards-oui.ieee.org/oui/oui.txt +oneoui(0x000c03, HDMI, "HDMI" ) +oneoui(0xc45dd8, HDMIForum, "HDMI Forum" ) +oneoui(0x90848b, HDR10, "HDR10+" ) +oneoui(0x00001a, AMD, "AMD" ) +oneoui(0x00044b, NVIDIA, "NVIDIA" ) +oneoui(0x000c6e, ASUS, "ASUS" ) +oneoui(0x0010fa, Apple, "Apple" ) +oneoui(0x0014b9, MSTAR, "MSTAR" ) +oneoui(0x00d046, Dolby, "Dolby" ) +oneoui(0x00e047, InFocus, "InFocus" ) +oneoui(0xca125c, Microsoft, "Microsoft" ) + +// http://standards-oui.ieee.org/cid/cid.txt +oneoui(0x3a0292, VESA, "VESA" ) + +// https://uefi.org/pnp_id_list +oneoui('APP\0' , asciiApple, "Apple" ) + +#undef oneoui diff --git a/parse-cta-block.cpp b/parse-cta-block.cpp index 13b3b73..71e0041 100644 --- a/parse-cta-block.cpp +++ b/parse-cta-block.cpp @@ -2029,9 +2029,10 @@ static void cta_hdmi_audio_block(const unsigned char *x, unsigned length) #define data_block_o(n) \ do { \ - data_block_oui(n, x, length, &oui); \ + data_block_oui(n, x, length, &ouinum); \ x += (length < 3) ? length : 3; \ length -= (length < 3) ? length : 3; \ + dooutputname = false; \ } while(0) void edid_state::cta_block(const unsigned char *x, bool duplicate) @@ -2047,7 +2048,8 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) x++; } - unsigned oui; + unsigned ouinum = 0; + bool dooutputname = true; bool audio_block = false; data_block.clear(); @@ -2100,7 +2102,7 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) warn("%s.\n", unknown_name.c_str()); } - if (data_block.length()) + if (dooutputname && data_block.length()) printf(" %s:\n", data_block.c_str()); switch (tag) { @@ -2124,53 +2126,37 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) if (audio_block && !(cta.byte3 & 0x40)) fail("Audio information is present, but bit 6 of Byte 3 of the CTA-861 Extension header indicates no Basic Audio support.\n"); + tag |= ouinum; switch (tag) { case 0x01: cta_audio_block(x, length); break; case 0x02: cta_svd(x, length, false); break; - case 0x03: - if (oui == 0x000c03) { - cta_hdmi_block(x, length); - cta.last_block_was_hdmi_vsdb = 1; - cta.block_number++; - // The HDMI OUI is present, so this EDID represents an HDMI - // interface. And HDMI interfaces must use EDID version 1.3 - // according to the HDMI Specification, so check for this. - if (base.edid_minor != 3) - fail("The HDMI Specification requires EDID 1.3 instead of 1.%u.\n", - base.edid_minor); - return; - } - if (oui == 0xc45dd8) { - if (!cta.last_block_was_hdmi_vsdb) - fail("HDMI Forum VSDB did not immediately follow the HDMI VSDB.\n"); - if (cta.have_hf_scdb || cta.have_hf_vsdb) - fail("Duplicate HDMI Forum VSDB/SCDB.\n"); - cta_hf_scdb(x, length); - cta.have_hf_vsdb = 1; - break; - } - if (oui == 0x00001a) { - cta_amd(x, length); - break; - } - if (oui == 0xca125c && length == 0x12) { - cta_microsoft(x, length); - break; - } - hex_block(" ", x, length); + case 0x03|kOUI_HDMI: + cta_hdmi_block(x, length); + cta.last_block_was_hdmi_vsdb = 1; + cta.block_number++; + // The HDMI OUI is present, so this EDID represents an HDMI + // interface. And HDMI interfaces must use EDID version 1.3 + // according to the HDMI Specification, so check for this. + if (base.edid_minor != 3) + fail("The HDMI Specification requires EDID 1.3 instead of 1.%u.\n", + base.edid_minor); + return; + case 0x03|kOUI_HDMIForum: + if (!cta.last_block_was_hdmi_vsdb) + fail("HDMI Forum VSDB did not immediately follow the HDMI VSDB.\n"); + if (cta.have_hf_scdb || cta.have_hf_vsdb) + fail("Duplicate HDMI Forum VSDB/SCDB.\n"); + cta_hf_scdb(x, length); + cta.have_hf_vsdb = 1; break; + case 0x03|kOUI_AMD: cta_amd(x, length); break; + case 0x03|kOUI_Microsoft: if (length != 0x12) goto dodefault; cta_microsoft(x, length); break; case 0x04: cta_sadb(x, length); break; case 0x05: cta_vesa_dtcdb(x, length); break; case 0x07: fail("Extended tag cannot have zero length.\n"); break; case 0x700: cta_vcdb(x, length); break; - case 0x701: - if (oui == 0x90848b) - cta_hdr10plus(x, length); - else if (oui == 0x00d046) - cta_dolby_video(x, length); - else - hex_block(" ", x, length); - break; + case 0x701|kOUI_HDR10: cta_hdr10plus(x, length); break; + case 0x701|kOUI_Dolby: cta_dolby_video(x, length); break; case 0x702: cta_vesa_vdddb(x, length); break; case 0x705: cta_colorimetry_block(x, length); break; case 0x706: cta_hdr_static_metadata_block(x, length); break; @@ -2178,12 +2164,7 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) case 0x70d: cta_vfpdb(x, length); break; case 0x70e: cta_svd(x, length, true); break; case 0x70f: cta_y420cmdb(x, length); break; - case 0x711: - if (oui == 0x00d046) - cta_dolby_audio(x, length); - else - hex_block(" ", x, length); - break; + case 0x711|kOUI_Dolby: cta_dolby_audio(x, length); break; case 0x712: cta_hdmi_audio_block(x, length); break; case 0x713: cta_rcdb(x, length); break; case 0x714: cta_sldb(x, length); break; @@ -2212,6 +2193,7 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) cta_hf_scdb(x + 2, length - 2); cta.have_hf_scdb = 1; break; +dodefault: default: hex_block(" ", x, length); } diff --git a/parse-displayid-block.cpp b/parse-displayid-block.cpp index 269444b..597005e 100644 --- a/parse-displayid-block.cpp +++ b/parse-displayid-block.cpp @@ -1651,16 +1651,23 @@ void edid_state::preparse_displayid_block(const unsigned char *x) } } +#define data_block_o(n, a, b) \ +do { \ + data_block_oui(n, x + 3, len, &ouinum, tag == 0, a, b); \ + dooutputname = false; \ +} while (0) + unsigned edid_state::displayid_block(const unsigned version, const unsigned char *x, unsigned length) { unsigned i; unsigned tag = x[0]; - unsigned oui = 0; + unsigned ouinum = 0; + bool dooutputname = true; unsigned len = (length < 3) ? 0 : x[2]; switch (tag) { // DisplayID 1.3: - case 0x00: data_block = "Product Identification Data Block (" + utohex(tag) + ")"; break; + case 0x00: data_block_o("Product Identification Data Block (" + utohex(tag) + ")", true, false); ouinum = 0; break; case 0x01: data_block = "Display Parameters Data Block (" + utohex(tag) + ")"; break; case 0x02: data_block = "Color Characteristics Data Block"; break; case 0x03: data_block = "Video Timing Modes Type 1 - Detailed Timings Data Block"; break; @@ -1682,7 +1689,7 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char case 0x13: data_block = "Video Timing Modes Type 6 - Detailed Timings Data Block"; break; // 0x14 .. 0x7e RESERVED for Additional VESA-defined Data Blocks // DisplayID 2.0 - case 0x20: data_block = "Product Identification Data Block (" + utohex(tag) + ")"; break; + case 0x20: data_block_o("Product Identification Data Block (" + utohex(tag) + ")", false, false); ouinum = 0; break; case 0x21: data_block = "Display Parameters Data Block (" + utohex(tag) + ")"; break; case 0x22: data_block = "Video Timing Modes Type 7 - Detailed Timings Data Block"; break; case 0x23: data_block = "Video Timing Modes Type 8 - Enumerated Timing Codes Data Block"; break; @@ -1695,26 +1702,8 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char case 0x2b: data_block = "Adaptive Sync Data Block"; break; case 0x32: data_block = "Video Timing Modes Type 10 - Formula-based Timings Data Block"; break; // 0x2a .. 0x7d RESERVED for Additional VESA-defined Data Blocks - case 0x7e: // DisplayID 2.0 - case 0x7f: // DisplayID 1.3 - { - oui = (x[3] << 16) + (x[4] << 8) + x[5]; - const char *name = oui_name(oui); - bool reversed = false; - - if (!name) { - name = oui_name(oui, true); - if (name) - reversed = true; - } - if (name) - data_block = "Vendor-Specific Data Block (" + utohex(tag) + ") (" + name + ")"; - else - data_block = "Vendor-Specific Data Block (" + utohex(tag) + "), OUI " + ouitohex(oui); - if (reversed) - fail((std::string("OUI ") + ouitohex(oui) + " is in the wrong byte order.\n").c_str()); - } - break; + case 0x7e: data_block_o("Vendor-Specific Data Block (" + utohex(tag) + ")", false, true); break; // DisplayID 2.0 + case 0x7f: data_block_o("Vendor-Specific Data Block (" + utohex(tag) + ")", true, false); break; // DisplayID 1.3 // 0x80 RESERVED case 0x81: data_block = "CTA-861 DisplayID Data Block"; break; // 0x82 .. 0xff RESERVED @@ -1751,6 +1740,7 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char return length; } + if (dooutputname && data_block.length()) printf(" %s:\n", data_block.c_str()); if (version >= 0x20 && (tag < 0x20 || tag == 0x7f)) @@ -1762,6 +1752,7 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char unsigned block_rev = x[1] & 0x07; + tag |= ouinum; switch (tag) { case 0x00: parse_displayid_product_id(x); break; case 0x01: parse_displayid_parameters(x); break; @@ -1882,14 +1873,9 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char parse_displayid_type_10_timing(&x[3 + i * sz], sz); break; } + case 0x7e|kOUI_VESA: parse_displayid_vesa(x); break; case 0x81: parse_displayid_cta_data_block(x); break; - case 0x7e: - if (oui == 0x3a0292) { - parse_displayid_vesa(x); - break; - } - // fall-through - default: hex_block(" ", x + 3, len); break; + default: hex_block(" ", x + 3 + (ouinum ? 3 : 0), len - (ouinum ? 3 : 0)); break; } if ((tag == 0x00 || tag == 0x20) && From patchwork Sun Sep 26 08:33:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: joevt X-Patchwork-Id: 12518103 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C15DC4332F for ; Sun, 26 Sep 2021 08:34:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2D39C60F93 for ; Sun, 26 Sep 2021 08:34:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229771AbhIZIgY (ORCPT ); Sun, 26 Sep 2021 04:36:24 -0400 Received: from omta001.cacentral1.a.cloudfilter.net ([3.97.99.32]:51462 "EHLO omta001.cacentral1.a.cloudfilter.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229710AbhIZIgX (ORCPT ); Sun, 26 Sep 2021 04:36:23 -0400 Received: from shw-obgw-4001a.ext.cloudfilter.net ([10.228.9.142]) by cmsmtp with ESMTP id U6HQmeyzYczbLUPcVmV5Vj; Sun, 26 Sep 2021 08:34:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=shaw.ca; s=s20180605; t=1632645287; bh=tWJvfTKLSYt+6yR9v1mDxI7t+sMuRVfyvNpyvBWiUYY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ys110x9xkhLl2/m3DUKt+c1wYSiGBTZ9iDPDA8EFwZQSwgwmkJZ6aq926NMGjsS6Z Hv1yJNCqrHzCIj7yD7aOgs42aq1KVODK3gmP3yynHwGKXaxONVaEV6EqjIvj7wJqG8 XJZ8sMZN1OlQrH99lzOrB31W/aaC8u5S+WZf6W+2mIwgu05Rv0lH374Av9dtzyQjJ4 MdheNxbSmC0ahgIK62KT5QDIhuWDlvMte33fiSAiXNeKTkiALApHwwPXaXKrio2nLi Ve8UCzM+yHpUUB1XOn4stGbmDxD9/AyV7H5//5bRJii5Dr+WtRu7MG2GB8Z9s6kKoq 9bLKBUAeLjbmA== Received: from shaw.ca ([70.71.78.228]) by cmsmtp with ESMTPA id UPcQm9l35U9pxUPcUmdRJL; Sun, 26 Sep 2021 08:34:47 +0000 Authentication-Results: ; auth=pass (LOGIN) smtp.auth=joevt@shaw.ca X-Authority-Analysis: v=2.4 cv=Bbi7bph2 c=1 sm=1 tr=0 ts=615030a7 a=qDatE6m/3wxSEG8Wq7h0zQ==:117 a=qDatE6m/3wxSEG8Wq7h0zQ==:17 a=_Dj-zB-qAAAA:8 a=z1wPPsIgj9QItgDB7ekA:9 a=c-cOe7UV8MviEfHuAVEQ:22 From: joevt To: Hans Verkuil Cc: linux-media@vger.kernel.org Subject: [PATCH v2 25/29] edid-decode: more OUI changes Date: Sun, 26 Sep 2021 01:33:26 -0700 Message-Id: <20210926083330.5206-26-joevt@shaw.ca> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210926083330.5206-1-joevt@shaw.ca> References: <20210926083330.5206-1-joevt@shaw.ca> MIME-Version: 1.0 X-CMAE-Envelope: MS4xfNoV77aVFgQdbcvecCL9UfIjJkrcDS0GueKV91Y8wnA+e/wiP70DOgXeQQBUUB5h77XHHZhnj91RsO8kyaG7pQgirYUhjp4u6opsVrn/1PjxD9HsGxLT eEOQl/ImFogCf8sN/qFIyhHetNCNILAbnj6pPEKLfirVuRPzzAQfZA2wque7RTzQidOpdKA9wuSsZDqID7Nkha+a7gHT2HNJ68U= Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Since OUI is part of the tag, we can make the following changes: - Replace cta.last_block_was_hdmi_vsdb with cta.previous_cta_tag. Instead of remembering if the last tag was HDMI VSDB, we can just always remember the last tag value and compare it to the HDMI VSDB tag value. With this change, we can clean up the HDMI VSDB case statement (remove the two lines that also exist at the end of the switch and change the return to a break. - Change found_tags from std::set to std::vector. std::vector not only remembers all the flags, but also their order so you could use it to find the number of tags or the first tag (replace block_number?) or the last tag (replace previous_cta_tag?). We could replace previous_cta_tag except found_tags is separate for DisplayID block for some reason, while previous_cta_tag is used for CTA data blocks in both CTA blocks and DisplayID blocks. Maybe there should be only one found_tags, like there is only one previous_cta_tag. - Remove duplicate parameter from cta_block. Instead, pass the list of found_tags that we want to check for duplicates. This way, the tag value doesn't need to be recalculated. - For blocks with OUI that we don't know how to parse, skip OUI even if it is zero. Make sure length passed to hex_block is not negative. Signed-off-by: Joe van Tunen --- edid-decode.h | 15 ++++++++------- parse-cta-block.cpp | 33 ++++++++++++--------------------- parse-displayid-block.cpp | 27 +++++++++++---------------- 3 files changed, 31 insertions(+), 44 deletions(-) diff --git a/edid-decode.h b/edid-decode.h index 9f73e9c..6a40092 100644 --- a/edid-decode.h +++ b/edid-decode.h @@ -153,7 +153,8 @@ struct edid_state { // CTA-861 block state cta.has_vic_1 = cta.first_svd_might_be_preferred = cta.has_sldb = cta.has_hdmi = cta.has_vcdb = cta.has_vfpdb = false; - cta.last_block_was_hdmi_vsdb = cta.have_hf_vsdb = cta.have_hf_scdb = false; + cta.previous_cta_tag = 0xfff; + cta.have_hf_vsdb = cta.have_hf_scdb = false; cta.block_number = 0; cta.first_svd = true; cta.supported_hdmi_vic_codes = cta.supported_hdmi_vic_vsb_codes = 0; @@ -244,8 +245,8 @@ struct edid_state { vec_timings_ext preferred_timings; bool preparsed_has_t8vtdb; // Keep track of the found Tag/Extended Tag pairs. - // The unsigned value is equal to: (tag << 8) | ext_tag - std::set found_tags; + // The unsigned value is equal to: (tag) | (OUI enum << 12) or (extended tag) | (tag << 8) | (OUI enum << 12) + std::vector found_tags; timings_ext t8vtdb; vec_timings_ext native_timings; bool has_vic_1; @@ -259,7 +260,7 @@ struct edid_state { bool preparsed_sld; bool has_sldb; unsigned short preparsed_phys_addr; - bool last_block_was_hdmi_vsdb; + unsigned previous_cta_tag; bool have_hf_vsdb, have_hf_scdb; unsigned block_number; bool first_svd; @@ -286,8 +287,8 @@ struct edid_state { unsigned native_width, native_height; unsigned block_number; // Keep track of the found CTA-861 Tag/Extended Tag pairs. - // The unsigned value is equal to: (tag << 8) | ext_tag - std::set found_tags; + // The unsigned value is equal to: (tag) | (OUI enum << 12) or (extended tag) | (tag << 8) | (OUI enum << 12) + std::vector found_tags; } dispid; // Block Map block state @@ -350,7 +351,7 @@ struct edid_state { void cta_displayid_type_7(const unsigned char *x, unsigned length); void cta_displayid_type_8(const unsigned char *x, unsigned length); void cta_displayid_type_10(const unsigned char *x, unsigned length); - void cta_block(const unsigned char *x, bool duplicate); + void cta_block(const unsigned char *x, std::vector &found_tags); void preparse_cta_block(const unsigned char *x); void parse_cta_block(const unsigned char *x); void cta_resolve_svr(vec_timings_ext::iterator iter); diff --git a/parse-cta-block.cpp b/parse-cta-block.cpp index 71e0041..9ae7597 100644 --- a/parse-cta-block.cpp +++ b/parse-cta-block.cpp @@ -2029,13 +2029,15 @@ static void cta_hdmi_audio_block(const unsigned char *x, unsigned length) #define data_block_o(n) \ do { \ + unsigned ouinum; \ data_block_oui(n, x, length, &ouinum); \ x += (length < 3) ? length : 3; \ length -= (length < 3) ? length : 3; \ dooutputname = false; \ + tag |= ouinum; \ } while(0) -void edid_state::cta_block(const unsigned char *x, bool duplicate) +void edid_state::cta_block(const unsigned char *x, std::vector &found_tags) { unsigned length = x[0] & 0x1f; unsigned tag=(x[0] & 0xe0) >> 5; @@ -2048,7 +2050,6 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) x++; } - unsigned ouinum = 0; bool dooutputname = true; bool audio_block = false; data_block.clear(); @@ -2118,7 +2119,7 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) case 0x713: case 0x778: case 0x779: - if (duplicate) + if (std::find(found_tags.begin(), found_tags.end(), tag) != found_tags.end()) fail("Only one instance of this Data Block is allowed.\n"); } @@ -2126,28 +2127,25 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) if (audio_block && !(cta.byte3 & 0x40)) fail("Audio information is present, but bit 6 of Byte 3 of the CTA-861 Extension header indicates no Basic Audio support.\n"); - tag |= ouinum; switch (tag) { case 0x01: cta_audio_block(x, length); break; case 0x02: cta_svd(x, length, false); break; case 0x03|kOUI_HDMI: cta_hdmi_block(x, length); - cta.last_block_was_hdmi_vsdb = 1; - cta.block_number++; // The HDMI OUI is present, so this EDID represents an HDMI // interface. And HDMI interfaces must use EDID version 1.3 // according to the HDMI Specification, so check for this. if (base.edid_minor != 3) fail("The HDMI Specification requires EDID 1.3 instead of 1.%u.\n", base.edid_minor); - return; + break; case 0x03|kOUI_HDMIForum: - if (!cta.last_block_was_hdmi_vsdb) + if (cta.previous_cta_tag != (0x03|kOUI_HDMI)) fail("HDMI Forum VSDB did not immediately follow the HDMI VSDB.\n"); if (cta.have_hf_scdb || cta.have_hf_vsdb) fail("Duplicate HDMI Forum VSDB/SCDB.\n"); cta_hf_scdb(x, length); - cta.have_hf_vsdb = 1; + cta.have_hf_vsdb = true; break; case 0x03|kOUI_AMD: cta_amd(x, length); break; case 0x03|kOUI_Microsoft: if (length != 0x12) goto dodefault; cta_microsoft(x, length); break; @@ -2179,7 +2177,7 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) fail("Block starts at a wrong offset.\n"); break; case 0x779: - if (!cta.last_block_was_hdmi_vsdb) + if (cta.previous_cta_tag != (0x03|kOUI_HDMI)) fail("HDMI Forum SCDB did not immediately follow the HDMI VSDB.\n"); if (cta.have_hf_scdb || cta.have_hf_vsdb) fail("Duplicate HDMI Forum VSDB/SCDB.\n"); @@ -2191,7 +2189,7 @@ void edid_state::cta_block(const unsigned char *x, bool duplicate) if (x[0] || x[1]) printf(" Non-zero SCDB reserved fields!\n"); cta_hf_scdb(x + 2, length - 2); - cta.have_hf_scdb = 1; + cta.have_hf_scdb = true; break; dodefault: default: @@ -2199,7 +2197,8 @@ dodefault: } cta.block_number++; - cta.last_block_was_hdmi_vsdb = 0; + cta.previous_cta_tag = tag; + found_tags.push_back(tag); } void edid_state::preparse_cta_block(const unsigned char *x) @@ -2345,15 +2344,7 @@ void edid_state::parse_cta_block(const unsigned char *x) unsigned i; for (i = 4; i < offset; i += (x[i] & 0x1f) + 1) { - unsigned tag = (x[i] & 0xe0) << 3; - - if (tag == 0x700) - tag |= x[i + 1]; - bool duplicate = cta.found_tags.find(tag) != cta.found_tags.end(); - - cta_block(x + i, duplicate); - if (!duplicate) - cta.found_tags.insert(tag); + cta_block(x + i, cta.found_tags); } data_block.clear(); diff --git a/parse-displayid-block.cpp b/parse-displayid-block.cpp index 597005e..a38c90e 100644 --- a/parse-displayid-block.cpp +++ b/parse-displayid-block.cpp @@ -1556,15 +1556,7 @@ void edid_state::parse_displayid_cta_data_block(const unsigned char *x) x += 3; for (i = 0; i < len; i += (x[i] & 0x1f) + 1) { - unsigned tag = (x[i] & 0xe0) << 3; - - if (tag == 0x700) - tag |= x[i + 1]; - bool duplicate = dispid.found_tags.find(tag) != dispid.found_tags.end(); - - cta_block(x + i, duplicate); - if (!duplicate) - dispid.found_tags.insert(tag); + cta_block(x + i, dispid.found_tags); } if (i != len) @@ -1653,21 +1645,25 @@ void edid_state::preparse_displayid_block(const unsigned char *x) #define data_block_o(n, a, b) \ do { \ + unsigned ouinum; \ data_block_oui(n, x + 3, len, &ouinum, tag == 0, a, b); \ dooutputname = false; \ + if (tag != 0x00 && tag != 0x20) tag |= ouinum; \ + hasoui = true; \ } while (0) unsigned edid_state::displayid_block(const unsigned version, const unsigned char *x, unsigned length) { unsigned i; unsigned tag = x[0]; - unsigned ouinum = 0; + unsigned tag_version = (tag < 0x20) ? 1 : (tag < 0x7f) ? 2 : (tag < 0x80) ? 1 : 0; bool dooutputname = true; unsigned len = (length < 3) ? 0 : x[2]; + bool hasoui = false; switch (tag) { // DisplayID 1.3: - case 0x00: data_block_o("Product Identification Data Block (" + utohex(tag) + ")", true, false); ouinum = 0; break; + case 0x00: data_block_o("Product Identification Data Block (" + utohex(tag) + ")", true, false); break; case 0x01: data_block = "Display Parameters Data Block (" + utohex(tag) + ")"; break; case 0x02: data_block = "Color Characteristics Data Block"; break; case 0x03: data_block = "Video Timing Modes Type 1 - Detailed Timings Data Block"; break; @@ -1689,7 +1685,7 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char case 0x13: data_block = "Video Timing Modes Type 6 - Detailed Timings Data Block"; break; // 0x14 .. 0x7e RESERVED for Additional VESA-defined Data Blocks // DisplayID 2.0 - case 0x20: data_block_o("Product Identification Data Block (" + utohex(tag) + ")", false, false); ouinum = 0; break; + case 0x20: data_block_o("Product Identification Data Block (" + utohex(tag) + ")", false, false); break; case 0x21: data_block = "Display Parameters Data Block (" + utohex(tag) + ")"; break; case 0x22: data_block = "Video Timing Modes Type 7 - Detailed Timings Data Block"; break; case 0x23: data_block = "Video Timing Modes Type 8 - Enumerated Timing Codes Data Block"; break; @@ -1743,16 +1739,15 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char if (dooutputname && data_block.length()) printf(" %s:\n", data_block.c_str()); - if (version >= 0x20 && (tag < 0x20 || tag == 0x7f)) + if (version >= 0x20 && tag_version == 1) fail("Use of DisplayID v1.x tag for DisplayID v%u.%u.\n", version >> 4, version & 0xf); - if (version < 0x20 && tag >= 0x20 && tag <= 0x7e) + if (version < 0x20 && tag_version == 2) fail("Use of DisplayID v2.0 tag for DisplayID v%u.%u.\n", version >> 4, version & 0xf); unsigned block_rev = x[1] & 0x07; - tag |= ouinum; switch (tag) { case 0x00: parse_displayid_product_id(x); break; case 0x01: parse_displayid_parameters(x); break; @@ -1875,7 +1870,7 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char } case 0x7e|kOUI_VESA: parse_displayid_vesa(x); break; case 0x81: parse_displayid_cta_data_block(x); break; - default: hex_block(" ", x + 3 + (ouinum ? 3 : 0), len - (ouinum ? 3 : 0)); break; + default: hex_block(" ", x + 3 + (hasoui ? 3 : 0), (len > (hasoui ? 3 : 0)) ? len - (hasoui ? 3 : 0) : 0); break; } if ((tag == 0x00 || tag == 0x20) && From patchwork Sun Sep 26 08:33:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: joevt X-Patchwork-Id: 12518099 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A9DCC43217 for ; Sun, 26 Sep 2021 08:34:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7091560EE0 for ; Sun, 26 Sep 2021 08:34:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229933AbhIZIgY (ORCPT ); Sun, 26 Sep 2021 04:36:24 -0400 Received: from omta001.cacentral1.a.cloudfilter.net ([3.97.99.32]:37615 "EHLO omta001.cacentral1.a.cloudfilter.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbhIZIgX (ORCPT ); Sun, 26 Sep 2021 04:36:23 -0400 Received: from shw-obgw-4001a.ext.cloudfilter.net ([10.228.9.142]) by cmsmtp with ESMTP id U6HQmeyzUczbLUPcVmV5Vk; Sun, 26 Sep 2021 08:34:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=shaw.ca; s=s20180605; t=1632645287; bh=+xC9rUswx3fQVGLBEoMnBRkB4qushvyUmkY8BNtUdbc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Kngfha7iIMcIttn+7uV92unaiAZb2lhW/Hsem1RqBolu2lS8JsB6b+ePpeWUUDsVu w4i1hRSZ1nu9m8fPohBm6TpRb7rHxs0RHLF/1aJAlrdKuqGfku8LOLwkGwluvhyAqF x+wwlzEX1o2AL+XD/mE+dCuaP/GvzoK7S/9pMw9EW9/zQxNI6S9Fq2SkvEDvJLt2ou DX4Xu0cHeCzwtQnvo2ll3c5QNzCJ/fBMj2kuLZxh5TZPBJFFHhRZyJCfMWhpUh0lmB gu3NBbZtRJnFTjOOXLhKomuzpanfSi5nDxGlUNQDwynNtR7oHWdVa2BL1RB2eeFvH2 p21D/cd0moIVg== Received: from shaw.ca ([70.71.78.228]) by cmsmtp with ESMTPA id UPcQm9l35U9pxUPcVmdRJT; Sun, 26 Sep 2021 08:34:47 +0000 Authentication-Results: ; auth=pass (LOGIN) smtp.auth=joevt@shaw.ca X-Authority-Analysis: v=2.4 cv=Bbi7bph2 c=1 sm=1 tr=0 ts=615030a7 a=qDatE6m/3wxSEG8Wq7h0zQ==:117 a=qDatE6m/3wxSEG8Wq7h0zQ==:17 a=_Dj-zB-qAAAA:8 a=lt6d07WIFPTZwTI6txAA:9 a=c-cOe7UV8MviEfHuAVEQ:22 From: joevt To: Hans Verkuil Cc: linux-media@vger.kernel.org Subject: [PATCH v2 26/29] edid-decode: remove extra vendor field Date: Sun, 26 Sep 2021 01:33:27 -0700 Message-Id: <20210926083330.5206-27-joevt@shaw.ca> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210926083330.5206-1-joevt@shaw.ca> References: <20210926083330.5206-1-joevt@shaw.ca> MIME-Version: 1.0 X-CMAE-Envelope: MS4xfNoV77aVFgQdbcvecCL9UfIjJkrcDS0GueKV91Y8wnA+e/wiP70DOgXeQQBUUB5h77XHHZhnj91RsO8kyaG7pQgirYUhjp4u6opsVrn/1PjxD9HsGxLT eEOQl/ImFogCf8sN/qFIyhHetNCNILAbnj6pPEKLfirVuRPzzAQfZA2wque7RTzQidOpdKA9wuSsZDqID7Nkha+a7gHT2HNJ68U= Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org - Since we use the data_block_oui function to get the vendor for the Production Identification Data Block, we don't need to output the vendor OUI or ID separately. data_block_oui is better because it will get the OUI's name (if it is known) and it verifies that the ID is valid ASCII (don't want to print weird control characters). Signed-off-by: Joe van Tunen --- parse-displayid-block.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/parse-displayid-block.cpp b/parse-displayid-block.cpp index a38c90e..ba2c15e 100644 --- a/parse-displayid-block.cpp +++ b/parse-displayid-block.cpp @@ -81,12 +81,6 @@ void edid_state::parse_displayid_product_id(const unsigned char *x) check_displayid_datablock_revision(x[1]); dispid.has_product_identification = true; - if (dispid.version >= 0x20) { - unsigned oui = (x[3] << 16) | (x[4] << 8) | x[5]; - printf(" Vendor OUI %s\n", ouitohex(oui).c_str()); - } else { - printf(" Vendor ID: %c%c%c\n", x[3], x[4], x[5]); - } printf(" Product Code: %u\n", x[6] | (x[7] << 8)); unsigned sn = x[8] | (x[9] << 8) | (x[10] << 16) | (x[11] << 24); if (sn) { From patchwork Sun Sep 26 08:33:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: joevt X-Patchwork-Id: 12518105 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1CE1AC433F5 for ; Sun, 26 Sep 2021 08:34:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 015FE60F93 for ; Sun, 26 Sep 2021 08:34:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229951AbhIZIg0 (ORCPT ); Sun, 26 Sep 2021 04:36:26 -0400 Received: from omta001.cacentral1.a.cloudfilter.net ([3.97.99.32]:51462 "EHLO omta001.cacentral1.a.cloudfilter.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbhIZIgZ (ORCPT ); Sun, 26 Sep 2021 04:36:25 -0400 Received: from shw-obgw-4001a.ext.cloudfilter.net ([10.228.9.142]) by cmsmtp with ESMTP id UC4amfNfCczbLUPcXmV5Vq; Sun, 26 Sep 2021 08:34:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=shaw.ca; s=s20180605; t=1632645289; bh=dQy5ZqKwM5EZ0Z1EXrmc/GIPO2CPrIhxn1M3R01s3dI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=aR6e/g7ybNT9EaaGLVlDcNTaSSWaLF1QD3beszTukaM3/dWdptz6g7XpZ7sKeSSDi UbWKQl5hceRgcpappqlytIT9ih1xQJ14BUOFVWc1LJ1WZDn/novDItG2DoyuTfCKQU 1B0BWXnBpolutoOVBAs+lsbHrDUQ7BAhy2v/HZsU2Y6I5r5+FWfuBtZotUA17MBXbG 5hfzVB1MDR8gqKalaK1+HQ1lb/aNeNreR7oP9uWrUYvssEuhozudRb9gIGOA0BkHEu IiohxWu8kf3awSEcgDZxdVsUeNtOniubNMT267HCLynjsVg/GcXe5fyU5bM9VnIGNh h863bQuiuAC9A== Received: from shaw.ca ([70.71.78.228]) by cmsmtp with ESMTPA id UPcQm9l35U9pxUPcWmdRJh; Sun, 26 Sep 2021 08:34:49 +0000 Authentication-Results: ; auth=pass (LOGIN) smtp.auth=joevt@shaw.ca X-Authority-Analysis: v=2.4 cv=Bbi7bph2 c=1 sm=1 tr=0 ts=615030a9 a=qDatE6m/3wxSEG8Wq7h0zQ==:117 a=qDatE6m/3wxSEG8Wq7h0zQ==:17 a=_Dj-zB-qAAAA:8 a=dLOKK2dYXMX4MAETwpcA:9 a=c-cOe7UV8MviEfHuAVEQ:22 From: joevt To: Hans Verkuil Cc: linux-media@vger.kernel.org Subject: [PATCH v2 28/29] edid-decode: add interesting EDID Date: Sun, 26 Sep 2021 01:33:29 -0700 Message-Id: <20210926083330.5206-29-joevt@shaw.ca> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210926083330.5206-1-joevt@shaw.ca> References: <20210926083330.5206-1-joevt@shaw.ca> MIME-Version: 1.0 X-CMAE-Envelope: MS4xfJBSncQJzUV+HHvi7hQavYn1Kcuyqd7WHuHQQ427TzabV0NqwCuQ2lema/+L4t2HOVAeW+DNBbeScuU3p7bKGQSgSeWiven36N7LjjrIhaz46BVeLVjl H123nH7mnqOh5f4qb2msh3/Gc453BgR/FBKvwBjaQ3ey746QINvsbF/H9ffz1s1ufU+GPvPNRomymfPJqGVDqYF1HcQwYpZjaoo= Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org It contains "Audio information is present, but bit ..." message and "CTA-861 DisplayID Data Block" data block. Looks like nested blocks (CTA blocks in a DisplayID block) need more indenting. Currently, indents are mostly hardcoded so they aren't suited for nested blocks. Maybe we could add indenting using the following: - Store current indent level in edid_state. - Replace printf with printi which will print spaces for current indent level. - For changing indent, you could use indent++ to indent and indent-- to outdent. - Maybe some C++ tricks can be used to automatically outdent: - Call a function that returns an object that has a constructor that increments indent. - Then the destructor can automatically decrement indent when the scope of the object ends. - We could also add a custom indenting string (currently it's two spaces per indent, but we could make it 4 or 8 spaces, or we could make it a tab). Signed-off-by: Joe van Tunen --- data/apple-imac-retina-4k-21.5-inch-late-2015 | Bin 0 -> 256 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 data/apple-imac-retina-4k-21.5-inch-late-2015 GIT binary patch literal 256 zcmZSh4+acu0!9mz_k8u2lw@RCY9L*q;6HI)pz{Vb{(uk$1_nkn;Cq2#!G{971_K3C zhTGhN3=C3IW(^ApEaV*!B0z0_7&3hmlerY204VaG!OYmg$iUgn$k@r**pzW;fp8@= z12cn7@EeAf|NQeA^c&`boC9<1>#X{p4SpIWD#OAYVfW_(? r#eN9@-N+zRX85OK<6b6#4#!KMzyAB*$iSh@$ X-Patchwork-Id: 12518107 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0964C4332F for ; Sun, 26 Sep 2021 08:34:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B490560F93 for ; Sun, 26 Sep 2021 08:34:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229962AbhIZIg0 (ORCPT ); Sun, 26 Sep 2021 04:36:26 -0400 Received: from omta001.cacentral1.a.cloudfilter.net ([3.97.99.32]:37615 "EHLO omta001.cacentral1.a.cloudfilter.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229939AbhIZIg0 (ORCPT ); Sun, 26 Sep 2021 04:36:26 -0400 Received: from shw-obgw-4001a.ext.cloudfilter.net ([10.228.9.142]) by cmsmtp with ESMTP id U6HQmeyzYczbLUPcXmV5Vs; Sun, 26 Sep 2021 08:34:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=shaw.ca; s=s20180605; t=1632645289; bh=O8GtA2gaMBuwNLOvMt64bZNoYUHo7C2r0wuhf1/pcNg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IY9f878Iq/cp/LAM/Li0uzkWG5SlXQzzNGezVGCBUEOlGG/IVS4s4vmL/Ew3FwzX5 JPdNATmc8eritCNd2/g1kelvzqt/Y4WJnt2OLJzISPCQD6NEhu6hvpWcF2Mf9yFjjm QSYzl3H1fZHg6QGfoP8HAF4zHh5N+mL7smSRsCmtjU0e2/6/fTygs+0cGAMVwQDjia nG0rb1ac55kGHZlWgu4ZHyJsyt0xuzTOzw5hk7JBowLN1NHKUdWEWHatjEmY1EtL8K DI603riZFCy3pQaHKJjHs5XGUnZ0qYfABV3SdiYd8Vchhl4LlJBe6thNZ5aZFRdIOG 3mcMpo9TlMsJw== Received: from shaw.ca ([70.71.78.228]) by cmsmtp with ESMTPA id UPcQm9l35U9pxUPcXmdRJk; Sun, 26 Sep 2021 08:34:49 +0000 Authentication-Results: ; auth=pass (LOGIN) smtp.auth=joevt@shaw.ca X-Authority-Analysis: v=2.4 cv=Bbi7bph2 c=1 sm=1 tr=0 ts=615030a9 a=qDatE6m/3wxSEG8Wq7h0zQ==:117 a=qDatE6m/3wxSEG8Wq7h0zQ==:17 a=_Dj-zB-qAAAA:8 a=2NhWfB50d646GWr7k7QA:9 a=c-cOe7UV8MviEfHuAVEQ:22 From: joevt To: Hans Verkuil Cc: linux-media@vger.kernel.org Subject: [PATCH v2 29/29] edid-decode: fix indents Date: Sun, 26 Sep 2021 01:33:30 -0700 Message-Id: <20210926083330.5206-30-joevt@shaw.ca> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210926083330.5206-1-joevt@shaw.ca> References: <20210926083330.5206-1-joevt@shaw.ca> MIME-Version: 1.0 X-CMAE-Envelope: MS4xfJBSncQJzUV+HHvi7hQavYn1Kcuyqd7WHuHQQ427TzabV0NqwCuQ2lema/+L4t2HOVAeW+DNBbeScuU3p7bKGQSgSeWiven36N7LjjrIhaz46BVeLVjl H123nH7mnqOh5f4qb2msh3/Gc453BgR/FBKvwBjaQ3ey746QINvsbF/H9ffz1s1ufU+GPvPNRomymfPJqGVDqYF1HcQwYpZjaoo= Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The indenting was messed up during rebase. Signed-off-by: Joe van Tunen --- parse-displayid-block.cpp | 230 +++++++++++++++++++------------------- 1 file changed, 115 insertions(+), 115 deletions(-) diff --git a/parse-displayid-block.cpp b/parse-displayid-block.cpp index ba2c15e..3fa0759 100644 --- a/parse-displayid-block.cpp +++ b/parse-displayid-block.cpp @@ -1655,80 +1655,80 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char unsigned len = (length < 3) ? 0 : x[2]; bool hasoui = false; - switch (tag) { - // DisplayID 1.3: + switch (tag) { + // DisplayID 1.3: case 0x00: data_block_o("Product Identification Data Block (" + utohex(tag) + ")", true, false); break; - case 0x01: data_block = "Display Parameters Data Block (" + utohex(tag) + ")"; break; - case 0x02: data_block = "Color Characteristics Data Block"; break; - case 0x03: data_block = "Video Timing Modes Type 1 - Detailed Timings Data Block"; break; - case 0x04: data_block = "Video Timing Modes Type 2 - Detailed Timings Data Block"; break; - case 0x05: data_block = "Video Timing Modes Type 3 - Short Timings Data Block"; break; - case 0x06: data_block = "Video Timing Modes Type 4 - DMT Timings Data Block"; break; - case 0x07: data_block = "Supported Timing Modes Type 1 - VESA DMT Timings Data Block"; break; - case 0x08: data_block = "Supported Timing Modes Type 2 - CTA-861 Timings Data Block"; break; - case 0x09: data_block = "Video Timing Range Data Block"; break; - case 0x0a: data_block = "Product Serial Number Data Block"; break; - case 0x0b: data_block = "GP ASCII String Data Block"; break; - case 0x0c: data_block = "Display Device Data Data Block"; break; - case 0x0d: data_block = "Interface Power Sequencing Data Block"; break; - case 0x0e: data_block = "Transfer Characteristics Data Block"; break; - case 0x0f: data_block = "Display Interface Data Block"; break; - case 0x10: data_block = "Stereo Display Interface Data Block (" + utohex(tag) + ")"; break; - case 0x11: data_block = "Video Timing Modes Type 5 - Short Timings Data Block"; break; - case 0x12: data_block = "Tiled Display Topology Data Block (" + utohex(tag) + ")"; break; - case 0x13: data_block = "Video Timing Modes Type 6 - Detailed Timings Data Block"; break; - // 0x14 .. 0x7e RESERVED for Additional VESA-defined Data Blocks - // DisplayID 2.0 + case 0x01: data_block = "Display Parameters Data Block (" + utohex(tag) + ")"; break; + case 0x02: data_block = "Color Characteristics Data Block"; break; + case 0x03: data_block = "Video Timing Modes Type 1 - Detailed Timings Data Block"; break; + case 0x04: data_block = "Video Timing Modes Type 2 - Detailed Timings Data Block"; break; + case 0x05: data_block = "Video Timing Modes Type 3 - Short Timings Data Block"; break; + case 0x06: data_block = "Video Timing Modes Type 4 - DMT Timings Data Block"; break; + case 0x07: data_block = "Supported Timing Modes Type 1 - VESA DMT Timings Data Block"; break; + case 0x08: data_block = "Supported Timing Modes Type 2 - CTA-861 Timings Data Block"; break; + case 0x09: data_block = "Video Timing Range Data Block"; break; + case 0x0a: data_block = "Product Serial Number Data Block"; break; + case 0x0b: data_block = "GP ASCII String Data Block"; break; + case 0x0c: data_block = "Display Device Data Data Block"; break; + case 0x0d: data_block = "Interface Power Sequencing Data Block"; break; + case 0x0e: data_block = "Transfer Characteristics Data Block"; break; + case 0x0f: data_block = "Display Interface Data Block"; break; + case 0x10: data_block = "Stereo Display Interface Data Block (" + utohex(tag) + ")"; break; + case 0x11: data_block = "Video Timing Modes Type 5 - Short Timings Data Block"; break; + case 0x12: data_block = "Tiled Display Topology Data Block (" + utohex(tag) + ")"; break; + case 0x13: data_block = "Video Timing Modes Type 6 - Detailed Timings Data Block"; break; + // 0x14 .. 0x7e RESERVED for Additional VESA-defined Data Blocks + // DisplayID 2.0 case 0x20: data_block_o("Product Identification Data Block (" + utohex(tag) + ")", false, false); break; - case 0x21: data_block = "Display Parameters Data Block (" + utohex(tag) + ")"; break; - case 0x22: data_block = "Video Timing Modes Type 7 - Detailed Timings Data Block"; break; - case 0x23: data_block = "Video Timing Modes Type 8 - Enumerated Timing Codes Data Block"; break; - case 0x24: data_block = "Video Timing Modes Type 9 - Formula-based Timings Data Block"; break; - case 0x25: data_block = "Dynamic Video Timing Range Limits Data Block"; break; - case 0x26: data_block = "Display Interface Features Data Block"; break; - case 0x27: data_block = "Stereo Display Interface Data Block (" + utohex(tag) + ")"; break; - case 0x28: data_block = "Tiled Display Topology Data Block (" + utohex(tag) + ")"; break; - case 0x29: data_block = "ContainerID Data Block"; break; - case 0x2b: data_block = "Adaptive Sync Data Block"; break; - case 0x32: data_block = "Video Timing Modes Type 10 - Formula-based Timings Data Block"; break; - // 0x2a .. 0x7d RESERVED for Additional VESA-defined Data Blocks + case 0x21: data_block = "Display Parameters Data Block (" + utohex(tag) + ")"; break; + case 0x22: data_block = "Video Timing Modes Type 7 - Detailed Timings Data Block"; break; + case 0x23: data_block = "Video Timing Modes Type 8 - Enumerated Timing Codes Data Block"; break; + case 0x24: data_block = "Video Timing Modes Type 9 - Formula-based Timings Data Block"; break; + case 0x25: data_block = "Dynamic Video Timing Range Limits Data Block"; break; + case 0x26: data_block = "Display Interface Features Data Block"; break; + case 0x27: data_block = "Stereo Display Interface Data Block (" + utohex(tag) + ")"; break; + case 0x28: data_block = "Tiled Display Topology Data Block (" + utohex(tag) + ")"; break; + case 0x29: data_block = "ContainerID Data Block"; break; + case 0x2b: data_block = "Adaptive Sync Data Block"; break; + case 0x32: data_block = "Video Timing Modes Type 10 - Formula-based Timings Data Block"; break; + // 0x2a .. 0x7d RESERVED for Additional VESA-defined Data Blocks case 0x7e: data_block_o("Vendor-Specific Data Block (" + utohex(tag) + ")", false, true); break; // DisplayID 2.0 case 0x7f: data_block_o("Vendor-Specific Data Block (" + utohex(tag) + ")", true, false); break; // DisplayID 1.3 - // 0x80 RESERVED + // 0x80 RESERVED case 0x81: data_block = "CTA-861 DisplayID Data Block"; break; - // 0x82 .. 0xff RESERVED - default: data_block = "Unknown DisplayID Data Block (" + utohex(tag) + ")"; break; - } + // 0x82 .. 0xff RESERVED + default: data_block = "Unknown DisplayID Data Block (" + utohex(tag) + ")"; break; + } - if (length < 3) { + if (length < 3) { // Report a problem when the remaining bytes are not 0. data_block.clear(); // Probably not a Data Block so clear this. if (tag || (length > 1 && x[1])) { printf(" Filler:\n"); fail("Not enough bytes remain (%d) for a DisplayID data block and the DisplayID filler is non-0.\n", length); hex_block(" ", x, length); - } - return length; } + return length; + } - if (length < len + 3) { + if (length < len + 3) { data_block.clear(); // Probably not a Data Block so clear this. printf(" Filler:\n"); - fail("The length of this DisplayID data block (%d) exceeds the number of bytes remaining (%d).\n", len + 3, length); + fail("The length of this DisplayID data block (%d) exceeds the number of bytes remaining (%d).\n", len + 3, length); hex_block(" ", x, length); return length; - } + } - if (!tag && !len) { - // A Product Identification Data Block with no payload bytes is not valid - assume this is the end. + if (!tag && !len) { + // A Product Identification Data Block with no payload bytes is not valid - assume this is the end. data_block.clear(); // Probably not a Product Identification Data Block so clear this. if (!memchk(x, length)) { printf(" Filler:\n"); - fail("Non-0 filler bytes in the DisplayID block.\n"); + fail("Non-0 filler bytes in the DisplayID block.\n"); hex_block(" ", x, length); - } - return length; } + return length; + } if (dooutputname && data_block.length()) printf(" %s:\n", data_block.c_str()); @@ -1742,135 +1742,135 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char unsigned block_rev = x[1] & 0x07; - switch (tag) { + switch (tag) { case 0x00: parse_displayid_product_id(x); break; case 0x01: parse_displayid_parameters(x); break; case 0x02: parse_displayid_color_characteristics(x); break; - case 0x03: + case 0x03: check_displayid_datablock_revision(x[1], 0, block_rev & 1); - for (i = 0; i < len / 20; i++) + for (i = 0; i < len / 20; i++) parse_displayid_type_1_7_timing(&x[3 + (i * 20)], false, block_rev); - break; - case 0x04: + break; + case 0x04: check_displayid_datablock_revision(x[1]); - for (i = 0; i < len / 11; i++) + for (i = 0; i < len / 11; i++) parse_displayid_type_2_timing(&x[3 + (i * 11)]); - break; - case 0x05: + break; + case 0x05: check_displayid_datablock_revision(x[1], 0, block_rev & 1); - for (i = 0; i < len / 3; i++) + for (i = 0; i < len / 3; i++) parse_displayid_type_3_timing(&x[3 + (i * 3)]); - break; - case 0x06: + break; + case 0x06: check_displayid_datablock_revision(x[1], 0xc0, 1); - for (i = 0; i < len; i++) + for (i = 0; i < len; i++) parse_displayid_type_4_8_timing((x[1] & 0xc0) >> 6, x[3 + i]); - break; - case 0x07: + break; + case 0x07: check_displayid_datablock_revision(x[1]); - for (i = 0; i < min(len, 10) * 8; i++) + for (i = 0; i < min(len, 10) * 8; i++) if (x[3 + i / 8] & (1 << (i % 8))) { - char type[16]; - sprintf(type, "DMT 0x%02x", i + 1); - print_timings(" ", find_dmt_id(i + 1), type); - } - break; - case 0x08: + char type[16]; + sprintf(type, "DMT 0x%02x", i + 1); + print_timings(" ", find_dmt_id(i + 1), type); + } + break; + case 0x08: check_displayid_datablock_revision(x[1]); - for (i = 0; i < min(len, 8) * 8; i++) + for (i = 0; i < min(len, 8) * 8; i++) if (x[3 + i / 8] & (1 << (i % 8))) { - char type[16]; - sprintf(type, "VIC %3u", i + 1); - print_timings(" ", find_vic_id(i + 1), type); - } - break; + char type[16]; + sprintf(type, "VIC %3u", i + 1); + print_timings(" ", find_vic_id(i + 1), type); + } + break; case 0x09: parse_displayid_video_timing_range_limits(x); break; - case 0x0a: + case 0x0a: case 0x0b: parse_displayid_string(x); break; case 0x0c: parse_displayid_display_device(x); break; case 0x0d: parse_displayid_intf_power_sequencing(x); break; case 0x0e: parse_displayid_transfer_characteristics(x); break; case 0x0f: parse_displayid_display_intf(x); break; case 0x10: parse_displayid_stereo_display_intf(x); break; - case 0x11: + case 0x11: check_displayid_datablock_revision(x[1]); - for (i = 0; i < len / 7; i++) + for (i = 0; i < len / 7; i++) parse_displayid_type_5_timing(&x[3 + (i * 7)]); - break; + break; case 0x12: parse_displayid_tiled_display_topology(x, false); break; - case 0x13: + case 0x13: check_displayid_datablock_revision(x[1]); for (i = 0; i < len; i += (x[3 + i + 2] & 0x40) ? 17 : 14) parse_displayid_type_6_timing(&x[3 + i]); - break; + break; case 0x20: parse_displayid_product_id(x); break; - case 0x21: - if (block_rev >= 1) + case 0x21: + if (block_rev >= 1) check_displayid_datablock_revision(x[1], 0x80, 1); - else + else check_displayid_datablock_revision(x[1], 0x80, 0); parse_displayid_parameters_v2(x, block_rev); - break; - case 0x22: { - unsigned sz = 20; + break; + case 0x22: { + unsigned sz = 20; - if (block_rev >= 2) + if (block_rev >= 2) check_displayid_datablock_revision(x[1], 0x08, 2); - else if (block_rev == 1) + else if (block_rev == 1) check_displayid_datablock_revision(x[1], 0x08, 1); - else + else check_displayid_datablock_revision(x[1]); sz += (x[1] & 0x70) >> 4; if (block_rev >= 1 && (x[1] & 0x08)) - printf(" These timings support DSC pass-through\n"); - for (i = 0; i < len / sz; i++) + printf(" These timings support DSC pass-through\n"); + for (i = 0; i < len / sz; i++) parse_displayid_type_1_7_timing(&x[3 + i * sz], true, block_rev); - break; - } - case 0x23: - if (block_rev) + break; + } + case 0x23: + if (block_rev) check_displayid_datablock_revision(x[1], 0xe8, 1); - else + else check_displayid_datablock_revision(x[1], 0xc8); if (x[1] & 0x08) { - for (i = 0; i < len / 2; i++) + for (i = 0; i < len / 2; i++) parse_displayid_type_4_8_timing((x[1] & 0xc0) >> 6, x[3 + i * 2] | (x[4 + i * 2] << 8)); - } else { - for (i = 0; i < len; i++) + } else { + for (i = 0; i < len; i++) parse_displayid_type_4_8_timing((x[1] & 0xc0) >> 6, x[3 + i]); - } - break; - case 0x24: + } + break; + case 0x24: check_displayid_datablock_revision(x[1]); - for (i = 0; i < len / 6; i++) + for (i = 0; i < len / 6; i++) parse_displayid_type_9_timing(&x[3 + i * 6]); - break; + break; case 0x25: parse_displayid_dynamic_video_timings_range_limits(x); break; case 0x26: parse_displayid_interface_features(x); break; case 0x27: parse_displayid_stereo_display_intf(x); break; case 0x28: parse_displayid_tiled_display_topology(x, true); break; case 0x29: parse_displayid_ContainerID(x); break; case 0x2b: parse_displayid_adaptive_sync(x); break; - case 0x32: { + case 0x32: { unsigned sz = 6 + ((x[1] & 0x70) >> 4); check_displayid_datablock_revision(x[1], 0x70); - for (i = 0; i < len / sz; i++) + for (i = 0; i < len / sz; i++) parse_displayid_type_10_timing(&x[3 + i * sz], sz); - break; - } + break; + } case 0x7e|kOUI_VESA: parse_displayid_vesa(x); break; case 0x81: parse_displayid_cta_data_block(x); break; default: hex_block(" ", x + 3 + (hasoui ? 3 : 0), (len > (hasoui ? 3 : 0)) ? len - (hasoui ? 3 : 0) : 0); break; - } + } - if ((tag == 0x00 || tag == 0x20) && + if ((tag == 0x00 || tag == 0x20) && (!dispid.is_base_block || dispid.block_number > 0)) - fail("%s is required to be the first DisplayID Data Block.\n", - data_block.c_str()); + fail("%s is required to be the first DisplayID Data Block.\n", + data_block.c_str()); dispid.block_number++; return len + 3;