27 #include <linux/module.h>
33 #define PT2258_CMD_RESET 0xc0
34 #define PT2258_CMD_UNMUTE 0xf8
35 #define PT2258_CMD_MUTE 0xf9
37 static const unsigned char pt2258_channel_code[12] = {
48 unsigned char bytes[2];
67 for (i = 0; i < 6; ++
i)
84 static int pt2258_stereo_volume_info(
struct snd_kcontrol *kcontrol,
94 static int pt2258_stereo_volume_get(
struct snd_kcontrol *kcontrol,
101 ucontrol->
value.integer.value[0] = 79 - pt->
volume[base];
102 ucontrol->
value.integer.value[1] = 79 - pt->
volume[base + 1];
106 static int pt2258_stereo_volume_put(
struct snd_kcontrol *kcontrol,
111 unsigned char bytes[2];
114 val0 = 79 - ucontrol->
value.integer.value[0];
115 val1 = 79 - ucontrol->
value.integer.value[1];
116 if (val0 < 0 || val0 > 79 || val1 < 0 || val1 > 79)
118 if (val0 == pt->
volume[base] && val1 == pt->
volume[base + 1])
122 bytes[0] = pt2258_channel_code[2 * base] | (val0 / 10);
123 bytes[1] = pt2258_channel_code[2 * base + 1] | (val0 % 10);
129 pt->
volume[base + 1] = val1;
130 bytes[0] = pt2258_channel_code[2 * base + 2] | (val1 / 10);
131 bytes[1] = pt2258_channel_code[2 * base + 3] | (val1 % 10);
145 #define pt2258_switch_info snd_ctl_boolean_mono_info
147 static int pt2258_switch_get(
struct snd_kcontrol *kcontrol,
152 ucontrol->
value.integer.value[0] = !pt->
mute;
156 static int pt2258_switch_put(
struct snd_kcontrol *kcontrol,
160 unsigned char bytes[2];
163 val = !ucontrol->
value.integer.value[0];
188 "Mic Loopback Playback Volume",
189 "Line Loopback Playback Volume",
190 "CD Loopback Playback Volume"
194 for (i = 0; i < 3; ++
i) {
195 memset(&knew, 0,
sizeof(knew));
196 knew.
name = names[
i];
202 knew.
info = pt2258_stereo_volume_info;
203 knew.
get = pt2258_stereo_volume_get;
204 knew.
put = pt2258_stereo_volume_put;
205 knew.
tlv.
p = pt2258_db_scale;
212 memset(&knew, 0,
sizeof(knew));
213 knew.
name =
"Loopback Switch";
216 knew.
get = pt2258_switch_get;
217 knew.
put = pt2258_switch_put;