brcm2708: update to v3.18
[openwrt/staging/wigyori.git] / target / linux / brcm2708 / patches-3.18 / 0084-Add-a-parameter-to-turn-off-SPDIF-output-if-no-audio.patch
1 From a09a8ebce7251e2a42668bd5ae57c12ed24fdca8 Mon Sep 17 00:00:00 2001
2 From: Daniel Matuschek <daniel@hifiberry.com>
3 Date: Sat, 31 Jan 2015 16:07:56 +0100
4 Subject: [PATCH 084/114] Add a parameter to turn off SPDIF output if no audio
5 is playing
6
7 This patch adds the paramater auto_shutdown_output to the kernel module.
8 Default behaviour of the module is the same, but when auto_shutdown_output
9 is set to 1, the SPDIF oputput will shutdown if no stream is playing.
10 ---
11 sound/soc/bcm/hifiberry_digi.c | 29 ++++++++++++++++++++++++++++-
12 1 file changed, 28 insertions(+), 1 deletion(-)
13
14 diff --git a/sound/soc/bcm/hifiberry_digi.c b/sound/soc/bcm/hifiberry_digi.c
15 index 76af8a6..b0e3d28 100644
16 --- a/sound/soc/bcm/hifiberry_digi.c
17 +++ b/sound/soc/bcm/hifiberry_digi.c
18 @@ -26,6 +26,11 @@
19
20 #include "../codecs/wm8804.h"
21
22 +static short int auto_shutdown_output = 0;
23 +module_param(auto_shutdown_output, short, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
24 +MODULE_PARM_DESC(auto_shutdown_output, "Shutdown SP/DIF output if playback is stopped");
25 +
26 +
27 static int samplerate=44100;
28
29 static int snd_rpi_hifiberry_digi_init(struct snd_soc_pcm_runtime *rtd)
30 @@ -38,6 +43,25 @@ static int snd_rpi_hifiberry_digi_init(struct snd_soc_pcm_runtime *rtd)
31 return 0;
32 }
33
34 +static int snd_rpi_hifiberry_digi_startup(struct snd_pcm_substream *substream) {
35 + /* turn on digital output */
36 + struct snd_soc_pcm_runtime *rtd = substream->private_data;
37 + struct snd_soc_codec *codec = rtd->codec;
38 + snd_soc_update_bits(codec, WM8804_PWRDN, 0x3c, 0x00);
39 + return 0;
40 +}
41 +
42 +static void snd_rpi_hifiberry_digi_shutdown(struct snd_pcm_substream *substream) {
43 + /* turn off output */
44 + if (auto_shutdown_output) {
45 + /* turn off output */
46 + struct snd_soc_pcm_runtime *rtd = substream->private_data;
47 + struct snd_soc_codec *codec = rtd->codec;
48 + snd_soc_update_bits(codec, WM8804_PWRDN, 0x3c, 0x3c);
49 + }
50 +}
51 +
52 +
53 static int snd_rpi_hifiberry_digi_hw_params(struct snd_pcm_substream *substream,
54 struct snd_pcm_hw_params *params)
55 {
56 @@ -70,7 +94,8 @@ static int snd_rpi_hifiberry_digi_hw_params(struct snd_pcm_substream *substream,
57 break;
58 default:
59 dev_err(substream->pcm->dev,
60 - "Failed to set WM8804 SYSCLK, unsupported samplerate\n");
61 + "Failed to set WM8804 SYSCLK, unsupported samplerate %d\n",
62 + samplerate);
63 }
64
65 snd_soc_dai_set_clkdiv(codec_dai, WM8804_MCLK_DIV, mclk_div);
66 @@ -96,6 +121,8 @@ static int snd_rpi_hifiberry_digi_hw_params(struct snd_pcm_substream *substream,
67 /* machine stream operations */
68 static struct snd_soc_ops snd_rpi_hifiberry_digi_ops = {
69 .hw_params = snd_rpi_hifiberry_digi_hw_params,
70 + .startup = snd_rpi_hifiberry_digi_startup,
71 + .shutdown = snd_rpi_hifiberry_digi_shutdown,
72 };
73
74 static struct snd_soc_dai_link snd_rpi_hifiberry_digi_dai[] = {
75 --
76 1.8.3.2
77