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
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.
11 sound/soc/bcm/hifiberry_digi.c | 29 ++++++++++++++++++++++++++++-
12 1 file changed, 28 insertions(+), 1 deletion(-)
14 --- a/sound/soc/bcm/hifiberry_digi.c
15 +++ b/sound/soc/bcm/hifiberry_digi.c
18 #include "../codecs/wm8804.h"
20 +static short int auto_shutdown_output = 0;
21 +module_param(auto_shutdown_output, short, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
22 +MODULE_PARM_DESC(auto_shutdown_output, "Shutdown SP/DIF output if playback is stopped");
25 static int samplerate=44100;
27 static int snd_rpi_hifiberry_digi_init(struct snd_soc_pcm_runtime *rtd)
28 @@ -38,6 +43,25 @@ static int snd_rpi_hifiberry_digi_init(s
32 +static int snd_rpi_hifiberry_digi_startup(struct snd_pcm_substream *substream) {
33 + /* turn on digital output */
34 + struct snd_soc_pcm_runtime *rtd = substream->private_data;
35 + struct snd_soc_codec *codec = rtd->codec;
36 + snd_soc_update_bits(codec, WM8804_PWRDN, 0x3c, 0x00);
40 +static void snd_rpi_hifiberry_digi_shutdown(struct snd_pcm_substream *substream) {
41 + /* turn off output */
42 + if (auto_shutdown_output) {
43 + /* turn off output */
44 + struct snd_soc_pcm_runtime *rtd = substream->private_data;
45 + struct snd_soc_codec *codec = rtd->codec;
46 + snd_soc_update_bits(codec, WM8804_PWRDN, 0x3c, 0x3c);
51 static int snd_rpi_hifiberry_digi_hw_params(struct snd_pcm_substream *substream,
52 struct snd_pcm_hw_params *params)
54 @@ -70,7 +94,8 @@ static int snd_rpi_hifiberry_digi_hw_par
57 dev_err(substream->pcm->dev,
58 - "Failed to set WM8804 SYSCLK, unsupported samplerate\n");
59 + "Failed to set WM8804 SYSCLK, unsupported samplerate %d\n",
63 snd_soc_dai_set_clkdiv(codec_dai, WM8804_MCLK_DIV, mclk_div);
64 @@ -96,6 +121,8 @@ static int snd_rpi_hifiberry_digi_hw_par
65 /* machine stream operations */
66 static struct snd_soc_ops snd_rpi_hifiberry_digi_ops = {
67 .hw_params = snd_rpi_hifiberry_digi_hw_params,
68 + .startup = snd_rpi_hifiberry_digi_startup,
69 + .shutdown = snd_rpi_hifiberry_digi_shutdown,
72 static struct snd_soc_dai_link snd_rpi_hifiberry_digi_dai[] = {