[PATCH 4/7] drm/panel: sitronix-st7789v: Use platform data
Miquel Raynal
miquel.raynal at bootlin.com
Fri Jun 9 14:59:48 UTC 2023
The Sitronix ST7789V LCD controller is actually packaged in a number of
different panels with slightly different properties. Before introducing
the support for another pannel using this same LCD controller, let's
move all the panel-specific information into a dedicated structure that
is available as platform data.
There is no functional change.
Signed-off-by: Miquel Raynal <miquel.raynal at bootlin.com>
---
.../gpu/drm/panel/panel-sitronix-st7789v.c | 30 +++++++++++++++----
1 file changed, 24 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c
index 0abb45bea18d..212bccc31804 100644
--- a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c
+++ b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c
@@ -112,11 +112,19 @@
return val; \
} while (0)
+struct st7789v_panel_info {
+ const struct drm_display_mode *display_mode;
+ u16 width_mm;
+ u16 height_mm;
+ u32 bus_format;
+};
+
struct st7789v {
struct drm_panel panel;
struct spi_device *spi;
struct gpio_desc *reset;
struct regulator *power;
+ const struct st7789v_panel_info *panel_info;
};
enum st7789v_prefix {
@@ -170,10 +178,11 @@ static const struct drm_display_mode default_mode = {
static int st7789v_get_modes(struct drm_panel *panel,
struct drm_connector *connector)
{
+ struct st7789v *ctx = panel_to_st7789v(panel);
+ const struct st7789v_panel_info *panel_info = ctx->panel_info;
struct drm_display_mode *mode;
- u32 bus_format = MEDIA_BUS_FMT_RGB666_1X18;
- mode = drm_mode_duplicate(connector->dev, &default_mode);
+ mode = drm_mode_duplicate(connector->dev, panel_info->display_mode);
if (!mode) {
dev_err(panel->dev, "failed to add mode %ux%ux@%u\n",
default_mode.hdisplay, default_mode.vdisplay,
@@ -186,10 +195,10 @@ static int st7789v_get_modes(struct drm_panel *panel,
mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
drm_mode_probed_add(connector, mode);
- connector->display_info.width_mm = 61;
- connector->display_info.height_mm = 103;
+ connector->display_info.width_mm = panel_info->width_mm;
+ connector->display_info.height_mm = panel_info->height_mm;
drm_display_info_set_bus_formats(&connector->display_info,
- &bus_format, 1);
+ &panel_info->bus_format, 1);
return 1;
}
@@ -365,6 +374,8 @@ static int st7789v_probe(struct spi_device *spi)
if (!ctx)
return -ENOMEM;
+ ctx->panel_info = device_get_match_data(&spi->dev);
+
spi_set_drvdata(spi, ctx);
ctx->spi = spi;
@@ -404,8 +415,15 @@ static void st7789v_remove(struct spi_device *spi)
drm_panel_remove(&ctx->panel);
}
+static const struct st7789v_panel_info st7789v_info = {
+ .display_mode = &default_mode,
+ .width_mm = 64,
+ .height_mm = 103,
+ .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
+};
+
static const struct of_device_id st7789v_of_match[] = {
- { .compatible = "sitronix,st7789v" },
+ { .compatible = "sitronix,st7789v", .data = &st7789v_info },
{ }
};
MODULE_DEVICE_TABLE(of, st7789v_of_match);
--
2.34.1
More information about the dri-devel
mailing list