mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alberto Ruiz via B4 Relay <devnull+aruiz.redhat.com@kernel.org>
To: Javier Martinez Canillas <javierm@redhat.com>,
	 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>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	 Alberto Ruiz <aruiz@redhat.com>
Subject: [PATCH 1/4] drm/solomon: add ssd130x_run_cmd_seq() for batch command execution
Date: Fri, 12 Jun 2026 18:17:16 +0100	[thread overview]
Message-ID: <20260612-ssd-batchcmd-v1-1-c61e5f7c24bc@redhat.com> (raw)
In-Reply-To: <20260612-ssd-batchcmd-v1-0-c61e5f7c24bc@redhat.com>

From: Alberto Ruiz <aruiz@redhat.com>

Introduce ssd130x_run_cmd_seq() that interprets a flat byte array of
length-prefixed command entries terminated by a zero byte, removing the
need for per-command error checking at each call site.

Signed-off-by: Alberto Ruiz <aruiz@redhat.com>
---
 drivers/gpu/drm/solomon/ssd130x.c | 43 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/drivers/gpu/drm/solomon/ssd130x.c b/drivers/gpu/drm/solomon/ssd130x.c
index c77455b1834d..46e2c277a9bf 100644
--- a/drivers/gpu/drm/solomon/ssd130x.c
+++ b/drivers/gpu/drm/solomon/ssd130x.c
@@ -276,6 +276,49 @@ static int ssd130x_write_cmd(struct ssd130x_device *ssd130x, int count,
 	return ret;
 }
 
+/*
+ * Write a command byte sequence from a buffer.
+ *
+ * Like ssd130x_write_cmd() but takes a pre-built byte array instead of
+ * variadic arguments, handy when the command is already in an array or
+ * when the caller wants to use sizeof() for the length.
+ */
+static int ssd130x_write_cmds(struct ssd130x_device *ssd130x, const u8 *cmd,
+			      size_t len)
+{
+	unsigned int i;
+	int ret;
+
+	for (i = 0; i < len; i++) {
+		ret = regmap_write(ssd130x->regmap, SSD13XX_COMMAND, cmd[i]);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
+}
+
+/*
+ * Run a packed command sequence.  The format is a flat byte array where each
+ * entry starts with a length byte followed by that many command bytes.  A
+ * zero length byte terminates the sequence.
+ *
+ * Example: { 2, 0x81, 0x80, 1, 0xAF, 0 }
+ *   sends command {0x81, 0x80}, then command {0xAF}, then stops.
+ */
+static int ssd130x_run_cmd_seq(struct ssd130x_device *ssd130x, const u8 *seq)
+{
+	while (*seq) {
+		u8 len = *seq++;
+		int ret = ssd130x_write_cmds(ssd130x, seq, len);
+
+		if (ret)
+			return ret;
+		seq += len;
+	}
+
+	return 0;
+}
 /* Set address range for horizontal/vertical addressing modes */
 static int ssd130x_set_col_range(struct ssd130x_device *ssd130x,
 				 u8 col_start, u8 cols)

-- 
2.53.0



  reply	other threads:[~2026-06-12 17:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-12 17:17 [PATCH 0/4] drm/solomon: batch command sequences for SSD130x/132x/133x init Alberto Ruiz via B4 Relay
2026-06-12 17:17 ` Alberto Ruiz via B4 Relay [this message]
2026-06-12 17:17 ` [PATCH 2/4] drm/solomon: use ssd130x_run_cmd_seq() in ssd130x_init() Alberto Ruiz via B4 Relay
2026-06-12 17:17 ` [PATCH 3/4] drm/solomon: use ssd130x_run_cmd_seq() in ssd132x_init() Alberto Ruiz via B4 Relay
2026-06-12 17:17 ` [PATCH 4/4] drm/solomon: use ssd130x_run_cmd_seq() in ssd133x_init() Alberto Ruiz via B4 Relay
2026-06-12 19:54 ` [PATCH 0/4] drm/solomon: batch command sequences for SSD130x/132x/133x init Javier Martinez Canillas
2026-06-16  8:48   ` Javier Martinez Canillas

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=20260612-ssd-batchcmd-v1-1-c61e5f7c24bc@redhat.com \
    --to=devnull+aruiz.redhat.com@kernel.org \
    --cc=airlied@gmail.com \
    --cc=aruiz@redhat.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=javierm@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --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

all inboxes | Powered by JetHome®