MLK-13946-4: ASoC: imx-cdnhdmi: refine machine driver for api changes
Since commit 3f5780eb4520 ("MLK-16538-2: hdmi api: Relocate hdmi api soure code") change the api. And hdmi video driver provide a new api for hdmi audio. Machine driver need to be updated accrodingly Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>pull/10/head
parent
b174603d35
commit
f37670a41f
|
@ -4,7 +4,7 @@ Required properties:
|
|||
- compatible : "fsl,imx-audio-cdnhdmi"
|
||||
- model : The user-visible name of this sound complex
|
||||
- audio-cpu : The phandle of the i.MX SAI controller
|
||||
- video-mode : hdmi video mode
|
||||
- protocol : 0 is hdmi, 1 is dp.
|
||||
|
||||
Example:
|
||||
|
||||
|
@ -12,6 +12,5 @@ sound-hdmi {
|
|||
compatible = "fsl,imx-audio-cdnhdmi";
|
||||
model = "imx-audio-hdmi";
|
||||
audio-cpu = <&sai4>;
|
||||
video-mode = <95>; /* #16: 1920x1080p@60HZ 16:9 */
|
||||
/* #95: 3840x2160p@30Hz 16:9 */
|
||||
protocol = <0>;
|
||||
};
|
||||
|
|
|
@ -21,9 +21,9 @@
|
|||
#include <sound/control.h>
|
||||
#include <sound/pcm_params.h>
|
||||
#include <sound/soc-dapm.h>
|
||||
#include "../../../drivers/mxc/hdp/API_General.h"
|
||||
#include "../../../drivers/mxc/hdp/API_Audio.h"
|
||||
#include "../../../drivers/mxc/hdp/vic_table.h"
|
||||
#include "../../../drivers/gpu/drm/imx/hdp/imx-hdp.h"
|
||||
#include "../../../drivers/video/fbdev/mxc/API_AFE_t28hpc_hdmitx.h"
|
||||
|
||||
#define SUPPORT_RATE_NUM 10
|
||||
#define SUPPORT_CHANNEL_NUM 10
|
||||
|
@ -31,50 +31,9 @@
|
|||
struct imx_cdnhdmi_data {
|
||||
struct snd_soc_dai_link dai;
|
||||
struct snd_soc_card card;
|
||||
int vmode_index;
|
||||
int protocol;
|
||||
};
|
||||
|
||||
u32 TMDS_rate_table[7] = {
|
||||
25200, 27000, 54000, 74250, 148500, 297000, 594000,
|
||||
};
|
||||
|
||||
u32 N_table_32k[8] = {
|
||||
/*25200, 27000, 54000, 74250, 148500, 297000, 594000,*/
|
||||
4096, 4096, 4096, 4096, 4096, 3072, 3072, 4096,
|
||||
};
|
||||
|
||||
u32 N_table_44k[8] = {
|
||||
6272, 6272, 6272, 6272, 6272, 4704, 9408, 6272,
|
||||
};
|
||||
|
||||
u32 N_table_48k[8] = {
|
||||
6144, 6144, 6144, 6144, 6144, 5120, 6144, 6144,
|
||||
};
|
||||
|
||||
static int select_N_index(struct device *dev, int vmode_index)
|
||||
{
|
||||
|
||||
int i = 0, j = 0;
|
||||
|
||||
for (i = 0; i < VIC_MODE_COUNT; i++) {
|
||||
if (vic_table[i][24] == vmode_index)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == VIC_MODE_COUNT) {
|
||||
dev_err(dev, "vmode is wrong!\n");
|
||||
j = 7;
|
||||
return j;
|
||||
}
|
||||
|
||||
for (j = 0; j < 7; j++) {
|
||||
if (vic_table[i][14] == TMDS_rate_table[j])
|
||||
break;
|
||||
}
|
||||
|
||||
return j;
|
||||
}
|
||||
|
||||
static int imx_cdnhdmi_startup(struct snd_pcm_substream *substream)
|
||||
{
|
||||
struct snd_pcm_runtime *runtime = substream->runtime;
|
||||
|
@ -116,16 +75,12 @@ static int imx_cdnhdmi_hw_params(struct snd_pcm_substream *substream,
|
|||
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
||||
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
||||
struct snd_soc_card *card = rtd->card;
|
||||
struct imx_cdnhdmi_data *data = snd_soc_card_get_drvdata(card);
|
||||
struct device *dev = card->dev;
|
||||
unsigned int sample_rate = params_rate(params);
|
||||
unsigned int channels = params_channels(params);
|
||||
unsigned int width = params_physical_width(params);
|
||||
AUDIO_FREQ freq;
|
||||
AUDIO_WIDTH bits;
|
||||
struct imx_cdnhdmi_data *data = snd_soc_card_get_drvdata(card);
|
||||
int ret;
|
||||
int ncts_n;
|
||||
int idx_n = select_N_index(dev, data->vmode_index);
|
||||
|
||||
/* set cpu DAI configuration */
|
||||
ret = snd_soc_dai_set_fmt(cpu_dai,
|
||||
|
@ -149,63 +104,11 @@ static int imx_cdnhdmi_hw_params(struct snd_pcm_substream *substream,
|
|||
return ret;
|
||||
}
|
||||
|
||||
switch (sample_rate) {
|
||||
case 32000:
|
||||
freq = AUDIO_FREQ_32;
|
||||
ncts_n = N_table_32k[idx_n];
|
||||
break;
|
||||
case 44100:
|
||||
freq = AUDIO_FREQ_44_1;
|
||||
ncts_n = N_table_44k[idx_n];
|
||||
break;
|
||||
case 48000:
|
||||
freq = AUDIO_FREQ_48;
|
||||
ncts_n = N_table_48k[idx_n];
|
||||
break;
|
||||
case 88200:
|
||||
freq = AUDIO_FREQ_88_2;
|
||||
ncts_n = N_table_44k[idx_n] * 2;
|
||||
break;
|
||||
case 96000:
|
||||
freq = AUDIO_FREQ_96;
|
||||
ncts_n = N_table_48k[idx_n] * 2;
|
||||
break;
|
||||
case 176400:
|
||||
freq = AUDIO_FREQ_176_4;
|
||||
ncts_n = N_table_44k[idx_n] * 4;
|
||||
break;
|
||||
case 192000:
|
||||
freq = AUDIO_FREQ_192;
|
||||
ncts_n = N_table_48k[idx_n] * 4;
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
if (data->protocol == 1)
|
||||
imx_hdp_audio(AUDIO_TYPE_I2S, sample_rate, channels, width);
|
||||
else
|
||||
imx_hdmi_audio(AUDIO_TYPE_I2S, sample_rate, channels, width);
|
||||
|
||||
switch (width) {
|
||||
case 16:
|
||||
bits = AUDIO_WIDTH_16;
|
||||
break;
|
||||
case 24:
|
||||
bits = AUDIO_WIDTH_24;
|
||||
break;
|
||||
case 32:
|
||||
bits = AUDIO_WIDTH_32;
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
||||
CDN_API_AudioOff_blocking(AUDIO_TYPE_I2S);
|
||||
CDN_API_AudioAutoConfig_blocking(AUDIO_TYPE_I2S,
|
||||
channels,
|
||||
freq,
|
||||
0,
|
||||
bits,
|
||||
CDN_HDMITX_KIRAN,
|
||||
ncts_n,
|
||||
AUDIO_MUTE_MODE_UNMUTE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -241,12 +144,8 @@ static int imx_cdnhdmi_probe(struct platform_device *pdev)
|
|||
goto fail;
|
||||
}
|
||||
|
||||
ret = of_property_read_u32(pdev->dev.of_node, "video-mode",
|
||||
&data->vmode_index);
|
||||
if (ret < 0) {
|
||||
ret = -EINVAL;
|
||||
goto fail;
|
||||
}
|
||||
of_property_read_u32(pdev->dev.of_node, "protocol",
|
||||
&data->protocol);
|
||||
|
||||
data->dai.name = "imx8 hdmi";
|
||||
data->dai.stream_name = "imx8 hdmi";
|
||||
|
@ -257,7 +156,7 @@ static int imx_cdnhdmi_probe(struct platform_device *pdev)
|
|||
data->dai.ops = &imx_cdnhdmi_ops;
|
||||
data->dai.playback_only = true;
|
||||
data->dai.capture_only = false;
|
||||
data->dai.dai_fmt = SND_SOC_DAIFMT_LEFT_J |
|
||||
data->dai.dai_fmt = SND_SOC_DAIFMT_I2S |
|
||||
SND_SOC_DAIFMT_NB_NF |
|
||||
SND_SOC_DAIFMT_CBS_CFS;
|
||||
|
||||
|
|
Loading…
Reference in New Issue