forked from nicokaiser/rpi-audio-receiver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
enable-hifiberry.sh
executable file
·65 lines (58 loc) · 1.18 KB
/
enable-hifiberry.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash -e
if [[ $(id -u) -ne 0 ]] ; then echo "Please run as root" ; exit 1 ; fi
echo
echo -n "Do you want to enable HiFiBerry device tree overlay and ALSA configuration? [y/N] "
read REPLY
if [[ ! "$REPLY" =~ ^(yes|y|Y)$ ]]; then exit 0; fi
echo -n "Which board do you want to enable? [dac/dacplus/dacplusadc/dacplusadcpro/dacplusdsp/digi/digipro/amp] "
read CARD
if [[ ! "$CARD" =~ ^(dac|dacplus|digi|amp)$ ]]; then exit 1; fi
cat <<'EOF' > /etc/asound.conf
defaults.pcm.card 0
defaults.ctl.card 0
pcm.hifiberry {
type hw
card 0
device 0
}
pcm.dmixer {
type dmix
ipc_key 1024
ipc_perm 0666
slave.pcm "hifiberry"
slave {
period_time 0
period_size 1024
buffer_size 8192
rate 44100
format S32_LE
}
bindings {
0 0
1 1
}
}
ctl.dmixer {
type hw
card 0
}
pcm.softvol {
type softvol
slave.pcm "dmixer"
control {
name "Softvol"
card 0
}
min_dB -90.2
max_dB 0.0
}
pcm.!default {
type plug
slave.pcm "softvol"
}
EOF
#amixer sset 'Softvol' 100%
#alsactl store
cat /boot/config.txt | grep -vi "dtparam=audio" | grep -vi hifiberry >/tmp/config.txt
echo dtoverlay=hifiberry-${CARD} >>/tmp/config.txt
mv /tmp/config.txt /boot/config.txt