From patchwork Thu Apr 19 09:31:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 10349405 X-Patchwork-Delegate: geert@linux-m68k.org 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 D0E7C60244 for ; Thu, 19 Apr 2018 09:36:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C2B27289A2 for ; Thu, 19 Apr 2018 09:36:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B78A6289B5; Thu, 19 Apr 2018 09:36:05 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55073289A2 for ; Thu, 19 Apr 2018 09:36:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752294AbeDSJbf (ORCPT ); Thu, 19 Apr 2018 05:31:35 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:49283 "EHLO relay3-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750990AbeDSJbc (ORCPT ); Thu, 19 Apr 2018 05:31:32 -0400 X-Originating-IP: 2.224.242.101 Received: from w540.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 68A976001E; Thu, 19 Apr 2018 11:31:28 +0200 (CEST) From: Jacopo Mondi To: architt@codeaurora.org, a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com, airlied@linux.ie Cc: Jacopo Mondi , daniel@ffwll.ch, peda@axentia.se, linux-renesas-soc@vger.kernel.org, linux-media@vger.kernel.org, devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/8] drm: bridge: thc63lvd1024: Add support for LVDS mode map Date: Thu, 19 Apr 2018 11:31:04 +0200 Message-Id: <1524130269-32688-4-git-send-email-jacopo+renesas@jmondi.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524130269-32688-1-git-send-email-jacopo+renesas@jmondi.org> References: <1524130269-32688-1-git-send-email-jacopo+renesas@jmondi.org> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The THC63LVD1024 LVDS to RGB bridge supports two different LVDS mapping modes, selectable by means of an external pin. Add support for configurable LVDS input mapping modes, using the newly introduced support for bridge input image formats. Signed-off-by: Jacopo Mondi --- drivers/gpu/drm/bridge/thc63lvd1024.c | 41 +++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/gpu/drm/bridge/thc63lvd1024.c b/drivers/gpu/drm/bridge/thc63lvd1024.c index 48527f8..a3071a1 100644 --- a/drivers/gpu/drm/bridge/thc63lvd1024.c +++ b/drivers/gpu/drm/bridge/thc63lvd1024.c @@ -10,9 +10,15 @@ #include #include +#include #include #include +enum thc63_lvds_mapping_mode { + THC63_LVDS_MAP_MODE2, + THC63_LVDS_MAP_MODE1, +}; + enum thc63_ports { THC63_LVDS_IN0, THC63_LVDS_IN1, @@ -116,6 +122,37 @@ static int thc63_parse_dt(struct thc63_dev *thc63) return 0; } +static int thc63_set_bus_fmt(struct thc63_dev *thc63) +{ + u32 bus_fmt; + u32 map; + int ret; + + ret = of_property_read_u32(thc63->dev->of_node, "thine,map", &map); + if (ret) { + dev_err(thc63->dev, + "Unable to parse property \"thine,map\": %d\n", ret); + return ret; + } + + switch (map) { + case THC63_LVDS_MAP_MODE1: + bus_fmt = MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA; + break; + case THC63_LVDS_MAP_MODE2: + bus_fmt = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG; + break; + default: + dev_err(thc63->dev, + "Invalid value for property \"thine,map\": %u\n", map); + return -EINVAL; + } + + drm_bridge_set_bus_formats(&thc63->bridge, &bus_fmt, 1); + + return 0; +} + static int thc63_gpio_init(struct thc63_dev *thc63) { thc63->oe = devm_gpiod_get_optional(thc63->dev, "oe", GPIOD_OUT_LOW); @@ -166,6 +203,10 @@ static int thc63_probe(struct platform_device *pdev) if (ret) return ret; + ret = thc63_set_bus_fmt(thc63); + if (ret) + return ret; + thc63->bridge.driver_private = thc63; thc63->bridge.of_node = pdev->dev.of_node; thc63->bridge.funcs = &thc63_bridge_func;