summaryrefslogtreecommitdiff
path: root/sound/soc/fsl/imx-cdnhdmi.c
diff options
context:
space:
mode:
authorShengjiu Wang <shengjiu.wang@nxp.com>2017-10-12 14:01:49 +0800
committerDong Aisheng <aisheng.dong@nxp.com>2019-11-25 15:52:32 +0800
commitd16ae6be3502790e4f4fd53a4a964b0a85571b53 (patch)
tree0c9a5f48942be89feb3bfdeeac220e30c84130e0 /sound/soc/fsl/imx-cdnhdmi.c
parente2c81bccd117896efdafc4b0339562d72965f29e (diff)
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>
Diffstat (limited to 'sound/soc/fsl/imx-cdnhdmi.c')
-rw-r--r--sound/soc/fsl/imx-cdnhdmi.c123
1 files changed, 11 insertions, 112 deletions
diff --git a/sound/soc/fsl/imx-cdnhdmi.c b/sound/soc/fsl/imx-cdnhdmi.c
index dfa638b4becb..7cb8ad4d504a 100644
--- a/sound/soc/fsl/imx-cdnhdmi.c
+++ b/sound/soc/fsl/imx-cdnhdmi.c
@@ -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;
- }
-
- 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;
- }
-
+ 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);
- 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;