From patchwork Tue Oct 15 17:25:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Wood X-Patchwork-Id: 3048331 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DBF59BF924 for ; Tue, 15 Oct 2013 21:02:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 84B9620123 for ; Tue, 15 Oct 2013 21:02:03 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 445552011F for ; Tue, 15 Oct 2013 21:02:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3EF80E6356 for ; Tue, 15 Oct 2013 14:02:01 -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 388E3E61EC for ; Tue, 15 Oct 2013 10:25:57 -0700 (PDT) Received: by mail-wg0-f43.google.com with SMTP id b13so4842881wgh.34 for ; Tue, 15 Oct 2013 10:25:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wFkf4R2ZKDzlrVkuuV4zpNxbRyyB+OIplBBH239W9qY=; b=TNcN0URzzY9+/uH3LbzQbrcScUeEIkKei8R0TNVpqRnRrMOoY8PDufRCihYnkOtw+j NM4xGajLb//01OacDYtjYaMeF08RUmeUI3/r1OOAEsFPjdCDVADEivd1CdUP1BtmUEaI 8zBr/0mbyaahLVUT3VF1C+/V04B25WBI6xURAGeSrEnw+eh/9ZwLH7gUOP+HpnPQaN7S JCeQeSEKiPI1XeanV1dk4+vjuihzEgYEexX7kcTK3ao5r+AMQ5gj3+HNgbzyxuq1b5tu 4ShujeqoXy75R1szVeMpEybEFJNmXcU1CqKbb/kibO/arhwOEEspvP9Z+UsKgnQ1qdcp YX6w== X-Gm-Message-State: ALoCoQmMyQP7kgy+ppnfF0WGYuPidHp3pCLkT6TzQ7Sz4nfJbCATkUoGteF1v5DaJSiFxejHCgOA X-Received: by 10.180.86.230 with SMTP id s6mr20570204wiz.64.1381857955948; Tue, 15 Oct 2013 10:25:55 -0700 (PDT) Received: from pistachio.icx.intel.com ([83.217.123.106]) by mx.google.com with ESMTPSA id om10sm2602743wic.5.2013.10.15.10.25.52 for (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128); Tue, 15 Oct 2013 10:25:55 -0700 (PDT) From: Thomas Wood To: ville.syrjala@linux.intel.com Date: Tue, 15 Oct 2013 18:25:27 +0100 Message-Id: <1381857927-3712-2-git-send-email-thomas.wood@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1381857927-3712-1-git-send-email-thomas.wood@intel.com> References: <20131011111214.GT13047@intel.com> <1381857927-3712-1-git-send-email-thomas.wood@intel.com> Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [Intel-gfx] [PATCH v2] drm: add support for additional stereo 3D modes 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 X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, 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 Parse the 3D_Structure_ALL and 3D_MASK fields of the HDMI Vendor Specific Data Block to expose more stereo 3D modes. Signed-off-by: Thomas Wood --- drivers/gpu/drm/drm_edid.c | 105 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 96 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 9e81609..456a694 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -2652,6 +2652,50 @@ static int add_hdmi_mode(struct drm_connector *connector, u8 vic) return 1; } +static int add_3d_struct_modes(struct drm_connector *connector, u16 structure, + const u8 *video_db, u8 video_len, u8 video_index) +{ + struct drm_device *dev = connector->dev; + struct drm_display_mode *newmode; + int modes = 0; + u8 cea_mode; + + if (video_db == NULL || video_index > video_len) + return 0; + + /* CEA modes are numbered 1..127 */ + cea_mode = (video_db[video_index] & 127) - 1; + if (cea_mode >= ARRAY_SIZE(edid_cea_modes)) + return 0; + + if (structure & (1 << 0)) { + newmode = drm_mode_duplicate(dev, &edid_cea_modes[cea_mode]); + if (newmode) { + newmode->flags |= DRM_MODE_FLAG_3D_FRAME_PACKING; + drm_mode_probed_add(connector, newmode); + modes++; + } + } + if (structure & (1 << 6)) { + newmode = drm_mode_duplicate(dev, &edid_cea_modes[cea_mode]); + if (newmode) { + newmode->flags |= DRM_MODE_FLAG_3D_TOP_AND_BOTTOM; + drm_mode_probed_add(connector, newmode); + modes++; + } + } + if (structure & (1 << 8)) { + newmode = drm_mode_duplicate(dev, &edid_cea_modes[cea_mode]); + if (newmode) { + newmode->flags = DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF; + drm_mode_probed_add(connector, newmode); + modes++; + } + } + + return modes; +} + /* * do_hdmi_vsdb_modes - Parse the HDMI Vendor Specific data block * @connector: connector corresponding to the HDMI sink @@ -2662,10 +2706,13 @@ static int add_hdmi_mode(struct drm_connector *connector, u8 vic) * also adds the stereo 3d modes when applicable. */ static int -do_hdmi_vsdb_modes(struct drm_connector *connector, const u8 *db, u8 len) +do_hdmi_vsdb_modes(struct drm_connector *connector, const u8 *db, u8 len, + const u8 *video_db, u8 video_len) { - int modes = 0, offset = 0, i; - u8 vic_len; + int modes = 0, offset = 0, i, multi_present = 0; + u8 vic_len, hdmi_3d_len; + u16 mask; + u16 structure_all; if (len < 8) goto out; @@ -2689,9 +2736,13 @@ do_hdmi_vsdb_modes(struct drm_connector *connector, const u8 *db, u8 len) /* 3D_Present */ offset++; - if (db[8 + offset] & (1 << 7)) + if (db[8 + offset] & (1 << 7)) { modes += add_hdmi_mandatory_stereo_modes(connector); + /* 3D_Multi_present */ + multi_present = (db[8 + offset] & 0x60) >> 5; + } + offset++; vic_len = db[8 + offset] >> 5; @@ -2702,6 +2753,38 @@ do_hdmi_vsdb_modes(struct drm_connector *connector, const u8 *db, u8 len) modes += add_hdmi_mode(connector, vic); } + if (!(multi_present == 1 || multi_present == 2)) + goto out; + + if ((multi_present == 1 && len < (9 + offset)) || + (multi_present == 2 && len < (11 + offset))) + goto out; + + hdmi_3d_len = db[8 + offset] & 0x1f; + + if ((multi_present == 1 && hdmi_3d_len < 2) || + (multi_present == 2 && hdmi_3d_len < 4)) + goto out; + + offset += 1 + vic_len; + + /* 3D_Structure_ALL */ + structure_all = (db[8 + offset] << 8) | db[9 + offset]; + + /* check if 3D_MASK is present */ + if (multi_present == 2) + mask = (db[10 + offset] << 8) | db[11 + offset]; + else + mask = 0xffff; + + for (i = 0; i < 16; i++) { + if (mask & (1 << i)) + modes += add_3d_struct_modes(connector, + structure_all, + video_db, + video_len, i); + } + out: return modes; } @@ -2759,8 +2842,8 @@ static int add_cea_modes(struct drm_connector *connector, struct edid *edid) { const u8 *cea = drm_find_cea_extension(edid); - const u8 *db, *hdmi = NULL; - u8 dbl, hdmi_len; + const u8 *db, *hdmi = NULL, *video = NULL; + u8 dbl, hdmi_len, video_len = 0; int modes = 0; if (cea && cea_revision(cea) >= 3) { @@ -2773,8 +2856,11 @@ add_cea_modes(struct drm_connector *connector, struct edid *edid) db = &cea[i]; dbl = cea_db_payload_len(db); - if (cea_db_tag(db) == VIDEO_BLOCK) - modes += do_cea_modes(connector, db + 1, dbl); + if (cea_db_tag(db) == VIDEO_BLOCK) { + video = db + 1; + video_len = dbl; + modes += do_cea_modes(connector, video, dbl); + } else if (cea_db_is_hdmi_vsdb(db)) { hdmi = db; hdmi_len = dbl; @@ -2787,7 +2873,8 @@ add_cea_modes(struct drm_connector *connector, struct edid *edid) * be patching their flags when the sink supports stereo 3D. */ if (hdmi) - modes += do_hdmi_vsdb_modes(connector, hdmi, hdmi_len); + modes += do_hdmi_vsdb_modes(connector, hdmi, hdmi_len, video, + video_len); return modes; }