[PATCH 1/6] mipi_dsi: add mipi_dsi_{generic/dcs}_write_seq helper macros

Julien Stephan <[email protected]>
Newsgroups org.u-boot-project.lists.u-boot
Message-ID <20260806-add_mipi_dsi_write_seq_helper_macros-v1-1-6b533788d0ac@baylibre.com>
Add wrapper mipi_dsi_generic_write_seq and mipi_dsi_dcs_write_seq helper
macros around mipi_dsi_generic_write and mipi_dsi_dcs_write_buffer to
mimic macros defined in the Kernel. This helps porting drivers from the
Kernel and avoids the manual declaration of static arrays in drivers.

Some drivers (hitachi-tx10d07vm0baa.c, lg-lh400wv3-sd04.c, mot-panel.c,
renesas-r69328.c and himax-hx8394.c) already define such a macro, so
this will avoid duplication.

Signed-off-by: Julien Stephan <[email protected]>
---
 include/mipi_dsi.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/include/mipi_dsi.h b/include/mipi_dsi.h
index 4ca05f71e29..fcad42d5145 100644
--- a/include/mipi_dsi.h
+++ b/include/mipi_dsi.h
@@ -267,6 +267,15 @@ int mipi_dsi_set_maximum_return_packet_size(struct mipi_dsi_device *dsi,
 
 ssize_t mipi_dsi_generic_write(struct mipi_dsi_device *dsi, const void *payload,
 			       size_t size);
+
+#define mipi_dsi_generic_write_seq(dsi, cmd, seq...) do {		\
+		static const u8 b[] = { cmd, seq };			\
+		int ret;						\
+		ret = mipi_dsi_generic_write(dsi, b, ARRAY_SIZE(b));	\
+		if (ret < 0)						\
+			return ret;					\
+	} while (0)
+
 ssize_t mipi_dsi_generic_read(struct mipi_dsi_device *dsi, const void *params,
 			      size_t num_params, void *data, size_t size);
 
@@ -303,6 +312,14 @@ enum mipi_dsi_dcs_tear_mode {
 ssize_t mipi_dsi_dcs_write_buffer(struct mipi_dsi_device *dsi,
 				  const void *data, size_t len);
 
+#define mipi_dsi_dcs_write_seq(dsi, cmd, seq...) do {			\
+		static const u8 b[] = { cmd, seq };			\
+		int ret;						\
+		ret = mipi_dsi_dcs_write_buffer(dsi, b, ARRAY_SIZE(b));	\
+		if (ret < 0)						\
+			return ret;					\
+	} while (0)
+
 /**
  * mipi_dsi_dcs_write() - send DCS write command
  * @dsi: DSI peripheral device

-- 
2.54.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.