Lines Matching refs:hdmi
27 #include <sound/omap-hdmi-audio.h>
37 #include "hdmi.h"
39 static int hdmi_runtime_get(struct omap_hdmi *hdmi)
45 r = pm_runtime_get_sync(&hdmi->pdev->dev);
53 static void hdmi_runtime_put(struct omap_hdmi *hdmi)
59 r = pm_runtime_put_sync(&hdmi->pdev->dev);
65 struct omap_hdmi *hdmi = data;
66 struct hdmi_wp_data *wp = &hdmi->wp;
92 u32 intr4 = hdmi_read_reg(hdmi->core.base, HDMI_CORE_SYS_INTR4);
94 hdmi_write_reg(hdmi->core.base, HDMI_CORE_SYS_INTR4, intr4);
96 hdmi4_cec_irq(&hdmi->core);
102 static int hdmi_power_on_core(struct omap_hdmi *hdmi)
106 if (hdmi->core.core_pwr_cnt++)
109 r = regulator_enable(hdmi->vdda_reg);
113 r = hdmi_runtime_get(hdmi);
117 hdmi4_core_powerdown_disable(&hdmi->core);
120 dss_select_hdmi_venc_clk_source(hdmi->dss, DSS_HDMI_M_PCLK);
122 hdmi->core_enabled = true;
127 regulator_disable(hdmi->vdda_reg);
129 hdmi->core.core_pwr_cnt--;
134 static void hdmi_power_off_core(struct omap_hdmi *hdmi)
136 if (--hdmi->core.core_pwr_cnt)
139 hdmi->core_enabled = false;
141 hdmi_runtime_put(hdmi);
142 regulator_disable(hdmi->vdda_reg);
145 static int hdmi_power_on_full(struct omap_hdmi *hdmi)
149 struct hdmi_wp_data *wp = &hdmi->wp;
153 r = hdmi_power_on_core(hdmi);
161 vm = &hdmi->cfg.vm;
173 dss_pll_calc_b(&hdmi->pll.pll, clk_get_rate(hdmi->pll.pll.clkin),
176 r = dss_pll_enable(&hdmi->pll.pll);
182 r = dss_pll_set_config(&hdmi->pll.pll, &hdmi_cinfo);
188 r = hdmi_phy_configure(&hdmi->phy, hdmi_cinfo.clkdco,
199 hdmi4_configure(&hdmi->core, &hdmi->wp, &hdmi->cfg);
201 r = dss_mgr_enable(&hdmi->output);
205 r = hdmi_wp_video_start(&hdmi->wp);
215 dss_mgr_disable(&hdmi->output);
217 hdmi_wp_set_phy_pwr(&hdmi->wp, HDMI_PHYPWRCMD_OFF);
221 dss_pll_disable(&hdmi->pll.pll);
223 hdmi_power_off_core(hdmi);
227 static void hdmi_power_off_full(struct omap_hdmi *hdmi)
229 hdmi_wp_clear_irqenable(&hdmi->wp, ~HDMI_IRQ_CORE);
231 hdmi_wp_video_stop(&hdmi->wp);
233 dss_mgr_disable(&hdmi->output);
235 hdmi_wp_set_phy_pwr(&hdmi->wp, HDMI_PHYPWRCMD_OFF);
237 dss_pll_disable(&hdmi->pll.pll);
239 hdmi_power_off_core(hdmi);
244 struct omap_hdmi *hdmi = s->private;
246 mutex_lock(&hdmi->lock);
248 if (hdmi_runtime_get(hdmi)) {
249 mutex_unlock(&hdmi->lock);
253 hdmi_wp_dump(&hdmi->wp, s);
254 hdmi_pll_dump(&hdmi->pll, s);
255 hdmi_phy_dump(&hdmi->phy, s);
256 hdmi4_core_dump(&hdmi->core, s);
258 hdmi_runtime_put(hdmi);
259 mutex_unlock(&hdmi->lock);
277 struct omap_hdmi *hdmi = container_of(core, struct omap_hdmi, core);
282 mutex_lock(&hdmi->lock);
284 r = hdmi_power_on_core(hdmi);
290 mutex_unlock(&hdmi->lock);
294 mutex_unlock(&hdmi->lock);
300 struct omap_hdmi *hdmi = container_of(core, struct omap_hdmi, core);
304 mutex_lock(&hdmi->lock);
306 hdmi_power_off_core(hdmi);
308 mutex_unlock(&hdmi->lock);
318 struct omap_hdmi *hdmi = drm_bridge_to_hdmi(bridge);
323 return drm_bridge_attach(bridge->encoder, hdmi->output.next_bridge,
331 struct omap_hdmi *hdmi = drm_bridge_to_hdmi(bridge);
333 mutex_lock(&hdmi->lock);
335 drm_display_mode_to_videomode(adjusted_mode, &hdmi->cfg.vm);
337 dispc_set_tv_pclk(hdmi->dss->dispc, adjusted_mode->clock * 1000);
339 mutex_unlock(&hdmi->lock);
345 struct omap_hdmi *hdmi = drm_bridge_to_hdmi(bridge);
368 hdmi->cfg.hdmi_dvi_mode = connector->display_info.is_hdmi
379 hdmi->cfg.infoframe = avi;
382 mutex_lock(&hdmi->lock);
384 ret = hdmi_power_on_full(hdmi);
390 if (hdmi->audio_configured) {
391 ret = hdmi4_audio_config(&hdmi->core, &hdmi->wp,
392 &hdmi->audio_config,
393 hdmi->cfg.vm.pixelclock);
396 hdmi->audio_abort_cb(&hdmi->pdev->dev);
397 hdmi->audio_configured = false;
401 spin_lock_irqsave(&hdmi->audio_playing_lock, flags);
402 if (hdmi->audio_configured && hdmi->audio_playing)
403 hdmi_start_audio_stream(hdmi);
404 hdmi->display_enabled = true;
405 spin_unlock_irqrestore(&hdmi->audio_playing_lock, flags);
408 mutex_unlock(&hdmi->lock);
414 struct omap_hdmi *hdmi = drm_bridge_to_hdmi(bridge);
417 mutex_lock(&hdmi->lock);
419 spin_lock_irqsave(&hdmi->audio_playing_lock, flags);
420 hdmi_stop_audio_stream(hdmi);
421 hdmi->display_enabled = false;
422 spin_unlock_irqrestore(&hdmi->audio_playing_lock, flags);
424 hdmi_power_off_full(hdmi);
426 mutex_unlock(&hdmi->lock);
432 struct omap_hdmi *hdmi = drm_bridge_to_hdmi(bridge);
435 hdmi4_cec_set_phys_addr(&hdmi->core, CEC_PHYS_ADDR_INVALID);
441 struct omap_hdmi *hdmi = drm_bridge_to_hdmi(bridge);
447 need_enable = hdmi->core_enabled == false;
450 r = hdmi4_core_enable(&hdmi->core);
455 mutex_lock(&hdmi->lock);
456 r = hdmi_runtime_get(hdmi);
459 r = hdmi4_core_ddc_init(&hdmi->core);
463 edid = drm_do_get_edid(connector, hdmi4_core_ddc_read, &hdmi->core);
466 hdmi_runtime_put(hdmi);
467 mutex_unlock(&hdmi->lock);
477 hdmi4_cec_set_phys_addr(&hdmi->core, cec_addr);
480 hdmi4_core_disable(&hdmi->core);
497 static void hdmi4_bridge_init(struct omap_hdmi *hdmi)
499 hdmi->bridge.funcs = &hdmi4_bridge_funcs;
500 hdmi->bridge.of_node = hdmi->pdev->dev.of_node;
501 hdmi->bridge.ops = DRM_BRIDGE_OP_EDID;
502 hdmi->bridge.type = DRM_MODE_CONNECTOR_HDMIA;
504 drm_bridge_add(&hdmi->bridge);
507 static void hdmi4_bridge_cleanup(struct omap_hdmi *hdmi)
509 drm_bridge_remove(&hdmi->bridge);
611 static int hdmi_audio_register(struct omap_hdmi *hdmi)
614 .dev = &hdmi->pdev->dev,
616 .audio_dma_addr = hdmi_wp_get_audio_dma_addr(&hdmi->wp),
620 hdmi->audio_pdev = platform_device_register_data(
621 &hdmi->pdev->dev, "omap-hdmi-audio", PLATFORM_DEVID_AUTO,
624 if (IS_ERR(hdmi->audio_pdev))
625 return PTR_ERR(hdmi->audio_pdev);
637 struct omap_hdmi *hdmi = dev_get_drvdata(dev);
640 hdmi->dss = dss;
642 r = hdmi_runtime_get(hdmi);
646 r = hdmi_pll_init(dss, hdmi->pdev, &hdmi->pll, &hdmi->wp);
650 r = hdmi4_cec_init(hdmi->pdev, &hdmi->core, &hdmi->wp);
654 r = hdmi_audio_register(hdmi);
660 hdmi->debugfs = dss_debugfs_create_file(dss, "hdmi", hdmi_dump_regs,
661 hdmi);
663 hdmi_runtime_put(hdmi);
668 hdmi4_cec_uninit(&hdmi->core);
670 hdmi_pll_uninit(&hdmi->pll);
672 hdmi_runtime_put(hdmi);
678 struct omap_hdmi *hdmi = dev_get_drvdata(dev);
680 dss_debugfs_remove_file(hdmi->debugfs);
682 if (hdmi->audio_pdev)
683 platform_device_unregister(hdmi->audio_pdev);
685 hdmi4_cec_uninit(&hdmi->core);
686 hdmi_pll_uninit(&hdmi->pll);
698 static int hdmi4_init_output(struct omap_hdmi *hdmi)
700 struct omap_dss_device *out = &hdmi->output;
703 hdmi4_bridge_init(hdmi);
705 out->dev = &hdmi->pdev->dev;
708 out->name = "hdmi.0";
713 r = omapdss_device_init_output(out, &hdmi->bridge);
715 hdmi4_bridge_cleanup(hdmi);
724 static void hdmi4_uninit_output(struct omap_hdmi *hdmi)
726 struct omap_dss_device *out = &hdmi->output;
731 hdmi4_bridge_cleanup(hdmi);
734 static int hdmi4_probe_of(struct omap_hdmi *hdmi)
736 struct platform_device *pdev = hdmi->pdev;
745 r = hdmi_parse_lanes_of(pdev, ep, &hdmi->phy);
752 struct omap_hdmi *hdmi;
756 hdmi = kzalloc(sizeof(*hdmi), GFP_KERNEL);
757 if (!hdmi)
760 hdmi->pdev = pdev;
762 dev_set_drvdata(&pdev->dev, hdmi);
764 mutex_init(&hdmi->lock);
765 spin_lock_init(&hdmi->audio_playing_lock);
767 r = hdmi4_probe_of(hdmi);
771 r = hdmi_wp_init(pdev, &hdmi->wp, 4);
775 r = hdmi_phy_init(pdev, &hdmi->phy, 4);
779 r = hdmi4_core_init(pdev, &hdmi->core);
792 IRQF_ONESHOT, "OMAP HDMI", hdmi);
798 hdmi->vdda_reg = devm_regulator_get(&pdev->dev, "vdda");
799 if (IS_ERR(hdmi->vdda_reg)) {
800 r = PTR_ERR(hdmi->vdda_reg);
808 r = hdmi4_init_output(hdmi);
819 hdmi4_uninit_output(hdmi);
823 kfree(hdmi);
829 struct omap_hdmi *hdmi = platform_get_drvdata(pdev);
833 hdmi4_uninit_output(hdmi);
837 kfree(hdmi);
842 { .compatible = "ti,omap4-hdmi", },