Skip to content

Commit 20bae1b

Browse files
author
Fox Snowpatch
committedOct 9, 2024·
1 parent f85c105 commit 20bae1b

File tree

1 file changed

+52
-7
lines changed

1 file changed

+52
-7
lines changed
 

‎sound/soc/fsl/imx-card.c

+52-7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ enum codec_type {
2525
CODEC_AK4458,
2626
CODEC_AK4497,
2727
CODEC_AK5552,
28+
CODEC_CS42888,
2829
};
2930

3031
/*
@@ -185,6 +186,16 @@ static struct imx_akcodec_tdm_fs_mul ak5558_tdm_fs_mul[] = {
185186
{ .min = 512, .max = 512, .mul = 1024 },
186187
};
187188

189+
static struct imx_akcodec_fs_mul cs42888_fs_mul[] = {
190+
{ .rmin = 8000, .rmax = 48000, .wmin = 256, .wmax = 1024, },
191+
{ .rmin = 64000, .rmax = 96000, .wmin = 128, .wmax = 512, },
192+
{ .rmin = 176400, .rmax = 192000, .wmin = 64, .wmax = 256, },
193+
};
194+
195+
static struct imx_akcodec_tdm_fs_mul cs42888_tdm_fs_mul[] = {
196+
{ .min = 256, .max = 256, .mul = 256 },
197+
};
198+
188199
static const u32 akcodec_rates[] = {
189200
8000, 11025, 16000, 22050, 32000, 44100, 48000, 88200,
190201
96000, 176400, 192000, 352800, 384000, 705600, 768000,
@@ -210,6 +221,14 @@ static const u32 ak5558_tdm_channels[] = {
210221
1, 2, 3, 4, 5, 6, 7, 8,
211222
};
212223

224+
static const u32 cs42888_channels[] = {
225+
1, 2, 4, 6, 8,
226+
};
227+
228+
static const u32 cs42888_tdm_channels[] = {
229+
1, 2, 3, 4, 5, 6, 7, 8,
230+
};
231+
213232
static bool format_is_dsd(struct snd_pcm_hw_params *params)
214233
{
215234
snd_pcm_format_t format = params_format(params);
@@ -241,6 +260,7 @@ static bool codec_is_akcodec(unsigned int type)
241260
case CODEC_AK4497:
242261
case CODEC_AK5558:
243262
case CODEC_AK5552:
263+
case CODEC_CS42888:
244264
return true;
245265
default:
246266
break;
@@ -340,13 +360,15 @@ static int imx_aif_hw_params(struct snd_pcm_substream *substream,
340360
return ret;
341361
}
342362

343-
ret = snd_soc_dai_set_tdm_slot(codec_dai,
344-
BIT(slots) - 1,
345-
BIT(slots) - 1,
346-
slots, slot_width);
347-
if (ret && ret != -ENOTSUPP) {
348-
dev_err(dev, "failed to set codec dai[%d] tdm slot: %d\n", i, ret);
349-
return ret;
363+
if (format_is_tdm(link_data)) {
364+
ret = snd_soc_dai_set_tdm_slot(codec_dai,
365+
BIT(slots) - 1,
366+
BIT(slots) - 1,
367+
slots, slot_width);
368+
if (ret && ret != -ENOTSUPP) {
369+
dev_err(dev, "failed to set codec dai[%d] tdm slot: %d\n", i, ret);
370+
return ret;
371+
}
350372
}
351373
}
352374

@@ -370,6 +392,11 @@ static int imx_aif_hw_params(struct snd_pcm_substream *substream,
370392
dev_err(dev, "failed to set cpui dai mclk1 rate (%lu): %d\n", mclk_freq, ret);
371393
return ret;
372394
}
395+
ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk_freq, SND_SOC_CLOCK_IN);
396+
if (ret && ret != -ENOTSUPP) {
397+
dev_err(dev, "failed to set codec dai mclk rate (%lu): %d\n", mclk_freq, ret);
398+
return ret;
399+
}
373400

374401
return 0;
375402
}
@@ -604,6 +631,8 @@ static int imx_card_parse_of(struct imx_card_data *data)
604631
plat_data->type = CODEC_AK5558;
605632
else if (!strcmp(link->codecs->dai_name, "ak5552-aif"))
606633
plat_data->type = CODEC_AK5552;
634+
else if (!strcmp(link->codecs->dai_name, "cs42888"))
635+
plat_data->type = CODEC_CS42888;
607636

608637
} else {
609638
link->codecs = &snd_soc_dummy_dlc;
@@ -761,6 +790,12 @@ static int imx_card_probe(struct platform_device *pdev)
761790
data->dapm_routes[i].sink = "ASRC-Capture";
762791
data->dapm_routes[i].source = "CPU-Capture";
763792
break;
793+
case CODEC_CS42888:
794+
data->dapm_routes[0].sink = "Playback";
795+
data->dapm_routes[0].source = "CPU-Playback";
796+
data->dapm_routes[1].sink = "CPU-Capture";
797+
data->dapm_routes[1].source = "Capture";
798+
break;
764799
default:
765800
break;
766801
}
@@ -800,6 +835,16 @@ static int imx_card_probe(struct platform_device *pdev)
800835
plat_data->support_tdm_channels = ak5558_tdm_channels;
801836
plat_data->num_tdm_channels = ARRAY_SIZE(ak5558_tdm_channels);
802837
break;
838+
case CODEC_CS42888:
839+
plat_data->fs_mul = cs42888_fs_mul;
840+
plat_data->num_fs_mul = ARRAY_SIZE(cs42888_fs_mul);
841+
plat_data->tdm_fs_mul = cs42888_tdm_fs_mul;
842+
plat_data->num_tdm_fs_mul = ARRAY_SIZE(cs42888_tdm_fs_mul);
843+
plat_data->support_channels = cs42888_channels;
844+
plat_data->num_channels = ARRAY_SIZE(cs42888_channels);
845+
plat_data->support_tdm_channels = cs42888_tdm_channels;
846+
plat_data->num_tdm_channels = ARRAY_SIZE(cs42888_tdm_channels);
847+
break;
803848
default:
804849
break;
805850
}

0 commit comments

Comments
 (0)
Please sign in to comment.