Lines Matching full:hdmi
2 * HDMI interface DSS driver for TI's OMAP4 family of SoCs.
21 #define DSS_SUBSYS_NAME "HDMI"
39 #include <sound/omap-hdmi-audio.h>
46 #include "hdmi.h"
48 static int hdmi_runtime_get(struct omap_hdmi *hdmi) in hdmi_runtime_get() argument
54 r = pm_runtime_get_sync(&hdmi->pdev->dev); in hdmi_runtime_get()
62 static void hdmi_runtime_put(struct omap_hdmi *hdmi) in hdmi_runtime_put() argument
68 r = pm_runtime_put_sync(&hdmi->pdev->dev); in hdmi_runtime_put()
74 struct omap_hdmi *hdmi = data; in hdmi_irq_handler() local
75 struct hdmi_wp_data *wp = &hdmi->wp; in hdmi_irq_handler()
101 u32 intr4 = hdmi_read_reg(hdmi->core.base, HDMI_CORE_SYS_INTR4); in hdmi_irq_handler()
103 hdmi_write_reg(hdmi->core.base, HDMI_CORE_SYS_INTR4, intr4); in hdmi_irq_handler()
105 hdmi4_cec_irq(&hdmi->core); in hdmi_irq_handler()
111 static int hdmi_init_regulator(struct omap_hdmi *hdmi) in hdmi_init_regulator() argument
115 if (hdmi->vdda_reg != NULL) in hdmi_init_regulator()
118 reg = devm_regulator_get(&hdmi->pdev->dev, "vdda"); in hdmi_init_regulator()
126 hdmi->vdda_reg = reg; in hdmi_init_regulator()
131 static int hdmi_power_on_core(struct omap_hdmi *hdmi) in hdmi_power_on_core() argument
135 if (hdmi->core.core_pwr_cnt++) in hdmi_power_on_core()
138 r = regulator_enable(hdmi->vdda_reg); in hdmi_power_on_core()
142 r = hdmi_runtime_get(hdmi); in hdmi_power_on_core()
146 hdmi4_core_powerdown_disable(&hdmi->core); in hdmi_power_on_core()
148 /* Make selection of HDMI in DSS */ in hdmi_power_on_core()
149 dss_select_hdmi_venc_clk_source(hdmi->dss, DSS_HDMI_M_PCLK); in hdmi_power_on_core()
151 hdmi->core_enabled = true; in hdmi_power_on_core()
156 regulator_disable(hdmi->vdda_reg); in hdmi_power_on_core()
158 hdmi->core.core_pwr_cnt--; in hdmi_power_on_core()
163 static void hdmi_power_off_core(struct omap_hdmi *hdmi) in hdmi_power_off_core() argument
165 if (--hdmi->core.core_pwr_cnt) in hdmi_power_off_core()
168 hdmi->core_enabled = false; in hdmi_power_off_core()
170 hdmi_runtime_put(hdmi); in hdmi_power_off_core()
171 regulator_disable(hdmi->vdda_reg); in hdmi_power_off_core()
174 static int hdmi_power_on_full(struct omap_hdmi *hdmi) in hdmi_power_on_full() argument
178 struct hdmi_wp_data *wp = &hdmi->wp; in hdmi_power_on_full()
182 r = hdmi_power_on_core(hdmi); in hdmi_power_on_full()
190 vm = &hdmi->cfg.vm; in hdmi_power_on_full()
202 dss_pll_calc_b(&hdmi->pll.pll, clk_get_rate(hdmi->pll.pll.clkin), in hdmi_power_on_full()
205 r = dss_pll_enable(&hdmi->pll.pll); in hdmi_power_on_full()
211 r = dss_pll_set_config(&hdmi->pll.pll, &hdmi_cinfo); in hdmi_power_on_full()
217 r = hdmi_phy_configure(&hdmi->phy, hdmi_cinfo.clkdco, in hdmi_power_on_full()
228 hdmi4_configure(&hdmi->core, &hdmi->wp, &hdmi->cfg); in hdmi_power_on_full()
231 dss_mgr_set_timings(&hdmi->output, vm); in hdmi_power_on_full()
233 r = dss_mgr_enable(&hdmi->output); in hdmi_power_on_full()
237 r = hdmi_wp_video_start(&hdmi->wp); in hdmi_power_on_full()
247 dss_mgr_disable(&hdmi->output); in hdmi_power_on_full()
249 hdmi_wp_set_phy_pwr(&hdmi->wp, HDMI_PHYPWRCMD_OFF); in hdmi_power_on_full()
253 dss_pll_disable(&hdmi->pll.pll); in hdmi_power_on_full()
255 hdmi_power_off_core(hdmi); in hdmi_power_on_full()
259 static void hdmi_power_off_full(struct omap_hdmi *hdmi) in hdmi_power_off_full() argument
261 hdmi_wp_clear_irqenable(&hdmi->wp, ~HDMI_IRQ_CORE); in hdmi_power_off_full()
263 hdmi_wp_video_stop(&hdmi->wp); in hdmi_power_off_full()
265 dss_mgr_disable(&hdmi->output); in hdmi_power_off_full()
267 hdmi_wp_set_phy_pwr(&hdmi->wp, HDMI_PHYPWRCMD_OFF); in hdmi_power_off_full()
269 dss_pll_disable(&hdmi->pll.pll); in hdmi_power_off_full()
271 hdmi_power_off_core(hdmi); in hdmi_power_off_full()
277 struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev); in hdmi_display_check_timing() local
279 if (!dispc_mgr_timings_ok(hdmi->dss->dispc, dssdev->dispc_channel, vm)) in hdmi_display_check_timing()
288 struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev); in hdmi_display_set_timing() local
290 mutex_lock(&hdmi->lock); in hdmi_display_set_timing()
292 hdmi->cfg.vm = *vm; in hdmi_display_set_timing()
294 dispc_set_tv_pclk(hdmi->dss->dispc, vm->pixelclock); in hdmi_display_set_timing()
296 mutex_unlock(&hdmi->lock); in hdmi_display_set_timing()
302 struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev); in hdmi_display_get_timings() local
304 *vm = hdmi->cfg.vm; in hdmi_display_get_timings()
309 struct omap_hdmi *hdmi = s->private; in hdmi_dump_regs() local
311 mutex_lock(&hdmi->lock); in hdmi_dump_regs()
313 if (hdmi_runtime_get(hdmi)) { in hdmi_dump_regs()
314 mutex_unlock(&hdmi->lock); in hdmi_dump_regs()
318 hdmi_wp_dump(&hdmi->wp, s); in hdmi_dump_regs()
319 hdmi_pll_dump(&hdmi->pll, s); in hdmi_dump_regs()
320 hdmi_phy_dump(&hdmi->phy, s); in hdmi_dump_regs()
321 hdmi4_core_dump(&hdmi->core, s); in hdmi_dump_regs()
323 hdmi_runtime_put(hdmi); in hdmi_dump_regs()
324 mutex_unlock(&hdmi->lock); in hdmi_dump_regs()
328 static int read_edid(struct omap_hdmi *hdmi, u8 *buf, int len) in read_edid() argument
332 mutex_lock(&hdmi->lock); in read_edid()
334 r = hdmi_runtime_get(hdmi); in read_edid()
337 r = hdmi4_read_edid(&hdmi->core, buf, len); in read_edid()
339 hdmi_runtime_put(hdmi); in read_edid()
340 mutex_unlock(&hdmi->lock); in read_edid()
359 struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev); in hdmi_display_enable() local
365 mutex_lock(&hdmi->lock); in hdmi_display_enable()
373 r = hdmi_power_on_full(hdmi); in hdmi_display_enable()
379 if (hdmi->audio_configured) { in hdmi_display_enable()
380 r = hdmi4_audio_config(&hdmi->core, &hdmi->wp, in hdmi_display_enable()
381 &hdmi->audio_config, in hdmi_display_enable()
382 hdmi->cfg.vm.pixelclock); in hdmi_display_enable()
385 hdmi->audio_abort_cb(&hdmi->pdev->dev); in hdmi_display_enable()
386 hdmi->audio_configured = false; in hdmi_display_enable()
390 spin_lock_irqsave(&hdmi->audio_playing_lock, flags); in hdmi_display_enable()
391 if (hdmi->audio_configured && hdmi->audio_playing) in hdmi_display_enable()
392 hdmi_start_audio_stream(hdmi); in hdmi_display_enable()
393 hdmi->display_enabled = true; in hdmi_display_enable()
394 spin_unlock_irqrestore(&hdmi->audio_playing_lock, flags); in hdmi_display_enable()
396 mutex_unlock(&hdmi->lock); in hdmi_display_enable()
400 mutex_unlock(&hdmi->lock); in hdmi_display_enable()
406 struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev); in hdmi_display_disable() local
411 mutex_lock(&hdmi->lock); in hdmi_display_disable()
413 spin_lock_irqsave(&hdmi->audio_playing_lock, flags); in hdmi_display_disable()
414 hdmi_stop_audio_stream(hdmi); in hdmi_display_disable()
415 hdmi->display_enabled = false; in hdmi_display_disable()
416 spin_unlock_irqrestore(&hdmi->audio_playing_lock, flags); in hdmi_display_disable()
418 hdmi_power_off_full(hdmi); in hdmi_display_disable()
420 mutex_unlock(&hdmi->lock); in hdmi_display_disable()
425 struct omap_hdmi *hdmi = container_of(core, struct omap_hdmi, core); in hdmi4_core_enable() local
430 mutex_lock(&hdmi->lock); in hdmi4_core_enable()
432 r = hdmi_power_on_core(hdmi); in hdmi4_core_enable()
438 mutex_unlock(&hdmi->lock); in hdmi4_core_enable()
442 mutex_unlock(&hdmi->lock); in hdmi4_core_enable()
448 struct omap_hdmi *hdmi = container_of(core, struct omap_hdmi, core); in hdmi4_core_disable() local
452 mutex_lock(&hdmi->lock); in hdmi4_core_disable()
454 hdmi_power_off_core(hdmi); in hdmi4_core_disable()
456 mutex_unlock(&hdmi->lock); in hdmi4_core_disable()
462 struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev); in hdmi_connect() local
465 r = hdmi_init_regulator(hdmi); in hdmi_connect()
469 r = dss_mgr_connect(&hdmi->output, dssdev); in hdmi_connect()
477 dss_mgr_disconnect(&hdmi->output, dssdev); in hdmi_connect()
487 struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev); in hdmi_disconnect() local
496 dss_mgr_disconnect(&hdmi->output, dssdev); in hdmi_disconnect()
502 struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev); in hdmi_read_edid() local
506 need_enable = hdmi->core_enabled == false; in hdmi_read_edid()
509 r = hdmi4_core_enable(&hdmi->core); in hdmi_read_edid()
514 r = read_edid(hdmi, edid, len); in hdmi_read_edid()
516 hdmi4_cec_set_phys_addr(&hdmi->core, in hdmi_read_edid()
519 hdmi4_cec_set_phys_addr(&hdmi->core, CEC_PHYS_ADDR_INVALID); in hdmi_read_edid()
521 hdmi4_core_disable(&hdmi->core); in hdmi_read_edid()
528 struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev); in hdmi_lost_hotplug() local
530 hdmi4_cec_set_phys_addr(&hdmi->core, CEC_PHYS_ADDR_INVALID); in hdmi_lost_hotplug()
536 struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev); in hdmi_set_infoframe() local
538 hdmi->cfg.infoframe = *avi; in hdmi_set_infoframe()
545 struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev); in hdmi_set_hdmi_mode() local
547 hdmi->cfg.hdmi_dvi_mode = hdmi_mode ? HDMI_HDMI : HDMI_DVI; in hdmi_set_hdmi_mode()
568 static void hdmi_init_output(struct omap_hdmi *hdmi) in hdmi_init_output() argument
570 struct omap_dss_device *out = &hdmi->output; in hdmi_init_output()
572 out->dev = &hdmi->pdev->dev; in hdmi_init_output()
575 out->name = "hdmi.0"; in hdmi_init_output()
577 out->ops.hdmi = &hdmi_ops; in hdmi_init_output()
583 static void hdmi_uninit_output(struct omap_hdmi *hdmi) in hdmi_uninit_output() argument
585 struct omap_dss_device *out = &hdmi->output; in hdmi_uninit_output()
590 static int hdmi_probe_of(struct omap_hdmi *hdmi) in hdmi_probe_of() argument
592 struct platform_device *pdev = hdmi->pdev; in hdmi_probe_of()
601 r = hdmi_parse_lanes_of(pdev, ep, &hdmi->phy); in hdmi_probe_of()
709 static int hdmi_audio_register(struct omap_hdmi *hdmi) in hdmi_audio_register() argument
712 .dev = &hdmi->pdev->dev, in hdmi_audio_register()
714 .audio_dma_addr = hdmi_wp_get_audio_dma_addr(&hdmi->wp), in hdmi_audio_register()
718 hdmi->audio_pdev = platform_device_register_data( in hdmi_audio_register()
719 &hdmi->pdev->dev, "omap-hdmi-audio", PLATFORM_DEVID_AUTO, in hdmi_audio_register()
722 if (IS_ERR(hdmi->audio_pdev)) in hdmi_audio_register()
723 return PTR_ERR(hdmi->audio_pdev); in hdmi_audio_register()
728 /* HDMI HW IP initialisation */
733 struct omap_hdmi *hdmi; in hdmi4_bind() local
737 hdmi = kzalloc(sizeof(*hdmi), GFP_KERNEL); in hdmi4_bind()
738 if (!hdmi) in hdmi4_bind()
741 hdmi->pdev = pdev; in hdmi4_bind()
742 hdmi->dss = dss; in hdmi4_bind()
743 dev_set_drvdata(&pdev->dev, hdmi); in hdmi4_bind()
745 mutex_init(&hdmi->lock); in hdmi4_bind()
746 spin_lock_init(&hdmi->audio_playing_lock); in hdmi4_bind()
748 r = hdmi_probe_of(hdmi); in hdmi4_bind()
752 r = hdmi_wp_init(pdev, &hdmi->wp, 4); in hdmi4_bind()
756 r = hdmi_pll_init(dss, pdev, &hdmi->pll, &hdmi->wp); in hdmi4_bind()
760 r = hdmi_phy_init(pdev, &hdmi->phy, 4); in hdmi4_bind()
764 r = hdmi4_core_init(pdev, &hdmi->core); in hdmi4_bind()
768 r = hdmi4_cec_init(pdev, &hdmi->core, &hdmi->wp); in hdmi4_bind()
781 IRQF_ONESHOT, "OMAP HDMI", hdmi); in hdmi4_bind()
783 DSSERR("HDMI IRQ request failed\n"); in hdmi4_bind()
789 hdmi_init_output(hdmi); in hdmi4_bind()
791 r = hdmi_audio_register(hdmi); in hdmi4_bind()
793 DSSERR("Registering HDMI audio failed\n"); in hdmi4_bind()
794 hdmi_uninit_output(hdmi); in hdmi4_bind()
799 hdmi->debugfs = dss_debugfs_create_file(dss, "hdmi", hdmi_dump_regs, in hdmi4_bind()
800 hdmi); in hdmi4_bind()
805 hdmi_pll_uninit(&hdmi->pll); in hdmi4_bind()
807 kfree(hdmi); in hdmi4_bind()
813 struct omap_hdmi *hdmi = dev_get_drvdata(dev); in hdmi4_unbind() local
815 dss_debugfs_remove_file(hdmi->debugfs); in hdmi4_unbind()
817 if (hdmi->audio_pdev) in hdmi4_unbind()
818 platform_device_unregister(hdmi->audio_pdev); in hdmi4_unbind()
820 hdmi_uninit_output(hdmi); in hdmi4_unbind()
822 hdmi4_cec_uninit(&hdmi->core); in hdmi4_unbind()
824 hdmi_pll_uninit(&hdmi->pll); in hdmi4_unbind()
828 kfree(hdmi); in hdmi4_unbind()
849 struct omap_hdmi *hdmi = dev_get_drvdata(dev); in hdmi_runtime_suspend() local
851 dispc_runtime_put(hdmi->dss->dispc); in hdmi_runtime_suspend()
858 struct omap_hdmi *hdmi = dev_get_drvdata(dev); in hdmi_runtime_resume() local
861 r = dispc_runtime_get(hdmi->dss->dispc); in hdmi_runtime_resume()
874 { .compatible = "ti,omap4-hdmi", },