Lines Matching refs:hdmi

164 	struct sti_hdmi *hdmi;  member
177 u32 hdmi_read(struct sti_hdmi *hdmi, int offset) in hdmi_read() argument
179 return readl(hdmi->regs + offset); in hdmi_read()
182 void hdmi_write(struct sti_hdmi *hdmi, u32 val, int offset) in hdmi_write() argument
184 writel(val, hdmi->regs + offset); in hdmi_write()
195 struct sti_hdmi *hdmi = arg; in hdmi_irq_thread() local
198 if (hdmi->irq_status & HDMI_INT_HOT_PLUG) { in hdmi_irq_thread()
199 hdmi->hpd = readl(hdmi->regs + HDMI_STA) & HDMI_STA_HOT_PLUG; in hdmi_irq_thread()
200 if (hdmi->drm_dev) in hdmi_irq_thread()
201 drm_helper_hpd_irq_event(hdmi->drm_dev); in hdmi_irq_thread()
207 if (hdmi->irq_status & (HDMI_INT_SW_RST | HDMI_INT_DLL_LCK)) { in hdmi_irq_thread()
208 hdmi->event_received = true; in hdmi_irq_thread()
209 wake_up_interruptible(&hdmi->wait_event); in hdmi_irq_thread()
213 if (hdmi->irq_status & HDMI_INT_AUDIO_FIFO_XRUN) in hdmi_irq_thread()
227 struct sti_hdmi *hdmi = arg; in hdmi_irq() local
230 hdmi->irq_status = hdmi_read(hdmi, HDMI_INT_STA); in hdmi_irq()
233 hdmi_write(hdmi, hdmi->irq_status, HDMI_INT_CLR); in hdmi_irq()
236 hdmi_read(hdmi, HDMI_INT_STA); in hdmi_irq()
246 static void hdmi_active_area(struct sti_hdmi *hdmi) in hdmi_active_area() argument
251 xmin = sti_vtg_get_pixel_number(hdmi->mode, 1); in hdmi_active_area()
252 xmax = sti_vtg_get_pixel_number(hdmi->mode, hdmi->mode.hdisplay); in hdmi_active_area()
253 ymin = sti_vtg_get_line_number(hdmi->mode, 0); in hdmi_active_area()
254 ymax = sti_vtg_get_line_number(hdmi->mode, hdmi->mode.vdisplay - 1); in hdmi_active_area()
256 hdmi_write(hdmi, xmin, HDMI_ACTIVE_VID_XMIN); in hdmi_active_area()
257 hdmi_write(hdmi, xmax, HDMI_ACTIVE_VID_XMAX); in hdmi_active_area()
258 hdmi_write(hdmi, ymin, HDMI_ACTIVE_VID_YMIN); in hdmi_active_area()
259 hdmi_write(hdmi, ymax, HDMI_ACTIVE_VID_YMAX); in hdmi_active_area()
267 static void hdmi_config(struct sti_hdmi *hdmi) in hdmi_config() argument
278 if (hdmi->hdmi_monitor) in hdmi_config()
282 if (hdmi->mode.flags & DRM_MODE_FLAG_NHSYNC) { in hdmi_config()
288 if (hdmi->mode.flags & DRM_MODE_FLAG_NVSYNC) { in hdmi_config()
296 hdmi_write(hdmi, conf, HDMI_CFG); in hdmi_config()
305 static void hdmi_infoframe_reset(struct sti_hdmi *hdmi, in hdmi_infoframe_reset() argument
330 val = hdmi_read(hdmi, HDMI_SW_DI_CFG); in hdmi_infoframe_reset()
332 hdmi_write(hdmi, val, HDMI_SW_DI_CFG); in hdmi_infoframe_reset()
335 hdmi_write(hdmi, 0x0, head_offset); in hdmi_infoframe_reset()
337 hdmi_write(hdmi, 0x0, pack_offset + i); in hdmi_infoframe_reset()
364 static void hdmi_infoframe_write_infopack(struct sti_hdmi *hdmi, in hdmi_infoframe_write_infopack() argument
397 val = hdmi_read(hdmi, HDMI_SW_DI_CFG); in hdmi_infoframe_write_infopack()
399 hdmi_write(hdmi, val, HDMI_SW_DI_CFG); in hdmi_infoframe_write_infopack()
404 writel(val, hdmi->regs + head_offset); in hdmi_infoframe_write_infopack()
418 writel(val, hdmi->regs + pack_offset + i); in hdmi_infoframe_write_infopack()
422 val = hdmi_read(hdmi, HDMI_SW_DI_CFG); in hdmi_infoframe_write_infopack()
424 hdmi_write(hdmi, val, HDMI_SW_DI_CFG); in hdmi_infoframe_write_infopack()
438 static int hdmi_avi_infoframe_config(struct sti_hdmi *hdmi) in hdmi_avi_infoframe_config() argument
440 struct drm_display_mode *mode = &hdmi->mode; in hdmi_avi_infoframe_config()
448 hdmi->drm_connector, mode); in hdmi_avi_infoframe_config()
455 infoframe.colorspace = hdmi->colorspace; in hdmi_avi_infoframe_config()
465 hdmi_infoframe_write_infopack(hdmi, buffer, ret); in hdmi_avi_infoframe_config()
481 static int hdmi_audio_infoframe_config(struct sti_hdmi *hdmi) in hdmi_audio_infoframe_config() argument
483 struct hdmi_audio_params *audio = &hdmi->audio; in hdmi_audio_infoframe_config()
497 hdmi_infoframe_write_infopack(hdmi, buffer, ret); in hdmi_audio_infoframe_config()
500 val = hdmi_read(hdmi, HDMI_SW_DI_CFG); in hdmi_audio_infoframe_config()
503 hdmi_write(hdmi, val, HDMI_SW_DI_CFG); in hdmi_audio_infoframe_config()
520 static int hdmi_vendor_infoframe_config(struct sti_hdmi *hdmi) in hdmi_vendor_infoframe_config() argument
522 struct drm_display_mode *mode = &hdmi->mode; in hdmi_vendor_infoframe_config()
530 hdmi->drm_connector, in hdmi_vendor_infoframe_config()
548 hdmi_infoframe_write_infopack(hdmi, buffer, ret); in hdmi_vendor_infoframe_config()
561 static void hdmi_swreset(struct sti_hdmi *hdmi) in hdmi_swreset() argument
568 if (clk_prepare_enable(hdmi->clk_audio)) in hdmi_swreset()
572 hdmi->event_received = false; in hdmi_swreset()
574 val = hdmi_read(hdmi, HDMI_CFG); in hdmi_swreset()
576 hdmi_write(hdmi, val, HDMI_CFG); in hdmi_swreset()
579 wait_event_interruptible_timeout(hdmi->wait_event, in hdmi_swreset()
580 hdmi->event_received, in hdmi_swreset()
588 if ((hdmi_read(hdmi, HDMI_STA) & HDMI_STA_SW_RST) == 0) in hdmi_swreset()
591 val = hdmi_read(hdmi, HDMI_CFG); in hdmi_swreset()
593 hdmi_write(hdmi, val, HDMI_CFG); in hdmi_swreset()
596 clk_disable_unprepare(hdmi->clk_audio); in hdmi_swreset()
602 hdmi_read(hdmi, reg))
672 struct sti_hdmi *hdmi = (struct sti_hdmi *)node->info_ent->data; in hdmi_dbg_show() local
674 seq_printf(s, "HDMI: (vaddr = 0x%p)", hdmi->regs); in hdmi_dbg_show()
676 hdmi_dbg_cfg(s, hdmi_read(hdmi, HDMI_CFG)); in hdmi_dbg_show()
679 hdmi_dbg_sta(s, hdmi_read(hdmi, HDMI_STA)); in hdmi_dbg_show()
682 DBGFS_PRINT_INT("Xmin:", hdmi_read(hdmi, HDMI_ACTIVE_VID_XMIN)); in hdmi_dbg_show()
685 DBGFS_PRINT_INT("Xmax:", hdmi_read(hdmi, HDMI_ACTIVE_VID_XMAX)); in hdmi_dbg_show()
688 DBGFS_PRINT_INT("Ymin:", hdmi_read(hdmi, HDMI_ACTIVE_VID_YMIN)); in hdmi_dbg_show()
691 DBGFS_PRINT_INT("Ymax:", hdmi_read(hdmi, HDMI_ACTIVE_VID_YMAX)); in hdmi_dbg_show()
693 hdmi_dbg_sw_di_cfg(s, hdmi_read(hdmi, HDMI_SW_DI_CFG)); in hdmi_dbg_show()
737 static void hdmi_debugfs_init(struct sti_hdmi *hdmi, struct drm_minor *minor) in hdmi_debugfs_init() argument
742 hdmi_debugfs_files[i].data = hdmi; in hdmi_debugfs_init()
751 struct sti_hdmi *hdmi = bridge->driver_private; in sti_hdmi_disable() local
753 u32 val = hdmi_read(hdmi, HDMI_CFG); in sti_hdmi_disable()
755 if (!hdmi->enabled) in sti_hdmi_disable()
762 hdmi_write(hdmi, val, HDMI_CFG); in sti_hdmi_disable()
764 hdmi_write(hdmi, 0xffffffff, HDMI_INT_CLR); in sti_hdmi_disable()
767 hdmi->phy_ops->stop(hdmi); in sti_hdmi_disable()
770 hdmi_infoframe_reset(hdmi, HDMI_IFRAME_SLOT_AVI); in sti_hdmi_disable()
771 hdmi_infoframe_reset(hdmi, HDMI_IFRAME_SLOT_AUDIO); in sti_hdmi_disable()
772 hdmi_infoframe_reset(hdmi, HDMI_IFRAME_SLOT_VENDOR); in sti_hdmi_disable()
775 hdmi_write(hdmi, 0x0000, HDMI_DFLT_CHL0_DAT); in sti_hdmi_disable()
776 hdmi_write(hdmi, 0x0000, HDMI_DFLT_CHL1_DAT); in sti_hdmi_disable()
777 hdmi_write(hdmi, 0x0060, HDMI_DFLT_CHL2_DAT); in sti_hdmi_disable()
780 clk_disable_unprepare(hdmi->clk_phy); in sti_hdmi_disable()
781 clk_disable_unprepare(hdmi->clk_tmds); in sti_hdmi_disable()
782 clk_disable_unprepare(hdmi->clk_pix); in sti_hdmi_disable()
784 hdmi->enabled = false; in sti_hdmi_disable()
786 cec_notifier_set_phys_addr(hdmi->notifier, CEC_PHYS_ADDR_INVALID); in sti_hdmi_disable()
835 static int hdmi_audio_configure(struct sti_hdmi *hdmi) in hdmi_audio_configure() argument
838 struct hdmi_audio_params *params = &hdmi->audio; in hdmi_audio_configure()
843 if (!hdmi->enabled) in hdmi_audio_configure()
850 params->sample_rate, hdmi->mode.clock * 1000, n); in hdmi_audio_configure()
851 hdmi_write(hdmi, n, HDMI_AUDN); in hdmi_audio_configure()
876 hdmi_write(hdmi, audio_cfg, HDMI_AUDIO_CFG); in hdmi_audio_configure()
878 return hdmi_audio_infoframe_config(hdmi); in hdmi_audio_configure()
883 struct sti_hdmi *hdmi = bridge->driver_private; in sti_hdmi_pre_enable() local
887 if (hdmi->enabled) in sti_hdmi_pre_enable()
891 if (clk_prepare_enable(hdmi->clk_pix)) in sti_hdmi_pre_enable()
893 if (clk_prepare_enable(hdmi->clk_tmds)) in sti_hdmi_pre_enable()
895 if (clk_prepare_enable(hdmi->clk_phy)) in sti_hdmi_pre_enable()
898 hdmi->enabled = true; in sti_hdmi_pre_enable()
901 if (!hdmi->phy_ops->start(hdmi)) { in sti_hdmi_pre_enable()
907 hdmi_active_area(hdmi); in sti_hdmi_pre_enable()
910 hdmi_write(hdmi, HDMI_WORKING_INT, HDMI_INT_EN); in sti_hdmi_pre_enable()
913 hdmi_config(hdmi); in sti_hdmi_pre_enable()
916 if (hdmi_avi_infoframe_config(hdmi)) in sti_hdmi_pre_enable()
919 if (hdmi->audio.enabled) { in sti_hdmi_pre_enable()
920 if (hdmi_audio_configure(hdmi)) in sti_hdmi_pre_enable()
923 hdmi_audio_infoframe_config(hdmi); in sti_hdmi_pre_enable()
927 if (hdmi_vendor_infoframe_config(hdmi)) in sti_hdmi_pre_enable()
931 hdmi_swreset(hdmi); in sti_hdmi_pre_enable()
938 struct sti_hdmi *hdmi = bridge->driver_private; in sti_hdmi_set_mode() local
944 drm_mode_copy(&hdmi->mode, mode); in sti_hdmi_set_mode()
947 ret = clk_set_rate(hdmi->clk_pix, mode->clock * 1000); in sti_hdmi_set_mode()
953 ret = clk_set_rate(hdmi->clk_phy, mode->clock * 1000); in sti_hdmi_set_mode()
978 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_connector_get_modes() local
984 edid = drm_get_edid(connector, hdmi->ddc_adapt); in sti_hdmi_connector_get_modes()
988 hdmi->hdmi_monitor = drm_detect_hdmi_monitor(edid); in sti_hdmi_connector_get_modes()
990 (hdmi->hdmi_monitor ? "hdmi monitor" : "dvi monitor"), in sti_hdmi_connector_get_modes()
992 cec_notifier_set_phys_addr_from_edid(hdmi->notifier, edid); in sti_hdmi_connector_get_modes()
1017 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_connector_mode_valid() local
1020 result = clk_round_rate(hdmi->clk_pix, target); in sti_hdmi_connector_mode_valid()
1045 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_connector_detect() local
1049 if (hdmi->hpd) { in sti_hdmi_connector_detect()
1055 cec_notifier_set_phys_addr(hdmi->notifier, CEC_PHYS_ADDR_INVALID); in sti_hdmi_connector_detect()
1064 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_connector_init_property() local
1068 hdmi->colorspace = DEFAULT_COLORSPACE_MODE; in sti_hdmi_connector_init_property()
1077 drm_object_attach_property(&connector->base, prop, hdmi->colorspace); in sti_hdmi_connector_init_property()
1088 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_connector_set_property() local
1091 hdmi->colorspace = val; in sti_hdmi_connector_set_property()
1107 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_connector_get_property() local
1110 *val = hdmi->colorspace; in sti_hdmi_connector_get_property()
1122 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_late_register() local
1124 hdmi_debugfs_init(hdmi, hdmi->drm_dev->primary); in sti_hdmi_late_register()
1155 struct sti_hdmi *hdmi = dev_get_drvdata(dev); in hdmi_audio_shutdown() local
1163 hdmi_write(hdmi, audio_cfg, HDMI_AUDIO_CFG); in hdmi_audio_shutdown()
1165 hdmi->audio.enabled = false; in hdmi_audio_shutdown()
1166 hdmi_audio_infoframe_config(hdmi); in hdmi_audio_shutdown()
1174 struct sti_hdmi *hdmi = dev_get_drvdata(dev); in hdmi_audio_hw_params() local
1189 hdmi->audio.sample_width = params->sample_width; in hdmi_audio_hw_params()
1190 hdmi->audio.sample_rate = params->sample_rate; in hdmi_audio_hw_params()
1191 hdmi->audio.cea = params->cea; in hdmi_audio_hw_params()
1193 hdmi->audio.enabled = true; in hdmi_audio_hw_params()
1195 ret = hdmi_audio_configure(hdmi); in hdmi_audio_hw_params()
1205 struct sti_hdmi *hdmi = dev_get_drvdata(dev); in hdmi_audio_mute() local
1210 hdmi_write(hdmi, HDMI_SAMPLE_FLAT_ALL, HDMI_SAMPLE_FLAT_MASK); in hdmi_audio_mute()
1212 hdmi_write(hdmi, HDMI_SAMPLE_FLAT_NO, HDMI_SAMPLE_FLAT_MASK); in hdmi_audio_mute()
1219 struct sti_hdmi *hdmi = dev_get_drvdata(dev); in hdmi_audio_get_eld() local
1220 struct drm_connector *connector = hdmi->drm_connector; in hdmi_audio_get_eld()
1237 struct sti_hdmi *hdmi) in sti_hdmi_register_audio_driver() argument
1247 hdmi->audio.enabled = false; in sti_hdmi_register_audio_driver()
1249 hdmi->audio_pdev = platform_device_register_data( in sti_hdmi_register_audio_driver()
1253 if (IS_ERR(hdmi->audio_pdev)) in sti_hdmi_register_audio_driver()
1254 return PTR_ERR(hdmi->audio_pdev); in sti_hdmi_register_audio_driver()
1263 struct sti_hdmi *hdmi = dev_get_drvdata(dev); in sti_hdmi_bind() local
1273 hdmi->drm_dev = drm_dev; in sti_hdmi_bind()
1283 connector->hdmi = hdmi; in sti_hdmi_bind()
1289 bridge->driver_private = hdmi; in sti_hdmi_bind()
1302 hdmi->ddc_adapt); in sti_hdmi_bind()
1309 hdmi->drm_connector = drm_connector; in sti_hdmi_bind()
1317 err = sti_hdmi_register_audio_driver(dev, hdmi); in sti_hdmi_bind()
1324 err = hdmi_audio_infoframe_init(&hdmi->audio.cea); in sti_hdmi_bind()
1331 hdmi->notifier = cec_notifier_conn_register(&hdmi->dev, NULL, in sti_hdmi_bind()
1333 if (!hdmi->notifier) { in sti_hdmi_bind()
1334 hdmi->drm_connector = NULL; in sti_hdmi_bind()
1339 hdmi_write(hdmi, HDMI_DEFAULT_INT, HDMI_INT_EN); in sti_hdmi_bind()
1344 hdmi->drm_connector = NULL; in sti_hdmi_bind()
1351 struct sti_hdmi *hdmi = dev_get_drvdata(dev); in sti_hdmi_unbind() local
1353 cec_notifier_conn_unregister(hdmi->notifier); in sti_hdmi_unbind()
1374 struct sti_hdmi *hdmi; in sti_hdmi_probe() local
1382 hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL); in sti_hdmi_probe()
1383 if (!hdmi) in sti_hdmi_probe()
1388 hdmi->ddc_adapt = of_get_i2c_adapter_by_node(ddc); in sti_hdmi_probe()
1390 if (!hdmi->ddc_adapt) in sti_hdmi_probe()
1394 hdmi->dev = pdev->dev; in sti_hdmi_probe()
1403 hdmi->regs = devm_ioremap(dev, res->start, resource_size(res)); in sti_hdmi_probe()
1404 if (!hdmi->regs) { in sti_hdmi_probe()
1409 hdmi->phy_ops = (struct hdmi_phy_ops *) in sti_hdmi_probe()
1413 hdmi->clk_pix = devm_clk_get(dev, "pix"); in sti_hdmi_probe()
1414 if (IS_ERR(hdmi->clk_pix)) { in sti_hdmi_probe()
1416 ret = PTR_ERR(hdmi->clk_pix); in sti_hdmi_probe()
1420 hdmi->clk_tmds = devm_clk_get(dev, "tmds"); in sti_hdmi_probe()
1421 if (IS_ERR(hdmi->clk_tmds)) { in sti_hdmi_probe()
1423 ret = PTR_ERR(hdmi->clk_tmds); in sti_hdmi_probe()
1427 hdmi->clk_phy = devm_clk_get(dev, "phy"); in sti_hdmi_probe()
1428 if (IS_ERR(hdmi->clk_phy)) { in sti_hdmi_probe()
1430 ret = PTR_ERR(hdmi->clk_phy); in sti_hdmi_probe()
1434 hdmi->clk_audio = devm_clk_get(dev, "audio"); in sti_hdmi_probe()
1435 if (IS_ERR(hdmi->clk_audio)) { in sti_hdmi_probe()
1437 ret = PTR_ERR(hdmi->clk_audio); in sti_hdmi_probe()
1441 hdmi->hpd = readl(hdmi->regs + HDMI_STA) & HDMI_STA_HOT_PLUG; in sti_hdmi_probe()
1443 init_waitqueue_head(&hdmi->wait_event); in sti_hdmi_probe()
1445 hdmi->irq = platform_get_irq_byname(pdev, "irq"); in sti_hdmi_probe()
1446 if (hdmi->irq < 0) { in sti_hdmi_probe()
1448 ret = hdmi->irq; in sti_hdmi_probe()
1452 ret = devm_request_threaded_irq(dev, hdmi->irq, hdmi_irq, in sti_hdmi_probe()
1453 hdmi_irq_thread, IRQF_ONESHOT, dev_name(dev), hdmi); in sti_hdmi_probe()
1459 hdmi->reset = devm_reset_control_get(dev, "hdmi"); in sti_hdmi_probe()
1461 if (!IS_ERR(hdmi->reset)) in sti_hdmi_probe()
1462 reset_control_deassert(hdmi->reset); in sti_hdmi_probe()
1464 platform_set_drvdata(pdev, hdmi); in sti_hdmi_probe()
1469 i2c_put_adapter(hdmi->ddc_adapt); in sti_hdmi_probe()
1476 struct sti_hdmi *hdmi = dev_get_drvdata(&pdev->dev); in sti_hdmi_remove() local
1478 i2c_put_adapter(hdmi->ddc_adapt); in sti_hdmi_remove()
1479 if (hdmi->audio_pdev) in sti_hdmi_remove()
1480 platform_device_unregister(hdmi->audio_pdev); in sti_hdmi_remove()