Skip to content

Commit 5694e02

Browse files
allocompopcornmix
allocom
authored andcommitted
allo-digione: 192kHz clicking sound fix
See: #2149
1 parent cbf6bb5 commit 5694e02

File tree

1 file changed

+55
-58
lines changed

1 file changed

+55
-58
lines changed

sound/soc/bcm/allo-digione.c

Lines changed: 55 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
#include "../codecs/wm8804.h"
3030

31-
static short int auto_shutdown_output = 0;
31+
static short int auto_shutdown_output;
3232
module_param(auto_shutdown_output, short,
3333
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
3434
MODULE_PARM_DESC(auto_shutdown_output, "Shutdown SP/DIF output if playback is stopped");
@@ -75,6 +75,7 @@ static int snd_allo_digione_startup(struct snd_pcm_substream *substream)
7575
/* turn on digital output */
7676
struct snd_soc_pcm_runtime *rtd = substream->private_data;
7777
struct snd_soc_codec *codec = rtd->codec;
78+
7879
snd_soc_update_bits(codec, WM8804_PWRDN, 0x3c, 0x00);
7980
return 0;
8081
}
@@ -86,6 +87,7 @@ static void snd_allo_digione_shutdown(struct snd_pcm_substream *substream)
8687
/* turn off output */
8788
struct snd_soc_pcm_runtime *rtd = substream->private_data;
8889
struct snd_soc_codec *codec = rtd->codec;
90+
8991
snd_soc_update_bits(codec, WM8804_PWRDN, 0x3c, 0x3c);
9092
}
9193
}
@@ -107,43 +109,37 @@ static int snd_allo_digione_hw_params(struct snd_pcm_substream *substream,
107109
int ret;
108110

109111
samplerate = params_rate(params);
110-
111-
if (samplerate <= 96000) {
112-
mclk_freq = samplerate * 256;
113-
mclk_div = WM8804_MCLKDIV_256FS;
114-
} else {
115-
mclk_freq = samplerate * 128;
116-
mclk_div = WM8804_MCLKDIV_128FS;
117-
}
112+
mclk_freq = samplerate * 256;
113+
mclk_div = WM8804_MCLKDIV_256FS;
118114

119115
sysclk = snd_allo_digione_enable_clock(samplerate);
120-
116+
121117
switch (samplerate) {
122-
case 32000:
123-
sampling_freq=0x03;
124-
break;
125-
case 44100:
126-
sampling_freq=0x00;
127-
break;
128-
case 48000:
129-
sampling_freq=0x02;
130-
break;
131-
case 88200:
132-
sampling_freq=0x08;
133-
break;
134-
case 96000:
135-
sampling_freq=0x0a;
136-
break;
137-
case 176400:
138-
sampling_freq=0x0c;
139-
break;
140-
case 192000:
141-
sampling_freq=0x0e;
142-
break;
143-
default:
144-
dev_err(codec->dev,
145-
"Failed to set WM8804 SYSCLK, unsupported samplerate %d\n",
146-
samplerate);
118+
case 32000:
119+
sampling_freq = 0x03;
120+
break;
121+
case 44100:
122+
sampling_freq = 0x00;
123+
break;
124+
case 48000:
125+
sampling_freq = 0x02;
126+
break;
127+
case 88200:
128+
sampling_freq = 0x08;
129+
break;
130+
case 96000:
131+
sampling_freq = 0x0a;
132+
break;
133+
case 176400:
134+
sampling_freq = 0x0c;
135+
break;
136+
case 192000:
137+
sampling_freq = 0x0e;
138+
break;
139+
default:
140+
dev_err(codec->dev,
141+
"Failed to set WM8804 SYSCLK, unsupported samplerate %d\n",
142+
samplerate);
147143
}
148144

149145
snd_soc_dai_set_clkdiv(codec_dai, WM8804_MCLK_DIV, mclk_div);
@@ -173,8 +169,8 @@ static int snd_allo_digione_hw_params(struct snd_pcm_substream *substream,
173169
/* machine stream operations */
174170
static struct snd_soc_ops snd_allo_digione_ops = {
175171
.hw_params = snd_allo_digione_hw_params,
176-
.startup = snd_allo_digione_startup,
177-
.shutdown = snd_allo_digione_shutdown,
172+
.startup = snd_allo_digione_startup,
173+
.shutdown = snd_allo_digione_shutdown,
178174
};
179175

180176
static struct snd_soc_dai_link snd_allo_digione_dai[] = {
@@ -209,27 +205,28 @@ static int snd_allo_digione_probe(struct platform_device *pdev)
209205
snd_allo_digione.dev = &pdev->dev;
210206

211207
if (pdev->dev.of_node) {
212-
struct device_node *i2s_node;
213-
struct snd_soc_dai_link *dai = &snd_allo_digione_dai[0];
214-
i2s_node = of_parse_phandle(pdev->dev.of_node,
215-
"i2s-controller", 0);
216-
217-
if (i2s_node) {
218-
dai->cpu_dai_name = NULL;
219-
dai->cpu_of_node = i2s_node;
220-
dai->platform_name = NULL;
221-
dai->platform_of_node = i2s_node;
222-
}
223-
224-
snd_allo_clk44gpio =
225-
devm_gpiod_get(&pdev->dev, "clock44", GPIOD_OUT_LOW);
226-
if (IS_ERR(snd_allo_clk44gpio))
227-
dev_err(&pdev->dev, "devm_gpiod_get() failed\n");
228-
229-
snd_allo_clk48gpio =
230-
devm_gpiod_get(&pdev->dev, "clock48", GPIOD_OUT_LOW);
231-
if (IS_ERR(snd_allo_clk48gpio))
232-
dev_err(&pdev->dev, "devm_gpiod_get() failed\n");
208+
struct device_node *i2s_node;
209+
struct snd_soc_dai_link *dai = &snd_allo_digione_dai[0];
210+
211+
i2s_node = of_parse_phandle(pdev->dev.of_node,
212+
"i2s-controller", 0);
213+
214+
if (i2s_node) {
215+
dai->cpu_dai_name = NULL;
216+
dai->cpu_of_node = i2s_node;
217+
dai->platform_name = NULL;
218+
dai->platform_of_node = i2s_node;
219+
}
220+
221+
snd_allo_clk44gpio =
222+
devm_gpiod_get(&pdev->dev, "clock44", GPIOD_OUT_LOW);
223+
if (IS_ERR(snd_allo_clk44gpio))
224+
dev_err(&pdev->dev, "devm_gpiod_get() failed\n");
225+
226+
snd_allo_clk48gpio =
227+
devm_gpiod_get(&pdev->dev, "clock48", GPIOD_OUT_LOW);
228+
if (IS_ERR(snd_allo_clk48gpio))
229+
dev_err(&pdev->dev, "devm_gpiod_get() failed\n");
233230
}
234231

235232
ret = snd_soc_register_card(&snd_allo_digione);

0 commit comments

Comments
 (0)