-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from deckerego/i2s_audio
I2S Audio Support
- Loading branch information
Showing
6 changed files
with
80 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,37 @@ | ||
#!/bin/bash | ||
|
||
BOOT_CONFIG=/boot/config.txt | ||
MOD_CONFIG=/etc/modules | ||
|
||
# Fix ownership in home directory after installing | ||
chown -R pi:pi /home/pi/hack-clock | ||
|
||
# Install those Python modules that only exist via pip | ||
echo "Installing missing Python modules..." | ||
pip install -r /usr/share/doc/hack-clock/requirements.txt | ||
|
||
# Set the hifiberry-dac i2s module | ||
echo "Installing I2S audio..." | ||
if [ -e $BOOT_CONFIG ] && grep -q "^dtoverlay=hifiberry-dac$" $BOOT_CONFIG; then | ||
echo "hifiberry already installed" | ||
else | ||
echo "dtoverlay=hifiberry-dac" | sudo tee -a $BOOT_CONFIG | ||
fi | ||
|
||
# Enable (optional) i2s-mmap to get rid of popping and set volumes | ||
if [ -e $BOOT_CONFIG ] && grep -q "^dtoverlay=i2s-mmap$" $BOOT_CONFIG; then | ||
echo "i2s-mmap already installed" | ||
else | ||
echo "dtoverlay=i2s-mmap" | sudo tee -a $BOOT_CONFIG | ||
fi | ||
|
||
# Make sure old audio is disabled | ||
if [ -e $BOOT_CONFIG ] && grep -q -E "^dtparam=audio=on$" $BOOT_CONFIG; then | ||
echo "Commenting out dtparam=audio=on in $BOOT_CONFIG" | ||
sudo sed -i "s|^dtparam=audio=on$|#dtparam=audio=on|" $BOOT_CONFIG &> /dev/null | ||
elif [ -e $MOD_CONFIG ] && grep -q "^snd-bcm2835" $MOD_CONFIG; then | ||
echo "Commenting out snd-bcm2835 in $MOD_CONFIG" | ||
sudo sed -i "s|^snd-bcm2835|#snd-bcm2835|" $MOD_CONFIG &> /dev/null | ||
fi | ||
|
||
echo "Please reboot your Raspberry Pi!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
pcm.hifiberry { | ||
type hw card 0 | ||
} | ||
|
||
pcm.!default { | ||
type plug | ||
slave.pcm "softvol" | ||
} | ||
|
||
pcm.dmixer { | ||
type dmix | ||
ipc_key 1024 | ||
slave { | ||
pcm "hifiberry" | ||
channels 2 | ||
} | ||
} | ||
|
||
ctl.dmixer { | ||
type hw | ||
card 0 | ||
} | ||
|
||
pcm.softvol { | ||
type softvol | ||
slave { | ||
pcm "dmixer" | ||
} | ||
control { | ||
name "Master" | ||
card 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters