From patchwork Sat Dec 3 04:35:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Sharma, Shashank" X-Patchwork-Id: 9459527 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A261B60515 for ; Sat, 3 Dec 2016 04:35:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80A3228554 for ; Sat, 3 Dec 2016 04:35:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6157328557; Sat, 3 Dec 2016 04:35:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C1C4F28554 for ; Sat, 3 Dec 2016 04:35:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2E5316E028; Sat, 3 Dec 2016 04:35:31 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1E6456E028 for ; Sat, 3 Dec 2016 04:35:29 +0000 (UTC) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP; 02 Dec 2016 20:35:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.33,733,1477983600"; d="scan'208"; a="1093963696" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga002.fm.intel.com with ESMTP; 02 Dec 2016 20:35:28 -0800 Received: from fmsmsx122.amr.corp.intel.com (10.18.125.37) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.248.2; Fri, 2 Dec 2016 20:35:28 -0800 Received: from bgsmsx106.gar.corp.intel.com (10.223.43.196) by fmsmsx122.amr.corp.intel.com (10.18.125.37) with Microsoft SMTP Server (TLS) id 14.3.248.2; Fri, 2 Dec 2016 20:35:27 -0800 Received: from bgsmsx101.gar.corp.intel.com ([169.254.1.239]) by BGSMSX106.gar.corp.intel.com ([10.223.43.196]) with mapi id 14.03.0248.002; Sat, 3 Dec 2016 10:05:25 +0530 From: "Sharma, Shashank" To: Thierry Reding , "dri-devel@lists.freedesktop.org" Subject: RE: [PATCH v2 2/3] drm/edid: Implement SCDC support detection Thread-Topic: [PATCH v2 2/3] drm/edid: Implement SCDC support detection Thread-Index: AQHSTNG4OOC713BngEW3oGoxLVBZC6D1o0bg Date: Sat, 3 Dec 2016 04:35:24 +0000 Message-ID: References: <20161202192415.16110-1-thierry.reding@gmail.com> <20161202192415.16110-2-thierry.reding@gmail.com> In-Reply-To: <20161202192415.16110-2-thierry.reding@gmail.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.223.10.10] MIME-Version: 1.0 Cc: Jose Abreu X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Hi Thierry, If you can please have a look on this patch, I had written one to parse HF-VSDB, which was covering SCDC detection too. https://patchwork.kernel.org/patch/9452259/ Regards Shashank -----Original Message----- From: Thierry Reding [mailto:thierry.reding@gmail.com] Sent: Saturday, December 3, 2016 12:54 AM To: dri-devel@lists.freedesktop.org Cc: Jani Nikula ; Sharma, Shashank ; Ville Syrjälä ; Jose Abreu Subject: [PATCH v2 2/3] drm/edid: Implement SCDC support detection From: Thierry Reding Sinks compliant with the HDMI 2.0 specification may support SCDC, a mechanism for the source and the sink to communicate. Sinks advertise support for this feature in the HDMI Forum Vendor Specific Data Block as defined in the HDMI 2.0 specification, section 10.4 "Status and Control Data Channel". Implement a small helper that find the HF-VSDB and parses it to check if the sink supports SCDC. Signed-off-by: Thierry Reding --- Changes in v2: - rename internal function to cea_db_is_hdmi_forum_vsdb() for more clarity (Ville Syrjälä) drivers/gpu/drm/drm_edid.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++ include/drm/drm_edid.h | 1 + include/linux/hdmi.h | 1 + 3 files changed, 51 insertions(+) +#define HDMI_FORUM_IEEE_OUI 0xc45dd8 #define HDMI_INFOFRAME_HEADER_SIZE 4 #define HDMI_AVI_INFOFRAME_SIZE 13 #define HDMI_SPD_INFOFRAME_SIZE 25 -- 2.10.2 diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 336be31ff3de..369961597ee5 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -3238,6 +3238,21 @@ static bool cea_db_is_hdmi_vsdb(const u8 *db) return hdmi_id == HDMI_IEEE_OUI; } +static bool cea_db_is_hdmi_forum_vsdb(const u8 *db) { + unsigned int oui; + + if (cea_db_tag(db) != VENDOR_BLOCK) + return false; + + if (cea_db_payload_len(db) < 7) + return false; + + oui = db[3] << 16 | db[2] << 8 | db[1]; + + return oui == HDMI_FORUM_IEEE_OUI; +} + #define for_each_cea_db(cea, i, start, end) \ for ((i) = (start); (i) < (end) && (i) + cea_db_payload_len(&(cea)[(i)]) < (end); (i) += cea_db_payload_len(&(cea)[(i)]) + 1) @@ -3687,6 +3702,40 @@ bool drm_detect_hdmi_monitor(struct edid *edid) EXPORT_SYMBOL(drm_detect_hdmi_monitor); /** + * drm_detect_hdmi_scdc - detect whether an HDMI sink supports SCDC + * @edid: sink EDID information + * + * Parse the CEA extension according to CEA-861-B to find an HF-VSDB as + * defined in HDMI 2.0, section 10.3.2 "HDMI Forum Vendor Specific Data + * Block" and checks if the SCDC_Present bit (bit 7 of byte 6) is set. + * + * Returns: + * True if the sink supports SCDC, false otherwise. + */ +bool drm_detect_hdmi_scdc(struct edid *edid) { + unsigned int start, end, i; + const u8 *cea; + + cea = drm_find_cea_extension(edid); + if (!cea) + return false; + + if (cea_db_offsets(cea, &start, &end)) + return false; + + for_each_cea_db(cea, i, start, end) { + if (cea_db_is_hdmi_forum_vsdb(&cea[i])) { + if (cea[i + 6] & 0x80) + return true; + } + } + + return false; +} +EXPORT_SYMBOL(drm_detect_hdmi_scdc); + +/** * drm_detect_monitor_audio - check monitor audio capability * @edid: EDID block to scan * diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h index 38eabf65f19d..7ea7e90846d8 100644 --- a/include/drm/drm_edid.h +++ b/include/drm/drm_edid.h @@ -440,6 +440,7 @@ int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid); u8 drm_match_cea_mode(const struct drm_display_mode *to_match); enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code); bool drm_detect_hdmi_monitor(struct edid *edid); +bool drm_detect_hdmi_scdc(struct edid *edid); bool drm_detect_monitor_audio(struct edid *edid); bool drm_rgb_quant_range_selectable(struct edid *edid); int drm_add_modes_noedid(struct drm_connector *connector, diff --git a/include/linux/hdmi.h b/include/linux/hdmi.h index edbb4fc674ed..d271ff23984f 100644 --- a/include/linux/hdmi.h +++ b/include/linux/hdmi.h @@ -35,6 +35,7 @@ enum hdmi_infoframe_type { }; #define HDMI_IEEE_OUI 0x000c03