summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Matuschek <daniel@hifiberry.com>2015-03-18 18:06:52 +0100
committerpopcornmix <popcornmix@gmail.com>2015-05-18 14:12:35 +0100
commit0738572131aee90968b22801aa6350eab3f7b460 (patch)
treedc5b5cf19b3249f720fa47108f7343b0abb9419d
parentc4b3716f0f020601fa4091708daebd118b4f76cd (diff)
downloadlinux-0738572131aee90968b22801aa6350eab3f7b460.tar.gz
HiFiBerry Digi: set SPDIF status bits for sample rate
The HiFiBerry Digi driver did not signal the sample rate in the SPDIF status bits. While this is optional, some DACs and receivers do not accept this signal. This patch adds the sample rate bits in the SPDIF status block.
-rw-r--r--sound/soc/bcm/hifiberry_digi.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/sound/soc/bcm/hifiberry_digi.c b/sound/soc/bcm/hifiberry_digi.c
index a294a1bbf631..80732b8ac180 100644
--- a/sound/soc/bcm/hifiberry_digi.c
+++ b/sound/soc/bcm/hifiberry_digi.c
@@ -74,24 +74,41 @@ static int snd_rpi_hifiberry_digi_hw_params(struct snd_pcm_substream *substream,
long mclk_freq=0;
int mclk_div=1;
+ int sampling_freq=1;
int ret;
samplerate = params_rate(params);
+ if (samplerate<=96000) {
+ mclk_freq=samplerate*256;
+ mclk_div=WM8804_MCLKDIV_256FS;
+ } else {
+ mclk_freq=samplerate*128;
+ mclk_div=WM8804_MCLKDIV_128FS;
+ }
+
switch (samplerate) {
case 32000:
+ sampling_freq=0x03;
+ break;
case 44100:
+ sampling_freq=0x00;
+ break;
case 48000:
+ sampling_freq=0x02;
+ break;
case 88200:
+ sampling_freq=0x08;
+ break;
case 96000:
- mclk_freq=samplerate*256;
- mclk_div=WM8804_MCLKDIV_256FS;
+ sampling_freq=0x0a;
break;
case 176400:
+ sampling_freq=0x0c;
+ break;
case 192000:
- mclk_freq=samplerate*128;
- mclk_div=WM8804_MCLKDIV_128FS;
+ sampling_freq=0x0e;
break;
default:
dev_err(codec->dev,
@@ -116,6 +133,9 @@ static int snd_rpi_hifiberry_digi_hw_params(struct snd_pcm_substream *substream,
/* Power on */
snd_soc_update_bits(codec, WM8804_PWRDN, 0x9, 0);
+ /* set sampling frequency status bits */
+ snd_soc_update_bits(codec, WM8804_SPDTX4, 0x0f, sampling_freq);
+
return snd_soc_dai_set_bclk_ratio(cpu_dai,64);
}