Lines Matching refs:vc4_hdmi

131 static bool vc4_hdmi_supports_scrambling(struct vc4_hdmi *vc4_hdmi)  in vc4_hdmi_supports_scrambling()  argument
133 struct drm_display_info *display = &vc4_hdmi->connector.display_info; in vc4_hdmi_supports_scrambling()
135 lockdep_assert_held(&vc4_hdmi->mutex); in vc4_hdmi_supports_scrambling()
156 static bool vc4_hdmi_is_full_range(struct vc4_hdmi *vc4_hdmi, in vc4_hdmi_is_full_range() argument
159 const struct drm_display_mode *mode = &vc4_hdmi->saved_adjusted_mode; in vc4_hdmi_is_full_range()
160 struct drm_display_info *display = &vc4_hdmi->connector.display_info; in vc4_hdmi_is_full_range()
174 struct vc4_hdmi *vc4_hdmi = entry->file.data; in vc4_hdmi_debugfs_regs() local
175 struct drm_device *drm = vc4_hdmi->connector.dev; in vc4_hdmi_debugfs_regs()
182 drm_print_regset32(&p, &vc4_hdmi->hdmi_regset); in vc4_hdmi_debugfs_regs()
183 drm_print_regset32(&p, &vc4_hdmi->hd_regset); in vc4_hdmi_debugfs_regs()
184 drm_print_regset32(&p, &vc4_hdmi->cec_regset); in vc4_hdmi_debugfs_regs()
185 drm_print_regset32(&p, &vc4_hdmi->csc_regset); in vc4_hdmi_debugfs_regs()
186 drm_print_regset32(&p, &vc4_hdmi->dvp_regset); in vc4_hdmi_debugfs_regs()
187 drm_print_regset32(&p, &vc4_hdmi->phy_regset); in vc4_hdmi_debugfs_regs()
188 drm_print_regset32(&p, &vc4_hdmi->ram_regset); in vc4_hdmi_debugfs_regs()
189 drm_print_regset32(&p, &vc4_hdmi->rm_regset); in vc4_hdmi_debugfs_regs()
196 static void vc4_hdmi_reset(struct vc4_hdmi *vc4_hdmi) in vc4_hdmi_reset() argument
198 struct drm_device *drm = vc4_hdmi->connector.dev; in vc4_hdmi_reset()
209 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_reset()
223 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_reset()
229 static void vc5_hdmi_reset(struct vc4_hdmi *vc4_hdmi) in vc5_hdmi_reset() argument
231 struct drm_device *drm = vc4_hdmi->connector.dev; in vc5_hdmi_reset()
242 reset_control_reset(vc4_hdmi->reset); in vc5_hdmi_reset()
244 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); in vc5_hdmi_reset()
251 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); in vc5_hdmi_reset()
258 static void vc4_hdmi_cec_update_clk_div(struct vc4_hdmi *vc4_hdmi) in vc4_hdmi_cec_update_clk_div() argument
260 struct drm_device *drm = vc4_hdmi->connector.dev; in vc4_hdmi_cec_update_clk_div()
276 cec_rate = clk_get_rate(vc4_hdmi->cec_clock); in vc4_hdmi_cec_update_clk_div()
278 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_cec_update_clk_div()
291 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_cec_update_clk_div()
297 static void vc4_hdmi_cec_update_clk_div(struct vc4_hdmi *vc4_hdmi) {} in vc4_hdmi_cec_update_clk_div() argument
332 struct vc4_hdmi *vc4_hdmi; in vc4_hdmi_reset_link() local
361 vc4_hdmi = connector_to_vc4_hdmi(connector); in vc4_hdmi_reset_link()
362 mutex_lock(&vc4_hdmi->mutex); in vc4_hdmi_reset_link()
364 if (!vc4_hdmi_supports_scrambling(vc4_hdmi)) { in vc4_hdmi_reset_link()
365 mutex_unlock(&vc4_hdmi->mutex); in vc4_hdmi_reset_link()
369 scrambling_needed = vc4_hdmi_mode_needs_scrambling(&vc4_hdmi->saved_adjusted_mode, in vc4_hdmi_reset_link()
370 vc4_hdmi->output_bpc, in vc4_hdmi_reset_link()
371 vc4_hdmi->output_format); in vc4_hdmi_reset_link()
373 mutex_unlock(&vc4_hdmi->mutex); in vc4_hdmi_reset_link()
379 mutex_unlock(&vc4_hdmi->mutex); in vc4_hdmi_reset_link()
386 mutex_unlock(&vc4_hdmi->mutex); in vc4_hdmi_reset_link()
391 mutex_unlock(&vc4_hdmi->mutex); in vc4_hdmi_reset_link()
395 mutex_unlock(&vc4_hdmi->mutex); in vc4_hdmi_reset_link()
409 static void vc4_hdmi_handle_hotplug(struct vc4_hdmi *vc4_hdmi, in vc4_hdmi_handle_hotplug() argument
413 struct drm_connector *connector = &vc4_hdmi->connector; in vc4_hdmi_handle_hotplug()
433 cec_phys_addr_invalidate(vc4_hdmi->cec_adap); in vc4_hdmi_handle_hotplug()
437 edid = drm_get_edid(connector, vc4_hdmi->ddc); in vc4_hdmi_handle_hotplug()
441 cec_s_phys_addr_from_edid(vc4_hdmi->cec_adap, edid); in vc4_hdmi_handle_hotplug()
459 struct vc4_hdmi *vc4_hdmi = connector_to_vc4_hdmi(connector); in vc4_hdmi_connector_detect_ctx() local
474 ret = pm_runtime_resume_and_get(&vc4_hdmi->pdev->dev); in vc4_hdmi_connector_detect_ctx()
481 if (vc4_hdmi->hpd_gpio) { in vc4_hdmi_connector_detect_ctx()
482 if (gpiod_get_value_cansleep(vc4_hdmi->hpd_gpio)) in vc4_hdmi_connector_detect_ctx()
485 if (vc4_hdmi->variant->hp_detect && in vc4_hdmi_connector_detect_ctx()
486 vc4_hdmi->variant->hp_detect(vc4_hdmi)) in vc4_hdmi_connector_detect_ctx()
490 vc4_hdmi_handle_hotplug(vc4_hdmi, ctx, status); in vc4_hdmi_connector_detect_ctx()
491 pm_runtime_put(&vc4_hdmi->pdev->dev); in vc4_hdmi_connector_detect_ctx()
498 struct vc4_hdmi *vc4_hdmi = connector_to_vc4_hdmi(connector); in vc4_hdmi_connector_get_modes() local
514 edid = drm_get_edid(connector, vc4_hdmi->ddc); in vc4_hdmi_connector_get_modes()
515 cec_s_phys_addr_from_edid(vc4_hdmi->cec_adap, edid); in vc4_hdmi_connector_get_modes()
601 struct vc4_hdmi *vc4_hdmi = in vc4_hdmi_connector_get_property() local
606 if (property == vc4_hdmi->broadcast_rgb_property) { in vc4_hdmi_connector_get_property()
623 struct vc4_hdmi *vc4_hdmi = in vc4_hdmi_connector_set_property() local
628 if (property == vc4_hdmi->broadcast_rgb_property) { in vc4_hdmi_connector_set_property()
704 struct vc4_hdmi *vc4_hdmi) in vc4_hdmi_attach_broadcast_rgb_property() argument
706 struct drm_property *prop = vc4_hdmi->broadcast_rgb_property; in vc4_hdmi_attach_broadcast_rgb_property()
716 vc4_hdmi->broadcast_rgb_property = prop; in vc4_hdmi_attach_broadcast_rgb_property()
719 drm_object_attach_property(&vc4_hdmi->connector.base, prop, in vc4_hdmi_attach_broadcast_rgb_property()
724 struct vc4_hdmi *vc4_hdmi) in vc4_hdmi_connector_init() argument
726 struct drm_connector *connector = &vc4_hdmi->connector; in vc4_hdmi_connector_init()
727 struct drm_encoder *encoder = &vc4_hdmi->encoder.base; in vc4_hdmi_connector_init()
733 vc4_hdmi->ddc); in vc4_hdmi_connector_init()
766 if (vc4_hdmi->variant->supports_hdr) in vc4_hdmi_connector_init()
769 vc4_hdmi_attach_broadcast_rgb_property(dev, vc4_hdmi); in vc4_hdmi_connector_init()
780 struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); in vc4_hdmi_stop_packet() local
781 struct drm_device *drm = vc4_hdmi->connector.dev; in vc4_hdmi_stop_packet()
790 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_stop_packet()
793 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_stop_packet()
807 struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); in vc4_hdmi_write_infoframe() local
808 struct drm_device *drm = vc4_hdmi->connector.dev; in vc4_hdmi_write_infoframe()
811 &vc4_hdmi->variant->registers[HDMI_RAM_PACKET_START]; in vc4_hdmi_write_infoframe()
815 void __iomem *base = __vc4_hdmi_get_field_base(vc4_hdmi, in vc4_hdmi_write_infoframe()
840 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_write_infoframe()
867 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_write_infoframe()
905 struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); in vc4_hdmi_set_avi_infoframe() local
906 struct drm_connector *connector = &vc4_hdmi->connector; in vc4_hdmi_set_avi_infoframe()
910 const struct drm_display_mode *mode = &vc4_hdmi->saved_adjusted_mode; in vc4_hdmi_set_avi_infoframe()
914 lockdep_assert_held(&vc4_hdmi->mutex); in vc4_hdmi_set_avi_infoframe()
925 vc4_hdmi_is_full_range(vc4_hdmi, vc4_state) ? in vc4_hdmi_set_avi_infoframe()
953 struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); in vc4_hdmi_set_audio_infoframe() local
954 struct hdmi_audio_infoframe *audio = &vc4_hdmi->audio.infoframe; in vc4_hdmi_set_audio_infoframe()
959 if (vc4_hdmi->packet_ram_enabled) in vc4_hdmi_set_audio_infoframe()
965 struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); in vc4_hdmi_set_hdr_infoframe() local
966 struct drm_connector *connector = &vc4_hdmi->connector; in vc4_hdmi_set_hdr_infoframe()
970 lockdep_assert_held(&vc4_hdmi->mutex); in vc4_hdmi_set_hdr_infoframe()
972 if (!vc4_hdmi->variant->supports_hdr) in vc4_hdmi_set_hdr_infoframe()
986 struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); in vc4_hdmi_set_infoframes() local
988 lockdep_assert_held(&vc4_hdmi->mutex); in vc4_hdmi_set_infoframes()
996 if (vc4_hdmi->audio.streaming) in vc4_hdmi_set_infoframes()
1006 struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); in vc4_hdmi_enable_scrambling() local
1007 struct drm_connector *connector = &vc4_hdmi->connector; in vc4_hdmi_enable_scrambling()
1009 const struct drm_display_mode *mode = &vc4_hdmi->saved_adjusted_mode; in vc4_hdmi_enable_scrambling()
1013 lockdep_assert_held(&vc4_hdmi->mutex); in vc4_hdmi_enable_scrambling()
1015 if (!vc4_hdmi_supports_scrambling(vc4_hdmi)) in vc4_hdmi_enable_scrambling()
1019 vc4_hdmi->output_bpc, in vc4_hdmi_enable_scrambling()
1020 vc4_hdmi->output_format)) in vc4_hdmi_enable_scrambling()
1029 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_enable_scrambling()
1032 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_enable_scrambling()
1036 vc4_hdmi->scdc_enabled = true; in vc4_hdmi_enable_scrambling()
1038 queue_delayed_work(system_wq, &vc4_hdmi->scrambling_work, in vc4_hdmi_enable_scrambling()
1044 struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); in vc4_hdmi_disable_scrambling() local
1045 struct drm_connector *connector = &vc4_hdmi->connector; in vc4_hdmi_disable_scrambling()
1050 lockdep_assert_held(&vc4_hdmi->mutex); in vc4_hdmi_disable_scrambling()
1052 if (!vc4_hdmi->scdc_enabled) in vc4_hdmi_disable_scrambling()
1055 vc4_hdmi->scdc_enabled = false; in vc4_hdmi_disable_scrambling()
1057 if (delayed_work_pending(&vc4_hdmi->scrambling_work)) in vc4_hdmi_disable_scrambling()
1058 cancel_delayed_work_sync(&vc4_hdmi->scrambling_work); in vc4_hdmi_disable_scrambling()
1063 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_disable_scrambling()
1066 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_disable_scrambling()
1076 struct vc4_hdmi *vc4_hdmi = container_of(to_delayed_work(work), in vc4_hdmi_scrambling_wq() local
1077 struct vc4_hdmi, in vc4_hdmi_scrambling_wq()
1079 struct drm_connector *connector = &vc4_hdmi->connector; in vc4_hdmi_scrambling_wq()
1087 queue_delayed_work(system_wq, &vc4_hdmi->scrambling_work, in vc4_hdmi_scrambling_wq()
1094 struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); in vc4_hdmi_encoder_post_crtc_disable() local
1095 struct drm_device *drm = vc4_hdmi->connector.dev; in vc4_hdmi_encoder_post_crtc_disable()
1099 mutex_lock(&vc4_hdmi->mutex); in vc4_hdmi_encoder_post_crtc_disable()
1101 vc4_hdmi->packet_ram_enabled = false; in vc4_hdmi_encoder_post_crtc_disable()
1106 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_encoder_post_crtc_disable()
1112 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_encoder_post_crtc_disable()
1116 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_encoder_post_crtc_disable()
1119 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_encoder_post_crtc_disable()
1126 mutex_unlock(&vc4_hdmi->mutex); in vc4_hdmi_encoder_post_crtc_disable()
1132 struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); in vc4_hdmi_encoder_post_crtc_powerdown() local
1133 struct drm_device *drm = vc4_hdmi->connector.dev; in vc4_hdmi_encoder_post_crtc_powerdown()
1138 mutex_lock(&vc4_hdmi->mutex); in vc4_hdmi_encoder_post_crtc_powerdown()
1143 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_encoder_post_crtc_powerdown()
1146 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_encoder_post_crtc_powerdown()
1148 if (vc4_hdmi->variant->phy_disable) in vc4_hdmi_encoder_post_crtc_powerdown()
1149 vc4_hdmi->variant->phy_disable(vc4_hdmi); in vc4_hdmi_encoder_post_crtc_powerdown()
1151 clk_disable_unprepare(vc4_hdmi->pixel_bvb_clock); in vc4_hdmi_encoder_post_crtc_powerdown()
1152 clk_disable_unprepare(vc4_hdmi->pixel_clock); in vc4_hdmi_encoder_post_crtc_powerdown()
1154 ret = pm_runtime_put(&vc4_hdmi->pdev->dev); in vc4_hdmi_encoder_post_crtc_powerdown()
1161 mutex_unlock(&vc4_hdmi->mutex); in vc4_hdmi_encoder_post_crtc_powerdown()
1164 static void vc4_hdmi_csc_setup(struct vc4_hdmi *vc4_hdmi, in vc4_hdmi_csc_setup() argument
1170 struct drm_device *drm = vc4_hdmi->connector.dev; in vc4_hdmi_csc_setup()
1178 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_csc_setup()
1183 if (!vc4_hdmi_is_full_range(vc4_hdmi, vc4_state)) { in vc4_hdmi_csc_setup()
1210 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_csc_setup()
1346 static void vc5_hdmi_set_csc_coeffs(struct vc4_hdmi *vc4_hdmi, in vc5_hdmi_set_csc_coeffs() argument
1349 lockdep_assert_held(&vc4_hdmi->hw_lock); in vc5_hdmi_set_csc_coeffs()
1359 static void vc5_hdmi_set_csc_coeffs_swap(struct vc4_hdmi *vc4_hdmi, in vc5_hdmi_set_csc_coeffs_swap() argument
1362 lockdep_assert_held(&vc4_hdmi->hw_lock); in vc5_hdmi_set_csc_coeffs_swap()
1374 (*vc5_hdmi_find_yuv_csc_coeffs(struct vc4_hdmi *vc4_hdmi, u32 colorspace, bool limited))[4] in vc5_hdmi_find_yuv_csc_coeffs() argument
1401 static void vc5_hdmi_csc_setup(struct vc4_hdmi *vc4_hdmi, in vc5_hdmi_csc_setup() argument
1405 struct drm_device *drm = vc4_hdmi->connector.dev; in vc5_hdmi_csc_setup()
1408 unsigned int lim_range = vc4_hdmi_is_full_range(vc4_hdmi, vc4_state) ? 0 : 1; in vc5_hdmi_csc_setup()
1421 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); in vc5_hdmi_csc_setup()
1425 csc = vc5_hdmi_find_yuv_csc_coeffs(vc4_hdmi, state->colorspace, !!lim_range); in vc5_hdmi_csc_setup()
1427 vc5_hdmi_set_csc_coeffs_swap(vc4_hdmi, csc); in vc5_hdmi_csc_setup()
1431 csc = vc5_hdmi_find_yuv_csc_coeffs(vc4_hdmi, state->colorspace, !!lim_range); in vc5_hdmi_csc_setup()
1444 vc5_hdmi_set_csc_coeffs(vc4_hdmi, csc); in vc5_hdmi_csc_setup()
1450 vc5_hdmi_set_csc_coeffs(vc4_hdmi, vc5_hdmi_csc_full_rgb_to_rgb[lim_range]); in vc5_hdmi_csc_setup()
1462 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); in vc5_hdmi_csc_setup()
1467 static void vc4_hdmi_set_timings(struct vc4_hdmi *vc4_hdmi, in vc4_hdmi_set_timings() argument
1471 struct drm_device *drm = vc4_hdmi->connector.dev; in vc4_hdmi_set_timings()
1496 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_set_timings()
1526 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_set_timings()
1531 static void vc5_hdmi_set_timings(struct vc4_hdmi *vc4_hdmi, in vc5_hdmi_set_timings() argument
1535 struct drm_device *drm = vc4_hdmi->connector.dev; in vc5_hdmi_set_timings()
1564 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); in vc5_hdmi_set_timings()
1635 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); in vc5_hdmi_set_timings()
1640 static void vc4_hdmi_recenter_fifo(struct vc4_hdmi *vc4_hdmi) in vc4_hdmi_recenter_fifo() argument
1642 struct drm_device *drm = vc4_hdmi->connector.dev; in vc4_hdmi_recenter_fifo()
1651 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_recenter_fifo()
1661 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_recenter_fifo()
1665 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_recenter_fifo()
1672 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_recenter_fifo()
1685 struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); in vc4_hdmi_encoder_pre_crtc_configure() local
1686 struct drm_device *drm = vc4_hdmi->connector.dev; in vc4_hdmi_encoder_pre_crtc_configure()
1687 struct drm_connector *connector = &vc4_hdmi->connector; in vc4_hdmi_encoder_pre_crtc_configure()
1692 const struct drm_display_mode *mode = &vc4_hdmi->saved_adjusted_mode; in vc4_hdmi_encoder_pre_crtc_configure()
1699 mutex_lock(&vc4_hdmi->mutex); in vc4_hdmi_encoder_pre_crtc_configure()
1704 ret = pm_runtime_resume_and_get(&vc4_hdmi->pdev->dev); in vc4_hdmi_encoder_pre_crtc_configure()
1729 ret = clk_set_min_rate(vc4_hdmi->hsm_clock, hsm_rate); in vc4_hdmi_encoder_pre_crtc_configure()
1735 ret = clk_set_rate(vc4_hdmi->pixel_clock, tmds_char_rate); in vc4_hdmi_encoder_pre_crtc_configure()
1741 ret = clk_prepare_enable(vc4_hdmi->pixel_clock); in vc4_hdmi_encoder_pre_crtc_configure()
1748 vc4_hdmi_cec_update_clk_div(vc4_hdmi); in vc4_hdmi_encoder_pre_crtc_configure()
1757 ret = clk_set_min_rate(vc4_hdmi->pixel_bvb_clock, bvb_rate); in vc4_hdmi_encoder_pre_crtc_configure()
1763 ret = clk_prepare_enable(vc4_hdmi->pixel_bvb_clock); in vc4_hdmi_encoder_pre_crtc_configure()
1769 if (vc4_hdmi->variant->phy_init) in vc4_hdmi_encoder_pre_crtc_configure()
1770 vc4_hdmi->variant->phy_init(vc4_hdmi, vc4_conn_state); in vc4_hdmi_encoder_pre_crtc_configure()
1772 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_encoder_pre_crtc_configure()
1779 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_encoder_pre_crtc_configure()
1781 if (vc4_hdmi->variant->set_timings) in vc4_hdmi_encoder_pre_crtc_configure()
1782 vc4_hdmi->variant->set_timings(vc4_hdmi, conn_state, mode); in vc4_hdmi_encoder_pre_crtc_configure()
1786 mutex_unlock(&vc4_hdmi->mutex); in vc4_hdmi_encoder_pre_crtc_configure()
1791 clk_disable_unprepare(vc4_hdmi->pixel_clock); in vc4_hdmi_encoder_pre_crtc_configure()
1793 pm_runtime_put(&vc4_hdmi->pdev->dev); in vc4_hdmi_encoder_pre_crtc_configure()
1797 mutex_unlock(&vc4_hdmi->mutex); in vc4_hdmi_encoder_pre_crtc_configure()
1804 struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); in vc4_hdmi_encoder_pre_crtc_enable() local
1805 struct drm_device *drm = vc4_hdmi->connector.dev; in vc4_hdmi_encoder_pre_crtc_enable()
1806 struct drm_connector *connector = &vc4_hdmi->connector; in vc4_hdmi_encoder_pre_crtc_enable()
1807 const struct drm_display_mode *mode = &vc4_hdmi->saved_adjusted_mode; in vc4_hdmi_encoder_pre_crtc_enable()
1813 mutex_lock(&vc4_hdmi->mutex); in vc4_hdmi_encoder_pre_crtc_enable()
1818 if (vc4_hdmi->variant->csc_setup) in vc4_hdmi_encoder_pre_crtc_enable()
1819 vc4_hdmi->variant->csc_setup(vc4_hdmi, conn_state, mode); in vc4_hdmi_encoder_pre_crtc_enable()
1821 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_encoder_pre_crtc_enable()
1823 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_encoder_pre_crtc_enable()
1828 mutex_unlock(&vc4_hdmi->mutex); in vc4_hdmi_encoder_pre_crtc_enable()
1834 struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); in vc4_hdmi_encoder_post_crtc_enable() local
1835 struct drm_device *drm = vc4_hdmi->connector.dev; in vc4_hdmi_encoder_post_crtc_enable()
1836 const struct drm_display_mode *mode = &vc4_hdmi->saved_adjusted_mode; in vc4_hdmi_encoder_post_crtc_enable()
1837 struct drm_display_info *display = &vc4_hdmi->connector.display_info; in vc4_hdmi_encoder_post_crtc_enable()
1844 mutex_lock(&vc4_hdmi->mutex); in vc4_hdmi_encoder_post_crtc_enable()
1849 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_encoder_post_crtc_enable()
1867 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_encoder_post_crtc_enable()
1881 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_encoder_post_crtc_enable()
1890 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_encoder_post_crtc_enable()
1898 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_encoder_post_crtc_enable()
1899 vc4_hdmi->packet_ram_enabled = true; in vc4_hdmi_encoder_post_crtc_enable()
1904 vc4_hdmi_recenter_fifo(vc4_hdmi); in vc4_hdmi_encoder_post_crtc_enable()
1910 mutex_unlock(&vc4_hdmi->mutex); in vc4_hdmi_encoder_post_crtc_enable()
1917 struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); in vc4_hdmi_encoder_atomic_mode_set() local
1921 mutex_lock(&vc4_hdmi->mutex); in vc4_hdmi_encoder_atomic_mode_set()
1922 drm_mode_copy(&vc4_hdmi->saved_adjusted_mode, in vc4_hdmi_encoder_atomic_mode_set()
1924 vc4_hdmi->output_bpc = vc4_state->output_bpc; in vc4_hdmi_encoder_atomic_mode_set()
1925 vc4_hdmi->output_format = vc4_state->output_format; in vc4_hdmi_encoder_atomic_mode_set()
1926 mutex_unlock(&vc4_hdmi->mutex); in vc4_hdmi_encoder_atomic_mode_set()
1930 vc4_hdmi_sink_supports_format_bpc(const struct vc4_hdmi *vc4_hdmi, in vc4_hdmi_sink_supports_format_bpc() argument
1935 struct drm_device *dev = vc4_hdmi->connector.dev; in vc4_hdmi_sink_supports_format_bpc()
2014 vc4_hdmi_encoder_clock_valid(const struct vc4_hdmi *vc4_hdmi, in vc4_hdmi_encoder_clock_valid() argument
2018 const struct drm_connector *connector = &vc4_hdmi->connector; in vc4_hdmi_encoder_clock_valid()
2022 if (clock > vc4_hdmi->variant->max_pixel_clock) in vc4_hdmi_encoder_clock_valid()
2060 vc4_hdmi_encoder_compute_clock(const struct vc4_hdmi *vc4_hdmi, in vc4_hdmi_encoder_compute_clock() argument
2068 if (vc4_hdmi_encoder_clock_valid(vc4_hdmi, mode, clock) != MODE_OK) in vc4_hdmi_encoder_compute_clock()
2077 vc4_hdmi_encoder_compute_format(const struct vc4_hdmi *vc4_hdmi, in vc4_hdmi_encoder_compute_format() argument
2082 struct drm_device *dev = vc4_hdmi->connector.dev; in vc4_hdmi_encoder_compute_format()
2083 const struct drm_connector *connector = &vc4_hdmi->connector; in vc4_hdmi_encoder_compute_format()
2090 if (vc4_hdmi_sink_supports_format_bpc(vc4_hdmi, info, mode, format, bpc)) { in vc4_hdmi_encoder_compute_format()
2093 ret = vc4_hdmi_encoder_compute_clock(vc4_hdmi, vc4_state, in vc4_hdmi_encoder_compute_format()
2104 if (vc4_hdmi_sink_supports_format_bpc(vc4_hdmi, info, mode, format, bpc)) { in vc4_hdmi_encoder_compute_format()
2107 ret = vc4_hdmi_encoder_compute_clock(vc4_hdmi, vc4_state, in vc4_hdmi_encoder_compute_format()
2121 vc4_hdmi_encoder_compute_config(const struct vc4_hdmi *vc4_hdmi, in vc4_hdmi_encoder_compute_config() argument
2125 struct drm_device *dev = vc4_hdmi->connector.dev; in vc4_hdmi_encoder_compute_config()
2134 ret = vc4_hdmi_encoder_compute_format(vc4_hdmi, vc4_state, in vc4_hdmi_encoder_compute_config()
2161 struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); in vc4_hdmi_encoder_atomic_check() local
2162 struct drm_connector *connector = &vc4_hdmi->connector; in vc4_hdmi_encoder_atomic_check()
2173 if (vc4_hdmi->variant->unsupported_odd_h_timings) { in vc4_hdmi_encoder_atomic_check()
2200 if (vc4_hdmi->disable_wifi_frequencies && in vc4_hdmi_encoder_atomic_check()
2207 ret = vc4_hdmi_encoder_compute_config(vc4_hdmi, vc4_state, mode); in vc4_hdmi_encoder_atomic_check()
2223 struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); in vc4_hdmi_encoder_mode_valid() local
2225 if (vc4_hdmi->variant->unsupported_odd_h_timings && in vc4_hdmi_encoder_mode_valid()
2231 return vc4_hdmi_encoder_clock_valid(vc4_hdmi, mode, mode->clock * 1000); in vc4_hdmi_encoder_mode_valid()
2243 struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); in vc4_hdmi_late_register() local
2244 const struct vc4_hdmi_variant *variant = vc4_hdmi->variant; in vc4_hdmi_late_register()
2247 vc4_hdmi_debugfs_regs, vc4_hdmi); in vc4_hdmi_late_register()
2256 static u32 vc4_hdmi_channel_map(struct vc4_hdmi *vc4_hdmi, u32 channel_mask) in vc4_hdmi_channel_map() argument
2268 static u32 vc5_hdmi_channel_map(struct vc4_hdmi *vc4_hdmi, u32 channel_mask) in vc5_hdmi_channel_map() argument
2280 static bool vc5_hdmi_hp_detect(struct vc4_hdmi *vc4_hdmi) in vc5_hdmi_hp_detect() argument
2282 struct drm_device *drm = vc4_hdmi->connector.dev; in vc5_hdmi_hp_detect()
2290 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); in vc5_hdmi_hp_detect()
2292 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); in vc5_hdmi_hp_detect()
2300 static void vc4_hdmi_audio_set_mai_clock(struct vc4_hdmi *vc4_hdmi, in vc4_hdmi_audio_set_mai_clock() argument
2303 struct drm_device *drm = vc4_hdmi->connector.dev; in vc4_hdmi_audio_set_mai_clock()
2312 hsm_clock = clk_get_rate(vc4_hdmi->audio_clock); in vc4_hdmi_audio_set_mai_clock()
2320 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_audio_set_mai_clock()
2324 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_audio_set_mai_clock()
2329 static void vc4_hdmi_set_n_cts(struct vc4_hdmi *vc4_hdmi, unsigned int samplerate) in vc4_hdmi_set_n_cts() argument
2331 const struct drm_display_mode *mode = &vc4_hdmi->saved_adjusted_mode; in vc4_hdmi_set_n_cts()
2335 lockdep_assert_held(&vc4_hdmi->mutex); in vc4_hdmi_set_n_cts()
2336 lockdep_assert_held(&vc4_hdmi->hw_lock); in vc4_hdmi_set_n_cts()
2356 static inline struct vc4_hdmi *dai_to_hdmi(struct snd_soc_dai *dai) in dai_to_hdmi()
2363 static bool vc4_hdmi_audio_can_stream(struct vc4_hdmi *vc4_hdmi) in vc4_hdmi_audio_can_stream() argument
2365 struct drm_display_info *display = &vc4_hdmi->connector.display_info; in vc4_hdmi_audio_can_stream()
2367 lockdep_assert_held(&vc4_hdmi->mutex); in vc4_hdmi_audio_can_stream()
2381 struct vc4_hdmi *vc4_hdmi = dev_get_drvdata(dev); in vc4_hdmi_audio_startup() local
2382 struct drm_device *drm = vc4_hdmi->connector.dev; in vc4_hdmi_audio_startup()
2387 mutex_lock(&vc4_hdmi->mutex); in vc4_hdmi_audio_startup()
2394 if (!vc4_hdmi_audio_can_stream(vc4_hdmi)) { in vc4_hdmi_audio_startup()
2399 vc4_hdmi->audio.streaming = true; in vc4_hdmi_audio_startup()
2401 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_audio_startup()
2408 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_audio_startup()
2410 if (vc4_hdmi->variant->phy_rng_enable) in vc4_hdmi_audio_startup()
2411 vc4_hdmi->variant->phy_rng_enable(vc4_hdmi); in vc4_hdmi_audio_startup()
2416 mutex_unlock(&vc4_hdmi->mutex); in vc4_hdmi_audio_startup()
2421 static void vc4_hdmi_audio_reset(struct vc4_hdmi *vc4_hdmi) in vc4_hdmi_audio_reset() argument
2423 struct drm_encoder *encoder = &vc4_hdmi->encoder.base; in vc4_hdmi_audio_reset()
2424 struct device *dev = &vc4_hdmi->pdev->dev; in vc4_hdmi_audio_reset()
2428 lockdep_assert_held(&vc4_hdmi->mutex); in vc4_hdmi_audio_reset()
2430 vc4_hdmi->audio.streaming = false; in vc4_hdmi_audio_reset()
2435 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_audio_reset()
2441 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_audio_reset()
2446 struct vc4_hdmi *vc4_hdmi = dev_get_drvdata(dev); in vc4_hdmi_audio_shutdown() local
2447 struct drm_device *drm = vc4_hdmi->connector.dev; in vc4_hdmi_audio_shutdown()
2451 mutex_lock(&vc4_hdmi->mutex); in vc4_hdmi_audio_shutdown()
2456 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_audio_shutdown()
2463 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_audio_shutdown()
2465 if (vc4_hdmi->variant->phy_rng_disable) in vc4_hdmi_audio_shutdown()
2466 vc4_hdmi->variant->phy_rng_disable(vc4_hdmi); in vc4_hdmi_audio_shutdown()
2468 vc4_hdmi->audio.streaming = false; in vc4_hdmi_audio_shutdown()
2469 vc4_hdmi_audio_reset(vc4_hdmi); in vc4_hdmi_audio_shutdown()
2474 mutex_unlock(&vc4_hdmi->mutex); in vc4_hdmi_audio_shutdown()
2520 struct vc4_hdmi *vc4_hdmi = dev_get_drvdata(dev); in vc4_hdmi_audio_prepare() local
2521 struct drm_device *drm = vc4_hdmi->connector.dev; in vc4_hdmi_audio_prepare()
2522 struct drm_encoder *encoder = &vc4_hdmi->encoder.base; in vc4_hdmi_audio_prepare()
2536 mutex_lock(&vc4_hdmi->mutex); in vc4_hdmi_audio_prepare()
2543 if (!vc4_hdmi_audio_can_stream(vc4_hdmi)) { in vc4_hdmi_audio_prepare()
2548 vc4_hdmi_audio_set_mai_clock(vc4_hdmi, sample_rate); in vc4_hdmi_audio_prepare()
2550 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_audio_prepare()
2591 channel_map = vc4_hdmi->variant->channel_map(vc4_hdmi, channel_mask); in vc4_hdmi_audio_prepare()
2595 vc4_hdmi_set_n_cts(vc4_hdmi, sample_rate); in vc4_hdmi_audio_prepare()
2597 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_audio_prepare()
2599 memcpy(&vc4_hdmi->audio.infoframe, &params->cea, sizeof(params->cea)); in vc4_hdmi_audio_prepare()
2605 mutex_unlock(&vc4_hdmi->mutex); in vc4_hdmi_audio_prepare()
2617 struct vc4_hdmi *vc4_hdmi = dai_to_hdmi(dai); in vc4_hdmi_audio_cpu_dai_probe() local
2619 snd_soc_dai_init_dma_data(dai, &vc4_hdmi->audio.dma_data, NULL); in vc4_hdmi_audio_cpu_dai_probe()
2651 struct vc4_hdmi *vc4_hdmi = dev_get_drvdata(dev); in vc4_hdmi_audio_get_eld() local
2652 struct drm_connector *connector = &vc4_hdmi->connector; in vc4_hdmi_audio_get_eld()
2654 mutex_lock(&vc4_hdmi->mutex); in vc4_hdmi_audio_get_eld()
2656 mutex_unlock(&vc4_hdmi->mutex); in vc4_hdmi_audio_get_eld()
2676 struct vc4_hdmi *vc4_hdmi = ptr; in vc4_hdmi_audio_codec_release() local
2678 platform_device_unregister(vc4_hdmi->audio.codec_pdev); in vc4_hdmi_audio_codec_release()
2679 vc4_hdmi->audio.codec_pdev = NULL; in vc4_hdmi_audio_codec_release()
2682 static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi) in vc4_hdmi_audio_init() argument
2685 &vc4_hdmi->variant->registers[HDMI_MAI_DATA]; in vc4_hdmi_audio_init()
2686 struct snd_soc_dai_link *dai_link = &vc4_hdmi->audio.link; in vc4_hdmi_audio_init()
2687 struct snd_soc_card *card = &vc4_hdmi->audio.card; in vc4_hdmi_audio_init()
2688 struct device *dev = &vc4_hdmi->pdev->dev; in vc4_hdmi_audio_init()
2712 BUILD_BUG_ON(offsetof(struct vc4_hdmi, audio) != 0); in vc4_hdmi_audio_init()
2741 vc4_hdmi->audio.dma_data.addr = be32_to_cpup(addr) + mai_data->offset; in vc4_hdmi_audio_init()
2742 vc4_hdmi->audio.dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; in vc4_hdmi_audio_init()
2743 vc4_hdmi->audio.dma_data.maxburst = 2; in vc4_hdmi_audio_init()
2790 vc4_hdmi->audio.codec_pdev = codec_pdev; in vc4_hdmi_audio_init()
2792 ret = devm_add_action_or_reset(dev, vc4_hdmi_audio_codec_release, vc4_hdmi); in vc4_hdmi_audio_init()
2796 dai_link->cpus = &vc4_hdmi->audio.cpu; in vc4_hdmi_audio_init()
2797 dai_link->codecs = &vc4_hdmi->audio.codec; in vc4_hdmi_audio_init()
2798 dai_link->platforms = &vc4_hdmi->audio.platform; in vc4_hdmi_audio_init()
2813 card->name = vc4_hdmi->variant->card_name; in vc4_hdmi_audio_init()
2825 snd_soc_card_set_drvdata(card, vc4_hdmi); in vc4_hdmi_audio_init()
2836 struct vc4_hdmi *vc4_hdmi = priv; in vc4_hdmi_hpd_irq_thread() local
2837 struct drm_connector *connector = &vc4_hdmi->connector; in vc4_hdmi_hpd_irq_thread()
2846 static int vc4_hdmi_hotplug_init(struct vc4_hdmi *vc4_hdmi) in vc4_hdmi_hotplug_init() argument
2848 struct drm_connector *connector = &vc4_hdmi->connector; in vc4_hdmi_hotplug_init()
2849 struct platform_device *pdev = vc4_hdmi->pdev; in vc4_hdmi_hotplug_init()
2852 if (vc4_hdmi->variant->external_irq_controller) { in vc4_hdmi_hotplug_init()
2859 "vc4 hdmi hpd connected", vc4_hdmi); in vc4_hdmi_hotplug_init()
2866 "vc4 hdmi hpd disconnected", vc4_hdmi); in vc4_hdmi_hotplug_init()
2879 struct vc4_hdmi *vc4_hdmi = priv; in vc4_cec_irq_handler_rx_thread() local
2881 if (vc4_hdmi->cec_rx_msg.len) in vc4_cec_irq_handler_rx_thread()
2882 cec_received_msg(vc4_hdmi->cec_adap, in vc4_cec_irq_handler_rx_thread()
2883 &vc4_hdmi->cec_rx_msg); in vc4_cec_irq_handler_rx_thread()
2890 struct vc4_hdmi *vc4_hdmi = priv; in vc4_cec_irq_handler_tx_thread() local
2892 if (vc4_hdmi->cec_tx_ok) { in vc4_cec_irq_handler_tx_thread()
2893 cec_transmit_done(vc4_hdmi->cec_adap, CEC_TX_STATUS_OK, in vc4_cec_irq_handler_tx_thread()
2900 cec_transmit_done(vc4_hdmi->cec_adap, CEC_TX_STATUS_NACK, in vc4_cec_irq_handler_tx_thread()
2908 struct vc4_hdmi *vc4_hdmi = priv; in vc4_cec_irq_handler_thread() local
2911 if (vc4_hdmi->cec_irq_was_rx) in vc4_cec_irq_handler_thread()
2919 static void vc4_cec_read_msg(struct vc4_hdmi *vc4_hdmi, u32 cntrl1) in vc4_cec_read_msg() argument
2921 struct drm_device *dev = vc4_hdmi->connector.dev; in vc4_cec_read_msg()
2922 struct cec_msg *msg = &vc4_hdmi->cec_rx_msg; in vc4_cec_read_msg()
2925 lockdep_assert_held(&vc4_hdmi->hw_lock); in vc4_cec_read_msg()
2945 static irqreturn_t vc4_cec_irq_handler_tx_bare_locked(struct vc4_hdmi *vc4_hdmi) in vc4_cec_irq_handler_tx_bare_locked() argument
2960 lockdep_assert_held(&vc4_hdmi->hw_lock); in vc4_cec_irq_handler_tx_bare_locked()
2963 vc4_hdmi->cec_tx_ok = cntrl1 & VC4_HDMI_CEC_TX_STATUS_GOOD; in vc4_cec_irq_handler_tx_bare_locked()
2972 struct vc4_hdmi *vc4_hdmi = priv; in vc4_cec_irq_handler_tx_bare() local
2975 spin_lock(&vc4_hdmi->hw_lock); in vc4_cec_irq_handler_tx_bare()
2976 ret = vc4_cec_irq_handler_tx_bare_locked(vc4_hdmi); in vc4_cec_irq_handler_tx_bare()
2977 spin_unlock(&vc4_hdmi->hw_lock); in vc4_cec_irq_handler_tx_bare()
2982 static irqreturn_t vc4_cec_irq_handler_rx_bare_locked(struct vc4_hdmi *vc4_hdmi) in vc4_cec_irq_handler_rx_bare_locked() argument
2986 lockdep_assert_held(&vc4_hdmi->hw_lock); in vc4_cec_irq_handler_rx_bare_locked()
2999 vc4_hdmi->cec_rx_msg.len = 0; in vc4_cec_irq_handler_rx_bare_locked()
3001 vc4_cec_read_msg(vc4_hdmi, cntrl1); in vc4_cec_irq_handler_rx_bare_locked()
3013 struct vc4_hdmi *vc4_hdmi = priv; in vc4_cec_irq_handler_rx_bare() local
3016 spin_lock(&vc4_hdmi->hw_lock); in vc4_cec_irq_handler_rx_bare()
3017 ret = vc4_cec_irq_handler_rx_bare_locked(vc4_hdmi); in vc4_cec_irq_handler_rx_bare()
3018 spin_unlock(&vc4_hdmi->hw_lock); in vc4_cec_irq_handler_rx_bare()
3025 struct vc4_hdmi *vc4_hdmi = priv; in vc4_cec_irq_handler() local
3044 spin_lock(&vc4_hdmi->hw_lock); in vc4_cec_irq_handler()
3046 vc4_hdmi->cec_irq_was_rx = cntrl5 & VC4_HDMI_CEC_RX_CEC_INT; in vc4_cec_irq_handler()
3047 if (vc4_hdmi->cec_irq_was_rx) in vc4_cec_irq_handler()
3048 ret = vc4_cec_irq_handler_rx_bare_locked(vc4_hdmi); in vc4_cec_irq_handler()
3050 ret = vc4_cec_irq_handler_tx_bare_locked(vc4_hdmi); in vc4_cec_irq_handler()
3053 spin_unlock(&vc4_hdmi->hw_lock); in vc4_cec_irq_handler()
3060 struct vc4_hdmi *vc4_hdmi = cec_get_drvdata(adap); in vc4_hdmi_cec_enable() local
3061 struct drm_device *drm = vc4_hdmi->connector.dev; in vc4_hdmi_cec_enable()
3077 ret = pm_runtime_resume_and_get(&vc4_hdmi->pdev->dev); in vc4_hdmi_cec_enable()
3083 mutex_lock(&vc4_hdmi->mutex); in vc4_hdmi_cec_enable()
3085 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_cec_enable()
3114 if (!vc4_hdmi->variant->external_irq_controller) in vc4_hdmi_cec_enable()
3117 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_cec_enable()
3119 mutex_unlock(&vc4_hdmi->mutex); in vc4_hdmi_cec_enable()
3127 struct vc4_hdmi *vc4_hdmi = cec_get_drvdata(adap); in vc4_hdmi_cec_disable() local
3128 struct drm_device *drm = vc4_hdmi->connector.dev; in vc4_hdmi_cec_disable()
3140 mutex_lock(&vc4_hdmi->mutex); in vc4_hdmi_cec_disable()
3142 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_cec_disable()
3144 if (!vc4_hdmi->variant->external_irq_controller) in vc4_hdmi_cec_disable()
3150 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_cec_disable()
3152 mutex_unlock(&vc4_hdmi->mutex); in vc4_hdmi_cec_disable()
3154 pm_runtime_put(&vc4_hdmi->pdev->dev); in vc4_hdmi_cec_disable()
3171 struct vc4_hdmi *vc4_hdmi = cec_get_drvdata(adap); in vc4_hdmi_cec_adap_log_addr() local
3172 struct drm_device *drm = vc4_hdmi->connector.dev; in vc4_hdmi_cec_adap_log_addr()
3184 mutex_lock(&vc4_hdmi->mutex); in vc4_hdmi_cec_adap_log_addr()
3185 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_cec_adap_log_addr()
3189 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_cec_adap_log_addr()
3190 mutex_unlock(&vc4_hdmi->mutex); in vc4_hdmi_cec_adap_log_addr()
3200 struct vc4_hdmi *vc4_hdmi = cec_get_drvdata(adap); in vc4_hdmi_cec_adap_transmit() local
3201 struct drm_device *dev = vc4_hdmi->connector.dev; in vc4_hdmi_cec_adap_transmit()
3216 mutex_lock(&vc4_hdmi->mutex); in vc4_hdmi_cec_adap_transmit()
3218 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_cec_adap_transmit()
3236 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_cec_adap_transmit()
3237 mutex_unlock(&vc4_hdmi->mutex); in vc4_hdmi_cec_adap_transmit()
3251 struct vc4_hdmi *vc4_hdmi = ptr; in vc4_hdmi_cec_release() local
3253 cec_unregister_adapter(vc4_hdmi->cec_adap); in vc4_hdmi_cec_release()
3254 vc4_hdmi->cec_adap = NULL; in vc4_hdmi_cec_release()
3257 static int vc4_hdmi_cec_init(struct vc4_hdmi *vc4_hdmi) in vc4_hdmi_cec_init() argument
3260 struct platform_device *pdev = vc4_hdmi->pdev; in vc4_hdmi_cec_init()
3269 vc4_hdmi->cec_adap = cec_allocate_adapter(&vc4_hdmi_cec_adap_ops, in vc4_hdmi_cec_init()
3270 vc4_hdmi, in vc4_hdmi_cec_init()
3271 vc4_hdmi->variant->card_name, in vc4_hdmi_cec_init()
3274 ret = PTR_ERR_OR_ZERO(vc4_hdmi->cec_adap); in vc4_hdmi_cec_init()
3278 cec_fill_conn_info_from_drm(&conn_info, &vc4_hdmi->connector); in vc4_hdmi_cec_init()
3279 cec_s_conn_info(vc4_hdmi->cec_adap, &conn_info); in vc4_hdmi_cec_init()
3281 if (vc4_hdmi->variant->external_irq_controller) { in vc4_hdmi_cec_init()
3285 "vc4 hdmi cec rx", vc4_hdmi); in vc4_hdmi_cec_init()
3292 "vc4 hdmi cec tx", vc4_hdmi); in vc4_hdmi_cec_init()
3299 "vc4 hdmi cec", vc4_hdmi); in vc4_hdmi_cec_init()
3304 ret = cec_register_adapter(vc4_hdmi->cec_adap, &pdev->dev); in vc4_hdmi_cec_init()
3331 ret = devm_add_action_or_reset(dev, vc4_hdmi_cec_release, vc4_hdmi); in vc4_hdmi_cec_init()
3338 cec_delete_adapter(vc4_hdmi->cec_adap); in vc4_hdmi_cec_init()
3343 static int vc4_hdmi_cec_init(struct vc4_hdmi *vc4_hdmi) in vc4_hdmi_cec_init() argument
3357 struct vc4_hdmi *vc4_hdmi, in vc4_hdmi_build_regset() argument
3361 const struct vc4_hdmi_variant *variant = vc4_hdmi->variant; in vc4_hdmi_build_regset()
3387 regset->base = __vc4_hdmi_get_field_base(vc4_hdmi, reg); in vc4_hdmi_build_regset()
3399 struct vc4_hdmi *vc4_hdmi) in vc4_hdmi_init_resources() argument
3401 struct platform_device *pdev = vc4_hdmi->pdev; in vc4_hdmi_init_resources()
3405 vc4_hdmi->hdmicore_regs = vc4_ioremap_regs(pdev, 0); in vc4_hdmi_init_resources()
3406 if (IS_ERR(vc4_hdmi->hdmicore_regs)) in vc4_hdmi_init_resources()
3407 return PTR_ERR(vc4_hdmi->hdmicore_regs); in vc4_hdmi_init_resources()
3409 vc4_hdmi->hd_regs = vc4_ioremap_regs(pdev, 1); in vc4_hdmi_init_resources()
3410 if (IS_ERR(vc4_hdmi->hd_regs)) in vc4_hdmi_init_resources()
3411 return PTR_ERR(vc4_hdmi->hd_regs); in vc4_hdmi_init_resources()
3413 ret = vc4_hdmi_build_regset(drm, vc4_hdmi, &vc4_hdmi->hd_regset, VC4_HD); in vc4_hdmi_init_resources()
3417 ret = vc4_hdmi_build_regset(drm, vc4_hdmi, &vc4_hdmi->hdmi_regset, VC4_HDMI); in vc4_hdmi_init_resources()
3421 vc4_hdmi->pixel_clock = devm_clk_get(dev, "pixel"); in vc4_hdmi_init_resources()
3422 if (IS_ERR(vc4_hdmi->pixel_clock)) { in vc4_hdmi_init_resources()
3423 ret = PTR_ERR(vc4_hdmi->pixel_clock); in vc4_hdmi_init_resources()
3429 vc4_hdmi->hsm_clock = devm_clk_get(dev, "hdmi"); in vc4_hdmi_init_resources()
3430 if (IS_ERR(vc4_hdmi->hsm_clock)) { in vc4_hdmi_init_resources()
3432 return PTR_ERR(vc4_hdmi->hsm_clock); in vc4_hdmi_init_resources()
3434 vc4_hdmi->audio_clock = vc4_hdmi->hsm_clock; in vc4_hdmi_init_resources()
3435 vc4_hdmi->cec_clock = vc4_hdmi->hsm_clock; in vc4_hdmi_init_resources()
3441 struct vc4_hdmi *vc4_hdmi) in vc5_hdmi_init_resources() argument
3443 struct platform_device *pdev = vc4_hdmi->pdev; in vc5_hdmi_init_resources()
3452 vc4_hdmi->hdmicore_regs = devm_ioremap(dev, res->start, in vc5_hdmi_init_resources()
3454 if (!vc4_hdmi->hdmicore_regs) in vc5_hdmi_init_resources()
3461 vc4_hdmi->hd_regs = devm_ioremap(dev, res->start, resource_size(res)); in vc5_hdmi_init_resources()
3462 if (!vc4_hdmi->hd_regs) in vc5_hdmi_init_resources()
3469 vc4_hdmi->cec_regs = devm_ioremap(dev, res->start, resource_size(res)); in vc5_hdmi_init_resources()
3470 if (!vc4_hdmi->cec_regs) in vc5_hdmi_init_resources()
3477 vc4_hdmi->csc_regs = devm_ioremap(dev, res->start, resource_size(res)); in vc5_hdmi_init_resources()
3478 if (!vc4_hdmi->csc_regs) in vc5_hdmi_init_resources()
3485 vc4_hdmi->dvp_regs = devm_ioremap(dev, res->start, resource_size(res)); in vc5_hdmi_init_resources()
3486 if (!vc4_hdmi->dvp_regs) in vc5_hdmi_init_resources()
3493 vc4_hdmi->phy_regs = devm_ioremap(dev, res->start, resource_size(res)); in vc5_hdmi_init_resources()
3494 if (!vc4_hdmi->phy_regs) in vc5_hdmi_init_resources()
3501 vc4_hdmi->ram_regs = devm_ioremap(dev, res->start, resource_size(res)); in vc5_hdmi_init_resources()
3502 if (!vc4_hdmi->ram_regs) in vc5_hdmi_init_resources()
3509 vc4_hdmi->rm_regs = devm_ioremap(dev, res->start, resource_size(res)); in vc5_hdmi_init_resources()
3510 if (!vc4_hdmi->rm_regs) in vc5_hdmi_init_resources()
3513 vc4_hdmi->hsm_clock = devm_clk_get(dev, "hdmi"); in vc5_hdmi_init_resources()
3514 if (IS_ERR(vc4_hdmi->hsm_clock)) { in vc5_hdmi_init_resources()
3516 return PTR_ERR(vc4_hdmi->hsm_clock); in vc5_hdmi_init_resources()
3519 vc4_hdmi->pixel_bvb_clock = devm_clk_get(dev, "bvb"); in vc5_hdmi_init_resources()
3520 if (IS_ERR(vc4_hdmi->pixel_bvb_clock)) { in vc5_hdmi_init_resources()
3522 return PTR_ERR(vc4_hdmi->pixel_bvb_clock); in vc5_hdmi_init_resources()
3525 vc4_hdmi->audio_clock = devm_clk_get(dev, "audio"); in vc5_hdmi_init_resources()
3526 if (IS_ERR(vc4_hdmi->audio_clock)) { in vc5_hdmi_init_resources()
3528 return PTR_ERR(vc4_hdmi->audio_clock); in vc5_hdmi_init_resources()
3531 vc4_hdmi->cec_clock = devm_clk_get(dev, "cec"); in vc5_hdmi_init_resources()
3532 if (IS_ERR(vc4_hdmi->cec_clock)) { in vc5_hdmi_init_resources()
3534 return PTR_ERR(vc4_hdmi->cec_clock); in vc5_hdmi_init_resources()
3537 vc4_hdmi->reset = devm_reset_control_get(dev, NULL); in vc5_hdmi_init_resources()
3538 if (IS_ERR(vc4_hdmi->reset)) { in vc5_hdmi_init_resources()
3540 return PTR_ERR(vc4_hdmi->reset); in vc5_hdmi_init_resources()
3543 ret = vc4_hdmi_build_regset(drm, vc4_hdmi, &vc4_hdmi->hdmi_regset, VC4_HDMI); in vc5_hdmi_init_resources()
3547 ret = vc4_hdmi_build_regset(drm, vc4_hdmi, &vc4_hdmi->hd_regset, VC4_HD); in vc5_hdmi_init_resources()
3551 ret = vc4_hdmi_build_regset(drm, vc4_hdmi, &vc4_hdmi->cec_regset, VC5_CEC); in vc5_hdmi_init_resources()
3555 ret = vc4_hdmi_build_regset(drm, vc4_hdmi, &vc4_hdmi->csc_regset, VC5_CSC); in vc5_hdmi_init_resources()
3559 ret = vc4_hdmi_build_regset(drm, vc4_hdmi, &vc4_hdmi->dvp_regset, VC5_DVP); in vc5_hdmi_init_resources()
3563 ret = vc4_hdmi_build_regset(drm, vc4_hdmi, &vc4_hdmi->phy_regset, VC5_PHY); in vc5_hdmi_init_resources()
3567 ret = vc4_hdmi_build_regset(drm, vc4_hdmi, &vc4_hdmi->ram_regset, VC5_RAM); in vc5_hdmi_init_resources()
3571 ret = vc4_hdmi_build_regset(drm, vc4_hdmi, &vc4_hdmi->rm_regset, VC5_RM); in vc5_hdmi_init_resources()
3580 struct vc4_hdmi *vc4_hdmi = dev_get_drvdata(dev); in vc4_hdmi_runtime_suspend() local
3582 clk_disable_unprepare(vc4_hdmi->hsm_clock); in vc4_hdmi_runtime_suspend()
3589 struct vc4_hdmi *vc4_hdmi = dev_get_drvdata(dev); in vc4_hdmi_runtime_resume() local
3595 ret = clk_prepare_enable(vc4_hdmi->hsm_clock); in vc4_hdmi_runtime_resume()
3608 rate = clk_get_rate(vc4_hdmi->hsm_clock); in vc4_hdmi_runtime_resume()
3614 if (vc4_hdmi->variant->reset) in vc4_hdmi_runtime_resume()
3615 vc4_hdmi->variant->reset(vc4_hdmi); in vc4_hdmi_runtime_resume()
3618 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_runtime_resume()
3623 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_runtime_resume()
3625 vc4_hdmi_cec_update_clk_div(vc4_hdmi); in vc4_hdmi_runtime_resume()
3627 if (!vc4_hdmi->variant->external_irq_controller) { in vc4_hdmi_runtime_resume()
3628 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_runtime_resume()
3630 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); in vc4_hdmi_runtime_resume()
3637 clk_disable_unprepare(vc4_hdmi->hsm_clock); in vc4_hdmi_runtime_resume()
3643 struct vc4_hdmi *vc4_hdmi = ptr; in vc4_hdmi_put_ddc_device() local
3645 put_device(&vc4_hdmi->ddc->dev); in vc4_hdmi_put_ddc_device()
3653 struct vc4_hdmi *vc4_hdmi; in vc4_hdmi_bind() local
3658 vc4_hdmi = drmm_kzalloc(drm, sizeof(*vc4_hdmi), GFP_KERNEL); in vc4_hdmi_bind()
3659 if (!vc4_hdmi) in vc4_hdmi_bind()
3662 ret = drmm_mutex_init(drm, &vc4_hdmi->mutex); in vc4_hdmi_bind()
3666 spin_lock_init(&vc4_hdmi->hw_lock); in vc4_hdmi_bind()
3667 INIT_DELAYED_WORK(&vc4_hdmi->scrambling_work, vc4_hdmi_scrambling_wq); in vc4_hdmi_bind()
3669 dev_set_drvdata(dev, vc4_hdmi); in vc4_hdmi_bind()
3670 encoder = &vc4_hdmi->encoder.base; in vc4_hdmi_bind()
3671 vc4_hdmi->encoder.type = variant->encoder_type; in vc4_hdmi_bind()
3672 vc4_hdmi->encoder.pre_crtc_configure = vc4_hdmi_encoder_pre_crtc_configure; in vc4_hdmi_bind()
3673 vc4_hdmi->encoder.pre_crtc_enable = vc4_hdmi_encoder_pre_crtc_enable; in vc4_hdmi_bind()
3674 vc4_hdmi->encoder.post_crtc_enable = vc4_hdmi_encoder_post_crtc_enable; in vc4_hdmi_bind()
3675 vc4_hdmi->encoder.post_crtc_disable = vc4_hdmi_encoder_post_crtc_disable; in vc4_hdmi_bind()
3676 vc4_hdmi->encoder.post_crtc_powerdown = vc4_hdmi_encoder_post_crtc_powerdown; in vc4_hdmi_bind()
3677 vc4_hdmi->pdev = pdev; in vc4_hdmi_bind()
3678 vc4_hdmi->variant = variant; in vc4_hdmi_bind()
3687 vc4_hdmi->scdc_enabled = true; in vc4_hdmi_bind()
3689 ret = variant->init_resources(drm, vc4_hdmi); in vc4_hdmi_bind()
3699 vc4_hdmi->ddc = of_find_i2c_adapter_by_node(ddc_node); in vc4_hdmi_bind()
3701 if (!vc4_hdmi->ddc) { in vc4_hdmi_bind()
3706 ret = devm_add_action_or_reset(dev, vc4_hdmi_put_ddc_device, vc4_hdmi); in vc4_hdmi_bind()
3713 vc4_hdmi->hpd_gpio = devm_gpiod_get_optional(dev, "hpd", GPIOD_IN); in vc4_hdmi_bind()
3714 if (IS_ERR(vc4_hdmi->hpd_gpio)) { in vc4_hdmi_bind()
3715 return PTR_ERR(vc4_hdmi->hpd_gpio); in vc4_hdmi_bind()
3718 vc4_hdmi->disable_wifi_frequencies = in vc4_hdmi_bind()
3736 clk_prepare_enable(vc4_hdmi->pixel_clock); in vc4_hdmi_bind()
3737 clk_prepare_enable(vc4_hdmi->hsm_clock); in vc4_hdmi_bind()
3738 clk_prepare_enable(vc4_hdmi->pixel_bvb_clock); in vc4_hdmi_bind()
3750 ret = vc4_hdmi_connector_init(drm, vc4_hdmi); in vc4_hdmi_bind()
3754 ret = vc4_hdmi_hotplug_init(vc4_hdmi); in vc4_hdmi_bind()
3758 ret = vc4_hdmi_cec_init(vc4_hdmi); in vc4_hdmi_bind()
3762 ret = vc4_hdmi_audio_init(vc4_hdmi); in vc4_hdmi_bind()