From patchwork Fri Oct 31 22:54:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 5207231 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A20A6C11AC for ; Fri, 31 Oct 2014 23:56:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CB5FF20173 for ; Fri, 31 Oct 2014 23:56:39 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id F1BC02014A for ; Fri, 31 Oct 2014 23:56:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6455E6E852; Fri, 31 Oct 2014 16:56:33 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pa0-f48.google.com (mail-pa0-f48.google.com [209.85.220.48]) by gabe.freedesktop.org (Postfix) with ESMTP id 9E1F66E84E for ; Fri, 31 Oct 2014 15:57:28 -0700 (PDT) Received: by mail-pa0-f48.google.com with SMTP id ey11so8566024pad.35 for ; Fri, 31 Oct 2014 15:57:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5NNy90fGnIp++bOrGtJdrPWqG7ilx/oZs04m00iiPNQ=; b=xdVALRic7uT5miQEA2Jo12sc+q8/VthJ+QDgfmFPmz79cQa8CSpDoPdYpuF4wQQo6S Dr864zcUfZfQ7T6nKg8uA6nkzVn6pH2EJ0MNYQRgSdo8s8jmTBwLZAs2P9G061PmXKZ8 /InBrxv4s8XLusd96lpd6GnqnOC8rJpHtgto/EUjyweyVnwolkOxUoj8wJSYPoW1YUxd 75/5Z5539rBEszE5Oytjy270c1brXCRTFGLobPjSjgC4DE9r4nEH14sMvQEnSxufPzys MnNHj/Z2JkLrBGYruRJLj/a0VvroQ0a8iW/7IT/eh/ifSVQGKbDovRuglobejqKAinT8 4+MA== X-Received: by 10.68.68.240 with SMTP id z16mr27472720pbt.70.1414796248530; Fri, 31 Oct 2014 15:57:28 -0700 (PDT) Received: from mothership.mgc.mentorg.com (c-50-152-159-227.hsd1.ca.comcast.net. [50.152.159.227]) by mx.google.com with ESMTPSA id ev8sm10870656pdb.28.2014.10.31.15.57.27 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 31 Oct 2014 15:57:28 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: dri-devel@lists.freedesktop.org Subject: [PATCH 49/72] imx-drm: imx-ldb: Add DDC support Date: Fri, 31 Oct 2014 15:54:32 -0700 Message-Id: <1414796095-10107-50-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1414796095-10107-1-git-send-email-steve_longerbeam@mentor.com> References: <1414796095-10107-1-git-send-email-steve_longerbeam@mentor.com> X-Mailman-Approved-At: Fri, 31 Oct 2014 16:56:32 -0700 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.7 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 Add support for reading EDID over Display Data Channel. If no DDC adapter is available, falls back to hardcoded EDID or display-timings node as before. Signed-off-by: Steve Longerbeam Acked-by: Philipp Zabel --- drivers/staging/imx-drm/imx-ldb.c | 39 +++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/drivers/staging/imx-drm/imx-ldb.c b/drivers/staging/imx-drm/imx-ldb.c index 1eb632f..6c16cf2 100644 --- a/drivers/staging/imx-drm/imx-ldb.c +++ b/drivers/staging/imx-drm/imx-ldb.c @@ -61,6 +61,7 @@ struct imx_ldb_channel { struct drm_connector connector; struct drm_encoder encoder; struct device_node *child; + struct i2c_adapter *ddc; int chno; void *edid; int edid_len; @@ -103,6 +104,9 @@ static int imx_ldb_connector_get_modes(struct drm_connector *connector) imx_ldb_entry_dbg(imx_ldb_ch); + if (!imx_ldb_ch->edid && imx_ldb_ch->ddc) + imx_ldb_ch->edid = drm_get_edid(connector, imx_ldb_ch->ddc); + if (imx_ldb_ch->edid) { drm_mode_connector_update_edid_property(connector, imx_ldb_ch->edid); @@ -529,6 +533,7 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data) for_each_child_of_node(np, child) { struct imx_ldb_channel *channel; + struct device_node *ddc_node; ret = of_property_read_u32(child, "reg", &i); if (ret || i < 0 || i > 1) @@ -547,14 +552,30 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data) channel->chno = i; channel->child = child; - edidp = of_get_property(child, "edid", &channel->edid_len); - if (edidp) { - channel->edid = kmemdup(edidp, channel->edid_len, - GFP_KERNEL); - } else { - ret = of_get_drm_display_mode(child, &channel->mode, 0); - if (!ret) - channel->mode_valid = 1; + ddc_node = of_parse_phandle(child, "ddc-i2c-bus", 0); + if (ddc_node) { + channel->ddc = of_find_i2c_adapter_by_node(ddc_node); + of_node_put(ddc_node); + } + + if (!channel->ddc) { + /* if no DDC available, fallback to hardcoded EDID */ + dev_dbg(dev, "no ddc available\n"); + + edidp = of_get_property(child, "edid", + &channel->edid_len); + if (edidp) { + channel->edid = kmemdup(edidp, + channel->edid_len, + GFP_KERNEL); + } else { + /* fallback to display-timings node */ + ret = of_get_drm_display_mode(child, + &channel->mode, + 0); + if (!ret) + channel->mode_valid = 1; + } } ret = of_property_read_u32(child, "fsl,data-width", &datawidth); @@ -616,6 +637,8 @@ static void imx_ldb_unbind(struct device *dev, struct device *master, channel->connector.funcs->destroy(&channel->connector); channel->encoder.funcs->destroy(&channel->encoder); + + i2c_put_adapter(channel->ddc); } }