Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/panel: ltk500hd1829: make room for more similar panels

There exist more dsi-panels from Leadtek sharing supplies and timings
with only the panel-mode and init commands differing.

So make room in the driver to also keep variants here instead of
requiring additional drivers per panel.

Signed-off-by: Heiko Stuebner <heiko.stuebner@cherry.de>
Reviewed-by: Jessica Zhang <quic_jesszhan@quicinc.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240215090515.3513817-2-heiko@sntech.de

authored by

Heiko Stuebner and committed by
Heiko Stuebner
f9488c16 c530379a

+47 -26
+47 -26
drivers/gpu/drm/panel/panel-leadtek-ltk500hd1829.c
··· 11 11 #include <linux/gpio/consumer.h> 12 12 #include <linux/module.h> 13 13 #include <linux/of.h> 14 + #include <linux/of_device.h> 14 15 #include <linux/regulator/consumer.h> 15 16 16 17 #include <video/mipi_display.h> ··· 22 21 #include <drm/drm_modes.h> 23 22 #include <drm/drm_panel.h> 24 23 24 + struct ltk500hd1829_cmd { 25 + char cmd; 26 + char data; 27 + }; 28 + 29 + struct ltk500hd1829_desc { 30 + const struct drm_display_mode *mode; 31 + const struct ltk500hd1829_cmd *init; 32 + unsigned int num_init; 33 + }; 34 + 25 35 struct ltk500hd1829 { 26 36 struct device *dev; 27 37 struct drm_panel panel; 28 38 struct gpio_desc *reset_gpio; 29 39 struct regulator *vcc; 30 40 struct regulator *iovcc; 41 + const struct ltk500hd1829_desc *panel_desc; 31 42 bool prepared; 32 - }; 33 - 34 - struct ltk500hd1829_cmd { 35 - char cmd; 36 - char data; 37 43 }; 38 44 39 45 /* 40 46 * There is no description in the Reference Manual about these commands. 41 47 * We received them from the vendor, so just use them as is. 42 48 */ 43 - static const struct ltk500hd1829_cmd init_code[] = { 49 + static const struct ltk500hd1829_cmd ltk500hd1829_init[] = { 44 50 { 0xE0, 0x00 }, 45 51 { 0xE1, 0x93 }, 46 52 { 0xE2, 0x65 }, ··· 268 260 { 0x35, 0x00 }, 269 261 }; 270 262 263 + static const struct drm_display_mode ltk500hd1829_mode = { 264 + .hdisplay = 720, 265 + .hsync_start = 720 + 50, 266 + .hsync_end = 720 + 50 + 50, 267 + .htotal = 720 + 50 + 50 + 50, 268 + .vdisplay = 1280, 269 + .vsync_start = 1280 + 30, 270 + .vsync_end = 1280 + 30 + 4, 271 + .vtotal = 1280 + 30 + 4 + 12, 272 + .clock = 69217, 273 + .width_mm = 62, 274 + .height_mm = 110, 275 + }; 276 + 277 + static const struct ltk500hd1829_desc ltk500hd1829_data = { 278 + .mode = &ltk500hd1829_mode, 279 + .init = ltk500hd1829_init, 280 + .num_init = ARRAY_SIZE(ltk500hd1829_init), 281 + }; 282 + 271 283 static inline 272 284 struct ltk500hd1829 *panel_to_ltk500hd1829(struct drm_panel *panel) 273 285 { ··· 352 324 /* tRT: >= 5ms */ 353 325 usleep_range(5000, 6000); 354 326 355 - for (i = 0; i < ARRAY_SIZE(init_code); i++) { 356 - ret = mipi_dsi_generic_write(dsi, &init_code[i], 327 + for (i = 0; i < ctx->panel_desc->num_init; i++) { 328 + ret = mipi_dsi_generic_write(dsi, &ctx->panel_desc->init[i], 357 329 sizeof(struct ltk500hd1829_cmd)); 358 330 if (ret < 0) { 359 331 dev_err(panel->dev, "failed to write init cmds: %d\n", ret); ··· 387 359 return ret; 388 360 } 389 361 390 - static const struct drm_display_mode default_mode = { 391 - .hdisplay = 720, 392 - .hsync_start = 720 + 50, 393 - .hsync_end = 720 + 50 + 50, 394 - .htotal = 720 + 50 + 50 + 50, 395 - .vdisplay = 1280, 396 - .vsync_start = 1280 + 30, 397 - .vsync_end = 1280 + 30 + 4, 398 - .vtotal = 1280 + 30 + 4 + 12, 399 - .clock = 69217, 400 - .width_mm = 62, 401 - .height_mm = 110, 402 - }; 403 - 404 362 static int ltk500hd1829_get_modes(struct drm_panel *panel, 405 363 struct drm_connector *connector) 406 364 { 407 365 struct ltk500hd1829 *ctx = panel_to_ltk500hd1829(panel); 408 366 struct drm_display_mode *mode; 409 367 410 - mode = drm_mode_duplicate(connector->dev, &default_mode); 368 + mode = drm_mode_duplicate(connector->dev, ctx->panel_desc->mode); 411 369 if (!mode) { 412 370 dev_err(ctx->dev, "failed to add mode %ux%u@%u\n", 413 - default_mode.hdisplay, default_mode.vdisplay, 414 - drm_mode_vrefresh(&default_mode)); 371 + ctx->panel_desc->mode->hdisplay, ctx->panel_desc->mode->vdisplay, 372 + drm_mode_vrefresh(ctx->panel_desc->mode)); 415 373 return -ENOMEM; 416 374 } 417 375 ··· 426 412 ctx = devm_kzalloc(&dsi->dev, sizeof(*ctx), GFP_KERNEL); 427 413 if (!ctx) 428 414 return -ENOMEM; 415 + 416 + ctx->panel_desc = of_device_get_match_data(dev); 417 + if (!ctx->panel_desc) 418 + return -EINVAL; 429 419 430 420 ctx->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); 431 421 if (IS_ERR(ctx->reset_gpio)) { ··· 510 492 } 511 493 512 494 static const struct of_device_id ltk500hd1829_of_match[] = { 513 - { .compatible = "leadtek,ltk500hd1829", }, 495 + { 496 + .compatible = "leadtek,ltk500hd1829", 497 + .data = &ltk500hd1829_data, 498 + }, 514 499 { /* sentinel */ } 515 500 }; 516 501 MODULE_DEVICE_TABLE(of, ltk500hd1829_of_match);