From patchwork Fri Feb 17 06:54:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Ying X-Patchwork-Id: 13144364 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A367BC05027 for ; Fri, 17 Feb 2023 06:54:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5M66LYDVKSRczD0R9jtc4j2ri+Sga11riCyvZ17m5Ug=; b=qflvDWy3gwZjyO p946oPIBIKsiCPTDr/bbX15AZr+sVgbZgs4kZGdS6ZNheWi5HWzSf76iMvy/a8VrEi5OVEUhrvFpV mR7b9d/STlQ1fyAUYjN0BBCJtbxpxRxDNq/whQHPcFwYSHMBo3uqmGEgjrrDmbEZaNcJVm00ruCDb pMZC7fMA8qbFDMP3q3Ptk7DedNvNf194QpPjZ45L+cc588HV4bsKnUi6EsQbJhfxnEsoVXDVNU0Nk FK3i8J9PwqUz5ePaTua4NWzRxQ/RS7hFxj2l4no2PLq+etRA9EYJ/96CTXvGFP4S37CtDP/DZBGHc UDyZ6sQWG6hBDJYPWIBQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSucw-00CzKT-Kq; Fri, 17 Feb 2023 06:53:50 +0000 Received: from mail-vi1eur05on20628.outbound.protection.outlook.com ([2a01:111:f400:7d00::628] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSucY-00Cz9S-OB for linux-arm-kernel@lists.infradead.org; Fri, 17 Feb 2023 06:53:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ho19rkWkZPkbbtmwCTdj+HQ+9eo24185EEJM3CrPACq6IUdRU86bHMmXuNbOnkjR3XKRNr9rt6iY2Sva8aofrI2L2s4P4gpclhBbYi42moTO8VTsXyBHZxaQzN1C+v99dDKQxLsFr0gusb67rpBgRgJFgXrzqaptd3j+cxzGQ42nBAxDZiJnMJ/0czGv1OEGgrB3wKVudy7C4+5s9b0b2keuYgb7H1mXxcziljXbY++Pe+gcHSNLhbiDlq4/Iey76a/ib3S8Fp7szpLRkB0TBJboE8qmPaL0jAExe7P2x1HGaq16zydUPcQcyF+zbWp8a+PrV0slCyzBddZsVqYWHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=45Pt7RvBtxBF0Gwzd3YEF57mgnD0zEJn7sUE89fFrxA=; b=jAfHD9Qxi7woyHGntaX66NLYHe593dcX172bwznEf6k6pt6XsvfX4NvB4FBJqXPZ7XeTXweXJczZkmn4f31mSW493h5NoRrvwOeyIBB1M8dvt2blIO3emXMz+Vq15V6ocOVCX91zxO5gXjeQHuGuysAIihPBN+Z7hbZaDPiVlMbX9tWYXdF5OrgNL3tSwtWYppt1lm4f21YAWOx7PClrp/c8sJRwOB5M+w3phISk9/atIF0gYVK1ot282a3WOAJsEANRK4wlhX/HqC1KwJ1wDu70MNZ9f/NH8Jq9tt7FGaHvX+EabOHeD8qzHCiVU+NTqskJBatMLslrzhgCH+WfiQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=45Pt7RvBtxBF0Gwzd3YEF57mgnD0zEJn7sUE89fFrxA=; b=eh0Y253szI2IKXoLkYwwSvvOkapKl+tUVWLQSGcF/Rz8lsRlay8x9y8SlDLaRPzJlX1RL4QN9Yfvspm0ghRF4kKgwLC8CLHZyFsyteEsNhDSwG2+HxgMRfLI8I/Dpso1GSXMS0jph8ICz03MaRXFvfhXrAKKkO1ftxdMzXn5vmU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM7PR04MB7046.eurprd04.prod.outlook.com (2603:10a6:20b:113::22) by AS8PR04MB7541.eurprd04.prod.outlook.com (2603:10a6:20b:29a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.22; Fri, 17 Feb 2023 06:53:24 +0000 Received: from AM7PR04MB7046.eurprd04.prod.outlook.com ([fe80::5725:92ec:f43e:f5fc]) by AM7PR04MB7046.eurprd04.prod.outlook.com ([fe80::5725:92ec:f43e:f5fc%9]) with mapi id 15.20.6111.014; Fri, 17 Feb 2023 06:53:24 +0000 From: Liu Ying To: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: marex@denx.de, stefan@agner.ch, airlied@gmail.com, daniel@ffwll.ch, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, krzysztof.kozlowski@linaro.org, LW@karo-electronics.de, alexander.stein@ew.tq-group.com Subject: [PATCH v4 4/6] drm: lcdif: Check consistent bus format and flags across first bridges Date: Fri, 17 Feb 2023 14:54:05 +0800 Message-Id: <20230217065407.2259731-5-victor.liu@nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230217065407.2259731-1-victor.liu@nxp.com> References: <20230217065407.2259731-1-victor.liu@nxp.com> X-ClientProxiedBy: SI2PR02CA0033.apcprd02.prod.outlook.com (2603:1096:4:195::20) To AM7PR04MB7046.eurprd04.prod.outlook.com (2603:10a6:20b:113::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM7PR04MB7046:EE_|AS8PR04MB7541:EE_ X-MS-Office365-Filtering-Correlation-Id: cb01bddc-0962-45fb-f44e-08db10b3aa51 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tEvc0B/wOgk9G6cy0YmaHukcvcUuJth1TxnYSUy+ICIEWV/SMhpIujwZ7FvlzPpXEA5aMjhiafPjaaW/hksvPV6Q9Lx6zSWtY4MZRLo6Y2bJCv+7mbaM/l0pbAOO1eAS8R5UoYdPWRixwV2PR20PdeKSFbrzAehQtXT18Jpnj10jgqGNILV7oxkIVSkveZfeP6LN92ZJOYajwnVxaMZPM9mfhIevZHpCLP36f/C3kV0afYFY+P9O1uMBd4kzFrsiW1m2uyE/7bg40dkY7UGygvHsYqq8FAI8MFFpYMVfKYU6Is5+1/jxjn6JeUUoziXXAu80Php2Whr0X4MyEE17W5OLWFM4b7QfdwQbCZC/nFSTltGNdL/OOACrKx7nupQkNmN/E1efasGyyyqGXjlK2ycc0CHV35NXRjzjNBdHe3Xxhn+4F5bRnEbyEhzLtrpLAx17btJJDwsaD4xv5qV/KZD1KpynYpjt10+2dBN6HtVmSQ1BJ3vC1V0Xcb8nouZ8iAOOlBO2MItGINCQrShl1SFRHRC4VagQlu8onfRjOr0F2sHZmBMn32y587o0U3ofyGoe2a4WyujOtUeqWKfQHz5xU4ANYbBC98Kwbx2u2fc6R4xu7lSvmBEY5ryHE5WCaSb5ujnFy7PMna4q5WORdfcu5xtwXzailPj4GCNHui3UfdPprk3Frf5C+oiHuxAMYmjbpBpo/pWmUA0RyxRFuA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM7PR04MB7046.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(136003)(366004)(346002)(396003)(376002)(39860400002)(451199018)(186003)(26005)(6486002)(6666004)(478600001)(52116002)(1076003)(6506007)(4326008)(66556008)(66476007)(66946007)(8676002)(7416002)(5660300002)(8936002)(316002)(2906002)(41300700001)(38350700002)(38100700002)(86362001)(6512007)(83380400001)(36756003)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KS1p8LpQHTH8iGGDjY6HsZNauD1AtEwPbIeXXIbot2vE9PTllhdWV6BmPQnbuFafh1M42FbuyAZalRhj2+0YEhK7PSiJqBEq24v3CHfG5iRoWx44qrRtSkri85xpBTF7VMf4OKt3SNYoHfZFRhoPeuEZsN/mY7gsZHZLn9loJg4Ld8clfmNgutj2aRBZNVVnJFqPLm85Gauf3EC0+VL226Iw8raUIKMIJNJxlnOgN9jFgQW3vxLQXIC5+L6U40bc36WFsV6P/wDnP3EGc3mt2grd6jzJbkRILvuE+482HpPnHOBkklpugWVH9NPA8i5FEODQyu/erlTWi+s/RZLmJinfD9tvwlw1HwrnfwlO5BpZW0CstFAxYh5P5k31F4T9SAHb+7bWUWKiZ39wtYoZBGZPEQ0HAEX0pJHi6sD7j+1BijjTkGvL5qfwhI4AS8YremB68UqOgi1L6I3fgTcJ+mJ9ih8g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r4HZO2jt7oIxKGaVtk5xSXiFX1vqPFq32mJ8qeLnd6nmYAiWiZGcbu9Aj+tx9aBGuQjqpbEieKD8K X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: cb01bddc-0962-45fb-f44e-08db10b3aa51 X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7046.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Feb 2023 06:53:24.7790 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1oExaU9NmZNydJDtaIhtSU/k/BMuuk5sv9ZnHYXtnHq1ABipdJQpWg47aolyWu9Nv81Fx9qwdeOdzvGFK9U4Pw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7541 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230216_225326_816125_36721098 X-CRM114-Status: GOOD ( 18.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The single LCDIF embedded in i.MX93 SoC may drive multiple displays simultaneously. Check bus format and flags across first bridges in ->atomic_check() to ensure they are consistent. This is a preparation for adding i.MX93 LCDIF support. Signed-off-by: Liu Ying Acked-by: Alexander Stein --- v3->v4: * No change. v2->v3: * No change. v1->v2: * Split from patch 2/2 in v1. (Marek, Alexander) * Drop a comment about bridge input bus format from lcdif_crtc_atomic_check(). drivers/gpu/drm/mxsfb/lcdif_drv.c | 2 - drivers/gpu/drm/mxsfb/lcdif_drv.h | 1 - drivers/gpu/drm/mxsfb/lcdif_kms.c | 76 ++++++++++++++++++++++--------- 3 files changed, 55 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/mxsfb/lcdif_drv.c b/drivers/gpu/drm/mxsfb/lcdif_drv.c index cc2ceb301b96..b5b9a8e273c6 100644 --- a/drivers/gpu/drm/mxsfb/lcdif_drv.c +++ b/drivers/gpu/drm/mxsfb/lcdif_drv.c @@ -52,8 +52,6 @@ static int lcdif_attach_bridge(struct lcdif_drm_private *lcdif) if (ret) return dev_err_probe(drm->dev, ret, "Failed to attach bridge\n"); - lcdif->bridge = bridge; - return 0; } diff --git a/drivers/gpu/drm/mxsfb/lcdif_drv.h b/drivers/gpu/drm/mxsfb/lcdif_drv.h index 6cdba6e20c02..aa6d099a1897 100644 --- a/drivers/gpu/drm/mxsfb/lcdif_drv.h +++ b/drivers/gpu/drm/mxsfb/lcdif_drv.h @@ -31,7 +31,6 @@ struct lcdif_drm_private { } planes; struct drm_crtc crtc; struct drm_encoder encoder; - struct drm_bridge *bridge; }; static inline struct lcdif_drm_private * diff --git a/drivers/gpu/drm/mxsfb/lcdif_kms.c b/drivers/gpu/drm/mxsfb/lcdif_kms.c index d46de433cd8e..d6009b353a16 100644 --- a/drivers/gpu/drm/mxsfb/lcdif_kms.c +++ b/drivers/gpu/drm/mxsfb/lcdif_kms.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -424,15 +425,19 @@ static int lcdif_crtc_atomic_check(struct drm_crtc *crtc, struct drm_atomic_state *state) { struct drm_device *drm = crtc->dev; - struct lcdif_drm_private *lcdif = to_lcdif_drm_private(drm); struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state, crtc); struct lcdif_crtc_state *lcdif_crtc_state = to_lcdif_crtc_state(crtc_state); bool has_primary = crtc_state->plane_mask & drm_plane_mask(crtc->primary); + struct drm_connector_state *connector_state; + struct drm_connector *connector; + struct drm_encoder *encoder; struct drm_bridge_state *bridge_state; - struct drm_bridge *bridge = lcdif->bridge; - int ret; + struct drm_bridge *bridge; + u32 bus_format, bus_flags; + bool format_set = false, flags_set = false; + int ret, i; /* The primary plane has to be enabled when the CRTC is active. */ if (crtc_state->active && !has_primary) @@ -442,26 +447,55 @@ static int lcdif_crtc_atomic_check(struct drm_crtc *crtc, if (ret) return ret; - bridge_state = drm_atomic_get_new_bridge_state(state, bridge); - if (!bridge_state) - lcdif_crtc_state->bus_format = MEDIA_BUS_FMT_FIXED; - else - lcdif_crtc_state->bus_format = bridge_state->input_bus_cfg.format; - - if (lcdif_crtc_state->bus_format == MEDIA_BUS_FMT_FIXED) { - dev_warn_once(drm->dev, - "Bridge does not provide bus format, assuming MEDIA_BUS_FMT_RGB888_1X24.\n" - "Please fix bridge driver by handling atomic_get_input_bus_fmts.\n"); - lcdif_crtc_state->bus_format = MEDIA_BUS_FMT_RGB888_1X24; + /* Try to find consistent bus format and flags across first bridges. */ + for_each_new_connector_in_state(state, connector, connector_state, i) { + if (!connector_state->crtc) + continue; + + encoder = connector_state->best_encoder; + + bridge = drm_bridge_chain_get_first_bridge(encoder); + if (!bridge) + continue; + + bridge_state = drm_atomic_get_new_bridge_state(state, bridge); + if (!bridge_state) + bus_format = MEDIA_BUS_FMT_FIXED; + else + bus_format = bridge_state->input_bus_cfg.format; + + if (bus_format == MEDIA_BUS_FMT_FIXED) { + dev_warn(drm->dev, + "[ENCODER:%d:%s]'s bridge does not provide bus format, assuming MEDIA_BUS_FMT_RGB888_1X24.\n" + "Please fix bridge driver by handling atomic_get_input_bus_fmts.\n", + encoder->base.id, encoder->name); + bus_format = MEDIA_BUS_FMT_RGB888_1X24; + } + + if (!format_set) { + lcdif_crtc_state->bus_format = bus_format; + format_set = true; + } else if (lcdif_crtc_state->bus_format != bus_format) { + DRM_DEV_DEBUG_DRIVER(drm->dev, "inconsistent bus format\n"); + return -EINVAL; + } + + if (bridge->timings) + bus_flags = bridge->timings->input_bus_flags; + else if (bridge_state) + bus_flags = bridge_state->input_bus_cfg.flags; + else + bus_flags = 0; + + if (!flags_set) { + lcdif_crtc_state->bus_flags = bus_flags; + flags_set = true; + } else if (lcdif_crtc_state->bus_flags != bus_flags) { + DRM_DEV_DEBUG_DRIVER(drm->dev, "inconsistent bus flags\n"); + return -EINVAL; + } } - if (bridge->timings) - lcdif_crtc_state->bus_flags = bridge->timings->input_bus_flags; - else if (bridge_state) - lcdif_crtc_state->bus_flags = bridge_state->input_bus_cfg.flags; - else - lcdif_crtc_state->bus_flags = 0; - return 0; }