Lines Matching +full:mt8173 +full:- +full:hdmi +full:- +full:phy

1 // SPDX-License-Identifier: GPL-2.0-only
7 #include <linux/arm-smccc.h>
10 #include <linux/hdmi.h>
20 #include <linux/phy/phy.h>
24 #include <sound/hdmi-codec.h>
160 struct phy *phy; member
191 static u32 mtk_hdmi_read(struct mtk_hdmi *hdmi, u32 offset) in mtk_hdmi_read() argument
193 return readl(hdmi->regs + offset); in mtk_hdmi_read()
196 static void mtk_hdmi_write(struct mtk_hdmi *hdmi, u32 offset, u32 val) in mtk_hdmi_write() argument
198 writel(val, hdmi->regs + offset); in mtk_hdmi_write()
201 static void mtk_hdmi_clear_bits(struct mtk_hdmi *hdmi, u32 offset, u32 bits) in mtk_hdmi_clear_bits() argument
203 void __iomem *reg = hdmi->regs + offset; in mtk_hdmi_clear_bits()
211 static void mtk_hdmi_set_bits(struct mtk_hdmi *hdmi, u32 offset, u32 bits) in mtk_hdmi_set_bits() argument
213 void __iomem *reg = hdmi->regs + offset; in mtk_hdmi_set_bits()
221 static void mtk_hdmi_mask(struct mtk_hdmi *hdmi, u32 offset, u32 val, u32 mask) in mtk_hdmi_mask() argument
223 void __iomem *reg = hdmi->regs + offset; in mtk_hdmi_mask()
231 static void mtk_hdmi_hw_vid_black(struct mtk_hdmi *hdmi, bool black) in mtk_hdmi_hw_vid_black() argument
233 mtk_hdmi_mask(hdmi, VIDEO_CFG_4, black ? GEN_RGB : NORMAL_PATH, in mtk_hdmi_hw_vid_black()
237 static void mtk_hdmi_hw_make_reg_writable(struct mtk_hdmi *hdmi, bool enable) in mtk_hdmi_hw_make_reg_writable() argument
242 * MT8173 HDMI hardware has an output control bit to enable/disable HDMI in mtk_hdmi_hw_make_reg_writable()
244 * The ARM trusted firmware provides an API for the HDMI driver to set in mtk_hdmi_hw_make_reg_writable()
245 * this control bit to enable HDMI output in supervisor mode. in mtk_hdmi_hw_make_reg_writable()
247 if (hdmi->conf && hdmi->conf->tz_disabled) in mtk_hdmi_hw_make_reg_writable()
248 regmap_update_bits(hdmi->sys_regmap, in mtk_hdmi_hw_make_reg_writable()
249 hdmi->sys_offset + HDMI_SYS_CFG20, in mtk_hdmi_hw_make_reg_writable()
255 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG20, in mtk_hdmi_hw_make_reg_writable()
257 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG1C, in mtk_hdmi_hw_make_reg_writable()
261 static void mtk_hdmi_hw_1p4_version_enable(struct mtk_hdmi *hdmi, bool enable) in mtk_hdmi_hw_1p4_version_enable() argument
263 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG20, in mtk_hdmi_hw_1p4_version_enable()
267 static void mtk_hdmi_hw_aud_mute(struct mtk_hdmi *hdmi) in mtk_hdmi_hw_aud_mute() argument
269 mtk_hdmi_set_bits(hdmi, GRL_AUDIO_CFG, AUDIO_ZERO); in mtk_hdmi_hw_aud_mute()
272 static void mtk_hdmi_hw_aud_unmute(struct mtk_hdmi *hdmi) in mtk_hdmi_hw_aud_unmute() argument
274 mtk_hdmi_clear_bits(hdmi, GRL_AUDIO_CFG, AUDIO_ZERO); in mtk_hdmi_hw_aud_unmute()
277 static void mtk_hdmi_hw_reset(struct mtk_hdmi *hdmi) in mtk_hdmi_hw_reset() argument
279 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG1C, in mtk_hdmi_hw_reset()
281 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG1C, in mtk_hdmi_hw_reset()
283 mtk_hdmi_clear_bits(hdmi, GRL_CFG3, CFG3_CONTROL_PACKET_DELAY); in mtk_hdmi_hw_reset()
284 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG1C, in mtk_hdmi_hw_reset()
288 static void mtk_hdmi_hw_enable_notice(struct mtk_hdmi *hdmi, bool enable_notice) in mtk_hdmi_hw_enable_notice() argument
290 mtk_hdmi_mask(hdmi, GRL_CFG2, enable_notice ? CFG2_NOTICE_EN : 0, in mtk_hdmi_hw_enable_notice()
294 static void mtk_hdmi_hw_write_int_mask(struct mtk_hdmi *hdmi, u32 int_mask) in mtk_hdmi_hw_write_int_mask() argument
296 mtk_hdmi_write(hdmi, GRL_INT_MASK, int_mask); in mtk_hdmi_hw_write_int_mask()
299 static void mtk_hdmi_hw_enable_dvi_mode(struct mtk_hdmi *hdmi, bool enable) in mtk_hdmi_hw_enable_dvi_mode() argument
301 mtk_hdmi_mask(hdmi, GRL_CFG1, enable ? CFG1_DVI : 0, CFG1_DVI); in mtk_hdmi_hw_enable_dvi_mode()
304 static void mtk_hdmi_hw_send_info_frame(struct mtk_hdmi *hdmi, u8 *buffer, in mtk_hdmi_hw_send_info_frame() argument
322 dev_dbg(hdmi->dev, in mtk_hdmi_hw_send_info_frame()
344 dev_err(hdmi->dev, "Unknown infoframe type %d\n", frame_type); in mtk_hdmi_hw_send_info_frame()
347 mtk_hdmi_clear_bits(hdmi, ctrl_reg, ctrl_frame_en); in mtk_hdmi_hw_send_info_frame()
348 mtk_hdmi_write(hdmi, GRL_INFOFRM_TYPE, frame_type); in mtk_hdmi_hw_send_info_frame()
349 mtk_hdmi_write(hdmi, GRL_INFOFRM_VER, frame_ver); in mtk_hdmi_hw_send_info_frame()
350 mtk_hdmi_write(hdmi, GRL_INFOFRM_LNG, frame_len); in mtk_hdmi_hw_send_info_frame()
352 mtk_hdmi_write(hdmi, GRL_IFM_PORT, checksum); in mtk_hdmi_hw_send_info_frame()
354 mtk_hdmi_write(hdmi, GRL_IFM_PORT, frame_data[i]); in mtk_hdmi_hw_send_info_frame()
356 mtk_hdmi_set_bits(hdmi, ctrl_reg, ctrl_frame_en); in mtk_hdmi_hw_send_info_frame()
359 static void mtk_hdmi_hw_send_aud_packet(struct mtk_hdmi *hdmi, bool enable) in mtk_hdmi_hw_send_aud_packet() argument
361 mtk_hdmi_mask(hdmi, GRL_SHIFT_R2, enable ? 0 : AUDIO_PACKET_OFF, in mtk_hdmi_hw_send_aud_packet()
365 static void mtk_hdmi_hw_config_sys(struct mtk_hdmi *hdmi) in mtk_hdmi_hw_config_sys() argument
367 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG20, in mtk_hdmi_hw_config_sys()
370 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG20, in mtk_hdmi_hw_config_sys()
374 static void mtk_hdmi_hw_set_deep_color_mode(struct mtk_hdmi *hdmi) in mtk_hdmi_hw_set_deep_color_mode() argument
376 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG20, in mtk_hdmi_hw_set_deep_color_mode()
381 static void mtk_hdmi_hw_send_av_mute(struct mtk_hdmi *hdmi) in mtk_hdmi_hw_send_av_mute() argument
383 mtk_hdmi_clear_bits(hdmi, GRL_CFG4, CTRL_AVMUTE); in mtk_hdmi_hw_send_av_mute()
385 mtk_hdmi_set_bits(hdmi, GRL_CFG4, CTRL_AVMUTE); in mtk_hdmi_hw_send_av_mute()
388 static void mtk_hdmi_hw_send_av_unmute(struct mtk_hdmi *hdmi) in mtk_hdmi_hw_send_av_unmute() argument
390 mtk_hdmi_mask(hdmi, GRL_CFG4, CFG4_AV_UNMUTE_EN, in mtk_hdmi_hw_send_av_unmute()
393 mtk_hdmi_mask(hdmi, GRL_CFG4, CFG4_AV_UNMUTE_SET, in mtk_hdmi_hw_send_av_unmute()
397 static void mtk_hdmi_hw_ncts_enable(struct mtk_hdmi *hdmi, bool on) in mtk_hdmi_hw_ncts_enable() argument
399 mtk_hdmi_mask(hdmi, GRL_CTS_CTRL, on ? 0 : CTS_CTRL_SOFT, in mtk_hdmi_hw_ncts_enable()
403 static void mtk_hdmi_hw_ncts_auto_write_enable(struct mtk_hdmi *hdmi, in mtk_hdmi_hw_ncts_auto_write_enable() argument
406 mtk_hdmi_mask(hdmi, GRL_CTS_CTRL, enable ? NCTS_WRI_ANYTIME : 0, in mtk_hdmi_hw_ncts_auto_write_enable()
410 static void mtk_hdmi_hw_msic_setting(struct mtk_hdmi *hdmi, in mtk_hdmi_hw_msic_setting() argument
413 mtk_hdmi_clear_bits(hdmi, GRL_CFG4, CFG4_MHL_MODE); in mtk_hdmi_hw_msic_setting()
415 if (mode->flags & DRM_MODE_FLAG_INTERLACE && in mtk_hdmi_hw_msic_setting()
416 mode->clock == 74250 && in mtk_hdmi_hw_msic_setting()
417 mode->vdisplay == 1080) in mtk_hdmi_hw_msic_setting()
418 mtk_hdmi_clear_bits(hdmi, GRL_CFG2, CFG2_MHL_DE_SEL); in mtk_hdmi_hw_msic_setting()
420 mtk_hdmi_set_bits(hdmi, GRL_CFG2, CFG2_MHL_DE_SEL); in mtk_hdmi_hw_msic_setting()
423 static void mtk_hdmi_hw_aud_set_channel_swap(struct mtk_hdmi *hdmi, in mtk_hdmi_hw_aud_set_channel_swap() argument
448 mtk_hdmi_mask(hdmi, GRL_CH_SWAP, swap_bit, 0xff); in mtk_hdmi_hw_aud_set_channel_swap()
451 static void mtk_hdmi_hw_aud_set_bit_num(struct mtk_hdmi *hdmi, in mtk_hdmi_hw_aud_set_bit_num() argument
469 mtk_hdmi_mask(hdmi, GRL_AOUT_CFG, val, AOUT_BNUM_SEL_MASK); in mtk_hdmi_hw_aud_set_bit_num()
472 static void mtk_hdmi_hw_aud_set_i2s_fmt(struct mtk_hdmi *hdmi, in mtk_hdmi_hw_aud_set_i2s_fmt() argument
477 val = mtk_hdmi_read(hdmi, GRL_CFG0); in mtk_hdmi_hw_aud_set_i2s_fmt()
501 mtk_hdmi_write(hdmi, GRL_CFG0, val); in mtk_hdmi_hw_aud_set_i2s_fmt()
504 static void mtk_hdmi_hw_audio_config(struct mtk_hdmi *hdmi, bool dst) in mtk_hdmi_hw_audio_config() argument
510 mtk_hdmi_clear_bits(hdmi, GRL_AOUT_CFG, HIGH_BIT_RATE_PACKET_ALIGN); in mtk_hdmi_hw_audio_config()
517 mtk_hdmi_mask(hdmi, GRL_AUDIO_CFG, val, mask); in mtk_hdmi_hw_audio_config()
520 static void mtk_hdmi_hw_aud_set_i2s_chan_num(struct mtk_hdmi *hdmi, in mtk_hdmi_hw_aud_set_i2s_chan_num() argument
558 mtk_hdmi_write(hdmi, GRL_CH_SW0, ch_switch & 0xff); in mtk_hdmi_hw_aud_set_i2s_chan_num()
559 mtk_hdmi_write(hdmi, GRL_CH_SW1, (ch_switch >> 8) & 0xff); in mtk_hdmi_hw_aud_set_i2s_chan_num()
560 mtk_hdmi_write(hdmi, GRL_CH_SW2, (ch_switch >> 16) & 0xff); in mtk_hdmi_hw_aud_set_i2s_chan_num()
561 mtk_hdmi_write(hdmi, GRL_I2S_UV, i2s_uv); in mtk_hdmi_hw_aud_set_i2s_chan_num()
564 static void mtk_hdmi_hw_aud_set_input_type(struct mtk_hdmi *hdmi, in mtk_hdmi_hw_aud_set_input_type() argument
569 val = mtk_hdmi_read(hdmi, GRL_CFG1); in mtk_hdmi_hw_aud_set_input_type()
577 mtk_hdmi_write(hdmi, GRL_CFG1, val); in mtk_hdmi_hw_aud_set_input_type()
580 static void mtk_hdmi_hw_aud_set_channel_status(struct mtk_hdmi *hdmi, in mtk_hdmi_hw_aud_set_channel_status() argument
586 mtk_hdmi_write(hdmi, GRL_I2S_C_STA0 + i * 4, channel_status[i]); in mtk_hdmi_hw_aud_set_channel_status()
587 mtk_hdmi_write(hdmi, GRL_L_STATUS_0 + i * 4, channel_status[i]); in mtk_hdmi_hw_aud_set_channel_status()
588 mtk_hdmi_write(hdmi, GRL_R_STATUS_0 + i * 4, channel_status[i]); in mtk_hdmi_hw_aud_set_channel_status()
591 mtk_hdmi_write(hdmi, GRL_L_STATUS_0 + i * 4, 0); in mtk_hdmi_hw_aud_set_channel_status()
592 mtk_hdmi_write(hdmi, GRL_R_STATUS_0 + i * 4, 0); in mtk_hdmi_hw_aud_set_channel_status()
596 static void mtk_hdmi_hw_aud_src_reenable(struct mtk_hdmi *hdmi) in mtk_hdmi_hw_aud_src_reenable() argument
600 val = mtk_hdmi_read(hdmi, GRL_MIX_CTRL); in mtk_hdmi_hw_aud_src_reenable()
603 mtk_hdmi_write(hdmi, GRL_MIX_CTRL, val); in mtk_hdmi_hw_aud_src_reenable()
606 mtk_hdmi_write(hdmi, GRL_MIX_CTRL, val); in mtk_hdmi_hw_aud_src_reenable()
610 static void mtk_hdmi_hw_aud_src_disable(struct mtk_hdmi *hdmi) in mtk_hdmi_hw_aud_src_disable() argument
614 val = mtk_hdmi_read(hdmi, GRL_MIX_CTRL); in mtk_hdmi_hw_aud_src_disable()
616 mtk_hdmi_write(hdmi, GRL_MIX_CTRL, val); in mtk_hdmi_hw_aud_src_disable()
617 mtk_hdmi_write(hdmi, GRL_SHIFT_L1, 0x00); in mtk_hdmi_hw_aud_src_disable()
620 static void mtk_hdmi_hw_aud_set_mclk(struct mtk_hdmi *hdmi, in mtk_hdmi_hw_aud_set_mclk() argument
625 val = mtk_hdmi_read(hdmi, GRL_CFG5); in mtk_hdmi_hw_aud_set_mclk()
648 mtk_hdmi_write(hdmi, GRL_CFG5, val); in mtk_hdmi_hw_aud_set_mclk()
656 /* Recommended N values from HDMI specification, tables 7-1 to 7-3 */
668 * hdmi_recommended_n() - Return N value recommended by HDMI specification
677 for (i = 0; i < ARRAY_SIZE(hdmi_rec_n_table) - 1; i++) { in hdmi_recommended_n()
685 return recommended->n[0]; in hdmi_recommended_n()
687 return recommended->n[1]; in hdmi_recommended_n()
689 return recommended->n[2]; in hdmi_recommended_n()
691 return recommended->n[1] * 2; in hdmi_recommended_n()
693 return recommended->n[2] * 2; in hdmi_recommended_n()
695 return recommended->n[1] * 4; in hdmi_recommended_n()
697 return recommended->n[2] * 4; in hdmi_recommended_n()
726 static void do_hdmi_hw_aud_set_ncts(struct mtk_hdmi *hdmi, unsigned int n, in do_hdmi_hw_aud_set_ncts() argument
732 mtk_hdmi_write(hdmi, GRL_NCTS, 0); in do_hdmi_hw_aud_set_ncts()
733 mtk_hdmi_write(hdmi, GRL_NCTS, 0); in do_hdmi_hw_aud_set_ncts()
734 mtk_hdmi_write(hdmi, GRL_NCTS, 0); in do_hdmi_hw_aud_set_ncts()
747 mtk_hdmi_write(hdmi, GRL_NCTS, val[i]); in do_hdmi_hw_aud_set_ncts()
750 static void mtk_hdmi_hw_aud_set_ncts(struct mtk_hdmi *hdmi, in mtk_hdmi_hw_aud_set_ncts() argument
759 dev_dbg(hdmi->dev, "%s: sample_rate=%u, clock=%d, cts=%u, n=%u\n", in mtk_hdmi_hw_aud_set_ncts()
762 mtk_hdmi_mask(hdmi, DUMMY_304, AUDIO_I2S_NCTS_SEL_64, in mtk_hdmi_hw_aud_set_ncts()
764 do_hdmi_hw_aud_set_ncts(hdmi, n, cts); in mtk_hdmi_hw_aud_set_ncts()
837 static int mtk_hdmi_video_change_vpll(struct mtk_hdmi *hdmi, u32 clock) in mtk_hdmi_video_change_vpll() argument
843 ret = clk_set_rate(hdmi->clk[MTK_HDMI_CLK_HDMI_PLL], clock); in mtk_hdmi_video_change_vpll()
845 dev_err(hdmi->dev, "Failed to set PLL to %u Hz: %d\n", clock, in mtk_hdmi_video_change_vpll()
850 rate = clk_get_rate(hdmi->clk[MTK_HDMI_CLK_HDMI_PLL]); in mtk_hdmi_video_change_vpll()
853 dev_warn(hdmi->dev, "Want PLL %u Hz, got %lu Hz\n", clock, in mtk_hdmi_video_change_vpll()
856 dev_dbg(hdmi->dev, "Want PLL %u Hz, got %lu Hz\n", clock, rate); in mtk_hdmi_video_change_vpll()
858 mtk_hdmi_hw_config_sys(hdmi); in mtk_hdmi_video_change_vpll()
859 mtk_hdmi_hw_set_deep_color_mode(hdmi); in mtk_hdmi_video_change_vpll()
863 static void mtk_hdmi_video_set_display_mode(struct mtk_hdmi *hdmi, in mtk_hdmi_video_set_display_mode() argument
866 mtk_hdmi_hw_reset(hdmi); in mtk_hdmi_video_set_display_mode()
867 mtk_hdmi_hw_enable_notice(hdmi, true); in mtk_hdmi_video_set_display_mode()
868 mtk_hdmi_hw_write_int_mask(hdmi, 0xff); in mtk_hdmi_video_set_display_mode()
869 mtk_hdmi_hw_enable_dvi_mode(hdmi, hdmi->dvi_mode); in mtk_hdmi_video_set_display_mode()
870 mtk_hdmi_hw_ncts_auto_write_enable(hdmi, true); in mtk_hdmi_video_set_display_mode()
872 mtk_hdmi_hw_msic_setting(hdmi, mode); in mtk_hdmi_video_set_display_mode()
876 static void mtk_hdmi_aud_set_input(struct mtk_hdmi *hdmi) in mtk_hdmi_aud_set_input() argument
882 mtk_hdmi_hw_aud_set_channel_swap(hdmi, HDMI_AUD_SWAP_LFE_CC); in mtk_hdmi_aud_set_input()
883 mtk_hdmi_set_bits(hdmi, GRL_MIX_CTRL, MIX_CTRL_FLAT); in mtk_hdmi_aud_set_input()
885 if (hdmi->aud_param.aud_input_type == HDMI_AUD_INPUT_SPDIF && in mtk_hdmi_aud_set_input()
886 hdmi->aud_param.aud_codec == HDMI_AUDIO_CODING_TYPE_DST) { in mtk_hdmi_aud_set_input()
887 mtk_hdmi_hw_aud_set_bit_num(hdmi, HDMI_AUDIO_SAMPLE_SIZE_24); in mtk_hdmi_aud_set_input()
888 } else if (hdmi->aud_param.aud_i2s_fmt == HDMI_I2S_MODE_LJT_24BIT) { in mtk_hdmi_aud_set_input()
889 hdmi->aud_param.aud_i2s_fmt = HDMI_I2S_MODE_LJT_16BIT; in mtk_hdmi_aud_set_input()
892 mtk_hdmi_hw_aud_set_i2s_fmt(hdmi, hdmi->aud_param.aud_i2s_fmt); in mtk_hdmi_aud_set_input()
893 mtk_hdmi_hw_aud_set_bit_num(hdmi, HDMI_AUDIO_SAMPLE_SIZE_24); in mtk_hdmi_aud_set_input()
895 dst = ((hdmi->aud_param.aud_input_type == HDMI_AUD_INPUT_SPDIF) && in mtk_hdmi_aud_set_input()
896 (hdmi->aud_param.aud_codec == HDMI_AUDIO_CODING_TYPE_DST)); in mtk_hdmi_aud_set_input()
897 mtk_hdmi_hw_audio_config(hdmi, dst); in mtk_hdmi_aud_set_input()
899 if (hdmi->aud_param.aud_input_type == HDMI_AUD_INPUT_SPDIF) in mtk_hdmi_aud_set_input()
902 chan_type = hdmi->aud_param.aud_input_chan_type; in mtk_hdmi_aud_set_input()
904 mtk_hdmi_hw_aud_set_i2s_chan_num(hdmi, chan_type, chan_count); in mtk_hdmi_aud_set_input()
905 mtk_hdmi_hw_aud_set_input_type(hdmi, hdmi->aud_param.aud_input_type); in mtk_hdmi_aud_set_input()
908 static int mtk_hdmi_aud_set_src(struct mtk_hdmi *hdmi, in mtk_hdmi_aud_set_src() argument
911 unsigned int sample_rate = hdmi->aud_param.codec_params.sample_rate; in mtk_hdmi_aud_set_src()
913 mtk_hdmi_hw_ncts_enable(hdmi, false); in mtk_hdmi_aud_set_src()
914 mtk_hdmi_hw_aud_src_disable(hdmi); in mtk_hdmi_aud_set_src()
915 mtk_hdmi_clear_bits(hdmi, GRL_CFG2, CFG2_ACLK_INV); in mtk_hdmi_aud_set_src()
917 if (hdmi->aud_param.aud_input_type == HDMI_AUD_INPUT_I2S) { in mtk_hdmi_aud_set_src()
926 return -EINVAL; in mtk_hdmi_aud_set_src()
928 mtk_hdmi_hw_aud_set_mclk(hdmi, hdmi->aud_param.aud_mclk); in mtk_hdmi_aud_set_src()
936 return -EINVAL; in mtk_hdmi_aud_set_src()
938 mtk_hdmi_hw_aud_set_mclk(hdmi, HDMI_AUD_MCLK_128FS); in mtk_hdmi_aud_set_src()
941 mtk_hdmi_hw_aud_set_ncts(hdmi, sample_rate, display_mode->clock); in mtk_hdmi_aud_set_src()
943 mtk_hdmi_hw_aud_src_reenable(hdmi); in mtk_hdmi_aud_set_src()
947 static int mtk_hdmi_aud_output_config(struct mtk_hdmi *hdmi, in mtk_hdmi_aud_output_config() argument
950 mtk_hdmi_hw_aud_mute(hdmi); in mtk_hdmi_aud_output_config()
951 mtk_hdmi_hw_send_aud_packet(hdmi, false); in mtk_hdmi_aud_output_config()
953 mtk_hdmi_aud_set_input(hdmi); in mtk_hdmi_aud_output_config()
954 mtk_hdmi_aud_set_src(hdmi, display_mode); in mtk_hdmi_aud_output_config()
955 mtk_hdmi_hw_aud_set_channel_status(hdmi, in mtk_hdmi_aud_output_config()
956 hdmi->aud_param.codec_params.iec.status); in mtk_hdmi_aud_output_config()
960 mtk_hdmi_hw_ncts_enable(hdmi, true); in mtk_hdmi_aud_output_config()
961 mtk_hdmi_hw_send_aud_packet(hdmi, true); in mtk_hdmi_aud_output_config()
962 mtk_hdmi_hw_aud_unmute(hdmi); in mtk_hdmi_aud_output_config()
966 static int mtk_hdmi_setup_avi_infoframe(struct mtk_hdmi *hdmi, in mtk_hdmi_setup_avi_infoframe() argument
974 hdmi->curr_conn, mode); in mtk_hdmi_setup_avi_infoframe()
976 dev_err(hdmi->dev, in mtk_hdmi_setup_avi_infoframe()
983 dev_err(hdmi->dev, "Failed to pack AVI infoframe: %zd\n", err); in mtk_hdmi_setup_avi_infoframe()
987 mtk_hdmi_hw_send_info_frame(hdmi, buffer, sizeof(buffer)); in mtk_hdmi_setup_avi_infoframe()
991 static int mtk_hdmi_setup_spd_infoframe(struct mtk_hdmi *hdmi, in mtk_hdmi_setup_spd_infoframe() argument
1001 dev_err(hdmi->dev, "Failed to initialize SPD infoframe: %zd\n", in mtk_hdmi_setup_spd_infoframe()
1008 dev_err(hdmi->dev, "Failed to pack SDP infoframe: %zd\n", err); in mtk_hdmi_setup_spd_infoframe()
1012 mtk_hdmi_hw_send_info_frame(hdmi, buffer, sizeof(buffer)); in mtk_hdmi_setup_spd_infoframe()
1016 static int mtk_hdmi_setup_audio_infoframe(struct mtk_hdmi *hdmi) in mtk_hdmi_setup_audio_infoframe() argument
1024 dev_err(hdmi->dev, "Failed to setup audio infoframe: %zd\n", in mtk_hdmi_setup_audio_infoframe()
1033 hdmi->aud_param.aud_input_chan_type); in mtk_hdmi_setup_audio_infoframe()
1037 dev_err(hdmi->dev, "Failed to pack audio infoframe: %zd\n", in mtk_hdmi_setup_audio_infoframe()
1042 mtk_hdmi_hw_send_info_frame(hdmi, buffer, sizeof(buffer)); in mtk_hdmi_setup_audio_infoframe()
1046 static int mtk_hdmi_setup_vendor_specific_infoframe(struct mtk_hdmi *hdmi, in mtk_hdmi_setup_vendor_specific_infoframe() argument
1054 hdmi->curr_conn, mode); in mtk_hdmi_setup_vendor_specific_infoframe()
1056 dev_err(hdmi->dev, in mtk_hdmi_setup_vendor_specific_infoframe()
1063 dev_err(hdmi->dev, "Failed to pack vendor infoframe: %zd\n", in mtk_hdmi_setup_vendor_specific_infoframe()
1068 mtk_hdmi_hw_send_info_frame(hdmi, buffer, sizeof(buffer)); in mtk_hdmi_setup_vendor_specific_infoframe()
1072 static int mtk_hdmi_output_init(struct mtk_hdmi *hdmi) in mtk_hdmi_output_init() argument
1074 struct hdmi_audio_param *aud_param = &hdmi->aud_param; in mtk_hdmi_output_init()
1076 hdmi->csp = HDMI_COLORSPACE_RGB; in mtk_hdmi_output_init()
1077 aud_param->aud_codec = HDMI_AUDIO_CODING_TYPE_PCM; in mtk_hdmi_output_init()
1078 aud_param->aud_sample_size = HDMI_AUDIO_SAMPLE_SIZE_16; in mtk_hdmi_output_init()
1079 aud_param->aud_input_type = HDMI_AUD_INPUT_I2S; in mtk_hdmi_output_init()
1080 aud_param->aud_i2s_fmt = HDMI_I2S_MODE_I2S_24BIT; in mtk_hdmi_output_init()
1081 aud_param->aud_mclk = HDMI_AUD_MCLK_128FS; in mtk_hdmi_output_init()
1082 aud_param->aud_input_chan_type = HDMI_AUD_CHAN_TYPE_2_0; in mtk_hdmi_output_init()
1087 static void mtk_hdmi_audio_enable(struct mtk_hdmi *hdmi) in mtk_hdmi_audio_enable() argument
1089 mtk_hdmi_hw_send_aud_packet(hdmi, true); in mtk_hdmi_audio_enable()
1090 hdmi->audio_enable = true; in mtk_hdmi_audio_enable()
1093 static void mtk_hdmi_audio_disable(struct mtk_hdmi *hdmi) in mtk_hdmi_audio_disable() argument
1095 mtk_hdmi_hw_send_aud_packet(hdmi, false); in mtk_hdmi_audio_disable()
1096 hdmi->audio_enable = false; in mtk_hdmi_audio_disable()
1099 static int mtk_hdmi_audio_set_param(struct mtk_hdmi *hdmi, in mtk_hdmi_audio_set_param() argument
1102 if (!hdmi->audio_enable) { in mtk_hdmi_audio_set_param()
1103 dev_err(hdmi->dev, "hdmi audio is in disable state!\n"); in mtk_hdmi_audio_set_param()
1104 return -EINVAL; in mtk_hdmi_audio_set_param()
1106 dev_dbg(hdmi->dev, "codec:%d, input:%d, channel:%d, fs:%d\n", in mtk_hdmi_audio_set_param()
1107 param->aud_codec, param->aud_input_type, in mtk_hdmi_audio_set_param()
1108 param->aud_input_chan_type, param->codec_params.sample_rate); in mtk_hdmi_audio_set_param()
1109 memcpy(&hdmi->aud_param, param, sizeof(*param)); in mtk_hdmi_audio_set_param()
1110 return mtk_hdmi_aud_output_config(hdmi, &hdmi->mode); in mtk_hdmi_audio_set_param()
1113 static int mtk_hdmi_output_set_display_mode(struct mtk_hdmi *hdmi, in mtk_hdmi_output_set_display_mode() argument
1118 mtk_hdmi_hw_vid_black(hdmi, true); in mtk_hdmi_output_set_display_mode()
1119 mtk_hdmi_hw_aud_mute(hdmi); in mtk_hdmi_output_set_display_mode()
1120 mtk_hdmi_hw_send_av_mute(hdmi); in mtk_hdmi_output_set_display_mode()
1121 phy_power_off(hdmi->phy); in mtk_hdmi_output_set_display_mode()
1123 ret = mtk_hdmi_video_change_vpll(hdmi, in mtk_hdmi_output_set_display_mode()
1124 mode->clock * 1000); in mtk_hdmi_output_set_display_mode()
1126 dev_err(hdmi->dev, "Failed to set vpll: %d\n", ret); in mtk_hdmi_output_set_display_mode()
1129 mtk_hdmi_video_set_display_mode(hdmi, mode); in mtk_hdmi_output_set_display_mode()
1131 phy_power_on(hdmi->phy); in mtk_hdmi_output_set_display_mode()
1132 mtk_hdmi_aud_output_config(hdmi, mode); in mtk_hdmi_output_set_display_mode()
1134 mtk_hdmi_hw_vid_black(hdmi, false); in mtk_hdmi_output_set_display_mode()
1135 mtk_hdmi_hw_aud_unmute(hdmi); in mtk_hdmi_output_set_display_mode()
1136 mtk_hdmi_hw_send_av_unmute(hdmi); in mtk_hdmi_output_set_display_mode()
1148 static int mtk_hdmi_get_all_clk(struct mtk_hdmi *hdmi, in mtk_hdmi_get_all_clk() argument
1154 hdmi->clk[i] = of_clk_get_by_name(np, in mtk_hdmi_get_all_clk()
1156 if (IS_ERR(hdmi->clk[i])) in mtk_hdmi_get_all_clk()
1157 return PTR_ERR(hdmi->clk[i]); in mtk_hdmi_get_all_clk()
1162 static int mtk_hdmi_clk_enable_audio(struct mtk_hdmi *hdmi) in mtk_hdmi_clk_enable_audio() argument
1166 ret = clk_prepare_enable(hdmi->clk[MTK_HDMI_CLK_AUD_BCLK]); in mtk_hdmi_clk_enable_audio()
1170 ret = clk_prepare_enable(hdmi->clk[MTK_HDMI_CLK_AUD_SPDIF]); in mtk_hdmi_clk_enable_audio()
1176 clk_disable_unprepare(hdmi->clk[MTK_HDMI_CLK_AUD_BCLK]); in mtk_hdmi_clk_enable_audio()
1180 static void mtk_hdmi_clk_disable_audio(struct mtk_hdmi *hdmi) in mtk_hdmi_clk_disable_audio() argument
1182 clk_disable_unprepare(hdmi->clk[MTK_HDMI_CLK_AUD_BCLK]); in mtk_hdmi_clk_disable_audio()
1183 clk_disable_unprepare(hdmi->clk[MTK_HDMI_CLK_AUD_SPDIF]); in mtk_hdmi_clk_disable_audio()
1187 mtk_hdmi_update_plugged_status(struct mtk_hdmi *hdmi) in mtk_hdmi_update_plugged_status() argument
1191 mutex_lock(&hdmi->update_plugged_status_lock); in mtk_hdmi_update_plugged_status()
1192 connected = mtk_cec_hpd_high(hdmi->cec_dev); in mtk_hdmi_update_plugged_status()
1193 if (hdmi->plugged_cb && hdmi->codec_dev) in mtk_hdmi_update_plugged_status()
1194 hdmi->plugged_cb(hdmi->codec_dev, connected); in mtk_hdmi_update_plugged_status()
1195 mutex_unlock(&hdmi->update_plugged_status_lock); in mtk_hdmi_update_plugged_status()
1201 static enum drm_connector_status mtk_hdmi_detect(struct mtk_hdmi *hdmi) in mtk_hdmi_detect() argument
1203 return mtk_hdmi_update_plugged_status(hdmi); in mtk_hdmi_detect()
1211 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge); in mtk_hdmi_bridge_mode_valid() local
1213 dev_dbg(hdmi->dev, "xres=%d, yres=%d, refresh=%d, intl=%d clock=%d\n", in mtk_hdmi_bridge_mode_valid()
1214 mode->hdisplay, mode->vdisplay, drm_mode_vrefresh(mode), in mtk_hdmi_bridge_mode_valid()
1215 !!(mode->flags & DRM_MODE_FLAG_INTERLACE), mode->clock * 1000); in mtk_hdmi_bridge_mode_valid()
1217 if (hdmi->conf) { in mtk_hdmi_bridge_mode_valid()
1218 if (hdmi->conf->cea_modes_only && !drm_match_cea_mode(mode)) in mtk_hdmi_bridge_mode_valid()
1221 if (hdmi->conf->max_mode_clock && in mtk_hdmi_bridge_mode_valid()
1222 mode->clock > hdmi->conf->max_mode_clock) in mtk_hdmi_bridge_mode_valid()
1226 if (mode->clock < 27000) in mtk_hdmi_bridge_mode_valid()
1228 if (mode->clock > 297000) in mtk_hdmi_bridge_mode_valid()
1236 struct mtk_hdmi *hdmi = dev_get_drvdata(dev); in mtk_hdmi_hpd_event() local
1238 if (hdmi && hdmi->bridge.encoder && hdmi->bridge.encoder->dev) { in mtk_hdmi_hpd_event()
1241 status = mtk_hdmi_detect(hdmi); in mtk_hdmi_hpd_event()
1242 drm_helper_hpd_irq_event(hdmi->bridge.encoder->dev); in mtk_hdmi_hpd_event()
1243 drm_bridge_hpd_notify(&hdmi->bridge, status); in mtk_hdmi_hpd_event()
1253 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge); in mtk_hdmi_bridge_detect() local
1255 return mtk_hdmi_detect(hdmi); in mtk_hdmi_bridge_detect()
1261 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge); in mtk_hdmi_bridge_edid_read() local
1264 if (!hdmi->ddc_adpt) in mtk_hdmi_bridge_edid_read()
1266 drm_edid = drm_edid_read_ddc(connector, hdmi->ddc_adpt); in mtk_hdmi_bridge_edid_read()
1269 * FIXME: This should use !connector->display_info.has_audio (or in mtk_hdmi_bridge_edid_read()
1270 * !connector->display_info.is_hdmi) from a path that has read in mtk_hdmi_bridge_edid_read()
1275 hdmi->dvi_mode = !drm_detect_monitor_audio(edid); in mtk_hdmi_bridge_edid_read()
1284 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge); in mtk_hdmi_bridge_attach() local
1290 return -EINVAL; in mtk_hdmi_bridge_attach()
1293 if (hdmi->next_bridge) { in mtk_hdmi_bridge_attach()
1294 ret = drm_bridge_attach(bridge->encoder, hdmi->next_bridge, in mtk_hdmi_bridge_attach()
1300 mtk_cec_set_hpd_event(hdmi->cec_dev, mtk_hdmi_hpd_event, hdmi->dev); in mtk_hdmi_bridge_attach()
1315 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge); in mtk_hdmi_bridge_atomic_disable() local
1317 if (!hdmi->enabled) in mtk_hdmi_bridge_atomic_disable()
1320 phy_power_off(hdmi->phy); in mtk_hdmi_bridge_atomic_disable()
1321 clk_disable_unprepare(hdmi->clk[MTK_HDMI_CLK_HDMI_PIXEL]); in mtk_hdmi_bridge_atomic_disable()
1322 clk_disable_unprepare(hdmi->clk[MTK_HDMI_CLK_HDMI_PLL]); in mtk_hdmi_bridge_atomic_disable()
1324 hdmi->curr_conn = NULL; in mtk_hdmi_bridge_atomic_disable()
1326 hdmi->enabled = false; in mtk_hdmi_bridge_atomic_disable()
1332 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge); in mtk_hdmi_bridge_atomic_post_disable() local
1334 if (!hdmi->powered) in mtk_hdmi_bridge_atomic_post_disable()
1337 mtk_hdmi_hw_1p4_version_enable(hdmi, true); in mtk_hdmi_bridge_atomic_post_disable()
1338 mtk_hdmi_hw_make_reg_writable(hdmi, false); in mtk_hdmi_bridge_atomic_post_disable()
1340 hdmi->powered = false; in mtk_hdmi_bridge_atomic_post_disable()
1347 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge); in mtk_hdmi_bridge_mode_set() local
1349 dev_dbg(hdmi->dev, "cur info: name:%s, hdisplay:%d\n", in mtk_hdmi_bridge_mode_set()
1350 adjusted_mode->name, adjusted_mode->hdisplay); in mtk_hdmi_bridge_mode_set()
1351 dev_dbg(hdmi->dev, "hsync_start:%d,hsync_end:%d, htotal:%d", in mtk_hdmi_bridge_mode_set()
1352 adjusted_mode->hsync_start, adjusted_mode->hsync_end, in mtk_hdmi_bridge_mode_set()
1353 adjusted_mode->htotal); in mtk_hdmi_bridge_mode_set()
1354 dev_dbg(hdmi->dev, "hskew:%d, vdisplay:%d\n", in mtk_hdmi_bridge_mode_set()
1355 adjusted_mode->hskew, adjusted_mode->vdisplay); in mtk_hdmi_bridge_mode_set()
1356 dev_dbg(hdmi->dev, "vsync_start:%d, vsync_end:%d, vtotal:%d", in mtk_hdmi_bridge_mode_set()
1357 adjusted_mode->vsync_start, adjusted_mode->vsync_end, in mtk_hdmi_bridge_mode_set()
1358 adjusted_mode->vtotal); in mtk_hdmi_bridge_mode_set()
1359 dev_dbg(hdmi->dev, "vscan:%d, flag:%d\n", in mtk_hdmi_bridge_mode_set()
1360 adjusted_mode->vscan, adjusted_mode->flags); in mtk_hdmi_bridge_mode_set()
1362 drm_mode_copy(&hdmi->mode, adjusted_mode); in mtk_hdmi_bridge_mode_set()
1368 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge); in mtk_hdmi_bridge_atomic_pre_enable() local
1370 mtk_hdmi_hw_make_reg_writable(hdmi, true); in mtk_hdmi_bridge_atomic_pre_enable()
1371 mtk_hdmi_hw_1p4_version_enable(hdmi, true); in mtk_hdmi_bridge_atomic_pre_enable()
1373 hdmi->powered = true; in mtk_hdmi_bridge_atomic_pre_enable()
1376 static void mtk_hdmi_send_infoframe(struct mtk_hdmi *hdmi, in mtk_hdmi_send_infoframe() argument
1379 mtk_hdmi_setup_audio_infoframe(hdmi); in mtk_hdmi_send_infoframe()
1380 mtk_hdmi_setup_avi_infoframe(hdmi, mode); in mtk_hdmi_send_infoframe()
1381 mtk_hdmi_setup_spd_infoframe(hdmi, "mediatek", "On-chip HDMI"); in mtk_hdmi_send_infoframe()
1382 if (mode->flags & DRM_MODE_FLAG_3D_MASK) in mtk_hdmi_send_infoframe()
1383 mtk_hdmi_setup_vendor_specific_infoframe(hdmi, mode); in mtk_hdmi_send_infoframe()
1389 struct drm_atomic_state *state = old_state->base.state; in mtk_hdmi_bridge_atomic_enable()
1390 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge); in mtk_hdmi_bridge_atomic_enable() local
1393 hdmi->curr_conn = drm_atomic_get_new_connector_for_encoder(state, in mtk_hdmi_bridge_atomic_enable()
1394 bridge->encoder); in mtk_hdmi_bridge_atomic_enable()
1396 mtk_hdmi_output_set_display_mode(hdmi, &hdmi->mode); in mtk_hdmi_bridge_atomic_enable()
1397 clk_prepare_enable(hdmi->clk[MTK_HDMI_CLK_HDMI_PLL]); in mtk_hdmi_bridge_atomic_enable()
1398 clk_prepare_enable(hdmi->clk[MTK_HDMI_CLK_HDMI_PIXEL]); in mtk_hdmi_bridge_atomic_enable()
1399 phy_power_on(hdmi->phy); in mtk_hdmi_bridge_atomic_enable()
1400 mtk_hdmi_send_infoframe(hdmi, &hdmi->mode); in mtk_hdmi_bridge_atomic_enable()
1402 hdmi->enabled = true; in mtk_hdmi_bridge_atomic_enable()
1421 static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi, in mtk_hdmi_dt_parse_pdata() argument
1424 struct device *dev = &pdev->dev; in mtk_hdmi_dt_parse_pdata()
1425 struct device_node *np = dev->of_node; in mtk_hdmi_dt_parse_pdata()
1432 ret = mtk_hdmi_get_all_clk(hdmi, np); in mtk_hdmi_dt_parse_pdata()
1434 if (ret != -EPROBE_DEFER) in mtk_hdmi_dt_parse_pdata()
1440 /* The CEC module handles HDMI hotplug detection */ in mtk_hdmi_dt_parse_pdata()
1441 cec_np = of_get_compatible_child(np->parent, "mediatek,mt8173-cec"); in mtk_hdmi_dt_parse_pdata()
1444 return -EINVAL; in mtk_hdmi_dt_parse_pdata()
1449 dev_err(hdmi->dev, "Waiting for CEC device %pOF\n", in mtk_hdmi_dt_parse_pdata()
1452 return -EPROBE_DEFER; in mtk_hdmi_dt_parse_pdata()
1455 hdmi->cec_dev = &cec_pdev->dev; in mtk_hdmi_dt_parse_pdata()
1458 * The mediatek,syscon-hdmi property contains a phandle link to the in mtk_hdmi_dt_parse_pdata()
1462 regmap = syscon_regmap_lookup_by_phandle(np, "mediatek,syscon-hdmi"); in mtk_hdmi_dt_parse_pdata()
1463 ret = of_property_read_u32_index(np, "mediatek,syscon-hdmi", 1, in mtk_hdmi_dt_parse_pdata()
1464 &hdmi->sys_offset); in mtk_hdmi_dt_parse_pdata()
1473 hdmi->sys_regmap = regmap; in mtk_hdmi_dt_parse_pdata()
1476 hdmi->regs = devm_ioremap_resource(dev, mem); in mtk_hdmi_dt_parse_pdata()
1477 if (IS_ERR(hdmi->regs)) { in mtk_hdmi_dt_parse_pdata()
1478 ret = PTR_ERR(hdmi->regs); in mtk_hdmi_dt_parse_pdata()
1484 ret = -EINVAL; in mtk_hdmi_dt_parse_pdata()
1488 if (!of_device_is_compatible(remote, "hdmi-connector")) { in mtk_hdmi_dt_parse_pdata()
1489 hdmi->next_bridge = of_drm_find_bridge(remote); in mtk_hdmi_dt_parse_pdata()
1490 if (!hdmi->next_bridge) { in mtk_hdmi_dt_parse_pdata()
1493 ret = -EPROBE_DEFER; in mtk_hdmi_dt_parse_pdata()
1498 i2c_np = of_parse_phandle(remote, "ddc-i2c-bus", 0); in mtk_hdmi_dt_parse_pdata()
1500 dev_err(dev, "Failed to find ddc-i2c-bus node in %pOF\n", in mtk_hdmi_dt_parse_pdata()
1503 ret = -EINVAL; in mtk_hdmi_dt_parse_pdata()
1508 hdmi->ddc_adpt = of_find_i2c_adapter_by_node(i2c_np); in mtk_hdmi_dt_parse_pdata()
1510 if (!hdmi->ddc_adpt) { in mtk_hdmi_dt_parse_pdata()
1512 ret = -EINVAL; in mtk_hdmi_dt_parse_pdata()
1518 put_device(hdmi->cec_dev); in mtk_hdmi_dt_parse_pdata()
1523 * HDMI audio codec callbacks
1530 struct mtk_hdmi *hdmi = dev_get_drvdata(dev); in mtk_hdmi_audio_hw_params() local
1532 unsigned int chan = params->cea.channels; in mtk_hdmi_audio_hw_params()
1534 dev_dbg(hdmi->dev, "%s: %u Hz, %d bit, %d channels\n", __func__, in mtk_hdmi_audio_hw_params()
1535 params->sample_rate, params->sample_width, chan); in mtk_hdmi_audio_hw_params()
1537 if (!hdmi->bridge.encoder) in mtk_hdmi_audio_hw_params()
1538 return -ENODEV; in mtk_hdmi_audio_hw_params()
1554 dev_err(hdmi->dev, "channel[%d] not supported!\n", chan); in mtk_hdmi_audio_hw_params()
1555 return -EINVAL; in mtk_hdmi_audio_hw_params()
1558 switch (params->sample_rate) { in mtk_hdmi_audio_hw_params()
1568 dev_err(hdmi->dev, "rate[%d] not supported!\n", in mtk_hdmi_audio_hw_params()
1569 params->sample_rate); in mtk_hdmi_audio_hw_params()
1570 return -EINVAL; in mtk_hdmi_audio_hw_params()
1573 switch (daifmt->fmt) { in mtk_hdmi_audio_hw_params()
1587 dev_err(hdmi->dev, "%s: Invalid DAI format %d\n", __func__, in mtk_hdmi_audio_hw_params()
1588 daifmt->fmt); in mtk_hdmi_audio_hw_params()
1589 return -EINVAL; in mtk_hdmi_audio_hw_params()
1595 mtk_hdmi_audio_set_param(hdmi, &hdmi_params); in mtk_hdmi_audio_hw_params()
1602 struct mtk_hdmi *hdmi = dev_get_drvdata(dev); in mtk_hdmi_audio_startup() local
1604 mtk_hdmi_audio_enable(hdmi); in mtk_hdmi_audio_startup()
1611 struct mtk_hdmi *hdmi = dev_get_drvdata(dev); in mtk_hdmi_audio_shutdown() local
1613 mtk_hdmi_audio_disable(hdmi); in mtk_hdmi_audio_shutdown()
1620 struct mtk_hdmi *hdmi = dev_get_drvdata(dev); in mtk_hdmi_audio_mute() local
1623 mtk_hdmi_hw_aud_mute(hdmi); in mtk_hdmi_audio_mute()
1625 mtk_hdmi_hw_aud_unmute(hdmi); in mtk_hdmi_audio_mute()
1632 struct mtk_hdmi *hdmi = dev_get_drvdata(dev); in mtk_hdmi_audio_get_eld() local
1634 if (hdmi->enabled) in mtk_hdmi_audio_get_eld()
1635 memcpy(buf, hdmi->curr_conn->eld, min(sizeof(hdmi->curr_conn->eld), len)); in mtk_hdmi_audio_get_eld()
1645 struct mtk_hdmi *hdmi = data; in mtk_hdmi_audio_hook_plugged_cb() local
1647 mutex_lock(&hdmi->update_plugged_status_lock); in mtk_hdmi_audio_hook_plugged_cb()
1648 hdmi->plugged_cb = fn; in mtk_hdmi_audio_hook_plugged_cb()
1649 hdmi->codec_dev = codec_dev; in mtk_hdmi_audio_hook_plugged_cb()
1650 mutex_unlock(&hdmi->update_plugged_status_lock); in mtk_hdmi_audio_hook_plugged_cb()
1652 mtk_hdmi_update_plugged_status(hdmi); in mtk_hdmi_audio_hook_plugged_cb()
1673 struct mtk_hdmi *hdmi = dev_get_drvdata(dev); in mtk_hdmi_register_audio_driver() local
1678 .data = hdmi, in mtk_hdmi_register_audio_driver()
1683 hdmi->audio_pdev = platform_device_register_data(dev, in mtk_hdmi_register_audio_driver()
1688 if (IS_ERR(hdmi->audio_pdev)) in mtk_hdmi_register_audio_driver()
1689 return PTR_ERR(hdmi->audio_pdev); in mtk_hdmi_register_audio_driver()
1692 hdmi->audio_pdev); in mtk_hdmi_register_audio_driver()
1696 DRM_INFO("%s driver bound to HDMI\n", HDMI_CODEC_DRV_NAME); in mtk_hdmi_register_audio_driver()
1702 struct mtk_hdmi *hdmi; in mtk_hdmi_probe() local
1703 struct device *dev = &pdev->dev; in mtk_hdmi_probe()
1706 hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL); in mtk_hdmi_probe()
1707 if (!hdmi) in mtk_hdmi_probe()
1708 return -ENOMEM; in mtk_hdmi_probe()
1710 hdmi->dev = dev; in mtk_hdmi_probe()
1711 hdmi->conf = of_device_get_match_data(dev); in mtk_hdmi_probe()
1713 ret = mtk_hdmi_dt_parse_pdata(hdmi, pdev); in mtk_hdmi_probe()
1717 hdmi->phy = devm_phy_get(dev, "hdmi"); in mtk_hdmi_probe()
1718 if (IS_ERR(hdmi->phy)) in mtk_hdmi_probe()
1719 return dev_err_probe(dev, PTR_ERR(hdmi->phy), in mtk_hdmi_probe()
1720 "Failed to get HDMI PHY\n"); in mtk_hdmi_probe()
1722 mutex_init(&hdmi->update_plugged_status_lock); in mtk_hdmi_probe()
1723 platform_set_drvdata(pdev, hdmi); in mtk_hdmi_probe()
1725 ret = mtk_hdmi_output_init(hdmi); in mtk_hdmi_probe()
1728 "Failed to initialize hdmi output\n"); in mtk_hdmi_probe()
1735 hdmi->bridge.funcs = &mtk_hdmi_bridge_funcs; in mtk_hdmi_probe()
1736 hdmi->bridge.of_node = pdev->dev.of_node; in mtk_hdmi_probe()
1737 hdmi->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID in mtk_hdmi_probe()
1739 hdmi->bridge.type = DRM_MODE_CONNECTOR_HDMIA; in mtk_hdmi_probe()
1740 drm_bridge_add(&hdmi->bridge); in mtk_hdmi_probe()
1742 ret = mtk_hdmi_clk_enable_audio(hdmi); in mtk_hdmi_probe()
1744 drm_bridge_remove(&hdmi->bridge); in mtk_hdmi_probe()
1754 struct mtk_hdmi *hdmi = platform_get_drvdata(pdev); in mtk_hdmi_remove() local
1756 drm_bridge_remove(&hdmi->bridge); in mtk_hdmi_remove()
1757 mtk_hdmi_clk_disable_audio(hdmi); in mtk_hdmi_remove()
1763 struct mtk_hdmi *hdmi = dev_get_drvdata(dev); in mtk_hdmi_suspend() local
1765 mtk_hdmi_clk_disable_audio(hdmi); in mtk_hdmi_suspend()
1772 struct mtk_hdmi *hdmi = dev_get_drvdata(dev); in mtk_hdmi_resume() local
1775 ret = mtk_hdmi_clk_enable_audio(hdmi); in mtk_hdmi_resume()
1777 dev_err(dev, "hdmi resume failed!\n"); in mtk_hdmi_resume()
1797 { .compatible = "mediatek,mt2701-hdmi",
1800 { .compatible = "mediatek,mt8167-hdmi",
1803 { .compatible = "mediatek,mt8173-hdmi",
1813 .name = "mediatek-drm-hdmi",
1841 MODULE_DESCRIPTION("MediaTek HDMI Driver");