From patchwork Thu Sep 24 16:51:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 7258261 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6E252BEEC1 for ; Thu, 24 Sep 2015 16:51:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8F67C2082F for ; Thu, 24 Sep 2015 16:51:47 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 8FB29206A4 for ; Thu, 24 Sep 2015 16:51:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0C8F06EEFD; Thu, 24 Sep 2015 09:51:46 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pa0-f41.google.com (mail-pa0-f41.google.com [209.85.220.41]) by gabe.freedesktop.org (Postfix) with ESMTPS id 141E96EF00 for ; Thu, 24 Sep 2015 09:51:43 -0700 (PDT) Received: by pacfv12 with SMTP id fv12so79160545pac.2 for ; Thu, 24 Sep 2015 09:51:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=mYTy+He2XkDA/Dg0XAPWNCQMwODBhxgWx7dwNaaBkY0=; b=tKYFuLkwCKJxzRUkbMYCn5VRk53i3lBwvt3kbZY2jxHl9ih/BSt6aWi1wOxgv/ykV8 zuGg7RMp5Wx7S6VdSzi8ZCYuU7NcLpqqwZCZjVGUUS6QvzspWnAuls+PpQ9CKRX1ID85 5JCTev5P3B50IPg4s9X6OKjb0LZFkoaB1a513nKqD6v+QQNul8YU/MknjiTySDC5twge 7l87WhKP4fhKbu1WeK+vrigUn1LoT090w/z4oMBwI/znFy4yvaVJjZyxv/Zga0pnsnUX QKZ7nyG+Z7nfnpGTSwsZbCvplhA0bf7JfVNcXUZStWus4Qz6r73LzFAS+RI66y+V3D92 ScLg== X-Received: by 10.69.2.69 with SMTP id bm5mr781306pbd.41.1443113502821; Thu, 24 Sep 2015 09:51:42 -0700 (PDT) Received: from localhost (port-5631.pppoe.wtnet.de. [84.46.22.21]) by smtp.gmail.com with ESMTPSA id vw7sm14633620pab.15.2015.09.24.09.51.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Sep 2015 09:51:42 -0700 (PDT) From: Thierry Reding To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/2] drm/edid: Implement SCDC support detection Date: Thu, 24 Sep 2015 18:51:35 +0200 Message-Id: <1443113495-32491-2-git-send-email-thierry.reding@gmail.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1443113495-32491-1-git-send-email-thierry.reding@gmail.com> References: <1443113495-32491-1-git-send-email-thierry.reding@gmail.com> 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: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/gpu/drm/drm_edid.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++ include/drm/drm_crtc.h | 1 + include/linux/hdmi.h | 1 + 3 files changed, 51 insertions(+) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index d895556be4f0..af4da105d66e 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -3059,6 +3059,21 @@ static bool cea_db_is_hdmi_vsdb(const u8 *db) return hdmi_id == HDMI_IEEE_OUI; } +static bool cea_db_is_hf_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) @@ -3454,6 +3469,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_hf_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_crtc.h b/include/drm/drm_crtc.h index 53a6f2455f35..5d0b88e4a80b 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -1513,6 +1513,7 @@ extern enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code); extern bool drm_detect_hdmi_monitor(struct edid *edid); extern bool drm_detect_monitor_audio(struct edid *edid); extern bool drm_rgb_quant_range_selectable(struct edid *edid); +extern bool drm_detect_hdmi_scdc(struct edid *edid); extern int drm_mode_page_flip_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv); extern int drm_add_modes_noedid(struct drm_connector *connector, diff --git a/include/linux/hdmi.h b/include/linux/hdmi.h index e9744202fa29..f860071e2d5a 100644 --- a/include/linux/hdmi.h +++ b/include/linux/hdmi.h @@ -35,6 +35,7 @@ enum hdmi_infoframe_type { }; #define HDMI_IEEE_OUI 0x000c03 +#define HDMI_FORUM_IEEE_OUI 0xc45dd8 #define HDMI_INFOFRAME_HEADER_SIZE 4 #define HDMI_AVI_INFOFRAME_SIZE 13 #define HDMI_SPD_INFOFRAME_SIZE 25