-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjackingoff-sof.sh
More file actions
executable file
·42 lines (30 loc) · 1.52 KB
/
Copy pathjackingoff-sof.sh
File metadata and controls
executable file
·42 lines (30 loc) · 1.52 KB
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
#!/bin/bash
# written & tested on Acer Nitro 5 AN515-56 only; use at your own risk
# run after recording (or arecord | aplay monitoring) is started
# hwC1D0 for me
ALC295_CLASS_PATH=$(grep -l "ALC295" /sys/class/sound/hwC*/chip_name 2>/dev/null | sed 's/\/chip_name//')
CODEC="/dev/snd/$(basename $ALC295_CLASS_PATH)"
# Acer Nitro 5 has three SOF channels normally: one is silent (ALC295), and two hold webcam sound (48kHz/16kHz)
# this looks up for the first one (normally 0x10 if active). checked here to be sure that the channel is opened at all
CONV=$(hda-verb $CODEC 0x07 GET_CONV 0x00 | grep -i -o '0x[0-9a-f]*' | tail -n 1)
if [ -z "$CONV" ] || [ "$CONV" = "0x0" ] || [ "$CONV" = "0x00" ]; then
echo "Error: no channels are currently opened" >&2
exit 1
fi
hda-verb $CODEC 0x21 SET_PIN_WIDGET_CONTROL 0x00
hda-verb $CODEC 0x20 SET_COEF_INDEX 0x4a
hda-verb $CODEC 0x20 SET_PROC_COEF 0x20e0
hda-verb $CODEC 0x57 SET_COEF_INDEX 0x05
hda-verb $CODEC 0x57 SET_PROC_COEF 0x7680
hda-verb $CODEC 0x1b SET_POWER_STATE 0x00
hda-verb $CODEC 0x1b SET_PIN_WIDGET_CONTROL 0x21
hda-verb $CODEC 0x1b SET_AMP_GAIN_MUTE 0x7000
hda-verb $CODEC 0x23 SET_POWER_STATE 0x00
hda-verb $CODEC 0x23 SET_CONNECT_SEL 0x02
hda-verb $CODEC 0x23 SET_AMP_GAIN_MUTE 0x7200
hda-verb $CODEC 0x08 SET_POWER_STATE 0x00
# the 2nd byte represents the gain. 0x17 usually leaves enough headroom for my usage
hda-verb $CODEC 0x08 SET_AMP_GAIN_MUTE 0x7017
hda-verb $CODEC 0x07 SET_CHANNEL_STREAMID 0x00
hda-verb $CODEC 0x08 SET_CHANNEL_STREAMID $CONV
echo "Done for $CONV"