From 2d280813de86f59568f625049de7c7a4e83d05dd Mon Sep 17 00:00:00 2001 From: Ken-Vamrs <90229124+Ken-Vamrs@users.noreply.github.com> Date: Fri, 16 Jun 2023 16:00:51 +0800 Subject: [PATCH] drm/panel/raspberrypi-touchscreen: add modeline for rk3588 platform (#137) Signed-off-by: Ken Wang --- .../drm/panel/panel-raspberrypi-touchscreen.c | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c b/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c index cd76aa72ce9de..7e31ed280721f 100644 --- a/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c +++ b/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c @@ -213,6 +213,26 @@ static const struct drm_display_mode rpi_touchscreen_modes[] = { }, }; +static const struct drm_display_mode rpi_touchscreen_modes_for_rk3588[] = { + { + /* Modeline comes from the Raspberry Pi firmware, with HFP=1 + * plugged in and clock re-computed from that. + */ + .clock = 26000000 / 1000, + .hdisplay = 800, + .hsync_start = 800 + 48, + .hsync_end = 800 + 48 + 88, + .htotal = 800 + 48 + 88 + 40, + .vdisplay = 480, + .vsync_start = 480 + 7, + .vsync_end = 480 + 7 + 1, + .vtotal = 480 + 7 + 1 + 21, + .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC, + }, +}; + +static const struct drm_display_mode *rpi_ts_modes = rpi_touchscreen_modes; + static struct rpi_touchscreen *panel_to_ts(struct drm_panel *panel) { return container_of(panel, struct rpi_touchscreen, base); @@ -328,7 +348,7 @@ static int rpi_touchscreen_get_modes(struct drm_panel *panel, static const u32 bus_format = MEDIA_BUS_FMT_RGB888_1X24; for (i = 0; i < ARRAY_SIZE(rpi_touchscreen_modes); i++) { - const struct drm_display_mode *m = &rpi_touchscreen_modes[i]; + const struct drm_display_mode *m = &rpi_ts_modes[i]; struct drm_display_mode *mode; mode = drm_mode_duplicate(connector->dev, m); @@ -375,12 +395,25 @@ static int rpi_touchscreen_probe(struct i2c_client *i2c, struct device_node *endpoint, *dsi_host_node; struct mipi_dsi_host *host; int ver; + struct device_node *np = i2c->dev.of_node; + u32 platform; struct mipi_dsi_device_info info = { .type = RPI_DSI_DRIVER_NAME, .channel = 0, .node = NULL, }; + if (of_property_read_u32(np, "platform", &platform)) { + dev_err(&i2c->dev, "failed to get platform property\n"); + } + + if (platform == 3588) { + dev_info(&i2c->dev, "Successfully get the platform property\n"); + rpi_ts_modes = rpi_touchscreen_modes_for_rk3588; + } else { + dev_info(&i2c->dev, "Use the default property\n"); + } + ts = devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL); if (!ts) return -ENOMEM;