Skip to content

Commit bd0197e

Browse files
committed
ASoC: dwc: Defer bclk_ratio handling to hw_params
bclk_ratio is only a factor in clock producer mode, and needs to override the default value of num_channels * sample_size. Move the bclk_ratio handling into the hw_params method, only latching the value in set_bclk_ratio, to address both of those matters. See: #5817 Signed-off-by: Phil Elwell <[email protected]>
1 parent 715c3c6 commit bd0197e

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

sound/soc/dwc/dwc-i2s.c

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,25 @@ static int dw_i2s_hw_params(struct snd_pcm_substream *substream,
381381
if (dev->tdm_slots)
382382
config->data_width = 32;
383383

384+
if ((dev->capability & DW_I2S_MASTER) && dev->bclk_ratio) {
385+
switch (dev->bclk_ratio) {
386+
case 32:
387+
dev->ccr = 0x00;
388+
break;
389+
390+
case 48:
391+
dev->ccr = 0x08;
392+
break;
393+
394+
case 64:
395+
dev->ccr = 0x10;
396+
break;
397+
398+
default:
399+
return -EINVAL;
400+
}
401+
}
402+
384403
config->chan_nr = params_channels(params);
385404

386405
switch (config->chan_nr) {
@@ -545,23 +564,7 @@ static int dw_i2s_set_bclk_ratio(struct snd_soc_dai *cpu_dai,
545564

546565
dev_dbg(dev->dev, "%s(%d)\n", __func__, ratio);
547566

548-
switch (ratio) {
549-
case 32:
550-
dev->ccr = 0x00;
551-
break;
552-
553-
case 48:
554-
dev->ccr = 0x08;
555-
break;
556-
557-
case 64:
558-
dev->ccr = 0x10;
559-
break;
560-
default:
561-
return -EINVAL;
562-
}
563-
564-
i2s_write_reg(dev->i2s_base, CCR, dev->ccr);
567+
dev->bclk_ratio = ratio;
565568

566569
return 0;
567570
}
@@ -1076,6 +1079,7 @@ static int dw_i2s_probe(struct platform_device *pdev)
10761079
}
10771080
}
10781081

1082+
dev->bclk_ratio = 0;
10791083
dev->i2s_reg_comp1 = I2S_COMP_PARAM_1;
10801084
dev->i2s_reg_comp2 = I2S_COMP_PARAM_2;
10811085
if (pdata) {

sound/soc/dwc/local.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ struct dw_i2s_dev {
128128
unsigned int quirks;
129129
unsigned int i2s_reg_comp1;
130130
unsigned int i2s_reg_comp2;
131+
unsigned int bclk_ratio;
131132
struct device *dev;
132133
u32 ccr;
133134
u32 xfer_resolution;

0 commit comments

Comments
 (0)