Commit 24179ff9 authored by Zhaoxiong Lv's avatar Zhaoxiong Lv Committed by Neil Armstrong

drm/panel: boe-th101mb31ig002 : Make it compatible with other panel.

This driver currently only applies to one panel. Modify it to be
compatible with other panels.
Signed-off-by: default avatarZhaoxiong Lv <lvzhaoxiong@huaqin.corp-partner.google.com>
Reviewed-by: default avatarNeil Armstrong <neil.armstrong@linaro.org>
Link: https://lore.kernel.org/r/20240709134754.28013-2-lvzhaoxiong@huaqin.corp-partner.google.comSigned-off-by: default avatarNeil Armstrong <neil.armstrong@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20240709134754.28013-2-lvzhaoxiong@huaqin.corp-partner.google.com
parent 533ca79c
...@@ -17,11 +17,21 @@ ...@@ -17,11 +17,21 @@
#include <drm/drm_modes.h> #include <drm/drm_modes.h>
#include <drm/drm_panel.h> #include <drm/drm_panel.h>
struct panel_desc {
const struct drm_display_mode *modes;
unsigned long mode_flags;
enum mipi_dsi_pixel_format format;
int (*init)(struct drm_panel *panel);
unsigned int lanes;
};
struct boe_th101mb31ig002 { struct boe_th101mb31ig002 {
struct drm_panel panel; struct drm_panel panel;
struct mipi_dsi_device *dsi; struct mipi_dsi_device *dsi;
const struct panel_desc *desc;
struct regulator *power; struct regulator *power;
struct gpio_desc *enable; struct gpio_desc *enable;
struct gpio_desc *reset; struct gpio_desc *reset;
...@@ -161,7 +171,10 @@ static int boe_th101mb31ig002_prepare(struct drm_panel *panel) ...@@ -161,7 +171,10 @@ static int boe_th101mb31ig002_prepare(struct drm_panel *panel)
gpiod_set_value_cansleep(ctx->enable, 1); gpiod_set_value_cansleep(ctx->enable, 1);
msleep(50); msleep(50);
boe_th101mb31ig002_reset(ctx); boe_th101mb31ig002_reset(ctx);
boe_th101mb31ig002_enable(panel);
ret = ctx->desc->init(panel);
if (ret)
return ret;
return 0; return 0;
} }
...@@ -181,6 +194,16 @@ static const struct drm_display_mode boe_th101mb31ig002_default_mode = { ...@@ -181,6 +194,16 @@ static const struct drm_display_mode boe_th101mb31ig002_default_mode = {
.type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED, .type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,
}; };
static const struct panel_desc boe_th101mb31ig002_desc = {
.modes = &boe_th101mb31ig002_default_mode,
.lanes = 4,
.format = MIPI_DSI_FMT_RGB888,
.mode_flags = MIPI_DSI_MODE_VIDEO_BURST |
MIPI_DSI_MODE_NO_EOT_PACKET |
MIPI_DSI_MODE_LPM,
.init = boe_th101mb31ig002_enable,
};
static int boe_th101mb31ig002_get_modes(struct drm_panel *panel, static int boe_th101mb31ig002_get_modes(struct drm_panel *panel,
struct drm_connector *connector) struct drm_connector *connector)
{ {
...@@ -237,6 +260,7 @@ static const struct drm_panel_funcs boe_th101mb31ig002_funcs = { ...@@ -237,6 +260,7 @@ static const struct drm_panel_funcs boe_th101mb31ig002_funcs = {
static int boe_th101mb31ig002_dsi_probe(struct mipi_dsi_device *dsi) static int boe_th101mb31ig002_dsi_probe(struct mipi_dsi_device *dsi)
{ {
struct boe_th101mb31ig002 *ctx; struct boe_th101mb31ig002 *ctx;
const struct panel_desc *desc;
int ret; int ret;
ctx = devm_kzalloc(&dsi->dev, sizeof(*ctx), GFP_KERNEL); ctx = devm_kzalloc(&dsi->dev, sizeof(*ctx), GFP_KERNEL);
...@@ -246,11 +270,11 @@ static int boe_th101mb31ig002_dsi_probe(struct mipi_dsi_device *dsi) ...@@ -246,11 +270,11 @@ static int boe_th101mb31ig002_dsi_probe(struct mipi_dsi_device *dsi)
mipi_dsi_set_drvdata(dsi, ctx); mipi_dsi_set_drvdata(dsi, ctx);
ctx->dsi = dsi; ctx->dsi = dsi;
dsi->lanes = 4; desc = of_device_get_match_data(&dsi->dev);
dsi->format = MIPI_DSI_FMT_RGB888; dsi->lanes = desc->lanes;
dsi->mode_flags = MIPI_DSI_MODE_VIDEO_BURST | dsi->format = desc->format;
MIPI_DSI_MODE_NO_EOT_PACKET | dsi->mode_flags = desc->mode_flags;
MIPI_DSI_MODE_LPM; ctx->desc = desc;
ctx->power = devm_regulator_get(&dsi->dev, "power"); ctx->power = devm_regulator_get(&dsi->dev, "power");
if (IS_ERR(ctx->power)) if (IS_ERR(ctx->power))
...@@ -302,7 +326,10 @@ static void boe_th101mb31ig002_dsi_remove(struct mipi_dsi_device *dsi) ...@@ -302,7 +326,10 @@ static void boe_th101mb31ig002_dsi_remove(struct mipi_dsi_device *dsi)
} }
static const struct of_device_id boe_th101mb31ig002_of_match[] = { static const struct of_device_id boe_th101mb31ig002_of_match[] = {
{ .compatible = "boe,th101mb31ig002-28a", }, {
.compatible = "boe,th101mb31ig002-28a",
.data = &boe_th101mb31ig002_desc
},
{ /* sentinel */ } { /* sentinel */ }
}; };
MODULE_DEVICE_TABLE(of, boe_th101mb31ig002_of_match); MODULE_DEVICE_TABLE(of, boe_th101mb31ig002_of_match);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment