Lines Matching +full:enforce +full:- +full:video +full:- +full:mode

1 // SPDX-License-Identifier: GPL-2.0+
3 * MIPI-DSI Novatek NT35560-based panel controller.
6 * Sony ACX424AKM - a 480x854 AMOLED DSI panel
7 * Sony ACX424AKP - a 480x864 AMOLED DSI panel
9 * Copyright (C) Linaro Ltd. 2019-2021
11 * Based on code and know-how from Marcus Lorentzon
12 * Copyright (C) ST-Ericsson SA 2010
13 * Based on code and know-how from Johan Olson and Joakim Wesslen
23 #include <video/mipi_display.h>
77 * command mode using the maximum HS frequency.
119 * command mode using the maximum HS frequency.
151 struct mipi_dsi_device *dsi = to_mipi_dsi_device(nt->dev); in nt35560_set_brightness()
153 int duty_ns = bl->props.brightness; in nt35560_set_brightness()
165 dev_err(nt->dev, "failed to disable display backlight (%d)\n", ret); in nt35560_set_brightness()
172 pwm_ratio = max(((duty_ns * 256) / period_ns) - 1, 1); in nt35560_set_brightness()
178 dev_dbg(nt->dev, "calculated duty cycle %02x\n", pwm_ratio); in nt35560_set_brightness()
182 dev_err(nt->dev, "failed to set display PWM ratio (%d)\n", ret); in nt35560_set_brightness()
198 dev_err(nt->dev, "failed to unlock CMD 2 (%d)\n", ret); in nt35560_set_brightness()
204 dev_err(nt->dev, "failed to enter page 1 (%d)\n", ret); in nt35560_set_brightness()
210 dev_err(nt->dev, "failed to disable MTP reload (%d)\n", ret); in nt35560_set_brightness()
215 dev_err(nt->dev, "failed to set PWM divisor (%d)\n", ret); in nt35560_set_brightness()
221 dev_err(nt->dev, "failed to lock CMD 2 (%d)\n", ret); in nt35560_set_brightness()
230 dev_err(nt->dev, "failed to enable display backlight (%d)\n", ret); in nt35560_set_brightness()
249 struct mipi_dsi_device *dsi = to_mipi_dsi_device(nt->dev); in nt35560_read_id()
256 dev_err(nt->dev, "could not vendor ID byte\n"); in nt35560_read_id()
261 dev_err(nt->dev, "could not read device version byte\n"); in nt35560_read_id()
266 dev_err(nt->dev, "could not read panel ID byte\n"); in nt35560_read_id()
271 dev_err(nt->dev, "device vendor ID is zero\n"); in nt35560_read_id()
272 return -ENODEV; in nt35560_read_id()
281 dev_info(nt->dev, "MTP vendor: %02x, version: %02x, panel: %02x\n", in nt35560_read_id()
285 dev_info(nt->dev, "unknown vendor: %02x, version: %02x, panel: %02x\n", in nt35560_read_id()
297 ret = regulator_enable(nt->supply); in nt35560_power_on()
299 dev_err(nt->dev, "failed to enable supply (%d)\n", ret); in nt35560_power_on()
304 gpiod_set_value_cansleep(nt->reset_gpio, 1); in nt35560_power_on()
306 /* De-assert RESET */ in nt35560_power_on()
307 gpiod_set_value_cansleep(nt->reset_gpio, 0); in nt35560_power_on()
316 gpiod_set_value_cansleep(nt->reset_gpio, 1); in nt35560_power_off()
319 regulator_disable(nt->supply); in nt35560_power_off()
325 struct mipi_dsi_device *dsi = to_mipi_dsi_device(nt->dev); in nt35560_prepare()
335 dev_err(nt->dev, "failed to read panel ID (%d)\n", ret); in nt35560_prepare()
339 /* Enabe tearing mode: send TE (tearing effect) at VBLANK */ in nt35560_prepare()
343 dev_err(nt->dev, "failed to enable vblank TE (%d)\n", ret); in nt35560_prepare()
360 dev_err(nt->dev, "failed to set MDDI (%d)\n", ret); in nt35560_prepare()
364 /* Exit sleep mode */ in nt35560_prepare()
367 dev_err(nt->dev, "failed to exit sleep mode (%d)\n", ret); in nt35560_prepare()
374 dev_err(nt->dev, "failed to turn display on (%d)\n", ret); in nt35560_prepare()
377 if (nt->video_mode) { in nt35560_prepare()
378 /* In video mode turn peripheral on */ in nt35560_prepare()
381 dev_err(nt->dev, "failed to turn on peripheral\n"); in nt35560_prepare()
396 struct mipi_dsi_device *dsi = to_mipi_dsi_device(nt->dev); in nt35560_unprepare()
401 dev_err(nt->dev, "failed to turn display off (%d)\n", ret); in nt35560_unprepare()
405 /* Enter sleep mode */ in nt35560_unprepare()
408 dev_err(nt->dev, "failed to enter sleep mode (%d)\n", ret); in nt35560_unprepare()
423 const struct nt35560_config *conf = nt->conf; in nt35560_get_modes()
424 struct drm_display_mode *mode; in nt35560_get_modes() local
426 if (nt->video_mode) in nt35560_get_modes()
427 mode = drm_mode_duplicate(connector->dev, in nt35560_get_modes()
428 conf->vid_mode); in nt35560_get_modes()
430 mode = drm_mode_duplicate(connector->dev, in nt35560_get_modes()
431 conf->cmd_mode); in nt35560_get_modes()
432 if (!mode) { in nt35560_get_modes()
433 dev_err(panel->dev, "bad mode or failed to add mode\n"); in nt35560_get_modes()
434 return -EINVAL; in nt35560_get_modes()
436 drm_mode_set_name(mode); in nt35560_get_modes()
437 mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; in nt35560_get_modes()
439 connector->display_info.width_mm = mode->width_mm; in nt35560_get_modes()
440 connector->display_info.height_mm = mode->height_mm; in nt35560_get_modes()
442 drm_mode_probed_add(connector, mode); in nt35560_get_modes()
455 struct device *dev = &dsi->dev; in nt35560_probe()
461 return -ENOMEM; in nt35560_probe()
462 nt->video_mode = of_property_read_bool(dev->of_node, in nt35560_probe()
463 "enforce-video-mode"); in nt35560_probe()
466 nt->dev = dev; in nt35560_probe()
468 nt->conf = of_device_get_match_data(dev); in nt35560_probe()
469 if (!nt->conf) { in nt35560_probe()
471 return -ENODEV; in nt35560_probe()
474 dsi->lanes = 2; in nt35560_probe()
475 dsi->format = MIPI_DSI_FMT_RGB888; in nt35560_probe()
477 * FIXME: these come from the ST-Ericsson vendor driver for the in nt35560_probe()
479 * platform, if you have the datasheet, please cross-check the in nt35560_probe()
482 dsi->lp_rate = 19200000; in nt35560_probe()
483 dsi->hs_rate = 420160000; in nt35560_probe()
485 if (nt->video_mode) in nt35560_probe()
486 /* Burst mode using event for sync */ in nt35560_probe()
487 dsi->mode_flags = in nt35560_probe()
491 dsi->mode_flags = in nt35560_probe()
494 nt->supply = devm_regulator_get(dev, "vddi"); in nt35560_probe()
495 if (IS_ERR(nt->supply)) in nt35560_probe()
496 return PTR_ERR(nt->supply); in nt35560_probe()
499 nt->reset_gpio = devm_gpiod_get_optional(dev, "reset", in nt35560_probe()
501 if (IS_ERR(nt->reset_gpio)) in nt35560_probe()
502 return dev_err_probe(dev, PTR_ERR(nt->reset_gpio), in nt35560_probe()
505 drm_panel_init(&nt->panel, dev, &nt35560_drm_funcs, in nt35560_probe()
508 nt->panel.backlight = devm_backlight_device_register(dev, "nt35560", dev, nt, in nt35560_probe()
510 if (IS_ERR(nt->panel.backlight)) in nt35560_probe()
511 return dev_err_probe(dev, PTR_ERR(nt->panel.backlight), in nt35560_probe()
514 drm_panel_add(&nt->panel); in nt35560_probe()
518 drm_panel_remove(&nt->panel); in nt35560_probe()
530 drm_panel_remove(&nt->panel); in nt35560_remove()
550 .name = "panel-novatek-nt35560",
557 MODULE_DESCRIPTION("MIPI-DSI Novatek NT35560 Panel Driver");