Lines Matching full:hdmi

3  * HDMI interface DSS driver for TI's OMAP4 family of SoCs.
10 #define DSS_SUBSYS_NAME "HDMI"
27 #include <sound/omap-hdmi-audio.h>
38 #include "hdmi.h"
40 static int hdmi_runtime_get(struct omap_hdmi *hdmi) in hdmi_runtime_get() argument
46 r = pm_runtime_get_sync(&hdmi->pdev->dev); in hdmi_runtime_get()
48 pm_runtime_put_noidle(&hdmi->pdev->dev); in hdmi_runtime_get()
54 static void hdmi_runtime_put(struct omap_hdmi *hdmi) in hdmi_runtime_put() argument
60 r = pm_runtime_put_sync(&hdmi->pdev->dev); in hdmi_runtime_put()
66 struct omap_hdmi *hdmi = data; in hdmi_irq_handler() local
67 struct hdmi_wp_data *wp = &hdmi->wp; in hdmi_irq_handler()
93 u32 intr4 = hdmi_read_reg(hdmi->core.base, HDMI_CORE_SYS_INTR4); in hdmi_irq_handler()
95 hdmi_write_reg(hdmi->core.base, HDMI_CORE_SYS_INTR4, intr4); in hdmi_irq_handler()
97 hdmi4_cec_irq(&hdmi->core); in hdmi_irq_handler()
103 static int hdmi_power_on_core(struct omap_hdmi *hdmi) in hdmi_power_on_core() argument
107 if (hdmi->core.core_pwr_cnt++) in hdmi_power_on_core()
110 r = regulator_enable(hdmi->vdda_reg); in hdmi_power_on_core()
114 r = hdmi_runtime_get(hdmi); in hdmi_power_on_core()
118 hdmi4_core_powerdown_disable(&hdmi->core); in hdmi_power_on_core()
120 /* Make selection of HDMI in DSS */ in hdmi_power_on_core()
121 dss_select_hdmi_venc_clk_source(hdmi->dss, DSS_HDMI_M_PCLK); in hdmi_power_on_core()
123 hdmi->core_enabled = true; in hdmi_power_on_core()
128 regulator_disable(hdmi->vdda_reg); in hdmi_power_on_core()
130 hdmi->core.core_pwr_cnt--; in hdmi_power_on_core()
135 static void hdmi_power_off_core(struct omap_hdmi *hdmi) in hdmi_power_off_core() argument
137 if (--hdmi->core.core_pwr_cnt) in hdmi_power_off_core()
140 hdmi->core_enabled = false; in hdmi_power_off_core()
142 hdmi_runtime_put(hdmi); in hdmi_power_off_core()
143 regulator_disable(hdmi->vdda_reg); in hdmi_power_off_core()
146 static int hdmi_power_on_full(struct omap_hdmi *hdmi) in hdmi_power_on_full() argument
150 struct hdmi_wp_data *wp = &hdmi->wp; in hdmi_power_on_full()
154 r = hdmi_power_on_core(hdmi); in hdmi_power_on_full()
162 vm = &hdmi->cfg.vm; in hdmi_power_on_full()
174 dss_pll_calc_b(&hdmi->pll.pll, clk_get_rate(hdmi->pll.pll.clkin), in hdmi_power_on_full()
177 r = dss_pll_enable(&hdmi->pll.pll); in hdmi_power_on_full()
183 r = dss_pll_set_config(&hdmi->pll.pll, &hdmi_cinfo); in hdmi_power_on_full()
189 r = hdmi_phy_configure(&hdmi->phy, hdmi_cinfo.clkdco, in hdmi_power_on_full()
200 hdmi4_configure(&hdmi->core, &hdmi->wp, &hdmi->cfg); in hdmi_power_on_full()
202 r = dss_mgr_enable(&hdmi->output); in hdmi_power_on_full()
206 r = hdmi_wp_video_start(&hdmi->wp); in hdmi_power_on_full()
216 dss_mgr_disable(&hdmi->output); in hdmi_power_on_full()
218 hdmi_wp_set_phy_pwr(&hdmi->wp, HDMI_PHYPWRCMD_OFF); in hdmi_power_on_full()
222 dss_pll_disable(&hdmi->pll.pll); in hdmi_power_on_full()
224 hdmi_power_off_core(hdmi); in hdmi_power_on_full()
228 static void hdmi_power_off_full(struct omap_hdmi *hdmi) in hdmi_power_off_full() argument
230 hdmi_wp_clear_irqenable(&hdmi->wp, ~HDMI_IRQ_CORE); in hdmi_power_off_full()
232 hdmi_wp_video_stop(&hdmi->wp); in hdmi_power_off_full()
234 dss_mgr_disable(&hdmi->output); in hdmi_power_off_full()
236 hdmi_wp_set_phy_pwr(&hdmi->wp, HDMI_PHYPWRCMD_OFF); in hdmi_power_off_full()
238 dss_pll_disable(&hdmi->pll.pll); in hdmi_power_off_full()
240 hdmi_power_off_core(hdmi); in hdmi_power_off_full()
245 struct omap_hdmi *hdmi = s->private; in hdmi_dump_regs() local
247 mutex_lock(&hdmi->lock); in hdmi_dump_regs()
249 if (hdmi_runtime_get(hdmi)) { in hdmi_dump_regs()
250 mutex_unlock(&hdmi->lock); in hdmi_dump_regs()
254 hdmi_wp_dump(&hdmi->wp, s); in hdmi_dump_regs()
255 hdmi_pll_dump(&hdmi->pll, s); in hdmi_dump_regs()
256 hdmi_phy_dump(&hdmi->phy, s); in hdmi_dump_regs()
257 hdmi4_core_dump(&hdmi->core, s); in hdmi_dump_regs()
259 hdmi_runtime_put(hdmi); in hdmi_dump_regs()
260 mutex_unlock(&hdmi->lock); in hdmi_dump_regs()
278 struct omap_hdmi *hdmi = container_of(core, struct omap_hdmi, core); in hdmi4_core_enable() local
283 mutex_lock(&hdmi->lock); in hdmi4_core_enable()
285 r = hdmi_power_on_core(hdmi); in hdmi4_core_enable()
291 mutex_unlock(&hdmi->lock); in hdmi4_core_enable()
295 mutex_unlock(&hdmi->lock); in hdmi4_core_enable()
301 struct omap_hdmi *hdmi = container_of(core, struct omap_hdmi, core); in hdmi4_core_disable() local
305 mutex_lock(&hdmi->lock); in hdmi4_core_disable()
307 hdmi_power_off_core(hdmi); in hdmi4_core_disable()
309 mutex_unlock(&hdmi->lock); in hdmi4_core_disable()
319 struct omap_hdmi *hdmi = drm_bridge_to_hdmi(bridge); in hdmi4_bridge_attach() local
324 return drm_bridge_attach(bridge->encoder, hdmi->output.next_bridge, in hdmi4_bridge_attach()
332 struct omap_hdmi *hdmi = drm_bridge_to_hdmi(bridge); in hdmi4_bridge_mode_set() local
334 mutex_lock(&hdmi->lock); in hdmi4_bridge_mode_set()
336 drm_display_mode_to_videomode(adjusted_mode, &hdmi->cfg.vm); in hdmi4_bridge_mode_set()
338 dispc_set_tv_pclk(hdmi->dss->dispc, adjusted_mode->clock * 1000); in hdmi4_bridge_mode_set()
340 mutex_unlock(&hdmi->lock); in hdmi4_bridge_mode_set()
346 struct omap_hdmi *hdmi = drm_bridge_to_hdmi(bridge); in hdmi4_bridge_enable() local
369 hdmi->cfg.hdmi_dvi_mode = connector->display_info.is_hdmi in hdmi4_bridge_enable()
380 hdmi->cfg.infoframe = avi; in hdmi4_bridge_enable()
383 mutex_lock(&hdmi->lock); in hdmi4_bridge_enable()
385 ret = hdmi_power_on_full(hdmi); in hdmi4_bridge_enable()
391 if (hdmi->audio_configured) { in hdmi4_bridge_enable()
392 ret = hdmi4_audio_config(&hdmi->core, &hdmi->wp, in hdmi4_bridge_enable()
393 &hdmi->audio_config, in hdmi4_bridge_enable()
394 hdmi->cfg.vm.pixelclock); in hdmi4_bridge_enable()
397 hdmi->audio_abort_cb(&hdmi->pdev->dev); in hdmi4_bridge_enable()
398 hdmi->audio_configured = false; in hdmi4_bridge_enable()
402 spin_lock_irqsave(&hdmi->audio_playing_lock, flags); in hdmi4_bridge_enable()
403 if (hdmi->audio_configured && hdmi->audio_playing) in hdmi4_bridge_enable()
404 hdmi_start_audio_stream(hdmi); in hdmi4_bridge_enable()
405 hdmi->display_enabled = true; in hdmi4_bridge_enable()
406 spin_unlock_irqrestore(&hdmi->audio_playing_lock, flags); in hdmi4_bridge_enable()
409 mutex_unlock(&hdmi->lock); in hdmi4_bridge_enable()
415 struct omap_hdmi *hdmi = drm_bridge_to_hdmi(bridge); in hdmi4_bridge_disable() local
418 mutex_lock(&hdmi->lock); in hdmi4_bridge_disable()
420 spin_lock_irqsave(&hdmi->audio_playing_lock, flags); in hdmi4_bridge_disable()
421 hdmi_stop_audio_stream(hdmi); in hdmi4_bridge_disable()
422 hdmi->display_enabled = false; in hdmi4_bridge_disable()
423 spin_unlock_irqrestore(&hdmi->audio_playing_lock, flags); in hdmi4_bridge_disable()
425 hdmi_power_off_full(hdmi); in hdmi4_bridge_disable()
427 mutex_unlock(&hdmi->lock); in hdmi4_bridge_disable()
433 struct omap_hdmi *hdmi = drm_bridge_to_hdmi(bridge); in hdmi4_bridge_hpd_notify() local
436 hdmi4_cec_set_phys_addr(&hdmi->core, CEC_PHYS_ADDR_INVALID); in hdmi4_bridge_hpd_notify()
442 struct omap_hdmi *hdmi = drm_bridge_to_hdmi(bridge); in hdmi4_bridge_get_edid() local
448 need_enable = hdmi->core_enabled == false; in hdmi4_bridge_get_edid()
451 r = hdmi4_core_enable(&hdmi->core); in hdmi4_bridge_get_edid()
456 mutex_lock(&hdmi->lock); in hdmi4_bridge_get_edid()
457 r = hdmi_runtime_get(hdmi); in hdmi4_bridge_get_edid()
460 r = hdmi4_core_ddc_init(&hdmi->core); in hdmi4_bridge_get_edid()
464 edid = drm_do_get_edid(connector, hdmi4_core_ddc_read, &hdmi->core); in hdmi4_bridge_get_edid()
467 hdmi_runtime_put(hdmi); in hdmi4_bridge_get_edid()
468 mutex_unlock(&hdmi->lock); in hdmi4_bridge_get_edid()
478 hdmi4_cec_set_phys_addr(&hdmi->core, cec_addr); in hdmi4_bridge_get_edid()
481 hdmi4_core_disable(&hdmi->core); in hdmi4_bridge_get_edid()
498 static void hdmi4_bridge_init(struct omap_hdmi *hdmi) in hdmi4_bridge_init() argument
500 hdmi->bridge.funcs = &hdmi4_bridge_funcs; in hdmi4_bridge_init()
501 hdmi->bridge.of_node = hdmi->pdev->dev.of_node; in hdmi4_bridge_init()
502 hdmi->bridge.ops = DRM_BRIDGE_OP_EDID; in hdmi4_bridge_init()
503 hdmi->bridge.type = DRM_MODE_CONNECTOR_HDMIA; in hdmi4_bridge_init()
505 drm_bridge_add(&hdmi->bridge); in hdmi4_bridge_init()
508 static void hdmi4_bridge_cleanup(struct omap_hdmi *hdmi) in hdmi4_bridge_cleanup() argument
510 drm_bridge_remove(&hdmi->bridge); in hdmi4_bridge_cleanup()
612 static int hdmi_audio_register(struct omap_hdmi *hdmi) in hdmi_audio_register() argument
615 .dev = &hdmi->pdev->dev, in hdmi_audio_register()
617 .audio_dma_addr = hdmi_wp_get_audio_dma_addr(&hdmi->wp), in hdmi_audio_register()
621 hdmi->audio_pdev = platform_device_register_data( in hdmi_audio_register()
622 &hdmi->pdev->dev, "omap-hdmi-audio", PLATFORM_DEVID_AUTO, in hdmi_audio_register()
625 if (IS_ERR(hdmi->audio_pdev)) in hdmi_audio_register()
626 return PTR_ERR(hdmi->audio_pdev); in hdmi_audio_register()
638 struct omap_hdmi *hdmi = dev_get_drvdata(dev); in hdmi4_bind() local
641 hdmi->dss = dss; in hdmi4_bind()
643 r = hdmi_runtime_get(hdmi); in hdmi4_bind()
647 r = hdmi_pll_init(dss, hdmi->pdev, &hdmi->pll, &hdmi->wp); in hdmi4_bind()
651 r = hdmi4_cec_init(hdmi->pdev, &hdmi->core, &hdmi->wp); in hdmi4_bind()
655 r = hdmi_audio_register(hdmi); in hdmi4_bind()
657 DSSERR("Registering HDMI audio failed\n"); in hdmi4_bind()
661 hdmi->debugfs = dss_debugfs_create_file(dss, "hdmi", hdmi_dump_regs, in hdmi4_bind()
662 hdmi); in hdmi4_bind()
664 hdmi_runtime_put(hdmi); in hdmi4_bind()
669 hdmi4_cec_uninit(&hdmi->core); in hdmi4_bind()
671 hdmi_pll_uninit(&hdmi->pll); in hdmi4_bind()
673 hdmi_runtime_put(hdmi); in hdmi4_bind()
679 struct omap_hdmi *hdmi = dev_get_drvdata(dev); in hdmi4_unbind() local
681 dss_debugfs_remove_file(hdmi->debugfs); in hdmi4_unbind()
683 if (hdmi->audio_pdev) in hdmi4_unbind()
684 platform_device_unregister(hdmi->audio_pdev); in hdmi4_unbind()
686 hdmi4_cec_uninit(&hdmi->core); in hdmi4_unbind()
687 hdmi_pll_uninit(&hdmi->pll); in hdmi4_unbind()
699 static int hdmi4_init_output(struct omap_hdmi *hdmi) in hdmi4_init_output() argument
701 struct omap_dss_device *out = &hdmi->output; in hdmi4_init_output()
704 hdmi4_bridge_init(hdmi); in hdmi4_init_output()
706 out->dev = &hdmi->pdev->dev; in hdmi4_init_output()
709 out->name = "hdmi.0"; in hdmi4_init_output()
713 r = omapdss_device_init_output(out, &hdmi->bridge); in hdmi4_init_output()
715 hdmi4_bridge_cleanup(hdmi); in hdmi4_init_output()
724 static void hdmi4_uninit_output(struct omap_hdmi *hdmi) in hdmi4_uninit_output() argument
726 struct omap_dss_device *out = &hdmi->output; in hdmi4_uninit_output()
731 hdmi4_bridge_cleanup(hdmi); in hdmi4_uninit_output()
734 static int hdmi4_probe_of(struct omap_hdmi *hdmi) in hdmi4_probe_of() argument
736 struct platform_device *pdev = hdmi->pdev; in hdmi4_probe_of()
745 r = hdmi_parse_lanes_of(pdev, ep, &hdmi->phy); in hdmi4_probe_of()
752 struct omap_hdmi *hdmi; in hdmi4_probe() local
756 hdmi = kzalloc(sizeof(*hdmi), GFP_KERNEL); in hdmi4_probe()
757 if (!hdmi) in hdmi4_probe()
760 hdmi->pdev = pdev; in hdmi4_probe()
762 dev_set_drvdata(&pdev->dev, hdmi); in hdmi4_probe()
764 mutex_init(&hdmi->lock); in hdmi4_probe()
765 spin_lock_init(&hdmi->audio_playing_lock); in hdmi4_probe()
767 r = hdmi4_probe_of(hdmi); in hdmi4_probe()
771 r = hdmi_wp_init(pdev, &hdmi->wp, 4); in hdmi4_probe()
775 r = hdmi_phy_init(pdev, &hdmi->phy, 4); in hdmi4_probe()
779 r = hdmi4_core_init(pdev, &hdmi->core); in hdmi4_probe()
792 IRQF_ONESHOT, "OMAP HDMI", hdmi); in hdmi4_probe()
794 DSSERR("HDMI IRQ request failed\n"); in hdmi4_probe()
798 hdmi->vdda_reg = devm_regulator_get(&pdev->dev, "vdda"); in hdmi4_probe()
799 if (IS_ERR(hdmi->vdda_reg)) { in hdmi4_probe()
800 r = PTR_ERR(hdmi->vdda_reg); in hdmi4_probe()
808 r = hdmi4_init_output(hdmi); in hdmi4_probe()
819 hdmi4_uninit_output(hdmi); in hdmi4_probe()
823 kfree(hdmi); in hdmi4_probe()
829 struct omap_hdmi *hdmi = platform_get_drvdata(pdev); in hdmi4_remove() local
833 hdmi4_uninit_output(hdmi); in hdmi4_remove()
837 kfree(hdmi); in hdmi4_remove()
841 { .compatible = "ti,omap4-hdmi", },