Lines Matching +full:edp +full:- +full:panel
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
32 MODULE_PARM_DESC(psr_enabled, "enable PSR for eDP and DP displays");
91 struct msm_dp_panel *panel; member
173 { .compatible = "qcom,sa8775p-dp", .data = &msm_dp_desc_sa8775p },
174 { .compatible = "qcom,sc7180-dp", .data = &msm_dp_desc_sc7180 },
175 { .compatible = "qcom,sc7280-dp", .data = &msm_dp_desc_sc7280 },
176 { .compatible = "qcom,sc7280-edp", .data = &msm_dp_desc_sc7280 },
177 { .compatible = "qcom,sc8180x-dp", .data = &msm_dp_desc_sc8180x },
178 { .compatible = "qcom,sc8180x-edp", .data = &msm_dp_desc_sc8180x },
179 { .compatible = "qcom,sc8280xp-dp", .data = &msm_dp_desc_sc8280xp },
180 { .compatible = "qcom,sc8280xp-edp", .data = &msm_dp_desc_sc8280xp },
181 { .compatible = "qcom,sdm845-dp", .data = &msm_dp_desc_sc7180 },
182 { .compatible = "qcom,sm8350-dp", .data = &msm_dp_desc_sc7180 },
183 { .compatible = "qcom,sm8650-dp", .data = &msm_dp_desc_sm8650 },
184 { .compatible = "qcom,x1e80100-dp", .data = &msm_dp_desc_x1e80100 },
202 spin_lock_irqsave(&msm_dp_priv->event_lock, flag); in msm_dp_add_event()
203 pndx = msm_dp_priv->event_pndx + 1; in msm_dp_add_event()
205 if (pndx == msm_dp_priv->event_gndx) { in msm_dp_add_event()
207 msm_dp_priv->event_pndx, msm_dp_priv->event_gndx); in msm_dp_add_event()
208 spin_unlock_irqrestore(&msm_dp_priv->event_lock, flag); in msm_dp_add_event()
209 return -EPERM; in msm_dp_add_event()
211 todo = &msm_dp_priv->event_list[msm_dp_priv->event_pndx++]; in msm_dp_add_event()
212 msm_dp_priv->event_pndx %= DP_EVENT_Q_MAX; in msm_dp_add_event()
213 todo->event_id = event; in msm_dp_add_event()
214 todo->data = data; in msm_dp_add_event()
215 todo->delay = delay; in msm_dp_add_event()
216 wake_up(&msm_dp_priv->event_q); in msm_dp_add_event()
217 spin_unlock_irqrestore(&msm_dp_priv->event_lock, flag); in msm_dp_add_event()
228 spin_lock_irqsave(&msm_dp_priv->event_lock, flag); in msm_dp_del_event()
229 if (msm_dp_priv->event_pndx == msm_dp_priv->event_gndx) { in msm_dp_del_event()
230 spin_unlock_irqrestore(&msm_dp_priv->event_lock, flag); in msm_dp_del_event()
231 return -ENOENT; in msm_dp_del_event()
234 gndx = msm_dp_priv->event_gndx; in msm_dp_del_event()
235 while (msm_dp_priv->event_pndx != gndx) { in msm_dp_del_event()
236 todo = &msm_dp_priv->event_list[gndx]; in msm_dp_del_event()
237 if (todo->event_id == event) { in msm_dp_del_event()
238 todo->event_id = EV_NO_EVENT; /* deleted */ in msm_dp_del_event()
239 todo->delay = 0; in msm_dp_del_event()
244 spin_unlock_irqrestore(&msm_dp_priv->event_lock, flag); in msm_dp_del_event()
255 reinit_completion(&dp->audio_comp); in msm_dp_display_signal_audio_start()
264 complete_all(&dp->audio_comp); in msm_dp_display_signal_audio_complete()
275 struct drm_device *drm = priv->dev; in msm_dp_display_bind()
277 dp->msm_dp_display.drm_dev = drm; in msm_dp_display_bind()
278 priv->dp[dp->id] = &dp->msm_dp_display; in msm_dp_display_bind()
282 dp->drm_dev = drm; in msm_dp_display_bind()
283 dp->aux->drm_dev = drm; in msm_dp_display_bind()
284 rc = msm_dp_aux_register(dp->aux); in msm_dp_display_bind()
291 rc = msm_dp_register_audio_driver(dev, dp->audio); in msm_dp_display_bind()
314 kthread_stop(dp->ev_tsk); in msm_dp_display_unbind()
316 of_dp_aux_depopulate_bus(dp->aux); in msm_dp_display_unbind()
318 msm_dp_unregister_audio_driver(dev, dp->audio); in msm_dp_display_unbind()
319 msm_dp_aux_unregister(dp->aux); in msm_dp_display_unbind()
320 dp->drm_dev = NULL; in msm_dp_display_unbind()
321 dp->aux->drm_dev = NULL; in msm_dp_display_unbind()
322 priv->dp[dp->id] = NULL; in msm_dp_display_unbind()
337 connector = dp->msm_dp_display.connector; in msm_dp_display_send_hpd_event()
338 drm_helper_hpd_irq_event(connector->dev); in msm_dp_display_send_hpd_event()
344 if ((hpd && dp->msm_dp_display.link_ready) || in msm_dp_display_send_hpd_notification()
345 (!hpd && !dp->msm_dp_display.link_ready)) { in msm_dp_display_send_hpd_notification()
346 drm_dbg_dp(dp->drm_dev, "HPD already %s\n", in msm_dp_display_send_hpd_notification()
353 dp->panel->video_test = false; in msm_dp_display_send_hpd_notification()
354 if (!dp->msm_dp_display.is_edp) in msm_dp_display_send_hpd_notification()
355 drm_dp_set_subconnector_property(dp->msm_dp_display.connector, in msm_dp_display_send_hpd_notification()
357 dp->panel->dpcd, in msm_dp_display_send_hpd_notification()
358 dp->panel->downstream_ports); in msm_dp_display_send_hpd_notification()
361 dp->msm_dp_display.link_ready = hpd; in msm_dp_display_send_hpd_notification()
363 drm_dbg_dp(dp->drm_dev, "type=%d hpd=%d\n", in msm_dp_display_send_hpd_notification()
364 dp->msm_dp_display.connector_type, hpd); in msm_dp_display_send_hpd_notification()
365 msm_dp_display_send_hpd_event(&dp->msm_dp_display); in msm_dp_display_send_hpd_notification()
372 struct drm_connector *connector = dp->msm_dp_display.connector; in msm_dp_display_process_hpd_high()
373 const struct drm_display_info *info = &connector->display_info; in msm_dp_display_process_hpd_high()
376 rc = msm_dp_panel_read_sink_caps(dp->panel, connector); in msm_dp_display_process_hpd_high()
380 msm_dp_link_process_request(dp->link); in msm_dp_display_process_hpd_high()
382 if (!dp->msm_dp_display.is_edp) in msm_dp_display_process_hpd_high()
385 dp->panel->dpcd, in msm_dp_display_process_hpd_high()
386 dp->panel->downstream_ports); in msm_dp_display_process_hpd_high()
388 dp->msm_dp_display.psr_supported = dp->panel->psr_cap.version && psr_enabled; in msm_dp_display_process_hpd_high()
390 dp->audio_supported = info->has_audio; in msm_dp_display_process_hpd_high()
391 msm_dp_panel_handle_sink_request(dp->panel); in msm_dp_display_process_hpd_high()
394 * set sink to normal operation mode -- D0 in msm_dp_display_process_hpd_high()
397 msm_dp_link_psm_config(dp->link, &dp->panel->link_info, false); in msm_dp_display_process_hpd_high()
399 msm_dp_link_reset_phy_params_vx_px(dp->link); in msm_dp_display_process_hpd_high()
400 rc = msm_dp_ctrl_on_link(dp->ctrl); in msm_dp_display_process_hpd_high()
414 drm_dbg_dp(dp->drm_dev, "type=%d core_init=%d phy_init=%d\n", in msm_dp_display_host_phy_init()
415 dp->msm_dp_display.connector_type, dp->core_initialized, in msm_dp_display_host_phy_init()
416 dp->phy_initialized); in msm_dp_display_host_phy_init()
418 if (!dp->phy_initialized) { in msm_dp_display_host_phy_init()
419 msm_dp_ctrl_phy_init(dp->ctrl); in msm_dp_display_host_phy_init()
420 dp->phy_initialized = true; in msm_dp_display_host_phy_init()
426 drm_dbg_dp(dp->drm_dev, "type=%d core_init=%d phy_init=%d\n", in msm_dp_display_host_phy_exit()
427 dp->msm_dp_display.connector_type, dp->core_initialized, in msm_dp_display_host_phy_exit()
428 dp->phy_initialized); in msm_dp_display_host_phy_exit()
430 if (dp->phy_initialized) { in msm_dp_display_host_phy_exit()
431 msm_dp_ctrl_phy_exit(dp->ctrl); in msm_dp_display_host_phy_exit()
432 dp->phy_initialized = false; in msm_dp_display_host_phy_exit()
438 drm_dbg_dp(dp->drm_dev, "type=%d core_init=%d phy_init=%d\n", in msm_dp_display_host_init()
439 dp->msm_dp_display.connector_type, dp->core_initialized, in msm_dp_display_host_init()
440 dp->phy_initialized); in msm_dp_display_host_init()
442 msm_dp_ctrl_core_clk_enable(dp->ctrl); in msm_dp_display_host_init()
443 msm_dp_ctrl_reset_irq_ctrl(dp->ctrl, true); in msm_dp_display_host_init()
444 msm_dp_aux_init(dp->aux); in msm_dp_display_host_init()
445 dp->core_initialized = true; in msm_dp_display_host_init()
450 drm_dbg_dp(dp->drm_dev, "type=%d core_init=%d phy_init=%d\n", in msm_dp_display_host_deinit()
451 dp->msm_dp_display.connector_type, dp->core_initialized, in msm_dp_display_host_deinit()
452 dp->phy_initialized); in msm_dp_display_host_deinit()
454 msm_dp_ctrl_reset_irq_ctrl(dp->ctrl, false); in msm_dp_display_host_deinit()
455 msm_dp_aux_deinit(dp->aux); in msm_dp_display_host_deinit()
456 msm_dp_ctrl_core_clk_disable(dp->ctrl); in msm_dp_display_host_deinit()
457 dp->core_initialized = false; in msm_dp_display_host_deinit()
480 if (dp->link->sink_request & DP_TEST_LINK_VIDEO_PATTERN) { in msm_dp_display_handle_video_request()
481 dp->panel->video_test = true; in msm_dp_display_handle_video_request()
482 msm_dp_link_send_test_response(dp->link); in msm_dp_display_handle_video_request()
490 if (drm_dp_is_branch(dp->panel->dpcd) && dp->link->sink_count == 0) { in msm_dp_display_handle_port_status_changed()
491 drm_dbg_dp(dp->drm_dev, "sink count is zero, nothing to do\n"); in msm_dp_display_handle_port_status_changed()
492 if (dp->hpd_state != ST_DISCONNECTED) { in msm_dp_display_handle_port_status_changed()
493 dp->hpd_state = ST_DISCONNECT_PENDING; in msm_dp_display_handle_port_status_changed()
497 if (dp->hpd_state == ST_DISCONNECTED) { in msm_dp_display_handle_port_status_changed()
498 dp->hpd_state = ST_MAINLINK_READY; in msm_dp_display_handle_port_status_changed()
501 dp->hpd_state = ST_DISCONNECTED; in msm_dp_display_handle_port_status_changed()
510 u32 sink_request = dp->link->sink_request; in msm_dp_display_handle_irq_hpd()
512 drm_dbg_dp(dp->drm_dev, "%d\n", sink_request); in msm_dp_display_handle_irq_hpd()
513 if (dp->hpd_state == ST_DISCONNECTED) { in msm_dp_display_handle_irq_hpd()
515 drm_dbg_dp(dp->drm_dev, "Disconnected sink_request: %d\n", in msm_dp_display_handle_irq_hpd()
518 return -EINVAL; in msm_dp_display_handle_irq_hpd()
522 msm_dp_ctrl_handle_sink_request(dp->ctrl); in msm_dp_display_handle_irq_hpd()
537 rc = msm_dp_link_process_request(dp->link); in msm_dp_display_usbpd_attention_cb()
539 sink_request = dp->link->sink_request; in msm_dp_display_usbpd_attention_cb()
540 drm_dbg_dp(dp->drm_dev, "hpd_state=%d sink_request=%d\n", in msm_dp_display_usbpd_attention_cb()
541 dp->hpd_state, sink_request); in msm_dp_display_usbpd_attention_cb()
555 struct platform_device *pdev = dp->msm_dp_display.pdev; in msm_dp_hpd_plug_handle()
557 msm_dp_aux_enable_xfers(dp->aux, true); in msm_dp_hpd_plug_handle()
559 mutex_lock(&dp->event_mutex); in msm_dp_hpd_plug_handle()
561 state = dp->hpd_state; in msm_dp_hpd_plug_handle()
562 drm_dbg_dp(dp->drm_dev, "Before, type=%d hpd_state=%d\n", in msm_dp_hpd_plug_handle()
563 dp->msm_dp_display.connector_type, state); in msm_dp_hpd_plug_handle()
566 mutex_unlock(&dp->event_mutex); in msm_dp_hpd_plug_handle()
571 mutex_unlock(&dp->event_mutex); in msm_dp_hpd_plug_handle()
578 mutex_unlock(&dp->event_mutex); in msm_dp_hpd_plug_handle()
582 ret = pm_runtime_resume_and_get(&pdev->dev); in msm_dp_hpd_plug_handle()
585 mutex_unlock(&dp->event_mutex); in msm_dp_hpd_plug_handle()
589 ret = msm_dp_display_usbpd_configure_cb(&pdev->dev); in msm_dp_hpd_plug_handle()
591 dp->hpd_state = ST_DISCONNECTED; in msm_dp_hpd_plug_handle()
592 pm_runtime_put_sync(&pdev->dev); in msm_dp_hpd_plug_handle()
594 dp->hpd_state = ST_MAINLINK_READY; in msm_dp_hpd_plug_handle()
597 drm_dbg_dp(dp->drm_dev, "After, type=%d hpd_state=%d\n", in msm_dp_hpd_plug_handle()
598 dp->msm_dp_display.connector_type, state); in msm_dp_hpd_plug_handle()
599 mutex_unlock(&dp->event_mutex); in msm_dp_hpd_plug_handle()
614 if (msm_dp_display->plugged_cb && msm_dp_display->codec_dev && in msm_dp_display_handle_plugged_change()
615 dp->audio_supported) in msm_dp_display_handle_plugged_change()
616 msm_dp_display->plugged_cb(msm_dp_display->codec_dev, plugged); in msm_dp_display_handle_plugged_change()
622 struct platform_device *pdev = dp->msm_dp_display.pdev; in msm_dp_hpd_unplug_handle()
624 msm_dp_aux_enable_xfers(dp->aux, false); in msm_dp_hpd_unplug_handle()
626 mutex_lock(&dp->event_mutex); in msm_dp_hpd_unplug_handle()
628 state = dp->hpd_state; in msm_dp_hpd_unplug_handle()
630 drm_dbg_dp(dp->drm_dev, "Before, type=%d hpd_state=%d\n", in msm_dp_hpd_unplug_handle()
631 dp->msm_dp_display.connector_type, state); in msm_dp_hpd_unplug_handle()
638 if (dp->link->sink_count == 0) { in msm_dp_hpd_unplug_handle()
641 msm_dp_display_notify_disconnect(&dp->msm_dp_display.pdev->dev); in msm_dp_hpd_unplug_handle()
642 mutex_unlock(&dp->event_mutex); in msm_dp_hpd_unplug_handle()
645 mutex_unlock(&dp->event_mutex); in msm_dp_hpd_unplug_handle()
648 msm_dp_ctrl_off_link(dp->ctrl); in msm_dp_hpd_unplug_handle()
650 dp->hpd_state = ST_DISCONNECTED; in msm_dp_hpd_unplug_handle()
651 msm_dp_display_notify_disconnect(&dp->msm_dp_display.pdev->dev); in msm_dp_hpd_unplug_handle()
652 pm_runtime_put_sync(&pdev->dev); in msm_dp_hpd_unplug_handle()
653 mutex_unlock(&dp->event_mutex); in msm_dp_hpd_unplug_handle()
661 msm_dp_display_notify_disconnect(&dp->msm_dp_display.pdev->dev); in msm_dp_hpd_unplug_handle()
664 dp->hpd_state = ST_DISCONNECTED; in msm_dp_hpd_unplug_handle()
666 dp->hpd_state = ST_DISCONNECT_PENDING; in msm_dp_hpd_unplug_handle()
670 msm_dp_display_handle_plugged_change(&dp->msm_dp_display, false); in msm_dp_hpd_unplug_handle()
672 drm_dbg_dp(dp->drm_dev, "After, type=%d hpd_state=%d\n", in msm_dp_hpd_unplug_handle()
673 dp->msm_dp_display.connector_type, state); in msm_dp_hpd_unplug_handle()
676 pm_runtime_put_sync(&pdev->dev); in msm_dp_hpd_unplug_handle()
677 mutex_unlock(&dp->event_mutex); in msm_dp_hpd_unplug_handle()
685 mutex_lock(&dp->event_mutex); in msm_dp_irq_hpd_handle()
688 state = dp->hpd_state; in msm_dp_irq_hpd_handle()
689 drm_dbg_dp(dp->drm_dev, "Before, type=%d hpd_state=%d\n", in msm_dp_irq_hpd_handle()
690 dp->msm_dp_display.connector_type, state); in msm_dp_irq_hpd_handle()
693 mutex_unlock(&dp->event_mutex); in msm_dp_irq_hpd_handle()
700 mutex_unlock(&dp->event_mutex); in msm_dp_irq_hpd_handle()
704 msm_dp_display_usbpd_attention_cb(&dp->msm_dp_display.pdev->dev); in msm_dp_irq_hpd_handle()
706 drm_dbg_dp(dp->drm_dev, "After, type=%d hpd_state=%d\n", in msm_dp_irq_hpd_handle()
707 dp->msm_dp_display.connector_type, state); in msm_dp_irq_hpd_handle()
709 mutex_unlock(&dp->event_mutex); in msm_dp_irq_hpd_handle()
716 msm_dp_audio_put(dp->audio); in msm_dp_display_deinit_sub_modules()
717 msm_dp_panel_put(dp->panel); in msm_dp_display_deinit_sub_modules()
718 msm_dp_aux_put(dp->aux); in msm_dp_display_deinit_sub_modules()
724 struct device *dev = &dp->msm_dp_display.pdev->dev; in msm_dp_init_sub_modules()
732 dp->msm_dp_display.is_edp ? PHY_SUBMODE_EDP : PHY_SUBMODE_DP); in msm_dp_init_sub_modules()
735 dp->catalog = NULL; in msm_dp_init_sub_modules()
739 dp->catalog = msm_dp_catalog_get(dev); in msm_dp_init_sub_modules()
740 if (IS_ERR(dp->catalog)) { in msm_dp_init_sub_modules()
741 rc = PTR_ERR(dp->catalog); in msm_dp_init_sub_modules()
743 dp->catalog = NULL; in msm_dp_init_sub_modules()
747 dp->aux = msm_dp_aux_get(dev, dp->catalog, in msm_dp_init_sub_modules()
749 dp->msm_dp_display.is_edp); in msm_dp_init_sub_modules()
750 if (IS_ERR(dp->aux)) { in msm_dp_init_sub_modules()
751 rc = PTR_ERR(dp->aux); in msm_dp_init_sub_modules()
753 dp->aux = NULL; in msm_dp_init_sub_modules()
757 dp->link = msm_dp_link_get(dev, dp->aux); in msm_dp_init_sub_modules()
758 if (IS_ERR(dp->link)) { in msm_dp_init_sub_modules()
759 rc = PTR_ERR(dp->link); in msm_dp_init_sub_modules()
761 dp->link = NULL; in msm_dp_init_sub_modules()
765 dp->panel = msm_dp_panel_get(dev, dp->aux, dp->link, dp->catalog); in msm_dp_init_sub_modules()
766 if (IS_ERR(dp->panel)) { in msm_dp_init_sub_modules()
767 rc = PTR_ERR(dp->panel); in msm_dp_init_sub_modules()
768 DRM_ERROR("failed to initialize panel, rc = %d\n", rc); in msm_dp_init_sub_modules()
769 dp->panel = NULL; in msm_dp_init_sub_modules()
773 dp->ctrl = msm_dp_ctrl_get(dev, dp->link, dp->panel, dp->aux, in msm_dp_init_sub_modules()
774 dp->catalog, in msm_dp_init_sub_modules()
776 if (IS_ERR(dp->ctrl)) { in msm_dp_init_sub_modules()
777 rc = PTR_ERR(dp->ctrl); in msm_dp_init_sub_modules()
779 dp->ctrl = NULL; in msm_dp_init_sub_modules()
783 dp->audio = msm_dp_audio_get(dp->msm_dp_display.pdev, dp->catalog); in msm_dp_init_sub_modules()
784 if (IS_ERR(dp->audio)) { in msm_dp_init_sub_modules()
785 rc = PTR_ERR(dp->audio); in msm_dp_init_sub_modules()
787 dp->audio = NULL; in msm_dp_init_sub_modules()
794 msm_dp_panel_put(dp->panel); in msm_dp_init_sub_modules()
796 msm_dp_aux_put(dp->aux); in msm_dp_init_sub_modules()
808 drm_mode_copy(&dp->panel->msm_dp_mode.drm_mode, &mode->drm_mode); in msm_dp_display_set_mode()
809 dp->panel->msm_dp_mode.bpp = mode->bpp; in msm_dp_display_set_mode()
810 dp->panel->msm_dp_mode.out_fmt_is_yuv_420 = mode->out_fmt_is_yuv_420; in msm_dp_display_set_mode()
811 msm_dp_panel_init_panel_info(dp->panel); in msm_dp_display_set_mode()
818 struct msm_dp *msm_dp_display = &dp->msm_dp_display; in msm_dp_display_enable()
820 drm_dbg_dp(dp->drm_dev, "sink_count=%d\n", dp->link->sink_count); in msm_dp_display_enable()
821 if (msm_dp_display->power_on) { in msm_dp_display_enable()
822 drm_dbg_dp(dp->drm_dev, "Link already setup, return\n"); in msm_dp_display_enable()
826 rc = msm_dp_ctrl_on_stream(dp->ctrl, force_link_train); in msm_dp_display_enable()
828 msm_dp_display->power_on = true; in msm_dp_display_enable()
840 rate = dp->link->link_params.rate; in msm_dp_display_post_enable()
842 if (dp->audio_supported) { in msm_dp_display_post_enable()
843 dp->audio->bw_code = drm_dp_link_rate_to_bw_code(rate); in msm_dp_display_post_enable()
844 dp->audio->lane_count = dp->link->link_params.num_lanes; in msm_dp_display_post_enable()
850 if (msm_dp_display->psr_supported) in msm_dp_display_post_enable()
851 msm_dp_ctrl_config_psr(dp->ctrl); in msm_dp_display_post_enable()
858 struct msm_dp *msm_dp_display = &dp->msm_dp_display; in msm_dp_display_disable()
860 if (!msm_dp_display->power_on) in msm_dp_display_disable()
864 if (msm_dp_display->audio_enabled) { in msm_dp_display_disable()
867 if (!wait_for_completion_timeout(&dp->audio_comp, in msm_dp_display_disable()
872 msm_dp_display->audio_enabled = false; in msm_dp_display_disable()
874 if (dp->link->sink_count == 0) { in msm_dp_display_disable()
879 msm_dp_ctrl_off_link_stream(dp->ctrl); in msm_dp_display_disable()
885 msm_dp_ctrl_off(dp->ctrl); in msm_dp_display_disable()
889 msm_dp_display->power_on = false; in msm_dp_display_disable()
891 drm_dbg_dp(dp->drm_dev, "sink count: %d\n", dp->link->sink_count); in msm_dp_display_disable()
900 msm_dp_display->plugged_cb = fn; in msm_dp_display_set_plugged_cb()
901 msm_dp_display->codec_dev = codec_dev; in msm_dp_display_set_plugged_cb()
902 plugged = msm_dp_display->link_ready; in msm_dp_display_set_plugged_cb()
909 * msm_dp_bridge_mode_valid - callback to determine if specified mode is valid
924 int mode_pclk_khz = mode->clock; in msm_dp_bridge_mode_valid()
926 dp = to_dp_bridge(bridge)->msm_dp_display; in msm_dp_bridge_mode_valid()
928 if (!dp || !mode_pclk_khz || !dp->connector) { in msm_dp_bridge_mode_valid()
930 return -EINVAL; in msm_dp_bridge_mode_valid()
934 link_info = &msm_dp_display->panel->link_info; in msm_dp_bridge_mode_valid()
936 if ((drm_mode_is_420_only(&dp->connector->display_info, mode) && in msm_dp_bridge_mode_valid()
937 msm_dp_display->panel->vsc_sdp_supported) || in msm_dp_bridge_mode_valid()
944 mode_bpp = dp->connector->display_info.bpc * num_components; in msm_dp_bridge_mode_valid()
948 mode_bpp = msm_dp_panel_get_mode_bpp(msm_dp_display->panel, in msm_dp_bridge_mode_valid()
952 supported_rate_khz = link_info->num_lanes * link_info->rate * 8; in msm_dp_bridge_mode_valid()
971 return msm_dp_panel_get_modes(msm_dp_display->panel, in msm_dp_display_get_modes()
972 dp->connector); in msm_dp_display_get_modes()
981 return msm_dp_display->panel->video_test; in msm_dp_display_check_video_test()
996 msm_dp_display->link->test_video.test_bit_depth); in msm_dp_display_get_test_bpp()
1012 mutex_lock(&msm_dp_display->event_mutex); in msm_dp_snapshot()
1014 if (!dp->power_on) { in msm_dp_snapshot()
1015 mutex_unlock(&msm_dp_display->event_mutex); in msm_dp_snapshot()
1019 msm_dp_catalog_snapshot(msm_dp_display->catalog, disp_state); in msm_dp_snapshot()
1021 mutex_unlock(&msm_dp_display->event_mutex); in msm_dp_snapshot()
1034 msm_dp_ctrl_set_psr(dp->ctrl, enter); in msm_dp_display_set_psr()
1048 wait_event_timeout(msm_dp_priv->event_q, in hpd_event_thread()
1049 (msm_dp_priv->event_pndx == msm_dp_priv->event_gndx) || in hpd_event_thread()
1052 wait_event_interruptible(msm_dp_priv->event_q, in hpd_event_thread()
1053 (msm_dp_priv->event_pndx != msm_dp_priv->event_gndx) || in hpd_event_thread()
1060 spin_lock_irqsave(&msm_dp_priv->event_lock, flag); in hpd_event_thread()
1061 todo = &msm_dp_priv->event_list[msm_dp_priv->event_gndx]; in hpd_event_thread()
1062 if (todo->delay) { in hpd_event_thread()
1065 msm_dp_priv->event_gndx++; in hpd_event_thread()
1066 msm_dp_priv->event_gndx %= DP_EVENT_Q_MAX; in hpd_event_thread()
1069 todo_next = &msm_dp_priv->event_list[msm_dp_priv->event_pndx++]; in hpd_event_thread()
1070 msm_dp_priv->event_pndx %= DP_EVENT_Q_MAX; in hpd_event_thread()
1071 todo_next->event_id = todo->event_id; in hpd_event_thread()
1072 todo_next->data = todo->data; in hpd_event_thread()
1073 todo_next->delay = todo->delay - 1; in hpd_event_thread()
1076 todo->event_id = EV_NO_EVENT; in hpd_event_thread()
1077 todo->delay = 0; in hpd_event_thread()
1081 spin_unlock_irqrestore(&msm_dp_priv->event_lock, flag); in hpd_event_thread()
1086 if (msm_dp_priv->event_pndx == msm_dp_priv->event_gndx) { in hpd_event_thread()
1087 spin_unlock_irqrestore(&msm_dp_priv->event_lock, flag); in hpd_event_thread()
1091 msm_dp_priv->event_gndx++; in hpd_event_thread()
1092 msm_dp_priv->event_gndx %= DP_EVENT_Q_MAX; in hpd_event_thread()
1094 spin_unlock_irqrestore(&msm_dp_priv->event_lock, flag); in hpd_event_thread()
1096 switch (todo->event_id) { in hpd_event_thread()
1098 msm_dp_hpd_plug_handle(msm_dp_priv, todo->data); in hpd_event_thread()
1101 msm_dp_hpd_unplug_handle(msm_dp_priv, todo->data); in hpd_event_thread()
1104 msm_dp_irq_hpd_handle(msm_dp_priv, todo->data); in hpd_event_thread()
1108 todo->data); in hpd_event_thread()
1121 msm_dp_priv->event_gndx = 0; in msm_dp_hpd_event_thread_start()
1122 msm_dp_priv->event_pndx = 0; in msm_dp_hpd_event_thread_start()
1124 msm_dp_priv->ev_tsk = kthread_run(hpd_event_thread, msm_dp_priv, "dp_hpd_handler"); in msm_dp_hpd_event_thread_start()
1125 if (IS_ERR(msm_dp_priv->ev_tsk)) in msm_dp_hpd_event_thread_start()
1126 return PTR_ERR(msm_dp_priv->ev_tsk); in msm_dp_hpd_event_thread_start()
1142 hpd_isr_status = msm_dp_catalog_hpd_get_intr_status(dp->catalog); in msm_dp_display_irq_handler()
1145 drm_dbg_dp(dp->drm_dev, "type=%d isr=0x%x\n", in msm_dp_display_irq_handler()
1146 dp->msm_dp_display.connector_type, hpd_isr_status); in msm_dp_display_irq_handler()
1167 ret |= msm_dp_ctrl_isr(dp->ctrl); in msm_dp_display_irq_handler()
1170 ret |= msm_dp_aux_isr(dp->aux); in msm_dp_display_irq_handler()
1178 struct platform_device *pdev = dp->msm_dp_display.pdev; in msm_dp_display_request_irq()
1180 dp->irq = platform_get_irq(pdev, 0); in msm_dp_display_request_irq()
1181 if (dp->irq < 0) { in msm_dp_display_request_irq()
1183 return dp->irq; in msm_dp_display_request_irq()
1186 rc = devm_request_irq(&pdev->dev, dp->irq, msm_dp_display_irq_handler, in msm_dp_display_request_irq()
1192 dp->irq, rc); in msm_dp_display_request_irq()
1201 const struct msm_dp_desc *descs = of_device_get_match_data(&pdev->dev); in msm_dp_display_get_desc()
1210 if (descs[i].io_start == res->start) in msm_dp_display_get_desc()
1214 dev_err(&pdev->dev, "unknown displayport instance\n"); in msm_dp_display_get_desc()
1224 * External bridges are mandatory for eDP interfaces: one has to in msm_dp_display_probe_tail()
1225 * provide at least an eDP panel (which gets wrapped into panel-bridge). in msm_dp_display_probe_tail()
1228 * silently ignore an error if one is not present (-ENODEV). in msm_dp_display_probe_tail()
1230 dp->next_bridge = devm_drm_of_get_bridge(&dp->pdev->dev, dp->pdev->dev.of_node, 1, 0); in msm_dp_display_probe_tail()
1231 if (IS_ERR(dp->next_bridge)) { in msm_dp_display_probe_tail()
1232 ret = PTR_ERR(dp->next_bridge); in msm_dp_display_probe_tail()
1233 dp->next_bridge = NULL; in msm_dp_display_probe_tail()
1234 if (dp->is_edp || ret != -ENODEV) in msm_dp_display_probe_tail()
1247 return msm_dp_display_probe_tail(aux->dev); in msm_dp_auxbus_done_probe()
1253 struct device_node *node = pdev->dev.of_node; in msm_dp_display_get_connector_type()
1254 struct device_node *aux_bus = of_get_child_by_name(node, "aux-bus"); in msm_dp_display_get_connector_type()
1255 struct device_node *panel = of_get_child_by_name(aux_bus, "panel"); in msm_dp_display_get_connector_type() local
1258 if (panel) in msm_dp_display_get_connector_type()
1263 of_node_put(panel); in msm_dp_display_get_connector_type()
1275 if (!pdev || !pdev->dev.of_node) { in msm_dp_display_probe()
1277 return -ENODEV; in msm_dp_display_probe()
1280 dp = devm_kzalloc(&pdev->dev, sizeof(*dp), GFP_KERNEL); in msm_dp_display_probe()
1282 return -ENOMEM; in msm_dp_display_probe()
1286 return -EINVAL; in msm_dp_display_probe()
1288 dp->msm_dp_display.pdev = pdev; in msm_dp_display_probe()
1289 dp->id = desc->id; in msm_dp_display_probe()
1290 dp->msm_dp_display.connector_type = msm_dp_display_get_connector_type(pdev, desc); in msm_dp_display_probe()
1291 dp->wide_bus_supported = desc->wide_bus_supported; in msm_dp_display_probe()
1292 dp->msm_dp_display.is_edp = in msm_dp_display_probe()
1293 (dp->msm_dp_display.connector_type == DRM_MODE_CONNECTOR_eDP); in msm_dp_display_probe()
1298 return -EPROBE_DEFER; in msm_dp_display_probe()
1302 mutex_init(&dp->event_mutex); in msm_dp_display_probe()
1303 init_waitqueue_head(&dp->event_q); in msm_dp_display_probe()
1304 spin_lock_init(&dp->event_lock); in msm_dp_display_probe()
1307 dp->msm_dp_display.msm_dp_audio = dp->audio; in msm_dp_display_probe()
1309 init_completion(&dp->audio_comp); in msm_dp_display_probe()
1311 platform_set_drvdata(pdev, &dp->msm_dp_display); in msm_dp_display_probe()
1313 rc = devm_pm_runtime_enable(&pdev->dev); in msm_dp_display_probe()
1321 if (dp->msm_dp_display.is_edp) { in msm_dp_display_probe()
1322 rc = devm_of_dp_aux_populate_bus(dp->aux, msm_dp_auxbus_done_probe); in msm_dp_display_probe()
1324 DRM_ERROR("eDP auxbus population failed, rc=%d\n", rc); in msm_dp_display_probe()
1328 rc = msm_dp_display_probe_tail(&pdev->dev); in msm_dp_display_probe()
1342 struct msm_dp_display_private *dp = dev_get_dp_display_private(&pdev->dev); in msm_dp_display_remove()
1344 component_del(&pdev->dev, &msm_dp_display_comp_ops); in msm_dp_display_remove()
1353 disable_irq(dp->irq); in msm_dp_pm_runtime_suspend()
1355 if (dp->msm_dp_display.is_edp) { in msm_dp_pm_runtime_suspend()
1357 msm_dp_catalog_ctrl_hpd_disable(dp->catalog); in msm_dp_pm_runtime_suspend()
1369 * for eDP, host cotroller, HPD block and PHY are enabled here in msm_dp_pm_runtime_resume()
1377 if (dp->msm_dp_display.is_edp) { in msm_dp_pm_runtime_resume()
1378 msm_dp_catalog_ctrl_hpd_enable(dp->catalog); in msm_dp_pm_runtime_resume()
1382 enable_irq(dp->irq); in msm_dp_pm_runtime_resume()
1396 .name = "msm-dp-display",
1426 info = &msm_dp_display->connector->display_info; in msm_dp_is_yuv_420_enabled()
1428 return dp->panel->vsc_sdp_supported && drm_mode_is_420_only(info, mode); in msm_dp_is_yuv_420_enabled()
1443 if (dp->msm_dp_mode.out_fmt_is_yuv_420) in msm_dp_wide_bus_available()
1446 return dp->wide_bus_supported; in msm_dp_wide_bus_available()
1456 dev = &dp->msm_dp_display.pdev->dev; in msm_dp_display_debugfs_init()
1458 rc = msm_dp_debug_init(dev, dp->panel, dp->link, dp->msm_dp_display.connector, root, is_edp); in msm_dp_display_debugfs_init()
1469 msm_dp_display->drm_dev = dev; in msm_dp_modeset_init()
1475 DRM_DEV_ERROR(dev->dev, in msm_dp_modeset_init()
1480 msm_dp_display->connector = msm_dp_drm_connector_init(msm_dp_display, encoder); in msm_dp_modeset_init()
1481 if (IS_ERR(msm_dp_display->connector)) { in msm_dp_modeset_init()
1482 ret = PTR_ERR(msm_dp_display->connector); in msm_dp_modeset_init()
1483 DRM_DEV_ERROR(dev->dev, in msm_dp_modeset_init()
1485 msm_dp_display->connector = NULL; in msm_dp_modeset_init()
1489 msm_dp_priv->panel->connector = msm_dp_display->connector; in msm_dp_modeset_init()
1498 struct msm_dp *dp = msm_dp_bridge->msm_dp_display; in msm_dp_bridge_atomic_enable()
1505 if (!msm_dp_display->msm_dp_mode.drm_mode.clock) { in msm_dp_bridge_atomic_enable()
1510 if (dp->is_edp) in msm_dp_bridge_atomic_enable()
1513 mutex_lock(&msm_dp_display->event_mutex); in msm_dp_bridge_atomic_enable()
1514 if (pm_runtime_resume_and_get(&dp->pdev->dev)) { in msm_dp_bridge_atomic_enable()
1516 mutex_unlock(&msm_dp_display->event_mutex); in msm_dp_bridge_atomic_enable()
1520 state = msm_dp_display->hpd_state; in msm_dp_bridge_atomic_enable()
1522 mutex_unlock(&msm_dp_display->event_mutex); in msm_dp_bridge_atomic_enable()
1526 rc = msm_dp_display_set_mode(dp, &msm_dp_display->msm_dp_mode); in msm_dp_bridge_atomic_enable()
1529 mutex_unlock(&msm_dp_display->event_mutex); in msm_dp_bridge_atomic_enable()
1533 state = msm_dp_display->hpd_state; in msm_dp_bridge_atomic_enable()
1549 msm_dp_display->hpd_state = ST_CONNECTED; in msm_dp_bridge_atomic_enable()
1551 drm_dbg_dp(dp->drm_dev, "type=%d Done\n", dp->connector_type); in msm_dp_bridge_atomic_enable()
1552 mutex_unlock(&msm_dp_display->event_mutex); in msm_dp_bridge_atomic_enable()
1559 struct msm_dp *dp = msm_dp_bridge->msm_dp_display; in msm_dp_bridge_atomic_disable()
1564 msm_dp_ctrl_push_idle(msm_dp_display->ctrl); in msm_dp_bridge_atomic_disable()
1571 struct msm_dp *dp = msm_dp_bridge->msm_dp_display; in msm_dp_bridge_atomic_post_disable()
1577 if (dp->is_edp) in msm_dp_bridge_atomic_post_disable()
1580 mutex_lock(&msm_dp_display->event_mutex); in msm_dp_bridge_atomic_post_disable()
1582 state = msm_dp_display->hpd_state; in msm_dp_bridge_atomic_post_disable()
1584 drm_dbg_dp(dp->drm_dev, "type=%d wrong hpd_state=%d\n", in msm_dp_bridge_atomic_post_disable()
1585 dp->connector_type, state); in msm_dp_bridge_atomic_post_disable()
1589 state = msm_dp_display->hpd_state; in msm_dp_bridge_atomic_post_disable()
1592 msm_dp_display->hpd_state = ST_DISCONNECTED; in msm_dp_bridge_atomic_post_disable()
1594 msm_dp_display->hpd_state = ST_DISPLAY_OFF; in msm_dp_bridge_atomic_post_disable()
1597 drm_dbg_dp(dp->drm_dev, "type=%d Done\n", dp->connector_type); in msm_dp_bridge_atomic_post_disable()
1599 pm_runtime_put_sync(&dp->pdev->dev); in msm_dp_bridge_atomic_post_disable()
1600 mutex_unlock(&msm_dp_display->event_mutex); in msm_dp_bridge_atomic_post_disable()
1608 struct msm_dp *dp = msm_dp_bridge->msm_dp_display; in msm_dp_bridge_mode_set()
1613 msm_dp_panel = msm_dp_display->panel; in msm_dp_bridge_mode_set()
1615 memset(&msm_dp_display->msm_dp_mode, 0x0, sizeof(struct msm_dp_display_mode)); in msm_dp_bridge_mode_set()
1618 msm_dp_display->msm_dp_mode.bpp = msm_dp_display_get_test_bpp(dp); in msm_dp_bridge_mode_set()
1620 msm_dp_display->msm_dp_mode.bpp = dp->connector->display_info.bpc * 3; in msm_dp_bridge_mode_set()
1622 if (!msm_dp_display->msm_dp_mode.bpp) in msm_dp_bridge_mode_set()
1623 msm_dp_display->msm_dp_mode.bpp = 24; /* Default bpp */ in msm_dp_bridge_mode_set()
1625 drm_mode_copy(&msm_dp_display->msm_dp_mode.drm_mode, adjusted_mode); in msm_dp_bridge_mode_set()
1627 msm_dp_display->msm_dp_mode.v_active_low = in msm_dp_bridge_mode_set()
1628 !!(msm_dp_display->msm_dp_mode.drm_mode.flags & DRM_MODE_FLAG_NVSYNC); in msm_dp_bridge_mode_set()
1630 msm_dp_display->msm_dp_mode.h_active_low = in msm_dp_bridge_mode_set()
1631 !!(msm_dp_display->msm_dp_mode.drm_mode.flags & DRM_MODE_FLAG_NHSYNC); in msm_dp_bridge_mode_set()
1633 msm_dp_display->msm_dp_mode.out_fmt_is_yuv_420 = in msm_dp_bridge_mode_set()
1634 drm_mode_is_420_only(&dp->connector->display_info, adjusted_mode) && in msm_dp_bridge_mode_set()
1635 msm_dp_panel->vsc_sdp_supported; in msm_dp_bridge_mode_set()
1638 msm_dp_display->ctrl->wide_bus_en = in msm_dp_bridge_mode_set()
1639 msm_dp_display->msm_dp_mode.out_fmt_is_yuv_420 ? false : msm_dp_display->wide_bus_supported; in msm_dp_bridge_mode_set()
1640 msm_dp_display->catalog->wide_bus_en = in msm_dp_bridge_mode_set()
1641 msm_dp_display->msm_dp_mode.out_fmt_is_yuv_420 ? false : msm_dp_display->wide_bus_supported; in msm_dp_bridge_mode_set()
1647 struct msm_dp *msm_dp_display = msm_dp_bridge->msm_dp_display; in msm_dp_bridge_hpd_enable()
1652 * step-1: msm_dp_pm_runtime_resume() enable dp host only in msm_dp_bridge_hpd_enable()
1653 * step-2: enable hdp block and have hpd irq enabled here in msm_dp_bridge_hpd_enable()
1654 * step-3: waiting for plugin irq while phy is not initialized in msm_dp_bridge_hpd_enable()
1655 * step-4: DP PHY is initialized at plugin handler before link training in msm_dp_bridge_hpd_enable()
1658 mutex_lock(&dp->event_mutex); in msm_dp_bridge_hpd_enable()
1659 if (pm_runtime_resume_and_get(&msm_dp_display->pdev->dev)) { in msm_dp_bridge_hpd_enable()
1661 mutex_unlock(&dp->event_mutex); in msm_dp_bridge_hpd_enable()
1665 msm_dp_catalog_ctrl_hpd_enable(dp->catalog); in msm_dp_bridge_hpd_enable()
1668 msm_dp_catalog_hpd_config_intr(dp->catalog, DP_DP_HPD_INT_MASK, true); in msm_dp_bridge_hpd_enable()
1670 msm_dp_display->internal_hpd = true; in msm_dp_bridge_hpd_enable()
1671 mutex_unlock(&dp->event_mutex); in msm_dp_bridge_hpd_enable()
1677 struct msm_dp *msm_dp_display = msm_dp_bridge->msm_dp_display; in msm_dp_bridge_hpd_disable()
1680 mutex_lock(&dp->event_mutex); in msm_dp_bridge_hpd_disable()
1682 msm_dp_catalog_hpd_config_intr(dp->catalog, DP_DP_HPD_INT_MASK, false); in msm_dp_bridge_hpd_disable()
1683 msm_dp_catalog_ctrl_hpd_disable(dp->catalog); in msm_dp_bridge_hpd_disable()
1685 msm_dp_display->internal_hpd = false; in msm_dp_bridge_hpd_disable()
1687 pm_runtime_put_sync(&msm_dp_display->pdev->dev); in msm_dp_bridge_hpd_disable()
1688 mutex_unlock(&dp->event_mutex); in msm_dp_bridge_hpd_disable()
1695 struct msm_dp *msm_dp_display = msm_dp_bridge->msm_dp_display; in msm_dp_bridge_hpd_notify()
1699 if (msm_dp_display->internal_hpd) in msm_dp_bridge_hpd_notify()
1702 if (!msm_dp_display->link_ready && status == connector_status_connected) in msm_dp_bridge_hpd_notify()
1704 else if (msm_dp_display->link_ready && status == connector_status_disconnected) in msm_dp_bridge_hpd_notify()