Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4004388rwd; Tue, 23 May 2023 01:27:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ74jmvgI0YSOnC0w6cIeCXnuaFPZK20hegJuupgX/BlVqE/YHz+yESYCWun/8DZgpvfJ2Id X-Received: by 2002:a05:6a00:124b:b0:64d:742f:f590 with SMTP id u11-20020a056a00124b00b0064d742ff590mr5986517pfi.8.1684830450802; Tue, 23 May 2023 01:27:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684830450; cv=none; d=google.com; s=arc-20160816; b=awA++U69C8HolGqZfzoBRb6l/qTbeGfSvgNG4B0gXMHQ9jKLbqKWlcQZvx3RZ9SE1n Uwl4KlOcc+xIpR3B1VBM2HQ378b4BlZr8EX6ViLAp15SJaWesaB07+rdtnrXYHaWVXxR VcTImvX5Pzr9dXjseAQOWaCsp3hxZCJz16kHnOXVPZMpUYvZdBxQ4dBoeChScN9Ast8V Bs4QbVSc2AWQhCcbNVXRC4s5b4mL5T0mUqoBxR/1zFJQ6C/V3W1jz5ZtHrae8F1bj+bR r2+fyOJMsaz17CkqIvgvmF5w+7sEcjeOclhGk+rs/dVojkHBTsOAUdLE8q4tORCBy1// mEIA== 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=YlMcfth1rQAjzRGKwWUvvGdWrgCCjBizFV5Hjc+S4eM=; b=adf6RHhSFZQQAHE05QEN/maycew5sXCzQIaPsO7QSwx3F5MLElAuf2z6z7uwFqjxr0 XZnbkQ9pic2+Y3va3gck03tWzX1IAZAVf2zWf9xhsFd8Swz/jm0jtNK/Qo0So1Uos9gy sqDcrQRFEY3seavp235MPz4EfTWjztmSmVLyb+SkYXELLos5Erp6Rd3MtnKo4MumVz0b s4ZtvEV4aaJlf/gLyZDXG4d7V9f0R+fRTTvS6py6JfNHyyhqQ9jblgYp+loUN7r+kzC6 Xw5+GfsgCYR7wGngW61gshPMdO+ZDmqJoqOvEmNTNZnGIQmtmm7YTwpVeZ3xc1LNeBkh UZMQ== 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 s26-20020aa78bda000000b0064d26a10764si1215807pfd.266.2023.05.23.01.27.18; Tue, 23 May 2023 01:27:30 -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 S236024AbjEWIXd (ORCPT + 99 others); Tue, 23 May 2023 04:23:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236104AbjEWIWq (ORCPT ); Tue, 23 May 2023 04:22:46 -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 81B831730 for ; Tue, 23 May 2023 01:20:03 -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 1q1NFB-00042n-Vr; Tue, 23 May 2023 10:19:46 +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 1q1NFB-002CaW-2S; Tue, 23 May 2023 10:19:45 +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 1q1NF9-006uEf-Pb; Tue, 23 May 2023 10:19:43 +0200 From: Johannes Zink Date: Tue, 23 May 2023 10:19:43 +0200 Subject: [PATCH v2 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-v2-3-87196f0d0b64@pengutronix.de> References: <20230523-simplepanel_support_nondefault_datamapping-v2-0-87196f0d0b64@pengutronix.de> In-Reply-To: <20230523-simplepanel_support_nondefault_datamapping-v2-0-87196f0d0b64@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=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 --- Changes: 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 | 39 +++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c index 2a9c1a785a5c..0a35fdb49ccb 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,42 @@ 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) { + err = -ENOMEM; + goto free_ddc; + } + + 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