0140-Allow-up-to-24dB-digital-gain-to-be-applied-when-usi.patch 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. From 3bb2e01fd397f375e54f6fe8a33af25aef1c981f Mon Sep 17 00:00:00 2001
  2. From: Digital Dreamtime <clive.messer@digitaldreamtime.co.uk>
  3. Date: Thu, 4 Feb 2016 14:14:44 +0000
  4. Subject: [PATCH 140/381] Allow up to 24dB digital gain to be applied when
  5. using IQAudIO DAC+
  6. 24db_digital_gain DT param can be used to specify that PCM512x
  7. codec "Digital" volume control should not be limited to 0dB gain,
  8. and if specified will allow the full 24dB gain.
  9. ---
  10. arch/arm/boot/dts/overlays/README | 17 +++++++++++++++--
  11. .../boot/dts/overlays/iqaudio-dacplus-overlay.dts | 6 +++++-
  12. sound/soc/bcm/iqaudio-dac.c | 20 ++++++++++++++------
  13. 3 files changed, 34 insertions(+), 9 deletions(-)
  14. --- a/arch/arm/boot/dts/overlays/README
  15. +++ b/arch/arm/boot/dts/overlays/README
  16. @@ -362,8 +362,21 @@ Params: <None>
  17. Name: iqaudio-dacplus
  18. Info: Configures the IQaudio DAC+ audio card
  19. -Load: dtoverlay=iqaudio-dacplus
  20. -Params: <None>
  21. +Load: dtoverlay=iqaudio-dacplus,<param>=<val>
  22. +Params: 24db_digital_gain Allow gain to be applied via the PCM512x codec
  23. + Digital volume control. Enable with
  24. + "dtoverlay=iqaudio-dacplus,24db_digital_gain"
  25. + (The default behaviour is that the Digital
  26. + volume control is limited to a maximum of
  27. + 0dB. ie. it can attenuate but not provide
  28. + gain. For most users, this will be desired
  29. + as it will prevent clipping. By appending
  30. + the 24db_digital_gain parameter, the Digital
  31. + volume control will allow up to 24dB of
  32. + gain. If this parameter is enabled, it is the
  33. + responsibility of the user to ensure that
  34. + the Digital volume control is set to a value
  35. + that does not result in clipping/distortion!)
  36. Name: lirc-rpi
  37. --- a/arch/arm/boot/dts/overlays/iqaudio-dacplus-overlay.dts
  38. +++ b/arch/arm/boot/dts/overlays/iqaudio-dacplus-overlay.dts
  39. @@ -7,7 +7,7 @@
  40. fragment@0 {
  41. target = <&sound>;
  42. - __overlay__ {
  43. + frag0: __overlay__ {
  44. compatible = "iqaudio,iqaudio-dac";
  45. i2s-controller = <&i2s>;
  46. status = "okay";
  47. @@ -36,4 +36,8 @@
  48. };
  49. };
  50. };
  51. +
  52. + __overrides__ {
  53. + 24db_digital_gain = <&frag0>,"iqaudio,24db_digital_gain?";
  54. + };
  55. };
  56. --- a/sound/soc/bcm/iqaudio-dac.c
  57. +++ b/sound/soc/bcm/iqaudio-dac.c
  58. @@ -23,14 +23,19 @@
  59. #include <sound/soc.h>
  60. #include <sound/jack.h>
  61. +static bool digital_gain_0db_limit = true;
  62. +
  63. static int snd_rpi_iqaudio_dac_init(struct snd_soc_pcm_runtime *rtd)
  64. {
  65. - int ret;
  66. - struct snd_soc_card *card = rtd->card;
  67. -
  68. - ret = snd_soc_limit_volume(card, "Digital Playback Volume", 207);
  69. - if (ret < 0)
  70. - dev_warn(card->dev, "Failed to set volume limit: %d\n", ret);
  71. + if (digital_gain_0db_limit)
  72. + {
  73. + int ret;
  74. + struct snd_soc_card *card = rtd->card;
  75. +
  76. + ret = snd_soc_limit_volume(card, "Digital Playback Volume", 207);
  77. + if (ret < 0)
  78. + dev_warn(card->dev, "Failed to set volume limit: %d\n", ret);
  79. + }
  80. return 0;
  81. }
  82. @@ -94,6 +99,9 @@ static int snd_rpi_iqaudio_dac_probe(str
  83. dai->platform_name = NULL;
  84. dai->platform_of_node = i2s_node;
  85. }
  86. +
  87. + digital_gain_0db_limit = !of_property_read_bool(pdev->dev.of_node,
  88. + "iqaudio,24db_digital_gain");
  89. }
  90. ret = snd_soc_register_card(&snd_rpi_iqaudio_dac);