diff options
author | Icenowy Zheng <icenowy@aosc.io> | 2020-07-19 20:04:07 +0300 |
---|---|---|
committer | Sam Ravnborg <sam@ravnborg.org> | 2020-08-15 17:50:29 +0300 |
commit | b7d71b6e1f039873e05b2d53f88200757316f931 (patch) | |
tree | 9dd9d99ec30c9a8ac72132dfc3ffb01952ddd0f5 /drivers/gpu/drm/panel | |
parent | e6c21e6f9cf4ef7986ed1b885e869ee7c3b12fc3 (diff) | |
download | linux-b7d71b6e1f039873e05b2d53f88200757316f931.tar.xz |
drm/panel: ilitek-ili9881c: prepare for adding support for extra panels
There're more panels with ILI9881C controller than the Bananapi one
supported by this driver.
Extract the mode and init sequence part, to prepare the driver for
adding new panels.
Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20200719170411.275812-2-icenowy@aosc.io
Diffstat (limited to 'drivers/gpu/drm/panel')
-rw-r--r-- | drivers/gpu/drm/panel/panel-ilitek-ili9881c.c | 56 |
1 files changed, 37 insertions, 19 deletions
diff --git a/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c b/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c index 066ef6c535df..02ef2750bd77 100644 --- a/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c +++ b/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c @@ -10,6 +10,7 @@ #include <linux/fb.h> #include <linux/kernel.h> #include <linux/module.h> +#include <linux/of_device.h> #include <linux/gpio/consumer.h> #include <linux/regulator/consumer.h> @@ -20,14 +21,6 @@ #include <video/mipi_display.h> -struct ili9881c { - struct drm_panel panel; - struct mipi_dsi_device *dsi; - - struct regulator *power; - struct gpio_desc *reset; -}; - enum ili9881c_op { ILI9881C_SWITCH_PAGE, ILI9881C_COMMAND, @@ -45,6 +38,21 @@ struct ili9881c_instr { } arg; }; +struct ili9881c_desc { + const struct ili9881c_instr *init; + const size_t init_length; + const struct drm_display_mode *mode; +}; + +struct ili9881c { + struct drm_panel panel; + struct mipi_dsi_device *dsi; + const struct ili9881c_desc *desc; + + struct regulator *power; + struct gpio_desc *reset; +}; + #define ILI9881C_SWITCH_PAGE_INSTR(_page) \ { \ .op = ILI9881C_SWITCH_PAGE, \ @@ -64,7 +72,7 @@ struct ili9881c_instr { }, \ } -static const struct ili9881c_instr ili9881c_init[] = { +static const struct ili9881c_instr lhr050h41_init[] = { ILI9881C_SWITCH_PAGE_INSTR(3), ILI9881C_COMMAND_INSTR(0x01, 0x00), ILI9881C_COMMAND_INSTR(0x02, 0x00), @@ -311,8 +319,8 @@ static int ili9881c_prepare(struct drm_panel *panel) gpiod_set_value(ctx->reset, 0); msleep(20); - for (i = 0; i < ARRAY_SIZE(ili9881c_init); i++) { - const struct ili9881c_instr *instr = &ili9881c_init[i]; + for (i = 0; i < ctx->desc->init_length; i++) { + const struct ili9881c_instr *instr = &ctx->desc->init[i]; if (instr->op == ILI9881C_SWITCH_PAGE) ret = ili9881c_switch_page(ctx, instr->arg.page); @@ -368,7 +376,7 @@ static int ili9881c_unprepare(struct drm_panel *panel) return 0; } -static const struct drm_display_mode bananapi_default_mode = { +static const struct drm_display_mode lhr050h41_default_mode = { .clock = 62000, .hdisplay = 720, @@ -380,6 +388,9 @@ static const struct drm_display_mode bananapi_default_mode = { .vsync_start = 1280 + 10, .vsync_end = 1280 + 10 + 10, .vtotal = 1280 + 10 + 10 + 20, + + .width_mm = 62, + .height_mm = 110, }; static int ili9881c_get_modes(struct drm_panel *panel, @@ -388,12 +399,12 @@ static int ili9881c_get_modes(struct drm_panel *panel, struct ili9881c *ctx = panel_to_ili9881c(panel); struct drm_display_mode *mode; - mode = drm_mode_duplicate(connector->dev, &bananapi_default_mode); + mode = drm_mode_duplicate(connector->dev, ctx->desc->mode); if (!mode) { dev_err(&ctx->dsi->dev, "failed to add mode %ux%ux@%u\n", - bananapi_default_mode.hdisplay, - bananapi_default_mode.vdisplay, - drm_mode_vrefresh(&bananapi_default_mode)); + ctx->desc->mode->hdisplay, + ctx->desc->mode->vdisplay, + drm_mode_vrefresh(ctx->desc->mode)); return -ENOMEM; } @@ -402,8 +413,8 @@ static int ili9881c_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 = 62; - connector->display_info.height_mm = 110; + connector->display_info.width_mm = mode->width_mm; + connector->display_info.height_mm = mode->height_mm; return 1; } @@ -426,6 +437,7 @@ static int ili9881c_dsi_probe(struct mipi_dsi_device *dsi) return -ENOMEM; mipi_dsi_set_drvdata(dsi, ctx); ctx->dsi = dsi; + ctx->desc = of_device_get_match_data(&dsi->dev); drm_panel_init(&ctx->panel, &dsi->dev, &ili9881c_funcs, DRM_MODE_CONNECTOR_DSI); @@ -465,8 +477,14 @@ static int ili9881c_dsi_remove(struct mipi_dsi_device *dsi) return 0; } +static const struct ili9881c_desc lhr050h41_desc = { + .init = lhr050h41_init, + .init_length = ARRAY_SIZE(lhr050h41_init), + .mode = &lhr050h41_default_mode, +}; + static const struct of_device_id ili9881c_of_match[] = { - { .compatible = "bananapi,lhr050h41" }, + { .compatible = "bananapi,lhr050h41", .data = &lhr050h41_desc }, { } }; MODULE_DEVICE_TABLE(of, ili9881c_of_match); |