Lines Matching +full:hdmi +full:- +full:connector
1 // SPDX-License-Identifier: GPL-2.0
10 #include <linux/hdmi.h>
26 #include <sound/hdmi-codec.h>
96 #define HDMI_IFRAME_CFG_DI_N(x, n) ((x) << ((n-1)*4)) /* n from 1 to 6 */
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()
188 * HDMI interrupt handler threaded
191 * @arg: connector structure
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()
220 * HDMI interrupt handler
223 * @arg: connector structure
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()
242 * Set hdmi active area depending on the drm display mode selected
244 * @hdmi: pointer on the hdmi internal structure
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()
263 * Overall hdmi configuration
265 * @hdmi: pointer on the hdmi internal structure
267 static void hdmi_config(struct sti_hdmi *hdmi) in hdmi_config() argument
269 struct drm_connector *connector = hdmi->drm_connector; in hdmi_config() local
279 if (connector->display_info.is_hdmi) in hdmi_config()
283 if (hdmi->mode.flags & DRM_MODE_FLAG_NHSYNC) { in hdmi_config()
289 if (hdmi->mode.flags & DRM_MODE_FLAG_NVSYNC) { in hdmi_config()
294 /* Enable HDMI */ in hdmi_config()
297 hdmi_write(hdmi, conf, HDMI_CFG); in hdmi_config()
303 * @hdmi: pointer on the hdmi internal structure
306 static void hdmi_infoframe_reset(struct sti_hdmi *hdmi, in hdmi_infoframe_reset() argument
331 val = hdmi_read(hdmi, HDMI_SW_DI_CFG); in hdmi_infoframe_reset()
333 hdmi_write(hdmi, val, HDMI_SW_DI_CFG); in hdmi_infoframe_reset()
336 hdmi_write(hdmi, 0x0, head_offset); in hdmi_infoframe_reset()
338 hdmi_write(hdmi, 0x0, pack_offset + i); in hdmi_infoframe_reset()
344 * @ptr: pointer on the hdmi internal structure
352 for (i = size; i > 0; i--) in hdmi_infoframe_subpack()
353 value = (value << 8) | ptr[i - 1]; in hdmi_infoframe_subpack()
361 * @hdmi: pointer on the hdmi internal structure
365 static void hdmi_infoframe_write_infopack(struct sti_hdmi *hdmi, in hdmi_infoframe_write_infopack() argument
398 val = hdmi_read(hdmi, HDMI_SW_DI_CFG); in hdmi_infoframe_write_infopack()
400 hdmi_write(hdmi, val, HDMI_SW_DI_CFG); in hdmi_infoframe_write_infopack()
405 writel(val, hdmi->regs + head_offset); in hdmi_infoframe_write_infopack()
412 size = size - HDMI_INFOFRAME_HEADER_SIZE + 1; in hdmi_infoframe_write_infopack()
416 num = min_t(size_t, size - i, sizeof(u32)); in hdmi_infoframe_write_infopack()
419 writel(val, hdmi->regs + pack_offset + i); in hdmi_infoframe_write_infopack()
423 val = hdmi_read(hdmi, HDMI_SW_DI_CFG); in hdmi_infoframe_write_infopack()
425 hdmi_write(hdmi, val, HDMI_SW_DI_CFG); in hdmi_infoframe_write_infopack()
432 * contains information about HDMI transmission mode such as color space,
435 * @hdmi: pointer on the hdmi internal structure
439 static int hdmi_avi_infoframe_config(struct sti_hdmi *hdmi) in hdmi_avi_infoframe_config() argument
441 struct drm_display_mode *mode = &hdmi->mode; in hdmi_avi_infoframe_config()
449 hdmi->drm_connector, mode); in hdmi_avi_infoframe_config()
456 infoframe.colorspace = hdmi->colorspace; in hdmi_avi_infoframe_config()
466 hdmi_infoframe_write_infopack(hdmi, buffer, ret); in hdmi_avi_infoframe_config()
475 * contains information about HDMI transmission mode such as audio codec,
478 * @hdmi: pointer on the hdmi internal structure
482 static int hdmi_audio_infoframe_config(struct sti_hdmi *hdmi) in hdmi_audio_infoframe_config() argument
484 struct hdmi_audio_params *audio = &hdmi->audio; in hdmi_audio_infoframe_config()
489 audio->enabled ? "enable" : "disable"); in hdmi_audio_infoframe_config()
490 if (audio->enabled) { in hdmi_audio_infoframe_config()
492 ret = hdmi_audio_infoframe_pack(&audio->cea, buffer, in hdmi_audio_infoframe_config()
498 hdmi_infoframe_write_infopack(hdmi, buffer, ret); in hdmi_audio_infoframe_config()
501 val = hdmi_read(hdmi, HDMI_SW_DI_CFG); in hdmi_audio_infoframe_config()
504 hdmi_write(hdmi, val, HDMI_SW_DI_CFG); in hdmi_audio_infoframe_config()
516 * @hdmi: pointer on the hdmi internal structure
521 static int hdmi_vendor_infoframe_config(struct sti_hdmi *hdmi) in hdmi_vendor_infoframe_config() argument
523 struct drm_display_mode *mode = &hdmi->mode; in hdmi_vendor_infoframe_config()
531 hdmi->drm_connector, in hdmi_vendor_infoframe_config()
549 hdmi_infoframe_write_infopack(hdmi, buffer, ret); in hdmi_vendor_infoframe_config()
557 * Software reset of the hdmi subsystem
559 * @hdmi: pointer on the hdmi internal structure
562 static void hdmi_swreset(struct sti_hdmi *hdmi) in hdmi_swreset() argument
568 /* Enable hdmi_audio clock only during hdmi reset */ in hdmi_swreset()
569 if (clk_prepare_enable(hdmi->clk_audio)) in hdmi_swreset()
573 hdmi->event_received = false; in hdmi_swreset()
575 val = hdmi_read(hdmi, HDMI_CFG); in hdmi_swreset()
577 hdmi_write(hdmi, val, HDMI_CFG); in hdmi_swreset()
580 wait_event_interruptible_timeout(hdmi->wait_event, in hdmi_swreset()
581 hdmi->event_received, in hdmi_swreset()
589 if ((hdmi_read(hdmi, HDMI_STA) & HDMI_STA_SW_RST) == 0) in hdmi_swreset()
590 DRM_DEBUG_DRIVER("Warning: HDMI sw reset timeout occurs\n"); in hdmi_swreset()
592 val = hdmi_read(hdmi, HDMI_CFG); in hdmi_swreset()
594 hdmi_write(hdmi, val, HDMI_CFG); in hdmi_swreset()
597 clk_disable_unprepare(hdmi->clk_audio); in hdmi_swreset()
600 #define DBGFS_PRINT_STR(str1, str2) seq_printf(s, "%-24s %s\n", str1, str2)
601 #define DBGFS_PRINT_INT(str1, int2) seq_printf(s, "%-24s %d\n", str1, int2)
602 #define DBGFS_DUMP(str, reg) seq_printf(s, "%s %-25s 0x%08X", str, #reg, \
603 hdmi_read(hdmi, reg))
612 DBGFS_PRINT_STR("mode:", tmp ? "HDMI" : "DVI"); in hdmi_dbg_cfg()
639 DBGFS_PRINT_STR("hdmi cable:", tmp ? "connected" : "not connected"); in hdmi_dbg_sta()
672 struct drm_info_node *node = s->private; in hdmi_dbg_show()
673 struct sti_hdmi *hdmi = (struct sti_hdmi *)node->info_ent->data; in hdmi_dbg_show() local
675 seq_printf(s, "HDMI: (vaddr = 0x%p)", hdmi->regs); in hdmi_dbg_show()
677 hdmi_dbg_cfg(s, hdmi_read(hdmi, HDMI_CFG)); in hdmi_dbg_show()
680 hdmi_dbg_sta(s, hdmi_read(hdmi, HDMI_STA)); in hdmi_dbg_show()
683 DBGFS_PRINT_INT("Xmin:", hdmi_read(hdmi, HDMI_ACTIVE_VID_XMIN)); in hdmi_dbg_show()
686 DBGFS_PRINT_INT("Xmax:", hdmi_read(hdmi, HDMI_ACTIVE_VID_XMAX)); in hdmi_dbg_show()
689 DBGFS_PRINT_INT("Ymin:", hdmi_read(hdmi, HDMI_ACTIVE_VID_YMIN)); in hdmi_dbg_show()
692 DBGFS_PRINT_INT("Ymax:", hdmi_read(hdmi, HDMI_ACTIVE_VID_YMAX)); in hdmi_dbg_show()
694 hdmi_dbg_sw_di_cfg(s, hdmi_read(hdmi, HDMI_SW_DI_CFG)); in hdmi_dbg_show()
735 { "hdmi", hdmi_dbg_show, 0, NULL },
738 static void hdmi_debugfs_init(struct sti_hdmi *hdmi, struct drm_minor *minor) in hdmi_debugfs_init() argument
743 hdmi_debugfs_files[i].data = hdmi; in hdmi_debugfs_init()
747 minor->debugfs_root, minor); in hdmi_debugfs_init()
752 struct sti_hdmi *hdmi = bridge->driver_private; in sti_hdmi_disable() local
754 u32 val = hdmi_read(hdmi, HDMI_CFG); in sti_hdmi_disable()
756 if (!hdmi->enabled) in sti_hdmi_disable()
761 /* Disable HDMI */ in sti_hdmi_disable()
763 hdmi_write(hdmi, val, HDMI_CFG); in sti_hdmi_disable()
765 hdmi_write(hdmi, 0xffffffff, HDMI_INT_CLR); in sti_hdmi_disable()
768 hdmi->phy_ops->stop(hdmi); in sti_hdmi_disable()
771 hdmi_infoframe_reset(hdmi, HDMI_IFRAME_SLOT_AVI); in sti_hdmi_disable()
772 hdmi_infoframe_reset(hdmi, HDMI_IFRAME_SLOT_AUDIO); in sti_hdmi_disable()
773 hdmi_infoframe_reset(hdmi, HDMI_IFRAME_SLOT_VENDOR); in sti_hdmi_disable()
776 hdmi_write(hdmi, 0x0000, HDMI_DFLT_CHL0_DAT); in sti_hdmi_disable()
777 hdmi_write(hdmi, 0x0000, HDMI_DFLT_CHL1_DAT); in sti_hdmi_disable()
778 hdmi_write(hdmi, 0x0060, HDMI_DFLT_CHL2_DAT); in sti_hdmi_disable()
780 /* Disable/unprepare hdmi clock */ in sti_hdmi_disable()
781 clk_disable_unprepare(hdmi->clk_phy); in sti_hdmi_disable()
782 clk_disable_unprepare(hdmi->clk_tmds); in sti_hdmi_disable()
783 clk_disable_unprepare(hdmi->clk_pix); in sti_hdmi_disable()
785 hdmi->enabled = false; in sti_hdmi_disable()
787 cec_notifier_set_phys_addr(hdmi->notifier, CEC_PHYS_ADDR_INVALID); in sti_hdmi_disable()
791 * sti_hdmi_audio_get_non_coherent_n() - get N parameter for non-coherent
792 * clocks. None-coherent clocks means that audio and TMDS clocks have not the
798 * Values computed are based on table described in HDMI specification 1.4b
829 /* Not pre-defined, recommended value: 128 * fs / 1000 */ in sti_hdmi_audio_get_non_coherent_n()
836 static int hdmi_audio_configure(struct sti_hdmi *hdmi) in hdmi_audio_configure() argument
839 struct hdmi_audio_params *params = &hdmi->audio; in hdmi_audio_configure()
840 struct hdmi_audio_infoframe *info = ¶ms->cea; in hdmi_audio_configure()
844 if (!hdmi->enabled) in hdmi_audio_configure()
848 n = sti_hdmi_audio_get_non_coherent_n(params->sample_rate); in hdmi_audio_configure()
851 params->sample_rate, hdmi->mode.clock * 1000, n); in hdmi_audio_configure()
852 hdmi_write(hdmi, n, HDMI_AUDN); in hdmi_audio_configure()
854 /* update HDMI registers according to configuration */ in hdmi_audio_configure()
858 switch (info->channels) { in hdmi_audio_configure()
873 info->channels); in hdmi_audio_configure()
874 return -EINVAL; in hdmi_audio_configure()
877 hdmi_write(hdmi, audio_cfg, HDMI_AUDIO_CFG); in hdmi_audio_configure()
879 return hdmi_audio_infoframe_config(hdmi); in hdmi_audio_configure()
884 struct sti_hdmi *hdmi = bridge->driver_private; in sti_hdmi_pre_enable() local
888 if (hdmi->enabled) in sti_hdmi_pre_enable()
892 if (clk_prepare_enable(hdmi->clk_pix)) in sti_hdmi_pre_enable()
894 if (clk_prepare_enable(hdmi->clk_tmds)) in sti_hdmi_pre_enable()
896 if (clk_prepare_enable(hdmi->clk_phy)) in sti_hdmi_pre_enable()
899 hdmi->enabled = true; in sti_hdmi_pre_enable()
901 /* Program hdmi serializer and start phy */ in sti_hdmi_pre_enable()
902 if (!hdmi->phy_ops->start(hdmi)) { in sti_hdmi_pre_enable()
903 DRM_ERROR("Unable to start hdmi phy\n"); in sti_hdmi_pre_enable()
907 /* Program hdmi active area */ in sti_hdmi_pre_enable()
908 hdmi_active_area(hdmi); in sti_hdmi_pre_enable()
911 hdmi_write(hdmi, HDMI_WORKING_INT, HDMI_INT_EN); in sti_hdmi_pre_enable()
913 /* Program hdmi config */ in sti_hdmi_pre_enable()
914 hdmi_config(hdmi); in sti_hdmi_pre_enable()
917 if (hdmi_avi_infoframe_config(hdmi)) in sti_hdmi_pre_enable()
920 if (hdmi->audio.enabled) { in sti_hdmi_pre_enable()
921 if (hdmi_audio_configure(hdmi)) in sti_hdmi_pre_enable()
924 hdmi_audio_infoframe_config(hdmi); in sti_hdmi_pre_enable()
928 if (hdmi_vendor_infoframe_config(hdmi)) in sti_hdmi_pre_enable()
932 hdmi_swreset(hdmi); in sti_hdmi_pre_enable()
939 struct sti_hdmi *hdmi = bridge->driver_private; in sti_hdmi_set_mode() local
944 /* Copy the drm display mode in the connector local structure */ in sti_hdmi_set_mode()
945 drm_mode_copy(&hdmi->mode, mode); in sti_hdmi_set_mode()
948 ret = clk_set_rate(hdmi->clk_pix, mode->clock * 1000); in sti_hdmi_set_mode()
951 mode->clock * 1000); in sti_hdmi_set_mode()
954 ret = clk_set_rate(hdmi->clk_phy, mode->clock * 1000); in sti_hdmi_set_mode()
957 mode->clock * 1000); in sti_hdmi_set_mode()
975 static int sti_hdmi_connector_get_modes(struct drm_connector *connector) in sti_hdmi_connector_get_modes() argument
977 const struct drm_display_info *info = &connector->display_info; in sti_hdmi_connector_get_modes()
979 = to_sti_hdmi_connector(connector); in sti_hdmi_connector_get_modes()
980 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_connector_get_modes() local
986 drm_edid = drm_edid_read(connector); in sti_hdmi_connector_get_modes()
988 drm_edid_connector_update(connector, drm_edid); in sti_hdmi_connector_get_modes()
990 cec_notifier_set_phys_addr(hdmi->notifier, in sti_hdmi_connector_get_modes()
991 connector->display_info.source_physical_address); in sti_hdmi_connector_get_modes()
996 count = drm_edid_connector_add_modes(connector); in sti_hdmi_connector_get_modes()
999 info->is_hdmi ? "hdmi monitor" : "dvi monitor", in sti_hdmi_connector_get_modes()
1000 info->width_mm / 10, info->height_mm / 10); in sti_hdmi_connector_get_modes()
1006 DRM_ERROR("Can't read HDMI EDID\n"); in sti_hdmi_connector_get_modes()
1013 sti_hdmi_connector_mode_valid(struct drm_connector *connector, in sti_hdmi_connector_mode_valid() argument
1016 int target = mode->clock * 1000; in sti_hdmi_connector_mode_valid()
1017 int target_min = target - CLK_TOLERANCE_HZ; in sti_hdmi_connector_mode_valid()
1021 = to_sti_hdmi_connector(connector); in sti_hdmi_connector_mode_valid()
1022 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_connector_mode_valid() local
1025 result = clk_round_rate(hdmi->clk_pix, target); in sti_hdmi_connector_mode_valid()
1031 DRM_DEBUG_DRIVER("hdmi pixclk=%d not supported\n", target); in sti_hdmi_connector_mode_valid()
1046 sti_hdmi_connector_detect(struct drm_connector *connector, bool force) in sti_hdmi_connector_detect() argument
1049 = to_sti_hdmi_connector(connector); in sti_hdmi_connector_detect()
1050 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_connector_detect() local
1054 if (hdmi->hpd) { in sti_hdmi_connector_detect()
1055 DRM_DEBUG_DRIVER("hdmi cable connected\n"); in sti_hdmi_connector_detect()
1059 DRM_DEBUG_DRIVER("hdmi cable disconnected\n"); in sti_hdmi_connector_detect()
1060 cec_notifier_set_phys_addr(hdmi->notifier, CEC_PHYS_ADDR_INVALID); in sti_hdmi_connector_detect()
1065 struct drm_connector *connector) in sti_hdmi_connector_init_property() argument
1068 = to_sti_hdmi_connector(connector); in sti_hdmi_connector_init_property()
1069 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_connector_init_property() local
1073 hdmi->colorspace = DEFAULT_COLORSPACE_MODE; in sti_hdmi_connector_init_property()
1081 hdmi_connector->colorspace_property = prop; in sti_hdmi_connector_init_property()
1082 drm_object_attach_property(&connector->base, prop, hdmi->colorspace); in sti_hdmi_connector_init_property()
1086 sti_hdmi_connector_set_property(struct drm_connector *connector, in sti_hdmi_connector_set_property() argument
1092 = to_sti_hdmi_connector(connector); in sti_hdmi_connector_set_property()
1093 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_connector_set_property() local
1095 if (property == hdmi_connector->colorspace_property) { in sti_hdmi_connector_set_property()
1096 hdmi->colorspace = val; in sti_hdmi_connector_set_property()
1100 DRM_ERROR("failed to set hdmi connector property\n"); in sti_hdmi_connector_set_property()
1101 return -EINVAL; in sti_hdmi_connector_set_property()
1105 sti_hdmi_connector_get_property(struct drm_connector *connector, in sti_hdmi_connector_get_property() argument
1111 = to_sti_hdmi_connector(connector); in sti_hdmi_connector_get_property()
1112 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_connector_get_property() local
1114 if (property == hdmi_connector->colorspace_property) { in sti_hdmi_connector_get_property()
1115 *val = hdmi->colorspace; in sti_hdmi_connector_get_property()
1119 DRM_ERROR("failed to get hdmi connector property\n"); in sti_hdmi_connector_get_property()
1120 return -EINVAL; in sti_hdmi_connector_get_property()
1123 static int sti_hdmi_late_register(struct drm_connector *connector) in sti_hdmi_late_register() argument
1126 = to_sti_hdmi_connector(connector); in sti_hdmi_late_register()
1127 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_late_register() local
1129 hdmi_debugfs_init(hdmi, hdmi->drm_dev->primary); in sti_hdmi_late_register()
1150 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { in sti_hdmi_find_encoder()
1151 if (encoder->encoder_type == DRM_MODE_ENCODER_TMDS) in sti_hdmi_find_encoder()
1160 struct sti_hdmi *hdmi = dev_get_drvdata(dev); in hdmi_audio_shutdown() local
1168 hdmi_write(hdmi, audio_cfg, HDMI_AUDIO_CFG); in hdmi_audio_shutdown()
1170 hdmi->audio.enabled = false; in hdmi_audio_shutdown()
1171 hdmi_audio_infoframe_config(hdmi); in hdmi_audio_shutdown()
1179 struct sti_hdmi *hdmi = dev_get_drvdata(dev); in hdmi_audio_hw_params() local
1184 if ((daifmt->fmt != HDMI_I2S) || daifmt->bit_clk_inv || in hdmi_audio_hw_params()
1185 daifmt->frame_clk_inv || daifmt->bit_clk_provider || in hdmi_audio_hw_params()
1186 daifmt->frame_clk_provider) { in hdmi_audio_hw_params()
1188 daifmt->bit_clk_inv, daifmt->frame_clk_inv, in hdmi_audio_hw_params()
1189 daifmt->bit_clk_provider, in hdmi_audio_hw_params()
1190 daifmt->frame_clk_provider); in hdmi_audio_hw_params()
1191 return -EINVAL; in hdmi_audio_hw_params()
1194 hdmi->audio.sample_width = params->sample_width; in hdmi_audio_hw_params()
1195 hdmi->audio.sample_rate = params->sample_rate; in hdmi_audio_hw_params()
1196 hdmi->audio.cea = params->cea; in hdmi_audio_hw_params()
1198 hdmi->audio.enabled = true; in hdmi_audio_hw_params()
1200 ret = hdmi_audio_configure(hdmi); in hdmi_audio_hw_params()
1210 struct sti_hdmi *hdmi = dev_get_drvdata(dev); in hdmi_audio_mute() local
1215 hdmi_write(hdmi, HDMI_SAMPLE_FLAT_ALL, HDMI_SAMPLE_FLAT_MASK); in hdmi_audio_mute()
1217 hdmi_write(hdmi, HDMI_SAMPLE_FLAT_NO, HDMI_SAMPLE_FLAT_MASK); in hdmi_audio_mute()
1224 struct sti_hdmi *hdmi = dev_get_drvdata(dev); in hdmi_audio_get_eld() local
1225 struct drm_connector *connector = hdmi->drm_connector; in hdmi_audio_get_eld() local
1228 memcpy(buf, connector->eld, min(sizeof(connector->eld), len)); in hdmi_audio_get_eld()
1242 struct sti_hdmi *hdmi) in sti_hdmi_register_audio_driver() argument
1252 hdmi->audio.enabled = false; in sti_hdmi_register_audio_driver()
1254 hdmi->audio_pdev = platform_device_register_data( in sti_hdmi_register_audio_driver()
1258 if (IS_ERR(hdmi->audio_pdev)) in sti_hdmi_register_audio_driver()
1259 return PTR_ERR(hdmi->audio_pdev); in sti_hdmi_register_audio_driver()
1268 struct sti_hdmi *hdmi = dev_get_drvdata(dev); in sti_hdmi_bind() local
1271 struct sti_hdmi_connector *connector; in sti_hdmi_bind() local
1278 hdmi->drm_dev = drm_dev; in sti_hdmi_bind()
1282 return -EINVAL; in sti_hdmi_bind()
1284 connector = devm_kzalloc(dev, sizeof(*connector), GFP_KERNEL); in sti_hdmi_bind()
1285 if (!connector) in sti_hdmi_bind()
1286 return -EINVAL; in sti_hdmi_bind()
1288 connector->hdmi = hdmi; in sti_hdmi_bind()
1292 return -EINVAL; in sti_hdmi_bind()
1294 bridge->driver_private = hdmi; in sti_hdmi_bind()
1295 bridge->funcs = &sti_hdmi_bridge_funcs; in sti_hdmi_bind()
1298 connector->encoder = encoder; in sti_hdmi_bind()
1300 drm_connector = (struct drm_connector *)connector; in sti_hdmi_bind()
1302 drm_connector->polled = DRM_CONNECTOR_POLL_HPD; in sti_hdmi_bind()
1307 hdmi->ddc_adapt); in sti_hdmi_bind()
1314 hdmi->drm_connector = drm_connector; in sti_hdmi_bind()
1318 DRM_ERROR("Failed to attach a connector to a encoder\n"); in sti_hdmi_bind()
1322 err = sti_hdmi_register_audio_driver(dev, hdmi); in sti_hdmi_bind()
1329 err = hdmi_audio_infoframe_init(&hdmi->audio.cea); in sti_hdmi_bind()
1336 hdmi->notifier = cec_notifier_conn_register(&hdmi->dev, NULL, in sti_hdmi_bind()
1338 if (!hdmi->notifier) { in sti_hdmi_bind()
1339 hdmi->drm_connector = NULL; in sti_hdmi_bind()
1340 return -ENOMEM; in sti_hdmi_bind()
1344 hdmi_write(hdmi, HDMI_DEFAULT_INT, HDMI_INT_EN); in sti_hdmi_bind()
1349 hdmi->drm_connector = NULL; in sti_hdmi_bind()
1350 return -EINVAL; in sti_hdmi_bind()
1356 struct sti_hdmi *hdmi = dev_get_drvdata(dev); in sti_hdmi_unbind() local
1358 cec_notifier_conn_unregister(hdmi->notifier); in sti_hdmi_unbind()
1368 .compatible = "st,stih407-hdmi",
1378 struct device *dev = &pdev->dev; in sti_hdmi_probe()
1379 struct sti_hdmi *hdmi; in sti_hdmi_probe() local
1380 struct device_node *np = dev->of_node; in sti_hdmi_probe()
1387 hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL); in sti_hdmi_probe()
1388 if (!hdmi) in sti_hdmi_probe()
1389 return -ENOMEM; in sti_hdmi_probe()
1391 ddc = of_parse_phandle(pdev->dev.of_node, "ddc", 0); in sti_hdmi_probe()
1393 hdmi->ddc_adapt = of_get_i2c_adapter_by_node(ddc); in sti_hdmi_probe()
1395 if (!hdmi->ddc_adapt) in sti_hdmi_probe()
1396 return -EPROBE_DEFER; in sti_hdmi_probe()
1399 hdmi->dev = pdev->dev; in sti_hdmi_probe()
1402 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hdmi-reg"); in sti_hdmi_probe()
1404 DRM_ERROR("Invalid hdmi resource\n"); in sti_hdmi_probe()
1405 ret = -ENOMEM; in sti_hdmi_probe()
1408 hdmi->regs = devm_ioremap(dev, res->start, resource_size(res)); in sti_hdmi_probe()
1409 if (!hdmi->regs) { in sti_hdmi_probe()
1410 ret = -ENOMEM; in sti_hdmi_probe()
1414 hdmi->phy_ops = (struct hdmi_phy_ops *) in sti_hdmi_probe()
1415 of_match_node(hdmi_of_match, np)->data; in sti_hdmi_probe()
1418 hdmi->clk_pix = devm_clk_get(dev, "pix"); in sti_hdmi_probe()
1419 if (IS_ERR(hdmi->clk_pix)) { in sti_hdmi_probe()
1421 ret = PTR_ERR(hdmi->clk_pix); in sti_hdmi_probe()
1425 hdmi->clk_tmds = devm_clk_get(dev, "tmds"); in sti_hdmi_probe()
1426 if (IS_ERR(hdmi->clk_tmds)) { in sti_hdmi_probe()
1428 ret = PTR_ERR(hdmi->clk_tmds); in sti_hdmi_probe()
1432 hdmi->clk_phy = devm_clk_get(dev, "phy"); in sti_hdmi_probe()
1433 if (IS_ERR(hdmi->clk_phy)) { in sti_hdmi_probe()
1435 ret = PTR_ERR(hdmi->clk_phy); in sti_hdmi_probe()
1439 hdmi->clk_audio = devm_clk_get(dev, "audio"); in sti_hdmi_probe()
1440 if (IS_ERR(hdmi->clk_audio)) { in sti_hdmi_probe()
1442 ret = PTR_ERR(hdmi->clk_audio); in sti_hdmi_probe()
1446 hdmi->hpd = readl(hdmi->regs + HDMI_STA) & HDMI_STA_HOT_PLUG; in sti_hdmi_probe()
1448 init_waitqueue_head(&hdmi->wait_event); in sti_hdmi_probe()
1450 hdmi->irq = platform_get_irq_byname(pdev, "irq"); in sti_hdmi_probe()
1451 if (hdmi->irq < 0) { in sti_hdmi_probe()
1452 DRM_ERROR("Cannot get HDMI irq\n"); in sti_hdmi_probe()
1453 ret = hdmi->irq; in sti_hdmi_probe()
1457 ret = devm_request_threaded_irq(dev, hdmi->irq, hdmi_irq, in sti_hdmi_probe()
1458 hdmi_irq_thread, IRQF_ONESHOT, dev_name(dev), hdmi); in sti_hdmi_probe()
1460 DRM_ERROR("Failed to register HDMI interrupt\n"); in sti_hdmi_probe()
1464 hdmi->reset = devm_reset_control_get(dev, "hdmi"); in sti_hdmi_probe()
1465 /* Take hdmi out of reset */ in sti_hdmi_probe()
1466 if (!IS_ERR(hdmi->reset)) in sti_hdmi_probe()
1467 reset_control_deassert(hdmi->reset); in sti_hdmi_probe()
1469 platform_set_drvdata(pdev, hdmi); in sti_hdmi_probe()
1471 return component_add(&pdev->dev, &sti_hdmi_ops); in sti_hdmi_probe()
1474 i2c_put_adapter(hdmi->ddc_adapt); in sti_hdmi_probe()
1481 struct sti_hdmi *hdmi = dev_get_drvdata(&pdev->dev); in sti_hdmi_remove() local
1483 i2c_put_adapter(hdmi->ddc_adapt); in sti_hdmi_remove()
1484 if (hdmi->audio_pdev) in sti_hdmi_remove()
1485 platform_device_unregister(hdmi->audio_pdev); in sti_hdmi_remove()
1486 component_del(&pdev->dev, &sti_hdmi_ops); in sti_hdmi_remove()
1491 .name = "sti-hdmi",