Lines Matching refs:hdmi

10 #include <linux/hdmi.h>
24 #include <sound/hdmi-codec.h>
190 static u32 mtk_hdmi_read(struct mtk_hdmi *hdmi, u32 offset)
192 return readl(hdmi->regs + offset);
195 static void mtk_hdmi_write(struct mtk_hdmi *hdmi, u32 offset, u32 val)
197 writel(val, hdmi->regs + offset);
200 static void mtk_hdmi_clear_bits(struct mtk_hdmi *hdmi, u32 offset, u32 bits)
202 void __iomem *reg = hdmi->regs + offset;
210 static void mtk_hdmi_set_bits(struct mtk_hdmi *hdmi, u32 offset, u32 bits)
212 void __iomem *reg = hdmi->regs + offset;
220 static void mtk_hdmi_mask(struct mtk_hdmi *hdmi, u32 offset, u32 val, u32 mask)
222 void __iomem *reg = hdmi->regs + offset;
230 static void mtk_hdmi_hw_vid_black(struct mtk_hdmi *hdmi, bool black)
232 mtk_hdmi_mask(hdmi, VIDEO_CFG_4, black ? GEN_RGB : NORMAL_PATH,
236 static void mtk_hdmi_hw_make_reg_writable(struct mtk_hdmi *hdmi, bool enable)
246 if (hdmi->conf && hdmi->conf->tz_disabled)
247 regmap_update_bits(hdmi->sys_regmap,
248 hdmi->sys_offset + HDMI_SYS_CFG20,
254 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG20,
256 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG1C,
260 static void mtk_hdmi_hw_1p4_version_enable(struct mtk_hdmi *hdmi, bool enable)
262 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG20,
266 static void mtk_hdmi_hw_aud_mute(struct mtk_hdmi *hdmi)
268 mtk_hdmi_set_bits(hdmi, GRL_AUDIO_CFG, AUDIO_ZERO);
271 static void mtk_hdmi_hw_aud_unmute(struct mtk_hdmi *hdmi)
273 mtk_hdmi_clear_bits(hdmi, GRL_AUDIO_CFG, AUDIO_ZERO);
276 static void mtk_hdmi_hw_reset(struct mtk_hdmi *hdmi)
278 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG1C,
280 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG1C,
282 mtk_hdmi_clear_bits(hdmi, GRL_CFG3, CFG3_CONTROL_PACKET_DELAY);
283 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG1C,
287 static void mtk_hdmi_hw_enable_notice(struct mtk_hdmi *hdmi, bool enable_notice)
289 mtk_hdmi_mask(hdmi, GRL_CFG2, enable_notice ? CFG2_NOTICE_EN : 0,
293 static void mtk_hdmi_hw_write_int_mask(struct mtk_hdmi *hdmi, u32 int_mask)
295 mtk_hdmi_write(hdmi, GRL_INT_MASK, int_mask);
298 static void mtk_hdmi_hw_enable_dvi_mode(struct mtk_hdmi *hdmi, bool enable)
300 mtk_hdmi_mask(hdmi, GRL_CFG1, enable ? CFG1_DVI : 0, CFG1_DVI);
303 static void mtk_hdmi_hw_send_info_frame(struct mtk_hdmi *hdmi, u8 *buffer,
321 dev_dbg(hdmi->dev,
343 dev_err(hdmi->dev, "Unknown infoframe type %d\n", frame_type);
346 mtk_hdmi_clear_bits(hdmi, ctrl_reg, ctrl_frame_en);
347 mtk_hdmi_write(hdmi, GRL_INFOFRM_TYPE, frame_type);
348 mtk_hdmi_write(hdmi, GRL_INFOFRM_VER, frame_ver);
349 mtk_hdmi_write(hdmi, GRL_INFOFRM_LNG, frame_len);
351 mtk_hdmi_write(hdmi, GRL_IFM_PORT, checksum);
353 mtk_hdmi_write(hdmi, GRL_IFM_PORT, frame_data[i]);
355 mtk_hdmi_set_bits(hdmi, ctrl_reg, ctrl_frame_en);
358 static void mtk_hdmi_hw_send_aud_packet(struct mtk_hdmi *hdmi, bool enable)
360 mtk_hdmi_mask(hdmi, GRL_SHIFT_R2, enable ? 0 : AUDIO_PACKET_OFF,
364 static void mtk_hdmi_hw_config_sys(struct mtk_hdmi *hdmi)
366 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG20,
369 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG20,
373 static void mtk_hdmi_hw_set_deep_color_mode(struct mtk_hdmi *hdmi)
375 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG20,
380 static void mtk_hdmi_hw_send_av_mute(struct mtk_hdmi *hdmi)
382 mtk_hdmi_clear_bits(hdmi, GRL_CFG4, CTRL_AVMUTE);
384 mtk_hdmi_set_bits(hdmi, GRL_CFG4, CTRL_AVMUTE);
387 static void mtk_hdmi_hw_send_av_unmute(struct mtk_hdmi *hdmi)
389 mtk_hdmi_mask(hdmi, GRL_CFG4, CFG4_AV_UNMUTE_EN,
392 mtk_hdmi_mask(hdmi, GRL_CFG4, CFG4_AV_UNMUTE_SET,
396 static void mtk_hdmi_hw_ncts_enable(struct mtk_hdmi *hdmi, bool on)
398 mtk_hdmi_mask(hdmi, GRL_CTS_CTRL, on ? 0 : CTS_CTRL_SOFT,
402 static void mtk_hdmi_hw_ncts_auto_write_enable(struct mtk_hdmi *hdmi,
405 mtk_hdmi_mask(hdmi, GRL_CTS_CTRL, enable ? NCTS_WRI_ANYTIME : 0,
409 static void mtk_hdmi_hw_msic_setting(struct mtk_hdmi *hdmi,
412 mtk_hdmi_clear_bits(hdmi, GRL_CFG4, CFG4_MHL_MODE);
417 mtk_hdmi_clear_bits(hdmi, GRL_CFG2, CFG2_MHL_DE_SEL);
419 mtk_hdmi_set_bits(hdmi, GRL_CFG2, CFG2_MHL_DE_SEL);
422 static void mtk_hdmi_hw_aud_set_channel_swap(struct mtk_hdmi *hdmi,
447 mtk_hdmi_mask(hdmi, GRL_CH_SWAP, swap_bit, 0xff);
450 static void mtk_hdmi_hw_aud_set_bit_num(struct mtk_hdmi *hdmi,
468 mtk_hdmi_mask(hdmi, GRL_AOUT_CFG, val, AOUT_BNUM_SEL_MASK);
471 static void mtk_hdmi_hw_aud_set_i2s_fmt(struct mtk_hdmi *hdmi,
476 val = mtk_hdmi_read(hdmi, GRL_CFG0);
500 mtk_hdmi_write(hdmi, GRL_CFG0, val);
503 static void mtk_hdmi_hw_audio_config(struct mtk_hdmi *hdmi, bool dst)
509 mtk_hdmi_clear_bits(hdmi, GRL_AOUT_CFG, HIGH_BIT_RATE_PACKET_ALIGN);
516 mtk_hdmi_mask(hdmi, GRL_AUDIO_CFG, val, mask);
519 static void mtk_hdmi_hw_aud_set_i2s_chan_num(struct mtk_hdmi *hdmi,
557 mtk_hdmi_write(hdmi, GRL_CH_SW0, ch_switch & 0xff);
558 mtk_hdmi_write(hdmi, GRL_CH_SW1, (ch_switch >> 8) & 0xff);
559 mtk_hdmi_write(hdmi, GRL_CH_SW2, (ch_switch >> 16) & 0xff);
560 mtk_hdmi_write(hdmi, GRL_I2S_UV, i2s_uv);
563 static void mtk_hdmi_hw_aud_set_input_type(struct mtk_hdmi *hdmi,
568 val = mtk_hdmi_read(hdmi, GRL_CFG1);
576 mtk_hdmi_write(hdmi, GRL_CFG1, val);
579 static void mtk_hdmi_hw_aud_set_channel_status(struct mtk_hdmi *hdmi,
585 mtk_hdmi_write(hdmi, GRL_I2S_C_STA0 + i * 4, channel_status[i]);
586 mtk_hdmi_write(hdmi, GRL_L_STATUS_0 + i * 4, channel_status[i]);
587 mtk_hdmi_write(hdmi, GRL_R_STATUS_0 + i * 4, channel_status[i]);
590 mtk_hdmi_write(hdmi, GRL_L_STATUS_0 + i * 4, 0);
591 mtk_hdmi_write(hdmi, GRL_R_STATUS_0 + i * 4, 0);
595 static void mtk_hdmi_hw_aud_src_reenable(struct mtk_hdmi *hdmi)
599 val = mtk_hdmi_read(hdmi, GRL_MIX_CTRL);
602 mtk_hdmi_write(hdmi, GRL_MIX_CTRL, val);
605 mtk_hdmi_write(hdmi, GRL_MIX_CTRL, val);
609 static void mtk_hdmi_hw_aud_src_disable(struct mtk_hdmi *hdmi)
613 val = mtk_hdmi_read(hdmi, GRL_MIX_CTRL);
615 mtk_hdmi_write(hdmi, GRL_MIX_CTRL, val);
616 mtk_hdmi_write(hdmi, GRL_SHIFT_L1, 0x00);
619 static void mtk_hdmi_hw_aud_set_mclk(struct mtk_hdmi *hdmi,
624 val = mtk_hdmi_read(hdmi, GRL_CFG5);
647 mtk_hdmi_write(hdmi, GRL_CFG5, val);
725 static void do_hdmi_hw_aud_set_ncts(struct mtk_hdmi *hdmi, unsigned int n,
731 mtk_hdmi_write(hdmi, GRL_NCTS, 0);
732 mtk_hdmi_write(hdmi, GRL_NCTS, 0);
733 mtk_hdmi_write(hdmi, GRL_NCTS, 0);
746 mtk_hdmi_write(hdmi, GRL_NCTS, val[i]);
749 static void mtk_hdmi_hw_aud_set_ncts(struct mtk_hdmi *hdmi,
758 dev_dbg(hdmi->dev, "%s: sample_rate=%u, clock=%d, cts=%u, n=%u\n",
761 mtk_hdmi_mask(hdmi, DUMMY_304, AUDIO_I2S_NCTS_SEL_64,
763 do_hdmi_hw_aud_set_ncts(hdmi, n, cts);
836 static int mtk_hdmi_video_change_vpll(struct mtk_hdmi *hdmi, u32 clock)
842 ret = clk_set_rate(hdmi->clk[MTK_HDMI_CLK_HDMI_PLL], clock);
844 dev_err(hdmi->dev, "Failed to set PLL to %u Hz: %d\n", clock,
849 rate = clk_get_rate(hdmi->clk[MTK_HDMI_CLK_HDMI_PLL]);
852 dev_warn(hdmi->dev, "Want PLL %u Hz, got %lu Hz\n", clock,
855 dev_dbg(hdmi->dev, "Want PLL %u Hz, got %lu Hz\n", clock, rate);
857 mtk_hdmi_hw_config_sys(hdmi);
858 mtk_hdmi_hw_set_deep_color_mode(hdmi);
862 static void mtk_hdmi_video_set_display_mode(struct mtk_hdmi *hdmi,
865 mtk_hdmi_hw_reset(hdmi);
866 mtk_hdmi_hw_enable_notice(hdmi, true);
867 mtk_hdmi_hw_write_int_mask(hdmi, 0xff);
868 mtk_hdmi_hw_enable_dvi_mode(hdmi, hdmi->dvi_mode);
869 mtk_hdmi_hw_ncts_auto_write_enable(hdmi, true);
871 mtk_hdmi_hw_msic_setting(hdmi, mode);
875 static void mtk_hdmi_aud_set_input(struct mtk_hdmi *hdmi)
881 mtk_hdmi_hw_aud_set_channel_swap(hdmi, HDMI_AUD_SWAP_LFE_CC);
882 mtk_hdmi_set_bits(hdmi, GRL_MIX_CTRL, MIX_CTRL_FLAT);
884 if (hdmi->aud_param.aud_input_type == HDMI_AUD_INPUT_SPDIF &&
885 hdmi->aud_param.aud_codec == HDMI_AUDIO_CODING_TYPE_DST) {
886 mtk_hdmi_hw_aud_set_bit_num(hdmi, HDMI_AUDIO_SAMPLE_SIZE_24);
887 } else if (hdmi->aud_param.aud_i2s_fmt == HDMI_I2S_MODE_LJT_24BIT) {
888 hdmi->aud_param.aud_i2s_fmt = HDMI_I2S_MODE_LJT_16BIT;
891 mtk_hdmi_hw_aud_set_i2s_fmt(hdmi, hdmi->aud_param.aud_i2s_fmt);
892 mtk_hdmi_hw_aud_set_bit_num(hdmi, HDMI_AUDIO_SAMPLE_SIZE_24);
894 dst = ((hdmi->aud_param.aud_input_type == HDMI_AUD_INPUT_SPDIF) &&
895 (hdmi->aud_param.aud_codec == HDMI_AUDIO_CODING_TYPE_DST));
896 mtk_hdmi_hw_audio_config(hdmi, dst);
898 if (hdmi->aud_param.aud_input_type == HDMI_AUD_INPUT_SPDIF)
901 chan_type = hdmi->aud_param.aud_input_chan_type;
903 mtk_hdmi_hw_aud_set_i2s_chan_num(hdmi, chan_type, chan_count);
904 mtk_hdmi_hw_aud_set_input_type(hdmi, hdmi->aud_param.aud_input_type);
907 static int mtk_hdmi_aud_set_src(struct mtk_hdmi *hdmi,
910 unsigned int sample_rate = hdmi->aud_param.codec_params.sample_rate;
912 mtk_hdmi_hw_ncts_enable(hdmi, false);
913 mtk_hdmi_hw_aud_src_disable(hdmi);
914 mtk_hdmi_clear_bits(hdmi, GRL_CFG2, CFG2_ACLK_INV);
916 if (hdmi->aud_param.aud_input_type == HDMI_AUD_INPUT_I2S) {
927 mtk_hdmi_hw_aud_set_mclk(hdmi, hdmi->aud_param.aud_mclk);
937 mtk_hdmi_hw_aud_set_mclk(hdmi, HDMI_AUD_MCLK_128FS);
940 mtk_hdmi_hw_aud_set_ncts(hdmi, sample_rate, display_mode->clock);
942 mtk_hdmi_hw_aud_src_reenable(hdmi);
946 static int mtk_hdmi_aud_output_config(struct mtk_hdmi *hdmi,
949 mtk_hdmi_hw_aud_mute(hdmi);
950 mtk_hdmi_hw_send_aud_packet(hdmi, false);
952 mtk_hdmi_aud_set_input(hdmi);
953 mtk_hdmi_aud_set_src(hdmi, display_mode);
954 mtk_hdmi_hw_aud_set_channel_status(hdmi,
955 hdmi->aud_param.codec_params.iec.status);
959 mtk_hdmi_hw_ncts_enable(hdmi, true);
960 mtk_hdmi_hw_send_aud_packet(hdmi, true);
961 mtk_hdmi_hw_aud_unmute(hdmi);
965 static int mtk_hdmi_setup_avi_infoframe(struct mtk_hdmi *hdmi,
973 hdmi->curr_conn, mode);
975 dev_err(hdmi->dev,
982 dev_err(hdmi->dev, "Failed to pack AVI infoframe: %zd\n", err);
986 mtk_hdmi_hw_send_info_frame(hdmi, buffer, sizeof(buffer));
990 static int mtk_hdmi_setup_spd_infoframe(struct mtk_hdmi *hdmi,
1000 dev_err(hdmi->dev, "Failed to initialize SPD infoframe: %zd\n",
1007 dev_err(hdmi->dev, "Failed to pack SDP infoframe: %zd\n", err);
1011 mtk_hdmi_hw_send_info_frame(hdmi, buffer, sizeof(buffer));
1015 static int mtk_hdmi_setup_audio_infoframe(struct mtk_hdmi *hdmi)
1023 dev_err(hdmi->dev, "Failed to setup audio infoframe: %zd\n",
1032 hdmi->aud_param.aud_input_chan_type);
1036 dev_err(hdmi->dev, "Failed to pack audio infoframe: %zd\n",
1041 mtk_hdmi_hw_send_info_frame(hdmi, buffer, sizeof(buffer));
1045 static int mtk_hdmi_setup_vendor_specific_infoframe(struct mtk_hdmi *hdmi,
1053 hdmi->curr_conn, mode);
1055 dev_err(hdmi->dev,
1062 dev_err(hdmi->dev, "Failed to pack vendor infoframe: %zd\n",
1067 mtk_hdmi_hw_send_info_frame(hdmi, buffer, sizeof(buffer));
1071 static int mtk_hdmi_output_init(struct mtk_hdmi *hdmi)
1073 struct hdmi_audio_param *aud_param = &hdmi->aud_param;
1075 hdmi->csp = HDMI_COLORSPACE_RGB;
1086 static void mtk_hdmi_audio_enable(struct mtk_hdmi *hdmi)
1088 mtk_hdmi_hw_send_aud_packet(hdmi, true);
1089 hdmi->audio_enable = true;
1092 static void mtk_hdmi_audio_disable(struct mtk_hdmi *hdmi)
1094 mtk_hdmi_hw_send_aud_packet(hdmi, false);
1095 hdmi->audio_enable = false;
1098 static int mtk_hdmi_audio_set_param(struct mtk_hdmi *hdmi,
1101 if (!hdmi->audio_enable) {
1102 dev_err(hdmi->dev, "hdmi audio is in disable state!\n");
1105 dev_dbg(hdmi->dev, "codec:%d, input:%d, channel:%d, fs:%d\n",
1108 memcpy(&hdmi->aud_param, param, sizeof(*param));
1109 return mtk_hdmi_aud_output_config(hdmi, &hdmi->mode);
1112 static int mtk_hdmi_output_set_display_mode(struct mtk_hdmi *hdmi,
1117 mtk_hdmi_hw_vid_black(hdmi, true);
1118 mtk_hdmi_hw_aud_mute(hdmi);
1119 mtk_hdmi_hw_send_av_mute(hdmi);
1120 phy_power_off(hdmi->phy);
1122 ret = mtk_hdmi_video_change_vpll(hdmi,
1125 dev_err(hdmi->dev, "Failed to set vpll: %d\n", ret);
1128 mtk_hdmi_video_set_display_mode(hdmi, mode);
1130 phy_power_on(hdmi->phy);
1131 mtk_hdmi_aud_output_config(hdmi, mode);
1133 mtk_hdmi_hw_vid_black(hdmi, false);
1134 mtk_hdmi_hw_aud_unmute(hdmi);
1135 mtk_hdmi_hw_send_av_unmute(hdmi);
1147 static int mtk_hdmi_get_all_clk(struct mtk_hdmi *hdmi,
1153 hdmi->clk[i] = of_clk_get_by_name(np,
1155 if (IS_ERR(hdmi->clk[i]))
1156 return PTR_ERR(hdmi->clk[i]);
1161 static int mtk_hdmi_clk_enable_audio(struct mtk_hdmi *hdmi)
1165 ret = clk_prepare_enable(hdmi->clk[MTK_HDMI_CLK_AUD_BCLK]);
1169 ret = clk_prepare_enable(hdmi->clk[MTK_HDMI_CLK_AUD_SPDIF]);
1175 clk_disable_unprepare(hdmi->clk[MTK_HDMI_CLK_AUD_BCLK]);
1179 static void mtk_hdmi_clk_disable_audio(struct mtk_hdmi *hdmi)
1181 clk_disable_unprepare(hdmi->clk[MTK_HDMI_CLK_AUD_BCLK]);
1182 clk_disable_unprepare(hdmi->clk[MTK_HDMI_CLK_AUD_SPDIF]);
1186 mtk_hdmi_update_plugged_status(struct mtk_hdmi *hdmi)
1190 mutex_lock(&hdmi->update_plugged_status_lock);
1191 connected = mtk_cec_hpd_high(hdmi->cec_dev);
1192 if (hdmi->plugged_cb && hdmi->codec_dev)
1193 hdmi->plugged_cb(hdmi->codec_dev, connected);
1194 mutex_unlock(&hdmi->update_plugged_status_lock);
1200 static enum drm_connector_status mtk_hdmi_detect(struct mtk_hdmi *hdmi)
1202 return mtk_hdmi_update_plugged_status(hdmi);
1210 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge);
1213 dev_dbg(hdmi->dev, "xres=%d, yres=%d, refresh=%d, intl=%d clock=%d\n",
1217 next_bridge = drm_bridge_get_next_bridge(&hdmi->bridge);
1227 if (hdmi->conf) {
1228 if (hdmi->conf->cea_modes_only && !drm_match_cea_mode(mode))
1231 if (hdmi->conf->max_mode_clock &&
1232 mode->clock > hdmi->conf->max_mode_clock)
1246 struct mtk_hdmi *hdmi = dev_get_drvdata(dev);
1248 if (hdmi && hdmi->bridge.encoder && hdmi->bridge.encoder->dev) {
1251 status = mtk_hdmi_detect(hdmi);
1252 drm_helper_hpd_irq_event(hdmi->bridge.encoder->dev);
1253 drm_bridge_hpd_notify(&hdmi->bridge, status);
1263 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge);
1265 return mtk_hdmi_detect(hdmi);
1271 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge);
1274 if (!hdmi->ddc_adpt)
1276 drm_edid = drm_edid_read_ddc(connector, hdmi->ddc_adpt);
1285 hdmi->dvi_mode = !drm_detect_monitor_audio(edid);
1294 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge);
1303 if (hdmi->next_bridge) {
1304 ret = drm_bridge_attach(bridge->encoder, hdmi->next_bridge,
1310 mtk_cec_set_hpd_event(hdmi->cec_dev, mtk_hdmi_hpd_event, hdmi->dev);
1325 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge);
1327 if (!hdmi->enabled)
1330 phy_power_off(hdmi->phy);
1331 clk_disable_unprepare(hdmi->clk[MTK_HDMI_CLK_HDMI_PIXEL]);
1332 clk_disable_unprepare(hdmi->clk[MTK_HDMI_CLK_HDMI_PLL]);
1334 hdmi->curr_conn = NULL;
1336 hdmi->enabled = false;
1342 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge);
1344 if (!hdmi->powered)
1347 mtk_hdmi_hw_1p4_version_enable(hdmi, true);
1348 mtk_hdmi_hw_make_reg_writable(hdmi, false);
1350 hdmi->powered = false;
1357 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge);
1359 dev_dbg(hdmi->dev, "cur info: name:%s, hdisplay:%d\n",
1361 dev_dbg(hdmi->dev, "hsync_start:%d,hsync_end:%d, htotal:%d",
1364 dev_dbg(hdmi->dev, "hskew:%d, vdisplay:%d\n",
1366 dev_dbg(hdmi->dev, "vsync_start:%d, vsync_end:%d, vtotal:%d",
1369 dev_dbg(hdmi->dev, "vscan:%d, flag:%d\n",
1372 drm_mode_copy(&hdmi->mode, adjusted_mode);
1378 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge);
1380 mtk_hdmi_hw_make_reg_writable(hdmi, true);
1381 mtk_hdmi_hw_1p4_version_enable(hdmi, true);
1383 hdmi->powered = true;
1386 static void mtk_hdmi_send_infoframe(struct mtk_hdmi *hdmi,
1389 mtk_hdmi_setup_audio_infoframe(hdmi);
1390 mtk_hdmi_setup_avi_infoframe(hdmi, mode);
1391 mtk_hdmi_setup_spd_infoframe(hdmi, "mediatek", "On-chip HDMI");
1393 mtk_hdmi_setup_vendor_specific_infoframe(hdmi, mode);
1400 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge);
1403 hdmi->curr_conn = drm_atomic_get_new_connector_for_encoder(state,
1406 mtk_hdmi_output_set_display_mode(hdmi, &hdmi->mode);
1407 clk_prepare_enable(hdmi->clk[MTK_HDMI_CLK_HDMI_PLL]);
1408 clk_prepare_enable(hdmi->clk[MTK_HDMI_CLK_HDMI_PIXEL]);
1409 phy_power_on(hdmi->phy);
1410 mtk_hdmi_send_infoframe(hdmi, &hdmi->mode);
1412 hdmi->enabled = true;
1431 static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi,
1442 ret = mtk_hdmi_get_all_clk(hdmi, np);
1459 dev_err(hdmi->dev, "Waiting for CEC device %pOF\n",
1465 hdmi->cec_dev = &cec_pdev->dev;
1468 * The mediatek,syscon-hdmi property contains a phandle link to the
1472 regmap = syscon_regmap_lookup_by_phandle(np, "mediatek,syscon-hdmi");
1473 ret = of_property_read_u32_index(np, "mediatek,syscon-hdmi", 1,
1474 &hdmi->sys_offset);
1483 hdmi->sys_regmap = regmap;
1486 hdmi->regs = devm_ioremap_resource(dev, mem);
1487 if (IS_ERR(hdmi->regs)) {
1488 ret = PTR_ERR(hdmi->regs);
1498 if (!of_device_is_compatible(remote, "hdmi-connector")) {
1499 hdmi->next_bridge = of_drm_find_bridge(remote);
1500 if (!hdmi->next_bridge) {
1518 hdmi->ddc_adpt = of_find_i2c_adapter_by_node(i2c_np);
1520 if (!hdmi->ddc_adpt) {
1528 put_device(hdmi->cec_dev);
1540 struct mtk_hdmi *hdmi = dev_get_drvdata(dev);
1544 dev_dbg(hdmi->dev, "%s: %u Hz, %d bit, %d channels\n", __func__,
1547 if (!hdmi->bridge.encoder)
1564 dev_err(hdmi->dev, "channel[%d] not supported!\n", chan);
1578 dev_err(hdmi->dev, "rate[%d] not supported!\n",
1597 dev_err(hdmi->dev, "%s: Invalid DAI format %d\n", __func__,
1605 mtk_hdmi_audio_set_param(hdmi, &hdmi_params);
1612 struct mtk_hdmi *hdmi = dev_get_drvdata(dev);
1614 mtk_hdmi_audio_enable(hdmi);
1621 struct mtk_hdmi *hdmi = dev_get_drvdata(dev);
1623 mtk_hdmi_audio_disable(hdmi);
1630 struct mtk_hdmi *hdmi = dev_get_drvdata(dev);
1633 mtk_hdmi_hw_aud_mute(hdmi);
1635 mtk_hdmi_hw_aud_unmute(hdmi);
1642 struct mtk_hdmi *hdmi = dev_get_drvdata(dev);
1644 if (hdmi->enabled)
1645 memcpy(buf, hdmi->curr_conn->eld, min(sizeof(hdmi->curr_conn->eld), len));
1655 struct mtk_hdmi *hdmi = data;
1657 mutex_lock(&hdmi->update_plugged_status_lock);
1658 hdmi->plugged_cb = fn;
1659 hdmi->codec_dev = codec_dev;
1660 mutex_unlock(&hdmi->update_plugged_status_lock);
1662 mtk_hdmi_update_plugged_status(hdmi);
1679 struct mtk_hdmi *hdmi = dev_get_drvdata(dev);
1684 .data = hdmi,
1700 struct mtk_hdmi *hdmi;
1704 hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL);
1705 if (!hdmi)
1708 hdmi->dev = dev;
1709 hdmi->conf = of_device_get_match_data(dev);
1711 ret = mtk_hdmi_dt_parse_pdata(hdmi, pdev);
1715 hdmi->phy = devm_phy_get(dev, "hdmi");
1716 if (IS_ERR(hdmi->phy)) {
1717 ret = PTR_ERR(hdmi->phy);
1722 mutex_init(&hdmi->update_plugged_status_lock);
1723 platform_set_drvdata(pdev, hdmi);
1725 ret = mtk_hdmi_output_init(hdmi);
1727 dev_err(dev, "Failed to initialize hdmi output\n");
1737 hdmi->bridge.funcs = &mtk_hdmi_bridge_funcs;
1738 hdmi->bridge.of_node = pdev->dev.of_node;
1739 hdmi->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID
1741 hdmi->bridge.type = DRM_MODE_CONNECTOR_HDMIA;
1742 drm_bridge_add(&hdmi->bridge);
1744 ret = mtk_hdmi_clk_enable_audio(hdmi);
1753 drm_bridge_remove(&hdmi->bridge);
1759 struct mtk_hdmi *hdmi = platform_get_drvdata(pdev);
1761 drm_bridge_remove(&hdmi->bridge);
1762 mtk_hdmi_clk_disable_audio(hdmi);
1768 struct mtk_hdmi *hdmi = dev_get_drvdata(dev);
1770 mtk_hdmi_clk_disable_audio(hdmi);
1777 struct mtk_hdmi *hdmi = dev_get_drvdata(dev);
1780 ret = mtk_hdmi_clk_enable_audio(hdmi);
1782 dev_err(dev, "hdmi resume failed!\n");
1802 { .compatible = "mediatek,mt2701-hdmi",
1805 { .compatible = "mediatek,mt8167-hdmi",
1808 { .compatible = "mediatek,mt8173-hdmi",
1818 .name = "mediatek-drm-hdmi",