| .. | .. |
|---|
| 6 | 6 | * Yannick Fertre <yannick.fertre@st.com> |
|---|
| 7 | 7 | */ |
|---|
| 8 | 8 | |
|---|
| 9 | | -#include <drm/drmP.h> |
|---|
| 10 | | -#include <drm/drm_mipi_dsi.h> |
|---|
| 11 | | -#include <drm/drm_panel.h> |
|---|
| 12 | 9 | #include <linux/backlight.h> |
|---|
| 10 | +#include <linux/delay.h> |
|---|
| 13 | 11 | #include <linux/gpio/consumer.h> |
|---|
| 12 | +#include <linux/module.h> |
|---|
| 14 | 13 | #include <linux/regulator/consumer.h> |
|---|
| 14 | + |
|---|
| 15 | 15 | #include <video/mipi_display.h> |
|---|
| 16 | + |
|---|
| 17 | +#include <drm/drm_mipi_dsi.h> |
|---|
| 18 | +#include <drm/drm_modes.h> |
|---|
| 19 | +#include <drm/drm_panel.h> |
|---|
| 16 | 20 | |
|---|
| 17 | 21 | #define OTM8009A_BACKLIGHT_DEFAULT 240 |
|---|
| 18 | 22 | #define OTM8009A_BACKLIGHT_MAX 255 |
|---|
| .. | .. |
|---|
| 67 | 71 | }; |
|---|
| 68 | 72 | |
|---|
| 69 | 73 | static const struct drm_display_mode default_mode = { |
|---|
| 70 | | - .clock = 32729, |
|---|
| 74 | + .clock = 29700, |
|---|
| 71 | 75 | .hdisplay = 480, |
|---|
| 72 | | - .hsync_start = 480 + 120, |
|---|
| 73 | | - .hsync_end = 480 + 120 + 63, |
|---|
| 74 | | - .htotal = 480 + 120 + 63 + 120, |
|---|
| 76 | + .hsync_start = 480 + 98, |
|---|
| 77 | + .hsync_end = 480 + 98 + 32, |
|---|
| 78 | + .htotal = 480 + 98 + 32 + 98, |
|---|
| 75 | 79 | .vdisplay = 800, |
|---|
| 76 | | - .vsync_start = 800 + 12, |
|---|
| 77 | | - .vsync_end = 800 + 12 + 12, |
|---|
| 78 | | - .vtotal = 800 + 12 + 12 + 12, |
|---|
| 79 | | - .vrefresh = 50, |
|---|
| 80 | + .vsync_start = 800 + 15, |
|---|
| 81 | + .vsync_end = 800 + 15 + 10, |
|---|
| 82 | + .vtotal = 800 + 15 + 10 + 14, |
|---|
| 80 | 83 | .flags = 0, |
|---|
| 81 | 84 | .width_mm = 52, |
|---|
| 82 | 85 | .height_mm = 86, |
|---|
| .. | .. |
|---|
| 93 | 96 | struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); |
|---|
| 94 | 97 | |
|---|
| 95 | 98 | if (mipi_dsi_dcs_write_buffer(dsi, data, len) < 0) |
|---|
| 96 | | - DRM_WARN("mipi dsi dcs write buffer failed\n"); |
|---|
| 99 | + dev_warn(ctx->dev, "mipi dsi dcs write buffer failed\n"); |
|---|
| 97 | 100 | } |
|---|
| 98 | 101 | |
|---|
| 99 | 102 | static void otm8009a_dcs_write_buf_hs(struct otm8009a *ctx, const void *data, |
|---|
| .. | .. |
|---|
| 309 | 312 | |
|---|
| 310 | 313 | ret = regulator_enable(ctx->supply); |
|---|
| 311 | 314 | if (ret < 0) { |
|---|
| 312 | | - DRM_ERROR("failed to enable supply: %d\n", ret); |
|---|
| 315 | + dev_err(panel->dev, "failed to enable supply: %d\n", ret); |
|---|
| 313 | 316 | return ret; |
|---|
| 314 | 317 | } |
|---|
| 315 | 318 | |
|---|
| .. | .. |
|---|
| 344 | 347 | return 0; |
|---|
| 345 | 348 | } |
|---|
| 346 | 349 | |
|---|
| 347 | | -static int otm8009a_get_modes(struct drm_panel *panel) |
|---|
| 350 | +static int otm8009a_get_modes(struct drm_panel *panel, |
|---|
| 351 | + struct drm_connector *connector) |
|---|
| 348 | 352 | { |
|---|
| 349 | 353 | struct drm_display_mode *mode; |
|---|
| 350 | 354 | |
|---|
| 351 | | - mode = drm_mode_duplicate(panel->drm, &default_mode); |
|---|
| 355 | + mode = drm_mode_duplicate(connector->dev, &default_mode); |
|---|
| 352 | 356 | if (!mode) { |
|---|
| 353 | | - DRM_ERROR("failed to add mode %ux%ux@%u\n", |
|---|
| 354 | | - default_mode.hdisplay, default_mode.vdisplay, |
|---|
| 355 | | - default_mode.vrefresh); |
|---|
| 357 | + dev_err(panel->dev, "failed to add mode %ux%u@%u\n", |
|---|
| 358 | + default_mode.hdisplay, default_mode.vdisplay, |
|---|
| 359 | + drm_mode_vrefresh(&default_mode)); |
|---|
| 356 | 360 | return -ENOMEM; |
|---|
| 357 | 361 | } |
|---|
| 358 | 362 | |
|---|
| 359 | 363 | drm_mode_set_name(mode); |
|---|
| 360 | 364 | |
|---|
| 361 | 365 | mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; |
|---|
| 362 | | - drm_mode_probed_add(panel->connector, mode); |
|---|
| 366 | + drm_mode_probed_add(connector, mode); |
|---|
| 363 | 367 | |
|---|
| 364 | | - panel->connector->display_info.width_mm = mode->width_mm; |
|---|
| 365 | | - panel->connector->display_info.height_mm = mode->height_mm; |
|---|
| 368 | + connector->display_info.width_mm = mode->width_mm; |
|---|
| 369 | + connector->display_info.height_mm = mode->height_mm; |
|---|
| 366 | 370 | |
|---|
| 367 | 371 | return 1; |
|---|
| 368 | 372 | } |
|---|
| .. | .. |
|---|
| 385 | 389 | u8 data[2]; |
|---|
| 386 | 390 | |
|---|
| 387 | 391 | if (!ctx->prepared) { |
|---|
| 388 | | - DRM_DEBUG("lcd not ready yet for setting its backlight!\n"); |
|---|
| 392 | + dev_dbg(&bd->dev, "lcd not ready yet for setting its backlight!\n"); |
|---|
| 389 | 393 | return -ENXIO; |
|---|
| 390 | 394 | } |
|---|
| 391 | 395 | |
|---|
| .. | .. |
|---|
| 436 | 440 | ctx->supply = devm_regulator_get(dev, "power"); |
|---|
| 437 | 441 | if (IS_ERR(ctx->supply)) { |
|---|
| 438 | 442 | ret = PTR_ERR(ctx->supply); |
|---|
| 439 | | - dev_err(dev, "failed to request regulator: %d\n", ret); |
|---|
| 443 | + if (ret != -EPROBE_DEFER) |
|---|
| 444 | + dev_err(dev, "failed to request regulator: %d\n", ret); |
|---|
| 440 | 445 | return ret; |
|---|
| 441 | 446 | } |
|---|
| 442 | 447 | |
|---|
| .. | .. |
|---|
| 447 | 452 | dsi->lanes = 2; |
|---|
| 448 | 453 | dsi->format = MIPI_DSI_FMT_RGB888; |
|---|
| 449 | 454 | dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST | |
|---|
| 450 | | - MIPI_DSI_MODE_LPM; |
|---|
| 455 | + MIPI_DSI_MODE_LPM | MIPI_DSI_CLOCK_NON_CONTINUOUS; |
|---|
| 451 | 456 | |
|---|
| 452 | | - drm_panel_init(&ctx->panel); |
|---|
| 453 | | - ctx->panel.dev = dev; |
|---|
| 454 | | - ctx->panel.funcs = &otm8009a_drm_funcs; |
|---|
| 457 | + drm_panel_init(&ctx->panel, dev, &otm8009a_drm_funcs, |
|---|
| 458 | + DRM_MODE_CONNECTOR_DSI); |
|---|
| 455 | 459 | |
|---|
| 456 | 460 | ctx->bl_dev = devm_backlight_device_register(dev, dev_name(dev), |
|---|
| 457 | | - dsi->host->dev, ctx, |
|---|
| 461 | + dev, ctx, |
|---|
| 458 | 462 | &otm8009a_backlight_ops, |
|---|
| 459 | 463 | NULL); |
|---|
| 460 | 464 | if (IS_ERR(ctx->bl_dev)) { |
|---|
| .. | .. |
|---|
| 474 | 478 | if (ret < 0) { |
|---|
| 475 | 479 | dev_err(dev, "mipi_dsi_attach failed. Is host ready?\n"); |
|---|
| 476 | 480 | drm_panel_remove(&ctx->panel); |
|---|
| 477 | | - backlight_device_unregister(ctx->bl_dev); |
|---|
| 478 | 481 | return ret; |
|---|
| 479 | 482 | } |
|---|
| 480 | 483 | |
|---|