Lines Matching refs:hdmi
27 #include <sound/omap-hdmi-audio.h>
38 #include "hdmi.h"
40 static int hdmi_runtime_get(struct omap_hdmi *hdmi)
46 r = pm_runtime_get_sync(&hdmi->pdev->dev);
48 pm_runtime_put_noidle(&hdmi->pdev->dev);
54 static void hdmi_runtime_put(struct omap_hdmi *hdmi)
60 r = pm_runtime_put_sync(&hdmi->pdev->dev);
66 struct omap_hdmi *hdmi = data;
67 struct hdmi_wp_data *wp = &hdmi->wp;
93 u32 intr4 = hdmi_read_reg(hdmi->core.base, HDMI_CORE_SYS_INTR4);
95 hdmi_write_reg(hdmi->core.base, HDMI_CORE_SYS_INTR4, intr4);
97 hdmi4_cec_irq(&hdmi->core);
103 static int hdmi_power_on_core(struct omap_hdmi *hdmi)
107 if (hdmi->core.core_pwr_cnt++)
110 r = regulator_enable(hdmi->vdda_reg);
114 r = hdmi_runtime_get(hdmi);
118 hdmi4_core_powerdown_disable(&hdmi->core);
121 dss_select_hdmi_venc_clk_source(hdmi->dss, DSS_HDMI_M_PCLK);
123 hdmi->core_enabled = true;
128 regulator_disable(hdmi->vdda_reg);
130 hdmi->core.core_pwr_cnt--;
135 static void hdmi_power_off_core(struct omap_hdmi *hdmi)
137 if (--hdmi->core.core_pwr_cnt)
140 hdmi->core_enabled = false;
142 hdmi_runtime_put(hdmi);
143 regulator_disable(hdmi->vdda_reg);
146 static int hdmi_power_on_full(struct omap_hdmi *hdmi)
150 struct hdmi_wp_data *wp = &hdmi->wp;
154 r = hdmi_power_on_core(hdmi);
162 vm = &hdmi->cfg.vm;
174 dss_pll_calc_b(&hdmi->pll.pll, clk_get_rate(hdmi->pll.pll.clkin),
177 r = dss_pll_enable(&hdmi->pll.pll);
183 r = dss_pll_set_config(&hdmi->pll.pll, &hdmi_cinfo);
189 r = hdmi_phy_configure(&hdmi->phy, hdmi_cinfo.clkdco,
200 hdmi4_configure(&hdmi->core, &hdmi->wp, &hdmi->cfg);
202 r = dss_mgr_enable(&hdmi->output);
206 r = hdmi_wp_video_start(&hdmi->wp);
216 dss_mgr_disable(&hdmi->output);
218 hdmi_wp_set_phy_pwr(&hdmi->wp, HDMI_PHYPWRCMD_OFF);
222 dss_pll_disable(&hdmi->pll.pll);
224 hdmi_power_off_core(hdmi);
228 static void hdmi_power_off_full(struct omap_hdmi *hdmi)
230 hdmi_wp_clear_irqenable(&hdmi->wp, ~HDMI_IRQ_CORE);
232 hdmi_wp_video_stop(&hdmi->wp);
234 dss_mgr_disable(&hdmi->output);
236 hdmi_wp_set_phy_pwr(&hdmi->wp, HDMI_PHYPWRCMD_OFF);
238 dss_pll_disable(&hdmi->pll.pll);
240 hdmi_power_off_core(hdmi);
245 struct omap_hdmi *hdmi = s->private;
247 mutex_lock(&hdmi->lock);
249 if (hdmi_runtime_get(hdmi)) {
250 mutex_unlock(&hdmi->lock);
254 hdmi_wp_dump(&hdmi->wp, s);
255 hdmi_pll_dump(&hdmi->pll, s);
256 hdmi_phy_dump(&hdmi->phy, s);
257 hdmi4_core_dump(&hdmi->core, s);
259 hdmi_runtime_put(hdmi);
260 mutex_unlock(&hdmi->lock);
278 struct omap_hdmi *hdmi = container_of(core, struct omap_hdmi, core);
283 mutex_lock(&hdmi->lock);
285 r = hdmi_power_on_core(hdmi);
291 mutex_unlock(&hdmi->lock);
295 mutex_unlock(&hdmi->lock);
301 struct omap_hdmi *hdmi = container_of(core, struct omap_hdmi, core);
305 mutex_lock(&hdmi->lock);
307 hdmi_power_off_core(hdmi);
309 mutex_unlock(&hdmi->lock);
319 struct omap_hdmi *hdmi = drm_bridge_to_hdmi(bridge);
324 return drm_bridge_attach(bridge->encoder, hdmi->output.next_bridge,
332 struct omap_hdmi *hdmi = drm_bridge_to_hdmi(bridge);
334 mutex_lock(&hdmi->lock);
336 drm_display_mode_to_videomode(adjusted_mode, &hdmi->cfg.vm);
338 dispc_set_tv_pclk(hdmi->dss->dispc, adjusted_mode->clock * 1000);
340 mutex_unlock(&hdmi->lock);
346 struct omap_hdmi *hdmi = drm_bridge_to_hdmi(bridge);
369 hdmi->cfg.hdmi_dvi_mode = connector->display_info.is_hdmi
380 hdmi->cfg.infoframe = avi;
383 mutex_lock(&hdmi->lock);
385 ret = hdmi_power_on_full(hdmi);
391 if (hdmi->audio_configured) {
392 ret = hdmi4_audio_config(&hdmi->core, &hdmi->wp,
393 &hdmi->audio_config,
394 hdmi->cfg.vm.pixelclock);
397 hdmi->audio_abort_cb(&hdmi->pdev->dev);
398 hdmi->audio_configured = false;
402 spin_lock_irqsave(&hdmi->audio_playing_lock, flags);
403 if (hdmi->audio_configured && hdmi->audio_playing)
404 hdmi_start_audio_stream(hdmi);
405 hdmi->display_enabled = true;
406 spin_unlock_irqrestore(&hdmi->audio_playing_lock, flags);
409 mutex_unlock(&hdmi->lock);
415 struct omap_hdmi *hdmi = drm_bridge_to_hdmi(bridge);
418 mutex_lock(&hdmi->lock);
420 spin_lock_irqsave(&hdmi->audio_playing_lock, flags);
421 hdmi_stop_audio_stream(hdmi);
422 hdmi->display_enabled = false;
423 spin_unlock_irqrestore(&hdmi->audio_playing_lock, flags);
425 hdmi_power_off_full(hdmi);
427 mutex_unlock(&hdmi->lock);
433 struct omap_hdmi *hdmi = drm_bridge_to_hdmi(bridge);
436 hdmi4_cec_set_phys_addr(&hdmi->core, CEC_PHYS_ADDR_INVALID);
442 struct omap_hdmi *hdmi = drm_bridge_to_hdmi(bridge);
448 need_enable = hdmi->core_enabled == false;
451 r = hdmi4_core_enable(&hdmi->core);
456 mutex_lock(&hdmi->lock);
457 r = hdmi_runtime_get(hdmi);
460 r = hdmi4_core_ddc_init(&hdmi->core);
464 edid = drm_do_get_edid(connector, hdmi4_core_ddc_read, &hdmi->core);
467 hdmi_runtime_put(hdmi);
468 mutex_unlock(&hdmi->lock);
478 hdmi4_cec_set_phys_addr(&hdmi->core, cec_addr);
481 hdmi4_core_disable(&hdmi->core);
498 static void hdmi4_bridge_init(struct omap_hdmi *hdmi)
500 hdmi->bridge.funcs = &hdmi4_bridge_funcs;
501 hdmi->bridge.of_node = hdmi->pdev->dev.of_node;
502 hdmi->bridge.ops = DRM_BRIDGE_OP_EDID;
503 hdmi->bridge.type = DRM_MODE_CONNECTOR_HDMIA;
505 drm_bridge_add(&hdmi->bridge);
508 static void hdmi4_bridge_cleanup(struct omap_hdmi *hdmi)
510 drm_bridge_remove(&hdmi->bridge);
612 static int hdmi_audio_register(struct omap_hdmi *hdmi)
615 .dev = &hdmi->pdev->dev,
617 .audio_dma_addr = hdmi_wp_get_audio_dma_addr(&hdmi->wp),
621 hdmi->audio_pdev = platform_device_register_data(
622 &hdmi->pdev->dev, "omap-hdmi-audio", PLATFORM_DEVID_AUTO,
625 if (IS_ERR(hdmi->audio_pdev))
626 return PTR_ERR(hdmi->audio_pdev);
638 struct omap_hdmi *hdmi = dev_get_drvdata(dev);
641 hdmi->dss = dss;
643 r = hdmi_runtime_get(hdmi);
647 r = hdmi_pll_init(dss, hdmi->pdev, &hdmi->pll, &hdmi->wp);
651 r = hdmi4_cec_init(hdmi->pdev, &hdmi->core, &hdmi->wp);
655 r = hdmi_audio_register(hdmi);
661 hdmi->debugfs = dss_debugfs_create_file(dss, "hdmi", hdmi_dump_regs,
662 hdmi);
664 hdmi_runtime_put(hdmi);
669 hdmi4_cec_uninit(&hdmi->core);
671 hdmi_pll_uninit(&hdmi->pll);
673 hdmi_runtime_put(hdmi);
679 struct omap_hdmi *hdmi = dev_get_drvdata(dev);
681 dss_debugfs_remove_file(hdmi->debugfs);
683 if (hdmi->audio_pdev)
684 platform_device_unregister(hdmi->audio_pdev);
686 hdmi4_cec_uninit(&hdmi->core);
687 hdmi_pll_uninit(&hdmi->pll);
699 static int hdmi4_init_output(struct omap_hdmi *hdmi)
701 struct omap_dss_device *out = &hdmi->output;
704 hdmi4_bridge_init(hdmi);
706 out->dev = &hdmi->pdev->dev;
709 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);
841 { .compatible = "ti,omap4-hdmi", },