Commit 6ae5837c authored by Guido Günther's avatar Guido Günther

drm/panel: mantix: Allow to specify default mode for different panels

This can be used to use different modes for differnt panels via OF
device match.
Signed-off-by: default avatarGuido Günther <agx@sigxcpu.org>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Reviewed-by: default avatarSam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/2580dba34c95a8159c1bdfd07604fbb8dbd0ad8c.1605688147.git.agx@sigxcpu.org
parent dd396dbc
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/gpio/consumer.h> #include <linux/gpio/consumer.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/of_device.h>
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
#include <video/mipi_display.h> #include <video/mipi_display.h>
...@@ -34,6 +35,8 @@ struct mantix { ...@@ -34,6 +35,8 @@ struct mantix {
struct regulator *avdd; struct regulator *avdd;
struct regulator *avee; struct regulator *avee;
struct regulator *vddi; struct regulator *vddi;
const struct drm_display_mode *default_mode;
}; };
static inline struct mantix *panel_to_mantix(struct drm_panel *panel) static inline struct mantix *panel_to_mantix(struct drm_panel *panel)
...@@ -187,7 +190,7 @@ static int mantix_prepare(struct drm_panel *panel) ...@@ -187,7 +190,7 @@ static int mantix_prepare(struct drm_panel *panel)
return 0; return 0;
} }
static const struct drm_display_mode default_mode = { static const struct drm_display_mode default_mode_mantix = {
.hdisplay = 720, .hdisplay = 720,
.hsync_start = 720 + 45, .hsync_start = 720 + 45,
.hsync_end = 720 + 45 + 14, .hsync_end = 720 + 45 + 14,
...@@ -208,11 +211,11 @@ static int mantix_get_modes(struct drm_panel *panel, ...@@ -208,11 +211,11 @@ static int mantix_get_modes(struct drm_panel *panel,
struct mantix *ctx = panel_to_mantix(panel); struct mantix *ctx = panel_to_mantix(panel);
struct drm_display_mode *mode; struct drm_display_mode *mode;
mode = drm_mode_duplicate(connector->dev, &default_mode); mode = drm_mode_duplicate(connector->dev, ctx->default_mode);
if (!mode) { if (!mode) {
dev_err(ctx->dev, "Failed to add mode %ux%u@%u\n", dev_err(ctx->dev, "Failed to add mode %ux%u@%u\n",
default_mode.hdisplay, default_mode.vdisplay, ctx->default_mode->hdisplay, ctx->default_mode->vdisplay,
drm_mode_vrefresh(&default_mode)); drm_mode_vrefresh(ctx->default_mode));
return -ENOMEM; return -ENOMEM;
} }
...@@ -243,6 +246,7 @@ static int mantix_probe(struct mipi_dsi_device *dsi) ...@@ -243,6 +246,7 @@ static int mantix_probe(struct mipi_dsi_device *dsi)
ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
if (!ctx) if (!ctx)
return -ENOMEM; return -ENOMEM;
ctx->default_mode = of_device_get_match_data(dev);
ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(ctx->reset_gpio)) { if (IS_ERR(ctx->reset_gpio)) {
...@@ -293,8 +297,8 @@ static int mantix_probe(struct mipi_dsi_device *dsi) ...@@ -293,8 +297,8 @@ static int mantix_probe(struct mipi_dsi_device *dsi)
} }
dev_info(dev, "%ux%u@%u %ubpp dsi %udl - ready\n", dev_info(dev, "%ux%u@%u %ubpp dsi %udl - ready\n",
default_mode.hdisplay, default_mode.vdisplay, ctx->default_mode->hdisplay, ctx->default_mode->vdisplay,
drm_mode_vrefresh(&default_mode), drm_mode_vrefresh(ctx->default_mode),
mipi_dsi_pixel_format_to_bpp(dsi->format), dsi->lanes); mipi_dsi_pixel_format_to_bpp(dsi->format), dsi->lanes);
return 0; return 0;
...@@ -321,7 +325,7 @@ static int mantix_remove(struct mipi_dsi_device *dsi) ...@@ -321,7 +325,7 @@ static int mantix_remove(struct mipi_dsi_device *dsi)
} }
static const struct of_device_id mantix_of_match[] = { static const struct of_device_id mantix_of_match[] = {
{ .compatible = "mantix,mlaf057we51-x" }, { .compatible = "mantix,mlaf057we51-x", .data = &default_mode_mantix },
{ /* sentinel */ } { /* sentinel */ }
}; };
MODULE_DEVICE_TABLE(of, mantix_of_match); MODULE_DEVICE_TABLE(of, mantix_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