Skip to content

Commit f6fdf77

Browse files
committed
ASoC: imx-card: several improvement and fixes
Merge series from Shengjiu Wang <[email protected]>: Several improvement and fixes for AK codecs supported on i.MX platfroms
2 parents 3b247ee + 3969341 commit f6fdf77

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

sound/soc/fsl/imx-card.c

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ struct imx_card_data {
120120

121121
static struct imx_akcodec_fs_mul ak4458_fs_mul[] = {
122122
/* Normal, < 32kHz */
123-
{ .rmin = 8000, .rmax = 24000, .wmin = 1024, .wmax = 1024, },
123+
{ .rmin = 8000, .rmax = 24000, .wmin = 256, .wmax = 1024, },
124124
/* Normal, 32kHz */
125125
{ .rmin = 32000, .rmax = 32000, .wmin = 256, .wmax = 1024, },
126126
/* Normal */
@@ -151,8 +151,8 @@ static struct imx_akcodec_fs_mul ak4497_fs_mul[] = {
151151
* Table 7 - mapping multiplier and speed mode
152152
* Tables 8 & 9 - mapping speed mode and LRCK fs
153153
*/
154-
{ .rmin = 8000, .rmax = 32000, .wmin = 1024, .wmax = 1024, }, /* Normal, <= 32kHz */
155-
{ .rmin = 44100, .rmax = 48000, .wmin = 512, .wmax = 512, }, /* Normal */
154+
{ .rmin = 8000, .rmax = 32000, .wmin = 256, .wmax = 1024, }, /* Normal, <= 32kHz */
155+
{ .rmin = 44100, .rmax = 48000, .wmin = 256, .wmax = 512, }, /* Normal */
156156
{ .rmin = 88200, .rmax = 96000, .wmin = 256, .wmax = 256, }, /* Double */
157157
{ .rmin = 176400, .rmax = 192000, .wmin = 128, .wmax = 128, }, /* Quad */
158158
{ .rmin = 352800, .rmax = 384000, .wmin = 128, .wmax = 128, }, /* Oct */
@@ -164,7 +164,7 @@ static struct imx_akcodec_fs_mul ak4497_fs_mul[] = {
164164
* (Table 4 from datasheet)
165165
*/
166166
static struct imx_akcodec_fs_mul ak5558_fs_mul[] = {
167-
{ .rmin = 8000, .rmax = 32000, .wmin = 1024, .wmax = 1024, },
167+
{ .rmin = 8000, .rmax = 32000, .wmin = 512, .wmax = 1024, },
168168
{ .rmin = 44100, .rmax = 48000, .wmin = 512, .wmax = 512, },
169169
{ .rmin = 88200, .rmax = 96000, .wmin = 256, .wmax = 256, },
170170
{ .rmin = 176400, .rmax = 192000, .wmin = 128, .wmax = 128, },
@@ -247,13 +247,14 @@ static bool codec_is_akcodec(unsigned int type)
247247
}
248248

249249
static unsigned long akcodec_get_mclk_rate(struct snd_pcm_substream *substream,
250-
struct snd_pcm_hw_params *params)
250+
struct snd_pcm_hw_params *params,
251+
int slots, int slot_width)
251252
{
252253
struct snd_soc_pcm_runtime *rtd = substream->private_data;
253254
struct imx_card_data *data = snd_soc_card_get_drvdata(rtd->card);
254255
const struct imx_card_plat_data *plat_data = data->plat_data;
255256
struct dai_link_data *link_data = &data->link_data[rtd->num];
256-
unsigned int width = link_data->slots * link_data->slot_width;
257+
unsigned int width = slots * slot_width;
257258
unsigned int rate = params_rate(params);
258259
int i;
259260

@@ -349,7 +350,7 @@ static int imx_aif_hw_params(struct snd_pcm_substream *substream,
349350

350351
/* Set MCLK freq */
351352
if (codec_is_akcodec(plat_data->type))
352-
mclk_freq = akcodec_get_mclk_rate(substream, params);
353+
mclk_freq = akcodec_get_mclk_rate(substream, params, slots, slot_width);
353354
else
354355
mclk_freq = params_rate(params) * slots * slot_width;
355356
/* Use the maximum freq from DSD512 (512*44100 = 22579200) */
@@ -553,8 +554,23 @@ static int imx_card_parse_of(struct imx_card_data *data)
553554
link_data->cpu_sysclk_id = FSL_SAI_CLK_MAST1;
554555

555556
/* sai may support mclk/bclk = 1 */
556-
if (of_find_property(np, "fsl,mclk-equal-bclk", NULL))
557+
if (of_find_property(np, "fsl,mclk-equal-bclk", NULL)) {
557558
link_data->one2one_ratio = true;
559+
} else {
560+
int i;
561+
562+
/*
563+
* i.MX8MQ don't support one2one ratio, then
564+
* with ak4497 only 16bit case is supported.
565+
*/
566+
for (i = 0; i < ARRAY_SIZE(ak4497_fs_mul); i++) {
567+
if (ak4497_fs_mul[i].rmin == 705600 &&
568+
ak4497_fs_mul[i].rmax == 768000) {
569+
ak4497_fs_mul[i].wmin = 32;
570+
ak4497_fs_mul[i].wmax = 32;
571+
}
572+
}
573+
}
558574
}
559575

560576
link->cpus->of_node = args.np;

0 commit comments

Comments
 (0)