From 528be4beaeeb5ee5232ab7f97733ccb6049781aa Mon Sep 17 00:00:00 2001 From: Julien Stephan Date: Thu, 6 Aug 2026 11:27:07 +0200 Subject: mipi_dsi: add mipi_dsi_{generic/dcs}_write_seq helper macros 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 Link: https://patch.msgid.link/20260806-add_mipi_dsi_write_seq_helper_macros-v1-1-6b533788d0ac@baylibre.com Signed-off-by: David Lechner --- include/mipi_dsi.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/include/mipi_dsi.h b/include/mipi_dsi.h index 4ca05f71e29..69ee8d49812 100644 --- a/include/mipi_dsi.h +++ b/include/mipi_dsi.h @@ -267,6 +267,24 @@ 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); + +/** + * mipi_dsi_generic_write_seq - transmit data using a generic write packet + * @dsi: DSI peripheral device + * @cmd: Command + * @seq: buffer containing the payload + * + * This macro returns from the calling function with a negative error code on + * failure. + */ +#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 +321,23 @@ enum mipi_dsi_dcs_tear_mode { ssize_t mipi_dsi_dcs_write_buffer(struct mipi_dsi_device *dsi, const void *data, size_t len); +/** + * mipi_dsi_dcs_write_seq - transmit a DCS command with payload + * @dsi: DSI peripheral device + * @cmd: DCS command + * @seq: buffer containing the payload + * + * This macro returns from the calling function with a negative error code on + * failure. + */ +#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 -- cgit v1.3.1