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

17  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
34 #include <video/display_timing.h>
35 #include <video/of_display_timing.h>
36 #include <video/videomode.h>
46 * struct panel_delay - Describes delays for a simple panel.
59 * hpd_absent. While that works, it's non-ideal.
68 * This is T3-max on eDP timing diagrams or the delay from power on
99 * // enforce prepare_to_enable min time
112 * video data.
114 * This is (T6-min + max(T7-max, T8-min)) on eDP timing diagrams or
126 * This is T9-min (delay from backlight off to end of valid video
142 * This is T12-min on eDP timing diagrams.
148 * struct panel_desc - Describes a simple panel.
154 * If only one mode then this can just be the address of the mode.
156 * then you cannot override the mode in the device tree.
195 * struct edp_panel_entry - Maps panel ID to delay / panel name.
198 /** @panel_id: 32-bit ID for panel, encoded with drm_edid_encode_panel_id(). */
244 struct drm_display_mode *mode; in panel_edp_get_timings_modes() local
247 for (i = 0; i < panel->desc->num_timings; i++) { in panel_edp_get_timings_modes()
248 const struct display_timing *dt = &panel->desc->timings[i]; in panel_edp_get_timings_modes()
252 mode = drm_mode_create(connector->dev); in panel_edp_get_timings_modes()
253 if (!mode) { in panel_edp_get_timings_modes()
254 dev_err(panel->base.dev, "failed to add mode %ux%u\n", in panel_edp_get_timings_modes()
255 dt->hactive.typ, dt->vactive.typ); in panel_edp_get_timings_modes()
259 drm_display_mode_from_videomode(&vm, mode); in panel_edp_get_timings_modes()
261 mode->type |= DRM_MODE_TYPE_DRIVER; in panel_edp_get_timings_modes()
263 if (panel->desc->num_timings == 1) in panel_edp_get_timings_modes()
264 mode->type |= DRM_MODE_TYPE_PREFERRED; in panel_edp_get_timings_modes()
266 drm_mode_probed_add(connector, mode); in panel_edp_get_timings_modes()
276 struct drm_display_mode *mode; in panel_edp_get_display_modes() local
279 for (i = 0; i < panel->desc->num_modes; i++) { in panel_edp_get_display_modes()
280 const struct drm_display_mode *m = &panel->desc->modes[i]; in panel_edp_get_display_modes()
282 mode = drm_mode_duplicate(connector->dev, m); in panel_edp_get_display_modes()
283 if (!mode) { in panel_edp_get_display_modes()
284 dev_err(panel->base.dev, "failed to add mode %ux%u@%u\n", in panel_edp_get_display_modes()
285 m->hdisplay, m->vdisplay, in panel_edp_get_display_modes()
290 mode->type |= DRM_MODE_TYPE_DRIVER; in panel_edp_get_display_modes()
292 if (panel->desc->num_modes == 1) in panel_edp_get_display_modes()
293 mode->type |= DRM_MODE_TYPE_PREFERRED; in panel_edp_get_display_modes()
295 drm_mode_set_name(mode); in panel_edp_get_display_modes()
297 drm_mode_probed_add(connector, mode); in panel_edp_get_display_modes()
307 struct drm_display_mode *mode; in panel_edp_get_non_edid_modes() local
308 bool has_override = panel->override_mode.type; in panel_edp_get_non_edid_modes()
311 if (!panel->desc) in panel_edp_get_non_edid_modes()
315 mode = drm_mode_duplicate(connector->dev, in panel_edp_get_non_edid_modes()
316 &panel->override_mode); in panel_edp_get_non_edid_modes()
317 if (mode) { in panel_edp_get_non_edid_modes()
318 drm_mode_probed_add(connector, mode); in panel_edp_get_non_edid_modes()
321 dev_err(panel->base.dev, "failed to add override mode\n"); in panel_edp_get_non_edid_modes()
326 if (num == 0 && panel->desc->num_timings) in panel_edp_get_non_edid_modes()
330 * Only add fixed modes if timings/override added no mode. in panel_edp_get_non_edid_modes()
333 * or a fixed mode. Anything else is rather bogus. in panel_edp_get_non_edid_modes()
335 WARN_ON(panel->desc->num_timings && panel->desc->num_modes); in panel_edp_get_non_edid_modes()
339 connector->display_info.bpc = panel->desc->bpc; in panel_edp_get_non_edid_modes()
340 connector->display_info.width_mm = panel->desc->size.width; in panel_edp_get_non_edid_modes()
341 connector->display_info.height_mm = panel->desc->size.height; in panel_edp_get_non_edid_modes()
364 if (!p->enabled) in panel_edp_disable()
367 if (p->desc->delay.disable) in panel_edp_disable()
368 msleep(p->desc->delay.disable); in panel_edp_disable()
370 p->enabled = false; in panel_edp_disable()
379 gpiod_set_value_cansleep(p->enable_gpio, 0); in panel_edp_suspend()
380 regulator_disable(p->supply); in panel_edp_suspend()
381 p->unprepared_time = ktime_get(); in panel_edp_suspend()
391 /* Unpreparing when already unprepared is a no-op */ in panel_edp_unprepare()
392 if (!p->prepared) in panel_edp_unprepare()
395 pm_runtime_mark_last_busy(panel->dev); in panel_edp_unprepare()
396 ret = pm_runtime_put_autosuspend(panel->dev); in panel_edp_unprepare()
399 p->prepared = false; in panel_edp_unprepare()
406 p->hpd_gpio = devm_gpiod_get_optional(dev, "hpd", GPIOD_IN); in panel_edp_get_hpd_gpio()
407 if (IS_ERR(p->hpd_gpio)) in panel_edp_get_hpd_gpio()
408 return dev_err_probe(dev, PTR_ERR(p->hpd_gpio), in panel_edp_get_hpd_gpio()
416 return !p->no_hpd && (p->hpd_gpio || (p->aux && p->aux->wait_hpd_asserted)); in panel_edp_can_read_hpd()
421 struct device *dev = p->base.dev; in panel_edp_prepare_once()
427 panel_edp_wait(p->unprepared_time, p->desc->delay.unprepare); in panel_edp_prepare_once()
429 err = regulator_enable(p->supply); in panel_edp_prepare_once()
435 gpiod_set_value_cansleep(p->enable_gpio, 1); in panel_edp_prepare_once()
437 delay = p->desc->delay.hpd_reliable; in panel_edp_prepare_once()
438 if (p->no_hpd) in panel_edp_prepare_once()
439 delay = max(delay, p->desc->delay.hpd_absent); in panel_edp_prepare_once()
444 if (p->desc->delay.hpd_absent) in panel_edp_prepare_once()
445 hpd_wait_us = p->desc->delay.hpd_absent * 1000UL; in panel_edp_prepare_once()
449 if (p->hpd_gpio) { in panel_edp_prepare_once()
451 p->hpd_gpio, hpd_asserted, in panel_edp_prepare_once()
456 err = p->aux->wait_hpd_asserted(p->aux, hpd_wait_us); in panel_edp_prepare_once()
460 if (err != -ETIMEDOUT) in panel_edp_prepare_once()
467 p->prepared_time = ktime_get(); in panel_edp_prepare_once()
472 gpiod_set_value_cansleep(p->enable_gpio, 0); in panel_edp_prepare_once()
473 regulator_disable(p->supply); in panel_edp_prepare_once()
474 p->unprepared_time = ktime_get(); in panel_edp_prepare_once()
493 if (ret != -ETIMEDOUT) in panel_edp_resume()
497 if (ret == -ETIMEDOUT) in panel_edp_resume()
510 /* Preparing when already prepared is a no-op */ in panel_edp_prepare()
511 if (p->prepared) in panel_edp_prepare()
514 ret = pm_runtime_get_sync(panel->dev); in panel_edp_prepare()
516 pm_runtime_put_autosuspend(panel->dev); in panel_edp_prepare()
520 p->prepared = true; in panel_edp_prepare()
530 if (p->enabled) in panel_edp_enable()
533 delay = p->desc->delay.enable; in panel_edp_enable()
543 * called (and link training took zero time). Note that "no-hpd" in panel_edp_enable()
552 if (p->desc->delay.prepare_to_enable && in panel_edp_enable()
553 !panel_edp_can_read_hpd(p) && !p->no_hpd) in panel_edp_enable()
554 delay = max(delay, p->desc->delay.prepare_to_enable); in panel_edp_enable()
559 panel_edp_wait(p->prepared_time, p->desc->delay.prepare_to_enable); in panel_edp_enable()
561 p->enabled = true; in panel_edp_enable()
573 if (p->ddc) { in panel_edp_get_modes()
574 pm_runtime_get_sync(panel->dev); in panel_edp_get_modes()
576 if (!p->edid) in panel_edp_get_modes()
577 p->edid = drm_get_edid(connector, p->ddc); in panel_edp_get_modes()
579 if (p->edid) in panel_edp_get_modes()
580 num += drm_add_edid_modes(connector, p->edid); in panel_edp_get_modes()
582 pm_runtime_mark_last_busy(panel->dev); in panel_edp_get_modes()
583 pm_runtime_put_autosuspend(panel->dev); in panel_edp_get_modes()
587 * Add hard-coded panel modes. Don't call this if there are no timings in panel_edp_get_modes()
588 * and no modes (the generic edp-panel case) because it will clobber in panel_edp_get_modes()
591 if (p->desc->num_timings || p->desc->num_modes) in panel_edp_get_modes()
594 dev_warn(p->base.dev, "No display modes\n"); in panel_edp_get_modes()
600 drm_connector_set_panel_orientation(connector, p->orientation); in panel_edp_get_modes()
612 if (p->desc->num_timings < num_timings) in panel_edp_get_timings()
613 num_timings = p->desc->num_timings; in panel_edp_get_timings()
617 timings[i] = p->desc->timings[i]; in panel_edp_get_timings()
619 return p->desc->num_timings; in panel_edp_get_timings()
626 return p->orientation; in panel_edp_get_orientation()
631 struct drm_panel *panel = s->private; in detected_panel_show()
634 if (IS_ERR(p->detected_panel)) in detected_panel_show()
636 else if (!p->detected_panel) in detected_panel_show()
639 seq_printf(s, "%s\n", p->detected_panel->name); in detected_panel_show()
663 (to_check->field.typ >= bounds->field.min && \
664 to_check->field.typ <= bounds->field.max)
669 const struct panel_desc *desc = panel->desc; in panel_edp_parse_panel_timing_node()
673 if (WARN_ON(desc->num_modes)) { in panel_edp_parse_panel_timing_node()
674 dev_err(dev, "Reject override mode: panel has a fixed mode\n"); in panel_edp_parse_panel_timing_node()
677 if (WARN_ON(!desc->num_timings)) { in panel_edp_parse_panel_timing_node()
678 dev_err(dev, "Reject override mode: no timings specified\n"); in panel_edp_parse_panel_timing_node()
682 for (i = 0; i < panel->desc->num_timings; i++) { in panel_edp_parse_panel_timing_node()
683 const struct display_timing *dt = &panel->desc->timings[i]; in panel_edp_parse_panel_timing_node()
695 if (ot->flags != dt->flags) in panel_edp_parse_panel_timing_node()
699 drm_display_mode_from_videomode(&vm, &panel->override_mode); in panel_edp_parse_panel_timing_node()
700 panel->override_mode.type |= DRM_MODE_TYPE_DRIVER | in panel_edp_parse_panel_timing_node()
705 if (WARN_ON(!panel->override_mode.type)) in panel_edp_parse_panel_timing_node()
706 dev_err(dev, "Reject override mode: No display_timing found\n"); in panel_edp_parse_panel_timing_node()
723 return -ENOMEM; in generic_edp_panel_probe()
724 panel->desc = desc; in generic_edp_panel_probe()
731 of_property_read_u32(dev->of_node, "hpd-reliable-delay-ms", &reliable_ms); in generic_edp_panel_probe()
732 desc->delay.hpd_reliable = reliable_ms; in generic_edp_panel_probe()
733 of_property_read_u32(dev->of_node, "hpd-absent-delay-ms", &absent_ms); in generic_edp_panel_probe()
734 desc->delay.hpd_absent = absent_ms; in generic_edp_panel_probe()
743 panel_id = drm_edid_get_panel_id(panel->ddc); in generic_edp_panel_probe()
746 ret = -EIO; in generic_edp_panel_probe()
751 panel->detected_panel = find_edp_panel(panel_id); in generic_edp_panel_probe()
754 * We're using non-optimized timings and want it really obvious that in generic_edp_panel_probe()
758 if (WARN_ON(!panel->detected_panel)) { in generic_edp_panel_probe()
766 * the HPD-related delays must have worked since we got this in generic_edp_panel_probe()
778 desc->delay.unprepare = 2000; in generic_edp_panel_probe()
779 desc->delay.enable = 200; in generic_edp_panel_probe()
781 panel->detected_panel = ERR_PTR(-EINVAL); in generic_edp_panel_probe()
784 vend, panel->detected_panel->name, product_id); in generic_edp_panel_probe()
787 desc->delay = *panel->detected_panel->delay; in generic_edp_panel_probe()
808 return -ENOMEM; in panel_edp_probe()
810 panel->enabled = false; in panel_edp_probe()
811 panel->prepared_time = 0; in panel_edp_probe()
812 panel->desc = desc; in panel_edp_probe()
813 panel->aux = aux; in panel_edp_probe()
815 panel->no_hpd = of_property_read_bool(dev->of_node, "no-hpd"); in panel_edp_probe()
816 if (!panel->no_hpd) { in panel_edp_probe()
822 panel->supply = devm_regulator_get(dev, "power"); in panel_edp_probe()
823 if (IS_ERR(panel->supply)) in panel_edp_probe()
824 return PTR_ERR(panel->supply); in panel_edp_probe()
826 panel->enable_gpio = devm_gpiod_get_optional(dev, "enable", in panel_edp_probe()
828 if (IS_ERR(panel->enable_gpio)) in panel_edp_probe()
829 return dev_err_probe(dev, PTR_ERR(panel->enable_gpio), in panel_edp_probe()
832 err = of_drm_get_panel_orientation(dev->of_node, &panel->orientation); in panel_edp_probe()
834 dev_err(dev, "%pOF: failed to get orientation %d\n", dev->of_node, err); in panel_edp_probe()
838 ddc = of_parse_phandle(dev->of_node, "ddc-i2c-bus", 0); in panel_edp_probe()
840 panel->ddc = of_find_i2c_adapter_by_node(ddc); in panel_edp_probe()
843 if (!panel->ddc) in panel_edp_probe()
844 return -EPROBE_DEFER; in panel_edp_probe()
846 panel->ddc = &aux->ddc; in panel_edp_probe()
849 if (!of_get_display_timing(dev->of_node, "panel-timing", &dt)) in panel_edp_probe()
854 drm_panel_init(&panel->base, dev, &panel_edp_funcs, DRM_MODE_CONNECTOR_eDP); in panel_edp_probe()
856 err = drm_panel_of_backlight(&panel->base); in panel_edp_probe()
870 if (of_device_is_compatible(dev->of_node, "edp-panel")) { in panel_edp_probe()
878 desc = panel->desc; in panel_edp_probe()
879 } else if (desc->bpc != 6 && desc->bpc != 8 && desc->bpc != 10) { in panel_edp_probe()
880 dev_warn(dev, "Expected bpc in {6,8,10} but got: %u\n", desc->bpc); in panel_edp_probe()
883 if (!panel->base.backlight && panel->aux) { in panel_edp_probe()
885 err = drm_panel_dp_aux_backlight(&panel->base, panel->aux); in panel_edp_probe()
892 drm_panel_add(&panel->base); in panel_edp_probe()
900 if (panel->ddc && (!panel->aux || panel->ddc != &panel->aux->ddc)) in panel_edp_probe()
901 put_device(&panel->ddc->dev); in panel_edp_probe()
910 drm_panel_remove(&panel->base); in panel_edp_remove()
911 drm_panel_disable(&panel->base); in panel_edp_remove()
912 drm_panel_unprepare(&panel->base); in panel_edp_remove()
916 if (panel->ddc && (!panel->aux || panel->ddc != &panel->aux->ddc)) in panel_edp_remove()
917 put_device(&panel->ddc->dev); in panel_edp_remove()
919 kfree(panel->edid); in panel_edp_remove()
920 panel->edid = NULL; in panel_edp_remove()
929 drm_panel_disable(&panel->base); in panel_edp_shutdown()
930 drm_panel_unprepare(&panel->base); in panel_edp_shutdown()
1144 /* TODO: should be hpd-absent and no-hpd should be set? */
1224 * - If HPD isn't hooked up you still have 200 ms delay.
1225 * - If HPD is hooked up we won't try to look at it for the
1258 /* TODO: should be hpd-absent and no-hpd should be set? */
1296 * - total horizontal time: { 1506, 1592, 1716 }
1297 * - total vertical time: { 788, 800, 868 }
1713 /* TODO: should be hpd-absent and no-hpd should be set? */
1723 .compatible = "edp-panel",
1749 .compatible = "boe,nv110wtm-n61",
1752 .compatible = "boe,nv133fhm-n61",
1755 .compatible = "boe,nv133fhm-n62",
1761 .compatible = "innolux,n116bca-ea1",
1767 .compatible = "innolux,n125hce-gn1",
1770 .compatible = "innolux,p120zdg-bf1",
1773 .compatible = "ivo,m133nwf4-r0",
1776 .compatible = "kingdisplay,kd116n21-30nv-a010",
1779 .compatible = "lg,lp079qx1-sp0v",
1782 .compatible = "lg,lp097qx1-spa1",
1794 .compatible = "samsung,lsn122dl01-c01",
1797 .compatible = "samsung,ltn140at29-301",
1800 .compatible = "sharp,ld-d5116z01b",
1877 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0786, &delay_200_500_p2e80, "NV116WHM-T01"),
1878 EDP_PANEL_ENTRY('B', 'O', 'E', 0x07d1, &boe_nv133fhm_n61.delay, "NV133FHM-N61"),
1879 EDP_PANEL_ENTRY('B', 'O', 'E', 0x082d, &boe_nv133fhm_n61.delay, "NV133FHM-N62"),
1880 EDP_PANEL_ENTRY('B', 'O', 'E', 0x094b, &delay_200_500_e50, "NT116WHM-N21"),
1881 EDP_PANEL_ENTRY('B', 'O', 'E', 0x098d, &boe_nv110wtm_n61.delay, "NV110WTM-N61"),
1882 EDP_PANEL_ENTRY('B', 'O', 'E', 0x09dd, &delay_200_500_e50, "NT116WHM-N21"),
1883 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0a5d, &delay_200_500_e50, "NV116WHM-N45"),
1884 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0ac5, &delay_200_500_e50, "NV116WHM-N4C"),
1886 EDP_PANEL_ENTRY('C', 'M', 'N', 0x114c, &innolux_n116bca_ea1.delay, "N116BCA-EA1"),
1887 EDP_PANEL_ENTRY('C', 'M', 'N', 0x1152, &delay_200_500_e80_d50, "N116BCN-EA1"),
1888 EDP_PANEL_ENTRY('C', 'M', 'N', 0x1154, &delay_200_500_e80_d50, "N116BCA-EA2"),
1889 EDP_PANEL_ENTRY('C', 'M', 'N', 0x1247, &delay_200_500_e80_d50, "N120ACA-EA1"),
1892 EDP_PANEL_ENTRY('I', 'V', 'O', 0x854b, &delay_200_500_p2e100, "M133NW4J-R3"),
1894 EDP_PANEL_ENTRY('K', 'D', 'B', 0x0624, &kingdisplay_kd116n21_30nv_a010.delay, "116N21-30NV-A010"),
1895 EDP_PANEL_ENTRY('K', 'D', 'B', 0x1120, &delay_200_500_e80_d50, "116N29-30NK-C007"),
1901 EDP_PANEL_ENTRY('S', 'T', 'A', 0x0100, &delay_100_500_e200, "2081116HHD028001-51D"),
1913 for (panel = edp_panels; panel->panel_id; panel++) in find_edp_panel()
1914 if (panel->panel_id == panel_id) in find_edp_panel()
1924 /* Skip one since "edp-panel" is only supported on DP AUX bus */ in panel_edp_platform_probe()
1925 id = of_match_node(platform_of_match + 1, pdev->dev.of_node); in panel_edp_platform_probe()
1927 return -ENODEV; in panel_edp_platform_probe()
1929 return panel_edp_probe(&pdev->dev, id->data, NULL); in panel_edp_platform_probe()
1934 return panel_edp_remove(&pdev->dev); in panel_edp_platform_remove()
1939 panel_edp_shutdown(&pdev->dev); in panel_edp_platform_shutdown()
1950 .name = "panel-edp",
1963 id = of_match_node(platform_of_match, aux_ep->dev.of_node); in panel_edp_dp_aux_ep_probe()
1965 return -ENODEV; in panel_edp_dp_aux_ep_probe()
1967 return panel_edp_probe(&aux_ep->dev, id->data, aux_ep->aux); in panel_edp_dp_aux_ep_probe()
1972 panel_edp_remove(&aux_ep->dev); in panel_edp_dp_aux_ep_remove()
1977 panel_edp_shutdown(&aux_ep->dev); in panel_edp_dp_aux_ep_shutdown()
1982 .name = "panel-simple-dp-aux",