Skip to content

Commit 16ce618

Browse files
HiassofTkamalmostafa
authored andcommitted
bcm2835-i2s: add 24bit support, update bclk_ratio to more correct values
Code ported from bcm2708-i2s driver in Raspberry Pi tree. RPi commit 62c05a0b5328d9376d39c9e74da10b8a2465c234 ("ASoC: BCM2708: Add 24 bit support") This adds 24 bit support to the I2S driver of the BCM2708. Besides enabling the 24 bit flags, it includes two bug fixes: MMAP is not supported. Claiming this leads to strange issues when the format of driver and file do not match. The datasheet states that the width extension bit should be set for widths greater than 24, but greater or equal would be correct. This follows from the definition of the width field. Signed-off-by: Florian Meier <[email protected]> RPi commit 3e8c672bc4e92d457aa4654bbb4cfd79a18a2327 ("bcm2708-i2s: Update bclk_ratio to more correct values") Discussion about blck_ratio affecting sound quality: raspberrypi/linux#681 Signed-off-by: Matthias Reichl <[email protected]>
1 parent c42f13c commit 16ce618

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

sound/soc/bcm/bcm2835-i2s.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,11 +340,15 @@ static int bcm2835_i2s_hw_params(struct snd_pcm_substream *substream,
340340
switch (params_format(params)) {
341341
case SNDRV_PCM_FORMAT_S16_LE:
342342
data_length = 16;
343-
bclk_ratio = 40;
343+
bclk_ratio = 50;
344+
break;
345+
case SNDRV_PCM_FORMAT_S24_LE:
346+
data_length = 24;
347+
bclk_ratio = 50;
344348
break;
345349
case SNDRV_PCM_FORMAT_S32_LE:
346350
data_length = 32;
347-
bclk_ratio = 80;
351+
bclk_ratio = 100;
348352
break;
349353
default:
350354
return -EINVAL;
@@ -420,7 +424,7 @@ static int bcm2835_i2s_hw_params(struct snd_pcm_substream *substream,
420424
/* Setup the frame format */
421425
format = BCM2835_I2S_CHEN;
422426

423-
if (data_length > 24)
427+
if (data_length >= 24)
424428
format |= BCM2835_I2S_CHWEX;
425429

426430
format |= BCM2835_I2S_CHWID((data_length-8)&0xf);
@@ -711,13 +715,15 @@ static struct snd_soc_dai_driver bcm2835_i2s_dai = {
711715
.channels_max = 2,
712716
.rates = SNDRV_PCM_RATE_8000_192000,
713717
.formats = SNDRV_PCM_FMTBIT_S16_LE
718+
| SNDRV_PCM_FMTBIT_S24_LE
714719
| SNDRV_PCM_FMTBIT_S32_LE
715720
},
716721
.capture = {
717722
.channels_min = 2,
718723
.channels_max = 2,
719724
.rates = SNDRV_PCM_RATE_8000_192000,
720725
.formats = SNDRV_PCM_FMTBIT_S16_LE
726+
| SNDRV_PCM_FMTBIT_S24_LE
721727
| SNDRV_PCM_FMTBIT_S32_LE
722728
},
723729
.ops = &bcm2835_i2s_dai_ops,

0 commit comments

Comments
 (0)