24 #include <linux/slab.h>
25 #include <linux/module.h>
34 #define TEA6330T_ADDR (0x80>>1)
36 #define TEA6330T_SADDR_VOLUME_LEFT 0x00
37 #define TEA6330T_SADDR_VOLUME_RIGHT 0x01
38 #define TEA6330T_SADDR_BASS 0x02
39 #define TEA6330T_SADDR_TREBLE 0x03
40 #define TEA6330T_SADDR_FADER 0x04
41 #define TEA6330T_MFN 0x20
42 #define TEA6330T_FCH 0x10
43 #define TEA6330T_SADDR_AUDIO_SWITCH 0x05
44 #define TEA6330T_GMU 0x80
45 #define TEA6330T_EQN 0x40
71 static void snd_tea6330t_set(
struct tea6330t *tea,
81 #define TEA6330T_MASTER_VOLUME(xname, xindex) \
82 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
83 .info = snd_tea6330t_info_master_volume, \
84 .get = snd_tea6330t_get_master_volume, .put = snd_tea6330t_put_master_volume }
86 static int snd_tea6330t_info_master_volume(
struct snd_kcontrol *kcontrol,
96 static int snd_tea6330t_get_master_volume(
struct snd_kcontrol *kcontrol,
101 snd_i2c_lock(tea->
bus);
102 ucontrol->
value.integer.value[0] = tea->
mleft - 0x14;
103 ucontrol->
value.integer.value[1] = tea->
mright - 0x14;
104 snd_i2c_unlock(tea->
bus);
108 static int snd_tea6330t_put_master_volume(
struct snd_kcontrol *kcontrol,
113 unsigned char bytes[3];
114 unsigned char val1, val2;
116 val1 = (ucontrol->
value.integer.value[0] % 44) + 0x14;
117 val2 = (ucontrol->
value.integer.value[1] % 44) + 0x14;
118 snd_i2c_lock(tea->
bus);
119 change = val1 != tea->
mleft || val2 != tea->
mright;
136 snd_i2c_unlock(tea->
bus);
140 #define TEA6330T_MASTER_SWITCH(xname, xindex) \
141 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
142 .info = snd_tea6330t_info_master_switch, \
143 .get = snd_tea6330t_get_master_switch, .put = snd_tea6330t_put_master_switch }
145 #define snd_tea6330t_info_master_switch snd_ctl_boolean_stereo_info
147 static int snd_tea6330t_get_master_switch(
struct snd_kcontrol *kcontrol,
152 snd_i2c_lock(tea->
bus);
155 snd_i2c_unlock(tea->
bus);
159 static int snd_tea6330t_put_master_switch(
struct snd_kcontrol *kcontrol,
164 unsigned char bytes[3];
165 unsigned char oval1, oval2, val1, val2;
167 val1 = ucontrol->
value.integer.value[0] & 1;
168 val2 = ucontrol->
value.integer.value[1] & 1;
169 snd_i2c_lock(tea->
bus);
172 change = val1 != oval1 || val2 != oval2;
180 snd_i2c_unlock(tea->
bus);
184 #define TEA6330T_BASS(xname, xindex) \
185 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
186 .info = snd_tea6330t_info_bass, \
187 .get = snd_tea6330t_get_bass, .put = snd_tea6330t_put_bass }
189 static int snd_tea6330t_info_bass(
struct snd_kcontrol *kcontrol,
201 static int snd_tea6330t_get_bass(
struct snd_kcontrol *kcontrol,
206 ucontrol->
value.integer.value[0] = tea->
bass;
210 static int snd_tea6330t_put_bass(
struct snd_kcontrol *kcontrol,
215 unsigned char bytes[2];
218 val1 = ucontrol->
value.integer.value[0] % (tea->
max_bass + 1);
219 snd_i2c_lock(tea->
bus);
227 snd_i2c_unlock(tea->
bus);
231 #define TEA6330T_TREBLE(xname, xindex) \
232 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
233 .info = snd_tea6330t_info_treble, \
234 .get = snd_tea6330t_get_treble, .put = snd_tea6330t_put_treble }
236 static int snd_tea6330t_info_treble(
struct snd_kcontrol *kcontrol,
248 static int snd_tea6330t_get_treble(
struct snd_kcontrol *kcontrol,
257 static int snd_tea6330t_put_treble(
struct snd_kcontrol *kcontrol,
262 unsigned char bytes[2];
266 snd_i2c_lock(tea->
bus);
274 snd_i2c_unlock(tea->
bus);
299 u8 default_treble, default_bass;
300 unsigned char bytes[7];
325 default_bass = 3 + 4;
327 default_treble = 3 + 4;
332 default_bass = 7 + 4;
343 for (idx = 0; idx < 6; idx++)
344 bytes[idx+1] = tea->
regs[idx];
352 for (idx = 0; idx <
ARRAY_SIZE(snd_tea6330t_controls); idx++) {
353 knew = &snd_tea6330t_controls[
idx];
376 static int __init alsa_tea6330t_init(
void)
381 static void __exit alsa_tea6330t_exit(
void)