950-0892-ASoC-dwc-Support-set_bclk_ratio.patch 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. From 06f794e8cb227249e03893e4b4923ff58556eb60 Mon Sep 17 00:00:00 2001
  2. From: Phil Elwell <[email protected]>
  3. Date: Thu, 4 Mar 2021 14:49:23 +0000
  4. Subject: [PATCH] ASoC: dwc: Support set_bclk_ratio
  5. Signed-off-by: Phil Elwell <[email protected]>
  6. ---
  7. sound/soc/dwc/dwc-i2s.c | 35 +++++++++++++++++++++++++++++++++++
  8. 1 file changed, 35 insertions(+)
  9. --- a/sound/soc/dwc/dwc-i2s.c
  10. +++ b/sound/soc/dwc/dwc-i2s.c
  11. @@ -351,11 +351,46 @@ static int dw_i2s_set_fmt(struct snd_soc
  12. return ret;
  13. }
  14. +static int dw_i2s_set_bclk_ratio(struct snd_soc_dai *cpu_dai,
  15. + unsigned int ratio)
  16. +{
  17. + struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(cpu_dai);
  18. + struct i2s_clk_config_data *config = &dev->config;
  19. +
  20. + dev_err(dev->dev, "%s(%d)\n", __func__, ratio);
  21. + switch (ratio) {
  22. + case 32:
  23. + config->data_width = 16;
  24. + dev->ccr = 0x00;
  25. + dev->xfer_resolution = 0x02;
  26. + break;
  27. +
  28. + case 48:
  29. + config->data_width = 24;
  30. + dev->ccr = 0x08;
  31. + dev->xfer_resolution = 0x04;
  32. + break;
  33. +
  34. + case 64:
  35. + config->data_width = 32;
  36. + dev->ccr = 0x10;
  37. + dev->xfer_resolution = 0x05;
  38. + break;
  39. + default:
  40. + return -EINVAL;
  41. + }
  42. +
  43. + i2s_write_reg(dev->i2s_base, CCR, dev->ccr);
  44. +
  45. + return 0;
  46. +}
  47. +
  48. static const struct snd_soc_dai_ops dw_i2s_dai_ops = {
  49. .hw_params = dw_i2s_hw_params,
  50. .prepare = dw_i2s_prepare,
  51. .trigger = dw_i2s_trigger,
  52. .set_fmt = dw_i2s_set_fmt,
  53. + .set_bclk_ratio = dw_i2s_set_bclk_ratio,
  54. };
  55. #ifdef CONFIG_PM