1 From 3cd4b3cfc651c4d54897c72fbbaa9cd583ee6208 Mon Sep 17 00:00:00 2001
2 From: Sandor Yu <Sandor.yu@nxp.com>
3 Date: Fri, 30 Aug 2019 17:51:43 +0800
4 Subject: [PATCH] drm: bridge: cadence: Add mhdp audio driver
6 Move mhdp audio driver to cadence folder.
7 Add audio info-frame set function for hdmi tx audio.
8 The driver suppoer both HDMI and DP audio.
10 Signed-off-by: Sandor Yu <Sandor.yu@nxp.com>
12 drivers/gpu/drm/bridge/cadence/Kconfig | 3 +
13 drivers/gpu/drm/bridge/cadence/Makefile | 3 +-
14 drivers/gpu/drm/bridge/cadence/cdns-dp-core.c | 4 +
15 drivers/gpu/drm/bridge/cadence/cdns-hdmi-core.c | 5 +-
16 drivers/gpu/drm/bridge/cadence/cdns-mhdp-audio.c | 395 ++++++++++++++++++++++
17 drivers/gpu/drm/bridge/cadence/cdns-mhdp-common.c | 183 ----------
18 drivers/gpu/drm/imx/Kconfig | 1 +
19 include/drm/bridge/cdns-mhdp-common.h | 6 +
20 8 files changed, 414 insertions(+), 186 deletions(-)
21 create mode 100644 drivers/gpu/drm/bridge/cadence/cdns-mhdp-audio.c
23 --- a/drivers/gpu/drm/bridge/cadence/Kconfig
24 +++ b/drivers/gpu/drm/bridge/cadence/Kconfig
25 @@ -11,3 +11,6 @@ config DRM_CDNS_HDMI
28 tristate "Cadence DP DRM driver"
30 +config DRM_CDNS_AUDIO
31 + tristate "Cadence MHDP Audio driver"
32 --- a/drivers/gpu/drm/bridge/cadence/Makefile
33 +++ b/drivers/gpu/drm/bridge/cadence/Makefile
35 -#ccflags-y := -Iinclude/drm
37 obj-$(CONFIG_DRM_CDNS_MHDP) += cdns-mhdp-common.o cdns-mhdp-hdmi.o
38 obj-$(CONFIG_DRM_CDNS_HDMI) += cdns-hdmi-core.o
39 obj-$(CONFIG_DRM_CDNS_DP) += cdns-dp-core.o
40 +obj-$(CONFIG_DRM_CDNS_AUDIO) += cdns-mhdp-audio.o
41 --- a/drivers/gpu/drm/bridge/cadence/cdns-dp-core.c
42 +++ b/drivers/gpu/drm/bridge/cadence/cdns-dp-core.c
43 @@ -526,6 +526,9 @@ __cdns_dp_probe(struct platform_device *
45 dev_set_drvdata(dev, &dp->mhdp);
47 + /* register audio driver */
48 + cdns_mhdp_register_audio_driver(dev);
50 dp_aux_init(&dp->mhdp, dev);
53 @@ -537,6 +540,7 @@ err_out:
54 static void __cdns_dp_remove(struct cdns_mhdp_device *mhdp)
57 + cdns_mhdp_unregister_audio_driver(mhdp->dev);
60 /* -----------------------------------------------------------------------------
61 --- a/drivers/gpu/drm/bridge/cadence/cdns-hdmi-core.c
62 +++ b/drivers/gpu/drm/bridge/cadence/cdns-hdmi-core.c
64 * (at your option) any later version.
68 #include <drm/bridge/cdns-mhdp-imx.h>
69 #include <drm/drm_atomic_helper.h>
70 #include <drm/drm_crtc_helper.h>
71 @@ -513,6 +512,9 @@ __cdns_hdmi_probe(struct platform_device
73 dev_set_drvdata(dev, &hdmi->mhdp);
75 + /* register audio driver */
76 + cdns_mhdp_register_audio_driver(dev);
81 @@ -522,6 +524,7 @@ err_out:
83 static void __cdns_hdmi_remove(struct cdns_mhdp_device *mhdp)
85 + cdns_mhdp_unregister_audio_driver(mhdp->dev);
88 /* -----------------------------------------------------------------------------
90 +++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp-audio.c
92 +// SPDX-License-Identifier: GPL-2.0
94 + * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd
95 + * Author: Chris Zhong <zyw@rock-chips.com>
97 + * This software is licensed under the terms of the GNU General Public
98 + * License version 2, as published by the Free Software Foundation, and
99 + * may be copied, distributed, and modified under those terms.
101 + * This program is distributed in the hope that it will be useful,
102 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
103 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
104 + * GNU General Public License for more details.
106 +#include <linux/clk.h>
107 +#include <linux/reset.h>
108 +#include <drm/bridge/cdns-mhdp-common.h>
109 +#include <sound/hdmi-codec.h>
110 +#include <drm/bridge/cdns-mhdp-imx.h>
111 +#include <drm/drm_of.h>
112 +#include <drm/drmP.h>
114 +#define CDNS_DP_SPDIF_CLK 200000000
116 +static u32 TMDS_rate_table[7] = {
117 + 25200, 27000, 54000, 74250, 148500, 297000, 594000,
120 +static u32 N_table_32k[7] = {
121 +/* 25200/27000/54000/74250/148500/297000/594000 */
122 + 4096, 4096, 4096, 4096, 4096, 3072, 3072,
125 +static u32 N_table_44k[7] = {
126 + 6272, 6272, 6272, 6272, 6272, 4704, 9408,
129 +static u32 N_table_48k[7] = {
130 + 6144, 6144, 6144, 6144, 6144, 5120, 6144,
133 +static int select_N_index(u32 pclk)
135 + int num = sizeof(TMDS_rate_table)/sizeof(int);
138 + for (i = 0; i < num ; i++)
139 + if (pclk == TMDS_rate_table[i])
143 + DRM_WARN("pclkc %d is not supported!\n", pclk);
150 +static void hdmi_audio_avi_set(struct cdns_mhdp_device *mhdp,
153 + struct hdmi_audio_infoframe frame;
157 + hdmi_audio_infoframe_init(&frame);
159 + frame.channels = channels;
160 + frame.coding_type = HDMI_AUDIO_CODING_TYPE_STREAM;
163 + frame.channel_allocation = 0;
164 + else if (channels == 4)
165 + frame.channel_allocation = 0x3;
166 + else if (channels == 8)
167 + frame.channel_allocation = 0x13;
169 + ret = hdmi_audio_infoframe_pack(&frame, buf + 1, sizeof(buf) - 1);
171 + DRM_ERROR("failed to pack audio infoframe: %d\n", ret);
177 + cdns_mhdp_infoframe_set(mhdp, 1, sizeof(buf), buf, HDMI_INFOFRAME_TYPE_AUDIO);
180 +int cdns_mhdp_audio_stop(struct cdns_mhdp_device *mhdp,
181 + struct audio_info *audio)
185 + if (audio->connector_type == DRM_MODE_CONNECTOR_DisplayPort) {
186 + ret = cdns_mhdp_reg_write(mhdp, AUDIO_PACK_CONTROL, 0);
188 + DRM_DEV_ERROR(mhdp->dev, "audio stop failed: %d\n", ret);
193 + cdns_mhdp_bus_write(0, mhdp, SPDIF_CTRL_ADDR);
195 + /* clearn the audio config and reset */
196 + cdns_mhdp_bus_write(0, mhdp, AUDIO_SRC_CNTL);
197 + cdns_mhdp_bus_write(0, mhdp, AUDIO_SRC_CNFG);
198 + cdns_mhdp_bus_write(AUDIO_SW_RST, mhdp, AUDIO_SRC_CNTL);
199 + cdns_mhdp_bus_write(0, mhdp, AUDIO_SRC_CNTL);
201 + /* reset smpl2pckt component */
202 + cdns_mhdp_bus_write(0, mhdp, SMPL2PKT_CNTL);
203 + cdns_mhdp_bus_write(AUDIO_SW_RST, mhdp, SMPL2PKT_CNTL);
204 + cdns_mhdp_bus_write(0, mhdp, SMPL2PKT_CNTL);
207 + cdns_mhdp_bus_write(AUDIO_SW_RST, mhdp, FIFO_CNTL);
208 + cdns_mhdp_bus_write(0, mhdp, FIFO_CNTL);
210 + if (audio->format == AFMT_SPDIF_INT)
211 + clk_disable_unprepare(mhdp->spdif_clk);
215 +EXPORT_SYMBOL(cdns_mhdp_audio_stop);
217 +int cdns_mhdp_audio_mute(struct cdns_mhdp_device *mhdp, bool enable)
219 + struct audio_info *audio = &mhdp->audio_info;
222 + if (audio->connector_type == DRM_MODE_CONNECTOR_DisplayPort) {
223 + ret = cdns_mhdp_reg_write_bit(mhdp, DP_VB_ID, 4, 1, enable);
225 + DRM_DEV_ERROR(mhdp->dev, "audio mute failed: %d\n", ret);
230 +EXPORT_SYMBOL(cdns_mhdp_audio_mute);
232 +static void cdns_mhdp_audio_config_i2s(struct cdns_mhdp_device *mhdp,
233 + struct audio_info *audio)
235 + int sub_pckt_num = 1, i2s_port_en_val = 0xf, i;
236 + int idx = select_N_index(mhdp->mode.clock);
239 + if (audio->channels == 2) {
240 + if (mhdp->dp.link.num_lanes == 1)
245 + i2s_port_en_val = 1;
246 + } else if (audio->channels == 4) {
247 + i2s_port_en_val = 3;
250 + cdns_mhdp_bus_write(0x0, mhdp, SPDIF_CTRL_ADDR);
252 + cdns_mhdp_bus_write(SYNC_WR_TO_CH_ZERO, mhdp, FIFO_CNTL);
254 + val = MAX_NUM_CH(audio->channels);
255 + val |= NUM_OF_I2S_PORTS(audio->channels);
256 + val |= AUDIO_TYPE_LPCM;
257 + val |= CFG_SUB_PCKT_NUM(sub_pckt_num);
258 + cdns_mhdp_bus_write(val, mhdp, SMPL2PKT_CNFG);
260 + if (audio->sample_width == 16)
262 + else if (audio->sample_width == 24)
267 + val |= AUDIO_CH_NUM(audio->channels);
268 + val |= I2S_DEC_PORT_EN(i2s_port_en_val);
269 + val |= TRANS_SMPL_WIDTH_32;
270 + cdns_mhdp_bus_write(val, mhdp, AUDIO_SRC_CNFG);
272 + for (i = 0; i < (audio->channels + 1) / 2; i++) {
273 + if (audio->sample_width == 16)
274 + val = (0x02 << 8) | (0x02 << 20);
275 + else if (audio->sample_width == 24)
276 + val = (0x0b << 8) | (0x0b << 20);
278 + val |= ((2 * i) << 4) | ((2 * i + 1) << 16);
279 + cdns_mhdp_bus_write(val, mhdp, STTS_BIT_CH(i));
282 + switch (audio->sample_rate) {
284 + val = SAMPLING_FREQ(3) |
285 + ORIGINAL_SAMP_FREQ(0xc);
286 + ncts = N_table_32k[idx];
289 + val = SAMPLING_FREQ(0) |
290 + ORIGINAL_SAMP_FREQ(0xf);
291 + ncts = N_table_44k[idx];
294 + val = SAMPLING_FREQ(2) |
295 + ORIGINAL_SAMP_FREQ(0xd);
296 + ncts = N_table_48k[idx];
299 + val = SAMPLING_FREQ(8) |
300 + ORIGINAL_SAMP_FREQ(0x7);
301 + ncts = N_table_44k[idx] * 2;
304 + val = SAMPLING_FREQ(0xa) |
305 + ORIGINAL_SAMP_FREQ(5);
306 + ncts = N_table_48k[idx] * 2;
309 + val = SAMPLING_FREQ(0xc) |
310 + ORIGINAL_SAMP_FREQ(3);
311 + ncts = N_table_44k[idx] * 4;
315 + val = SAMPLING_FREQ(0xe) |
316 + ORIGINAL_SAMP_FREQ(1);
317 + ncts = N_table_48k[idx] * 4;
321 + cdns_mhdp_bus_write(val, mhdp, COM_CH_STTS_BITS);
323 + if (audio->connector_type == DRM_MODE_CONNECTOR_HDMIA)
324 + cdns_mhdp_reg_write(mhdp, CM_I2S_CTRL, ncts | 0x4000000);
326 + cdns_mhdp_bus_write(SMPL2PKT_EN, mhdp, SMPL2PKT_CNTL);
327 + cdns_mhdp_bus_write(I2S_DEC_START, mhdp, AUDIO_SRC_CNTL);
330 +static void cdns_mhdp_audio_config_spdif(struct cdns_mhdp_device *mhdp)
334 + cdns_mhdp_bus_write(SYNC_WR_TO_CH_ZERO, mhdp, FIFO_CNTL);
336 + val = MAX_NUM_CH(2) | AUDIO_TYPE_LPCM | CFG_SUB_PCKT_NUM(4);
337 + cdns_mhdp_bus_write(val, mhdp, SMPL2PKT_CNFG);
338 + cdns_mhdp_bus_write(SMPL2PKT_EN, mhdp, SMPL2PKT_CNTL);
340 + val = SPDIF_ENABLE | SPDIF_AVG_SEL | SPDIF_JITTER_BYPASS;
341 + cdns_mhdp_bus_write(val, mhdp, SPDIF_CTRL_ADDR);
343 + clk_prepare_enable(mhdp->spdif_clk);
344 + clk_set_rate(mhdp->spdif_clk, CDNS_DP_SPDIF_CLK);
347 +int cdns_mhdp_audio_config(struct cdns_mhdp_device *mhdp,
348 + struct audio_info *audio)
352 + /* reset the spdif clk before config */
353 + if (audio->format == AFMT_SPDIF_INT) {
354 + reset_control_assert(mhdp->spdif_rst);
355 + reset_control_deassert(mhdp->spdif_rst);
358 + if (audio->connector_type == DRM_MODE_CONNECTOR_DisplayPort) {
359 + ret = cdns_mhdp_reg_write(mhdp, CM_LANE_CTRL, LANE_REF_CYC);
361 + goto err_audio_config;
363 + ret = cdns_mhdp_reg_write(mhdp, CM_CTRL, 0);
365 + goto err_audio_config;
368 + ret = cdns_mhdp_reg_write(mhdp, CM_CTRL, 8);
370 + goto err_audio_config;
373 + if (audio->format == AFMT_I2S)
374 + cdns_mhdp_audio_config_i2s(mhdp, audio);
375 + else if (audio->format == AFMT_SPDIF_INT)
376 + cdns_mhdp_audio_config_spdif(mhdp);
378 + if (audio->connector_type == DRM_MODE_CONNECTOR_DisplayPort)
379 + ret = cdns_mhdp_reg_write(mhdp, AUDIO_PACK_CONTROL, AUDIO_PACK_EN);
381 + if (audio->connector_type == DRM_MODE_CONNECTOR_HDMIA)
382 + hdmi_audio_avi_set(mhdp, audio->channels);
386 + DRM_DEV_ERROR(mhdp->dev, "audio config failed: %d\n", ret);
389 +EXPORT_SYMBOL(cdns_mhdp_audio_config);
391 +static int audio_hw_params(struct device *dev, void *data,
392 + struct hdmi_codec_daifmt *daifmt,
393 + struct hdmi_codec_params *params)
395 + struct cdns_mhdp_device *mhdp = dev_get_drvdata(dev);
396 + struct audio_info audio = {
397 + .sample_width = params->sample_width,
398 + .sample_rate = params->sample_rate,
399 + .channels = params->channels,
400 + .connector_type = mhdp->connector.base.connector_type,
404 + switch (daifmt->fmt) {
406 + audio.format = AFMT_I2S;
409 + audio.format = AFMT_SPDIF_EXT;
412 + DRM_DEV_ERROR(dev, "Invalid format %d\n", daifmt->fmt);
417 + ret = cdns_mhdp_audio_config(mhdp, &audio);
419 + mhdp->audio_info = audio;
425 +static void audio_shutdown(struct device *dev, void *data)
427 + struct cdns_mhdp_device *mhdp = dev_get_drvdata(dev);
430 + ret = cdns_mhdp_audio_stop(mhdp, &mhdp->audio_info);
432 + mhdp->audio_info.format = AFMT_UNUSED;
435 +static int audio_digital_mute(struct device *dev, void *data,
438 + struct cdns_mhdp_device *mhdp = dev_get_drvdata(dev);
441 + ret = cdns_mhdp_audio_mute(mhdp, enable);
446 +static int audio_get_eld(struct device *dev, void *data,
447 + u8 *buf, size_t len)
449 + struct cdns_mhdp_device *mhdp = dev_get_drvdata(dev);
451 + memcpy(buf, mhdp->connector.base.eld,
452 + min(sizeof(mhdp->connector.base.eld), len));
457 +static const struct hdmi_codec_ops audio_codec_ops = {
458 + .hw_params = audio_hw_params,
459 + .audio_shutdown = audio_shutdown,
460 + .digital_mute = audio_digital_mute,
461 + .get_eld = audio_get_eld,
464 +int cdns_mhdp_register_audio_driver(struct device *dev)
466 + struct cdns_mhdp_device *mhdp = dev_get_drvdata(dev);
467 + struct hdmi_codec_pdata codec_data = {
470 + .ops = &audio_codec_ops,
471 + .max_i2s_channels = 8,
474 + mhdp->audio_pdev = platform_device_register_data(
475 + dev, HDMI_CODEC_DRV_NAME, 1,
476 + &codec_data, sizeof(codec_data));
478 + return PTR_ERR_OR_ZERO(mhdp->audio_pdev);
481 +void cdns_mhdp_unregister_audio_driver(struct device *dev)
483 + struct cdns_mhdp_device *mhdp = dev_get_drvdata(dev);
485 + platform_device_unregister(mhdp->audio_pdev);
487 --- a/drivers/gpu/drm/bridge/cadence/cdns-mhdp-common.c
488 +++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp-common.c
489 @@ -937,189 +937,6 @@ err_config_video:
491 EXPORT_SYMBOL(cdns_mhdp_config_video);
493 -int cdns_mhdp_audio_stop(struct cdns_mhdp_device *mhdp,
494 - struct audio_info *audio)
498 - ret = cdns_mhdp_reg_write(mhdp, AUDIO_PACK_CONTROL, 0);
500 - DRM_DEV_ERROR(mhdp->dev, "audio stop failed: %d\n", ret);
504 - cdns_mhdp_bus_write(0, mhdp, SPDIF_CTRL_ADDR);
506 - /* clearn the audio config and reset */
507 - cdns_mhdp_bus_write(0, mhdp, AUDIO_SRC_CNTL);
508 - cdns_mhdp_bus_write(0, mhdp, AUDIO_SRC_CNFG);
509 - cdns_mhdp_bus_write(AUDIO_SW_RST, mhdp, AUDIO_SRC_CNTL);
510 - cdns_mhdp_bus_write(0, mhdp, AUDIO_SRC_CNTL);
512 - /* reset smpl2pckt component */
513 - cdns_mhdp_bus_write(0, mhdp, SMPL2PKT_CNTL);
514 - cdns_mhdp_bus_write(AUDIO_SW_RST, mhdp, SMPL2PKT_CNTL);
515 - cdns_mhdp_bus_write(0, mhdp, SMPL2PKT_CNTL);
518 - cdns_mhdp_bus_write(AUDIO_SW_RST, mhdp, FIFO_CNTL);
519 - cdns_mhdp_bus_write(0, mhdp, FIFO_CNTL);
521 - if (audio->format == AFMT_SPDIF_INT)
522 - clk_disable_unprepare(mhdp->spdif_clk);
526 -EXPORT_SYMBOL(cdns_mhdp_audio_stop);
528 -int cdns_mhdp_audio_mute(struct cdns_mhdp_device *mhdp, bool enable)
532 - ret = cdns_mhdp_reg_write_bit(mhdp, DP_VB_ID, 4, 1, enable);
534 - DRM_DEV_ERROR(mhdp->dev, "audio mute failed: %d\n", ret);
538 -EXPORT_SYMBOL(cdns_mhdp_audio_mute);
540 -static void cdns_mhdp_audio_config_i2s(struct cdns_mhdp_device *mhdp,
541 - struct audio_info *audio)
543 - int sub_pckt_num = 1, i2s_port_en_val = 0xf, i;
546 - if (audio->channels == 2) {
547 - if (mhdp->dp.link.num_lanes == 1)
552 - i2s_port_en_val = 1;
553 - } else if (audio->channels == 4) {
554 - i2s_port_en_val = 3;
557 - cdns_mhdp_bus_write(0x0, mhdp, SPDIF_CTRL_ADDR);
559 - cdns_mhdp_bus_write(SYNC_WR_TO_CH_ZERO, mhdp, FIFO_CNTL);
561 - val = MAX_NUM_CH(audio->channels);
562 - val |= NUM_OF_I2S_PORTS(audio->channels);
563 - val |= AUDIO_TYPE_LPCM;
564 - val |= CFG_SUB_PCKT_NUM(sub_pckt_num);
565 - cdns_mhdp_bus_write(val, mhdp, SMPL2PKT_CNFG);
567 - if (audio->sample_width == 16)
569 - else if (audio->sample_width == 24)
574 - val |= AUDIO_CH_NUM(audio->channels);
575 - val |= I2S_DEC_PORT_EN(i2s_port_en_val);
576 - val |= TRANS_SMPL_WIDTH_32;
577 - cdns_mhdp_bus_write(val, mhdp, AUDIO_SRC_CNFG);
579 - for (i = 0; i < (audio->channels + 1) / 2; i++) {
580 - if (audio->sample_width == 16)
581 - val = (0x02 << 8) | (0x02 << 20);
582 - else if (audio->sample_width == 24)
583 - val = (0x0b << 8) | (0x0b << 20);
585 - val |= ((2 * i) << 4) | ((2 * i + 1) << 16);
586 - cdns_mhdp_bus_write(val, mhdp, STTS_BIT_CH(i));
589 - switch (audio->sample_rate) {
591 - val = SAMPLING_FREQ(3) |
592 - ORIGINAL_SAMP_FREQ(0xc);
595 - val = SAMPLING_FREQ(0) |
596 - ORIGINAL_SAMP_FREQ(0xf);
599 - val = SAMPLING_FREQ(2) |
600 - ORIGINAL_SAMP_FREQ(0xd);
603 - val = SAMPLING_FREQ(8) |
604 - ORIGINAL_SAMP_FREQ(0x7);
607 - val = SAMPLING_FREQ(0xa) |
608 - ORIGINAL_SAMP_FREQ(5);
611 - val = SAMPLING_FREQ(0xc) |
612 - ORIGINAL_SAMP_FREQ(3);
615 - val = SAMPLING_FREQ(0xe) |
616 - ORIGINAL_SAMP_FREQ(1);
620 - cdns_mhdp_bus_write(val, mhdp, COM_CH_STTS_BITS);
622 - cdns_mhdp_bus_write(SMPL2PKT_EN, mhdp, SMPL2PKT_CNTL);
623 - cdns_mhdp_bus_write(I2S_DEC_START, mhdp, AUDIO_SRC_CNTL);
626 -static void cdns_mhdp_audio_config_spdif(struct cdns_mhdp_device *mhdp)
630 - cdns_mhdp_bus_write(SYNC_WR_TO_CH_ZERO, mhdp, FIFO_CNTL);
632 - val = MAX_NUM_CH(2) | AUDIO_TYPE_LPCM | CFG_SUB_PCKT_NUM(4);
633 - cdns_mhdp_bus_write(val, mhdp, SMPL2PKT_CNFG);
634 - cdns_mhdp_bus_write(SMPL2PKT_EN, mhdp, SMPL2PKT_CNTL);
636 - val = SPDIF_ENABLE | SPDIF_AVG_SEL | SPDIF_JITTER_BYPASS;
637 - cdns_mhdp_bus_write(val, mhdp, SPDIF_CTRL_ADDR);
639 - clk_prepare_enable(mhdp->spdif_clk);
640 - clk_set_rate(mhdp->spdif_clk, CDNS_DP_SPDIF_CLK);
643 -int cdns_mhdp_audio_config(struct cdns_mhdp_device *mhdp,
644 - struct audio_info *audio)
648 - /* reset the spdif clk before config */
649 - if (audio->format == AFMT_SPDIF_INT) {
650 - reset_control_assert(mhdp->spdif_rst);
651 - reset_control_deassert(mhdp->spdif_rst);
654 - ret = cdns_mhdp_reg_write(mhdp, CM_LANE_CTRL, LANE_REF_CYC);
656 - goto err_audio_config;
658 - ret = cdns_mhdp_reg_write(mhdp, CM_CTRL, 0);
660 - goto err_audio_config;
662 - if (audio->format == AFMT_I2S)
663 - cdns_mhdp_audio_config_i2s(mhdp, audio);
664 - else if (audio->format == AFMT_SPDIF_INT)
665 - cdns_mhdp_audio_config_spdif(mhdp);
667 - ret = cdns_mhdp_reg_write(mhdp, AUDIO_PACK_CONTROL, AUDIO_PACK_EN);
671 - DRM_DEV_ERROR(mhdp->dev, "audio config failed: %d\n", ret);
674 -EXPORT_SYMBOL(cdns_mhdp_audio_config);
676 int cdns_mhdp_adjust_lt(struct cdns_mhdp_device *mhdp,
677 u8 nlanes, u16 udelay, u8 *lanes_data, u8 *dpcd)
679 --- a/drivers/gpu/drm/imx/Kconfig
680 +++ b/drivers/gpu/drm/imx/Kconfig
681 @@ -45,6 +45,7 @@ config DRM_IMX_CDNS_MHDP
685 + select DRM_CDNS_AUDIO
688 Choose this if you want to use HDMI on i.MX8.
689 --- a/include/drm/bridge/cdns-mhdp-common.h
690 +++ b/include/drm/bridge/cdns-mhdp-common.h
691 @@ -548,6 +548,7 @@ struct audio_info {
695 + int connector_type;
698 enum vic_pxl_encoding_format {
699 @@ -670,11 +671,16 @@ int cdns_mhdp_get_edid_block(void *mhdp,
700 int cdns_mhdp_train_link(struct cdns_mhdp_device *mhdp);
701 int cdns_mhdp_set_video_status(struct cdns_mhdp_device *mhdp, int active);
702 int cdns_mhdp_config_video(struct cdns_mhdp_device *mhdp);
705 int cdns_mhdp_audio_stop(struct cdns_mhdp_device *mhdp,
706 struct audio_info *audio);
707 int cdns_mhdp_audio_mute(struct cdns_mhdp_device *mhdp, bool enable);
708 int cdns_mhdp_audio_config(struct cdns_mhdp_device *mhdp,
709 struct audio_info *audio);
710 +int cdns_mhdp_register_audio_driver(struct device *dev);
711 +void cdns_mhdp_unregister_audio_driver(struct device *dev);
713 int cdns_mhdp_reg_read(struct cdns_mhdp_device *mhdp, u32 addr);
714 int cdns_mhdp_reg_write(struct cdns_mhdp_device *mhdp, u32 addr, u32 val);
715 int cdns_mhdp_reg_write_bit(struct cdns_mhdp_device *mhdp, u16 addr,