summaryrefslogtreecommitdiff
path: root/tools/sunxi-setup-amixer.sh
blob: f33ebb7da844b221056575033738e44dba0f2e85 (plain)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/bash

amixer() {
    /usr/bin/amixer "$@"
}

setup_opi_pc2() {
	for v in unmute cap; do
		amixer set "Line In" $v
		amixer set "Mic1" $v
		amixer set "Mic2" $v
	done

	for k in "Mic1 Boost" "Line In" "Mic1" "Mic2 Boost" "Mic2"; do
		amixer set "$k" "86%"
	done
}

setup_opi_one() {
	for v in unmute cap; do
		amixer set "Line In" $v
		amixer set "Mic1" $v
  	done

  	for k in "Mic1 Boost" "Line In" "Mic1"; do
		amixer set "$k" "86%"
  	done
}

setup_opi3lts() {
	switches=(
		"Left DAC Mixer ADCL"
		"Left DAC Mixer I2SDACL"
		"Left I2S Mixer ADCL"
		"Left I2S Mixer I2SDACL"
		"Left Input Mixer LINEINL"
		"Left Input Mixer MIC1"
		"Left Input Mixer MIC2"
		"Left Input Mixer OMixerL"
		"Left Input Mixer OMixerR"
		"Left Input Mixer PhoneN"
		"Left Input Mixer PhonePN"
		"Left Output Mixer DACL"
		"Left Output Mixer DACR"
		"Left Output Mixer LINEINL"
		"Left Output Mixer MIC1"
		"Left Output Mixer MIC2"
		"Left Output Mixer PhoneN"
		"Left Output Mixer PhonePN"
		"Right DAC Mixer ADCR"
		"Right DAC Mixer I2SDACR"
		"Right I2S Mixer ADCR"
		"Right I2S Mixer I2SDACR"
		"Right Input Mixer LINEINR"
		"Right Input Mixer MIC1"
		"Right Input Mixer MIC2"
		"Right Input Mixer OMixerL"
		"Right Input Mixer OMixerR"
		"Right Input Mixer PhoneP"
		"Right Input Mixer PhonePN"
		"Right Output Mixer DACL"
		"Right Output Mixer DACR"
		"Right Output Mixer LINEINR"
		"Right Output Mixer MIC1"
		"Right Output Mixer MIC2"
		"Right Output Mixer PhoneP"
		"Right Output Mixer PhonePN"
	)
	for v in "${switches[@]}"; do
		value=on
		case "$v" in
			*Input*)
				value=on
				;;
			*Output*)
				value=off
				;;
		esac
		amixer set "$v" $value
	done

	to_mute=(
		"I2S Mixer ADC"
		"I2S Mixer DAC"
		"ADC Input"
		"DAC Mixer ADC"
		"DAC Mxier DAC" # this is not a typo
	)
	for v in "${to_mute[@]}"; do
		amixer set "$v" "0%"
	done

	amixer set "Master" "100%"
	amixer set "MIC1 Boost" "100%"
	amixer set "MIC2 Boost" "100%"
	amixer set "Line Out Mixer" "86%"
	amixer set "MIC Out Mixer" "71%"
}

device="$(tr -d '\0' < /sys/firmware/devicetree/base/model)"
case "$device" in
	*"Orange Pi PC 2")
		setup_opi_pc2
		;;
	*"Orange Pi One")
		setup_opi_one
		;;
	*"OrangePi 3 LTS")
		setup_opi3lts
		;;
	*)
		>&2 echo "error: unidentified device: $device"
		;;
esac