Lines Matching +full:hdmi +full:- +full:in

1 // SPDX-License-Identifier: GPL-2.0-only
7 #include <linux/arm-smccc.h>
10 #include <linux/hdmi.h>
24 #include <sound/hdmi-codec.h>
183 static void mtk_hdmi_hw_vid_black(struct mtk_hdmi *hdmi, bool black) in mtk_hdmi_hw_vid_black() argument
185 regmap_update_bits(hdmi->regs, VIDEO_CFG_4, in mtk_hdmi_hw_vid_black()
189 static void mtk_hdmi_hw_make_reg_writable(struct mtk_hdmi *hdmi, bool enable) in mtk_hdmi_hw_make_reg_writable() argument
194 * MT8173 HDMI hardware has an output control bit to enable/disable HDMI in mtk_hdmi_hw_make_reg_writable()
195 * output. This bit can only be controlled in ARM supervisor mode. in mtk_hdmi_hw_make_reg_writable()
196 * The ARM trusted firmware provides an API for the HDMI driver to set in mtk_hdmi_hw_make_reg_writable()
197 * this control bit to enable HDMI output in supervisor mode. in mtk_hdmi_hw_make_reg_writable()
199 if (hdmi->conf && hdmi->conf->tz_disabled) in mtk_hdmi_hw_make_reg_writable()
200 regmap_update_bits(hdmi->sys_regmap, in mtk_hdmi_hw_make_reg_writable()
201 hdmi->sys_offset + HDMI_SYS_CFG20, in mtk_hdmi_hw_make_reg_writable()
207 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG20, in mtk_hdmi_hw_make_reg_writable()
209 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG1C, in mtk_hdmi_hw_make_reg_writable()
213 static void mtk_hdmi_hw_1p4_version_enable(struct mtk_hdmi *hdmi, bool enable) in mtk_hdmi_hw_1p4_version_enable() argument
215 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG20, in mtk_hdmi_hw_1p4_version_enable()
219 static void mtk_hdmi_hw_aud_mute(struct mtk_hdmi *hdmi) in mtk_hdmi_hw_aud_mute() argument
221 regmap_set_bits(hdmi->regs, GRL_AUDIO_CFG, AUDIO_ZERO); in mtk_hdmi_hw_aud_mute()
224 static void mtk_hdmi_hw_aud_unmute(struct mtk_hdmi *hdmi) in mtk_hdmi_hw_aud_unmute() argument
226 regmap_clear_bits(hdmi->regs, GRL_AUDIO_CFG, AUDIO_ZERO); in mtk_hdmi_hw_aud_unmute()
229 static void mtk_hdmi_hw_reset(struct mtk_hdmi *hdmi) in mtk_hdmi_hw_reset() argument
231 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG1C, in mtk_hdmi_hw_reset()
233 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG1C, in mtk_hdmi_hw_reset()
235 regmap_clear_bits(hdmi->regs, GRL_CFG3, CFG3_CONTROL_PACKET_DELAY); in mtk_hdmi_hw_reset()
236 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG1C, in mtk_hdmi_hw_reset()
240 static void mtk_hdmi_hw_enable_notice(struct mtk_hdmi *hdmi, bool enable_notice) in mtk_hdmi_hw_enable_notice() argument
242 regmap_update_bits(hdmi->regs, GRL_CFG2, CFG2_NOTICE_EN, in mtk_hdmi_hw_enable_notice()
246 static void mtk_hdmi_hw_write_int_mask(struct mtk_hdmi *hdmi, u32 int_mask) in mtk_hdmi_hw_write_int_mask() argument
248 regmap_write(hdmi->regs, GRL_INT_MASK, int_mask); in mtk_hdmi_hw_write_int_mask()
251 static void mtk_hdmi_hw_enable_dvi_mode(struct mtk_hdmi *hdmi, bool enable) in mtk_hdmi_hw_enable_dvi_mode() argument
253 regmap_update_bits(hdmi->regs, GRL_CFG1, CFG1_DVI, enable ? CFG1_DVI : 0); in mtk_hdmi_hw_enable_dvi_mode()
256 static void mtk_hdmi_hw_send_info_frame(struct mtk_hdmi *hdmi, u8 *buffer, in mtk_hdmi_hw_send_info_frame() argument
274 dev_dbg(hdmi->dev, in mtk_hdmi_hw_send_info_frame()
296 dev_err(hdmi->dev, "Unknown infoframe type %d\n", frame_type); in mtk_hdmi_hw_send_info_frame()
299 regmap_clear_bits(hdmi->regs, ctrl_reg, ctrl_frame_en); in mtk_hdmi_hw_send_info_frame()
300 regmap_write(hdmi->regs, GRL_INFOFRM_TYPE, frame_type); in mtk_hdmi_hw_send_info_frame()
301 regmap_write(hdmi->regs, GRL_INFOFRM_VER, frame_ver); in mtk_hdmi_hw_send_info_frame()
302 regmap_write(hdmi->regs, GRL_INFOFRM_LNG, frame_len); in mtk_hdmi_hw_send_info_frame()
304 regmap_write(hdmi->regs, GRL_IFM_PORT, checksum); in mtk_hdmi_hw_send_info_frame()
306 regmap_write(hdmi->regs, GRL_IFM_PORT, frame_data[i]); in mtk_hdmi_hw_send_info_frame()
308 regmap_set_bits(hdmi->regs, ctrl_reg, ctrl_frame_en); in mtk_hdmi_hw_send_info_frame()
311 static void mtk_hdmi_hw_send_aud_packet(struct mtk_hdmi *hdmi, bool enable) in mtk_hdmi_hw_send_aud_packet() argument
313 regmap_update_bits(hdmi->regs, GRL_SHIFT_R2, in mtk_hdmi_hw_send_aud_packet()
317 static void mtk_hdmi_hw_config_sys(struct mtk_hdmi *hdmi) in mtk_hdmi_hw_config_sys() argument
319 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG20, in mtk_hdmi_hw_config_sys()
322 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG20, in mtk_hdmi_hw_config_sys()
326 static void mtk_hdmi_hw_set_deep_color_mode(struct mtk_hdmi *hdmi) in mtk_hdmi_hw_set_deep_color_mode() argument
328 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG20, in mtk_hdmi_hw_set_deep_color_mode()
333 static void mtk_hdmi_hw_send_av_mute(struct mtk_hdmi *hdmi) in mtk_hdmi_hw_send_av_mute() argument
335 regmap_clear_bits(hdmi->regs, GRL_CFG4, CTRL_AVMUTE); in mtk_hdmi_hw_send_av_mute()
337 regmap_set_bits(hdmi->regs, GRL_CFG4, CTRL_AVMUTE); in mtk_hdmi_hw_send_av_mute()
340 static void mtk_hdmi_hw_send_av_unmute(struct mtk_hdmi *hdmi) in mtk_hdmi_hw_send_av_unmute() argument
342 regmap_update_bits(hdmi->regs, GRL_CFG4, CFG4_AV_UNMUTE_EN | CFG4_AV_UNMUTE_SET, in mtk_hdmi_hw_send_av_unmute()
345 regmap_update_bits(hdmi->regs, GRL_CFG4, CFG4_AV_UNMUTE_EN | CFG4_AV_UNMUTE_SET, in mtk_hdmi_hw_send_av_unmute()
349 static void mtk_hdmi_hw_ncts_enable(struct mtk_hdmi *hdmi, bool on) in mtk_hdmi_hw_ncts_enable() argument
351 regmap_update_bits(hdmi->regs, GRL_CTS_CTRL, CTS_CTRL_SOFT, in mtk_hdmi_hw_ncts_enable()
355 static void mtk_hdmi_hw_ncts_auto_write_enable(struct mtk_hdmi *hdmi, in mtk_hdmi_hw_ncts_auto_write_enable() argument
358 regmap_update_bits(hdmi->regs, GRL_CTS_CTRL, NCTS_WRI_ANYTIME, in mtk_hdmi_hw_ncts_auto_write_enable()
362 static void mtk_hdmi_hw_msic_setting(struct mtk_hdmi *hdmi, in mtk_hdmi_hw_msic_setting() argument
365 regmap_clear_bits(hdmi->regs, GRL_CFG4, CFG4_MHL_MODE); in mtk_hdmi_hw_msic_setting()
367 if (mode->flags & DRM_MODE_FLAG_INTERLACE && in mtk_hdmi_hw_msic_setting()
368 mode->clock == 74250 && in mtk_hdmi_hw_msic_setting()
369 mode->vdisplay == 1080) in mtk_hdmi_hw_msic_setting()
370 regmap_clear_bits(hdmi->regs, GRL_CFG2, CFG2_MHL_DE_SEL); in mtk_hdmi_hw_msic_setting()
372 regmap_set_bits(hdmi->regs, GRL_CFG2, CFG2_MHL_DE_SEL); in mtk_hdmi_hw_msic_setting()
375 static void mtk_hdmi_hw_aud_set_channel_swap(struct mtk_hdmi *hdmi, in mtk_hdmi_hw_aud_set_channel_swap() argument
400 regmap_update_bits(hdmi->regs, GRL_CH_SWAP, 0xff, swap_bit); in mtk_hdmi_hw_aud_set_channel_swap()
403 static void mtk_hdmi_hw_aud_set_bit_num(struct mtk_hdmi *hdmi, in mtk_hdmi_hw_aud_set_bit_num() argument
421 regmap_update_bits(hdmi->regs, GRL_AOUT_CFG, AOUT_BNUM_SEL_MASK, val); in mtk_hdmi_hw_aud_set_bit_num()
424 static void mtk_hdmi_hw_aud_set_i2s_fmt(struct mtk_hdmi *hdmi, in mtk_hdmi_hw_aud_set_i2s_fmt() argument
429 regmap_read(hdmi->regs, GRL_CFG0, &val); in mtk_hdmi_hw_aud_set_i2s_fmt()
453 regmap_write(hdmi->regs, GRL_CFG0, val); in mtk_hdmi_hw_aud_set_i2s_fmt()
456 static void mtk_hdmi_hw_audio_config(struct mtk_hdmi *hdmi, bool dst) in mtk_hdmi_hw_audio_config() argument
462 regmap_clear_bits(hdmi->regs, GRL_AOUT_CFG, HIGH_BIT_RATE_PACKET_ALIGN); in mtk_hdmi_hw_audio_config()
469 regmap_update_bits(hdmi->regs, GRL_AUDIO_CFG, mask, val); in mtk_hdmi_hw_audio_config()
472 static void mtk_hdmi_hw_aud_set_i2s_chan_num(struct mtk_hdmi *hdmi, in mtk_hdmi_hw_aud_set_i2s_chan_num() argument
510 regmap_write(hdmi->regs, GRL_CH_SW0, ch_switch & 0xff); in mtk_hdmi_hw_aud_set_i2s_chan_num()
511 regmap_write(hdmi->regs, GRL_CH_SW1, (ch_switch >> 8) & 0xff); in mtk_hdmi_hw_aud_set_i2s_chan_num()
512 regmap_write(hdmi->regs, GRL_CH_SW2, (ch_switch >> 16) & 0xff); in mtk_hdmi_hw_aud_set_i2s_chan_num()
513 regmap_write(hdmi->regs, GRL_I2S_UV, i2s_uv); in mtk_hdmi_hw_aud_set_i2s_chan_num()
516 static void mtk_hdmi_hw_aud_set_input_type(struct mtk_hdmi *hdmi, in mtk_hdmi_hw_aud_set_input_type() argument
521 regmap_read(hdmi->regs, GRL_CFG1, &val); in mtk_hdmi_hw_aud_set_input_type()
529 regmap_write(hdmi->regs, GRL_CFG1, val); in mtk_hdmi_hw_aud_set_input_type()
532 static void mtk_hdmi_hw_aud_set_channel_status(struct mtk_hdmi *hdmi, in mtk_hdmi_hw_aud_set_channel_status() argument
538 regmap_write(hdmi->regs, GRL_I2S_C_STA0 + i * 4, channel_status[i]); in mtk_hdmi_hw_aud_set_channel_status()
539 regmap_write(hdmi->regs, GRL_L_STATUS_0 + i * 4, channel_status[i]); in mtk_hdmi_hw_aud_set_channel_status()
540 regmap_write(hdmi->regs, GRL_R_STATUS_0 + i * 4, channel_status[i]); in mtk_hdmi_hw_aud_set_channel_status()
543 regmap_write(hdmi->regs, GRL_L_STATUS_0 + i * 4, 0); in mtk_hdmi_hw_aud_set_channel_status()
544 regmap_write(hdmi->regs, GRL_R_STATUS_0 + i * 4, 0); in mtk_hdmi_hw_aud_set_channel_status()
548 static void mtk_hdmi_hw_aud_src_reenable(struct mtk_hdmi *hdmi) in mtk_hdmi_hw_aud_src_reenable() argument
552 regmap_read(hdmi->regs, GRL_MIX_CTRL, &val); in mtk_hdmi_hw_aud_src_reenable()
555 regmap_write(hdmi->regs, GRL_MIX_CTRL, val); in mtk_hdmi_hw_aud_src_reenable()
558 regmap_write(hdmi->regs, GRL_MIX_CTRL, val); in mtk_hdmi_hw_aud_src_reenable()
562 static void mtk_hdmi_hw_aud_src_disable(struct mtk_hdmi *hdmi) in mtk_hdmi_hw_aud_src_disable() argument
566 regmap_read(hdmi->regs, GRL_MIX_CTRL, &val); in mtk_hdmi_hw_aud_src_disable()
568 regmap_write(hdmi->regs, GRL_MIX_CTRL, val); in mtk_hdmi_hw_aud_src_disable()
569 regmap_write(hdmi->regs, GRL_SHIFT_L1, 0x00); in mtk_hdmi_hw_aud_src_disable()
572 static void mtk_hdmi_hw_aud_set_mclk(struct mtk_hdmi *hdmi, in mtk_hdmi_hw_aud_set_mclk() argument
577 regmap_read(hdmi->regs, GRL_CFG5, &val); in mtk_hdmi_hw_aud_set_mclk()
600 regmap_write(hdmi->regs, GRL_CFG5, val); in mtk_hdmi_hw_aud_set_mclk()
608 /* Recommended N values from HDMI specification, tables 7-1 to 7-3 */
620 * hdmi_recommended_n() - Return N value recommended by HDMI specification
621 * @freq: audio sample rate in Hz
622 * @clock: rounded TMDS clock in kHz
629 for (i = 0; i < ARRAY_SIZE(hdmi_rec_n_table) - 1; i++) { in hdmi_recommended_n()
637 return recommended->n[0]; in hdmi_recommended_n()
639 return recommended->n[1]; in hdmi_recommended_n()
641 return recommended->n[2]; in hdmi_recommended_n()
643 return recommended->n[1] * 2; in hdmi_recommended_n()
645 return recommended->n[2] * 2; in hdmi_recommended_n()
647 return recommended->n[1] * 4; in hdmi_recommended_n()
649 return recommended->n[2] * 4; in hdmi_recommended_n()
685 static void do_hdmi_hw_aud_set_ncts(struct mtk_hdmi *hdmi, unsigned int n, in do_hdmi_hw_aud_set_ncts() argument
691 regmap_write(hdmi->regs, GRL_NCTS, 0); in do_hdmi_hw_aud_set_ncts()
692 regmap_write(hdmi->regs, GRL_NCTS, 0); in do_hdmi_hw_aud_set_ncts()
693 regmap_write(hdmi->regs, GRL_NCTS, 0); in do_hdmi_hw_aud_set_ncts()
706 regmap_write(hdmi->regs, GRL_NCTS, val[i]); in do_hdmi_hw_aud_set_ncts()
709 static void mtk_hdmi_hw_aud_set_ncts(struct mtk_hdmi *hdmi, in mtk_hdmi_hw_aud_set_ncts() argument
717 dev_dbg(hdmi->dev, "%s: sample_rate=%u, clock=%d, cts=%u, n=%u\n", in mtk_hdmi_hw_aud_set_ncts()
720 regmap_update_bits(hdmi->regs, DUMMY_304, AUDIO_I2S_NCTS_SEL, AUDIO_I2S_NCTS_SEL_64); in mtk_hdmi_hw_aud_set_ncts()
721 do_hdmi_hw_aud_set_ncts(hdmi, n, cts); in mtk_hdmi_hw_aud_set_ncts()
794 static int mtk_hdmi_video_change_vpll(struct mtk_hdmi *hdmi, u32 clock) in mtk_hdmi_video_change_vpll() argument
800 ret = clk_set_rate(hdmi->clk[MTK_HDMI_CLK_HDMI_PLL], clock); in mtk_hdmi_video_change_vpll()
802 dev_err(hdmi->dev, "Failed to set PLL to %u Hz: %d\n", clock, in mtk_hdmi_video_change_vpll()
807 rate = clk_get_rate(hdmi->clk[MTK_HDMI_CLK_HDMI_PLL]); in mtk_hdmi_video_change_vpll()
810 dev_warn(hdmi->dev, "Want PLL %u Hz, got %lu Hz\n", clock, in mtk_hdmi_video_change_vpll()
813 dev_dbg(hdmi->dev, "Want PLL %u Hz, got %lu Hz\n", clock, rate); in mtk_hdmi_video_change_vpll()
815 mtk_hdmi_hw_config_sys(hdmi); in mtk_hdmi_video_change_vpll()
816 mtk_hdmi_hw_set_deep_color_mode(hdmi); in mtk_hdmi_video_change_vpll()
820 static void mtk_hdmi_video_set_display_mode(struct mtk_hdmi *hdmi, in mtk_hdmi_video_set_display_mode() argument
823 mtk_hdmi_hw_reset(hdmi); in mtk_hdmi_video_set_display_mode()
824 mtk_hdmi_hw_enable_notice(hdmi, true); in mtk_hdmi_video_set_display_mode()
825 mtk_hdmi_hw_write_int_mask(hdmi, 0xff); in mtk_hdmi_video_set_display_mode()
826 mtk_hdmi_hw_enable_dvi_mode(hdmi, hdmi->dvi_mode); in mtk_hdmi_video_set_display_mode()
827 mtk_hdmi_hw_ncts_auto_write_enable(hdmi, true); in mtk_hdmi_video_set_display_mode()
829 mtk_hdmi_hw_msic_setting(hdmi, mode); in mtk_hdmi_video_set_display_mode()
833 static void mtk_hdmi_aud_set_input(struct mtk_hdmi *hdmi) in mtk_hdmi_aud_set_input() argument
839 mtk_hdmi_hw_aud_set_channel_swap(hdmi, HDMI_AUD_SWAP_LFE_CC); in mtk_hdmi_aud_set_input()
840 regmap_set_bits(hdmi->regs, GRL_MIX_CTRL, MIX_CTRL_FLAT); in mtk_hdmi_aud_set_input()
842 if (hdmi->aud_param.aud_input_type == HDMI_AUD_INPUT_SPDIF && in mtk_hdmi_aud_set_input()
843 hdmi->aud_param.aud_codec == HDMI_AUDIO_CODING_TYPE_DST) { in mtk_hdmi_aud_set_input()
844 mtk_hdmi_hw_aud_set_bit_num(hdmi, HDMI_AUDIO_SAMPLE_SIZE_24); in mtk_hdmi_aud_set_input()
845 } else if (hdmi->aud_param.aud_i2s_fmt == HDMI_I2S_MODE_LJT_24BIT) { in mtk_hdmi_aud_set_input()
846 hdmi->aud_param.aud_i2s_fmt = HDMI_I2S_MODE_LJT_16BIT; in mtk_hdmi_aud_set_input()
849 mtk_hdmi_hw_aud_set_i2s_fmt(hdmi, hdmi->aud_param.aud_i2s_fmt); in mtk_hdmi_aud_set_input()
850 mtk_hdmi_hw_aud_set_bit_num(hdmi, HDMI_AUDIO_SAMPLE_SIZE_24); in mtk_hdmi_aud_set_input()
852 dst = ((hdmi->aud_param.aud_input_type == HDMI_AUD_INPUT_SPDIF) && in mtk_hdmi_aud_set_input()
853 (hdmi->aud_param.aud_codec == HDMI_AUDIO_CODING_TYPE_DST)); in mtk_hdmi_aud_set_input()
854 mtk_hdmi_hw_audio_config(hdmi, dst); in mtk_hdmi_aud_set_input()
856 if (hdmi->aud_param.aud_input_type == HDMI_AUD_INPUT_SPDIF) in mtk_hdmi_aud_set_input()
859 chan_type = hdmi->aud_param.aud_input_chan_type; in mtk_hdmi_aud_set_input()
861 mtk_hdmi_hw_aud_set_i2s_chan_num(hdmi, chan_type, chan_count); in mtk_hdmi_aud_set_input()
862 mtk_hdmi_hw_aud_set_input_type(hdmi, hdmi->aud_param.aud_input_type); in mtk_hdmi_aud_set_input()
865 static int mtk_hdmi_aud_set_src(struct mtk_hdmi *hdmi, in mtk_hdmi_aud_set_src() argument
868 unsigned int sample_rate = hdmi->aud_param.codec_params.sample_rate; in mtk_hdmi_aud_set_src()
870 mtk_hdmi_hw_ncts_enable(hdmi, false); in mtk_hdmi_aud_set_src()
871 mtk_hdmi_hw_aud_src_disable(hdmi); in mtk_hdmi_aud_set_src()
872 regmap_clear_bits(hdmi->regs, GRL_CFG2, CFG2_ACLK_INV); in mtk_hdmi_aud_set_src()
874 if (hdmi->aud_param.aud_input_type == HDMI_AUD_INPUT_I2S) { in mtk_hdmi_aud_set_src()
883 return -EINVAL; in mtk_hdmi_aud_set_src()
885 mtk_hdmi_hw_aud_set_mclk(hdmi, hdmi->aud_param.aud_mclk); in mtk_hdmi_aud_set_src()
893 return -EINVAL; in mtk_hdmi_aud_set_src()
895 mtk_hdmi_hw_aud_set_mclk(hdmi, HDMI_AUD_MCLK_128FS); in mtk_hdmi_aud_set_src()
898 mtk_hdmi_hw_aud_set_ncts(hdmi, sample_rate, display_mode->clock); in mtk_hdmi_aud_set_src()
900 mtk_hdmi_hw_aud_src_reenable(hdmi); in mtk_hdmi_aud_set_src()
904 static int mtk_hdmi_aud_output_config(struct mtk_hdmi *hdmi, in mtk_hdmi_aud_output_config() argument
907 mtk_hdmi_hw_aud_mute(hdmi); in mtk_hdmi_aud_output_config()
908 mtk_hdmi_hw_send_aud_packet(hdmi, false); in mtk_hdmi_aud_output_config()
910 mtk_hdmi_aud_set_input(hdmi); in mtk_hdmi_aud_output_config()
911 mtk_hdmi_aud_set_src(hdmi, display_mode); in mtk_hdmi_aud_output_config()
912 mtk_hdmi_hw_aud_set_channel_status(hdmi, in mtk_hdmi_aud_output_config()
913 hdmi->aud_param.codec_params.iec.status); in mtk_hdmi_aud_output_config()
917 mtk_hdmi_hw_ncts_enable(hdmi, true); in mtk_hdmi_aud_output_config()
918 mtk_hdmi_hw_send_aud_packet(hdmi, true); in mtk_hdmi_aud_output_config()
919 mtk_hdmi_hw_aud_unmute(hdmi); in mtk_hdmi_aud_output_config()
923 static int mtk_hdmi_setup_avi_infoframe(struct mtk_hdmi *hdmi, in mtk_hdmi_setup_avi_infoframe() argument
931 hdmi->curr_conn, mode); in mtk_hdmi_setup_avi_infoframe()
933 dev_err(hdmi->dev, in mtk_hdmi_setup_avi_infoframe()
940 dev_err(hdmi->dev, "Failed to pack AVI infoframe: %zd\n", err); in mtk_hdmi_setup_avi_infoframe()
944 mtk_hdmi_hw_send_info_frame(hdmi, buffer, sizeof(buffer)); in mtk_hdmi_setup_avi_infoframe()
948 static int mtk_hdmi_setup_spd_infoframe(struct mtk_hdmi *hdmi) in mtk_hdmi_setup_spd_infoframe() argument
950 struct drm_bridge *bridge = &hdmi->bridge; in mtk_hdmi_setup_spd_infoframe()
955 err = hdmi_spd_infoframe_init(&frame, bridge->vendor, bridge->product); in mtk_hdmi_setup_spd_infoframe()
957 dev_err(hdmi->dev, "Failed to initialize SPD infoframe: %zd\n", in mtk_hdmi_setup_spd_infoframe()
964 dev_err(hdmi->dev, "Failed to pack SDP infoframe: %zd\n", err); in mtk_hdmi_setup_spd_infoframe()
968 mtk_hdmi_hw_send_info_frame(hdmi, buffer, sizeof(buffer)); in mtk_hdmi_setup_spd_infoframe()
972 static int mtk_hdmi_setup_audio_infoframe(struct mtk_hdmi *hdmi) in mtk_hdmi_setup_audio_infoframe() argument
980 dev_err(hdmi->dev, "Failed to setup audio infoframe: %zd\n", in mtk_hdmi_setup_audio_infoframe()
989 hdmi->aud_param.aud_input_chan_type); in mtk_hdmi_setup_audio_infoframe()
993 dev_err(hdmi->dev, "Failed to pack audio infoframe: %zd\n", in mtk_hdmi_setup_audio_infoframe()
998 mtk_hdmi_hw_send_info_frame(hdmi, buffer, sizeof(buffer)); in mtk_hdmi_setup_audio_infoframe()
1002 static int mtk_hdmi_setup_vendor_specific_infoframe(struct mtk_hdmi *hdmi, in mtk_hdmi_setup_vendor_specific_infoframe() argument
1010 hdmi->curr_conn, mode); in mtk_hdmi_setup_vendor_specific_infoframe()
1012 dev_err(hdmi->dev, in mtk_hdmi_setup_vendor_specific_infoframe()
1019 dev_err(hdmi->dev, "Failed to pack vendor infoframe: %zd\n", in mtk_hdmi_setup_vendor_specific_infoframe()
1024 mtk_hdmi_hw_send_info_frame(hdmi, buffer, sizeof(buffer)); in mtk_hdmi_setup_vendor_specific_infoframe()
1028 static void mtk_hdmi_audio_enable(struct mtk_hdmi *hdmi) in mtk_hdmi_audio_enable() argument
1030 mtk_hdmi_hw_send_aud_packet(hdmi, true); in mtk_hdmi_audio_enable()
1031 hdmi->audio_enable = true; in mtk_hdmi_audio_enable()
1034 static void mtk_hdmi_audio_disable(struct mtk_hdmi *hdmi) in mtk_hdmi_audio_disable() argument
1036 mtk_hdmi_hw_send_aud_packet(hdmi, false); in mtk_hdmi_audio_disable()
1037 hdmi->audio_enable = false; in mtk_hdmi_audio_disable()
1040 static int mtk_hdmi_output_set_display_mode(struct mtk_hdmi *hdmi, in mtk_hdmi_output_set_display_mode() argument
1045 mtk_hdmi_hw_vid_black(hdmi, true); in mtk_hdmi_output_set_display_mode()
1046 mtk_hdmi_hw_aud_mute(hdmi); in mtk_hdmi_output_set_display_mode()
1047 mtk_hdmi_hw_send_av_mute(hdmi); in mtk_hdmi_output_set_display_mode()
1048 phy_power_off(hdmi->phy); in mtk_hdmi_output_set_display_mode()
1050 ret = mtk_hdmi_video_change_vpll(hdmi, in mtk_hdmi_output_set_display_mode()
1051 mode->clock * 1000); in mtk_hdmi_output_set_display_mode()
1053 dev_err(hdmi->dev, "Failed to set vpll: %d\n", ret); in mtk_hdmi_output_set_display_mode()
1056 mtk_hdmi_video_set_display_mode(hdmi, mode); in mtk_hdmi_output_set_display_mode()
1058 phy_power_on(hdmi->phy); in mtk_hdmi_output_set_display_mode()
1059 mtk_hdmi_aud_output_config(hdmi, mode); in mtk_hdmi_output_set_display_mode()
1061 mtk_hdmi_hw_vid_black(hdmi, false); in mtk_hdmi_output_set_display_mode()
1062 mtk_hdmi_hw_aud_unmute(hdmi); in mtk_hdmi_output_set_display_mode()
1063 mtk_hdmi_hw_send_av_unmute(hdmi); in mtk_hdmi_output_set_display_mode()
1075 static int mtk_hdmi_get_all_clk(struct mtk_hdmi *hdmi, in mtk_hdmi_get_all_clk() argument
1081 hdmi->clk[i] = of_clk_get_by_name(np, in mtk_hdmi_get_all_clk()
1083 if (IS_ERR(hdmi->clk[i])) in mtk_hdmi_get_all_clk()
1084 return PTR_ERR(hdmi->clk[i]); in mtk_hdmi_get_all_clk()
1089 static int mtk_hdmi_clk_enable_audio(struct mtk_hdmi *hdmi) in mtk_hdmi_clk_enable_audio() argument
1093 ret = clk_prepare_enable(hdmi->clk[MTK_HDMI_CLK_AUD_BCLK]); in mtk_hdmi_clk_enable_audio()
1097 ret = clk_prepare_enable(hdmi->clk[MTK_HDMI_CLK_AUD_SPDIF]); in mtk_hdmi_clk_enable_audio()
1099 clk_disable_unprepare(hdmi->clk[MTK_HDMI_CLK_AUD_BCLK]); in mtk_hdmi_clk_enable_audio()
1106 static void mtk_hdmi_clk_disable_audio(struct mtk_hdmi *hdmi) in mtk_hdmi_clk_disable_audio() argument
1108 clk_disable_unprepare(hdmi->clk[MTK_HDMI_CLK_AUD_BCLK]); in mtk_hdmi_clk_disable_audio()
1109 clk_disable_unprepare(hdmi->clk[MTK_HDMI_CLK_AUD_SPDIF]); in mtk_hdmi_clk_disable_audio()
1113 mtk_hdmi_update_plugged_status(struct mtk_hdmi *hdmi) in mtk_hdmi_update_plugged_status() argument
1117 mutex_lock(&hdmi->update_plugged_status_lock); in mtk_hdmi_update_plugged_status()
1118 connected = mtk_cec_hpd_high(hdmi->cec_dev); in mtk_hdmi_update_plugged_status()
1119 if (hdmi->plugged_cb && hdmi->codec_dev) in mtk_hdmi_update_plugged_status()
1120 hdmi->plugged_cb(hdmi->codec_dev, connected); in mtk_hdmi_update_plugged_status()
1121 mutex_unlock(&hdmi->update_plugged_status_lock); in mtk_hdmi_update_plugged_status()
1127 static enum drm_connector_status mtk_hdmi_detect(struct mtk_hdmi *hdmi) in mtk_hdmi_detect() argument
1129 return mtk_hdmi_update_plugged_status(hdmi); in mtk_hdmi_detect()
1137 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge); in mtk_hdmi_bridge_mode_valid() local
1139 dev_dbg(hdmi->dev, "xres=%d, yres=%d, refresh=%d, intl=%d clock=%d\n", in mtk_hdmi_bridge_mode_valid()
1140 mode->hdisplay, mode->vdisplay, drm_mode_vrefresh(mode), in mtk_hdmi_bridge_mode_valid()
1141 !!(mode->flags & DRM_MODE_FLAG_INTERLACE), mode->clock * 1000); in mtk_hdmi_bridge_mode_valid()
1143 if (hdmi->conf) { in mtk_hdmi_bridge_mode_valid()
1144 if (hdmi->conf->cea_modes_only && !drm_match_cea_mode(mode)) in mtk_hdmi_bridge_mode_valid()
1147 if (hdmi->conf->max_mode_clock && in mtk_hdmi_bridge_mode_valid()
1148 mode->clock > hdmi->conf->max_mode_clock) in mtk_hdmi_bridge_mode_valid()
1152 if (mode->clock < 27000) in mtk_hdmi_bridge_mode_valid()
1154 if (mode->clock > 297000) in mtk_hdmi_bridge_mode_valid()
1162 struct mtk_hdmi *hdmi = dev_get_drvdata(dev); in mtk_hdmi_hpd_event() local
1164 if (hdmi && hdmi->bridge.encoder && hdmi->bridge.encoder->dev) { in mtk_hdmi_hpd_event()
1167 status = mtk_hdmi_detect(hdmi); in mtk_hdmi_hpd_event()
1168 drm_helper_hpd_irq_event(hdmi->bridge.encoder->dev); in mtk_hdmi_hpd_event()
1169 drm_bridge_hpd_notify(&hdmi->bridge, status); in mtk_hdmi_hpd_event()
1180 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge); in mtk_hdmi_bridge_detect() local
1182 return mtk_hdmi_detect(hdmi); in mtk_hdmi_bridge_detect()
1188 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge); in mtk_hdmi_bridge_edid_read() local
1191 if (!hdmi->ddc_adpt) in mtk_hdmi_bridge_edid_read()
1193 drm_edid = drm_edid_read_ddc(connector, hdmi->ddc_adpt); in mtk_hdmi_bridge_edid_read()
1196 * FIXME: This should use !connector->display_info.has_audio (or in mtk_hdmi_bridge_edid_read()
1197 * !connector->display_info.is_hdmi) from a path that has read in mtk_hdmi_bridge_edid_read()
1202 hdmi->dvi_mode = !drm_detect_monitor_audio(edid); in mtk_hdmi_bridge_edid_read()
1212 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge); in mtk_hdmi_bridge_attach() local
1218 return -EINVAL; in mtk_hdmi_bridge_attach()
1221 if (hdmi->next_bridge) { in mtk_hdmi_bridge_attach()
1222 ret = drm_bridge_attach(encoder, hdmi->next_bridge, in mtk_hdmi_bridge_attach()
1228 mtk_cec_set_hpd_event(hdmi->cec_dev, mtk_hdmi_hpd_event, hdmi->dev); in mtk_hdmi_bridge_attach()
1243 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge); in mtk_hdmi_bridge_atomic_disable() local
1245 if (!hdmi->enabled) in mtk_hdmi_bridge_atomic_disable()
1248 phy_power_off(hdmi->phy); in mtk_hdmi_bridge_atomic_disable()
1249 clk_disable_unprepare(hdmi->clk[MTK_HDMI_CLK_HDMI_PIXEL]); in mtk_hdmi_bridge_atomic_disable()
1250 clk_disable_unprepare(hdmi->clk[MTK_HDMI_CLK_HDMI_PLL]); in mtk_hdmi_bridge_atomic_disable()
1252 hdmi->curr_conn = NULL; in mtk_hdmi_bridge_atomic_disable()
1254 hdmi->enabled = false; in mtk_hdmi_bridge_atomic_disable()
1260 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge); in mtk_hdmi_bridge_atomic_post_disable() local
1262 if (!hdmi->powered) in mtk_hdmi_bridge_atomic_post_disable()
1265 mtk_hdmi_hw_1p4_version_enable(hdmi, true); in mtk_hdmi_bridge_atomic_post_disable()
1266 mtk_hdmi_hw_make_reg_writable(hdmi, false); in mtk_hdmi_bridge_atomic_post_disable()
1268 hdmi->powered = false; in mtk_hdmi_bridge_atomic_post_disable()
1275 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge); in mtk_hdmi_bridge_mode_set() local
1277 dev_dbg(hdmi->dev, "cur info: name:%s, hdisplay:%d\n", in mtk_hdmi_bridge_mode_set()
1278 adjusted_mode->name, adjusted_mode->hdisplay); in mtk_hdmi_bridge_mode_set()
1279 dev_dbg(hdmi->dev, "hsync_start:%d,hsync_end:%d, htotal:%d", in mtk_hdmi_bridge_mode_set()
1280 adjusted_mode->hsync_start, adjusted_mode->hsync_end, in mtk_hdmi_bridge_mode_set()
1281 adjusted_mode->htotal); in mtk_hdmi_bridge_mode_set()
1282 dev_dbg(hdmi->dev, "hskew:%d, vdisplay:%d\n", in mtk_hdmi_bridge_mode_set()
1283 adjusted_mode->hskew, adjusted_mode->vdisplay); in mtk_hdmi_bridge_mode_set()
1284 dev_dbg(hdmi->dev, "vsync_start:%d, vsync_end:%d, vtotal:%d", in mtk_hdmi_bridge_mode_set()
1285 adjusted_mode->vsync_start, adjusted_mode->vsync_end, in mtk_hdmi_bridge_mode_set()
1286 adjusted_mode->vtotal); in mtk_hdmi_bridge_mode_set()
1287 dev_dbg(hdmi->dev, "vscan:%d, flag:%d\n", in mtk_hdmi_bridge_mode_set()
1288 adjusted_mode->vscan, adjusted_mode->flags); in mtk_hdmi_bridge_mode_set()
1290 drm_mode_copy(&hdmi->mode, adjusted_mode); in mtk_hdmi_bridge_mode_set()
1296 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge); in mtk_hdmi_bridge_atomic_pre_enable() local
1298 mtk_hdmi_hw_make_reg_writable(hdmi, true); in mtk_hdmi_bridge_atomic_pre_enable()
1299 mtk_hdmi_hw_1p4_version_enable(hdmi, true); in mtk_hdmi_bridge_atomic_pre_enable()
1301 hdmi->powered = true; in mtk_hdmi_bridge_atomic_pre_enable()
1304 static void mtk_hdmi_send_infoframe(struct mtk_hdmi *hdmi, in mtk_hdmi_send_infoframe() argument
1307 mtk_hdmi_setup_audio_infoframe(hdmi); in mtk_hdmi_send_infoframe()
1308 mtk_hdmi_setup_avi_infoframe(hdmi, mode); in mtk_hdmi_send_infoframe()
1309 mtk_hdmi_setup_spd_infoframe(hdmi); in mtk_hdmi_send_infoframe()
1310 if (mode->flags & DRM_MODE_FLAG_3D_MASK) in mtk_hdmi_send_infoframe()
1311 mtk_hdmi_setup_vendor_specific_infoframe(hdmi, mode); in mtk_hdmi_send_infoframe()
1317 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge); in mtk_hdmi_bridge_atomic_enable() local
1320 hdmi->curr_conn = drm_atomic_get_new_connector_for_encoder(state, in mtk_hdmi_bridge_atomic_enable()
1321 bridge->encoder); in mtk_hdmi_bridge_atomic_enable()
1323 mtk_hdmi_output_set_display_mode(hdmi, &hdmi->mode); in mtk_hdmi_bridge_atomic_enable()
1324 clk_prepare_enable(hdmi->clk[MTK_HDMI_CLK_HDMI_PLL]); in mtk_hdmi_bridge_atomic_enable()
1325 clk_prepare_enable(hdmi->clk[MTK_HDMI_CLK_HDMI_PIXEL]); in mtk_hdmi_bridge_atomic_enable()
1326 phy_power_on(hdmi->phy); in mtk_hdmi_bridge_atomic_enable()
1327 mtk_hdmi_send_infoframe(hdmi, &hdmi->mode); in mtk_hdmi_bridge_atomic_enable()
1329 hdmi->enabled = true; in mtk_hdmi_bridge_atomic_enable()
1348 static int mtk_hdmi_get_cec_dev(struct mtk_hdmi *hdmi, struct device *dev, struct device_node *np) in mtk_hdmi_get_cec_dev() argument
1354 ret = mtk_hdmi_get_all_clk(hdmi, np); in mtk_hdmi_get_cec_dev()
1358 /* The CEC module handles HDMI hotplug detection */ in mtk_hdmi_get_cec_dev()
1359 cec_np = of_get_compatible_child(np->parent, "mediatek,mt8173-cec"); in mtk_hdmi_get_cec_dev()
1361 return dev_err_probe(dev, -EINVAL, "Failed to find CEC node\n"); in mtk_hdmi_get_cec_dev()
1365 dev_err(hdmi->dev, "Waiting for CEC device %pOF\n", in mtk_hdmi_get_cec_dev()
1368 return -EPROBE_DEFER; in mtk_hdmi_get_cec_dev()
1373 * The mediatek,syscon-hdmi property contains a phandle link to the in mtk_hdmi_get_cec_dev()
1377 hdmi->sys_regmap = syscon_regmap_lookup_by_phandle_args(np, "mediatek,syscon-hdmi", in mtk_hdmi_get_cec_dev()
1378 1, &hdmi->sys_offset); in mtk_hdmi_get_cec_dev()
1379 if (IS_ERR(hdmi->sys_regmap)) in mtk_hdmi_get_cec_dev()
1380 return dev_err_probe(dev, PTR_ERR(hdmi->sys_regmap), in mtk_hdmi_get_cec_dev()
1383 hdmi->cec_dev = &cec_pdev->dev; in mtk_hdmi_get_cec_dev()
1387 static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi, in mtk_hdmi_dt_parse_pdata() argument
1390 struct device *dev = &pdev->dev; in mtk_hdmi_dt_parse_pdata()
1391 struct device_node *np = dev->of_node; in mtk_hdmi_dt_parse_pdata()
1395 ret = mtk_hdmi_get_all_clk(hdmi, np); in mtk_hdmi_dt_parse_pdata()
1399 hdmi->regs = device_node_to_regmap(dev->of_node); in mtk_hdmi_dt_parse_pdata()
1400 if (IS_ERR(hdmi->regs)) in mtk_hdmi_dt_parse_pdata()
1401 return PTR_ERR(hdmi->regs); in mtk_hdmi_dt_parse_pdata()
1405 return -EINVAL; in mtk_hdmi_dt_parse_pdata()
1407 if (!of_device_is_compatible(remote, "hdmi-connector")) { in mtk_hdmi_dt_parse_pdata()
1408 hdmi->next_bridge = of_drm_find_bridge(remote); in mtk_hdmi_dt_parse_pdata()
1409 if (!hdmi->next_bridge) { in mtk_hdmi_dt_parse_pdata()
1412 return -EPROBE_DEFER; in mtk_hdmi_dt_parse_pdata()
1416 i2c_np = of_parse_phandle(remote, "ddc-i2c-bus", 0); in mtk_hdmi_dt_parse_pdata()
1419 return dev_err_probe(dev, -EINVAL, "No ddc-i2c-bus in connector\n"); in mtk_hdmi_dt_parse_pdata()
1421 hdmi->ddc_adpt = of_find_i2c_adapter_by_node(i2c_np); in mtk_hdmi_dt_parse_pdata()
1423 if (!hdmi->ddc_adpt) in mtk_hdmi_dt_parse_pdata()
1424 return dev_err_probe(dev, -EINVAL, "Failed to get ddc i2c adapter by node\n"); in mtk_hdmi_dt_parse_pdata()
1426 ret = mtk_hdmi_get_cec_dev(hdmi, dev, np); in mtk_hdmi_dt_parse_pdata()
1434 * HDMI audio codec callbacks
1437 static int mtk_hdmi_audio_params(struct mtk_hdmi *hdmi, in mtk_hdmi_audio_params() argument
1442 unsigned int chan = params->cea.channels; in mtk_hdmi_audio_params()
1444 dev_dbg(hdmi->dev, "%s: %u Hz, %d bit, %d channels\n", __func__, in mtk_hdmi_audio_params()
1445 params->sample_rate, params->sample_width, chan); in mtk_hdmi_audio_params()
1447 if (!hdmi->bridge.encoder) in mtk_hdmi_audio_params()
1448 return -ENODEV; in mtk_hdmi_audio_params()
1464 dev_err(hdmi->dev, "channel[%d] not supported!\n", chan); in mtk_hdmi_audio_params()
1465 return -EINVAL; in mtk_hdmi_audio_params()
1468 switch (params->sample_rate) { in mtk_hdmi_audio_params()
1478 dev_err(hdmi->dev, "rate[%d] not supported!\n", in mtk_hdmi_audio_params()
1479 params->sample_rate); in mtk_hdmi_audio_params()
1480 return -EINVAL; in mtk_hdmi_audio_params()
1483 switch (daifmt->fmt) { in mtk_hdmi_audio_params()
1497 dev_err(hdmi->dev, "%s: Invalid DAI format %d\n", __func__, in mtk_hdmi_audio_params()
1498 daifmt->fmt); in mtk_hdmi_audio_params()
1499 return -EINVAL; in mtk_hdmi_audio_params()
1502 memcpy(&hdmi->aud_param, &aud_params, sizeof(aud_params)); in mtk_hdmi_audio_params()
1504 dev_dbg(hdmi->dev, "codec:%d, input:%d, channel:%d, fs:%d\n", in mtk_hdmi_audio_params()
1515 struct mtk_hdmi *hdmi = dev_get_drvdata(dev); in mtk_hdmi_audio_hw_params() local
1517 if (!hdmi->audio_enable) { in mtk_hdmi_audio_hw_params()
1518 dev_err(hdmi->dev, "hdmi audio is in disable state!\n"); in mtk_hdmi_audio_hw_params()
1519 return -EINVAL; in mtk_hdmi_audio_hw_params()
1522 mtk_hdmi_audio_params(hdmi, daifmt, params); in mtk_hdmi_audio_hw_params()
1523 mtk_hdmi_aud_output_config(hdmi, &hdmi->mode); in mtk_hdmi_audio_hw_params()
1530 struct mtk_hdmi *hdmi = dev_get_drvdata(dev); in mtk_hdmi_audio_startup() local
1532 mtk_hdmi_audio_enable(hdmi); in mtk_hdmi_audio_startup()
1539 struct mtk_hdmi *hdmi = dev_get_drvdata(dev); in mtk_hdmi_audio_shutdown() local
1541 mtk_hdmi_audio_disable(hdmi); in mtk_hdmi_audio_shutdown()
1548 struct mtk_hdmi *hdmi = dev_get_drvdata(dev); in mtk_hdmi_audio_mute() local
1551 mtk_hdmi_hw_aud_mute(hdmi); in mtk_hdmi_audio_mute()
1553 mtk_hdmi_hw_aud_unmute(hdmi); in mtk_hdmi_audio_mute()
1560 struct mtk_hdmi *hdmi = dev_get_drvdata(dev); in mtk_hdmi_audio_get_eld() local
1562 if (hdmi->enabled) in mtk_hdmi_audio_get_eld()
1563 memcpy(buf, hdmi->curr_conn->eld, min(sizeof(hdmi->curr_conn->eld), len)); in mtk_hdmi_audio_get_eld()
1569 static void mtk_hdmi_audio_set_plugged_cb(struct mtk_hdmi *hdmi, hdmi_codec_plugged_cb fn, in mtk_hdmi_audio_set_plugged_cb() argument
1572 mutex_lock(&hdmi->update_plugged_status_lock); in mtk_hdmi_audio_set_plugged_cb()
1573 hdmi->plugged_cb = fn; in mtk_hdmi_audio_set_plugged_cb()
1574 hdmi->codec_dev = codec_dev; in mtk_hdmi_audio_set_plugged_cb()
1575 mutex_unlock(&hdmi->update_plugged_status_lock); in mtk_hdmi_audio_set_plugged_cb()
1582 struct mtk_hdmi *hdmi = data; in mtk_hdmi_audio_hook_plugged_cb() local
1584 mtk_hdmi_audio_set_plugged_cb(hdmi, fn, codec_dev); in mtk_hdmi_audio_hook_plugged_cb()
1585 mtk_hdmi_update_plugged_status(hdmi); in mtk_hdmi_audio_hook_plugged_cb()
1606 struct mtk_hdmi *hdmi = dev_get_drvdata(dev); in mtk_hdmi_register_audio_driver() local
1607 struct hdmi_audio_param *aud_param = &hdmi->aud_param; in mtk_hdmi_register_audio_driver()
1612 .data = hdmi, in mtk_hdmi_register_audio_driver()
1617 aud_param->aud_codec = HDMI_AUDIO_CODING_TYPE_PCM; in mtk_hdmi_register_audio_driver()
1618 aud_param->aud_sample_size = HDMI_AUDIO_SAMPLE_SIZE_16; in mtk_hdmi_register_audio_driver()
1619 aud_param->aud_input_type = HDMI_AUD_INPUT_I2S; in mtk_hdmi_register_audio_driver()
1620 aud_param->aud_i2s_fmt = HDMI_I2S_MODE_I2S_24BIT; in mtk_hdmi_register_audio_driver()
1621 aud_param->aud_mclk = HDMI_AUD_MCLK_128FS; in mtk_hdmi_register_audio_driver()
1622 aud_param->aud_input_chan_type = HDMI_AUD_CHAN_TYPE_2_0; in mtk_hdmi_register_audio_driver()
1624 hdmi->audio_pdev = platform_device_register_data(dev, in mtk_hdmi_register_audio_driver()
1629 if (IS_ERR(hdmi->audio_pdev)) in mtk_hdmi_register_audio_driver()
1630 return PTR_ERR(hdmi->audio_pdev); in mtk_hdmi_register_audio_driver()
1633 hdmi->audio_pdev); in mtk_hdmi_register_audio_driver()
1642 struct mtk_hdmi *hdmi; in mtk_hdmi_probe() local
1643 struct device *dev = &pdev->dev; in mtk_hdmi_probe()
1646 hdmi = devm_drm_bridge_alloc(dev, struct mtk_hdmi, bridge, in mtk_hdmi_probe()
1648 if (IS_ERR(hdmi)) in mtk_hdmi_probe()
1649 return PTR_ERR(hdmi); in mtk_hdmi_probe()
1651 hdmi->dev = dev; in mtk_hdmi_probe()
1652 hdmi->conf = of_device_get_match_data(dev); in mtk_hdmi_probe()
1654 ret = mtk_hdmi_dt_parse_pdata(hdmi, pdev); in mtk_hdmi_probe()
1658 hdmi->phy = devm_phy_get(dev, "hdmi"); in mtk_hdmi_probe()
1659 if (IS_ERR(hdmi->phy)) in mtk_hdmi_probe()
1660 return dev_err_probe(dev, PTR_ERR(hdmi->phy), in mtk_hdmi_probe()
1661 "Failed to get HDMI PHY\n"); in mtk_hdmi_probe()
1663 mutex_init(&hdmi->update_plugged_status_lock); in mtk_hdmi_probe()
1664 platform_set_drvdata(pdev, hdmi); in mtk_hdmi_probe()
1671 hdmi->bridge.of_node = pdev->dev.of_node; in mtk_hdmi_probe()
1672 hdmi->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID in mtk_hdmi_probe()
1674 hdmi->bridge.type = DRM_MODE_CONNECTOR_HDMIA; in mtk_hdmi_probe()
1675 hdmi->bridge.vendor = "MediaTek"; in mtk_hdmi_probe()
1676 hdmi->bridge.product = "On-Chip HDMI"; in mtk_hdmi_probe()
1678 ret = devm_drm_bridge_add(dev, &hdmi->bridge); in mtk_hdmi_probe()
1682 ret = mtk_hdmi_clk_enable_audio(hdmi); in mtk_hdmi_probe()
1692 struct mtk_hdmi *hdmi = platform_get_drvdata(pdev); in mtk_hdmi_remove() local
1694 mtk_hdmi_clk_disable_audio(hdmi); in mtk_hdmi_remove()
1699 struct mtk_hdmi *hdmi = dev_get_drvdata(dev); in mtk_hdmi_suspend() local
1701 mtk_hdmi_clk_disable_audio(hdmi); in mtk_hdmi_suspend()
1708 struct mtk_hdmi *hdmi = dev_get_drvdata(dev); in mtk_hdmi_resume() local
1710 return mtk_hdmi_clk_enable_audio(hdmi); in mtk_hdmi_resume()
1725 { .compatible = "mediatek,mt2701-hdmi", .data = &mtk_hdmi_conf_mt2701 },
1726 { .compatible = "mediatek,mt8167-hdmi", .data = &mtk_hdmi_conf_mt8167 },
1727 { .compatible = "mediatek,mt8173-hdmi" },
1736 .name = "mediatek-drm-hdmi",
1744 MODULE_DESCRIPTION("MediaTek HDMI Driver");