Lines Matching +full:sc7280 +full:- +full:edp
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");
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()
735 dp->msm_dp_display.is_edp ? PHY_SUBMODE_EDP : PHY_SUBMODE_DP); in msm_dp_init_sub_modules()
738 dp->catalog = NULL; in msm_dp_init_sub_modules()
742 dp->catalog = msm_dp_catalog_get(dev); in msm_dp_init_sub_modules()
743 if (IS_ERR(dp->catalog)) { in msm_dp_init_sub_modules()
744 rc = PTR_ERR(dp->catalog); in msm_dp_init_sub_modules()
746 dp->catalog = NULL; in msm_dp_init_sub_modules()
750 dp->aux = msm_dp_aux_get(dev, dp->catalog, in msm_dp_init_sub_modules()
752 dp->msm_dp_display.is_edp); in msm_dp_init_sub_modules()
753 if (IS_ERR(dp->aux)) { in msm_dp_init_sub_modules()
754 rc = PTR_ERR(dp->aux); in msm_dp_init_sub_modules()
756 dp->aux = NULL; in msm_dp_init_sub_modules()
760 dp->link = msm_dp_link_get(dev, dp->aux); in msm_dp_init_sub_modules()
761 if (IS_ERR(dp->link)) { in msm_dp_init_sub_modules()
762 rc = PTR_ERR(dp->link); in msm_dp_init_sub_modules()
764 dp->link = NULL; in msm_dp_init_sub_modules()
768 panel_in.aux = dp->aux; in msm_dp_init_sub_modules()
769 panel_in.catalog = dp->catalog; in msm_dp_init_sub_modules()
770 panel_in.link = dp->link; in msm_dp_init_sub_modules()
772 dp->panel = msm_dp_panel_get(&panel_in); in msm_dp_init_sub_modules()
773 if (IS_ERR(dp->panel)) { in msm_dp_init_sub_modules()
774 rc = PTR_ERR(dp->panel); in msm_dp_init_sub_modules()
776 dp->panel = NULL; in msm_dp_init_sub_modules()
780 dp->ctrl = msm_dp_ctrl_get(dev, dp->link, dp->panel, dp->aux, in msm_dp_init_sub_modules()
781 dp->catalog, in msm_dp_init_sub_modules()
783 if (IS_ERR(dp->ctrl)) { in msm_dp_init_sub_modules()
784 rc = PTR_ERR(dp->ctrl); in msm_dp_init_sub_modules()
786 dp->ctrl = NULL; in msm_dp_init_sub_modules()
790 dp->audio = msm_dp_audio_get(dp->msm_dp_display.pdev, dp->panel, dp->catalog); in msm_dp_init_sub_modules()
791 if (IS_ERR(dp->audio)) { in msm_dp_init_sub_modules()
792 rc = PTR_ERR(dp->audio); in msm_dp_init_sub_modules()
794 dp->audio = NULL; in msm_dp_init_sub_modules()
801 msm_dp_panel_put(dp->panel); in msm_dp_init_sub_modules()
803 msm_dp_aux_put(dp->aux); in msm_dp_init_sub_modules()
815 drm_mode_copy(&dp->panel->msm_dp_mode.drm_mode, &mode->drm_mode); in msm_dp_display_set_mode()
816 dp->panel->msm_dp_mode.bpp = mode->bpp; in msm_dp_display_set_mode()
817 dp->panel->msm_dp_mode.out_fmt_is_yuv_420 = mode->out_fmt_is_yuv_420; in msm_dp_display_set_mode()
818 msm_dp_panel_init_panel_info(dp->panel); in msm_dp_display_set_mode()
825 struct msm_dp *msm_dp_display = &dp->msm_dp_display; in msm_dp_display_enable()
827 drm_dbg_dp(dp->drm_dev, "sink_count=%d\n", dp->link->sink_count); in msm_dp_display_enable()
828 if (msm_dp_display->power_on) { in msm_dp_display_enable()
829 drm_dbg_dp(dp->drm_dev, "Link already setup, return\n"); in msm_dp_display_enable()
833 rc = msm_dp_ctrl_on_stream(dp->ctrl, force_link_train); in msm_dp_display_enable()
835 msm_dp_display->power_on = true; in msm_dp_display_enable()
847 rate = dp->link->link_params.rate; in msm_dp_display_post_enable()
849 if (dp->audio_supported) { in msm_dp_display_post_enable()
850 dp->audio->bw_code = drm_dp_link_rate_to_bw_code(rate); in msm_dp_display_post_enable()
851 dp->audio->lane_count = dp->link->link_params.num_lanes; in msm_dp_display_post_enable()
857 if (msm_dp_display->psr_supported) in msm_dp_display_post_enable()
858 msm_dp_ctrl_config_psr(dp->ctrl); in msm_dp_display_post_enable()
865 struct msm_dp *msm_dp_display = &dp->msm_dp_display; in msm_dp_display_disable()
867 if (!msm_dp_display->power_on) in msm_dp_display_disable()
871 if (msm_dp_display->audio_enabled) { in msm_dp_display_disable()
874 if (!wait_for_completion_timeout(&dp->audio_comp, in msm_dp_display_disable()
879 msm_dp_display->audio_enabled = false; in msm_dp_display_disable()
881 if (dp->link->sink_count == 0) { in msm_dp_display_disable()
886 msm_dp_ctrl_off_link_stream(dp->ctrl); in msm_dp_display_disable()
892 msm_dp_ctrl_off(dp->ctrl); in msm_dp_display_disable()
896 msm_dp_display->power_on = false; in msm_dp_display_disable()
898 drm_dbg_dp(dp->drm_dev, "sink count: %d\n", dp->link->sink_count); in msm_dp_display_disable()
907 msm_dp_display->plugged_cb = fn; in msm_dp_display_set_plugged_cb()
908 msm_dp_display->codec_dev = codec_dev; in msm_dp_display_set_plugged_cb()
909 plugged = msm_dp_display->link_ready; in msm_dp_display_set_plugged_cb()
916 * msm_dp_bridge_mode_valid - callback to determine if specified mode is valid
931 int mode_pclk_khz = mode->clock; in msm_dp_bridge_mode_valid()
933 dp = to_dp_bridge(bridge)->msm_dp_display; in msm_dp_bridge_mode_valid()
935 if (!dp || !mode_pclk_khz || !dp->connector) { in msm_dp_bridge_mode_valid()
937 return -EINVAL; in msm_dp_bridge_mode_valid()
940 if (mode->clock > DP_MAX_PIXEL_CLK_KHZ) in msm_dp_bridge_mode_valid()
944 link_info = &msm_dp_display->panel->link_info; in msm_dp_bridge_mode_valid()
946 if (drm_mode_is_420_only(&dp->connector->display_info, mode) && in msm_dp_bridge_mode_valid()
947 msm_dp_display->panel->vsc_sdp_supported) in msm_dp_bridge_mode_valid()
950 mode_bpp = dp->connector->display_info.bpc * num_components; in msm_dp_bridge_mode_valid()
954 mode_bpp = msm_dp_panel_get_mode_bpp(msm_dp_display->panel, in msm_dp_bridge_mode_valid()
958 supported_rate_khz = link_info->num_lanes * link_info->rate * 8; in msm_dp_bridge_mode_valid()
977 return msm_dp_panel_get_modes(msm_dp_display->panel, in msm_dp_display_get_modes()
978 dp->connector); in msm_dp_display_get_modes()
987 return msm_dp_display->panel->video_test; in msm_dp_display_check_video_test()
1002 msm_dp_display->link->test_video.test_bit_depth); in msm_dp_display_get_test_bpp()
1018 mutex_lock(&msm_dp_display->event_mutex); in msm_dp_snapshot()
1020 if (!dp->power_on) { in msm_dp_snapshot()
1021 mutex_unlock(&msm_dp_display->event_mutex); in msm_dp_snapshot()
1025 msm_dp_catalog_snapshot(msm_dp_display->catalog, disp_state); in msm_dp_snapshot()
1027 mutex_unlock(&msm_dp_display->event_mutex); in msm_dp_snapshot()
1040 msm_dp_ctrl_set_psr(dp->ctrl, enter); in msm_dp_display_set_psr()
1054 wait_event_timeout(msm_dp_priv->event_q, in hpd_event_thread()
1055 (msm_dp_priv->event_pndx == msm_dp_priv->event_gndx) || in hpd_event_thread()
1058 wait_event_interruptible(msm_dp_priv->event_q, in hpd_event_thread()
1059 (msm_dp_priv->event_pndx != msm_dp_priv->event_gndx) || in hpd_event_thread()
1066 spin_lock_irqsave(&msm_dp_priv->event_lock, flag); in hpd_event_thread()
1067 todo = &msm_dp_priv->event_list[msm_dp_priv->event_gndx]; in hpd_event_thread()
1068 if (todo->delay) { in hpd_event_thread()
1071 msm_dp_priv->event_gndx++; in hpd_event_thread()
1072 msm_dp_priv->event_gndx %= DP_EVENT_Q_MAX; in hpd_event_thread()
1075 todo_next = &msm_dp_priv->event_list[msm_dp_priv->event_pndx++]; in hpd_event_thread()
1076 msm_dp_priv->event_pndx %= DP_EVENT_Q_MAX; in hpd_event_thread()
1077 todo_next->event_id = todo->event_id; in hpd_event_thread()
1078 todo_next->data = todo->data; in hpd_event_thread()
1079 todo_next->delay = todo->delay - 1; in hpd_event_thread()
1082 todo->event_id = EV_NO_EVENT; in hpd_event_thread()
1083 todo->delay = 0; in hpd_event_thread()
1087 spin_unlock_irqrestore(&msm_dp_priv->event_lock, flag); in hpd_event_thread()
1092 if (msm_dp_priv->event_pndx == msm_dp_priv->event_gndx) { in hpd_event_thread()
1093 spin_unlock_irqrestore(&msm_dp_priv->event_lock, flag); in hpd_event_thread()
1097 msm_dp_priv->event_gndx++; in hpd_event_thread()
1098 msm_dp_priv->event_gndx %= DP_EVENT_Q_MAX; in hpd_event_thread()
1100 spin_unlock_irqrestore(&msm_dp_priv->event_lock, flag); in hpd_event_thread()
1102 switch (todo->event_id) { in hpd_event_thread()
1104 msm_dp_hpd_plug_handle(msm_dp_priv, todo->data); in hpd_event_thread()
1107 msm_dp_hpd_unplug_handle(msm_dp_priv, todo->data); in hpd_event_thread()
1110 msm_dp_irq_hpd_handle(msm_dp_priv, todo->data); in hpd_event_thread()
1114 todo->data); in hpd_event_thread()
1127 msm_dp_priv->event_gndx = 0; in msm_dp_hpd_event_thread_start()
1128 msm_dp_priv->event_pndx = 0; in msm_dp_hpd_event_thread_start()
1130 msm_dp_priv->ev_tsk = kthread_run(hpd_event_thread, msm_dp_priv, "dp_hpd_handler"); in msm_dp_hpd_event_thread_start()
1131 if (IS_ERR(msm_dp_priv->ev_tsk)) in msm_dp_hpd_event_thread_start()
1132 return PTR_ERR(msm_dp_priv->ev_tsk); in msm_dp_hpd_event_thread_start()
1148 hpd_isr_status = msm_dp_catalog_hpd_get_intr_status(dp->catalog); in msm_dp_display_irq_handler()
1151 drm_dbg_dp(dp->drm_dev, "type=%d isr=0x%x\n", in msm_dp_display_irq_handler()
1152 dp->msm_dp_display.connector_type, hpd_isr_status); in msm_dp_display_irq_handler()
1173 ret |= msm_dp_ctrl_isr(dp->ctrl); in msm_dp_display_irq_handler()
1176 ret |= msm_dp_aux_isr(dp->aux); in msm_dp_display_irq_handler()
1184 struct platform_device *pdev = dp->msm_dp_display.pdev; in msm_dp_display_request_irq()
1186 dp->irq = platform_get_irq(pdev, 0); in msm_dp_display_request_irq()
1187 if (dp->irq < 0) { in msm_dp_display_request_irq()
1189 return dp->irq; in msm_dp_display_request_irq()
1192 rc = devm_request_irq(&pdev->dev, dp->irq, msm_dp_display_irq_handler, in msm_dp_display_request_irq()
1198 dp->irq, rc); in msm_dp_display_request_irq()
1207 const struct msm_dp_desc *descs = of_device_get_match_data(&pdev->dev); in msm_dp_display_get_desc()
1216 if (descs[i].io_start == res->start) in msm_dp_display_get_desc()
1220 dev_err(&pdev->dev, "unknown displayport instance\n"); in msm_dp_display_get_desc()
1230 * External bridges are mandatory for eDP interfaces: one has to in msm_dp_display_probe_tail()
1231 * provide at least an eDP panel (which gets wrapped into panel-bridge). in msm_dp_display_probe_tail()
1234 * silently ignore an error if one is not present (-ENODEV). in msm_dp_display_probe_tail()
1236 dp->next_bridge = devm_drm_of_get_bridge(&dp->pdev->dev, dp->pdev->dev.of_node, 1, 0); in msm_dp_display_probe_tail()
1237 if (IS_ERR(dp->next_bridge)) { in msm_dp_display_probe_tail()
1238 ret = PTR_ERR(dp->next_bridge); in msm_dp_display_probe_tail()
1239 dp->next_bridge = NULL; in msm_dp_display_probe_tail()
1240 if (dp->is_edp || ret != -ENODEV) in msm_dp_display_probe_tail()
1253 return msm_dp_display_probe_tail(aux->dev); in msm_dp_auxbus_done_probe()
1259 struct device_node *node = pdev->dev.of_node; in msm_dp_display_get_connector_type()
1260 struct device_node *aux_bus = of_get_child_by_name(node, "aux-bus"); in msm_dp_display_get_connector_type()
1281 if (!pdev || !pdev->dev.of_node) { in msm_dp_display_probe()
1283 return -ENODEV; in msm_dp_display_probe()
1286 dp = devm_kzalloc(&pdev->dev, sizeof(*dp), GFP_KERNEL); in msm_dp_display_probe()
1288 return -ENOMEM; in msm_dp_display_probe()
1292 return -EINVAL; in msm_dp_display_probe()
1294 dp->msm_dp_display.pdev = pdev; in msm_dp_display_probe()
1295 dp->id = desc->id; in msm_dp_display_probe()
1296 dp->msm_dp_display.connector_type = msm_dp_display_get_connector_type(pdev, desc); in msm_dp_display_probe()
1297 dp->wide_bus_supported = desc->wide_bus_supported; in msm_dp_display_probe()
1298 dp->msm_dp_display.is_edp = in msm_dp_display_probe()
1299 (dp->msm_dp_display.connector_type == DRM_MODE_CONNECTOR_eDP); in msm_dp_display_probe()
1304 return -EPROBE_DEFER; in msm_dp_display_probe()
1308 mutex_init(&dp->event_mutex); in msm_dp_display_probe()
1309 init_waitqueue_head(&dp->event_q); in msm_dp_display_probe()
1310 spin_lock_init(&dp->event_lock); in msm_dp_display_probe()
1313 dp->msm_dp_display.msm_dp_audio = dp->audio; in msm_dp_display_probe()
1315 init_completion(&dp->audio_comp); in msm_dp_display_probe()
1317 platform_set_drvdata(pdev, &dp->msm_dp_display); in msm_dp_display_probe()
1319 rc = devm_pm_runtime_enable(&pdev->dev); in msm_dp_display_probe()
1327 if (dp->msm_dp_display.is_edp) { in msm_dp_display_probe()
1328 rc = devm_of_dp_aux_populate_bus(dp->aux, msm_dp_auxbus_done_probe); in msm_dp_display_probe()
1330 DRM_ERROR("eDP auxbus population failed, rc=%d\n", rc); in msm_dp_display_probe()
1334 rc = msm_dp_display_probe_tail(&pdev->dev); in msm_dp_display_probe()
1348 struct msm_dp_display_private *dp = dev_get_dp_display_private(&pdev->dev); in msm_dp_display_remove()
1350 component_del(&pdev->dev, &msm_dp_display_comp_ops); in msm_dp_display_remove()
1359 disable_irq(dp->irq); in msm_dp_pm_runtime_suspend()
1361 if (dp->msm_dp_display.is_edp) { in msm_dp_pm_runtime_suspend()
1363 msm_dp_catalog_ctrl_hpd_disable(dp->catalog); in msm_dp_pm_runtime_suspend()
1375 * for eDP, host cotroller, HPD block and PHY are enabled here in msm_dp_pm_runtime_resume()
1383 if (dp->msm_dp_display.is_edp) { in msm_dp_pm_runtime_resume()
1384 msm_dp_catalog_ctrl_hpd_enable(dp->catalog); in msm_dp_pm_runtime_resume()
1388 enable_irq(dp->irq); in msm_dp_pm_runtime_resume()
1402 .name = "msm-dp-display",
1432 info = &msm_dp_display->connector->display_info; in msm_dp_is_yuv_420_enabled()
1434 return dp->panel->vsc_sdp_supported && drm_mode_is_420_only(info, mode); in msm_dp_is_yuv_420_enabled()
1449 if (dp->msm_dp_mode.out_fmt_is_yuv_420) in msm_dp_wide_bus_available()
1452 return dp->wide_bus_supported; in msm_dp_wide_bus_available()
1462 dev = &dp->msm_dp_display.pdev->dev; in msm_dp_display_debugfs_init()
1464 rc = msm_dp_debug_init(dev, dp->panel, dp->link, dp->msm_dp_display.connector, root, is_edp); in msm_dp_display_debugfs_init()
1475 msm_dp_display->drm_dev = dev; in msm_dp_modeset_init()
1481 DRM_DEV_ERROR(dev->dev, in msm_dp_modeset_init()
1486 msm_dp_display->connector = msm_dp_drm_connector_init(msm_dp_display, encoder); in msm_dp_modeset_init()
1487 if (IS_ERR(msm_dp_display->connector)) { in msm_dp_modeset_init()
1488 ret = PTR_ERR(msm_dp_display->connector); in msm_dp_modeset_init()
1489 DRM_DEV_ERROR(dev->dev, in msm_dp_modeset_init()
1491 msm_dp_display->connector = NULL; in msm_dp_modeset_init()
1495 msm_dp_priv->panel->connector = msm_dp_display->connector; in msm_dp_modeset_init()
1504 struct msm_dp *dp = msm_dp_bridge->msm_dp_display; in msm_dp_bridge_atomic_enable()
1511 if (!msm_dp_display->msm_dp_mode.drm_mode.clock) { in msm_dp_bridge_atomic_enable()
1516 if (dp->is_edp) in msm_dp_bridge_atomic_enable()
1519 mutex_lock(&msm_dp_display->event_mutex); in msm_dp_bridge_atomic_enable()
1520 if (pm_runtime_resume_and_get(&dp->pdev->dev)) { in msm_dp_bridge_atomic_enable()
1522 mutex_unlock(&msm_dp_display->event_mutex); in msm_dp_bridge_atomic_enable()
1526 state = msm_dp_display->hpd_state; in msm_dp_bridge_atomic_enable()
1528 mutex_unlock(&msm_dp_display->event_mutex); in msm_dp_bridge_atomic_enable()
1532 rc = msm_dp_display_set_mode(dp, &msm_dp_display->msm_dp_mode); in msm_dp_bridge_atomic_enable()
1535 mutex_unlock(&msm_dp_display->event_mutex); in msm_dp_bridge_atomic_enable()
1539 state = msm_dp_display->hpd_state; in msm_dp_bridge_atomic_enable()
1555 msm_dp_display->hpd_state = ST_CONNECTED; in msm_dp_bridge_atomic_enable()
1557 drm_dbg_dp(dp->drm_dev, "type=%d Done\n", dp->connector_type); in msm_dp_bridge_atomic_enable()
1558 mutex_unlock(&msm_dp_display->event_mutex); in msm_dp_bridge_atomic_enable()
1565 struct msm_dp *dp = msm_dp_bridge->msm_dp_display; in msm_dp_bridge_atomic_disable()
1570 msm_dp_ctrl_push_idle(msm_dp_display->ctrl); in msm_dp_bridge_atomic_disable()
1577 struct msm_dp *dp = msm_dp_bridge->msm_dp_display; in msm_dp_bridge_atomic_post_disable()
1583 if (dp->is_edp) in msm_dp_bridge_atomic_post_disable()
1586 mutex_lock(&msm_dp_display->event_mutex); in msm_dp_bridge_atomic_post_disable()
1588 state = msm_dp_display->hpd_state; in msm_dp_bridge_atomic_post_disable()
1590 drm_dbg_dp(dp->drm_dev, "type=%d wrong hpd_state=%d\n", in msm_dp_bridge_atomic_post_disable()
1591 dp->connector_type, state); in msm_dp_bridge_atomic_post_disable()
1595 state = msm_dp_display->hpd_state; in msm_dp_bridge_atomic_post_disable()
1598 msm_dp_display->hpd_state = ST_DISCONNECTED; in msm_dp_bridge_atomic_post_disable()
1600 msm_dp_display->hpd_state = ST_DISPLAY_OFF; in msm_dp_bridge_atomic_post_disable()
1603 drm_dbg_dp(dp->drm_dev, "type=%d Done\n", dp->connector_type); in msm_dp_bridge_atomic_post_disable()
1605 pm_runtime_put_sync(&dp->pdev->dev); in msm_dp_bridge_atomic_post_disable()
1606 mutex_unlock(&msm_dp_display->event_mutex); in msm_dp_bridge_atomic_post_disable()
1614 struct msm_dp *dp = msm_dp_bridge->msm_dp_display; in msm_dp_bridge_mode_set()
1619 msm_dp_panel = msm_dp_display->panel; in msm_dp_bridge_mode_set()
1621 memset(&msm_dp_display->msm_dp_mode, 0x0, sizeof(struct msm_dp_display_mode)); in msm_dp_bridge_mode_set()
1624 msm_dp_display->msm_dp_mode.bpp = msm_dp_display_get_test_bpp(dp); in msm_dp_bridge_mode_set()
1626 msm_dp_display->msm_dp_mode.bpp = dp->connector->display_info.bpc * 3; in msm_dp_bridge_mode_set()
1628 if (!msm_dp_display->msm_dp_mode.bpp) in msm_dp_bridge_mode_set()
1629 msm_dp_display->msm_dp_mode.bpp = 24; /* Default bpp */ in msm_dp_bridge_mode_set()
1631 drm_mode_copy(&msm_dp_display->msm_dp_mode.drm_mode, adjusted_mode); in msm_dp_bridge_mode_set()
1633 msm_dp_display->msm_dp_mode.v_active_low = in msm_dp_bridge_mode_set()
1634 !!(msm_dp_display->msm_dp_mode.drm_mode.flags & DRM_MODE_FLAG_NVSYNC); in msm_dp_bridge_mode_set()
1636 msm_dp_display->msm_dp_mode.h_active_low = in msm_dp_bridge_mode_set()
1637 !!(msm_dp_display->msm_dp_mode.drm_mode.flags & DRM_MODE_FLAG_NHSYNC); in msm_dp_bridge_mode_set()
1639 msm_dp_display->msm_dp_mode.out_fmt_is_yuv_420 = in msm_dp_bridge_mode_set()
1640 drm_mode_is_420_only(&dp->connector->display_info, adjusted_mode) && in msm_dp_bridge_mode_set()
1641 msm_dp_panel->vsc_sdp_supported; in msm_dp_bridge_mode_set()
1644 msm_dp_display->ctrl->wide_bus_en = in msm_dp_bridge_mode_set()
1645 msm_dp_display->msm_dp_mode.out_fmt_is_yuv_420 ? false : msm_dp_display->wide_bus_supported; in msm_dp_bridge_mode_set()
1646 msm_dp_display->catalog->wide_bus_en = in msm_dp_bridge_mode_set()
1647 msm_dp_display->msm_dp_mode.out_fmt_is_yuv_420 ? false : msm_dp_display->wide_bus_supported; in msm_dp_bridge_mode_set()
1653 struct msm_dp *msm_dp_display = msm_dp_bridge->msm_dp_display; in msm_dp_bridge_hpd_enable()
1658 * step-1: msm_dp_pm_runtime_resume() enable dp host only in msm_dp_bridge_hpd_enable()
1659 * step-2: enable hdp block and have hpd irq enabled here in msm_dp_bridge_hpd_enable()
1660 * step-3: waiting for plugin irq while phy is not initialized in msm_dp_bridge_hpd_enable()
1661 * step-4: DP PHY is initialized at plugin handler before link training in msm_dp_bridge_hpd_enable()
1664 mutex_lock(&dp->event_mutex); in msm_dp_bridge_hpd_enable()
1665 if (pm_runtime_resume_and_get(&msm_dp_display->pdev->dev)) { in msm_dp_bridge_hpd_enable()
1667 mutex_unlock(&dp->event_mutex); in msm_dp_bridge_hpd_enable()
1671 msm_dp_catalog_ctrl_hpd_enable(dp->catalog); in msm_dp_bridge_hpd_enable()
1674 msm_dp_catalog_hpd_config_intr(dp->catalog, DP_DP_HPD_INT_MASK, true); in msm_dp_bridge_hpd_enable()
1676 msm_dp_display->internal_hpd = true; in msm_dp_bridge_hpd_enable()
1677 mutex_unlock(&dp->event_mutex); in msm_dp_bridge_hpd_enable()
1683 struct msm_dp *msm_dp_display = msm_dp_bridge->msm_dp_display; in msm_dp_bridge_hpd_disable()
1686 mutex_lock(&dp->event_mutex); in msm_dp_bridge_hpd_disable()
1688 msm_dp_catalog_hpd_config_intr(dp->catalog, DP_DP_HPD_INT_MASK, false); in msm_dp_bridge_hpd_disable()
1689 msm_dp_catalog_ctrl_hpd_disable(dp->catalog); in msm_dp_bridge_hpd_disable()
1691 msm_dp_display->internal_hpd = false; in msm_dp_bridge_hpd_disable()
1693 pm_runtime_put_sync(&msm_dp_display->pdev->dev); in msm_dp_bridge_hpd_disable()
1694 mutex_unlock(&dp->event_mutex); in msm_dp_bridge_hpd_disable()
1701 struct msm_dp *msm_dp_display = msm_dp_bridge->msm_dp_display; in msm_dp_bridge_hpd_notify()
1705 if (msm_dp_display->internal_hpd) in msm_dp_bridge_hpd_notify()
1708 if (!msm_dp_display->link_ready && status == connector_status_connected) in msm_dp_bridge_hpd_notify()
1710 else if (msm_dp_display->link_ready && status == connector_status_disconnected) in msm_dp_bridge_hpd_notify()