Skip to content

Commit dfc0490

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 59da6c1 commit dfc0490

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
@@ -263,6 +263,25 @@ static int dw_i2s_hw_params(struct snd_pcm_substream *substream,
263263
return -EINVAL;
264264
}
265265

266+
if ((dev->capability & DW_I2S_MASTER) && dev->bclk_ratio) {
267+
switch (dev->bclk_ratio) {
268+
case 32:
269+
dev->ccr = 0x00;
270+
break;
271+
272+
case 48:
273+
dev->ccr = 0x08;
274+
break;
275+
276+
case 64:
277+
dev->ccr = 0x10;
278+
break;
279+
280+
default:
281+
return -EINVAL;
282+
}
283+
}
284+
266285
config->chan_nr = params_channels(params);
267286

268287
switch (config->chan_nr) {
@@ -436,23 +455,7 @@ static int dw_i2s_set_bclk_ratio(struct snd_soc_dai *cpu_dai,
436455

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

439-
switch (ratio) {
440-
case 32:
441-
dev->ccr = 0x00;
442-
break;
443-
444-
case 48:
445-
dev->ccr = 0x08;
446-
break;
447-
448-
case 64:
449-
dev->ccr = 0x10;
450-
break;
451-
default:
452-
return -EINVAL;
453-
}
454-
455-
i2s_write_reg(dev->i2s_base, CCR, dev->ccr);
458+
dev->bclk_ratio = ratio;
456459

457460
return 0;
458461
}
@@ -746,6 +749,7 @@ static int dw_i2s_probe(struct platform_device *pdev)
746749
}
747750
}
748751

752+
dev->bclk_ratio = 0;
749753
dev->i2s_reg_comp1 = I2S_COMP_PARAM_1;
750754
dev->i2s_reg_comp2 = I2S_COMP_PARAM_2;
751755
if (pdata) {

sound/soc/dwc/local.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ struct dw_i2s_dev {
107107
unsigned int quirks;
108108
unsigned int i2s_reg_comp1;
109109
unsigned int i2s_reg_comp2;
110+
unsigned int bclk_ratio;
110111
struct device *dev;
111112
u32 ccr;
112113
u32 xfer_resolution;

0 commit comments

Comments
 (0)