From patchwork Thu Sep 27 18:41:07 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Lespiau X-Patchwork-Id: 1515521 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id 816943FC71 for ; Thu, 27 Sep 2012 18:48:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 879679F58D for ; Thu, 27 Sep 2012 11:48:36 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wg0-f43.google.com (mail-wg0-f43.google.com [74.125.82.43]) by gabe.freedesktop.org (Postfix) with ESMTP id 890D19ED6A; Thu, 27 Sep 2012 11:41:21 -0700 (PDT) Received: by mail-wg0-f43.google.com with SMTP id dq11so1424353wgb.12 for ; Thu, 27 Sep 2012 11:41:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:x-mailer:in-reply-to:references; bh=CIb1QGZeUXaHJBIAhnc8MXQtLtcc+53YZLJsVuIuJoY=; b=LxCvCRlCR946NXxkWF2ZJsfKCqw9fZFzYX94Dt0RIPVLMeQ+aRTzC8mZSHvME8PzJp ysWUKUjsHOMWwF9HhhPGmt97AOnAB+bL2DpEepZ6PxjY/MiUa5vd6sWWvqa92QY/kTNU 4IRvNg1k2guf95Bz1YzpPPhj8Hu7M8Ih7RFuYvt2uFeYnYxYBGczAWIhqKFvHP4FuiX2 PbmsoN8v/SCRAwCvALmLA06zqHaz4LlFJ1CJzfsrYemGhm5MWKbZ642sqdsf/u08/7Wf zqcJzk2TRYYzmUdolXOLzvr101mYLNZNekAfqGsbtLwBnMaSHh7PNeavUFc+h8NyVtBk oJJg== Received: by 10.216.195.100 with SMTP id o78mr2020057wen.182.1348771281131; Thu, 27 Sep 2012 11:41:21 -0700 (PDT) Received: from localhost.localdomain ([83.217.123.106]) by mx.google.com with ESMTPS id q7sm14624516wiy.11.2012.09.27.11.41.19 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 27 Sep 2012 11:41:20 -0700 (PDT) From: Damien Lespiau To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Date: Thu, 27 Sep 2012 19:41:07 +0100 Message-Id: <1348771268-3436-3-git-send-email-damien.lespiau@gmail.com> X-Mailer: git-send-email 1.7.11.4 In-Reply-To: <1348771268-3436-1-git-send-email-damien.lespiau@gmail.com> References: <1348771268-3436-1-git-send-email-damien.lespiau@gmail.com> Subject: [Intel-gfx] [PATCH 2/3] drm: Parse the HDMI cea vendor block for 3D present X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org From: Damien Lespiau For now, let's just look at the 3D_present flag of the CEA HDMI vendor block to detect if the sink supports a small list of then mandatory 3D formats. See the HDMI 1.4a 3D extraction for detail: http://www.hdmi.org/manufacturer/specification.aspx Signed-off-by: Damien Lespiau Reviewed-by: Rodrigo Vivi Tested-by: Rodrigo Vivi --- drivers/gpu/drm/drm_edid.c | 87 ++++++++++++++++++++++++++++++++++++++++++++-- include/drm/drm_mode.h | 35 +++++++++++-------- 2 files changed, 105 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index b7ee230..7eecfa0 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -1522,21 +1522,102 @@ do_cea_modes (struct drm_connector *connector, u8 *db, u8 len) return modes; } +static bool cea_hdmi_3d_present(u8 *hdmi) +{ + u8 len, skip = 0; + + len = hdmi[0] & 0x1f; + + if (len < 8) + return false; + + /* no HDMI_Video_present */ + if (!(hdmi[8] & (1<<5))) + return false; + + /* Latency_fields_present */ + if (hdmi[8] & (1 << 7)) + skip += 2; + + /* I_Latency_fields_present */ + if (hdmi[8] & (1 << 6)) + skip += 2; + + /* the declared length is not long enough */ + if (len < (9 + skip)) + return false; + + return (hdmi[9 + skip] & (1 << 7)) != 0; +} + +static const struct { + int width, height, freq; + unsigned int select, value; + unsigned int formats; +} s3d_mandatory_modes[] = { + { 1920, 1080, 24, DRM_MODE_FLAG_INTERLACE, 0, + DRM_MODE_FLAG_3D_TOP_BOTTOM | DRM_MODE_FLAG_3D_FRAME_PACKING }, + { 1920, 1080, 50, DRM_MODE_FLAG_INTERLACE, DRM_MODE_FLAG_INTERLACE, + DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF }, + { 1920, 1080, 60, DRM_MODE_FLAG_INTERLACE, DRM_MODE_FLAG_INTERLACE, + DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF }, + { 1280, 720, 50, DRM_MODE_FLAG_INTERLACE, 0, + DRM_MODE_FLAG_3D_TOP_BOTTOM | DRM_MODE_FLAG_3D_FRAME_PACKING }, + { 1280, 720, 60, DRM_MODE_FLAG_INTERLACE, 0, + DRM_MODE_FLAG_3D_TOP_BOTTOM | DRM_MODE_FLAG_3D_FRAME_PACKING } +}; + +static void cea_hdmi_patch_mandatory_3d_mode(struct drm_display_mode *mode) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(s3d_mandatory_modes); i++) { + if (mode->hdisplay == s3d_mandatory_modes[i].width && + mode->vdisplay == s3d_mandatory_modes[i].height && + (mode->flags & s3d_mandatory_modes[i].select) == + s3d_mandatory_modes[i].value && + drm_mode_vrefresh(mode) == s3d_mandatory_modes[i].freq) { + mode->flags |= s3d_mandatory_modes[i].formats; + } + } +} + +static void cea_hdmi_patch_mandatory_3d_modes(struct drm_connector *connector) +{ + struct drm_display_mode *mode; + + list_for_each_entry(mode, &connector->probed_modes, head) + cea_hdmi_patch_mandatory_3d_mode(mode); +} + static int add_cea_modes(struct drm_connector *connector, struct edid *edid) { u8 * cea = drm_find_cea_extension(edid); - u8 * db, dbl; - int modes = 0; + u8 * db, *hdmi = NULL, dbl; + int modes = 0, vendor_id; + /* let's find the cea modes before looking at the hdmi vendor block + * as the 3d_present flag needs to know about the supported modes + * to infer the 3D modes */ if (cea && cea[1] >= 3) { for (db = cea + 4; db < cea + cea[2]; db += dbl + 1) { dbl = db[0] & 0x1f; - if (((db[0] & 0xe0) >> 5) == VIDEO_BLOCK) + switch ((db[0] & 0xe0) >> 5) { + case VIDEO_BLOCK: modes += do_cea_modes (connector, db+1, dbl); + break; + case VENDOR_BLOCK: + vendor_id = db[1] | db[2] << 8 | db[3] << 16; + if (vendor_id == HDMI_IDENTIFIER) + hdmi = db; + } } } + if (connector->expose_3d_modes && hdmi && cea_hdmi_3d_present(hdmi)) + cea_hdmi_patch_mandatory_3d_modes(connector); + return modes; } diff --git a/include/drm/drm_mode.h b/include/drm/drm_mode.h index 45b19c6..d5d22de 100644 --- a/include/drm/drm_mode.h +++ b/include/drm/drm_mode.h @@ -44,20 +44,27 @@ /* Video mode flags */ /* bit compatible with the xorg definitions. */ -#define DRM_MODE_FLAG_PHSYNC (1<<0) -#define DRM_MODE_FLAG_NHSYNC (1<<1) -#define DRM_MODE_FLAG_PVSYNC (1<<2) -#define DRM_MODE_FLAG_NVSYNC (1<<3) -#define DRM_MODE_FLAG_INTERLACE (1<<4) -#define DRM_MODE_FLAG_DBLSCAN (1<<5) -#define DRM_MODE_FLAG_CSYNC (1<<6) -#define DRM_MODE_FLAG_PCSYNC (1<<7) -#define DRM_MODE_FLAG_NCSYNC (1<<8) -#define DRM_MODE_FLAG_HSKEW (1<<9) /* hskew provided */ -#define DRM_MODE_FLAG_BCAST (1<<10) -#define DRM_MODE_FLAG_PIXMUX (1<<11) -#define DRM_MODE_FLAG_DBLCLK (1<<12) -#define DRM_MODE_FLAG_CLKDIV2 (1<<13) +#define DRM_MODE_FLAG_PHSYNC (1<<0) +#define DRM_MODE_FLAG_NHSYNC (1<<1) +#define DRM_MODE_FLAG_PVSYNC (1<<2) +#define DRM_MODE_FLAG_NVSYNC (1<<3) +#define DRM_MODE_FLAG_INTERLACE (1<<4) +#define DRM_MODE_FLAG_DBLSCAN (1<<5) +#define DRM_MODE_FLAG_CSYNC (1<<6) +#define DRM_MODE_FLAG_PCSYNC (1<<7) +#define DRM_MODE_FLAG_NCSYNC (1<<8) +#define DRM_MODE_FLAG_HSKEW (1<<9) /* hskew provided */ +#define DRM_MODE_FLAG_BCAST (1<<10) +#define DRM_MODE_FLAG_PIXMUX (1<<11) +#define DRM_MODE_FLAG_DBLCLK (1<<12) +#define DRM_MODE_FLAG_CLKDIV2 (1<<13) +#define DRM_MODE_FLAG_3D_TOP_BOTTOM (1<<14) +#define DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF (1<<15) +#define DRM_MODE_FLAG_3D_FRAME_PACKING (1<<16) + +#define DRM_MODE_FLAG_3D_MASK (DRM_MODE_FLAG_3D_TOP_BOTTOM | \ + DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF | \ + DRM_MODE_FLAG_3D_FRAME_PACKING) /* DPMS flags */ /* bit compatible with the xorg definitions. */