0015-bcm2835-i2s-add-24bit-support-update-bclk_ratio-to-m.patch 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. From 962015d18b8f8dcce75ec843b5a5224c813c3362 Mon Sep 17 00:00:00 2001
  2. From: Matthias Reichl <hias@horus.com>
  3. Date: Sun, 11 Oct 2015 15:21:16 +0200
  4. Subject: [PATCH] bcm2835-i2s: add 24bit support, update bclk_ratio to more
  5. correct values
  6. Code ported from bcm2708-i2s driver in Raspberry Pi tree.
  7. RPi commit 62c05a0b5328d9376d39c9e74da10b8a2465c234 ("ASoC: BCM2708:
  8. Add 24 bit support")
  9. This adds 24 bit support to the I2S driver of the BCM2708.
  10. Besides enabling the 24 bit flags, it includes two bug fixes:
  11. MMAP is not supported. Claiming this leads to strange issues
  12. when the format of driver and file do not match.
  13. The datasheet states that the width extension bit should be set
  14. for widths greater than 24, but greater or equal would be correct.
  15. This follows from the definition of the width field.
  16. Signed-off-by: Florian Meier <florian.meier@koalo.de>
  17. RPi commit 3e8c672bc4e92d457aa4654bbb4cfd79a18a2327 ("bcm2708-i2s:
  18. Update bclk_ratio to more correct values")
  19. Discussion about blck_ratio affecting sound quality:
  20. https://github.com/raspberrypi/linux/issues/681
  21. Signed-off-by: Matthias Reichl <hias@horus.com>
  22. ---
  23. sound/soc/bcm/bcm2835-i2s.c | 12 +++++++++---
  24. 1 file changed, 9 insertions(+), 3 deletions(-)
  25. --- a/sound/soc/bcm/bcm2835-i2s.c
  26. +++ b/sound/soc/bcm/bcm2835-i2s.c
  27. @@ -340,11 +340,15 @@ static int bcm2835_i2s_hw_params(struct
  28. switch (params_format(params)) {
  29. case SNDRV_PCM_FORMAT_S16_LE:
  30. data_length = 16;
  31. - bclk_ratio = 40;
  32. + bclk_ratio = 50;
  33. + break;
  34. + case SNDRV_PCM_FORMAT_S24_LE:
  35. + data_length = 24;
  36. + bclk_ratio = 50;
  37. break;
  38. case SNDRV_PCM_FORMAT_S32_LE:
  39. data_length = 32;
  40. - bclk_ratio = 80;
  41. + bclk_ratio = 100;
  42. break;
  43. default:
  44. return -EINVAL;
  45. @@ -420,7 +424,7 @@ static int bcm2835_i2s_hw_params(struct
  46. /* Setup the frame format */
  47. format = BCM2835_I2S_CHEN;
  48. - if (data_length > 24)
  49. + if (data_length >= 24)
  50. format |= BCM2835_I2S_CHWEX;
  51. format |= BCM2835_I2S_CHWID((data_length-8)&0xf);
  52. @@ -711,6 +715,7 @@ static struct snd_soc_dai_driver bcm2835
  53. .channels_max = 2,
  54. .rates = SNDRV_PCM_RATE_8000_192000,
  55. .formats = SNDRV_PCM_FMTBIT_S16_LE
  56. + | SNDRV_PCM_FMTBIT_S24_LE
  57. | SNDRV_PCM_FMTBIT_S32_LE
  58. },
  59. .capture = {
  60. @@ -718,6 +723,7 @@ static struct snd_soc_dai_driver bcm2835
  61. .channels_max = 2,
  62. .rates = SNDRV_PCM_RATE_8000_192000,
  63. .formats = SNDRV_PCM_FMTBIT_S16_LE
  64. + | SNDRV_PCM_FMTBIT_S24_LE
  65. | SNDRV_PCM_FMTBIT_S32_LE
  66. },
  67. .ops = &bcm2835_i2s_dai_ops,