forked from HinTak/seeed-voicecard
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8b84b89
commit 73ff8fe
Showing
2 changed files
with
96 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2018 Baozhu Zuo <zuobaozhu@gmail.com> | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
# THE SOFTWARE. | ||
|
||
is_1a=$(i2cdetect -y 1 0x1a 0x1a | grep 1a | awk '{print $2}') | ||
is_35=$(i2cdetect -y 1 0x35 0x35 | grep 35 | awk '{print $2}') | ||
is_3b=$(i2cdetect -y 1 0x3b 0x3b | grep 3b | awk '{print $2}') | ||
|
||
if [ "x${is_1a}" == "x1a" ] && [ "x${is_35}" == "x" ] ; then | ||
echo "install 2mic" | ||
dtoverlay seeed-2mic-voicecard | ||
sleep 1 | ||
hw=$(aplay -l | grep seeed2micvoicec | awk '{print $2}' | sed 's/://') | ||
|
||
cp /etc/voicecard/asound_2mic.conf /etc/asound.conf | ||
|
||
echo "get old hw number" | ||
old=$(cat /etc/asound.conf | grep hw: | awk 'NR==1 {print $2}' | sed 's/\"//g') | ||
|
||
echo "replace new hw:${hw},0" | ||
sed -i -e "s/${old}/hw:${hw},0/g" /etc/asound.conf | ||
|
||
cp /etc/voicecard/wm8960_asound.state /var/lib/alsa/asound.state | ||
fi | ||
|
||
if [ "x${is_3b}" == "x3b" ] && [ "x${is_35}" == "x" ] ; then | ||
echo "install 4mic" | ||
dtoverlay seeed-4mic-voicecard | ||
sleep 1 | ||
hw=$(arecord -l | grep seeed4micvoicec | awk '{print $2}' | sed 's/://') | ||
|
||
cp /etc/voicecard/asound_4mic.conf /etc/asound.conf | ||
|
||
echo "get slavepcm line number" | ||
line=$(grep -n slavepcm /etc/asound.conf | awk '{print $1}' | sed 's/://') | ||
|
||
echo "delete ${line} slavepcm hw number" | ||
sed -i -e "${line}d" /etc/asound.conf | ||
|
||
echo "inset slavepcm hw:${hw},0" | ||
sed -i "${line}i slavepcm \"hw:${hw},0\"" /etc/asound.conf | ||
|
||
cp /etc/voicecard/ac108_asound.state /var/lib/alsa/asound.state | ||
fi | ||
|
||
if [ "x${is_3b}" == "x3b" ] && [ "x${is_35}" == "x35" ] ; then | ||
echo "install 6mic" | ||
dtoverlay seeed-8mic-voicecard | ||
sleep 1 | ||
hw=$(aplay -l | grep seeed8micvoicec | awk '{print $2}' | sed 's/://') | ||
|
||
cp /etc/voicecard/asound_6mic.conf /etc/asound.conf | ||
|
||
old=$(cat /etc/asound.conf | grep hw: | awk 'NR==1 {print $2}' | sed 's/\"//g') | ||
|
||
sed -i -e "s/${old}/hw:${hw},0/g" /etc/asound.conf | ||
|
||
cp /etc/voicecard/ac101-ok-20180119.state /var/lib/alsa/asound.state | ||
fi | ||
|
||
alsactl restore | ||
|
||
#Fore 3.5mm ('headphone') jack | ||
amixer cset numid=3 1 | ||
|
||
|
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,12 @@ | ||
[Unit] | ||
Description=Seeed Voicecard service | ||
After=alsa-restore.service | ||
|
||
[Service] | ||
Type=oneshot | ||
RemainAfterExit=yes | ||
ExecStart=/usr/bin/seeed-voicecard | ||
User=root | ||
|
||
[Install] | ||
WantedBy=sysinit.target |