Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp1130317lqo; Sat, 11 May 2024 08:33:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWHaV0TvpMMd42Ueilk/H+XPCU7SLQ7FloUd8GqZpgZIKGx5HCblWy6yNcb/b0UdxV8JnZq5Fl1ChRNJp66m1zHJ72VQedkidCWxL+/+Q== X-Google-Smtp-Source: AGHT+IGhzOzBYLO3mISCTkCccqahIz9kSH38aRi6WZSavuAZkKQySK8thCBqz7W6Ij9uyuCQElga X-Received: by 2002:a05:6a00:2d9c:b0:6f4:54f1:ccae with SMTP id d2e1a72fcca58-6f4c90b608amr12114137b3a.6.1715441618913; Sat, 11 May 2024 08:33:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715441618; cv=pass; d=google.com; s=arc-20160816; b=ghIfiybAx/u51YhR+7D3Y9Sajewby8orAEyk07hqO37RXcWLyVGHfWQnF/4k3l/JUr LILT4N8nSsJ1V2emP2UiQ+Ux53xhdGv59E5OGcDv49iK+Hr90hnO+RkaV9lm15ofwr71 c2z14IMN2hzv5/U7qPHP1VRtRuT46hu2Vrz2cbJuxNP1qBfW7WK7Nr/p68IGiPg+1Ix+ BTmyjfQp9eilCCDUh0ks7BFnSx0tkpGsPrb7yzYXYSfYs09d3WrDzy9/Ft7S9U8/WIOi JCsXMB0F63ssQu/PTyQPDSBS2VFqH0pQ6gZtNPC83KxPTB9wT+y125a04aV9qdO20Mwg GMLw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=fk0R74ejNAtWO6vhDM0NFCaBa9DRbhEs2Wo/6bUX1hc=; fh=S9bpg2GSVUyHrOpz7OrTZKhBuXBWSWpC7FsdxUCOuBM=; b=Mi65TfVoJZDVjo57NIpvIBqFSsso/k4DRptVUjNNt2rR5NryY3jFWRqb6sBOmPY8N0 m4z4JyrOfTyGHgV163L6b8vNaAW5XummrMHS6q+Eg5qACG0aXjwkE/XNVJ1jNhpltZMd Noq04/huL2rPv5nCD5codEHaEdAiAhZgxyhDJCioumiO1+LiQdmCs3pvBlolX3qDyJ6D 0cAAC/XRPuKW6amgm26CcOzGFOHLwFancDpnDrYMuIedTnpkDDL7I+33r/FNtcKElZyh gGucTFP8/wHBN1K0gMc7jYW/MzM18ZFYqIgSCSUQI8nn/T918EWe6DI8OwxCiFi6V5dr Qs4A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Gw29m6D2; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-176609-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176609-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-6f4d2a9716esi5755447b3a.111.2024.05.11.08.33.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 May 2024 08:33:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-176609-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Gw29m6D2; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-176609-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176609-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 05933B21628 for ; Sat, 11 May 2024 15:32:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 61A0158AD0; Sat, 11 May 2024 15:31:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="Gw29m6D2" Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CDD7A3233 for ; Sat, 11 May 2024 15:31:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.248 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715441500; cv=none; b=ElIKyCBnzuU5UkqoD3wbmoZ3PbXx3G5PybP32OVA4dPkqM1B470u7H5Inwr2TH6C9OqjgY1lsKEMfxNKVzNtqiTFt3iR7YgjclZzuYYKSMDYqJggQHnU0EXSUvBb80H/RBcleb8QywWaRNrIKWhrEmR78FMNXI90i8k1+Xa5C4k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715441500; c=relaxed/simple; bh=mvnFXnP+keq+bj43RVnE2MbMwD12LycLPedBt8DOdis=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=U1iuGMrPNszx3FfIwpKmB75ieCBZsXh68QXgLQuCBjirQcVeerZcNAw7iD73fXczYUu2ozZI+JBU0bu1CZrv7VntlI2hhWDGTluGHfLwstro6txTO571KyeDqDQJ4GMqJOn8baFUVjq5E09zjKJw3c9+voaOwMHeglDal07iYCE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=Gw29m6D2; arc=none smtp.client-ip=198.47.23.248 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 44BFV09f014469; Sat, 11 May 2024 10:31:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1715441460; bh=fk0R74ejNAtWO6vhDM0NFCaBa9DRbhEs2Wo/6bUX1hc=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Gw29m6D2u+PMlzQE3AhtqF2y3G7biUiGhTgqSNX7tg1SYvGTJX/Eq8PqmxvREOFzu xE05EjfnPCKQE7bbLzYWm1JqMQQZsVyhRfYtfNii3FMi86uiMfLS3KSiYRonhbRArE 6H+a+dZkV3qx4gXnwk9GlHKhvVGoYsWUTYedteoA= Received: from DLEE105.ent.ti.com (dlee105.ent.ti.com [157.170.170.35]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 44BFV0LP098507 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Sat, 11 May 2024 10:31:00 -0500 Received: from DLEE108.ent.ti.com (157.170.170.38) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Sat, 11 May 2024 10:31:00 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Sat, 11 May 2024 10:31:00 -0500 Received: from localhost (uda0496377.dhcp.ti.com [172.24.227.31]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 44BFUxUA074866; Sat, 11 May 2024 10:31:00 -0500 From: Aradhya Bhatia To: Tomi Valkeinen , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Jyri Sarha , Thomas Zimmermann , David Airlie , Daniel Vetter CC: DRI Development List , Linux Kernel List , Sam Ravnborg , Thierry Reding , Kieran Bingham , Boris Brezillon , Nishanth Menon , Vignesh Raghavendra , Praneeth Bajjuri , Udit Kumar , Devarsh Thakkar , Jayesh Choudhary , Jai Luthra , Aradhya Bhatia Subject: [PATCH 5/7] drm/bridge: cdns-dsi: Support atomic bridge APIs Date: Sat, 11 May 2024 21:00:49 +0530 Message-ID: <20240511153051.1355825-6-a-bhatia1@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240511153051.1355825-1-a-bhatia1@ti.com> References: <20240511153051.1355825-1-a-bhatia1@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Change the existing (and deparacated) bridge hooks, to the bridge atomic APIs. Add drm helpers for duplicate_state, destroy_state, and bridge_reset bridge hooks. Further add support for the input format negotiation hook. Signed-off-by: Aradhya Bhatia --- .../gpu/drm/bridge/cadence/cdns-dsi-core.c | 70 ++++++++++++++++--- 1 file changed, 62 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/bridge/cadence/cdns-dsi-core.c b/drivers/gpu/drm/bridge/cadence/cdns-dsi-core.c index 87fdd07ca0bc..c7519d18e94f 100644 --- a/drivers/gpu/drm/bridge/cadence/cdns-dsi-core.c +++ b/drivers/gpu/drm/bridge/cadence/cdns-dsi-core.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -655,7 +656,8 @@ cdns_dsi_bridge_mode_valid(struct drm_bridge *bridge, return MODE_OK; } -static void cdns_dsi_bridge_disable(struct drm_bridge *bridge) +static void cdns_dsi_bridge_atomic_disable(struct drm_bridge *bridge, + struct drm_bridge_state *old_bridge_state) { struct cdns_dsi_input *input = bridge_to_cdns_dsi_input(bridge); struct cdns_dsi *dsi = input_to_dsi(input); @@ -675,7 +677,8 @@ static void cdns_dsi_bridge_disable(struct drm_bridge *bridge) pm_runtime_put(dsi->base.dev); } -static void cdns_dsi_bridge_post_disable(struct drm_bridge *bridge) +static void cdns_dsi_bridge_post_disable(struct drm_bridge *bridge, + struct drm_bridge_state *old_bridge_state) { struct cdns_dsi_input *input = bridge_to_cdns_dsi_input(bridge); struct cdns_dsi *dsi = input_to_dsi(input); @@ -752,7 +755,8 @@ static void cdns_dsi_init_link(struct cdns_dsi *dsi) dsi->link_initialized = true; } -static void cdns_dsi_bridge_enable(struct drm_bridge *bridge) +static void cdns_dsi_bridge_atomic_enable(struct drm_bridge *bridge, + struct drm_bridge_state *old_bridge_state) { struct cdns_dsi_input *input = bridge_to_cdns_dsi_input(bridge); struct cdns_dsi *dsi = input_to_dsi(input); @@ -903,7 +907,8 @@ static void cdns_dsi_bridge_enable(struct drm_bridge *bridge) writel(tmp, dsi->regs + MCTL_MAIN_EN); } -static void cdns_dsi_bridge_pre_enable(struct drm_bridge *bridge) +static void cdns_dsi_bridge_pre_enable(struct drm_bridge *bridge, + struct drm_bridge_state *old_bridge_state) { struct cdns_dsi_input *input = bridge_to_cdns_dsi_input(bridge); struct cdns_dsi *dsi = input_to_dsi(input); @@ -915,13 +920,62 @@ static void cdns_dsi_bridge_pre_enable(struct drm_bridge *bridge) cdns_dsi_hs_init(dsi); } +static u32 *cdns_dsi_bridge_get_input_bus_fmts(struct drm_bridge *bridge, + struct drm_bridge_state *bridge_state, + struct drm_crtc_state *crtc_state, + struct drm_connector_state *conn_state, + u32 output_fmt, + unsigned int *num_input_fmts) +{ + struct cdns_dsi_input *input = bridge_to_cdns_dsi_input(bridge); + struct cdns_dsi *dsi = input_to_dsi(input); + struct cdns_dsi_output *output = &dsi->output; + u32 *input_fmts; + + *num_input_fmts = 0; + + input_fmts = kzalloc(sizeof(*input_fmts), GFP_KERNEL); + if (!input_fmts) + return NULL; + + switch (output->dev->format) { + case MIPI_DSI_FMT_RGB888: + input_fmts[0] = MEDIA_BUS_FMT_RGB888_1X24; + break; + + case MIPI_DSI_FMT_RGB666: + input_fmts[0] = MEDIA_BUS_FMT_RGB666_1X24_CPADHI; + break; + + case MIPI_DSI_FMT_RGB666_PACKED: + input_fmts[0] = MEDIA_BUS_FMT_RGB666_1X18; + break; + + case MIPI_DSI_FMT_RGB565: + input_fmts[0] = MEDIA_BUS_FMT_RGB565_1X16; + break; + + default: + /* Unsupported DSI Format */ + return NULL; + } + + *num_input_fmts = 1; + + return input_fmts; +} + static const struct drm_bridge_funcs cdns_dsi_bridge_funcs = { .attach = cdns_dsi_bridge_attach, .mode_valid = cdns_dsi_bridge_mode_valid, - .disable = cdns_dsi_bridge_disable, - .pre_enable = cdns_dsi_bridge_pre_enable, - .enable = cdns_dsi_bridge_enable, - .post_disable = cdns_dsi_bridge_post_disable, + .atomic_disable = cdns_dsi_bridge_atomic_disable, + .atomic_pre_enable = cdns_dsi_bridge_atomic_pre_enable, + .atomic_enable = cdns_dsi_bridge_atomic_enable, + .atomic_post_disable = cdns_dsi_bridge_atomic_post_disable, + .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state, + .atomic_reset = drm_atomic_helper_bridge_reset, + .atomic_get_input_bus_fmts = cdns_dsi_bridge_get_input_bus_fmts, }; static int cdns_dsi_attach(struct mipi_dsi_host *host, -- 2.34.1