Skip to content

Commit

Permalink
drm/ssd130x: Add support for the SSD132x OLED controller family
Browse files Browse the repository at this point in the history
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.

Instead adding an indirection level to allow the same modesetting pipeline
to be used by both controller families, add another pipeline for SSD132x.

This leads to some code duplication but it makes the driver easier to read
and reason about. Once other controller families are added (e.g: SSD133x),
some common code can be factored out in driver helpers to be shared by the
different families. But that can be done later once these patterns emerge.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20231014071520.1342189-5-javierm@redhat.com
  • Loading branch information
Javier Martinez Canillas committed Oct 18, 2023
1 parent 9081d21 commit fdd591e
Show file tree
Hide file tree
Showing 5 changed files with 449 additions and 27 deletions.
12 changes: 6 additions & 6 deletions drivers/gpu/drm/solomon/Kconfig
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
config DRM_SSD130X
tristate "DRM support for Solomon SSD130x OLED displays"
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.

config DRM_SSD130X_I2C
tristate "DRM support for Solomon SSD130x OLED displays (I2C bus)"
tristate "DRM support for Solomon SSD13xx OLED displays (I2C bus)"
depends on DRM_SSD130X && 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.

config DRM_SSD130X_SPI
tristate "DRM support for Solomon SSD130X OLED displays (SPI bus)"
tristate "DRM support for Solomon SSD13xx OLED displays (SPI bus)"
depends on DRM_SSD130X && 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.
17 changes: 15 additions & 2 deletions drivers/gpu/drm/solomon/ssd130x-i2c.c
Original file line number Diff line number Diff line change
@@ -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 <javierm@redhat.com>
Expand All @@ -14,7 +14,7 @@
#include "ssd130x.h"

#define DRIVER_NAME "ssd130x-i2c"
#define DRIVER_DESC "DRM driver for Solomon SSD130x OLED displays (I2C)"
#define DRIVER_DESC "DRM driver for Solomon SSD13xx OLED displays (I2C)"

static const struct regmap_config ssd130x_i2c_regmap_config = {
.reg_bits = 8,
Expand Down Expand Up @@ -92,6 +92,19 @@ static const struct of_device_id ssd130x_of_match[] = {
.compatible = "solomon,ssd1309fb-i2c",
.data = &ssd130x_variants[SSD1309_ID],
},
/* ssd132x family */
{
.compatible = "solomon,ssd1322",
.data = &ssd130x_variants[SSD1322_ID],
},
{
.compatible = "solomon,ssd1325",
.data = &ssd130x_variants[SSD1325_ID],
},
{
.compatible = "solomon,ssd1327",
.data = &ssd130x_variants[SSD1327_ID],
},
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, ssd130x_of_match);
Expand Down
21 changes: 19 additions & 2 deletions drivers/gpu/drm/solomon/ssd130x-spi.c
Original file line number Diff line number Diff line change
@@ -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 <javierm@redhat.com>
Expand All @@ -11,7 +11,7 @@
#include "ssd130x.h"

#define DRIVER_NAME "ssd130x-spi"
#define DRIVER_DESC "DRM driver for Solomon SSD130X OLED displays (SPI)"
#define DRIVER_DESC "DRM driver for Solomon SSD13xx OLED displays (SPI)"

struct ssd130x_spi_transport {
struct spi_device *spi;
Expand Down Expand Up @@ -129,6 +129,19 @@ static const struct of_device_id ssd130x_of_match[] = {
.compatible = "solomon,ssd1309",
.data = &ssd130x_variants[SSD1309_ID],
},
/* ssd132x family */
{
.compatible = "solomon,ssd1322",
.data = &ssd130x_variants[SSD1322_ID],
},
{
.compatible = "solomon,ssd1325",
.data = &ssd130x_variants[SSD1325_ID],
},
{
.compatible = "solomon,ssd1327",
.data = &ssd130x_variants[SSD1327_ID],
},
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, ssd130x_of_match);
Expand All @@ -149,6 +162,10 @@ static const struct spi_device_id ssd130x_spi_table[] = {
{ "ssd1306", SSD1306_ID },
{ "ssd1307", SSD1307_ID },
{ "ssd1309", SSD1309_ID },
/* ssd132x family */
{ "ssd1322", SSD1322_ID },
{ "ssd1325", SSD1325_ID },
{ "ssd1327", SSD1327_ID },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(spi, ssd130x_spi_table);
Expand Down
Loading

0 comments on commit fdd591e

Please sign in to comment.