Skip to content

Commit

Permalink
ASoC: dwc: Defer bclk_ratio handling to hw_params
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
pelwell committed Jan 4, 2024
1 parent 715c3c6 commit bd0197e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
38 changes: 21 additions & 17 deletions sound/soc/dwc/dwc-i2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,25 @@ static int dw_i2s_hw_params(struct snd_pcm_substream *substream,
if (dev->tdm_slots)
config->data_width = 32;

if ((dev->capability & DW_I2S_MASTER) && dev->bclk_ratio) {
switch (dev->bclk_ratio) {
case 32:
dev->ccr = 0x00;
break;

case 48:
dev->ccr = 0x08;
break;

case 64:
dev->ccr = 0x10;
break;

default:
return -EINVAL;
}
}

config->chan_nr = params_channels(params);

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

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

switch (ratio) {
case 32:
dev->ccr = 0x00;
break;

case 48:
dev->ccr = 0x08;
break;

case 64:
dev->ccr = 0x10;
break;
default:
return -EINVAL;
}

i2s_write_reg(dev->i2s_base, CCR, dev->ccr);
dev->bclk_ratio = ratio;

return 0;
}
Expand Down Expand Up @@ -1076,6 +1079,7 @@ static int dw_i2s_probe(struct platform_device *pdev)
}
}

dev->bclk_ratio = 0;
dev->i2s_reg_comp1 = I2S_COMP_PARAM_1;
dev->i2s_reg_comp2 = I2S_COMP_PARAM_2;
if (pdata) {
Expand Down
1 change: 1 addition & 0 deletions sound/soc/dwc/local.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ struct dw_i2s_dev {
unsigned int quirks;
unsigned int i2s_reg_comp1;
unsigned int i2s_reg_comp2;
unsigned int bclk_ratio;
struct device *dev;
u32 ccr;
u32 xfer_resolution;
Expand Down

0 comments on commit bd0197e

Please sign in to comment.