mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/4] drm/solomon: batch command sequences for SSD130x/132x/133x init
@ 2026-06-12 17:17 Alberto Ruiz via B4 Relay
  2026-06-12 17:17 ` [PATCH 1/4] drm/solomon: add ssd130x_run_cmd_seq() for batch command execution Alberto Ruiz via B4 Relay
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Alberto Ruiz via B4 Relay @ 2026-06-12 17:17 UTC (permalink / raw)
  To: Javier Martinez Canillas, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter
  Cc: dri-devel, linux-kernel, Alberto Ruiz

The ssd130x_init(), ssd132x_init(), and ssd133x_init() functions each
issue long chains of individual ssd130x_write_cmd() calls, each
followed by its own error check.  This is verbose and makes the init
sequences harder to read and maintain.

This series introduces ssd130x_run_cmd_seq(), which interprets a flat
byte array of length-prefixed command entries terminated by a zero
byte, and converts the three init functions to use it.  The result is
a net reduction of ~110 lines, with the hardware programming sequences
now expressed as compact, declarative tables rather than imperative
call-and-check chains.

Signed-off-by: Alberto Ruiz <aruiz@redhat.com>
---
Alberto Ruiz (4):
      drm/solomon: add ssd130x_run_cmd_seq() for batch command execution
      drm/solomon: use ssd130x_run_cmd_seq() in ssd130x_init()
      drm/solomon: use ssd130x_run_cmd_seq() in ssd132x_init()
      drm/solomon: use ssd130x_run_cmd_seq() in ssd133x_init()

 drivers/gpu/drm/solomon/ssd130x.c | 367 +++++++++++++-------------------------
 1 file changed, 128 insertions(+), 239 deletions(-)
---
base-commit: 2b414a95b8f7307d42173ba9e580d6d3e2bcbfce
change-id: 20260612-ssd-batchcmd-35f7ba8c1e8b

Best regards,
--  
Alberto Ruiz <aruiz@redhat.com>



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/4] drm/solomon: add ssd130x_run_cmd_seq() for batch command execution
  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
  2026-06-12 17:17 ` [PATCH 2/4] drm/solomon: use ssd130x_run_cmd_seq() in ssd130x_init() Alberto Ruiz via B4 Relay
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Alberto Ruiz via B4 Relay @ 2026-06-12 17:17 UTC (permalink / raw)
  To: Javier Martinez Canillas, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter
  Cc: dri-devel, linux-kernel, Alberto Ruiz

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



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/4] drm/solomon: use ssd130x_run_cmd_seq() in ssd130x_init()
  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 ` [PATCH 1/4] drm/solomon: add ssd130x_run_cmd_seq() for batch command execution Alberto Ruiz via B4 Relay
@ 2026-06-12 17:17 ` 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
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Alberto Ruiz via B4 Relay @ 2026-06-12 17:17 UTC (permalink / raw)
  To: Javier Martinez Canillas, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter
  Cc: dri-devel, linux-kernel, Alberto Ruiz

From: Alberto Ruiz <aruiz@redhat.com>

Replace individual ssd130x_write_cmd() calls and per-command error
checks with flat command arrays dispatched through ssd130x_run_cmd_seq().

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

diff --git a/drivers/gpu/drm/solomon/ssd130x.c b/drivers/gpu/drm/solomon/ssd130x.c
index 46e2c277a9bf..ec6bf9f6c7c8 100644
--- a/drivers/gpu/drm/solomon/ssd130x.c
+++ b/drivers/gpu/drm/solomon/ssd130x.c
@@ -451,39 +451,25 @@ static int ssd130x_init(struct ssd130x_device *ssd130x)
 	bool scan_mode;
 	int ret;
 
-	/* Set initial contrast */
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD13XX_CONTRAST, ssd130x->contrast);
-	if (ret < 0)
-		return ret;
-
-	/* Set segment re-map */
 	seg_remap = (SSD13XX_SET_SEG_REMAP |
-		     SSD13XX_SET_SEG_REMAP_SET(ssd130x->seg_remap));
-	ret = ssd130x_write_cmd(ssd130x, 1, seg_remap);
-	if (ret < 0)
-		return ret;
-
-	/* Set COM direction */
+		SSD13XX_SET_SEG_REMAP_SET(ssd130x->seg_remap));
 	com_invdir = (SSD130X_SET_COM_SCAN_DIR |
-		      SSD130X_SET_COM_SCAN_DIR_SET(ssd130x->com_invdir));
-	ret = ssd130x_write_cmd(ssd130x,  1, com_invdir);
-	if (ret < 0)
-		return ret;
-
-	/* Set multiplex ratio value */
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD13XX_SET_MULTIPLEX_RATIO, ssd130x->height - 1);
-	if (ret < 0)
-		return ret;
-
-	/* set display offset value */
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD130X_SET_DISPLAY_OFFSET, ssd130x->com_offset);
-	if (ret < 0)
-		return ret;
-
-	/* Set clock frequency */
+		SSD130X_SET_COM_SCAN_DIR_SET(ssd130x->com_invdir));
 	dclk = (SSD130X_SET_CLOCK_DIV_SET(ssd130x->dclk_div - 1) |
 		SSD130X_SET_CLOCK_FREQ_SET(ssd130x->dclk_frq));
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD130X_SET_CLOCK_FREQ, dclk);
+
+	const u8 *cmds = (const u8[]) {
+		2, SSD13XX_CONTRAST, ssd130x->contrast,
+		/* Set segment re-map */
+		1, seg_remap,
+		/* Set COM scan direction */
+		1, com_invdir,
+		2, SSD13XX_SET_MULTIPLEX_RATIO, ssd130x->height - 1,
+		2, SSD130X_SET_DISPLAY_OFFSET, ssd130x->com_offset,
+		2, SSD130X_SET_CLOCK_FREQ, dclk,
+		0,
+	};
+	ret = ssd130x_run_cmd_seq(ssd130x, cmds);
 	if (ret < 0)
 		return ret;
 
@@ -505,36 +491,30 @@ static int ssd130x_init(struct ssd130x_device *ssd130x)
 	/* Set precharge period in number of ticks from the internal clock */
 	precharge = (SSD130X_SET_PRECHARGE_PERIOD1_SET(ssd130x->prechargep1) |
 		     SSD130X_SET_PRECHARGE_PERIOD2_SET(ssd130x->prechargep2));
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD130X_SET_PRECHARGE_PERIOD, precharge);
-	if (ret < 0)
-		return ret;
 
-	/* Set COM pins configuration */
-	compins = BIT(1);
-	/*
+	/* Set COM pins configuration
+	 *
 	 * The COM scan mode field values are the inverse of the boolean DT
 	 * property "solomon,com-seq". The value 0b means scan from COM0 to
 	 * COM[N - 1] while 1b means scan from COM[N - 1] to COM0.
 	 */
 	scan_mode = !ssd130x->com_seq;
-	compins |= (SSD130X_SET_COM_PINS_CONFIG1_SET(scan_mode) |
+	compins = BIT(1) | (SSD130X_SET_COM_PINS_CONFIG1_SET(scan_mode) |
 		    SSD130X_SET_COM_PINS_CONFIG2_SET(ssd130x->com_lrremap));
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD130X_SET_COM_PINS_CONFIG, compins);
-	if (ret < 0)
-		return ret;
-
-	/* Set VCOMH */
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD130X_SET_VCOMH, ssd130x->vcomh);
-	if (ret < 0)
-		return ret;
 
 	/* Turn on the DC-DC Charge Pump */
 	chargepump = BIT(4);
-
 	if (ssd130x->device_info->need_chargepump)
 		chargepump |= BIT(2);
 
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD130X_CHARGE_PUMP, chargepump);
+	cmds = (const u8[]) {
+		2, SSD130X_SET_PRECHARGE_PERIOD, precharge,
+		2, SSD130X_SET_COM_PINS_CONFIG, compins,
+		2, SSD130X_SET_VCOMH, ssd130x->vcomh,
+		2, SSD130X_CHARGE_PUMP, chargepump,
+		0
+	};
+	ret = ssd130x_run_cmd_seq(ssd130x, cmds);
 	if (ret < 0)
 		return ret;
 

-- 
2.53.0



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 3/4] drm/solomon: use ssd130x_run_cmd_seq() in ssd132x_init()
  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 ` [PATCH 1/4] drm/solomon: add ssd130x_run_cmd_seq() for batch command execution Alberto Ruiz via B4 Relay
  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 ` 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
  4 siblings, 0 replies; 7+ messages in thread
From: Alberto Ruiz via B4 Relay @ 2026-06-12 17:17 UTC (permalink / raw)
  To: Javier Martinez Canillas, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter
  Cc: dri-devel, linux-kernel, Alberto Ruiz

From: Alberto Ruiz <aruiz@redhat.com>

Replace individual ssd130x_write_cmd() calls and per-command error
checks with a flat command array dispatched through ssd130x_run_cmd_seq().

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

diff --git a/drivers/gpu/drm/solomon/ssd130x.c b/drivers/gpu/drm/solomon/ssd130x.c
index ec6bf9f6c7c8..a9914365ad27 100644
--- a/drivers/gpu/drm/solomon/ssd130x.c
+++ b/drivers/gpu/drm/solomon/ssd130x.c
@@ -551,92 +551,34 @@ static int ssd130x_init(struct ssd130x_device *ssd130x)
 
 static int ssd132x_init(struct ssd130x_device *ssd130x)
 {
-	int ret;
-
-	/* Set initial contrast */
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD13XX_CONTRAST, 0x80);
-	if (ret < 0)
-		return ret;
-
-	/* Set column start and end */
-	ret = ssd130x_write_cmd(ssd130x, 3, SSD132X_SET_COL_RANGE, 0x00,
-				ssd130x->width / SSD132X_SEGMENT_WIDTH - 1);
-	if (ret < 0)
-		return ret;
-
-	/* Set row start and end */
-	ret = ssd130x_write_cmd(ssd130x, 3, SSD132X_SET_ROW_RANGE, 0x00, ssd130x->height - 1);
-	if (ret < 0)
-		return ret;
-	/*
-	 * Horizontal Address Increment
-	 * Re-map for Column Address, Nibble and COM
-	 * COM Split Odd Even
-	 */
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD13XX_SET_SEG_REMAP, 0x53);
-	if (ret < 0)
-		return ret;
-
-	/* Set display start and offset */
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD132X_SET_DISPLAY_START, 0x00);
-	if (ret < 0)
-		return ret;
-
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD132X_SET_DISPLAY_OFFSET, 0x00);
-	if (ret < 0)
-		return ret;
-
-	/* Set display mode normal */
-	ret = ssd130x_write_cmd(ssd130x, 1, SSD132X_SET_DISPLAY_NORMAL);
-	if (ret < 0)
-		return ret;
-
-	/* Set multiplex ratio value */
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD13XX_SET_MULTIPLEX_RATIO, ssd130x->height - 1);
-	if (ret < 0)
-		return ret;
-
-	/* Set phase length */
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD132X_SET_PHASE_LENGTH, 0x55);
-	if (ret < 0)
-		return ret;
-
-	/* Select default linear gray scale table */
-	ret = ssd130x_write_cmd(ssd130x, 1, SSD132X_SELECT_DEFAULT_TABLE);
-	if (ret < 0)
-		return ret;
-
-	/* Set clock frequency */
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD132X_SET_CLOCK_FREQ, 0x01);
-	if (ret < 0)
-		return ret;
-
-	/* Enable internal VDD regulator */
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD132X_SET_FUNCTION_SELECT_A, 0x1);
-	if (ret < 0)
-		return ret;
-
-	/* Set pre-charge period */
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD132X_SET_PRECHARGE_PERIOD, 0x01);
-	if (ret < 0)
-		return ret;
-
-	/* Set pre-charge voltage */
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD132X_SET_PRECHARGE_VOLTAGE, 0x08);
-	if (ret < 0)
-		return ret;
-
-	/* Set VCOMH voltage */
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD130X_SET_VCOMH_VOLTAGE, 0x07);
-	if (ret < 0)
-		return ret;
-
-	/* Enable second pre-charge and internal VSL */
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD132X_SET_FUNCTION_SELECT_B, 0x62);
-	if (ret < 0)
-		return ret;
+	const u8 cmds[] = {
+		2, SSD13XX_CONTRAST, 0x80,
+		3, SSD132X_SET_COL_RANGE, 0x00,
+					ssd130x->width / SSD132X_SEGMENT_WIDTH - 1,
+		3, SSD132X_SET_ROW_RANGE, 0x00, ssd130x->height - 1,
+		/*
+		 * Horizontal Address Increment
+		 * Re-map for Column Address, Nibble and COM
+		 * COM Split Odd Even
+		 */
+		2, SSD13XX_SET_SEG_REMAP, 0x53,
+		2, SSD132X_SET_DISPLAY_START, 0x00,
+		2, SSD132X_SET_DISPLAY_OFFSET, 0x00,
+		1, SSD132X_SET_DISPLAY_NORMAL,
+		2, SSD13XX_SET_MULTIPLEX_RATIO, ssd130x->height - 1,
+		2, SSD132X_SET_PHASE_LENGTH, 0x55,
+		1, SSD132X_SELECT_DEFAULT_TABLE,
+		2, SSD132X_SET_CLOCK_FREQ, 0x01,
+		2, SSD132X_SET_FUNCTION_SELECT_A, 0x1,
+		2, SSD132X_SET_PRECHARGE_PERIOD, 0x01,
+		2, SSD132X_SET_PRECHARGE_VOLTAGE, 0x08,
+		2, SSD130X_SET_VCOMH_VOLTAGE, 0x07,
+		/* Enable second pre-charge and internal VSL */
+		2, SSD132X_SET_FUNCTION_SELECT_B, 0x62,
+		0,
+	};
 
-	return 0;
+	return ssd130x_run_cmd_seq(ssd130x, cmds);
 }
 
 static int ssd133x_init(struct ssd130x_device *ssd130x)

-- 
2.53.0



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 4/4] drm/solomon: use ssd130x_run_cmd_seq() in ssd133x_init()
  2026-06-12 17:17 [PATCH 0/4] drm/solomon: batch command sequences for SSD130x/132x/133x init Alberto Ruiz via B4 Relay
                   ` (2 preceding siblings ...)
  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 ` 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
  4 siblings, 0 replies; 7+ messages in thread
From: Alberto Ruiz via B4 Relay @ 2026-06-12 17:17 UTC (permalink / raw)
  To: Javier Martinez Canillas, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter
  Cc: dri-devel, linux-kernel, Alberto Ruiz

From: Alberto Ruiz <aruiz@redhat.com>

Replace individual ssd130x_write_cmd() calls and per-command error
checks with a flat command array dispatched through ssd130x_run_cmd_seq().

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

diff --git a/drivers/gpu/drm/solomon/ssd130x.c b/drivers/gpu/drm/solomon/ssd130x.c
index a9914365ad27..9466b7353886 100644
--- a/drivers/gpu/drm/solomon/ssd130x.c
+++ b/drivers/gpu/drm/solomon/ssd130x.c
@@ -583,113 +583,37 @@ static int ssd132x_init(struct ssd130x_device *ssd130x)
 
 static int ssd133x_init(struct ssd130x_device *ssd130x)
 {
-	int ret;
-
-	/* Set color A contrast */
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD133X_CONTRAST_A, 0x91);
-	if (ret < 0)
-		return ret;
-
-	/* Set color B contrast */
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD133X_CONTRAST_B, 0x50);
-	if (ret < 0)
-		return ret;
-
-	/* Set color C contrast */
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD133X_CONTRAST_C, 0x7d);
-	if (ret < 0)
-		return ret;
-
-	/* Set master current */
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD133X_SET_MASTER_CURRENT, 0x06);
-	if (ret < 0)
-		return ret;
-
-	/* Set column start and end */
-	ret = ssd130x_write_cmd(ssd130x, 3, SSD133X_SET_COL_RANGE, 0x00, ssd130x->width - 1);
-	if (ret < 0)
-		return ret;
-
-	/* Set row start and end */
-	ret = ssd130x_write_cmd(ssd130x, 3, SSD133X_SET_ROW_RANGE, 0x00, ssd130x->height - 1);
-	if (ret < 0)
-		return ret;
-
-	/*
-	 * Horizontal Address Increment
-	 * Normal order SA,SB,SC (e.g. RGB)
-	 * COM Split Odd Even
-	 * 256 color format
-	 */
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD13XX_SET_SEG_REMAP, 0x20);
-	if (ret < 0)
-		return ret;
-
-	/* Set display start and offset */
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD133X_SET_DISPLAY_START, 0x00);
-	if (ret < 0)
-		return ret;
-
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD133X_SET_DISPLAY_OFFSET, 0x00);
-	if (ret < 0)
-		return ret;
-
-	/* Set display mode normal */
-	ret = ssd130x_write_cmd(ssd130x, 1, SSD133X_SET_DISPLAY_NORMAL);
-	if (ret < 0)
-		return ret;
-
-	/* Set multiplex ratio value */
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD13XX_SET_MULTIPLEX_RATIO, ssd130x->height - 1);
-	if (ret < 0)
-		return ret;
-
-	/* Set master configuration */
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD133X_SET_MASTER_CONFIG, 0x8e);
-	if (ret < 0)
-		return ret;
-
-	/* Set power mode */
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD133X_POWER_SAVE_MODE, 0x0b);
-	if (ret < 0)
-		return ret;
-
-	/* Set Phase 1 and 2 period */
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD133X_PHASES_PERIOD, 0x31);
-	if (ret < 0)
-		return ret;
-
-	/* Set clock divider */
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD133X_SET_CLOCK_FREQ, 0xf0);
-	if (ret < 0)
-		return ret;
-
-	/* Set pre-charge A */
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD132X_SET_PRECHARGE_A, 0x64);
-	if (ret < 0)
-		return ret;
-
-	/* Set pre-charge B */
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD132X_SET_PRECHARGE_B, 0x78);
-	if (ret < 0)
-		return ret;
-
-	/* Set pre-charge C */
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD132X_SET_PRECHARGE_C, 0x64);
-	if (ret < 0)
-		return ret;
-
-	/* Set pre-charge level */
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD133X_SET_PRECHARGE_VOLTAGE, 0x3a);
-	if (ret < 0)
-		return ret;
-
-	/* Set VCOMH voltage */
-	ret = ssd130x_write_cmd(ssd130x, 2, SSD133X_SET_VCOMH_VOLTAGE, 0x3e);
-	if (ret < 0)
-		return ret;
+	const u8 cmds[] = {
+		2, SSD133X_CONTRAST_A, 0x91,
+		2, SSD133X_CONTRAST_B, 0x50,
+		2, SSD133X_CONTRAST_C, 0x7d,
+		2, SSD133X_SET_MASTER_CURRENT, 0x06,
+		3, SSD133X_SET_COL_RANGE, 0x00, ssd130x->width - 1,
+		3, SSD133X_SET_ROW_RANGE, 0x00, ssd130x->height - 1,
+		/*
+		 * Horizontal Address Increment
+		 * Normal order SA,SB,SC (e.g. RGB)
+		 * COM Split Odd Even
+		 * 256 color format
+		 */
+		2, SSD13XX_SET_SEG_REMAP, 0x20,
+		2, SSD133X_SET_DISPLAY_START, 0x00,
+		2, SSD133X_SET_DISPLAY_OFFSET, 0x00,
+		1, SSD133X_SET_DISPLAY_NORMAL,
+		2, SSD13XX_SET_MULTIPLEX_RATIO, ssd130x->height - 1,
+		2, SSD133X_SET_MASTER_CONFIG, 0x8e,
+		2, SSD133X_POWER_SAVE_MODE, 0x0b,
+		2, SSD133X_PHASES_PERIOD, 0x31,
+		2, SSD133X_SET_CLOCK_FREQ, 0xf0,
+		2, SSD132X_SET_PRECHARGE_A, 0x64,
+		2, SSD132X_SET_PRECHARGE_B, 0x78,
+		2, SSD132X_SET_PRECHARGE_C, 0x64,
+		2, SSD133X_SET_PRECHARGE_VOLTAGE, 0x3a,
+		2, SSD133X_SET_VCOMH_VOLTAGE, 0x3e,
+		0,
+	};
 
-	return 0;
+	return ssd130x_run_cmd_seq(ssd130x, cmds);
 }
 
 static int ssd130x_update_rect(struct ssd130x_device *ssd130x,

-- 
2.53.0



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/4] drm/solomon: batch command sequences for SSD130x/132x/133x init
  2026-06-12 17:17 [PATCH 0/4] drm/solomon: batch command sequences for SSD130x/132x/133x init Alberto Ruiz via B4 Relay
                   ` (3 preceding siblings ...)
  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 ` Javier Martinez Canillas
  2026-06-16  8:48   ` Javier Martinez Canillas
  4 siblings, 1 reply; 7+ messages in thread
From: Javier Martinez Canillas @ 2026-06-12 19:54 UTC (permalink / raw)
  To: Alberto Ruiz via B4 Relay, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter
  Cc: dri-devel, linux-kernel, Alberto Ruiz

Alberto Ruiz via B4 Relay <devnull+aruiz.redhat.com@kernel.org> writes:

Hello Alberto,

Thanks for the patches. Nice cleanup!

> The ssd130x_init(), ssd132x_init(), and ssd133x_init() functions each
> issue long chains of individual ssd130x_write_cmd() calls, each
> followed by its own error check.  This is verbose and makes the init
> sequences harder to read and maintain.
>
> This series introduces ssd130x_run_cmd_seq(), which interprets a flat
> byte array of length-prefixed command entries terminated by a zero
> byte, and converts the three init functions to use it.  The result is
> a net reduction of ~110 lines, with the hardware programming sequences
> now expressed as compact, declarative tables rather than imperative
> call-and-check chains.
>
> Signed-off-by: Alberto Ruiz <aruiz@redhat.com>
> ---
> Alberto Ruiz (4):
>       drm/solomon: add ssd130x_run_cmd_seq() for batch command execution
>       drm/solomon: use ssd130x_run_cmd_seq() in ssd130x_init()
>       drm/solomon: use ssd130x_run_cmd_seq() in ssd132x_init()
>       drm/solomon: use ssd130x_run_cmd_seq() in ssd133x_init()

For all the patches:

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Tested-by: Javier Martinez Canillas <javierm@redhat.com>

I'll wait for a few days to merge them, in case someone else have comments.

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/4] drm/solomon: batch command sequences for SSD130x/132x/133x init
  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
  0 siblings, 0 replies; 7+ messages in thread
From: Javier Martinez Canillas @ 2026-06-16  8:48 UTC (permalink / raw)
  To: Alberto Ruiz via B4 Relay, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter
  Cc: dri-devel, linux-kernel, Alberto Ruiz

Javier Martinez Canillas <javierm@redhat.com> writes:

> Alberto Ruiz via B4 Relay <devnull+aruiz.redhat.com@kernel.org> writes:
>
> Hello Alberto,
>
> Thanks for the patches. Nice cleanup!
>
>> The ssd130x_init(), ssd132x_init(), and ssd133x_init() functions each
>> issue long chains of individual ssd130x_write_cmd() calls, each
>> followed by its own error check.  This is verbose and makes the init
>> sequences harder to read and maintain.
>>
>> This series introduces ssd130x_run_cmd_seq(), which interprets a flat
>> byte array of length-prefixed command entries terminated by a zero
>> byte, and converts the three init functions to use it.  The result is
>> a net reduction of ~110 lines, with the hardware programming sequences
>> now expressed as compact, declarative tables rather than imperative
>> call-and-check chains.
>>
>> Signed-off-by: Alberto Ruiz <aruiz@redhat.com>
>> ---
>> Alberto Ruiz (4):
>>       drm/solomon: add ssd130x_run_cmd_seq() for batch command execution
>>       drm/solomon: use ssd130x_run_cmd_seq() in ssd130x_init()
>>       drm/solomon: use ssd130x_run_cmd_seq() in ssd132x_init()
>>       drm/solomon: use ssd130x_run_cmd_seq() in ssd133x_init()
>
> For all the patches:
>
> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
> Tested-by: Javier Martinez Canillas <javierm@redhat.com>
>
> I'll wait for a few days to merge them, in case someone else have comments.
>

Pushed to drm-misc (drm-misc-next). Thanks!

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-06-16  8:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 1/4] drm/solomon: add ssd130x_run_cmd_seq() for batch command execution Alberto Ruiz via B4 Relay
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

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®