Lines Matching +full:video +full:- +full:encoder

1 // SPDX-License-Identifier: GPL-2.0-only
4 * Author: Chris Zhong <zyw@rock-chips.com>
16 #include <sound/hdmi-codec.h>
25 #include "cdn-dp-core.h"
26 #include "cdn-dp-reg.h"
33 static inline struct cdn_dp_device *encoder_to_dp(struct drm_encoder *encoder) in encoder_to_dp() argument
35 struct rockchip_encoder *rkencoder = to_rockchip_encoder(encoder); in encoder_to_dp()
37 return container_of(rkencoder, struct cdn_dp_device, encoder); in encoder_to_dp()
61 { .compatible = "rockchip,rk3399-cdn-dp",
73 ret = clk_prepare_enable(dp->grf_clk); in cdn_dp_grf_write()
75 DRM_DEV_ERROR(dp->dev, "Failed to prepare_enable grf clock\n"); in cdn_dp_grf_write()
79 ret = regmap_write(dp->grf, reg, val); in cdn_dp_grf_write()
81 DRM_DEV_ERROR(dp->dev, "Could not write to GRF: %d\n", ret); in cdn_dp_grf_write()
82 clk_disable_unprepare(dp->grf_clk); in cdn_dp_grf_write()
86 clk_disable_unprepare(dp->grf_clk); in cdn_dp_grf_write()
96 ret = clk_prepare_enable(dp->pclk); in cdn_dp_clk_enable()
98 DRM_DEV_ERROR(dp->dev, "cannot enable dp pclk %d\n", ret); in cdn_dp_clk_enable()
102 ret = clk_prepare_enable(dp->core_clk); in cdn_dp_clk_enable()
104 DRM_DEV_ERROR(dp->dev, "cannot enable core_clk %d\n", ret); in cdn_dp_clk_enable()
108 ret = pm_runtime_get_sync(dp->dev); in cdn_dp_clk_enable()
110 DRM_DEV_ERROR(dp->dev, "cannot get pm runtime %d\n", ret); in cdn_dp_clk_enable()
114 reset_control_assert(dp->core_rst); in cdn_dp_clk_enable()
115 reset_control_assert(dp->dptx_rst); in cdn_dp_clk_enable()
116 reset_control_assert(dp->apb_rst); in cdn_dp_clk_enable()
117 reset_control_deassert(dp->core_rst); in cdn_dp_clk_enable()
118 reset_control_deassert(dp->dptx_rst); in cdn_dp_clk_enable()
119 reset_control_deassert(dp->apb_rst); in cdn_dp_clk_enable()
121 rate = clk_get_rate(dp->core_clk); in cdn_dp_clk_enable()
123 DRM_DEV_ERROR(dp->dev, "get clk rate failed\n"); in cdn_dp_clk_enable()
124 ret = -EINVAL; in cdn_dp_clk_enable()
134 pm_runtime_put(dp->dev); in cdn_dp_clk_enable()
136 clk_disable_unprepare(dp->core_clk); in cdn_dp_clk_enable()
138 clk_disable_unprepare(dp->pclk); in cdn_dp_clk_enable()
145 pm_runtime_put_sync(dp->dev); in cdn_dp_clk_disable()
146 clk_disable_unprepare(dp->pclk); in cdn_dp_clk_disable()
147 clk_disable_unprepare(dp->core_clk); in cdn_dp_clk_disable()
152 struct extcon_dev *edev = port->extcon; in cdn_dp_get_port_lanes()
191 for (i = 0; i < dp->ports; i++) { in cdn_dp_connected_port()
192 port = dp->port[i]; in cdn_dp_connected_port()
206 if (dp->active_port < 0 || dp->active_port >= dp->ports) { in cdn_dp_check_sink_connection()
207 DRM_DEV_ERROR(dp->dev, "active_port is wrong!\n"); in cdn_dp_check_sink_connection()
211 port = dp->port[dp->active_port]; in cdn_dp_check_sink_connection()
220 if (!extcon_get_state(port->extcon, EXTCON_DISP_DP)) in cdn_dp_check_sink_connection()
229 DRM_DEV_ERROR(dp->dev, "Get sink capability timed out\n"); in cdn_dp_check_sink_connection()
239 mutex_lock(&dp->lock); in cdn_dp_connector_detect()
240 if (dp->connected) in cdn_dp_connector_detect()
242 mutex_unlock(&dp->lock); in cdn_dp_connector_detect()
267 mutex_lock(&dp->lock); in cdn_dp_connector_get_modes()
271 mutex_unlock(&dp->lock); in cdn_dp_connector_get_modes()
281 struct drm_display_info *display_info = &dp->connector.display_info; in cdn_dp_connector_mode_valid()
286 if (!dp->connected) in cdn_dp_connector_mode_valid()
289 switch (display_info->bpc) { in cdn_dp_connector_mode_valid()
301 requested = mode->clock * bpc * 3 / 1000; in cdn_dp_connector_mode_valid()
303 source_max = dp->lanes; in cdn_dp_connector_mode_valid()
304 sink_max = drm_dp_max_lane_count(dp->dpcd); in cdn_dp_connector_mode_valid()
308 sink_max = drm_dp_max_link_rate(dp->dpcd); in cdn_dp_connector_mode_valid()
317 DRM_DEV_DEBUG_KMS(dp->dev, in cdn_dp_connector_mode_valid()
319 requested, actual, mode->clock); in cdn_dp_connector_mode_valid()
335 const struct firmware *fw = dp->fw; in cdn_dp_firmware_init()
338 hdr = (struct cdn_firmware_header *)fw->data; in cdn_dp_firmware_init()
339 if (fw->size != le32_to_cpu(hdr->size_bytes)) { in cdn_dp_firmware_init()
340 DRM_DEV_ERROR(dp->dev, "firmware is invalid\n"); in cdn_dp_firmware_init()
341 return -EINVAL; in cdn_dp_firmware_init()
344 iram_data = (const u32 *)(fw->data + hdr->header_size); in cdn_dp_firmware_init()
345 dram_data = (const u32 *)(fw->data + hdr->header_size + hdr->iram_size); in cdn_dp_firmware_init()
347 ret = cdn_dp_load_firmware(dp, iram_data, hdr->iram_size, in cdn_dp_firmware_init()
348 dram_data, hdr->dram_size); in cdn_dp_firmware_init()
354 DRM_DEV_ERROR(dp->dev, "active ucpu failed: %d\n", ret); in cdn_dp_firmware_init()
363 const struct drm_display_info *info = &dp->connector.display_info; in cdn_dp_get_sink_capability()
367 return -ENODEV; in cdn_dp_get_sink_capability()
369 ret = cdn_dp_dpcd_read(dp, DP_DPCD_REV, dp->dpcd, in cdn_dp_get_sink_capability()
372 DRM_DEV_ERROR(dp->dev, "Failed to get caps %d\n", ret); in cdn_dp_get_sink_capability()
376 drm_edid_free(dp->drm_edid); in cdn_dp_get_sink_capability()
377 dp->drm_edid = drm_edid_read_custom(&dp->connector, in cdn_dp_get_sink_capability()
379 drm_edid_connector_update(&dp->connector, dp->drm_edid); in cdn_dp_get_sink_capability()
381 dp->sink_has_audio = info->has_audio; in cdn_dp_get_sink_capability()
383 if (dp->drm_edid) in cdn_dp_get_sink_capability()
384 DRM_DEV_DEBUG_KMS(dp->dev, "got edid: width[%d] x height[%d]\n", in cdn_dp_get_sink_capability()
385 info->width_mm / 10, info->height_mm / 10); in cdn_dp_get_sink_capability()
395 if (!port->phy_enabled) { in cdn_dp_enable_phy()
396 ret = phy_power_on(port->phy); in cdn_dp_enable_phy()
398 DRM_DEV_ERROR(dp->dev, "phy power on failed: %d\n", in cdn_dp_enable_phy()
402 port->phy_enabled = true; in cdn_dp_enable_phy()
408 DRM_DEV_ERROR(dp->dev, "Failed to write HPD_SEL %d\n", ret); in cdn_dp_enable_phy()
415 DRM_DEV_ERROR(dp->dev, "hpd does not exist\n"); in cdn_dp_enable_phy()
419 ret = extcon_get_property(port->extcon, EXTCON_DISP_DP, in cdn_dp_enable_phy()
422 DRM_DEV_ERROR(dp->dev, "get property failed\n"); in cdn_dp_enable_phy()
426 port->lanes = cdn_dp_get_port_lanes(port); in cdn_dp_enable_phy()
427 ret = cdn_dp_set_host_cap(dp, port->lanes, property.intval); in cdn_dp_enable_phy()
429 DRM_DEV_ERROR(dp->dev, "set host capabilities failed: %d\n", in cdn_dp_enable_phy()
434 dp->active_port = port->id; in cdn_dp_enable_phy()
438 if (phy_power_off(port->phy)) in cdn_dp_enable_phy()
439 DRM_DEV_ERROR(dp->dev, "phy power off failed: %d", ret); in cdn_dp_enable_phy()
441 port->phy_enabled = false; in cdn_dp_enable_phy()
454 if (port->phy_enabled) { in cdn_dp_disable_phy()
455 ret = phy_power_off(port->phy); in cdn_dp_disable_phy()
457 DRM_DEV_ERROR(dp->dev, "phy power off failed: %d", ret); in cdn_dp_disable_phy()
462 port->phy_enabled = false; in cdn_dp_disable_phy()
463 port->lanes = 0; in cdn_dp_disable_phy()
464 dp->active_port = -1; in cdn_dp_disable_phy()
472 if (!dp->active) in cdn_dp_disable()
475 for (i = 0; i < dp->ports; i++) in cdn_dp_disable()
476 cdn_dp_disable_phy(dp, dp->port[i]); in cdn_dp_disable()
481 DRM_DEV_ERROR(dp->dev, "Failed to clear hpd sel %d\n", in cdn_dp_disable()
488 dp->active = false; in cdn_dp_disable()
489 dp->max_lanes = 0; in cdn_dp_disable()
490 dp->max_rate = 0; in cdn_dp_disable()
491 if (!dp->connected) { in cdn_dp_disable()
492 drm_edid_free(dp->drm_edid); in cdn_dp_disable()
493 dp->drm_edid = NULL; in cdn_dp_disable()
506 DRM_DEV_ERROR(dp->dev, in cdn_dp_enable()
508 return -ENODEV; in cdn_dp_enable()
511 if (dp->active) in cdn_dp_enable()
520 DRM_DEV_ERROR(dp->dev, "firmware init failed: %d", ret); in cdn_dp_enable()
525 for (i = port->id; i < dp->ports; i++) { in cdn_dp_enable()
526 port = dp->port[i]; in cdn_dp_enable()
537 dp->active = true; in cdn_dp_enable()
538 dp->lanes = port->lanes; in cdn_dp_enable()
549 static void cdn_dp_encoder_mode_set(struct drm_encoder *encoder, in cdn_dp_encoder_mode_set() argument
553 struct cdn_dp_device *dp = encoder_to_dp(encoder); in cdn_dp_encoder_mode_set()
554 struct drm_display_info *display_info = &dp->connector.display_info; in cdn_dp_encoder_mode_set()
555 struct video_info *video = &dp->video_info; in cdn_dp_encoder_mode_set() local
557 switch (display_info->bpc) { in cdn_dp_encoder_mode_set()
559 video->color_depth = 10; in cdn_dp_encoder_mode_set()
562 video->color_depth = 6; in cdn_dp_encoder_mode_set()
565 video->color_depth = 8; in cdn_dp_encoder_mode_set()
569 video->color_fmt = PXL_RGB; in cdn_dp_encoder_mode_set()
570 video->v_sync_polarity = !!(mode->flags & DRM_MODE_FLAG_NVSYNC); in cdn_dp_encoder_mode_set()
571 video->h_sync_polarity = !!(mode->flags & DRM_MODE_FLAG_NHSYNC); in cdn_dp_encoder_mode_set()
573 drm_mode_copy(&dp->mode, adjusted); in cdn_dp_encoder_mode_set()
580 u8 sink_lanes = drm_dp_max_lane_count(dp->dpcd); in cdn_dp_check_link_status()
582 if (!port || !dp->max_rate || !dp->max_lanes) in cdn_dp_check_link_status()
592 return drm_dp_channel_eq_ok(link_status, min(port->lanes, sink_lanes)); in cdn_dp_check_link_status()
598 if (dp->codec_dev) in cdn_dp_audio_handle_plugged_change()
599 dp->plugged_cb(dp->codec_dev, plugged); in cdn_dp_audio_handle_plugged_change()
602 static void cdn_dp_encoder_enable(struct drm_encoder *encoder) in cdn_dp_encoder_enable() argument
604 struct cdn_dp_device *dp = encoder_to_dp(encoder); in cdn_dp_encoder_enable()
607 ret = drm_of_encoder_active_endpoint_id(dp->dev->of_node, encoder); in cdn_dp_encoder_enable()
609 DRM_DEV_ERROR(dp->dev, "Could not get vop id, %d", ret); in cdn_dp_encoder_enable()
613 DRM_DEV_DEBUG_KMS(dp->dev, "vop %s output to cdn-dp\n", in cdn_dp_encoder_enable()
624 mutex_lock(&dp->lock); in cdn_dp_encoder_enable()
628 DRM_DEV_ERROR(dp->dev, "Failed to enable encoder %d\n", in cdn_dp_encoder_enable()
635 DRM_DEV_ERROR(dp->dev, "Failed link train %d\n", ret); in cdn_dp_encoder_enable()
642 DRM_DEV_ERROR(dp->dev, "Failed to idle video %d\n", ret); in cdn_dp_encoder_enable()
648 DRM_DEV_ERROR(dp->dev, "Failed to config video %d\n", ret); in cdn_dp_encoder_enable()
654 DRM_DEV_ERROR(dp->dev, "Failed to valid video %d\n", ret); in cdn_dp_encoder_enable()
661 mutex_unlock(&dp->lock); in cdn_dp_encoder_enable()
664 static void cdn_dp_encoder_disable(struct drm_encoder *encoder) in cdn_dp_encoder_disable() argument
666 struct cdn_dp_device *dp = encoder_to_dp(encoder); in cdn_dp_encoder_disable()
669 mutex_lock(&dp->lock); in cdn_dp_encoder_disable()
672 if (dp->active) { in cdn_dp_encoder_disable()
675 DRM_DEV_ERROR(dp->dev, "Failed to disable encoder %d\n", in cdn_dp_encoder_disable()
679 mutex_unlock(&dp->lock); in cdn_dp_encoder_disable()
682 * In the following 2 cases, we need to run the event_work to re-enable in cdn_dp_encoder_disable()
686 * run the event_work to re-open DP for the other port. in cdn_dp_encoder_disable()
687 * 2. If re-training or re-config failed, the DP will be disabled here. in cdn_dp_encoder_disable()
688 * run the event_work to re-connect it. in cdn_dp_encoder_disable()
690 if (!dp->connected && cdn_dp_connected_port(dp)) in cdn_dp_encoder_disable()
691 schedule_work(&dp->event_work); in cdn_dp_encoder_disable()
694 static int cdn_dp_encoder_atomic_check(struct drm_encoder *encoder, in cdn_dp_encoder_atomic_check() argument
700 s->output_mode = ROCKCHIP_OUT_MODE_AAAA; in cdn_dp_encoder_atomic_check()
701 s->output_type = DRM_MODE_CONNECTOR_DisplayPort; in cdn_dp_encoder_atomic_check()
715 struct device *dev = dp->dev; in cdn_dp_parse_dt()
716 struct device_node *np = dev->of_node; in cdn_dp_parse_dt()
719 dp->grf = syscon_regmap_lookup_by_phandle(np, "rockchip,grf"); in cdn_dp_parse_dt()
720 if (IS_ERR(dp->grf)) { in cdn_dp_parse_dt()
721 DRM_DEV_ERROR(dev, "cdn-dp needs rockchip,grf property\n"); in cdn_dp_parse_dt()
722 return PTR_ERR(dp->grf); in cdn_dp_parse_dt()
725 dp->regs = devm_platform_ioremap_resource(pdev, 0); in cdn_dp_parse_dt()
726 if (IS_ERR(dp->regs)) { in cdn_dp_parse_dt()
728 return PTR_ERR(dp->regs); in cdn_dp_parse_dt()
731 dp->core_clk = devm_clk_get(dev, "core-clk"); in cdn_dp_parse_dt()
732 if (IS_ERR(dp->core_clk)) { in cdn_dp_parse_dt()
734 return PTR_ERR(dp->core_clk); in cdn_dp_parse_dt()
737 dp->pclk = devm_clk_get(dev, "pclk"); in cdn_dp_parse_dt()
738 if (IS_ERR(dp->pclk)) { in cdn_dp_parse_dt()
740 return PTR_ERR(dp->pclk); in cdn_dp_parse_dt()
743 dp->spdif_clk = devm_clk_get(dev, "spdif"); in cdn_dp_parse_dt()
744 if (IS_ERR(dp->spdif_clk)) { in cdn_dp_parse_dt()
746 return PTR_ERR(dp->spdif_clk); in cdn_dp_parse_dt()
749 dp->grf_clk = devm_clk_get(dev, "grf"); in cdn_dp_parse_dt()
750 if (IS_ERR(dp->grf_clk)) { in cdn_dp_parse_dt()
752 return PTR_ERR(dp->grf_clk); in cdn_dp_parse_dt()
755 dp->spdif_rst = devm_reset_control_get(dev, "spdif"); in cdn_dp_parse_dt()
756 if (IS_ERR(dp->spdif_rst)) { in cdn_dp_parse_dt()
758 return PTR_ERR(dp->spdif_rst); in cdn_dp_parse_dt()
761 dp->dptx_rst = devm_reset_control_get(dev, "dptx"); in cdn_dp_parse_dt()
762 if (IS_ERR(dp->dptx_rst)) { in cdn_dp_parse_dt()
764 return PTR_ERR(dp->dptx_rst); in cdn_dp_parse_dt()
767 dp->core_rst = devm_reset_control_get(dev, "core"); in cdn_dp_parse_dt()
768 if (IS_ERR(dp->core_rst)) { in cdn_dp_parse_dt()
770 return PTR_ERR(dp->core_rst); in cdn_dp_parse_dt()
773 dp->apb_rst = devm_reset_control_get(dev, "apb"); in cdn_dp_parse_dt()
774 if (IS_ERR(dp->apb_rst)) { in cdn_dp_parse_dt()
776 return PTR_ERR(dp->apb_rst); in cdn_dp_parse_dt()
788 .sample_width = params->sample_width, in cdn_dp_audio_hw_params()
789 .sample_rate = params->sample_rate, in cdn_dp_audio_hw_params()
790 .channels = params->channels, in cdn_dp_audio_hw_params()
794 mutex_lock(&dp->lock); in cdn_dp_audio_hw_params()
795 if (!dp->active) { in cdn_dp_audio_hw_params()
796 ret = -ENODEV; in cdn_dp_audio_hw_params()
800 switch (daifmt->fmt) { in cdn_dp_audio_hw_params()
808 DRM_DEV_ERROR(dev, "Invalid format %d\n", daifmt->fmt); in cdn_dp_audio_hw_params()
809 ret = -EINVAL; in cdn_dp_audio_hw_params()
815 dp->audio_info = audio; in cdn_dp_audio_hw_params()
818 mutex_unlock(&dp->lock); in cdn_dp_audio_hw_params()
827 mutex_lock(&dp->lock); in cdn_dp_audio_shutdown()
828 if (!dp->active) in cdn_dp_audio_shutdown()
831 ret = cdn_dp_audio_stop(dp, &dp->audio_info); in cdn_dp_audio_shutdown()
833 dp->audio_info.format = AFMT_UNUSED; in cdn_dp_audio_shutdown()
835 mutex_unlock(&dp->lock); in cdn_dp_audio_shutdown()
844 mutex_lock(&dp->lock); in cdn_dp_audio_mute_stream()
845 if (!dp->active) { in cdn_dp_audio_mute_stream()
846 ret = -ENODEV; in cdn_dp_audio_mute_stream()
853 mutex_unlock(&dp->lock); in cdn_dp_audio_mute_stream()
862 memcpy(buf, dp->connector.eld, min(sizeof(dp->connector.eld), len)); in cdn_dp_audio_get_eld()
873 mutex_lock(&dp->lock); in cdn_dp_audio_hook_plugged_cb()
874 dp->plugged_cb = fn; in cdn_dp_audio_hook_plugged_cb()
875 dp->codec_dev = codec_dev; in cdn_dp_audio_hook_plugged_cb()
876 cdn_dp_audio_handle_plugged_change(dp, dp->connected); in cdn_dp_audio_hook_plugged_cb()
877 mutex_unlock(&dp->lock); in cdn_dp_audio_hook_plugged_cb()
901 dp->audio_pdev = platform_device_register_data( in cdn_dp_audio_codec_init()
905 return PTR_ERR_OR_ZERO(dp->audio_pdev); in cdn_dp_audio_codec_init()
914 WARN_ON(!mutex_is_locked(&dp->lock)); in cdn_dp_request_firmware()
916 if (dp->fw_loaded) in cdn_dp_request_firmware()
920 mutex_unlock(&dp->lock); in cdn_dp_request_firmware()
923 ret = request_firmware(&dp->fw, CDN_DP_FIRMWARE, dp->dev); in cdn_dp_request_firmware()
924 if (ret == -ENOENT) { in cdn_dp_request_firmware()
929 DRM_DEV_ERROR(dp->dev, in cdn_dp_request_firmware()
934 dp->fw_loaded = true; in cdn_dp_request_firmware()
939 DRM_DEV_ERROR(dp->dev, "Timed out trying to load firmware\n"); in cdn_dp_request_firmware()
940 ret = -ETIMEDOUT; in cdn_dp_request_firmware()
942 mutex_lock(&dp->lock); in cdn_dp_request_firmware()
950 struct drm_connector *connector = &dp->connector; in cdn_dp_pd_event_work()
955 mutex_lock(&dp->lock); in cdn_dp_pd_event_work()
957 if (dp->suspended) in cdn_dp_pd_event_work()
964 dp->connected = true; in cdn_dp_pd_event_work()
968 DRM_DEV_INFO(dp->dev, "Not connected; disabling cdn\n"); in cdn_dp_pd_event_work()
969 dp->connected = false; in cdn_dp_pd_event_work()
972 } else if (!dp->active) { in cdn_dp_pd_event_work()
973 DRM_DEV_INFO(dp->dev, "Connected, not enabled; enabling cdn\n"); in cdn_dp_pd_event_work()
976 DRM_DEV_ERROR(dp->dev, "Enabling dp failed: %d\n", ret); in cdn_dp_pd_event_work()
977 dp->connected = false; in cdn_dp_pd_event_work()
982 DRM_DEV_INFO(dp->dev, "Connected without sink; assert hpd\n"); in cdn_dp_pd_event_work()
983 dp->connected = false; in cdn_dp_pd_event_work()
985 /* Enabled and connected with a sink, re-train if requested */ in cdn_dp_pd_event_work()
987 unsigned int rate = dp->max_rate; in cdn_dp_pd_event_work()
988 unsigned int lanes = dp->max_lanes; in cdn_dp_pd_event_work()
989 struct drm_display_mode *mode = &dp->mode; in cdn_dp_pd_event_work()
991 DRM_DEV_INFO(dp->dev, "Connected with sink; re-train link\n"); in cdn_dp_pd_event_work()
994 dp->connected = false; in cdn_dp_pd_event_work()
995 DRM_DEV_ERROR(dp->dev, "Training link failed: %d\n", ret); in cdn_dp_pd_event_work()
999 /* If training result is changed, update the video config */ in cdn_dp_pd_event_work()
1000 if (mode->clock && in cdn_dp_pd_event_work()
1001 (rate != dp->max_rate || lanes != dp->max_lanes)) { in cdn_dp_pd_event_work()
1004 dp->connected = false; in cdn_dp_pd_event_work()
1005 DRM_DEV_ERROR(dp->dev, "Failed to configure video: %d\n", ret); in cdn_dp_pd_event_work()
1011 mutex_unlock(&dp->lock); in cdn_dp_pd_event_work()
1013 old_status = connector->status; in cdn_dp_pd_event_work()
1014 connector->status = connector->funcs->detect(connector, false); in cdn_dp_pd_event_work()
1015 if (old_status != connector->status) in cdn_dp_pd_event_work()
1016 drm_kms_helper_hotplug_event(dp->drm_dev); in cdn_dp_pd_event_work()
1024 struct cdn_dp_device *dp = port->dp; in cdn_dp_pd_event()
1031 schedule_work(&dp->event_work); in cdn_dp_pd_event()
1039 struct drm_encoder *encoder; in cdn_dp_bind() local
1049 dp->drm_dev = drm_dev; in cdn_dp_bind()
1050 dp->connected = false; in cdn_dp_bind()
1051 dp->active = false; in cdn_dp_bind()
1052 dp->active_port = -1; in cdn_dp_bind()
1053 dp->fw_loaded = false; in cdn_dp_bind()
1055 INIT_WORK(&dp->event_work, cdn_dp_pd_event_work); in cdn_dp_bind()
1057 encoder = &dp->encoder.encoder; in cdn_dp_bind()
1059 encoder->possible_crtcs = drm_of_find_possible_crtcs(drm_dev, in cdn_dp_bind()
1060 dev->of_node); in cdn_dp_bind()
1061 DRM_DEBUG_KMS("possible_crtcs = 0x%x\n", encoder->possible_crtcs); in cdn_dp_bind()
1063 ret = drm_simple_encoder_init(drm_dev, encoder, in cdn_dp_bind()
1066 DRM_ERROR("failed to initialize encoder with drm\n"); in cdn_dp_bind()
1070 drm_encoder_helper_add(encoder, &cdn_dp_encoder_helper_funcs); in cdn_dp_bind()
1072 connector = &dp->connector; in cdn_dp_bind()
1073 connector->polled = DRM_CONNECTOR_POLL_HPD; in cdn_dp_bind()
1074 connector->dpms = DRM_MODE_DPMS_OFF; in cdn_dp_bind()
1086 ret = drm_connector_attach_encoder(connector, encoder); in cdn_dp_bind()
1088 DRM_ERROR("failed to attach connector and encoder\n"); in cdn_dp_bind()
1092 for (i = 0; i < dp->ports; i++) { in cdn_dp_bind()
1093 port = dp->port[i]; in cdn_dp_bind()
1095 port->event_nb.notifier_call = cdn_dp_pd_event; in cdn_dp_bind()
1096 ret = devm_extcon_register_notifier(dp->dev, port->extcon, in cdn_dp_bind()
1098 &port->event_nb); in cdn_dp_bind()
1108 schedule_work(&dp->event_work); in cdn_dp_bind()
1115 drm_encoder_cleanup(encoder); in cdn_dp_bind()
1122 struct drm_encoder *encoder = &dp->encoder.encoder; in cdn_dp_unbind() local
1123 struct drm_connector *connector = &dp->connector; in cdn_dp_unbind()
1125 cancel_work_sync(&dp->event_work); in cdn_dp_unbind()
1126 cdn_dp_encoder_disable(encoder); in cdn_dp_unbind()
1127 encoder->funcs->destroy(encoder); in cdn_dp_unbind()
1128 connector->funcs->destroy(connector); in cdn_dp_unbind()
1131 if (dp->fw_loaded) in cdn_dp_unbind()
1132 release_firmware(dp->fw); in cdn_dp_unbind()
1133 drm_edid_free(dp->drm_edid); in cdn_dp_unbind()
1134 dp->drm_edid = NULL; in cdn_dp_unbind()
1147 mutex_lock(&dp->lock); in cdn_dp_suspend()
1148 if (dp->active) in cdn_dp_suspend()
1150 dp->suspended = true; in cdn_dp_suspend()
1151 mutex_unlock(&dp->lock); in cdn_dp_suspend()
1160 mutex_lock(&dp->lock); in cdn_dp_resume()
1161 dp->suspended = false; in cdn_dp_resume()
1162 if (dp->fw_loaded) in cdn_dp_resume()
1163 schedule_work(&dp->event_work); in cdn_dp_resume()
1164 mutex_unlock(&dp->lock); in cdn_dp_resume()
1171 struct device *dev = &pdev->dev; in cdn_dp_probe()
1183 return -ENOMEM; in cdn_dp_probe()
1184 dp->dev = dev; in cdn_dp_probe()
1186 match = of_match_node(cdn_dp_dt_ids, pdev->dev.of_node); in cdn_dp_probe()
1187 dp_data = (struct cdn_dp_data *)match->data; in cdn_dp_probe()
1189 for (i = 0; i < dp_data->max_phy; i++) { in cdn_dp_probe()
1191 phy = devm_of_phy_get_by_index(dev, dev->of_node, i); in cdn_dp_probe()
1193 if (PTR_ERR(extcon) == -EPROBE_DEFER || in cdn_dp_probe()
1194 PTR_ERR(phy) == -EPROBE_DEFER) in cdn_dp_probe()
1195 return -EPROBE_DEFER; in cdn_dp_probe()
1202 return -ENOMEM; in cdn_dp_probe()
1204 port->extcon = extcon; in cdn_dp_probe()
1205 port->phy = phy; in cdn_dp_probe()
1206 port->dp = dp; in cdn_dp_probe()
1207 port->id = i; in cdn_dp_probe()
1208 dp->port[dp->ports++] = port; in cdn_dp_probe()
1211 if (!dp->ports) { in cdn_dp_probe()
1213 return -EINVAL; in cdn_dp_probe()
1216 mutex_init(&dp->lock); in cdn_dp_probe()
1230 platform_device_unregister(dp->audio_pdev); in cdn_dp_probe()
1238 platform_device_unregister(dp->audio_pdev); in cdn_dp_remove()
1239 cdn_dp_suspend(dp->dev); in cdn_dp_remove()
1240 component_del(&pdev->dev, &cdn_dp_component_ops); in cdn_dp_remove()
1247 cdn_dp_suspend(dp->dev); in cdn_dp_shutdown()
1260 .name = "cdn-dp",