Lines Matching +full:hdmi +full:- +full:connector
1 // SPDX-License-Identifier: GPL-2.0
10 #include <linux/hdmi.h>
25 #include <sound/hdmi-codec.h>
95 #define HDMI_IFRAME_CFG_DI_N(x, n) ((x) << ((n-1)*4)) /* n from 1 to 6 */
163 struct sti_hdmi *hdmi; member
176 u32 hdmi_read(struct sti_hdmi *hdmi, int offset) in hdmi_read() argument
178 return readl(hdmi->regs + offset); in hdmi_read()
181 void hdmi_write(struct sti_hdmi *hdmi, u32 val, int offset) in hdmi_write() argument
183 writel(val, hdmi->regs + offset); in hdmi_write()
187 * HDMI interrupt handler threaded
190 * @arg: connector structure
194 struct sti_hdmi *hdmi = arg; in hdmi_irq_thread() local
197 if (hdmi->irq_status & HDMI_INT_HOT_PLUG) { in hdmi_irq_thread()
198 hdmi->hpd = readl(hdmi->regs + HDMI_STA) & HDMI_STA_HOT_PLUG; in hdmi_irq_thread()
199 if (hdmi->drm_dev) in hdmi_irq_thread()
200 drm_helper_hpd_irq_event(hdmi->drm_dev); in hdmi_irq_thread()
206 if (hdmi->irq_status & (HDMI_INT_SW_RST | HDMI_INT_DLL_LCK)) { in hdmi_irq_thread()
207 hdmi->event_received = true; in hdmi_irq_thread()
208 wake_up_interruptible(&hdmi->wait_event); in hdmi_irq_thread()
212 if (hdmi->irq_status & HDMI_INT_AUDIO_FIFO_XRUN) in hdmi_irq_thread()
219 * HDMI interrupt handler
222 * @arg: connector structure
226 struct sti_hdmi *hdmi = arg; in hdmi_irq() local
229 hdmi->irq_status = hdmi_read(hdmi, HDMI_INT_STA); in hdmi_irq()
232 hdmi_write(hdmi, hdmi->irq_status, HDMI_INT_CLR); in hdmi_irq()
235 hdmi_read(hdmi, HDMI_INT_STA); in hdmi_irq()
241 * Set hdmi active area depending on the drm display mode selected
243 * @hdmi: pointer on the hdmi internal structure
245 static void hdmi_active_area(struct sti_hdmi *hdmi) in hdmi_active_area() argument
250 xmin = sti_vtg_get_pixel_number(hdmi->mode, 1); in hdmi_active_area()
251 xmax = sti_vtg_get_pixel_number(hdmi->mode, hdmi->mode.hdisplay); in hdmi_active_area()
252 ymin = sti_vtg_get_line_number(hdmi->mode, 0); in hdmi_active_area()
253 ymax = sti_vtg_get_line_number(hdmi->mode, hdmi->mode.vdisplay - 1); in hdmi_active_area()
255 hdmi_write(hdmi, xmin, HDMI_ACTIVE_VID_XMIN); in hdmi_active_area()
256 hdmi_write(hdmi, xmax, HDMI_ACTIVE_VID_XMAX); in hdmi_active_area()
257 hdmi_write(hdmi, ymin, HDMI_ACTIVE_VID_YMIN); in hdmi_active_area()
258 hdmi_write(hdmi, ymax, HDMI_ACTIVE_VID_YMAX); in hdmi_active_area()
262 * Overall hdmi configuration
264 * @hdmi: pointer on the hdmi internal structure
266 static void hdmi_config(struct sti_hdmi *hdmi) in hdmi_config() argument
277 if (hdmi->hdmi_monitor) in hdmi_config()
281 if (hdmi->mode.flags & DRM_MODE_FLAG_NHSYNC) { in hdmi_config()
287 if (hdmi->mode.flags & DRM_MODE_FLAG_NVSYNC) { in hdmi_config()
292 /* Enable HDMI */ in hdmi_config()
295 hdmi_write(hdmi, conf, HDMI_CFG); in hdmi_config()
301 * @hdmi: pointer on the hdmi internal structure
304 static void hdmi_infoframe_reset(struct sti_hdmi *hdmi, in hdmi_infoframe_reset() argument
329 val = hdmi_read(hdmi, HDMI_SW_DI_CFG); in hdmi_infoframe_reset()
331 hdmi_write(hdmi, val, HDMI_SW_DI_CFG); in hdmi_infoframe_reset()
334 hdmi_write(hdmi, 0x0, head_offset); in hdmi_infoframe_reset()
336 hdmi_write(hdmi, 0x0, pack_offset + i); in hdmi_infoframe_reset()
342 * @ptr: pointer on the hdmi internal structure
350 for (i = size; i > 0; i--) in hdmi_infoframe_subpack()
351 value = (value << 8) | ptr[i - 1]; in hdmi_infoframe_subpack()
359 * @hdmi: pointer on the hdmi internal structure
363 static void hdmi_infoframe_write_infopack(struct sti_hdmi *hdmi, in hdmi_infoframe_write_infopack() argument
396 val = hdmi_read(hdmi, HDMI_SW_DI_CFG); in hdmi_infoframe_write_infopack()
398 hdmi_write(hdmi, val, HDMI_SW_DI_CFG); in hdmi_infoframe_write_infopack()
403 writel(val, hdmi->regs + head_offset); in hdmi_infoframe_write_infopack()
410 size = size - HDMI_INFOFRAME_HEADER_SIZE + 1; in hdmi_infoframe_write_infopack()
414 num = min_t(size_t, size - i, sizeof(u32)); in hdmi_infoframe_write_infopack()
417 writel(val, hdmi->regs + pack_offset + i); in hdmi_infoframe_write_infopack()
421 val = hdmi_read(hdmi, HDMI_SW_DI_CFG); in hdmi_infoframe_write_infopack()
423 hdmi_write(hdmi, val, HDMI_SW_DI_CFG); in hdmi_infoframe_write_infopack()
430 * contains information about HDMI transmission mode such as color space,
433 * @hdmi: pointer on the hdmi internal structure
437 static int hdmi_avi_infoframe_config(struct sti_hdmi *hdmi) in hdmi_avi_infoframe_config() argument
439 struct drm_display_mode *mode = &hdmi->mode; in hdmi_avi_infoframe_config()
447 hdmi->drm_connector, mode); in hdmi_avi_infoframe_config()
454 infoframe.colorspace = hdmi->colorspace; in hdmi_avi_infoframe_config()
464 hdmi_infoframe_write_infopack(hdmi, buffer, ret); in hdmi_avi_infoframe_config()
473 * contains information about HDMI transmission mode such as audio codec,
476 * @hdmi: pointer on the hdmi internal structure
480 static int hdmi_audio_infoframe_config(struct sti_hdmi *hdmi) in hdmi_audio_infoframe_config() argument
482 struct hdmi_audio_params *audio = &hdmi->audio; in hdmi_audio_infoframe_config()
487 audio->enabled ? "enable" : "disable"); in hdmi_audio_infoframe_config()
488 if (audio->enabled) { in hdmi_audio_infoframe_config()
490 ret = hdmi_audio_infoframe_pack(&audio->cea, buffer, in hdmi_audio_infoframe_config()
496 hdmi_infoframe_write_infopack(hdmi, buffer, ret); in hdmi_audio_infoframe_config()
499 val = hdmi_read(hdmi, HDMI_SW_DI_CFG); in hdmi_audio_infoframe_config()
502 hdmi_write(hdmi, val, HDMI_SW_DI_CFG); in hdmi_audio_infoframe_config()
514 * @hdmi: pointer on the hdmi internal structure
519 static int hdmi_vendor_infoframe_config(struct sti_hdmi *hdmi) in hdmi_vendor_infoframe_config() argument
521 struct drm_display_mode *mode = &hdmi->mode; in hdmi_vendor_infoframe_config()
529 hdmi->drm_connector, in hdmi_vendor_infoframe_config()
547 hdmi_infoframe_write_infopack(hdmi, buffer, ret); in hdmi_vendor_infoframe_config()
555 * Software reset of the hdmi subsystem
557 * @hdmi: pointer on the hdmi internal structure
560 static void hdmi_swreset(struct sti_hdmi *hdmi) in hdmi_swreset() argument
566 /* Enable hdmi_audio clock only during hdmi reset */ in hdmi_swreset()
567 if (clk_prepare_enable(hdmi->clk_audio)) in hdmi_swreset()
571 hdmi->event_received = false; in hdmi_swreset()
573 val = hdmi_read(hdmi, HDMI_CFG); in hdmi_swreset()
575 hdmi_write(hdmi, val, HDMI_CFG); in hdmi_swreset()
578 wait_event_interruptible_timeout(hdmi->wait_event, in hdmi_swreset()
579 hdmi->event_received, in hdmi_swreset()
587 if ((hdmi_read(hdmi, HDMI_STA) & HDMI_STA_SW_RST) == 0) in hdmi_swreset()
588 DRM_DEBUG_DRIVER("Warning: HDMI sw reset timeout occurs\n"); in hdmi_swreset()
590 val = hdmi_read(hdmi, HDMI_CFG); in hdmi_swreset()
592 hdmi_write(hdmi, val, HDMI_CFG); in hdmi_swreset()
595 clk_disable_unprepare(hdmi->clk_audio); in hdmi_swreset()
598 #define DBGFS_PRINT_STR(str1, str2) seq_printf(s, "%-24s %s\n", str1, str2)
599 #define DBGFS_PRINT_INT(str1, int2) seq_printf(s, "%-24s %d\n", str1, int2)
600 #define DBGFS_DUMP(str, reg) seq_printf(s, "%s %-25s 0x%08X", str, #reg, \
601 hdmi_read(hdmi, reg))
610 DBGFS_PRINT_STR("mode:", tmp ? "HDMI" : "DVI"); in hdmi_dbg_cfg()
637 DBGFS_PRINT_STR("hdmi cable:", tmp ? "connected" : "not connected"); in hdmi_dbg_sta()
670 struct drm_info_node *node = s->private; in hdmi_dbg_show()
671 struct sti_hdmi *hdmi = (struct sti_hdmi *)node->info_ent->data; in hdmi_dbg_show() local
673 seq_printf(s, "HDMI: (vaddr = 0x%p)", hdmi->regs); in hdmi_dbg_show()
675 hdmi_dbg_cfg(s, hdmi_read(hdmi, HDMI_CFG)); in hdmi_dbg_show()
678 hdmi_dbg_sta(s, hdmi_read(hdmi, HDMI_STA)); in hdmi_dbg_show()
681 DBGFS_PRINT_INT("Xmin:", hdmi_read(hdmi, HDMI_ACTIVE_VID_XMIN)); in hdmi_dbg_show()
684 DBGFS_PRINT_INT("Xmax:", hdmi_read(hdmi, HDMI_ACTIVE_VID_XMAX)); in hdmi_dbg_show()
687 DBGFS_PRINT_INT("Ymin:", hdmi_read(hdmi, HDMI_ACTIVE_VID_YMIN)); in hdmi_dbg_show()
690 DBGFS_PRINT_INT("Ymax:", hdmi_read(hdmi, HDMI_ACTIVE_VID_YMAX)); in hdmi_dbg_show()
692 hdmi_dbg_sw_di_cfg(s, hdmi_read(hdmi, HDMI_SW_DI_CFG)); in hdmi_dbg_show()
733 { "hdmi", hdmi_dbg_show, 0, NULL },
736 static void hdmi_debugfs_init(struct sti_hdmi *hdmi, struct drm_minor *minor) in hdmi_debugfs_init() argument
741 hdmi_debugfs_files[i].data = hdmi; in hdmi_debugfs_init()
745 minor->debugfs_root, minor); in hdmi_debugfs_init()
750 struct sti_hdmi *hdmi = bridge->driver_private; in sti_hdmi_disable() local
752 u32 val = hdmi_read(hdmi, HDMI_CFG); in sti_hdmi_disable()
754 if (!hdmi->enabled) in sti_hdmi_disable()
759 /* Disable HDMI */ in sti_hdmi_disable()
761 hdmi_write(hdmi, val, HDMI_CFG); in sti_hdmi_disable()
763 hdmi_write(hdmi, 0xffffffff, HDMI_INT_CLR); in sti_hdmi_disable()
766 hdmi->phy_ops->stop(hdmi); in sti_hdmi_disable()
769 hdmi_infoframe_reset(hdmi, HDMI_IFRAME_SLOT_AVI); in sti_hdmi_disable()
770 hdmi_infoframe_reset(hdmi, HDMI_IFRAME_SLOT_AUDIO); in sti_hdmi_disable()
771 hdmi_infoframe_reset(hdmi, HDMI_IFRAME_SLOT_VENDOR); in sti_hdmi_disable()
774 hdmi_write(hdmi, 0x0000, HDMI_DFLT_CHL0_DAT); in sti_hdmi_disable()
775 hdmi_write(hdmi, 0x0000, HDMI_DFLT_CHL1_DAT); in sti_hdmi_disable()
776 hdmi_write(hdmi, 0x0060, HDMI_DFLT_CHL2_DAT); in sti_hdmi_disable()
778 /* Disable/unprepare hdmi clock */ in sti_hdmi_disable()
779 clk_disable_unprepare(hdmi->clk_phy); in sti_hdmi_disable()
780 clk_disable_unprepare(hdmi->clk_tmds); in sti_hdmi_disable()
781 clk_disable_unprepare(hdmi->clk_pix); in sti_hdmi_disable()
783 hdmi->enabled = false; in sti_hdmi_disable()
785 cec_notifier_set_phys_addr(hdmi->notifier, CEC_PHYS_ADDR_INVALID); in sti_hdmi_disable()
789 * sti_hdmi_audio_get_non_coherent_n() - get N parameter for non-coherent
790 * clocks. None-coherent clocks means that audio and TMDS clocks have not the
796 * Values computed are based on table described in HDMI specification 1.4b
827 /* Not pre-defined, recommended value: 128 * fs / 1000 */ in sti_hdmi_audio_get_non_coherent_n()
834 static int hdmi_audio_configure(struct sti_hdmi *hdmi) in hdmi_audio_configure() argument
837 struct hdmi_audio_params *params = &hdmi->audio; in hdmi_audio_configure()
838 struct hdmi_audio_infoframe *info = ¶ms->cea; in hdmi_audio_configure()
842 if (!hdmi->enabled) in hdmi_audio_configure()
846 n = sti_hdmi_audio_get_non_coherent_n(params->sample_rate); in hdmi_audio_configure()
849 params->sample_rate, hdmi->mode.clock * 1000, n); in hdmi_audio_configure()
850 hdmi_write(hdmi, n, HDMI_AUDN); in hdmi_audio_configure()
852 /* update HDMI registers according to configuration */ in hdmi_audio_configure()
856 switch (info->channels) { in hdmi_audio_configure()
871 info->channels); in hdmi_audio_configure()
872 return -EINVAL; in hdmi_audio_configure()
875 hdmi_write(hdmi, audio_cfg, HDMI_AUDIO_CFG); in hdmi_audio_configure()
877 return hdmi_audio_infoframe_config(hdmi); in hdmi_audio_configure()
882 struct sti_hdmi *hdmi = bridge->driver_private; in sti_hdmi_pre_enable() local
886 if (hdmi->enabled) in sti_hdmi_pre_enable()
890 if (clk_prepare_enable(hdmi->clk_pix)) in sti_hdmi_pre_enable()
892 if (clk_prepare_enable(hdmi->clk_tmds)) in sti_hdmi_pre_enable()
894 if (clk_prepare_enable(hdmi->clk_phy)) in sti_hdmi_pre_enable()
897 hdmi->enabled = true; in sti_hdmi_pre_enable()
899 /* Program hdmi serializer and start phy */ in sti_hdmi_pre_enable()
900 if (!hdmi->phy_ops->start(hdmi)) { in sti_hdmi_pre_enable()
901 DRM_ERROR("Unable to start hdmi phy\n"); in sti_hdmi_pre_enable()
905 /* Program hdmi active area */ in sti_hdmi_pre_enable()
906 hdmi_active_area(hdmi); in sti_hdmi_pre_enable()
909 hdmi_write(hdmi, HDMI_WORKING_INT, HDMI_INT_EN); in sti_hdmi_pre_enable()
911 /* Program hdmi config */ in sti_hdmi_pre_enable()
912 hdmi_config(hdmi); in sti_hdmi_pre_enable()
915 if (hdmi_avi_infoframe_config(hdmi)) in sti_hdmi_pre_enable()
918 if (hdmi->audio.enabled) { in sti_hdmi_pre_enable()
919 if (hdmi_audio_configure(hdmi)) in sti_hdmi_pre_enable()
922 hdmi_audio_infoframe_config(hdmi); in sti_hdmi_pre_enable()
926 if (hdmi_vendor_infoframe_config(hdmi)) in sti_hdmi_pre_enable()
930 hdmi_swreset(hdmi); in sti_hdmi_pre_enable()
937 struct sti_hdmi *hdmi = bridge->driver_private; in sti_hdmi_set_mode() local
942 /* Copy the drm display mode in the connector local structure */ in sti_hdmi_set_mode()
943 memcpy(&hdmi->mode, mode, sizeof(struct drm_display_mode)); in sti_hdmi_set_mode()
946 ret = clk_set_rate(hdmi->clk_pix, mode->clock * 1000); in sti_hdmi_set_mode()
949 mode->clock * 1000); in sti_hdmi_set_mode()
952 ret = clk_set_rate(hdmi->clk_phy, mode->clock * 1000); in sti_hdmi_set_mode()
955 mode->clock * 1000); in sti_hdmi_set_mode()
973 static int sti_hdmi_connector_get_modes(struct drm_connector *connector) in sti_hdmi_connector_get_modes() argument
976 = to_sti_hdmi_connector(connector); in sti_hdmi_connector_get_modes()
977 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_connector_get_modes() local
983 edid = drm_get_edid(connector, hdmi->ddc_adapt); in sti_hdmi_connector_get_modes()
987 hdmi->hdmi_monitor = drm_detect_hdmi_monitor(edid); in sti_hdmi_connector_get_modes()
989 (hdmi->hdmi_monitor ? "hdmi monitor" : "dvi monitor"), in sti_hdmi_connector_get_modes()
990 edid->width_cm, edid->height_cm); in sti_hdmi_connector_get_modes()
991 cec_notifier_set_phys_addr_from_edid(hdmi->notifier, edid); in sti_hdmi_connector_get_modes()
993 count = drm_add_edid_modes(connector, edid); in sti_hdmi_connector_get_modes()
994 drm_connector_update_edid_property(connector, edid); in sti_hdmi_connector_get_modes()
1000 DRM_ERROR("Can't read HDMI EDID\n"); in sti_hdmi_connector_get_modes()
1006 static int sti_hdmi_connector_mode_valid(struct drm_connector *connector, in sti_hdmi_connector_mode_valid() argument
1009 int target = mode->clock * 1000; in sti_hdmi_connector_mode_valid()
1010 int target_min = target - CLK_TOLERANCE_HZ; in sti_hdmi_connector_mode_valid()
1014 = to_sti_hdmi_connector(connector); in sti_hdmi_connector_mode_valid()
1015 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_connector_mode_valid() local
1018 result = clk_round_rate(hdmi->clk_pix, target); in sti_hdmi_connector_mode_valid()
1024 DRM_DEBUG_DRIVER("hdmi pixclk=%d not supported\n", target); in sti_hdmi_connector_mode_valid()
1039 sti_hdmi_connector_detect(struct drm_connector *connector, bool force) in sti_hdmi_connector_detect() argument
1042 = to_sti_hdmi_connector(connector); in sti_hdmi_connector_detect()
1043 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_connector_detect() local
1047 if (hdmi->hpd) { in sti_hdmi_connector_detect()
1048 DRM_DEBUG_DRIVER("hdmi cable connected\n"); in sti_hdmi_connector_detect()
1052 DRM_DEBUG_DRIVER("hdmi cable disconnected\n"); in sti_hdmi_connector_detect()
1053 cec_notifier_set_phys_addr(hdmi->notifier, CEC_PHYS_ADDR_INVALID); in sti_hdmi_connector_detect()
1058 struct drm_connector *connector) in sti_hdmi_connector_init_property() argument
1061 = to_sti_hdmi_connector(connector); in sti_hdmi_connector_init_property()
1062 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_connector_init_property() local
1066 hdmi->colorspace = DEFAULT_COLORSPACE_MODE; in sti_hdmi_connector_init_property()
1074 hdmi_connector->colorspace_property = prop; in sti_hdmi_connector_init_property()
1075 drm_object_attach_property(&connector->base, prop, hdmi->colorspace); in sti_hdmi_connector_init_property()
1079 sti_hdmi_connector_set_property(struct drm_connector *connector, in sti_hdmi_connector_set_property() argument
1085 = to_sti_hdmi_connector(connector); in sti_hdmi_connector_set_property()
1086 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_connector_set_property() local
1088 if (property == hdmi_connector->colorspace_property) { in sti_hdmi_connector_set_property()
1089 hdmi->colorspace = val; in sti_hdmi_connector_set_property()
1093 DRM_ERROR("failed to set hdmi connector property\n"); in sti_hdmi_connector_set_property()
1094 return -EINVAL; in sti_hdmi_connector_set_property()
1098 sti_hdmi_connector_get_property(struct drm_connector *connector, in sti_hdmi_connector_get_property() argument
1104 = to_sti_hdmi_connector(connector); in sti_hdmi_connector_get_property()
1105 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_connector_get_property() local
1107 if (property == hdmi_connector->colorspace_property) { in sti_hdmi_connector_get_property()
1108 *val = hdmi->colorspace; in sti_hdmi_connector_get_property()
1112 DRM_ERROR("failed to get hdmi connector property\n"); in sti_hdmi_connector_get_property()
1113 return -EINVAL; in sti_hdmi_connector_get_property()
1116 static int sti_hdmi_late_register(struct drm_connector *connector) in sti_hdmi_late_register() argument
1119 = to_sti_hdmi_connector(connector); in sti_hdmi_late_register()
1120 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_late_register() local
1122 hdmi_debugfs_init(hdmi, hdmi->drm_dev->primary); in sti_hdmi_late_register()
1143 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { in sti_hdmi_find_encoder()
1144 if (encoder->encoder_type == DRM_MODE_ENCODER_TMDS) in sti_hdmi_find_encoder()
1153 struct sti_hdmi *hdmi = dev_get_drvdata(dev); in hdmi_audio_shutdown() local
1161 hdmi_write(hdmi, audio_cfg, HDMI_AUDIO_CFG); in hdmi_audio_shutdown()
1163 hdmi->audio.enabled = false; in hdmi_audio_shutdown()
1164 hdmi_audio_infoframe_config(hdmi); in hdmi_audio_shutdown()
1172 struct sti_hdmi *hdmi = dev_get_drvdata(dev); in hdmi_audio_hw_params() local
1177 if ((daifmt->fmt != HDMI_I2S) || daifmt->bit_clk_inv || in hdmi_audio_hw_params()
1178 daifmt->frame_clk_inv || daifmt->bit_clk_master || in hdmi_audio_hw_params()
1179 daifmt->frame_clk_master) { in hdmi_audio_hw_params()
1181 daifmt->bit_clk_inv, daifmt->frame_clk_inv, in hdmi_audio_hw_params()
1182 daifmt->bit_clk_master, in hdmi_audio_hw_params()
1183 daifmt->frame_clk_master); in hdmi_audio_hw_params()
1184 return -EINVAL; in hdmi_audio_hw_params()
1187 hdmi->audio.sample_width = params->sample_width; in hdmi_audio_hw_params()
1188 hdmi->audio.sample_rate = params->sample_rate; in hdmi_audio_hw_params()
1189 hdmi->audio.cea = params->cea; in hdmi_audio_hw_params()
1191 hdmi->audio.enabled = true; in hdmi_audio_hw_params()
1193 ret = hdmi_audio_configure(hdmi); in hdmi_audio_hw_params()
1203 struct sti_hdmi *hdmi = dev_get_drvdata(dev); in hdmi_audio_mute() local
1208 hdmi_write(hdmi, HDMI_SAMPLE_FLAT_ALL, HDMI_SAMPLE_FLAT_MASK); in hdmi_audio_mute()
1210 hdmi_write(hdmi, HDMI_SAMPLE_FLAT_NO, HDMI_SAMPLE_FLAT_MASK); in hdmi_audio_mute()
1217 struct sti_hdmi *hdmi = dev_get_drvdata(dev); in hdmi_audio_get_eld() local
1218 struct drm_connector *connector = hdmi->drm_connector; in hdmi_audio_get_eld() local
1221 memcpy(buf, connector->eld, min(sizeof(connector->eld), len)); in hdmi_audio_get_eld()
1235 struct sti_hdmi *hdmi) in sti_hdmi_register_audio_driver() argument
1245 hdmi->audio.enabled = false; in sti_hdmi_register_audio_driver()
1247 hdmi->audio_pdev = platform_device_register_data( in sti_hdmi_register_audio_driver()
1251 if (IS_ERR(hdmi->audio_pdev)) in sti_hdmi_register_audio_driver()
1252 return PTR_ERR(hdmi->audio_pdev); in sti_hdmi_register_audio_driver()
1261 struct sti_hdmi *hdmi = dev_get_drvdata(dev); in sti_hdmi_bind() local
1264 struct sti_hdmi_connector *connector; in sti_hdmi_bind() local
1271 hdmi->drm_dev = drm_dev; in sti_hdmi_bind()
1275 return -EINVAL; in sti_hdmi_bind()
1277 connector = devm_kzalloc(dev, sizeof(*connector), GFP_KERNEL); in sti_hdmi_bind()
1278 if (!connector) in sti_hdmi_bind()
1279 return -EINVAL; in sti_hdmi_bind()
1281 connector->hdmi = hdmi; in sti_hdmi_bind()
1285 return -EINVAL; in sti_hdmi_bind()
1287 bridge->driver_private = hdmi; in sti_hdmi_bind()
1288 bridge->funcs = &sti_hdmi_bridge_funcs; in sti_hdmi_bind()
1291 connector->encoder = encoder; in sti_hdmi_bind()
1293 drm_connector = (struct drm_connector *)connector; in sti_hdmi_bind()
1295 drm_connector->polled = DRM_CONNECTOR_POLL_HPD; in sti_hdmi_bind()
1300 hdmi->ddc_adapt); in sti_hdmi_bind()
1307 hdmi->drm_connector = drm_connector; in sti_hdmi_bind()
1311 DRM_ERROR("Failed to attach a connector to a encoder\n"); in sti_hdmi_bind()
1315 err = sti_hdmi_register_audio_driver(dev, hdmi); in sti_hdmi_bind()
1322 err = hdmi_audio_infoframe_init(&hdmi->audio.cea); in sti_hdmi_bind()
1329 hdmi->notifier = cec_notifier_conn_register(&hdmi->dev, NULL, in sti_hdmi_bind()
1331 if (!hdmi->notifier) { in sti_hdmi_bind()
1332 hdmi->drm_connector = NULL; in sti_hdmi_bind()
1333 return -ENOMEM; in sti_hdmi_bind()
1337 hdmi_write(hdmi, HDMI_DEFAULT_INT, HDMI_INT_EN); in sti_hdmi_bind()
1342 hdmi->drm_connector = NULL; in sti_hdmi_bind()
1343 return -EINVAL; in sti_hdmi_bind()
1349 struct sti_hdmi *hdmi = dev_get_drvdata(dev); in sti_hdmi_unbind() local
1351 cec_notifier_conn_unregister(hdmi->notifier); in sti_hdmi_unbind()
1361 .compatible = "st,stih407-hdmi",
1371 struct device *dev = &pdev->dev; in sti_hdmi_probe()
1372 struct sti_hdmi *hdmi; in sti_hdmi_probe() local
1373 struct device_node *np = dev->of_node; in sti_hdmi_probe()
1380 hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL); in sti_hdmi_probe()
1381 if (!hdmi) in sti_hdmi_probe()
1382 return -ENOMEM; in sti_hdmi_probe()
1384 ddc = of_parse_phandle(pdev->dev.of_node, "ddc", 0); in sti_hdmi_probe()
1386 hdmi->ddc_adapt = of_get_i2c_adapter_by_node(ddc); in sti_hdmi_probe()
1388 if (!hdmi->ddc_adapt) in sti_hdmi_probe()
1389 return -EPROBE_DEFER; in sti_hdmi_probe()
1392 hdmi->dev = pdev->dev; in sti_hdmi_probe()
1395 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hdmi-reg"); in sti_hdmi_probe()
1397 DRM_ERROR("Invalid hdmi resource\n"); in sti_hdmi_probe()
1398 ret = -ENOMEM; in sti_hdmi_probe()
1401 hdmi->regs = devm_ioremap(dev, res->start, resource_size(res)); in sti_hdmi_probe()
1402 if (!hdmi->regs) { in sti_hdmi_probe()
1403 ret = -ENOMEM; in sti_hdmi_probe()
1407 hdmi->phy_ops = (struct hdmi_phy_ops *) in sti_hdmi_probe()
1408 of_match_node(hdmi_of_match, np)->data; in sti_hdmi_probe()
1411 hdmi->clk_pix = devm_clk_get(dev, "pix"); in sti_hdmi_probe()
1412 if (IS_ERR(hdmi->clk_pix)) { in sti_hdmi_probe()
1414 ret = PTR_ERR(hdmi->clk_pix); in sti_hdmi_probe()
1418 hdmi->clk_tmds = devm_clk_get(dev, "tmds"); in sti_hdmi_probe()
1419 if (IS_ERR(hdmi->clk_tmds)) { in sti_hdmi_probe()
1421 ret = PTR_ERR(hdmi->clk_tmds); in sti_hdmi_probe()
1425 hdmi->clk_phy = devm_clk_get(dev, "phy"); in sti_hdmi_probe()
1426 if (IS_ERR(hdmi->clk_phy)) { in sti_hdmi_probe()
1428 ret = PTR_ERR(hdmi->clk_phy); in sti_hdmi_probe()
1432 hdmi->clk_audio = devm_clk_get(dev, "audio"); in sti_hdmi_probe()
1433 if (IS_ERR(hdmi->clk_audio)) { in sti_hdmi_probe()
1435 ret = PTR_ERR(hdmi->clk_audio); in sti_hdmi_probe()
1439 hdmi->hpd = readl(hdmi->regs + HDMI_STA) & HDMI_STA_HOT_PLUG; in sti_hdmi_probe()
1441 init_waitqueue_head(&hdmi->wait_event); in sti_hdmi_probe()
1443 hdmi->irq = platform_get_irq_byname(pdev, "irq"); in sti_hdmi_probe()
1444 if (hdmi->irq < 0) { in sti_hdmi_probe()
1445 DRM_ERROR("Cannot get HDMI irq\n"); in sti_hdmi_probe()
1446 ret = hdmi->irq; in sti_hdmi_probe()
1450 ret = devm_request_threaded_irq(dev, hdmi->irq, hdmi_irq, in sti_hdmi_probe()
1451 hdmi_irq_thread, IRQF_ONESHOT, dev_name(dev), hdmi); in sti_hdmi_probe()
1453 DRM_ERROR("Failed to register HDMI interrupt\n"); in sti_hdmi_probe()
1457 hdmi->reset = devm_reset_control_get(dev, "hdmi"); in sti_hdmi_probe()
1458 /* Take hdmi out of reset */ in sti_hdmi_probe()
1459 if (!IS_ERR(hdmi->reset)) in sti_hdmi_probe()
1460 reset_control_deassert(hdmi->reset); in sti_hdmi_probe()
1462 platform_set_drvdata(pdev, hdmi); in sti_hdmi_probe()
1464 return component_add(&pdev->dev, &sti_hdmi_ops); in sti_hdmi_probe()
1467 i2c_put_adapter(hdmi->ddc_adapt); in sti_hdmi_probe()
1474 struct sti_hdmi *hdmi = dev_get_drvdata(&pdev->dev); in sti_hdmi_remove() local
1476 i2c_put_adapter(hdmi->ddc_adapt); in sti_hdmi_remove()
1477 if (hdmi->audio_pdev) in sti_hdmi_remove()
1478 platform_device_unregister(hdmi->audio_pdev); in sti_hdmi_remove()
1479 component_del(&pdev->dev, &sti_hdmi_ops); in sti_hdmi_remove()
1486 .name = "sti-hdmi",