From: Luca Ceresoli <luca.ceresoli@bootlin.com>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>,
Simona Vetter <simona@ffwll.ch>,
Andrzej Hajda <andrzej.hajda@intel.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
Robert Foss <rfoss@kernel.org>,
Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
Jonas Karlman <jonas@kwiboo.se>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Inki Dae <inki.dae@samsung.com>,
Jagan Teki <jagan@amarulasolutions.com>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Jani Nikula <jani.nikula@linux.intel.com>,
Dmitry Baryshkov <lumag@kernel.org>
Cc: Hui Pu <Hui.Pu@gehealthcare.com>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
linux-sunxi@lists.linux.dev,
Luca Ceresoli <luca.ceresoli@bootlin.com>
Subject: [PATCH 14/32] drm/mipi-dsi: add .attach_new to mipi_dsi_host_ops
Date: Wed, 25 Jun 2025 18:45:18 +0200 [thread overview]
Message-ID: <20250625-drm-dsi-host-no-device-ptr-v1-14-e36bc258a7c5@bootlin.com> (raw)
In-Reply-To: <20250625-drm-dsi-host-no-device-ptr-v1-0-e36bc258a7c5@bootlin.com>
In preparation to avoid DSI host drivers to take any pointer to struct
mipi_dsi_device, add a new host op which does not take such pointer. The
old op can be removed once all users are converted to the new one.
The .attach_new op takes the DSI device format values, (part of) which are
needed by most DSI host drivers. It passes a temporary struct, in order to
ensure host drivers copy the values they need and not keep a pointer.
The struct with the data (struct mipi_dsi_bus_fmt) is a subset of struct
mipi_dsi_device. After all host drivers are converted, struct
mipi_dsi_device can be modified to hold a struct mipi_dsi_bus_fmt instead
of individual fields.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/drm_mipi_dsi.c | 21 +++++++++++++++++++--
include/drm/drm_mipi_dsi.h | 29 ++++++++++++++++++++++++++++-
2 files changed, 47 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
index f16f70c70c87988a95f959d0b8b18a6941dd2808..f45425f777f6bed6ac5f261b0097455c52ab7d9e 100644
--- a/drivers/gpu/drm/drm_mipi_dsi.c
+++ b/drivers/gpu/drm/drm_mipi_dsi.c
@@ -367,6 +367,18 @@ void mipi_dsi_host_unregister(struct mipi_dsi_host *host)
}
EXPORT_SYMBOL(mipi_dsi_host_unregister);
+static void mipi_dsi_dev_copy_bus_fmt(struct mipi_dsi_bus_fmt *fmt,
+ const struct mipi_dsi_device *dsi_dev)
+{
+ fmt->channel = dsi_dev->channel;
+ fmt->lanes = dsi_dev->lanes;
+ fmt->format = dsi_dev->format;
+ fmt->mode_flags = dsi_dev->mode_flags;
+ fmt->hs_rate = dsi_dev->hs_rate;
+ fmt->lp_rate = dsi_dev->lp_rate;
+ fmt->dsc = dsi_dev->dsc;
+}
+
/**
* mipi_dsi_attach - attach a DSI device to its DSI host
* @dsi: DSI peripheral
@@ -374,15 +386,20 @@ EXPORT_SYMBOL(mipi_dsi_host_unregister);
int mipi_dsi_attach(struct mipi_dsi_device *dsi)
{
const struct mipi_dsi_host_ops *ops = dsi->host->ops;
+ struct mipi_dsi_bus_fmt bus_fmt;
int ret;
- if (!ops || !ops->attach)
+ if (!ops || !(ops->attach_new || ops->attach))
return -ENOSYS;
if (dsi->lanes < 1)
return dev_err_probe(&dsi->dev, -EINVAL, "Incorrect lanes number\n");
- ret = ops->attach(dsi->host, dsi);
+ mipi_dsi_dev_copy_bus_fmt(&bus_fmt, dsi);
+
+ ret = ops->attach_new ?
+ ops->attach_new(dsi->host, &bus_fmt) :
+ ops->attach(dsi->host, dsi);
if (ret) {
dev_err(dsi->host->dev,
"Failed to attach %s device (lanes:%d bpp:%d mode-flags:0x%lx) (%d)\n",
diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h
index e42483fd022fed4dfc9e5ef180117c3dd37a3b51..5d5f3dca1ec1a654378ccca15f3f15a5ce957518 100644
--- a/include/drm/drm_mipi_dsi.h
+++ b/include/drm/drm_mipi_dsi.h
@@ -102,9 +102,34 @@ enum mipi_dsi_pixel_format {
#define DSI_DEV_NAME_SIZE 20
+/**
+ * struct mipi_dsi_bus_fmt - format required by a DSI peripheral device
+ * @channel: virtual channel assigned to the peripheral
+ * @format: pixel format for video mode
+ * @lanes: number of active data lanes
+ * @mode_flags: DSI operation mode related flags
+ * @hs_rate: maximum lane frequency for high speed mode in hertz, this should
+ * be set to the real limits of the hardware, zero is only accepted for
+ * legacy drivers
+ * @lp_rate: maximum lane frequency for low power mode in hertz, this should
+ * be set to the real limits of the hardware, zero is only accepted for
+ * legacy drivers
+ * @dsc: panel/bridge DSC pps payload to be sent
+ */
+struct mipi_dsi_bus_fmt {
+ unsigned int channel;
+ unsigned int lanes;
+ enum mipi_dsi_pixel_format format;
+ unsigned long mode_flags;
+ unsigned long hs_rate;
+ unsigned long lp_rate;
+ struct drm_dsc_config *dsc;
+};
+
/**
* struct mipi_dsi_host_ops - DSI bus operations
- * @attach: attach DSI device to DSI host
+ * @attach_new: attach DSI device to DSI host; either @attach_new or @attach is mandatory
+ * @attach: deprecated version of @attach_new
* @detach: detach DSI device from DSI host
* @transfer: transmit a DSI packet
*
@@ -126,6 +151,8 @@ enum mipi_dsi_pixel_format {
* properly enabled.
*/
struct mipi_dsi_host_ops {
+ int (*attach_new)(struct mipi_dsi_host *host,
+ const struct mipi_dsi_bus_fmt *bus_fmt);
int (*attach)(struct mipi_dsi_host *host,
struct mipi_dsi_device *dsi);
int (*detach)(struct mipi_dsi_host *host,
--
2.49.0
next prev parent reply other threads:[~2025-06-25 16:46 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-25 16:45 [PATCH 00/32] drm/mipi-dsi: avoid DSI host drivers to have pointers to DSI devices Luca Ceresoli
2025-06-25 16:45 ` [PATCH 01/32] drm/mipi-dsi: add sanity check of lane number in mipi_dsi_attach() Luca Ceresoli
2025-06-25 16:45 ` [PATCH 02/32] drm/hisilicon/kirin: remove redundant lanes number check Luca Ceresoli
2025-06-25 16:45 ` [PATCH 03/32] drm/bridge: nwl-dsi: " Luca Ceresoli
2025-06-25 16:45 ` [PATCH 04/32] drm/mcde: " Luca Ceresoli
2025-06-25 16:45 ` [PATCH 05/32] drm/mipi-dsi: log DSI device attach and detach Luca Ceresoli
2025-06-25 16:45 ` [PATCH 06/32] drm/bridge: samsung-dsim: remove redundant logging Luca Ceresoli
2025-06-25 16:45 ` [PATCH 07/32] drm/bridge: nwl-dsi: " Luca Ceresoli
2025-06-25 16:45 ` [PATCH 08/32] drm/bridge: cdns-dsi: " Luca Ceresoli
2025-06-25 16:45 ` [PATCH 09/32] drm/mcde: " Luca Ceresoli
2025-06-25 16:45 ` [PATCH 10/32] drm/sun4i: dsi: " Luca Ceresoli
2025-06-25 16:45 ` [PATCH 11/32] drm/bridge: synopsys/dsi2: remove DSI device pointer from private callbacks Luca Ceresoli
2025-06-25 16:45 ` [PATCH RFC 12/32] drm/meson: dsi: remove unneeded DSI device check Luca Ceresoli
2025-06-25 16:45 ` [PATCH 13/32] drm/mipi-dsi: move format define above Luca Ceresoli
2025-06-25 16:45 ` Luca Ceresoli [this message]
2025-06-25 16:45 ` [PATCH 15/32] drm: adp: mipi: convert to the .attach_new op Luca Ceresoli
2025-06-25 16:45 ` [PATCH 16/32] drm/kmb: dsi: " Luca Ceresoli
2025-06-25 16:45 ` [PATCH 17/32] drm/i915/dsi: " Luca Ceresoli
2025-06-25 18:42 ` Jani Nikula
2025-06-25 16:45 ` [PATCH 18/32] drm/hisilicon/kirin: " Luca Ceresoli
2025-06-25 16:45 ` [PATCH 19/32] drm/bridge: synopsys/dsi2: " Luca Ceresoli
2025-06-25 16:45 ` [PATCH 20/32] drm/msm/dsi: " Luca Ceresoli
2025-06-25 16:45 ` [PATCH 21/32] drm/rcar-du: dsi: " Luca Ceresoli
2025-06-25 16:45 ` [PATCH 22/32] drm: renesas: rz-du: rzg2l_mipi_dsi: " Luca Ceresoli
2025-06-26 23:42 ` kernel test robot
2025-06-25 16:45 ` [PATCH 23/32] drm/vc4: dsi: " Luca Ceresoli
2025-06-25 16:45 ` [PATCH 24/32] drm/mediatek: " Luca Ceresoli
2025-06-25 16:45 ` [PATCH 25/32] drm/bridge: nwl-dsi: " Luca Ceresoli
2025-06-25 16:45 ` [PATCH 26/32] drm/bridge: cdns-dsi: " Luca Ceresoli
2025-06-25 16:45 ` [PATCH 27/32] drm/bridge: tc358768: " Luca Ceresoli
2025-06-25 16:45 ` [PATCH 28/32] drm/sprd: " Luca Ceresoli
2025-06-25 16:45 ` [PATCH 29/32] drm/bridge: synopsys: dw-mipi-dsi: " Luca Ceresoli
2025-06-25 16:45 ` [PATCH 30/32] drm/mcde: store a pointer to mipi_dsi_host to perform TE requests Luca Ceresoli
2025-06-25 16:45 ` [PATCH 31/32] drm/mcde: use the DSI host pointer in mcde_dsi_irq Luca Ceresoli
2025-06-25 16:45 ` [PATCH 32/32] drm/mcde: convert to the .attach_new op Luca Ceresoli
2025-07-07 6:16 ` [PATCH 00/32] drm/mipi-dsi: avoid DSI host drivers to have pointers to DSI devices Maxime Ripard
2025-07-07 9:58 ` Luca Ceresoli
2025-07-07 10:13 ` Luca Ceresoli
2025-07-14 15:28 ` Luca Ceresoli
2025-07-25 15:22 ` Maxime Ripard
2025-07-25 15:32 ` Luca Ceresoli
2025-07-25 15:17 ` Maxime Ripard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250625-drm-dsi-host-no-device-ptr-v1-14-e36bc258a7c5@bootlin.com \
--to=luca.ceresoli@bootlin.com \
--cc=Hui.Pu@gehealthcare.com \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=airlied@gmail.com \
--cc=andrzej.hajda@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=inki.dae@samsung.com \
--cc=jagan@amarulasolutions.com \
--cc=jani.nikula@linux.intel.com \
--cc=jernej.skrabec@gmail.com \
--cc=jonas@kwiboo.se \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=lumag@kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=rfoss@kernel.org \
--cc=simona@ffwll.ch \
--cc=thomas.petazzoni@bootlin.com \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).