Skip to contentSkip to conversation

drm/solomon: Add support for the SSD132x controller family

PATCH Superseded Javier Martinez Canillas 5 participants 25 messages Oct 9, 2023 – Oct 11, 2023

Subsystems (5)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Javier Martinez Canillas

author maintainer
#0 lore raw

cover drm/solomon: Add support for the SSD132x controller family

Hello,

This patch-set adds support for the family of SSD132x Solomon controllers, such as the SSD1322, SSD1325 and SSD1327 chips. These are used for 16 Gray Scale Dot Matrix OLED panels.

The patches were tested on a Waveshare SSD1327 display using glmark2-drm, fbcon, fbtests and the retroarch emulator.

Patch #1 renames the ssd130x driver to ssd13xx since it will support both the SSD130x and SSD132x Solomon families and at least the SSD133x family in the future.

Patch #2 also renames the data structures and functions prefixes with the ssd13xx name.

Patch #3 drops the .page_height field from the device info with a constant because it's only needed by the SSD130x family and not the SSD132x family.

Patch #4 changes the driver to use drm_format_info_min_pitch() instead of open coding the same calculation.

Patch #5 adds a per controller family functions table to have logic that could be shared by both SSD130x and SSD132x callbacks.

Patch #6 renames some SSD130X_* commands that are shared by both families and patch #7 adds the support for the SSD132x controller family.

Finally patch #8 adds a DT binding schema for the SSD132x device nodes.

Best regards,
Javier

Javier Martinez Canillas (8):
drm/solomon: Rename ssd130x driver to ssd13xx
drm/ssd13xx: Rename data structures and functions prefixes drm/ssd13xx: Replace .page_height field in device info with a constant drm/ssd13xx: Use drm_format_info_min_pitch() to calculate the
dest_pitch
drm/ssd13xx: Add a per controller family functions table drm/ssd13xx: Rename commands that are shared across chip families drm/ssd13xx: Add support for the SSD132x OLED controller family
dt-bindings: display: Add SSD132x OLED controllers

 .../bindings/display/solomon,ssd132x.yaml     |  116 ++
 MAINTAINERS                                   |    6 +-
 drivers/gpu/drm/solomon/Kconfig               |   28 +-
 drivers/gpu/drm/solomon/Makefile              |    6 +-
 drivers/gpu/drm/solomon/ssd130x-i2c.c         |  112 --
 drivers/gpu/drm/solomon/ssd130x.c             | 1260 --------------
 drivers/gpu/drm/solomon/ssd13xx-i2c.c         |  126 ++
 .../solomon/{ssd130x-spi.c => ssd13xx-spi.c}  |  104 +-
 drivers/gpu/drm/solomon/ssd13xx.c             | 1508 +++++++++++++++++
 .../gpu/drm/solomon/{ssd130x.h => ssd13xx.h}  |   63 +-
 10 files changed, 1876 insertions(+), 1453 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/display/solomon,ssd132x.yaml
 delete mode 100644 drivers/gpu/drm/solomon/ssd130x-i2c.c
 delete mode 100644 drivers/gpu/drm/solomon/ssd130x.c
 create mode 100644 drivers/gpu/drm/solomon/ssd13xx-i2c.c
 rename drivers/gpu/drm/solomon/{ssd130x-spi.c => ssd13xx-spi.c} (54%)
 create mode 100644 drivers/gpu/drm/solomon/ssd13xx.c
 rename drivers/gpu/drm/solomon/{ssd130x.h => ssd13xx.h} (51%)
Signature · 1 line
2.41.0
author maintainer
#1 lore raw

PATCH 1/8 drm/solomon: Rename ssd130x driver to ssd13xx

The driver only supports the SSD130x family of Solomon OLED controllers now, but will be extended to also support the SSD132x (4-bit grayscale) and SSD133x (16-bit RGB) controller families. Rename driver to ssd13xx.

---

 MAINTAINERS                                   |  6 ++--
 drivers/gpu/drm/solomon/Kconfig               | 28 +++++++++----------
 drivers/gpu/drm/solomon/Makefile              |  6 ++--
 .../solomon/{ssd130x-i2c.c => ssd13xx-i2c.c}  | 10 +++----
 .../solomon/{ssd130x-spi.c => ssd13xx-spi.c}  | 14 +++++-----
 .../gpu/drm/solomon/{ssd130x.c => ssd13xx.c}  | 10 +++----
 .../gpu/drm/solomon/{ssd130x.h => ssd13xx.h}  |  8 +++---
 7 files changed, 41 insertions(+), 41 deletions(-)
 rename drivers/gpu/drm/solomon/{ssd130x-i2c.c => ssd13xx-i2c.c} (92%)
 rename drivers/gpu/drm/solomon/{ssd130x-spi.c => ssd13xx-spi.c} (93%)
 rename drivers/gpu/drm/solomon/{ssd130x.c => ssd13xx.c} (99%)
 rename drivers/gpu/drm/solomon/{ssd130x.h => ssd13xx.h} (94%)
MAINTAINERS +3 -3
index 46ca5c4affdb..8eab0d9dca89 100644
@@ -6728,12 +6728,12 @@ T:	git git://anongit.freedesktop.org/drm/drm-misc
 F:	Documentation/devicetree/bindings/display/sitronix,st7735r.yaml
 F:	drivers/gpu/drm/tiny/st7735r.c
 
-DRM DRIVER FOR SOLOMON SSD130X OLED DISPLAYS
+DRM DRIVER FOR SOLOMON SSD13XX OLED DISPLAYS
 M:	Javier Martinez Canillas <[email protected]>
 S:	Maintained
 T:	git git://anongit.freedesktop.org/drm/drm-misc
-F:	Documentation/devicetree/bindings/display/solomon,ssd1307fb.yaml
-F:	drivers/gpu/drm/solomon/ssd130x*
+F:	Documentation/devicetree/bindings/display/solomon,ssd13*.yaml
+F:	drivers/gpu/drm/solomon/ssd13*
 
 DRM DRIVER FOR ST-ERICSSON MCDE
 M:	Linus Walleij <[email protected]>
drivers/gpu/drm/solomon/Kconfig +14 -14
index e170716d976b..ba9f631402bc 100644
@@ -1,31 +1,31 @@
-config DRM_SSD130X
-	tristate "DRM support for Solomon SSD130x OLED displays"
+config DRM_SSD13XX
+	tristate "DRM support for Solomon SSD13xx OLED displays"
 	depends on DRM && MMU
 	select BACKLIGHT_CLASS_DEVICE
 	select DRM_GEM_SHMEM_HELPER
 	select DRM_KMS_HELPER
 	help
-	  DRM driver for the SSD130x Solomon and SINO WEALTH SH110x OLED
+	  DRM driver for the SSD13xx Solomon and SINO WEALTH SH110x OLED
 	  controllers. This is only for the core driver, a driver for the
 	  appropriate bus transport in your chip also must be selected.
 
-	  If M is selected the module will be called ssd130x.
+	  If M is selected the module will be called ssd13xx.
 
-config DRM_SSD130X_I2C
-	tristate "DRM support for Solomon SSD130x OLED displays (I2C bus)"
-	depends on DRM_SSD130X && I2C
+config DRM_SSD13XX_I2C
+	tristate "DRM support for Solomon SSD13xx OLED displays (I2C bus)"
+	depends on DRM_SSD13XX && I2C
 	select REGMAP_I2C
 	help
-	  Say Y here if the SSD130x or SH110x OLED display is connected via
+	  Say Y here if the SSD13xx or SH110x OLED display is connected via
 	  I2C bus.
 
-	  If M is selected the module will be called ssd130x-i2c.
+	  If M is selected the module will be called ssd13xx-i2c.
 
-config DRM_SSD130X_SPI
-	tristate "DRM support for Solomon SSD130X OLED displays (SPI bus)"
-	depends on DRM_SSD130X && SPI
+config DRM_SSD13XX_SPI
+	tristate "DRM support for Solomon SSD13xx OLED displays (SPI bus)"
+	depends on DRM_SSD13XX && SPI
 	select REGMAP
 	help
-	  Say Y here if the SSD130x OLED display is connected via SPI bus.
+	  Say Y here if the SSD13xx OLED display is connected via SPI bus.
 
-	  If M is selected the module will be called ssd130x-spi.
+	  If M is selected the module will be called ssd13xx-spi.
drivers/gpu/drm/solomon/Makefile +3 -3
index b5fc792257d7..6cec14c4062d 100644
@@ -1,3 +1,3 @@
-obj-$(CONFIG_DRM_SSD130X)	+= ssd130x.o
-obj-$(CONFIG_DRM_SSD130X_I2C)	+= ssd130x-i2c.o
-obj-$(CONFIG_DRM_SSD130X_SPI)	+= ssd130x-spi.o
+obj-$(CONFIG_DRM_SSD13XX)	+= ssd13xx.o
+obj-$(CONFIG_DRM_SSD13XX_I2C)	+= ssd13xx-i2c.o
+obj-$(CONFIG_DRM_SSD13XX_SPI)	+= ssd13xx-spi.o
drivers/gpu/drm/solomon/ssd13xx-i2c.c renamed from drivers/gpu/drm/solomon/ssd130x-i2c.c +5 -5
similarity index 92%
rename from drivers/gpu/drm/solomon/ssd130x-i2c.c
rename to drivers/gpu/drm/solomon/ssd13xx-i2c.c
index b4eb2d64bf6e..f4d0feaa8515 100644
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
- * DRM driver for Solomon SSD130x OLED displays (I2C bus)
+ * DRM driver for Solomon SSD13xx OLED displays (I2C bus)
  *
  * Copyright 2022 Red Hat Inc.
  * Author: Javier Martinez Canillas <[email protected]>
@@ -11,10 +11,10 @@
 #include <linux/i2c.h>
 #include <linux/module.h>
 
-#include "ssd130x.h"
+#include "ssd13xx.h"
 
-#define DRIVER_NAME	"ssd130x-i2c"
-#define DRIVER_DESC	"DRM driver for Solomon SSD130x OLED displays (I2C)"
+#define DRIVER_NAME	"ssd13xx-i2c"
+#define DRIVER_DESC	"DRM driver for Solomon SSD13xx OLED displays (I2C)"
 
 static const struct regmap_config ssd130x_i2c_regmap_config = {
 	.reg_bits = 8,
@@ -109,4 +109,4 @@ module_i2c_driver(ssd130x_i2c_driver);
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_AUTHOR("Javier Martinez Canillas <[email protected]>");
 MODULE_LICENSE("GPL v2");
-MODULE_IMPORT_NS(DRM_SSD130X);
+MODULE_IMPORT_NS(DRM_SSD13XX);
drivers/gpu/drm/solomon/ssd13xx-spi.c renamed from drivers/gpu/drm/solomon/ssd130x-spi.c +7 -7
similarity index 93%
rename from drivers/gpu/drm/solomon/ssd130x-spi.c
rename to drivers/gpu/drm/solomon/ssd13xx-spi.c
index 19ab4942cb33..20d1e3711e2f 100644
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
- * DRM driver for Solomon SSD130X OLED displays (SPI bus)
+ * DRM driver for Solomon SSD13xx OLED displays (SPI bus)
  *
  * Copyright 2022 Red Hat Inc.
  * Authors: Javier Martinez Canillas <[email protected]>
@@ -8,10 +8,10 @@
 #include <linux/spi/spi.h>
 #include <linux/module.h>
 
-#include "ssd130x.h"
+#include "ssd13xx.h"
 
-#define DRIVER_NAME	"ssd130x-spi"
-#define DRIVER_DESC	"DRM driver for Solomon SSD130X OLED displays (SPI)"
+#define DRIVER_NAME	"ssd13xx-spi"
+#define DRIVER_DESC	"DRM driver for Solomon SSD13xx OLED displays (SPI)"
 
 struct ssd130x_spi_transport {
 	struct spi_device *spi;
@@ -25,7 +25,7 @@ struct ssd130x_spi_transport {
  * prior to every data byte, that contains a bit with the D/C# value.
  *
  * These control bytes are considered registers by the ssd130x core driver
- * and can be used by the ssd130x SPI driver to determine if the data sent
+ * and can be used by the ssd13xx SPI driver to determine if the data sent
  * is for a command register or for the Graphic Display Data RAM (GDDRAM).
  */
 static int ssd130x_spi_write(void *context, const void *data, size_t count)
@@ -132,7 +132,7 @@ static const struct of_device_id ssd130x_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, ssd130x_of_match);
 
-#if IS_MODULE(CONFIG_DRM_SSD130X_SPI)
+#if IS_MODULE(CONFIG_DRM_SSD13XX_SPI)
 /*
  * The SPI core always reports a MODALIAS uevent of the form "spi:<dev>", even
  * if the device was registered via OF. This means that the module will not be
@@ -166,4 +166,4 @@ module_spi_driver(ssd130x_spi_driver);
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_AUTHOR("Javier Martinez Canillas <[email protected]>");
 MODULE_LICENSE("GPL");
-MODULE_IMPORT_NS(DRM_SSD130X);
+MODULE_IMPORT_NS(DRM_SSD13XX);
drivers/gpu/drm/solomon/ssd13xx.c renamed from drivers/gpu/drm/solomon/ssd130x.c +5 -5
similarity index 99%
rename from drivers/gpu/drm/solomon/ssd130x.c
rename to drivers/gpu/drm/solomon/ssd13xx.c
index 6dcf3e041113..0bf12965719a 100644
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
- * DRM driver for Solomon SSD130x OLED displays
+ * DRM driver for Solomon SSD13xx OLED displays
  *
  * Copyright 2022 Red Hat Inc.
  * Author: Javier Martinez Canillas <[email protected]>
@@ -34,10 +34,10 @@
 #include <drm/drm_rect.h>
 #include <drm/drm_probe_helper.h>
 
-#include "ssd130x.h"
+#include "ssd13xx.h"
 
-#define DRIVER_NAME	"ssd130x"
-#define DRIVER_DESC	"DRM driver for Solomon SSD130x OLED displays"
+#define DRIVER_NAME	"ssd13xx"
+#define DRIVER_DESC	"DRM driver for Solomon SSD13xx OLED displays"
 #define DRIVER_DATE	"20220131"
 #define DRIVER_MAJOR	1
 #define DRIVER_MINOR	0
@@ -139,7 +139,7 @@ const struct ssd130x_deviceinfo ssd130x_variants[] = {
 		.page_height = 8,
 	}
 };
-EXPORT_SYMBOL_NS_GPL(ssd130x_variants, DRM_SSD130X);
+EXPORT_SYMBOL_NS_GPL(ssd130x_variants, DRM_SSD13XX);
 
 struct ssd130x_crtc_state {
 	struct drm_crtc_state base;
drivers/gpu/drm/solomon/ssd13xx.h renamed from drivers/gpu/drm/solomon/ssd130x.h +4 -4
similarity index 94%
rename from drivers/gpu/drm/solomon/ssd130x.h
rename to drivers/gpu/drm/solomon/ssd13xx.h
index aa39b13615eb..f89ccd11cd29 100644
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
  * Header file for:
- * DRM driver for Solomon SSD130x OLED displays
+ * DRM driver for Solomon SSD13xx OLED displays
  *
  * Copyright 2022 Red Hat Inc.
  * Author: Javier Martinez Canillas <[email protected]>
@@ -10,8 +10,8 @@
  * Copyright 2012 Free Electrons
  */
 
-#ifndef __SSD130X_H__
-#define __SSD130X_H__
+#ifndef __SSD13XX_H__
+#define __SSD13XX_H__
 
 #include <drm/drm_connector.h>
 #include <drm/drm_crtc.h>
@@ -97,4 +97,4 @@ struct ssd130x_device *ssd130x_probe(struct device *dev, struct regmap *regmap);
 void ssd130x_remove(struct ssd130x_device *ssd130x);
 void ssd130x_shutdown(struct ssd130x_device *ssd130x);
 
-#endif /* __SSD130X_H__ */
+#endif /* __SSD13XX_H__ */
Signature · 1 line
2.41.0
maintainer
#2 lore raw

Re: [PATCH 1/8] drm/solomon: Rename ssd130x driver to ssd13xx

Hi,

Quoted 5 lines · Javier Martinez Canillas

The driver only supports the SSD130x family of Solomon OLED controllers now, but will be extended to also support the SSD132x (4-bit grayscale) and SSD133x (16-bit RGB) controller families. Rename driver to ssd13xx.

I'm not sure it's worth it. I understand what you want to achieve, but this will create conflicts, affect the configuration of everyone enabling that driver, etc.

And we have plenty of drivers that don't match all the devices they support anyway.

Plus ....

Quoted 4 lines
drivers/gpu/drm/solomon/ssd13xx-i2c.c renamed from drivers/gpu/drm/solomon/ssd130x-i2c.c +0 -0
@@ -11,10 +11,10 @@
 #include <linux/i2c.h>
 #include <linux/module.h>
 

drivers/gpu/drm/solomon/ssd13xx-i2c.c line 20

Quoted 10 lines
drivers/gpu/drm/solomon/ssd13xx-i2c.c renamed from drivers/gpu/drm/solomon/ssd130x-i2c.c +3 -3
-#include "ssd130x.h"
+#include "ssd13xx.h"
 
-#define DRIVER_NAME	"ssd130x-i2c"
-#define DRIVER_DESC	"DRM driver for Solomon SSD130x OLED displays (I2C)"
+#define DRIVER_NAME	"ssd13xx-i2c"
+#define DRIVER_DESC	"DRM driver for Solomon SSD13xx OLED displays (I2C)"
 
 static const struct regmap_config ssd130x_i2c_regmap_config = {
 	.reg_bits = 8,

... We now end up with a lot of inconsistencies where some things are called ssd130x and others ssd13xx.

Maxime

author maintainer
#3 lore raw

Re: [PATCH 1/8] drm/solomon: Rename ssd130x driver to ssd13xx

Maxime Ripard <[email protected]> writes:

Hello Maxime,

Thanks for the feedback.

Quoted 7 lines

Hi,

Quoted 4 lines · Javier Martinez Canillas

The driver only supports the SSD130x family of Solomon OLED controllers now, but will be extended to also support the SSD132x (4-bit grayscale) and SSD133x (16-bit RGB) controller families. Rename driver to ssd13xx.

Quoted 9 lines
Quoted 1 line

I'm not sure it's worth it. I understand what you want to achieve, but this will create conflicts, affect the configuration of everyone enabling that driver, etc.

And we have plenty of drivers that don't match all the devices they support anyway.

Yeah, I was on the fence and even discussed this with others. I'm OK with dropping this patch if the agreegment is that isn't worth it to make the name more accurate.

Quoted 14 lines

Plus ....

Quoted 12 lines
drivers/gpu/drm/solomon/ssd13xx-i2c.c renamed from drivers/gpu/drm/solomon/ssd130x-i2c.c +3 -3
@@ -11,10 +11,10 @@
 #include <linux/i2c.h>
 #include <linux/module.h>
 
-#include "ssd130x.h"
+#include "ssd13xx.h"
 
-#define DRIVER_NAME	"ssd130x-i2c"
-#define DRIVER_DESC	"DRM driver for Solomon SSD130x OLED displays (I2C)"
+#define DRIVER_NAME	"ssd13xx-i2c"
+#define DRIVER_DESC	"DRM driver for Solomon SSD13xx OLED displays (I2C)"
 
Quoted 6 lines

drivers/gpu/drm/solomon/ssd13xx-i2c.c line 20

Quoted 2 lines
drivers/gpu/drm/solomon/ssd13xx-i2c.c renamed from drivers/gpu/drm/solomon/ssd130x-i2c.c +0 -0
 static const struct regmap_config ssd130x_i2c_regmap_config = {
 	.reg_bits = 8,

... We now end up with a lot of inconsistencies where some things are called ssd130x and others ssd13xx.

Yes, but I fix that in patch #2.

Quoted 1 line

Maxime

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
author maintainer
#4 lore raw

PATCH 2/8 drm/ssd13xx: Rename data structures and functions prefixes

In reply to Javier Martinez Canillas

Since the driver is now called ssd13xx and will support other Solomon OLED controller families, rename the structs and functions prefixes as well.

---

 drivers/gpu/drm/solomon/ssd13xx-i2c.c |  63 +--
 drivers/gpu/drm/solomon/ssd13xx-spi.c |  73 +--
 drivers/gpu/drm/solomon/ssd13xx.c     | 644 +++++++++++++-------------
 drivers/gpu/drm/solomon/ssd13xx.h     |  18 +-
 4 files changed, 400 insertions(+), 398 deletions(-)
drivers/gpu/drm/solomon/ssd13xx-i2c.c +32 -31
index f4d0feaa8515..d9cece374331 100644
@@ -16,95 +16,96 @@
 #define DRIVER_NAME	"ssd13xx-i2c"
 #define DRIVER_DESC	"DRM driver for Solomon SSD13xx OLED displays (I2C)"
 
-static const struct regmap_config ssd130x_i2c_regmap_config = {
+static const struct regmap_config ssd13xx_i2c_regmap_config = {
 	.reg_bits = 8,
 	.val_bits = 8,
 };
 
-static int ssd130x_i2c_probe(struct i2c_client *client)
+static int ssd13xx_i2c_probe(struct i2c_client *client)
 {
-	struct ssd130x_device *ssd130x;
+	struct ssd13xx_device *ssd13xx;
 	struct regmap *regmap;
 
-	regmap = devm_regmap_init_i2c(client, &ssd130x_i2c_regmap_config);
+	regmap = devm_regmap_init_i2c(client, &ssd13xx_i2c_regmap_config);
 	if (IS_ERR(regmap))
 		return PTR_ERR(regmap);
 
-	ssd130x = ssd130x_probe(&client->dev, regmap);
-	if (IS_ERR(ssd130x))
-		return PTR_ERR(ssd130x);
+	ssd13xx = ssd13xx_probe(&client->dev, regmap);
+	if (IS_ERR(ssd13xx))
+		return PTR_ERR(ssd13xx);
 
-	i2c_set_clientdata(client, ssd130x);
+	i2c_set_clientdata(client, ssd13xx);
 
 	return 0;
 }
 
-static void ssd130x_i2c_remove(struct i2c_client *client)
+static void ssd13xx_i2c_remove(struct i2c_client *client)
 {
-	struct ssd130x_device *ssd130x = i2c_get_clientdata(client);
+	struct ssd13xx_device *ssd13xx = i2c_get_clientdata(client);
 
-	ssd130x_remove(ssd130x);
+	ssd13xx_remove(ssd13xx);
 }
 
-static void ssd130x_i2c_shutdown(struct i2c_client *client)
+static void ssd13xx_i2c_shutdown(struct i2c_client *client)
 {
-	struct ssd130x_device *ssd130x = i2c_get_clientdata(client);
+	struct ssd13xx_device *ssd13xx = i2c_get_clientdata(client);
 
-	ssd130x_shutdown(ssd130x);
+	ssd13xx_shutdown(ssd13xx);
 }
 
-static const struct of_device_id ssd130x_of_match[] = {
+static const struct of_device_id ssd13xx_of_match[] = {
+	/* ssd130x family */
 	{
 		.compatible = "sinowealth,sh1106",
-		.data = &ssd130x_variants[SH1106_ID],
+		.data = &ssd13xx_variants[SH1106_ID],
 	},
 	{
 		.compatible = "solomon,ssd1305",
-		.data = &ssd130x_variants[SSD1305_ID],
+		.data = &ssd13xx_variants[SSD1305_ID],
 	},
 	{
 		.compatible = "solomon,ssd1306",
-		.data = &ssd130x_variants[SSD1306_ID],
+		.data = &ssd13xx_variants[SSD1306_ID],
 	},
 	{
 		.compatible = "solomon,ssd1307",
-		.data = &ssd130x_variants[SSD1307_ID],
+		.data = &ssd13xx_variants[SSD1307_ID],
 	},
 	{
 		.compatible = "solomon,ssd1309",
-		.data = &ssd130x_variants[SSD1309_ID],
+		.data = &ssd13xx_variants[SSD1309_ID],
 	},
 	/* Deprecated but kept for backward compatibility */
 	{
 		.compatible = "solomon,ssd1305fb-i2c",
-		.data = &ssd130x_variants[SSD1305_ID],
+		.data = &ssd13xx_variants[SSD1305_ID],
 	},
 	{
 		.compatible = "solomon,ssd1306fb-i2c",
-		.data = &ssd130x_variants[SSD1306_ID],
+		.data = &ssd13xx_variants[SSD1306_ID],
 	},
 	{
 		.compatible = "solomon,ssd1307fb-i2c",
-		.data = &ssd130x_variants[SSD1307_ID],
+		.data = &ssd13xx_variants[SSD1307_ID],
 	},
 	{
 		.compatible = "solomon,ssd1309fb-i2c",
-		.data = &ssd130x_variants[SSD1309_ID],
+		.data = &ssd13xx_variants[SSD1309_ID],
 	},
 	{ /* sentinel */ }
 };
-MODULE_DEVICE_TABLE(of, ssd130x_of_match);
+MODULE_DEVICE_TABLE(of, ssd13xx_of_match);
 
-static struct i2c_driver ssd130x_i2c_driver = {
+static struct i2c_driver ssd13xx_i2c_driver = {
 	.driver = {
 		.name = DRIVER_NAME,
-		.of_match_table = ssd130x_of_match,
+		.of_match_table = ssd13xx_of_match,
 	},
-	.probe = ssd130x_i2c_probe,
-	.remove = ssd130x_i2c_remove,
-	.shutdown = ssd130x_i2c_shutdown,
+	.probe = ssd13xx_i2c_probe,
+	.remove = ssd13xx_i2c_remove,
+	.shutdown = ssd13xx_i2c_shutdown,
 };
-module_i2c_driver(ssd130x_i2c_driver);
+module_i2c_driver(ssd13xx_i2c_driver);
 
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_AUTHOR("Javier Martinez Canillas <[email protected]>");
drivers/gpu/drm/solomon/ssd13xx-spi.c +37 -36

160 lines not on this page · raw message

drivers/gpu/drm/solomon/ssd13xx.c +322 -322

1,317 lines not on this page · raw message

drivers/gpu/drm/solomon/ssd13xx.h +9 -9
index f89ccd11cd29..e5abf23196b0 100644
@@ -24,16 +24,16 @@
 #define SSD130X_DATA				0x40
 #define SSD130X_COMMAND				0x80
 
-enum ssd130x_variants {
+enum ssd13xx_variants {
 	SH1106_ID,
 	SSD1305_ID,
 	SSD1306_ID,
 	SSD1307_ID,
 	SSD1309_ID,
-	NR_SSD130X_VARIANTS
+	NR_SSD13XX_VARIANTS
 };
 
-struct ssd130x_deviceinfo {
+struct ssd13xx_deviceinfo {
 	u32 default_vcomh;
 	u32 default_dclk_div;
 	u32 default_dclk_frq;
@@ -45,7 +45,7 @@ struct ssd130x_deviceinfo {
 	bool page_mode_only;
 };
 
-struct ssd130x_device {
+struct ssd13xx_device {
 	struct drm_device drm;
 	struct device *dev;
 	struct drm_display_mode mode;
@@ -57,7 +57,7 @@ struct ssd130x_device {
 
 	struct regmap *regmap;
 
-	const struct ssd130x_deviceinfo *device_info;
+	const struct ssd13xx_deviceinfo *device_info;
 
 	unsigned page_address_mode : 1;
 	unsigned area_color_enable : 1;
@@ -91,10 +91,10 @@ struct ssd130x_device {
 	u8 page_end;
 };
 
-extern const struct ssd130x_deviceinfo ssd130x_variants[];
+extern const struct ssd13xx_deviceinfo ssd13xx_variants[];
 
-struct ssd130x_device *ssd130x_probe(struct device *dev, struct regmap *regmap);
-void ssd130x_remove(struct ssd130x_device *ssd130x);
-void ssd130x_shutdown(struct ssd130x_device *ssd130x);
+struct ssd13xx_device *ssd13xx_probe(struct device *dev, struct regmap *regmap);
+void ssd13xx_remove(struct ssd13xx_device *ssd13xx);
+void ssd13xx_shutdown(struct ssd13xx_device *ssd13xx);
 
 #endif /* __SSD13XX_H__ */
Signature · 1 line
2.41.0
author maintainer
#5 lore raw

PATCH 3/8 drm/ssd13xx: Replace .page_height field in device info with a constant

In reply to Javier Martinez Canillas

This deemed useful to avoid hardcoding a page height and allow to support other Solomon controller families, but dividing the screen in pages seems to be something that is specific to the SSD130x chip family.

For example, SSD132x chip family divides the screen in segments (columns) and common outputs (rows), so the concept of screen pages does not exist for the SSD132x family.

Let's drop this field from the device info struct and just use a constant SSD130X_PAGE_HEIGHT macro to define the page height. While being there, replace hardcoded 8 values in places where it is used as the page height.

---

 drivers/gpu/drm/solomon/ssd13xx.c | 37 +++++++++++++++----------------
 drivers/gpu/drm/solomon/ssd13xx.h |  1 -
 2 files changed, 18 insertions(+), 20 deletions(-)
drivers/gpu/drm/solomon/ssd13xx.c +18 -19
index 10a767fb614c..d29be17665b5 100644
@@ -42,6 +42,8 @@
 #define DRIVER_MAJOR	1
 #define DRIVER_MINOR	0
 
+#define SSD130X_PAGE_HEIGHT 8
+
 #define SSD130X_PAGE_COL_START_LOW		0x00
 #define SSD130X_PAGE_COL_START_HIGH		0x10
 #define SSD130X_SET_ADDRESS_MODE		0x20
@@ -102,7 +104,6 @@ const struct ssd13xx_deviceinfo ssd13xx_variants[] = {
 		.default_width = 132,
 		.default_height = 64,
 		.page_mode_only = 1,
-		.page_height = 8,
 	},
 	[SSD1305_ID] = {
 		.default_vcomh = 0x34,
@@ -110,7 +111,6 @@ const struct ssd13xx_deviceinfo ssd13xx_variants[] = {
 		.default_dclk_frq = 7,
 		.default_width = 132,
 		.default_height = 64,
-		.page_height = 8,
 	},
 	[SSD1306_ID] = {
 		.default_vcomh = 0x20,
@@ -119,7 +119,6 @@ const struct ssd13xx_deviceinfo ssd13xx_variants[] = {
 		.need_chargepump = 1,
 		.default_width = 128,
 		.default_height = 64,
-		.page_height = 8,
 	},
 	[SSD1307_ID] = {
 		.default_vcomh = 0x20,
@@ -128,7 +127,6 @@ const struct ssd13xx_deviceinfo ssd13xx_variants[] = {
 		.need_pwm = 1,
 		.default_width = 128,
 		.default_height = 39,
-		.page_height = 8,
 	},
 	[SSD1309_ID] = {
 		.default_vcomh = 0x34,
@@ -136,7 +134,6 @@ const struct ssd13xx_deviceinfo ssd13xx_variants[] = {
 		.default_dclk_frq = 10,
 		.default_width = 128,
 		.default_height = 64,
-		.page_height = 8,
 	}
 };
 EXPORT_SYMBOL_NS_GPL(ssd13xx_variants, DRM_SSD13XX);
@@ -465,13 +462,13 @@ static int ssd13xx_update_rect(struct ssd13xx_device *ssd13xx,
 	unsigned int width = drm_rect_width(rect);
 	unsigned int height = drm_rect_height(rect);
 	unsigned int line_length = DIV_ROUND_UP(width, 8);
-	unsigned int page_height = ssd13xx->device_info->page_height;
+	unsigned int page_height = SSD130X_PAGE_HEIGHT;
 	unsigned int pages = DIV_ROUND_UP(height, page_height);
 	struct drm_device *drm = &ssd13xx->drm;
 	u32 array_idx = 0;
 	int ret, i, j, k;
 
-	drm_WARN_ONCE(drm, y % 8 != 0, "y must be aligned to screen page\n");
+	drm_WARN_ONCE(drm, y % page_height != 0, "y must be aligned to screen page\n");
 
 	/*
 	 * The screen is divided in pages, each having a height of 8
@@ -503,27 +500,32 @@ static int ssd13xx_update_rect(struct ssd13xx_device *ssd13xx,
 	 */
 
 	if (!ssd13xx->page_address_mode) {
+		u8 page_start;
+
 		/* Set address range for horizontal addressing mode */
 		ret = ssd13xx_set_col_range(ssd13xx, ssd13xx->col_offset + x, width);
 		if (ret < 0)
 			return ret;
 
-		ret = ssd13xx_set_page_range(ssd13xx, ssd13xx->page_offset + y / 8, pages);
+		page_start = ssd13xx->page_offset + y / page_height;
+		ret = ssd13xx_set_page_range(ssd13xx, page_start, pages);
 		if (ret < 0)
 			return ret;
 	}
 
 	for (i = 0; i < pages; i++) {
-		int m = 8;
+		int m = page_height;
 
 		/* Last page may be partial */
-		if (8 * (y / 8 + i + 1) > ssd13xx->height)
-			m = ssd13xx->height % 8;
+		if (page_height * (y / page_height + i + 1) > ssd13xx->height)
+			m = ssd13xx->height % page_height;
+
 		for (j = 0; j < width; j++) {
 			u8 data = 0;
 
 			for (k = 0; k < m; k++) {
-				u8 byte = buf[(8 * i + k) * line_length + j / 8];
+				u32 idx = (page_height * i + k) * line_length + j / 8;
+				u8 byte = buf[idx];
 				u8 bit = (byte >> (j % 8)) & 1;
 
 				data |= bit << k;
@@ -559,8 +561,7 @@ static int ssd13xx_update_rect(struct ssd13xx_device *ssd13xx,
 
 static void ssd13xx_clear_screen(struct ssd13xx_device *ssd13xx, u8 *data_array)
 {
-	unsigned int page_height = ssd13xx->device_info->page_height;
-	unsigned int pages = DIV_ROUND_UP(ssd13xx->height, page_height);
+	unsigned int pages = DIV_ROUND_UP(ssd13xx->height, SSD130X_PAGE_HEIGHT);
 	unsigned int width = ssd13xx->width;
 	int ret, i;
 
@@ -605,14 +606,13 @@ static int ssd13xx_fb_blit_rect(struct drm_framebuffer *fb,
 				u8 *buf, u8 *data_array)
 {
 	struct ssd13xx_device *ssd13xx = drm_to_ssd13xx(fb->dev);
-	unsigned int page_height = ssd13xx->device_info->page_height;
 	struct iosys_map dst;
 	unsigned int dst_pitch;
 	int ret = 0;
 
 	/* Align y to display page boundaries */
-	rect->y1 = round_down(rect->y1, page_height);
-	rect->y2 = min_t(unsigned int, round_up(rect->y2, page_height), ssd13xx->height);
+	rect->y1 = round_down(rect->y1, SSD130X_PAGE_HEIGHT);
+	rect->y2 = min_t(unsigned int, round_up(rect->y2, SSD130X_PAGE_HEIGHT), ssd13xx->height);
 
 	dst_pitch = DIV_ROUND_UP(drm_rect_width(rect), 8);
 
@@ -814,8 +814,7 @@ static int ssd13xx_crtc_atomic_check(struct drm_crtc *crtc,
 	struct ssd13xx_device *ssd13xx = drm_to_ssd13xx(drm);
 	struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
 	struct ssd13xx_crtc_state *ssd13xx_state = to_ssd13xx_crtc_state(crtc_state);
-	unsigned int page_height = ssd13xx->device_info->page_height;
-	unsigned int pages = DIV_ROUND_UP(ssd13xx->height, page_height);
+	unsigned int pages = DIV_ROUND_UP(ssd13xx->height, SSD130X_PAGE_HEIGHT);
 	int ret;
 
 	ret = drm_crtc_helper_atomic_check(crtc, state);
drivers/gpu/drm/solomon/ssd13xx.h +0 -1
index e5abf23196b0..64283935fbc1 100644
@@ -39,7 +39,6 @@ struct ssd13xx_deviceinfo {
 	u32 default_dclk_frq;
 	u32 default_width;
 	u32 default_height;
-	u32 page_height;
 	bool need_pwm;
 	bool need_chargepump;
 	bool page_mode_only;
Signature · 1 line
2.41.0
Reviewed-by on v1 3/8
#6 lore raw

Re: [PATCH 3/8] drm/ssd13xx: Replace .page_height field in device info with a constant

Quoted 57 lines · Javier Martinez Canillas

This deemed useful to avoid hardcoding a page height and allow to support other Solomon controller families, but dividing the screen in pages seems to be something that is specific to the SSD130x chip family.

For example, SSD132x chip family divides the screen in segments (columns) and common outputs (rows), so the concept of screen pages does not exist for the SSD132x family.

Let's drop this field from the device info struct and just use a constant SSD130X_PAGE_HEIGHT macro to define the page height. While being there, replace hardcoded 8 values in places where it is used as the page height.

drivers/gpu/drm/solomon/ssd13xx.c +7 -5
@@ -465,13 +462,13 @@ static int ssd13xx_update_rect(struct ssd13xx_device *ssd13xx,
        unsigned int width = drm_rect_width(rect);
        unsigned int height = drm_rect_height(rect);
        unsigned int line_length = DIV_ROUND_UP(width, 8);
-       unsigned int page_height = ssd13xx->device_info->page_height;
+       unsigned int page_height = SSD130X_PAGE_HEIGHT;
        unsigned int pages = DIV_ROUND_UP(height, page_height);
        struct drm_device *drm = &ssd13xx->drm;
        u32 array_idx = 0;
        int ret, i, j, k;
 
-       drm_WARN_ONCE(drm, y % 8 != 0, "y must be aligned to screen page\n");
+       drm_WARN_ONCE(drm, y % page_height != 0, "y must be aligned to screen page\n");
 
        /*
         * The screen is divided in pages, each having a height of 8
@@ -503,27 +500,32 @@ static int ssd13xx_update_rect(struct ssd13xx_device *ssd13xx,
         */
 
        if (!ssd13xx->page_address_mode) {
+               u8 page_start;
+
                /* Set address range for horizontal addressing mode */
                ret = ssd13xx_set_col_range(ssd13xx, ssd13xx->col_offset + x, width);
                if (ret < 0)
                        return ret;
 
-               ret = ssd13xx_set_page_range(ssd13xx, ssd13xx->page_offset + y / 8, pages);
+               page_start = ssd13xx->page_offset + y / page_height;
+               ret = ssd13xx_set_page_range(ssd13xx, page_start, pages);
                if (ret < 0)
                        return ret;
        }
 
        for (i = 0; i < pages; i++) {
-               int m = 8;
+               int m = page_height;
 
                /* Last page may be partial */
-               if (8 * (y / 8 + i + 1) > ssd13xx->height)

drivers/gpu/drm/solomon/ssd13xx.c static int ssd13xx_update_rect(struct ssd13xx_device *ssd13xx, · line 527

Quoted 10 lines
drivers/gpu/drm/solomon/ssd13xx.c +4 -2
-                       m = ssd13xx->height % 8;
+               if (page_height * (y / page_height + i + 1) > ssd13xx->height)
+                       m = ssd13xx->height % page_height;
+
                for (j = 0; j < width; j++) {
                        u8 data = 0;
 
                        for (k = 0; k < m; k++) {
-                               u8 byte = buf[(8 * i + k) * line_length + j / 8];
+                               u32 idx = (page_height * i + k) * line_length + j / 8;

Nit: I would use unsigned int for idx, as that matches all other variables involved.
But given array_idx is u32, too, u32 may makes sense.

drivers/gpu/drm/solomon/ssd13xx.c static int ssd13xx_update_rect(struct ssd13xx_device *ssd13xx, · line 531

Quoted 4 lines
drivers/gpu/drm/solomon/ssd13xx.c +1 -0
+                               u8 byte = buf[idx];
                                u8 bit = (byte >> (j % 8)) & 1;
 
                                data |= bit << k;

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
author maintainer
#7 lore raw

Re: [PATCH 3/8] drm/ssd13xx: Replace .page_height field in device info with a constant

Geert Uytterhoeven <[email protected]> writes:

Hello Geert,

Thanks a lot for your feedback.

Quoted 2 lines

On Mon, Oct 9, 2023 at 8:36 PM Javier Martinez Canillas <[email protected]> wrote:

[...]

Quoted 1 line
Quoted 1 line
        u32 array_idx = 0;

[...]

Quoted 9 lines

drivers/gpu/drm/solomon/ssd13xx.c static int ssd13xx_update_rect(struct ssd13xx_device *ssd13xx, · line 527

Quoted 4 lines
                        for (k = 0; k < m; k++) {
drivers/gpu/drm/solomon/ssd13xx.c +1 -1
-                               u8 byte = buf[(8 * i + k) * line_length + j / 8];
+                               u32 idx = (page_height * i + k) * line_length + j / 8;

Nit: I would use unsigned int for idx, as that matches all other variables involved.
But given array_idx is u32, too, u32 may makes sense.

Yes, this function logic is mostly based on ssd1307fb_update_rect() from drivers/video/fbdev/ssd1307fb.c and that is from where the u32 array_idx comes from.

As you said, I used u32 for idx to be consistent with that variable type.

Quoted 7 lines
Quoted 4 lines
+                               u8 byte = buf[idx];
                                u8 bit = (byte >> (j % 8)) & 1;

                                data |= bit << k;

Thanks!

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
author maintainer
#8 lore raw

PATCH 4/8 drm/ssd13xx: Use drm_format_info_min_pitch() to calculate the dest_pitch

In reply to Javier Martinez Canillas

Don't assume bpp of 1 and instead compute the destination pitch using the intermediate buffer pixel format info when doing a format conversion.

---

 drivers/gpu/drm/solomon/ssd13xx.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/gpu/drm/solomon/ssd13xx.c +9 -3
index d29be17665b5..9747f8656636 100644
@@ -148,6 +148,8 @@ struct ssd13xx_plane_state {
 	struct drm_shadow_plane_state base;
 	/* Intermediate buffer to convert pixels from XRGB8888 to HW format */
 	u8 *buffer;
+	/* Pixel format info for the intermediate buffer */
+	const struct drm_format_info *fi;
 };
 
 static inline struct ssd13xx_crtc_state *to_ssd13xx_crtc_state(struct drm_crtc_state *state)
@@ -602,8 +604,9 @@ static void ssd13xx_clear_screen(struct ssd13xx_device *ssd13xx, u8 *data_array)
 
 static int ssd13xx_fb_blit_rect(struct drm_framebuffer *fb,
 				const struct iosys_map *vmap,
-				struct drm_rect *rect,
-				u8 *buf, u8 *data_array)
+				struct drm_rect *rect, u8 *buf,
+				const struct drm_format_info *fi,
+				u8 *data_array)
 {
 	struct ssd13xx_device *ssd13xx = drm_to_ssd13xx(fb->dev);
 	struct iosys_map dst;
@@ -614,7 +617,7 @@ static int ssd13xx_fb_blit_rect(struct drm_framebuffer *fb,
 	rect->y1 = round_down(rect->y1, SSD130X_PAGE_HEIGHT);
 	rect->y2 = min_t(unsigned int, round_up(rect->y2, SSD130X_PAGE_HEIGHT), ssd13xx->height);
 
-	dst_pitch = DIV_ROUND_UP(drm_rect_width(rect), 8);
+	dst_pitch = drm_format_info_min_pitch(fi, 0, drm_rect_width(rect));
 
 	ret = drm_gem_fb_begin_cpu_access(fb, DMA_FROM_DEVICE);
 	if (ret)
@@ -664,6 +667,8 @@ static int ssd13xx_primary_plane_atomic_check(struct drm_plane *plane,
 	if (!ssd13xx_state->buffer)
 		return -ENOMEM;
 
+	ssd13xx_state->fi = fi;
+
 	return 0;
 }
 
@@ -695,6 +700,7 @@ static void ssd13xx_primary_plane_atomic_update(struct drm_plane *plane,
 
 		ssd13xx_fb_blit_rect(fb, &shadow_plane_state->data[0], &dst_clip,
 				     ssd13xx_plane_state->buffer,
+				     ssd13xx_plane_state->fi,
 				     ssd13xx_crtc_state->data_array);
 	}
 
Signature · 1 line
2.41.0
#9 lore raw

Re: [PATCH 4/8] drm/ssd13xx: Use drm_format_info_min_pitch() to calculate the dest_pitch

Hi Javier,

Quoted 4 lines · Javier Martinez Canillas

Don't assume bpp of 1 and instead compute the destination pitch using the intermediate buffer pixel format info when doing a format conversion.

Thanks for your patch!

drivers/gpu/drm/solomon/ssd13xx.c struct ssd13xx_plane_state { · line 152

Quoted 8 lines
drivers/gpu/drm/solomon/ssd13xx.c +2 -0
@@ -148,6 +148,8 @@ struct ssd13xx_plane_state {
        struct drm_shadow_plane_state base;
        /* Intermediate buffer to convert pixels from XRGB8888 to HW format */
        u8 *buffer;
+       /* Pixel format info for the intermediate buffer */
+       const struct drm_format_info *fi;

This is really intermediate, as it is removed again in the next patch :-)

In fact 60% of this patch is changed again in the next patch. So perhaps combine this with the next patch?

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
author maintainer
#10 lore raw

Re: [PATCH 4/8] drm/ssd13xx: Use drm_format_info_min_pitch() to calculate the dest_pitch

Quoted 22 lines · Geert Uytterhoeven

Hi Javier,

Quoted 4 lines · Javier Martinez Canillas

Don't assume bpp of 1 and instead compute the destination pitch using the intermediate buffer pixel format info when doing a format conversion.

Thanks for your patch!

drivers/gpu/drm/solomon/ssd13xx.c struct ssd13xx_plane_state { · line 152

Quoted 8 lines
drivers/gpu/drm/solomon/ssd13xx.c +2 -0
@@ -148,6 +148,8 @@ struct ssd13xx_plane_state {
        struct drm_shadow_plane_state base;
        /* Intermediate buffer to convert pixels from XRGB8888 to HW format */
        u8 *buffer;
+       /* Pixel format info for the intermediate buffer */
+       const struct drm_format_info *fi;

This is really intermediate, as it is removed again in the next patch :-)

Quoted 3 lines

In fact 60% of this patch is changed again in the next patch. So perhaps combine this with the next patch?

I actually had it like that but then thought that maybe someone would say that should be a separate patch :) I will squash it then.

Quoted 2 lines

Gr{oetje,eeting}s,

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
author maintainer
#11 lore raw

PATCH 5/8 drm/ssd13xx: Add a per controller family functions table

In reply to Javier Martinez Canillas

To allow the driver to decouple the common logic in the function callbacks from the behaviour that is specific of a given Solomon controller family.

For this, include a chip family to the device info and add fields to the driver-private device struct, to store the hardware buffer maximum size, the intermediate buffer maximum size and pixel format, and a set of per chip family function handlers.

---

 drivers/gpu/drm/solomon/ssd13xx.c | 88 ++++++++++++++++++++++---------
 drivers/gpu/drm/solomon/ssd13xx.h | 27 ++++++++++
 2 files changed, 90 insertions(+), 25 deletions(-)
drivers/gpu/drm/solomon/ssd13xx.c +63 -25
index 9747f8656636..5a426ac10c58 100644
@@ -104,6 +104,7 @@ const struct ssd13xx_deviceinfo ssd13xx_variants[] = {
 		.default_width = 132,
 		.default_height = 64,
 		.page_mode_only = 1,
+		.family_id = SSD130X_FAMILY,
 	},
 	[SSD1305_ID] = {
 		.default_vcomh = 0x34,
@@ -111,6 +112,7 @@ const struct ssd13xx_deviceinfo ssd13xx_variants[] = {
 		.default_dclk_frq = 7,
 		.default_width = 132,
 		.default_height = 64,
+		.family_id = SSD130X_FAMILY,
 	},
 	[SSD1306_ID] = {
 		.default_vcomh = 0x20,
@@ -119,6 +121,7 @@ const struct ssd13xx_deviceinfo ssd13xx_variants[] = {
 		.need_chargepump = 1,
 		.default_width = 128,
 		.default_height = 64,
+		.family_id = SSD130X_FAMILY,
 	},
 	[SSD1307_ID] = {
 		.default_vcomh = 0x20,
@@ -127,6 +130,7 @@ const struct ssd13xx_deviceinfo ssd13xx_variants[] = {
 		.need_pwm = 1,
 		.default_width = 128,
 		.default_height = 39,
+		.family_id = SSD130X_FAMILY,
 	},
 	[SSD1309_ID] = {
 		.default_vcomh = 0x34,
@@ -134,6 +138,7 @@ const struct ssd13xx_deviceinfo ssd13xx_variants[] = {
 		.default_dclk_frq = 10,
 		.default_width = 128,
 		.default_height = 64,
+		.family_id = SSD130X_FAMILY,
 	}
 };
 EXPORT_SYMBOL_NS_GPL(ssd13xx_variants, DRM_SSD13XX);
@@ -148,8 +153,6 @@ struct ssd13xx_plane_state {
 	struct drm_shadow_plane_state base;
 	/* Intermediate buffer to convert pixels from XRGB8888 to HW format */
 	u8 *buffer;
-	/* Pixel format info for the intermediate buffer */
-	const struct drm_format_info *fi;
 };
 
 static inline struct ssd13xx_crtc_state *to_ssd13xx_crtc_state(struct drm_crtc_state *state)
@@ -331,7 +334,7 @@ static void ssd13xx_power_off(struct ssd13xx_device *ssd13xx)
 	regulator_disable(ssd13xx->vcc_reg);
 }
 
-static int ssd13xx_init(struct ssd13xx_device *ssd13xx)
+static int ssd130x_init(struct ssd13xx_device *ssd13xx)
 {
 	u32 precharge, dclk, com_invdir, compins, chargepump, seg_remap;
 	bool scan_mode;
@@ -455,7 +458,7 @@ static int ssd13xx_init(struct ssd13xx_device *ssd13xx)
 				 SSD130X_SET_ADDRESS_MODE_HORIZONTAL);
 }
 
-static int ssd13xx_update_rect(struct ssd13xx_device *ssd13xx,
+static int ssd130x_update_rect(struct ssd13xx_device *ssd13xx,
 			       struct drm_rect *rect, u8 *buf,
 			       u8 *data_array)
 {
@@ -561,7 +564,7 @@ static int ssd13xx_update_rect(struct ssd13xx_device *ssd13xx,
 	return ret;
 }
 
-static void ssd13xx_clear_screen(struct ssd13xx_device *ssd13xx, u8 *data_array)
+static void ssd130x_clear_screen(struct ssd13xx_device *ssd13xx, u8 *data_array)
 {
 	unsigned int pages = DIV_ROUND_UP(ssd13xx->height, SSD130X_PAGE_HEIGHT);
 	unsigned int width = ssd13xx->width;
@@ -602,6 +605,15 @@ static void ssd13xx_clear_screen(struct ssd13xx_device *ssd13xx, u8 *data_array)
 	}
 }
 
+static const struct ssd13xx_funcs ssd13xx_family_funcs[] = {
+	[SSD130X_FAMILY] = {
+		.init = ssd130x_init,
+		.update_rect = ssd130x_update_rect,
+		.clear_screen = ssd130x_clear_screen,
+		.fmt_convert = drm_fb_xrgb8888_to_mono,
+	},
+};
+
 static int ssd13xx_fb_blit_rect(struct drm_framebuffer *fb,
 				const struct iosys_map *vmap,
 				struct drm_rect *rect, u8 *buf,
@@ -609,6 +621,7 @@ static int ssd13xx_fb_blit_rect(struct drm_framebuffer *fb,
 				u8 *data_array)
 {
 	struct ssd13xx_device *ssd13xx = drm_to_ssd13xx(fb->dev);
+	const struct ssd13xx_funcs *ssd13xx_funcs = ssd13xx->funcs;
 	struct iosys_map dst;
 	unsigned int dst_pitch;
 	int ret = 0;
@@ -624,13 +637,11 @@ static int ssd13xx_fb_blit_rect(struct drm_framebuffer *fb,
 		return ret;
 
 	iosys_map_set_vaddr(&dst, buf);
-	drm_fb_xrgb8888_to_mono(&dst, &dst_pitch, vmap, fb, rect);
+	ssd13xx_funcs->fmt_convert(&dst, &dst_pitch, vmap, fb, rect);
 
 	drm_gem_fb_end_cpu_access(fb, DMA_FROM_DEVICE);
 
-	ssd13xx_update_rect(ssd13xx, rect, buf, data_array);
-
-	return ret;
+	return ssd13xx_funcs->update_rect(ssd13xx, rect, buf, data_array);
 }
 
 static int ssd13xx_primary_plane_atomic_check(struct drm_plane *plane,
@@ -642,8 +653,6 @@ static int ssd13xx_primary_plane_atomic_check(struct drm_plane *plane,
 	struct ssd13xx_plane_state *ssd13xx_state = to_ssd13xx_plane_state(plane_state);
 	struct drm_crtc *crtc = plane_state->crtc;
 	struct drm_crtc_state *crtc_state;
-	const struct drm_format_info *fi;
-	unsigned int pitch;
 	int ret;
 
 	if (!crtc)
@@ -657,18 +666,10 @@ static int ssd13xx_primary_plane_atomic_check(struct drm_plane *plane,
 	if (ret)
 		return ret;
 
-	fi = drm_format_info(DRM_FORMAT_R1);
-	if (!fi)
-		return -EINVAL;
-
-	pitch = drm_format_info_min_pitch(fi, 0, ssd13xx->width);
-
-	ssd13xx_state->buffer = kcalloc(pitch, ssd13xx->height, GFP_KERNEL);
+	ssd13xx_state->buffer = kzalloc(ssd13xx->buffer_size, GFP_KERNEL);
 	if (!ssd13xx_state->buffer)
 		return -ENOMEM;
 
-	ssd13xx_state->fi = fi;
-
 	return 0;
 }
 
@@ -684,6 +685,7 @@ static void ssd13xx_primary_plane_atomic_update(struct drm_plane *plane,
 	struct drm_framebuffer *fb = plane_state->fb;
 	struct drm_atomic_helper_damage_iter iter;
 	struct drm_device *drm = plane->dev;
+	struct ssd13xx_device *ssd13xx = drm_to_ssd13xx(drm);
 	struct drm_rect dst_clip;
 	struct drm_rect damage;
 	int idx;
@@ -700,7 +702,7 @@ static void ssd13xx_primary_plane_atomic_update(struct drm_plane *plane,
 
 		ssd13xx_fb_blit_rect(fb, &shadow_plane_state->data[0], &dst_clip,
 				     ssd13xx_plane_state->buffer,
-				     ssd13xx_plane_state->fi,
+				     ssd13xx->buffer_fi,
 				     ssd13xx_crtc_state->data_array);
 	}
 
@@ -712,6 +714,7 @@ static void ssd13xx_primary_plane_atomic_disable(struct drm_plane *plane,
 {
 	struct drm_device *drm = plane->dev;
 	struct ssd13xx_device *ssd13xx = drm_to_ssd13xx(drm);
+	const struct ssd13xx_funcs *ssd13xx_funcs = ssd13xx->funcs;
 	struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane);
 	struct drm_crtc_state *crtc_state;
 	struct ssd13xx_crtc_state *ssd13xx_crtc_state;
@@ -726,7 +729,7 @@ static void ssd13xx_primary_plane_atomic_disable(struct drm_plane *plane,
 	if (!drm_dev_enter(drm, &idx))
 		return;
 
-	ssd13xx_clear_screen(ssd13xx, ssd13xx_crtc_state->data_array);
+	ssd13xx_funcs->clear_screen(ssd13xx, ssd13xx_crtc_state->data_array);
 
 	drm_dev_exit(idx);
 }
@@ -820,14 +823,13 @@ static int ssd13xx_crtc_atomic_check(struct drm_crtc *crtc,
 	struct ssd13xx_device *ssd13xx = drm_to_ssd13xx(drm);
 	struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
 	struct ssd13xx_crtc_state *ssd13xx_state = to_ssd13xx_crtc_state(crtc_state);
-	unsigned int pages = DIV_ROUND_UP(ssd13xx->height, SSD130X_PAGE_HEIGHT);
 	int ret;
 
 	ret = drm_crtc_helper_atomic_check(crtc, state);
 	if (ret)
 		return ret;
 
-	ssd13xx_state->data_array = kmalloc(ssd13xx->width * pages, GFP_KERNEL);
+	ssd13xx_state->data_array = kmalloc(ssd13xx->data_array_size, GFP_KERNEL);
 	if (!ssd13xx_state->data_array)
 		return -ENOMEM;
 
@@ -905,13 +907,14 @@ static void ssd13xx_encoder_atomic_enable(struct drm_encoder *encoder,
 {
 	struct drm_device *drm = encoder->dev;
 	struct ssd13xx_device *ssd13xx = drm_to_ssd13xx(drm);
+	const struct ssd13xx_funcs *ssd13xx_funcs = ssd13xx->funcs;
 	int ret;
 
 	ret = ssd13xx_power_on(ssd13xx);
 	if (ret)
 		return;
 
-	ret = ssd13xx_init(ssd13xx);
+	ret = ssd13xx_funcs->init(ssd13xx);
 	if (ret)
 		goto power_off;
 
@@ -1195,11 +1198,38 @@ static int ssd13xx_get_resources(struct ssd13xx_device *ssd13xx)
 	return 0;
 }
 
+static int ssd13xx_set_buffer_sizes(struct ssd13xx_device *ssd13xx,
+				    enum ssd13xx_family_ids family_id)
+{
+	const struct drm_format_info *fi;
+	unsigned int buffer_pitch;
+
+	switch (family_id) {
+	case SSD130X_FAMILY:
+		unsigned int pages = DIV_ROUND_UP(ssd13xx->height, SSD130X_PAGE_HEIGHT);
+
+		ssd13xx->data_array_size = ssd13xx->width * pages;
+
+		fi = drm_format_info(DRM_FORMAT_R1);
+		break;
+	}
+
+	if (!fi)
+		return -EINVAL;
+
+	buffer_pitch = drm_format_info_min_pitch(fi, 0, ssd13xx->width);
+	ssd13xx->buffer_size = buffer_pitch * ssd13xx->height;
+	ssd13xx->buffer_fi = fi;
+
+	return 0;
+}
+
 struct ssd13xx_device *ssd13xx_probe(struct device *dev, struct regmap *regmap)
 {
 	struct ssd13xx_device *ssd13xx;
 	struct backlight_device *bl;
 	struct drm_device *drm;
+	enum ssd13xx_family_ids family_id;
 	int ret;
 
 	ssd13xx = devm_drm_dev_alloc(dev, &ssd13xx_drm_driver,
@@ -1214,11 +1244,19 @@ struct ssd13xx_device *ssd13xx_probe(struct device *dev, struct regmap *regmap)
 	ssd13xx->regmap = regmap;
 	ssd13xx->device_info = device_get_match_data(dev);
 
+	family_id = ssd13xx->device_info->family_id;
+
+	ssd13xx->funcs = &ssd13xx_family_funcs[family_id];
+
 	if (ssd13xx->device_info->page_mode_only)
 		ssd13xx->page_address_mode = 1;
 
 	ssd13xx_parse_properties(ssd13xx);
 
+	ret = ssd13xx_set_buffer_sizes(ssd13xx, family_id);
+	if (ret)
+		return ERR_PTR(ret);
+
 	ret = ssd13xx_get_resources(ssd13xx);
 	if (ret)
 		return ERR_PTR(ret);
drivers/gpu/drm/solomon/ssd13xx.h +27 -0
index 64283935fbc1..e78d5ab87474 100644
@@ -20,11 +20,17 @@
 #include <drm/drm_plane_helper.h>
 
 #include <linux/regmap.h>
+#include <linux/iosys-map.h>
 
 #define SSD130X_DATA				0x40
 #define SSD130X_COMMAND				0x80
 
+enum ssd13xx_family_ids {
+	SSD130X_FAMILY,
+};
+
 enum ssd13xx_variants {
+	/* ssd130x family */
 	SH1106_ID,
 	SSD1305_ID,
 	SSD1306_ID,
@@ -39,6 +45,7 @@ struct ssd13xx_deviceinfo {
 	u32 default_dclk_frq;
 	u32 default_width;
 	u32 default_height;
+	enum ssd13xx_family_ids family_id;
 	bool need_pwm;
 	bool need_chargepump;
 	bool page_mode_only;
@@ -76,6 +83,12 @@ struct ssd13xx_device {
 	u32 col_offset;
 	u32 prechargep1;
 	u32 prechargep2;
+	/* HW format buffer size */
+	u32 data_array_size;
+	/* Intermediate buffer size */
+	u32 buffer_size;
+	/* Pixel format info for the intermediate buffer */
+	const struct drm_format_info *buffer_fi;
 
 	struct backlight_device *bl_dev;
 	struct pwm_device *pwm;
@@ -88,6 +101,20 @@ struct ssd13xx_device {
 	u8 col_end;
 	u8 page_start;
 	u8 page_end;
+
+	/* Chip family specific operations */
+	const struct ssd13xx_funcs *funcs;
+};
+
+struct ssd13xx_funcs {
+	int (*init)(struct ssd13xx_device *ssd130x);
+	int (*update_rect)(struct ssd13xx_device *ssd13xx, struct drm_rect *rect,
+			   u8 *buf, u8 *data_array);
+	void (*clear_screen)(struct ssd13xx_device *ssd13xx,
+			     u8 *data_array);
+	void (*fmt_convert)(struct iosys_map *dst, const unsigned int *dst_pitch,
+			    const struct iosys_map *src, const struct drm_framebuffer *fb,
+			    const struct drm_rect *clip);
 };
 
 extern const struct ssd13xx_deviceinfo ssd13xx_variants[];
Signature · 1 line
2.41.0
#12 lore raw

Re: [PATCH 5/8] drm/ssd13xx: Add a per controller family functions table

Hi Javier,

Quoted 9 lines · Javier Martinez Canillas

To allow the driver to decouple the common logic in the function callbacks from the behaviour that is specific of a given Solomon controller family.

For this, include a chip family to the device info and add fields to the driver-private device struct, to store the hardware buffer maximum size, the intermediate buffer maximum size and pixel format, and a set of per chip family function handlers.

Thanks for your patch!

drivers/gpu/drm/solomon/ssd13xx.c const struct ssd13xx_deviceinfo ssd13xx_variants[] = { · line 107

Quoted 7 lines
drivers/gpu/drm/solomon/ssd13xx.c +1 -0
@@ -104,6 +104,7 @@ const struct ssd13xx_deviceinfo ssd13xx_variants[] = {
                .default_width = 132,
                .default_height = 64,
                .page_mode_only = 1,
+               .family_id = SSD130X_FAMILY,

Why not store &ssd13xx_family_funcs[SSD130X_FAMILY]?

Quoted 30 lines
drivers/gpu/drm/solomon/ssd13xx.c +14 -0
        },
        [SSD1305_ID] = {
                .default_vcomh = 0x34,
@@ -602,6 +605,15 @@ static void ssd13xx_clear_screen(struct ssd13xx_device *ssd13xx, u8 *data_array)
        }
 }
 
+static const struct ssd13xx_funcs ssd13xx_family_funcs[] = {
+       [SSD130X_FAMILY] = {
+               .init = ssd130x_init,
+               .update_rect = ssd130x_update_rect,
+               .clear_screen = ssd130x_clear_screen,
+               .fmt_convert = drm_fb_xrgb8888_to_mono,
+       },
+};
+
 static int ssd13xx_fb_blit_rect(struct drm_framebuffer *fb,
                                const struct iosys_map *vmap,
                                struct drm_rect *rect, u8 *buf,
@@ -1195,11 +1198,38 @@ static int ssd13xx_get_resources(struct ssd13xx_device *ssd13xx)
        return 0;
 }
 
+static int ssd13xx_set_buffer_sizes(struct ssd13xx_device *ssd13xx,
+                                   enum ssd13xx_family_ids family_id)
+{
+       const struct drm_format_info *fi;
+       unsigned int buffer_pitch;

drivers/gpu/drm/solomon/ssd13xx.c static int ssd13xx_get_resources(struct ssd13xx_device *ssd13xx) · line 1215

Quoted 10 lines
drivers/gpu/drm/solomon/ssd13xx.c +10 -0
+
+       switch (family_id) {
+       case SSD130X_FAMILY:
+               unsigned int pages = DIV_ROUND_UP(ssd13xx->height, SSD130X_PAGE_HEIGHT);
+
+               ssd13xx->data_array_size = ssd13xx->width * pages;
+
+               fi = drm_format_info(DRM_FORMAT_R1);
+               break;
+       }

Please don't mix ssd13xx_funcs[family_id] and switch (family_id). The switch() could be replaced by an extra function pointer in ssd13xx_funcs, and by storing fi in ssd13xx_funcs, too.

Note that you don't really need the full drm_format_info, the number of bits per pixel is sufficient. But having the drm_format_info is nice, as fmt_convert() will need it later when adding support for fbdev emulation using R1 or R4 ;-)

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
author maintainer
#13 lore raw

Re: [PATCH 5/8] drm/ssd13xx: Add a per controller family functions table

Quoted 16 lines · Geert Uytterhoeven

Hi Javier,

Quoted 9 lines · Javier Martinez Canillas

To allow the driver to decouple the common logic in the function callbacks from the behaviour that is specific of a given Solomon controller family.

For this, include a chip family to the device info and add fields to the driver-private device struct, to store the hardware buffer maximum size, the intermediate buffer maximum size and pixel format, and a set of per chip family function handlers.

Thanks for your patch!

Quoted 10 lines

drivers/gpu/drm/solomon/ssd13xx.c const struct ssd13xx_deviceinfo ssd13xx_variants[] = { · line 107

Quoted 7 lines
drivers/gpu/drm/solomon/ssd13xx.c +1 -0
@@ -104,6 +104,7 @@ const struct ssd13xx_deviceinfo ssd13xx_variants[] = {
                .default_width = 132,
                .default_height = 64,
                .page_mode_only = 1,
+               .family_id = SSD130X_FAMILY,

Why not store &ssd13xx_family_funcs[SSD130X_FAMILY]?

I could do that, yeah. Originally thought that could be useful besides the per chip functions, but I don't think that it's used for anything else...

[...]

Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/solomon/ssd13xx.c +5 -0
+       switch (family_id) {
+       case SSD130X_FAMILY:
+               unsigned int pages = DIV_ROUND_UP(ssd13xx->height, SSD130X_PAGE_HEIGHT);
+
+               ssd13xx->data_array_size = ssd13xx->width * pages;
Quoted 9 lines

drivers/gpu/drm/solomon/ssd13xx.c static int ssd13xx_get_resources(struct ssd13xx_device *ssd13xx) · line 1215

Quoted 4 lines
drivers/gpu/drm/solomon/ssd13xx.c +4 -0
+
+               fi = drm_format_info(DRM_FORMAT_R1);
+               break;
+       }

Please don't mix ssd13xx_funcs[family_id] and switch (family_id). The switch() could be replaced by an extra function pointer in ssd13xx_funcs, and by storing fi in ssd13xx_funcs, too.

Yes, I didn't want to store the format info in struct ssd13xx_funcs because the idea was for that struct to only have chip operations.

But could do that. I wonder if should rename that struct thought? to something that better denotes is more than function handlers.

Quoted 5 lines

Note that you don't really need the full drm_format_info, the number of bits per pixel is sufficient. But having the drm_format_info is nice, as fmt_convert() will need it later when adding support for fbdev emulation using R1 or R4 ;-)

Exactly, thinking in your patches is why I stored the full format info :)

Quoted 1 line

Gr{oetje,eeting}s,

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
author maintainer
#14 lore raw

PATCH 6/8 drm/ssd13xx: Rename commands that are shared across chip families

In reply to Javier Martinez Canillas

There are some commands that are shared between the SSD130x and SSD132x controller families, define these as a common SSD13XX set of commands.

---

 drivers/gpu/drm/solomon/ssd13xx-spi.c |  4 +--
 drivers/gpu/drm/solomon/ssd13xx.c     | 45 +++++++++++++++------------
 drivers/gpu/drm/solomon/ssd13xx.h     |  4 +--
 3 files changed, 29 insertions(+), 24 deletions(-)
drivers/gpu/drm/solomon/ssd13xx-spi.c +2 -2
index a5ebe5475a49..2416756686cc 100644
@@ -34,10 +34,10 @@ static int ssd13xx_spi_write(void *context, const void *data, size_t count)
 	struct spi_device *spi = t->spi;
 	const u8 *reg = data;
 
-	if (*reg == SSD130X_COMMAND)
+	if (*reg == SSD13XX_COMMAND)
 		gpiod_set_value_cansleep(t->dc, 0);
 
-	if (*reg == SSD130X_DATA)
+	if (*reg == SSD13XX_DATA)
 		gpiod_set_value_cansleep(t->dc, 1);
 
 	/* Remove control byte since is not used in a 4-wire SPI interface */
drivers/gpu/drm/solomon/ssd13xx.c +25 -20

124 lines not on this page · raw message

drivers/gpu/drm/solomon/ssd13xx.h +2 -2
index e78d5ab87474..399b0c8b5680 100644
@@ -22,8 +22,8 @@
 #include <linux/regmap.h>
 #include <linux/iosys-map.h>
 
-#define SSD130X_DATA				0x40
-#define SSD130X_COMMAND				0x80
+#define SSD13XX_DATA				0x40
+#define SSD13XX_COMMAND				0x80
 
 enum ssd13xx_family_ids {
 	SSD130X_FAMILY,
Signature · 1 line
2.41.0
author maintainer
#15 lore raw

PATCH 7/8 drm/ssd13xx: Add support for the SSD132x OLED controller family

In reply to Javier Martinez Canillas

The Solomon SSD132x controllers (such as the SSD1322, SSD1325 and SSD1327) are used by 16 grayscale dot matrix OLED panels, extend the driver to also support this chip family.

---

 drivers/gpu/drm/solomon/ssd13xx-i2c.c |  13 ++
 drivers/gpu/drm/solomon/ssd13xx-spi.c |  13 ++
 drivers/gpu/drm/solomon/ssd13xx.c     | 206 +++++++++++++++++++++++++-
 drivers/gpu/drm/solomon/ssd13xx.h     |   5 +
 4 files changed, 234 insertions(+), 3 deletions(-)
drivers/gpu/drm/solomon/ssd13xx-i2c.c +13 -0
index d9cece374331..9cf78d206c6e 100644
@@ -92,6 +92,19 @@ static const struct of_device_id ssd13xx_of_match[] = {
 		.compatible = "solomon,ssd1309fb-i2c",
 		.data = &ssd13xx_variants[SSD1309_ID],
 	},
+	/* ssd1302x family */
+	{
+		.compatible = "solomon,ssd1322",
+		.data = &ssd13xx_variants[SSD1322_ID],
+	},
+	{
+		.compatible = "solomon,ssd1325",
+		.data = &ssd13xx_variants[SSD1325_ID],
+	},
+	{
+		.compatible = "solomon,ssd1327",
+		.data = &ssd13xx_variants[SSD1327_ID],
+	},
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, ssd13xx_of_match);
drivers/gpu/drm/solomon/ssd13xx-spi.c +13 -0
index 2416756686cc..55162e49f037 100644
@@ -129,6 +129,19 @@ static const struct of_device_id ssd13xx_of_match[] = {
 		.compatible = "solomon,ssd1309",
 		.data = &ssd13xx_variants[SSD1309_ID],
 	},
+	/* ssd1302x family */
+	{
+		.compatible = "solomon,ssd1322",
+		.data = &ssd13xx_variants[SSD1322_ID],
+	},
+	{
+		.compatible = "solomon,ssd1325",
+		.data = &ssd13xx_variants[SSD1325_ID],
+	},
+	{
+		.compatible = "solomon,ssd1327",
+		.data = &ssd13xx_variants[SSD1327_ID],
+	},
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, ssd13xx_of_match);
drivers/gpu/drm/solomon/ssd13xx.c +203 -3

242 lines not on this page · raw message

drivers/gpu/drm/solomon/ssd13xx.h +5 -0
index 399b0c8b5680..58083c7e08c8 100644
@@ -27,6 +27,7 @@
 
 enum ssd13xx_family_ids {
 	SSD130X_FAMILY,
+	SSD132X_FAMILY,
 };
 
 enum ssd13xx_variants {
@@ -36,6 +37,10 @@ enum ssd13xx_variants {
 	SSD1306_ID,
 	SSD1307_ID,
 	SSD1309_ID,
+	/* ssd132x family */
+	SSD1322_ID,
+	SSD1325_ID,
+	SSD1327_ID,
 	NR_SSD13XX_VARIANTS
 };
 
Signature · 1 line
2.41.0
#16 lore raw

Re: [PATCH 7/8] drm/ssd13xx: Add support for the SSD132x OLED controller family

Hi Javier,

Quoted 5 lines · Javier Martinez Canillas

The Solomon SSD132x controllers (such as the SSD1322, SSD1325 and SSD1327) are used by 16 grayscale dot matrix OLED panels, extend the driver to also support this chip family.

Thanks for your patch!

Quoted 6 lines
drivers/gpu/drm/solomon/ssd13xx.c +0 -0
@@ -631,9 +821,12 @@ static int ssd13xx_fb_blit_rect(struct drm_framebuffer *fb,
        unsigned int dst_pitch;
        int ret = 0;

drivers/gpu/drm/solomon/ssd13xx.c static int ssd13xx_fb_blit_rect(struct drm_framebuffer *fb, · line 829

Quoted 10 lines
drivers/gpu/drm/solomon/ssd13xx.c +6 -3
 
-       /* Align y to display page boundaries */
-       rect->y1 = round_down(rect->y1, SSD130X_PAGE_HEIGHT);
-       rect->y2 = min_t(unsigned int, round_up(rect->y2, SSD130X_PAGE_HEIGHT), ssd13xx->height);
+       if (ssd13xx->device_info->family_id == SSD130X_FAMILY) {
+               /* Align y to display page boundaries */
+               rect->y1 = round_down(rect->y1, SSD130X_PAGE_HEIGHT);
+               rect->y2 = min_t(unsigned int, round_up(rect->y2, SSD130X_PAGE_HEIGHT),
+                                ssd13xx->height);
+       }

Don't you need to align to page boundaries (2 pixels per page) on SSD132X?

This should be handled through ssd13xx_funcs instead of a family check.

drivers/gpu/drm/solomon/ssd13xx.c static int ssd13xx_fb_blit_rect(struct drm_framebuffer *fb, · line 832

Quoted 3 lines
drivers/gpu/drm/solomon/ssd13xx.c +0 -0
        dst_pitch = drm_format_info_min_pitch(fi, 0, drm_rect_width(rect));
 

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
author maintainer
#17 lore raw

Re: [PATCH 7/8] drm/ssd13xx: Add support for the SSD132x OLED controller family

Quoted 19 lines · Geert Uytterhoeven

Hi Javier,

Quoted 5 lines · Javier Martinez Canillas

The Solomon SSD132x controllers (such as the SSD1322, SSD1325 and SSD1327) are used by 16 grayscale dot matrix OLED panels, extend the driver to also support this chip family.

Thanks for your patch!

Quoted 7 lines
drivers/gpu/drm/solomon/ssd13xx.c +0 -0
@@ -631,9 +821,12 @@ static int ssd13xx_fb_blit_rect(struct drm_framebuffer *fb,
        unsigned int dst_pitch;
        int ret = 0;
 
Quoted 13 lines

drivers/gpu/drm/solomon/ssd13xx.c static int ssd13xx_fb_blit_rect(struct drm_framebuffer *fb, · line 829

Quoted 9 lines
drivers/gpu/drm/solomon/ssd13xx.c +6 -3
-       /* Align y to display page boundaries */
-       rect->y1 = round_down(rect->y1, SSD130X_PAGE_HEIGHT);
-       rect->y2 = min_t(unsigned int, round_up(rect->y2, SSD130X_PAGE_HEIGHT), ssd13xx->height);
+       if (ssd13xx->device_info->family_id == SSD130X_FAMILY) {
+               /* Align y to display page boundaries */
+               rect->y1 = round_down(rect->y1, SSD130X_PAGE_HEIGHT);
+               rect->y2 = min_t(unsigned int, round_up(rect->y2, SSD130X_PAGE_HEIGHT),
+                                ssd13xx->height);
+       }

Don't you need to align to page boundaries (2 pixels per page) on SSD132X?

I guess so, yes. I'll add that to v2 as well.

Quoted 2 lines

This should be handled through ssd13xx_funcs instead of a family check.

Agreed.

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
author maintainer
#18 lore raw

PATCH 8/8 dt-bindings: display: Add SSD132x OLED controllers

In reply to Javier Martinez Canillas

Add a Device Tree binding schema for the OLED panels based on the Solomon SSD132x family of controllers.

---

 .../bindings/display/solomon,ssd132x.yaml     | 116 ++++++++++++++++++
 1 file changed, 116 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/solomon,ssd132x.yaml
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml new file +116 -0
new file mode 100644
index 000000000000..b64904703a3a
@@ -0,0 +1,116 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/solomon,ssd132x.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Solomon SSD132x OLED Controllers
+
+maintainers:
+  - Javier Martinez Canillas <[email protected]>
+
+properties:
+  compatible:
+    oneOf:
+      - enum:
+          - solomon,ssd1322
+          - solomon,ssd1325
+          - solomon,ssd1327
+
+  reg:
+    maxItems: 1
+
+  reset-gpios:
+    maxItems: 1
+
+  # Only required for SPI
+  dc-gpios:
+    description:
+      GPIO connected to the controller's D/C# (Data/Command) pin,
+      that is needed for 4-wire SPI to tell the controller if the
+      data sent is for a command register or the display data RAM
+    maxItems: 1
+
+  solomon,height:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Height in pixel of the screen driven by the controller.
+      The default value is controller-dependent.
+
+  solomon,width:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Width in pixel of the screen driven by the controller.
+      The default value is controller-dependent.
+
+required:
+  - compatible
+  - reg
+
+allOf:
+  - $ref: /schemas/spi/spi-peripheral-props.yaml#
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: solomon,ssd1322
+    then:
+      properties:
+        width:
+          default: 480
+        height:
+          default: 128
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: solomon,ssd1325
+    then:
+      properties:
+        width:
+          default: 128
+        height:
+          default: 80
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: solomon,ssd1327
+    then:
+      properties:
+        width:
+          default: 128
+        height:
+          default: 128
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    i2c {
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            ssd1327_i2c: oled@3c {
+                    compatible = "solomon,ssd1327";
+                    reg = <0x3c>;
+                    reset-gpios = <&gpio2 7>;
+            };
+
+    };
+  - |
+    spi {
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            ssd1327_spi: oled@0 {
+                    compatible = "solomon,ssd1327";
+                    reg = <0x0>;
+                    reset-gpios = <&gpio2 7>;
+                    dc-gpios = <&gpio2 8>;
+                    spi-max-frequency = <10000000>;
+            };
+    };
Signature · 1 line
2.41.0
#19 lore raw

Re: [PATCH 8/8] dt-bindings: display: Add SSD132x OLED controllers

Hey,

Quoted 24 lines · Javier Martinez Canillas

Add a Device Tree binding schema for the OLED panels based on the Solomon SSD132x family of controllers.

---

 .../bindings/display/solomon,ssd132x.yaml     | 116 ++++++++++++++++++
 1 file changed, 116 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/solomon,ssd132x.yaml
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml new file +8 -0
new file mode 100644
index 000000000000..b64904703a3a
@@ -0,0 +1,116 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/solomon,ssd132x.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Solomon SSD132x OLED Controllers
+

Documentation/devicetree/bindings/display/solomon,ssd132x.yaml line 18

Quoted 10 lines
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml new file +10 -0
+maintainers:
+  - Javier Martinez Canillas <[email protected]>
+
+properties:
+  compatible:
+    oneOf:
+      - enum:
+          - solomon,ssd1322
+          - solomon,ssd1325
+          - solomon,ssd1327

You don't need the oneOf here here as there is only the enum as a possible item.
I didn't get anything else in the series, I have to ask - are these controllers not compatible with eachother?

Quoted 10 lines
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml new file +10 -0
+
+  reg:
+    maxItems: 1
+
+  reset-gpios:
+    maxItems: 1
+
+  # Only required for SPI
+  dc-gpios:
+    description:

Documentation/devicetree/bindings/display/solomon,ssd132x.yaml line 38

Quoted 10 lines
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml new file +10 -0
+      GPIO connected to the controller's D/C# (Data/Command) pin,
+      that is needed for 4-wire SPI to tell the controller if the
+      data sent is for a command register or the display data RAM
+    maxItems: 1
+
+  solomon,height:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Height in pixel of the screen driven by the controller.
+      The default value is controller-dependent.

You probably know better than me, operating in drm stuff, but are there really no generic properties for the weidth/height of a display?

Quoted 39 lines
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml new file +39 -0
+
+  solomon,width:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Width in pixel of the screen driven by the controller.
+      The default value is controller-dependent.
+
+required:
+  - compatible
+  - reg
+
+allOf:
+  - $ref: /schemas/spi/spi-peripheral-props.yaml#
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: solomon,ssd1322
+    then:
+      properties:
+        width:
+          default: 480
+        height:
+          default: 128
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: solomon,ssd1325
+    then:
+      properties:
+        width:
+          default: 128
+        height:
+          default: 80
+
+  - if:

Documentation/devicetree/bindings/display/solomon,ssd132x.yaml line 87

Quoted 10 lines
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml new file +10 -0
+      properties:
+        compatible:
+          contains:
+            const: solomon,ssd1327
+    then:
+      properties:
+        width:
+          default: 128
+        height:
+          default: 128

Unless you did it like this for clarity, 2 of these have the same default width and 2 have the same default height. You could cut this down to a pair of if/then/else on that basis AFAICT.
:wq

Documentation/devicetree/bindings/display/solomon,ssd132x.yaml line 97

Quoted 10 lines
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml new file +10 -0
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    i2c {
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            ssd1327_i2c: oled@3c {

This label is unused as far as I can tell. Ditto below.

Cheers,
Conor.

Quoted 23 lines
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml new file +19 -0
+                    compatible = "solomon,ssd1327";
+                    reg = <0x3c>;
+                    reset-gpios = <&gpio2 7>;
+            };
+
+    };
+  - |
+    spi {
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            ssd1327_spi: oled@0 {
+                    compatible = "solomon,ssd1327";
+                    reg = <0x0>;
+                    reset-gpios = <&gpio2 7>;
+                    dc-gpios = <&gpio2 8>;
+                    spi-max-frequency = <10000000>;
+            };
+    };
Signature · 1 line
2.41.0
author maintainer
#20 lore raw

Re: [PATCH 8/8] dt-bindings: display: Add SSD132x OLED controllers

Conor Dooley <[email protected]> writes:

Hello Conor,

Thanks a lot for your feedback.

Quoted 3 lines

Hey,

On Mon, Oct 09, 2023 at 08:34:22PM +0200, Javier Martinez Canillas wrote:

[...]

Quoted 10 lines

Documentation/devicetree/bindings/display/solomon,ssd132x.yaml line 18

Quoted 7 lines
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml new file +7 -0
+properties:
+  compatible:
+    oneOf:
+      - enum:
+          - solomon,ssd1322
+          - solomon,ssd1325
+          - solomon,ssd1327

You don't need the oneOf here here as there is only the enum as a possible item.

Indeed. I'll fix that in v2.

Quoted 3 lines

I didn't get anything else in the series, I have to ask - are these controllers not compatible with eachother?

They are not, basically the difference is in the default width and height for each controller. That's why the width and height fields are optional.

But other than the default resolution, yes the controllers are very much the same.

Quoted 15 lines
Quoted 15 lines
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml new file +15 -0
+
+  reg:
+    maxItems: 1
+
+  reset-gpios:
+    maxItems: 1
+
+  # Only required for SPI
+  dc-gpios:
+    description:
+      GPIO connected to the controller's D/C# (Data/Command) pin,
+      that is needed for 4-wire SPI to tell the controller if the
+      data sent is for a command register or the display data RAM
+    maxItems: 1
+
Quoted 9 lines

Documentation/devicetree/bindings/display/solomon,ssd132x.yaml line 38

Quoted 5 lines
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml new file +5 -0
+  solomon,height:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Height in pixel of the screen driven by the controller.
+      The default value is controller-dependent.

You probably know better than me, operating in drm stuff, but are there really no generic properties for the weidth/height of a display?

There are some common properties, such as the width-mm and height-mm for the panel-common:

Documentation/devicetree/bindings/display/panel/panel-common.yaml

But those are to describe the physical area expressed in millimeters and the Solomon drivers (the old ssd1307fb fbdev driver and the new ssd130x DRM driver for backward compatibility with existing DTB) express the width and height in pixels.

That's why are Solomon controller specific properties "solomon,width" and "solomon,height".

[...]

Quoted 7 lines

Documentation/devicetree/bindings/display/solomon,ssd132x.yaml line 85

Quoted 6 lines
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml new file +6 -0
+    then:
+      properties:
+        width:
+          default: 128
+        height:
+          default: 128
Quoted 5 lines

Unless you did it like this for clarity, 2 of these have the same default width and 2 have the same default height. You could cut this down to a pair of if/then/else on that basis AFAICT.
:wq

Yes, this was done like that for clarity. Because is easier for someone reading the DT binding schema to reason about resolution (width,height) for a given SSD132x controller, rather than following the if/else logic.

Quoted 4 lines
Quoted 4 lines
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml new file +4 -0
+
+unevaluatedProperties: false
+
+examples:
Quoted 9 lines

Documentation/devicetree/bindings/display/solomon,ssd132x.yaml line 97

Quoted 6 lines
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml new file +6 -0
+  - |
+    i2c {
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            ssd1327_i2c: oled@3c {

This label is unused as far as I can tell. Ditto below.

Right, I'll drop those too.

Quoted 3 lines

Cheers,
Conor.

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
#21 lore raw

Re: [PATCH 8/8] dt-bindings: display: Add SSD132x OLED controllers

Quoted 24 lines · Javier Martinez Canillas
Quoted 14 lines · Conor Dooley

Documentation/devicetree/bindings/display/solomon,ssd132x.yaml line 38

Quoted 13 lines
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml new file +13 -0
+  # Only required for SPI
+  dc-gpios:
+    description:
+      GPIO connected to the controller's D/C# (Data/Command) pin,
+      that is needed for 4-wire SPI to tell the controller if the
+      data sent is for a command register or the display data RAM
+    maxItems: 1
+
+  solomon,height:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Height in pixel of the screen driven by the controller.
+      The default value is controller-dependent.
Quoted 3 lines

You probably know better than me, operating in drm stuff, but are there really no generic properties for the weidth/height of a display?

There are some common properties, such as the width-mm and height-mm for the panel-common:

Documentation/devicetree/bindings/display/panel/panel-common.yaml

Quoted 7 lines

But those are to describe the physical area expressed in millimeters and the Solomon drivers (the old ssd1307fb fbdev driver and the new ssd130x DRM driver for backward compatibility with existing DTB) express the width and height in pixels.

That's why are Solomon controller specific properties "solomon,width" and "solomon,height".

Okay. Thanks for the explanation.

maintainer
#22 lore raw

Re: [PATCH 8/8] dt-bindings: display: Add SSD132x OLED controllers

In reply to Javier Martinez Canillas
Quoted 2 lines · Javier Martinez Canillas

Add a Device Tree binding schema for the OLED panels based on the Solomon SSD132x family of controllers.

Looks like the same binding as solomon,ssd1307fb.yaml. Why a different binding? Why does that binding need a slew of custom properties and here you don't?

Quoted 48 lines

---

 .../bindings/display/solomon,ssd132x.yaml     | 116 ++++++++++++++++++
 1 file changed, 116 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/solomon,ssd132x.yaml
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml new file +34 -0
new file mode 100644
index 000000000000..b64904703a3a
@@ -0,0 +1,116 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/solomon,ssd132x.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Solomon SSD132x OLED Controllers
+
+maintainers:
+  - Javier Martinez Canillas <[email protected]>
+
+properties:
+  compatible:
+    oneOf:
+      - enum:
+          - solomon,ssd1322
+          - solomon,ssd1325
+          - solomon,ssd1327
+
+  reg:
+    maxItems: 1
+
+  reset-gpios:
+    maxItems: 1
+
+  # Only required for SPI
+  dc-gpios:
+    description:
+      GPIO connected to the controller's D/C# (Data/Command) pin,
+      that is needed for 4-wire SPI to tell the controller if the
+      data sent is for a command register or the display data RAM
+    maxItems: 1
+
+  solomon,height:

Documentation/devicetree/bindings/display/solomon,ssd132x.yaml line 44

Quoted 10 lines
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml new file +10 -0
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Height in pixel of the screen driven by the controller.
+      The default value is controller-dependent.
+
+  solomon,width:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Width in pixel of the screen driven by the controller.
+      The default value is controller-dependent.

Don't define the same properties twice. Either share the binding or split out the common properties into their own schema file.

Rob

author maintainer
#23 lore raw

Re: [PATCH 8/8] dt-bindings: display: Add SSD132x OLED controllers

Rob Herring <[email protected]> writes:

Hello Rob,

Thanks a lot for your feedback.

Quoted 8 lines · Javier Martinez Canillas
Quoted 2 lines

Add a Device Tree binding schema for the OLED panels based on the Solomon SSD132x family of controllers.

Looks like the same binding as solomon,ssd1307fb.yaml. Why a different binding? Why does that binding need a slew of custom properties and here you don't?

It's a sub-set of it. Because only the minimum required properties are defined. But also, is a clean slate schema because the old ssd1307fb fbdev driver only supports the Solomon SSD130x family, so there is no need to follow the existing solomon,ssd1307fb.yaml nor the need for backward compat.

[...]

Quoted 12 lines

Documentation/devicetree/bindings/display/solomon,ssd132x.yaml line 44

Quoted 11 lines
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml new file +11 -0
+  solomon,height:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Height in pixel of the screen driven by the controller.
+      The default value is controller-dependent.
+
+  solomon,width:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Width in pixel of the screen driven by the controller.
+      The default value is controller-dependent.
Quoted 3 lines

Don't define the same properties twice. Either share the binding or split out the common properties into their own schema file.

Agreed. I'll do that in v2.

Quoted 2 lines

Rob

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
author maintainer
#24 lore raw

Re: [PATCH 8/8] dt-bindings: display: Add SSD132x OLED controllers

Quoted 15 lines · Javier Martinez Canillas

Rob Herring <[email protected]> writes:

Hello Rob,

Thanks a lot for your feedback.

Quoted 8 lines · Javier Martinez Canillas
Quoted 2 lines

Add a Device Tree binding schema for the OLED panels based on the Solomon SSD132x family of controllers.

Looks like the same binding as solomon,ssd1307fb.yaml. Why a different binding? Why does that binding need a slew of custom properties and here you don't?

Quoted 5 lines

It's a sub-set of it. Because only the minimum required properties are defined. But also, is a clean slate schema because the old ssd1307fb fbdev driver only supports the Solomon SSD130x family, so there is no need to follow the existing solomon,ssd1307fb.yaml nor the need for backward compat.

I think this answer was a little sparse, let me elaborate a bit. The Solomon display controllers are quite flexible, so that could be used with different OLED panels.

And the ssd1307fb binding schema defines a set of properties that are almost a 1:1 mapping from properties to the configuration registers. This makes the driver to support most SSD130x controller + panel configurations but at the expense of making the binding more complicated (a slew of custom propertie as you pointed out).

Now, as mentioned this is support for greyscale Solomon controllers (the old fbdev driver only supports monochrome controllers) so we don't care about DT backward compatibility.

I decided for now to keep the binding at a minimum and be more opinionated in the driver with having what I think are sane defaults for most of the config registers.

If there is a need to expose any of this configuration as DT properties, then we can later added it share some of the existing solomon,ssd1307fb.yaml custom properties and move them to a common schema.

We can always change the driver in the future anyways, but we can't do the same with the DT binding schema since that is considered an ABI.

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat