Skip to content

Commit 2260bc6

Browse files
Chancel Liubroonie
authored andcommitted
ASoC: imx-card: Add WM8524 support
WM8524 is a stereo DAC. Add support for this codec in imx-card ASoC machine driver. Signed-off-by: Chancel Liu <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent c58c35e commit 2260bc6

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

sound/soc/fsl/imx-card.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ enum codec_type {
2626
CODEC_AK4497,
2727
CODEC_AK5552,
2828
CODEC_CS42888,
29+
CODEC_WM8524,
2930
};
3031

3132
/*
@@ -196,6 +197,13 @@ static struct imx_akcodec_tdm_fs_mul cs42888_tdm_fs_mul[] = {
196197
{ .min = 256, .max = 256, .mul = 256 },
197198
};
198199

200+
static struct imx_akcodec_fs_mul wm8524_fs_mul[] = {
201+
{ .rmin = 8000, .rmax = 32000, .wmin = 256, .wmax = 1152, },
202+
{ .rmin = 44100, .rmax = 48000, .wmin = 256, .wmax = 768, },
203+
{ .rmin = 88200, .rmax = 96000, .wmin = 128, .wmax = 384, },
204+
{ .rmin = 176400, .rmax = 192000, .wmin = 128, .wmax = 192, },
205+
};
206+
199207
static const u32 akcodec_rates[] = {
200208
8000, 11025, 16000, 22050, 32000, 44100, 48000, 88200,
201209
96000, 176400, 192000, 352800, 384000, 705600, 768000,
@@ -229,6 +237,10 @@ static const u32 cs42888_tdm_channels[] = {
229237
1, 2, 3, 4, 5, 6, 7, 8,
230238
};
231239

240+
static const u32 wm8524_channels[] = {
241+
2,
242+
};
243+
232244
static bool format_is_dsd(struct snd_pcm_hw_params *params)
233245
{
234246
snd_pcm_format_t format = params_format(params);
@@ -261,6 +273,7 @@ static bool codec_is_akcodec(unsigned int type)
261273
case CODEC_AK5558:
262274
case CODEC_AK5552:
263275
case CODEC_CS42888:
276+
case CODEC_WM8524:
264277
return true;
265278
default:
266279
break;
@@ -477,9 +490,24 @@ static int imx_aif_startup(struct snd_pcm_substream *substream)
477490
return ret;
478491
}
479492

493+
static void imx_aif_shutdown(struct snd_pcm_substream *substream)
494+
{
495+
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
496+
struct snd_soc_dai *cpu_dai;
497+
struct snd_soc_dai *codec_dai;
498+
int i;
499+
500+
for_each_rtd_cpu_dais(rtd, i, cpu_dai)
501+
snd_soc_dai_set_sysclk(cpu_dai, 0, 0, SND_SOC_CLOCK_OUT);
502+
503+
for_each_rtd_codec_dais(rtd, i, codec_dai)
504+
snd_soc_dai_set_sysclk(codec_dai, 0, 0, SND_SOC_CLOCK_IN);
505+
}
506+
480507
static const struct snd_soc_ops imx_aif_ops = {
481508
.hw_params = imx_aif_hw_params,
482509
.startup = imx_aif_startup,
510+
.shutdown = imx_aif_shutdown,
483511
};
484512

485513
static const struct snd_soc_ops imx_aif_ops_be = {
@@ -632,6 +660,8 @@ static int imx_card_parse_of(struct imx_card_data *data)
632660
plat_data->type = CODEC_AK5552;
633661
else if (!strcmp(link->codecs->dai_name, "cs42888"))
634662
plat_data->type = CODEC_CS42888;
663+
else if (!strcmp(link->codecs->dai_name, "wm8524-hifi"))
664+
plat_data->type = CODEC_WM8524;
635665

636666
} else {
637667
link->codecs = &snd_soc_dummy_dlc;
@@ -805,6 +835,10 @@ static int imx_card_probe(struct platform_device *pdev)
805835
data->dapm_routes[1].sink = "CPU-Capture";
806836
data->dapm_routes[1].source = "Capture";
807837
break;
838+
case CODEC_WM8524:
839+
data->dapm_routes[0].sink = "Playback";
840+
data->dapm_routes[0].source = "CPU-Playback";
841+
break;
808842
default:
809843
break;
810844
}
@@ -854,6 +888,12 @@ static int imx_card_probe(struct platform_device *pdev)
854888
plat_data->support_tdm_channels = cs42888_tdm_channels;
855889
plat_data->num_tdm_channels = ARRAY_SIZE(cs42888_tdm_channels);
856890
break;
891+
case CODEC_WM8524:
892+
plat_data->fs_mul = wm8524_fs_mul;
893+
plat_data->num_fs_mul = ARRAY_SIZE(wm8524_fs_mul);
894+
plat_data->support_channels = wm8524_channels;
895+
plat_data->num_channels = ARRAY_SIZE(wm8524_channels);
896+
break;
857897
default:
858898
break;
859899
}

0 commit comments

Comments
 (0)