Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp756702rwe; Fri, 14 Apr 2023 09:18:00 -0700 (PDT) X-Google-Smtp-Source: AKy350ZtGon+OIVRwZ1oeQN7YJ8MuX6+Q70AdK6cjWIyNxrsdHxnCsDghxidevNlz9YTpIzcjb+5 X-Received: by 2002:a05:6e02:1b0b:b0:329:244e:9ab2 with SMTP id i11-20020a056e021b0b00b00329244e9ab2mr4062047ilv.3.1681489080275; Fri, 14 Apr 2023 09:18:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681489080; cv=none; d=google.com; s=arc-20160816; b=Ekz9RY7upYa0BroZg6CHOz4FkZfwDuCJ+pE8q7Ai4Gp4l8pG8hWfQgdCKH148wgXyk p1zye2o19N83Sm0wLkGsXNTYI8mx0M7HNYBclD0UE5zrl6yZsU5M3wokrOPA12PnSfhq hcwMX+uKZxzSeP3oi7EqtcB69dg5DH+N8sfThn+Qd+rzuAC4E08x74VKp/Yy0w9xUkfP nNbDhrfl7+EA0AjJAywlDhwMBF8kTsoeXlldv5KgvRX3qL6iSyOzHR7ov5+CzJNGV003 JT/GzoWv/TO7E0ApJKV5fSoeTBwudRKeyjFDPcmT1XmC+uDRNNWHdCDEuUbWFwEVQm4R t4Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=icrWhueeRxkZwZ1SjAtDZQwWk3qmS0DmiXtqMSSZS3Y=; b=TW7NP08LsbUyjS0TYBnJ4VwOKUdSNytFYnUIkf9rhPkuHjwCaip/uPztf6uIGkuwQW sTrnOQQp240XajRz7OQwj4FIrYSD/4XX0e/cOREHHGmMPTSsTu5Emp+a+8HUMR4zUwQi oWJGmPYy/0iz5qt4UZf3yuTYnDaT5sWrPoXKEE70aAfd5495IxLRO+B79jf5cCIyWkPn SpX/Kbwjvjg0c4fhO3BKb4tKHui9r/18jcChnaEiGbfOfob/qePXC876JrM+9HSgsJ4D hZVXO5ZfVWJoSFyw+WEcqR2T6oRlMEce8Jzgp4fsmj2fEDgCyzIx0Ln9vXXUd/0V3Q9f FXkg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z22-20020a056638241600b00408fc86a8cesi4999331jat.25.2023.04.14.09.17.46; Fri, 14 Apr 2023 09:18:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229805AbjDNQLd (ORCPT + 99 others); Fri, 14 Apr 2023 12:11:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229836AbjDNQLb (ORCPT ); Fri, 14 Apr 2023 12:11:31 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A404B8A53 for ; Fri, 14 Apr 2023 09:11:30 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pnM1A-00049P-QL; Fri, 14 Apr 2023 18:11:21 +0200 Received: from [2a0a:edc0:0:1101:1d::39] (helo=dude03.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pnM19-00BEra-Ci; Fri, 14 Apr 2023 18:11:19 +0200 Received: from jzi by dude03.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pnM18-00FQvp-Id; Fri, 14 Apr 2023 18:11:18 +0200 From: Johannes Zink To: thierry.reding@gmail.com, sam@ravnborg.org, airlied@gmail.com, daniel@ffwll.ch, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de Cc: Johannes Zink Subject: [PATCH 2/2] drm/panel-simple: allow LVDS format override Date: Fri, 14 Apr 2023 18:11:16 +0200 Message-Id: <20230414161116.3673911-3-j.zink@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414161116.3673911-1-j.zink@pengutronix.de> References: <20230414161116.3673911-1-j.zink@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: jzi@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some panels support multiple LVDS data mapping formats, which can be used e.g. run displays on jeida-18 format when only 3 LVDS lanes are available. Add parsing of an optional data-mapping devicetree property, which also touches up the bits per color to match the bus format. Signed-off-by: Johannes Zink --- drivers/gpu/drm/panel/panel-simple.c | 37 +++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c index 065f378bba9d..7366ad13b3f1 100644 --- a/drivers/gpu/drm/panel/panel-simple.c +++ b/drivers/gpu/drm/panel/panel-simple.c @@ -40,6 +40,7 @@ #include #include #include +#include /** * struct panel_desc - Describes a simple panel. @@ -559,7 +560,7 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc) struct device_node *ddc; int connector_type; u32 bus_flags; - int err; + int err, ret; panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL); if (!panel) @@ -605,6 +606,40 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc) panel_simple_parse_panel_timing_node(dev, panel, &dt); } + + /* optional data-mapping property for overriding bus format */ + ret = drm_of_lvds_get_data_mapping(dev->of_node); + if (ret == -EINVAL) { + dev_warn(dev, "Ignore invalid data-mapping property"); + } else if (ret != -ENODEV) { + int bpc; + + switch (ret) { + default: + WARN_ON(1); + fallthrough; + case MEDIA_BUS_FMT_RGB888_1X7X4_SPWG: + fallthrough; + case MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA: + bpc = 8; + break; + case MEDIA_BUS_FMT_RGB666_1X7X3_SPWG: + bpc = 6; + } + + if (desc->bpc != bpc || desc->bus_format != ret) { + struct panel_desc *override_desc; + + override_desc = devm_kmemdup(dev, desc, sizeof(*desc), GFP_KERNEL); + if (!override_desc) + return -ENOMEM; + + override_desc->bus_format = ret; + override_desc->bpc = bpc; + panel->desc = override_desc; + } + } + connector_type = desc->connector_type; /* Catch common mistakes for panels. */ switch (connector_type) { -- 2.39.2