Received: by 2002:ac8:6714:0:b0:405:464a:c27a with SMTP id e20csp395936qtp; Fri, 28 Jul 2023 05:24:28 -0700 (PDT) X-Google-Smtp-Source: APBJJlH0WGJhX1VnYQkiTzWvei+bJfNC6Wq5X+Yq3tZMfi6ZuwzXEnX4YAShUPk79zW2reGKGkpu X-Received: by 2002:a05:6808:1588:b0:3a3:e6d4:69d6 with SMTP id t8-20020a056808158800b003a3e6d469d6mr3713243oiw.7.1690547068276; Fri, 28 Jul 2023 05:24:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690547068; cv=none; d=google.com; s=arc-20160816; b=VllXMJbDNMyncJrz+NCsAsn0CHz3M+xhcDuLiX5nvbVwQy5pXw4hQlTG9qO/t4gTJf /vzAuN2haqiAlreYdnHoFb5pneAgRDRklyJ0WLjoU9lMMrxjXPbKJ9WjeomyiloSGJF2 DCf/1EhUBQH6jfnUq2GtagKLJhZWGrD+D7RvmAnXRp+H40jHiRnMFrwN8og0+cZsXAcu 9GV2rKIYu2GSnhu6DVx7qMRTlJGExumRzMzOIhTpaRjvho2cPXCqn17RBGSYjOQUehJv CyXVDc0mk6d8LYw9rAGW4t/iMpKVtcfDurSYBhOgkmC6fEV3XjGFBL8SOF9xLBEss+dC 4amA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from; bh=DSCgJ5FhjduJRqSKc/WzaHOyW8d60nUIOaVXenAa4JE=; fh=rP9FHtW2A/h0fXZcKuUf+Qz+2VkvPWabXR/vO5n9PvE=; b=JugX2o3DwBwIl+afbPztwsfIfO7eA0GNlwWGWcqeEpx0CK7EJh/sHerH/p8jaf/qpY gU3yzjn17ZCrifOXlT73FByV06w+thXN199bHued3hWIdiub5Idm0QpYdNJsP5g3F9Vf QOpXuCcQuI0S+sduZwrT5gXkhIO+LAUqH/+rZCMa+Hpt0coSAtM57n63EWKG787pk31V 3B8PoVBheFaWIa5ITcaqGmVqCqGUB7NUlOFO2gFpoJ6JGgs8uF+fRLi5Z3MjJ/ZlTB3g 6cNBbga4xND15+EGSw4ylV3pBf2gQNhjLvnx0ixwlrTyNfifF4JPWbRob3aH0/u9nlwy HkXg== 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 n2-20020a17090ac68200b00263355e8183si3026677pjt.114.2023.07.28.05.24.15; Fri, 28 Jul 2023 05:24:28 -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 S236350AbjG1LzM (ORCPT + 99 others); Fri, 28 Jul 2023 07:55:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236338AbjG1LzJ (ORCPT ); Fri, 28 Jul 2023 07:55:09 -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 ABF964200 for ; Fri, 28 Jul 2023 04:55:04 -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 1qPM3Z-0002Lv-0R; Fri, 28 Jul 2023 13:54:53 +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 1qPM3Y-002hCy-AD; Fri, 28 Jul 2023 13:54:52 +0200 Received: from localhost ([::1] helo=dude03.red.stw.pengutronix.de) by dude03.red.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1qPM3W-008twe-Br; Fri, 28 Jul 2023 13:54:50 +0200 From: Johannes Zink Date: Fri, 28 Jul 2023 13:54:40 +0200 Subject: [PATCH v3 3/3] drm/panel-simple: allow LVDS format override MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230523-simplepanel_support_nondefault_datamapping-v3-3-78ede374d3d9@pengutronix.de> References: <20230523-simplepanel_support_nondefault_datamapping-v3-0-78ede374d3d9@pengutronix.de> In-Reply-To: <20230523-simplepanel_support_nondefault_datamapping-v3-0-78ede374d3d9@pengutronix.de> To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Laurent Pinchart , Thierry Reding , Neil Armstrong , Sam Ravnborg Cc: kernel test robot , Dan Carpenter , patchwork-jzi@pengutronix.de, kernel@pengutronix.de, Laurent Pinchart , dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johannes Zink X-Mailer: b4 0.12.2 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: j.zink@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=ham 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 --- Changes: v2 -> v3: - worked in Laurent's review findings (thanks for reviewing my work): - extract fixing up the bus format to separate function - only call function on LVDS panels - fix typos found by Laurent - simplified error handling v1 -> v2: - fix missing unwind goto found by test robot Reported-by: kernel test robot Reported-by: Dan Carpenter Link: https://lore.kernel.org/r/202304160359.4LHmFOlU-lkp@intel.com/ --- drivers/gpu/drm/panel/panel-simple.c | 55 +++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c index 4badda6570d5..0c25718dcb56 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. @@ -549,6 +550,51 @@ static void panel_simple_parse_panel_timing_node(struct device *dev, dev_err(dev, "Reject override mode: No display_timing found\n"); } +static int panel_simple_override_nondefault_lvds_datamapping(struct device *dev, + struct panel_simple *panel) +{ + int ret, bpc; + + ret = drm_of_lvds_get_data_mapping(dev->of_node); + if (ret < 0) { + if (ret == -EINVAL) + dev_warn(dev, "Ignore invalid data-mapping property\n"); + + /* + * Ignore non-existing or malformatted property, fallback to + * default data-mapping, and return 0. + */ + return 0; + } + + 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 (panel->desc->bpc != bpc || panel->desc->bus_format != ret) { + struct panel_desc *override_desc; + + override_desc = devm_kmemdup(dev, panel->desc, sizeof(*panel->desc), GFP_KERNEL); + if (!override_desc) + return -ENOMEM; + + override_desc->bus_format = ret; + override_desc->bpc = bpc; + panel->desc = override_desc; + } + + return 0; +} + static int panel_simple_probe(struct device *dev, const struct panel_desc *desc) { struct panel_simple *panel; @@ -556,7 +602,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) @@ -601,6 +647,13 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc) panel_simple_parse_panel_timing_node(dev, panel, &dt); } + if (desc->connector_type == DRM_MODE_CONNECTOR_LVDS) { + /* Optional data-mapping property for overriding bus format */ + ret = panel_simple_override_nondefault_lvds_datamapping(dev, panel); + if (ret) + goto free_ddc; + } + connector_type = desc->connector_type; /* Catch common mistakes for panels. */ switch (connector_type) { -- 2.39.2