public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: david@lechnology.com, javierm@redhat.com, lanzano.alex@gmail.com,
	kamlesh.gurudasani@gmail.com, architanant5@gmail.com,
	wens@kernel.org, mripard@kernel.org,
	maarten.lankhorst@linux.intel.com, simona@ffwll.ch,
	airlied@gmail.com
Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann <tzimmermann@suse.de>
Subject: [PATCH v3 02/16] drm/mipi-dbi: Support custom pipelines with drm_mipi_dbi_dev_init()
Date: Thu, 19 Mar 2026 16:59:38 +0100	[thread overview]
Message-ID: <20260319160110.109610-3-tzimmermann@suse.de> (raw)
In-Reply-To: <20260319160110.109610-1-tzimmermann@suse.de>

Initialize the mipi-dbi device with drm_mipi_dbi_dev_init() without
creating a modesetting pipeline. Will allow for mipi-dbi drivers
without simple-display helpers.

As the new helper is a DRM function, add the drm_ prefix. Mipi-dbi
interfaces currently lack this.

v3:
- document tx_buf_size parameter (David)

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: David Lechner <david@lechnology.com>
---
 drivers/gpu/drm/drm_mipi_dbi.c | 80 ++++++++++++++++++++++++----------
 include/drm/drm_mipi_dbi.h     |  4 ++
 2 files changed, 61 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/drm_mipi_dbi.c b/drivers/gpu/drm/drm_mipi_dbi.c
index bb6cebc583be..bc5444ca7ac6 100644
--- a/drivers/gpu/drm/drm_mipi_dbi.c
+++ b/drivers/gpu/drm/drm_mipi_dbi.c
@@ -554,6 +554,59 @@ static const uint32_t mipi_dbi_formats[] = {
 	DRM_FORMAT_XRGB8888,
 };
 
+/**
+ * drm_mipi_dbi_dev_init - MIPI DBI device initialization
+ * @dbidev: MIPI DBI device structure to initialize
+ * @mode: Hardware display mode
+ * @format: Hardware color format (DRM_FORMAT\_\*).
+ * @rotation: Initial rotation in degrees Counter Clock Wise
+ * @tx_buf_size: Allocate a transmit buffer of at least this size.
+ *
+ * Initializes a MIPI-DBI device. The minimum size of the transmit buffer
+ * in @tx_buf_size is optional. Pass 0 to allocate enough memory to transmit
+ * a single scanline of the display.
+ *
+ * Returns:
+ * Zero on success, negative error code on failure.
+ */
+int drm_mipi_dbi_dev_init(struct mipi_dbi_dev *dbidev, const struct drm_display_mode *mode,
+			  u32 format, unsigned int rotation, size_t tx_buf_size)
+{
+	struct drm_device *drm = &dbidev->drm;
+	int ret;
+
+	if (!dbidev->dbi.command)
+		return -EINVAL;
+
+	if (!tx_buf_size) {
+		const struct drm_format_info *info = drm_format_info(format);
+
+		tx_buf_size = drm_format_info_min_pitch(info, 0, mode->hdisplay) *
+			      mode->vdisplay;
+	}
+
+	dbidev->tx_buf = devm_kmalloc(drm->dev, tx_buf_size, GFP_KERNEL);
+	if (!dbidev->tx_buf)
+		return -ENOMEM;
+
+	drm_mode_copy(&dbidev->mode, mode);
+	ret = mipi_dbi_rotate_mode(&dbidev->mode, rotation);
+	if (ret) {
+		drm_err(drm, "Illegal rotation value %u\n", rotation);
+		return -EINVAL;
+	}
+
+	dbidev->rotation = rotation;
+	drm_dbg(drm, "rotation = %u\n", rotation);
+
+	dbidev->pixel_format = format;
+	if (dbidev->pixel_format == DRM_FORMAT_RGB888)
+		dbidev->dbi.write_memory_bpw = 8;
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_mipi_dbi_dev_init);
+
 /**
  * mipi_dbi_dev_init_with_formats - MIPI DBI device initialization with custom formats
  * @dbidev: MIPI DBI device structure to initialize
@@ -590,24 +643,14 @@ int mipi_dbi_dev_init_with_formats(struct mipi_dbi_dev *dbidev,
 	struct drm_device *drm = &dbidev->drm;
 	int ret;
 
-	if (!dbidev->dbi.command)
-		return -EINVAL;
+	ret = drm_mipi_dbi_dev_init(dbidev, mode, formats[0], rotation, tx_buf_size);
+	if (ret)
+		return ret;
 
 	ret = drmm_mode_config_init(drm);
 	if (ret)
 		return ret;
 
-	dbidev->tx_buf = devm_kmalloc(drm->dev, tx_buf_size, GFP_KERNEL);
-	if (!dbidev->tx_buf)
-		return -ENOMEM;
-
-	drm_mode_copy(&dbidev->mode, mode);
-	ret = mipi_dbi_rotate_mode(&dbidev->mode, rotation);
-	if (ret) {
-		DRM_ERROR("Illegal rotation value %u\n", rotation);
-		return -EINVAL;
-	}
-
 	drm_connector_helper_add(&dbidev->connector, &mipi_dbi_connector_hfuncs);
 	ret = drm_connector_init(drm, &dbidev->connector, &mipi_dbi_connector_funcs,
 				 DRM_MODE_CONNECTOR_SPI);
@@ -628,13 +671,6 @@ int mipi_dbi_dev_init_with_formats(struct mipi_dbi_dev *dbidev,
 	drm->mode_config.max_height = dbidev->mode.vdisplay;
 	drm->mode_config.helper_private = &mipi_dbi_mode_config_helper_funcs;
 
-	dbidev->rotation = rotation;
-	dbidev->pixel_format = formats[0];
-	if (formats[0] == DRM_FORMAT_RGB888)
-		dbidev->dbi.write_memory_bpw = 8;
-
-	DRM_DEBUG_KMS("rotation = %u\n", rotation);
-
 	return 0;
 }
 EXPORT_SYMBOL(mipi_dbi_dev_init_with_formats);
@@ -660,13 +696,11 @@ int mipi_dbi_dev_init(struct mipi_dbi_dev *dbidev,
 		      const struct drm_simple_display_pipe_funcs *funcs,
 		      const struct drm_display_mode *mode, unsigned int rotation)
 {
-	size_t bufsize = (u32)mode->vdisplay * mode->hdisplay * sizeof(u16);
-
 	dbidev->drm.mode_config.preferred_depth = 16;
 
 	return mipi_dbi_dev_init_with_formats(dbidev, funcs, mipi_dbi_formats,
 					      ARRAY_SIZE(mipi_dbi_formats), mode,
-					      rotation, bufsize);
+					      rotation, 0);
 }
 EXPORT_SYMBOL(mipi_dbi_dev_init);
 
diff --git a/include/drm/drm_mipi_dbi.h b/include/drm/drm_mipi_dbi.h
index 637be84d3d5a..9c0e015dd929 100644
--- a/include/drm/drm_mipi_dbi.h
+++ b/include/drm/drm_mipi_dbi.h
@@ -164,6 +164,10 @@ static inline struct mipi_dbi_dev *drm_to_mipi_dbi_dev(struct drm_device *drm)
 
 int mipi_dbi_spi_init(struct spi_device *spi, struct mipi_dbi *dbi,
 		      struct gpio_desc *dc);
+
+int drm_mipi_dbi_dev_init(struct mipi_dbi_dev *dbidev, const struct drm_display_mode *mode,
+			  u32 format, unsigned int rotation, size_t tx_buf_size);
+
 int mipi_dbi_dev_init_with_formats(struct mipi_dbi_dev *dbidev,
 				   const struct drm_simple_display_pipe_funcs *funcs,
 				   const uint32_t *formats, unsigned int format_count,
-- 
2.53.0


  parent reply	other threads:[~2026-03-19 16:01 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-19 15:59 [PATCH v3 00/16] drm/mipi-dbi: Replace simple-display helpers with regular atomic helpers Thomas Zimmermann
2026-03-19 15:59 ` [PATCH v3 01/16] drm/mipi-dbi: Only modify planes on enabled CRTCs Thomas Zimmermann
2026-03-21 18:15   ` Claude review: " Claude Code Review Bot
2026-03-19 15:59 ` Thomas Zimmermann [this message]
2026-03-21 18:15   ` Claude review: drm/mipi-dbi: Support custom pipelines with drm_mipi_dbi_dev_init() Claude Code Review Bot
2026-03-19 15:59 ` [PATCH v3 03/16] drm/mipi-dbi: Provide callbacks for atomic interfaces Thomas Zimmermann
2026-03-21 18:15   ` Claude review: " Claude Code Review Bot
2026-03-19 15:59 ` [PATCH v3 04/16] drm/hx8357d: Use regular atomic helpers; drop simple-display helpers Thomas Zimmermann
2026-03-21 18:15   ` Claude review: " Claude Code Review Bot
2026-03-19 15:59 ` [PATCH v3 05/16] drm/ili9163: " Thomas Zimmermann
2026-03-21 18:15   ` Claude review: " Claude Code Review Bot
2026-03-19 15:59 ` [PATCH v3 06/16] drm/ili9225: " Thomas Zimmermann
2026-03-21 18:15   ` Claude review: " Claude Code Review Bot
2026-03-19 15:59 ` [PATCH v3 07/16] drm/ili9341: " Thomas Zimmermann
2026-03-21 18:15   ` Claude review: " Claude Code Review Bot
2026-03-19 15:59 ` [PATCH v3 08/16] drm/ili9486: " Thomas Zimmermann
2026-03-21 18:15   ` Claude review: " Claude Code Review Bot
2026-03-19 15:59 ` [PATCH v3 09/16] drm/mi0283qt: " Thomas Zimmermann
2026-03-21 18:15   ` Claude review: " Claude Code Review Bot
2026-03-19 15:59 ` [PATCH v3 10/16] drm/panel-mipi-dbi: " Thomas Zimmermann
2026-03-21 18:15   ` Claude review: " Claude Code Review Bot
2026-03-19 15:59 ` [PATCH v3 11/16] drm/st7586: " Thomas Zimmermann
2026-03-21 18:15   ` Claude review: " Claude Code Review Bot
2026-03-19 15:59 ` [PATCH v3 12/16] drm/st7735r: Rename struct st7735r_priv to struct st7735r_device Thomas Zimmermann
2026-03-21 18:15   ` Claude review: " Claude Code Review Bot
2026-03-19 15:59 ` [PATCH v3 13/16] drm/st7735r: Rename priv variable to st7735r Thomas Zimmermann
2026-03-21 18:15   ` Claude review: " Claude Code Review Bot
2026-03-19 15:59 ` [PATCH v3 14/16] drm/st7735r: Use regular atomic helpers; drop simple-display helpers Thomas Zimmermann
2026-03-21 18:15   ` Claude review: " Claude Code Review Bot
2026-03-19 15:59 ` [PATCH v3 15/16] drm/mipi-dbi: Remove simple-display helpers from mipi-dbi Thomas Zimmermann
2026-03-21 18:15   ` Claude review: " Claude Code Review Bot
2026-03-19 15:59 ` [PATCH v3 16/16] drm/simple-kms: Deprecate simple-kms helpers Thomas Zimmermann
2026-03-21 18:15   ` Claude review: " Claude Code Review Bot
2026-03-21 18:15 ` Claude review: drm/mipi-dbi: Replace simple-display helpers with regular atomic helpers Claude Code Review Bot

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=20260319160110.109610-3-tzimmermann@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@gmail.com \
    --cc=architanant5@gmail.com \
    --cc=david@lechnology.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=javierm@redhat.com \
    --cc=kamlesh.gurudasani@gmail.com \
    --cc=lanzano.alex@gmail.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=wens@kernel.org \
    /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