1 // SPDX-License-Identifier: GPL-2.0-or-later << 2 /* 1 /* 3 * Routines for control of the TEA6330T circu 2 * Routines for control of the TEA6330T circuit via i2c bus 4 * Sound fader control circuit for car radios 3 * Sound fader control circuit for car radios by Philips Semiconductors 5 * Copyright (c) by Jaroslav Kysela <perex@pe 4 * Copyright (c) by Jaroslav Kysela <perex@perex.cz> >> 5 * >> 6 * >> 7 * This program is free software; you can redistribute it and/or modify >> 8 * it under the terms of the GNU General Public License as published by >> 9 * the Free Software Foundation; either version 2 of the License, or >> 10 * (at your option) any later version. >> 11 * >> 12 * This program is distributed in the hope that it will be useful, >> 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of >> 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> 15 * GNU General Public License for more details. >> 16 * >> 17 * You should have received a copy of the GNU General Public License >> 18 * along with this program; if not, write to the Free Software >> 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA >> 20 * 6 */ 21 */ 7 22 8 #include <linux/init.h> 23 #include <linux/init.h> 9 #include <linux/slab.h> 24 #include <linux/slab.h> 10 #include <linux/module.h> 25 #include <linux/module.h> 11 #include <sound/core.h> 26 #include <sound/core.h> 12 #include <sound/control.h> 27 #include <sound/control.h> 13 #include <sound/tea6330t.h> 28 #include <sound/tea6330t.h> 14 29 15 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz 30 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>"); 16 MODULE_DESCRIPTION("Routines for control of th 31 MODULE_DESCRIPTION("Routines for control of the TEA6330T circuit via i2c bus"); 17 MODULE_LICENSE("GPL"); 32 MODULE_LICENSE("GPL"); 18 33 19 #define TEA6330T_ADDR (0x80> 34 #define TEA6330T_ADDR (0x80>>1) /* fixed address */ 20 35 21 #define TEA6330T_SADDR_VOLUME_LEFT 0x00 36 #define TEA6330T_SADDR_VOLUME_LEFT 0x00 /* volume left */ 22 #define TEA6330T_SADDR_VOLUME_RIGHT 0x01 37 #define TEA6330T_SADDR_VOLUME_RIGHT 0x01 /* volume right */ 23 #define TEA6330T_SADDR_BASS 0x02 38 #define TEA6330T_SADDR_BASS 0x02 /* bass control */ 24 #define TEA6330T_SADDR_TREBLE 0x03 39 #define TEA6330T_SADDR_TREBLE 0x03 /* treble control */ 25 #define TEA6330T_SADDR_FADER 0x04 40 #define TEA6330T_SADDR_FADER 0x04 /* fader control */ 26 #define TEA6330T_MFN 0x20 41 #define TEA6330T_MFN 0x20 /* mute control for selected channels */ 27 #define TEA6330T_FCH 0x10 42 #define TEA6330T_FCH 0x10 /* select fader channels - front or rear */ 28 #define TEA6330T_SADDR_AUDIO_SWITCH 0x05 43 #define TEA6330T_SADDR_AUDIO_SWITCH 0x05 /* audio switch */ 29 #define TEA6330T_GMU 0x80 44 #define TEA6330T_GMU 0x80 /* mute control, general mute */ 30 #define TEA6330T_EQN 0x40 45 #define TEA6330T_EQN 0x40 /* equalizer switchover (0=equalizer-on) */ 31 46 32 47 33 struct tea6330t { 48 struct tea6330t { 34 struct snd_i2c_device *device; 49 struct snd_i2c_device *device; 35 struct snd_i2c_bus *bus; 50 struct snd_i2c_bus *bus; 36 int equalizer; 51 int equalizer; 37 int fader; 52 int fader; 38 unsigned char regs[8]; 53 unsigned char regs[8]; 39 unsigned char mleft, mright; 54 unsigned char mleft, mright; 40 unsigned char bass, treble; 55 unsigned char bass, treble; 41 unsigned char max_bass, max_treble; 56 unsigned char max_bass, max_treble; 42 }; 57 }; 43 58 44 59 45 int snd_tea6330t_detect(struct snd_i2c_bus *bu 60 int snd_tea6330t_detect(struct snd_i2c_bus *bus, int equalizer) 46 { 61 { 47 int res; 62 int res; 48 63 49 snd_i2c_lock(bus); 64 snd_i2c_lock(bus); 50 res = snd_i2c_probeaddr(bus, TEA6330T_ 65 res = snd_i2c_probeaddr(bus, TEA6330T_ADDR); 51 snd_i2c_unlock(bus); 66 snd_i2c_unlock(bus); 52 return res; 67 return res; 53 } 68 } 54 69 55 #if 0 70 #if 0 56 static void snd_tea6330t_set(struct tea6330t * 71 static void snd_tea6330t_set(struct tea6330t *tea, 57 unsigned char add 72 unsigned char addr, unsigned char value) 58 { 73 { >> 74 #if 0 >> 75 printk(KERN_DEBUG "set - 0x%x/0x%x\n", addr, value); >> 76 #endif 59 snd_i2c_write(tea->bus, TEA6330T_ADDR, 77 snd_i2c_write(tea->bus, TEA6330T_ADDR, addr, value, 1); 60 } 78 } 61 #endif 79 #endif 62 80 63 #define TEA6330T_MASTER_VOLUME(xname, xindex) 81 #define TEA6330T_MASTER_VOLUME(xname, xindex) \ 64 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = 82 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ 65 .info = snd_tea6330t_info_master_volume, \ 83 .info = snd_tea6330t_info_master_volume, \ 66 .get = snd_tea6330t_get_master_volume, .put 84 .get = snd_tea6330t_get_master_volume, .put = snd_tea6330t_put_master_volume } 67 85 68 static int snd_tea6330t_info_master_volume(str 86 static int snd_tea6330t_info_master_volume(struct snd_kcontrol *kcontrol, 69 str 87 struct snd_ctl_elem_info *uinfo) 70 { 88 { 71 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTE 89 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 72 uinfo->count = 2; 90 uinfo->count = 2; 73 uinfo->value.integer.min = 0; 91 uinfo->value.integer.min = 0; 74 uinfo->value.integer.max = 43; 92 uinfo->value.integer.max = 43; 75 return 0; 93 return 0; 76 } 94 } 77 95 78 static int snd_tea6330t_get_master_volume(stru 96 static int snd_tea6330t_get_master_volume(struct snd_kcontrol *kcontrol, 79 stru 97 struct snd_ctl_elem_value *ucontrol) 80 { 98 { 81 struct tea6330t *tea = snd_kcontrol_ch 99 struct tea6330t *tea = snd_kcontrol_chip(kcontrol); 82 100 83 snd_i2c_lock(tea->bus); 101 snd_i2c_lock(tea->bus); 84 ucontrol->value.integer.value[0] = tea 102 ucontrol->value.integer.value[0] = tea->mleft - 0x14; 85 ucontrol->value.integer.value[1] = tea 103 ucontrol->value.integer.value[1] = tea->mright - 0x14; 86 snd_i2c_unlock(tea->bus); 104 snd_i2c_unlock(tea->bus); 87 return 0; 105 return 0; 88 } 106 } 89 107 90 static int snd_tea6330t_put_master_volume(stru 108 static int snd_tea6330t_put_master_volume(struct snd_kcontrol *kcontrol, 91 stru 109 struct snd_ctl_elem_value *ucontrol) 92 { 110 { 93 struct tea6330t *tea = snd_kcontrol_ch 111 struct tea6330t *tea = snd_kcontrol_chip(kcontrol); 94 int change, count, err; 112 int change, count, err; 95 unsigned char bytes[3]; 113 unsigned char bytes[3]; 96 unsigned char val1, val2; 114 unsigned char val1, val2; 97 115 98 val1 = (ucontrol->value.integer.value[ 116 val1 = (ucontrol->value.integer.value[0] % 44) + 0x14; 99 val2 = (ucontrol->value.integer.value[ 117 val2 = (ucontrol->value.integer.value[1] % 44) + 0x14; 100 snd_i2c_lock(tea->bus); 118 snd_i2c_lock(tea->bus); 101 change = val1 != tea->mleft || val2 != 119 change = val1 != tea->mleft || val2 != tea->mright; 102 tea->mleft = val1; 120 tea->mleft = val1; 103 tea->mright = val2; 121 tea->mright = val2; 104 count = 0; 122 count = 0; 105 if (tea->regs[TEA6330T_SADDR_VOLUME_LE 123 if (tea->regs[TEA6330T_SADDR_VOLUME_LEFT] != 0) { 106 bytes[count++] = TEA6330T_SADD 124 bytes[count++] = TEA6330T_SADDR_VOLUME_LEFT; 107 bytes[count++] = tea->regs[TEA 125 bytes[count++] = tea->regs[TEA6330T_SADDR_VOLUME_LEFT] = tea->mleft; 108 } 126 } 109 if (tea->regs[TEA6330T_SADDR_VOLUME_RI 127 if (tea->regs[TEA6330T_SADDR_VOLUME_RIGHT] != 0) { 110 if (count == 0) 128 if (count == 0) 111 bytes[count++] = TEA63 129 bytes[count++] = TEA6330T_SADDR_VOLUME_RIGHT; 112 bytes[count++] = tea->regs[TEA 130 bytes[count++] = tea->regs[TEA6330T_SADDR_VOLUME_RIGHT] = tea->mright; 113 } 131 } 114 if (count > 0) { 132 if (count > 0) { 115 err = snd_i2c_sendbytes(tea->d !! 133 if ((err = snd_i2c_sendbytes(tea->device, bytes, count)) < 0) 116 if (err < 0) << 117 change = err; 134 change = err; 118 } 135 } 119 snd_i2c_unlock(tea->bus); 136 snd_i2c_unlock(tea->bus); 120 return change; 137 return change; 121 } 138 } 122 139 123 #define TEA6330T_MASTER_SWITCH(xname, xindex) 140 #define TEA6330T_MASTER_SWITCH(xname, xindex) \ 124 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = 141 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ 125 .info = snd_tea6330t_info_master_switch, \ 142 .info = snd_tea6330t_info_master_switch, \ 126 .get = snd_tea6330t_get_master_switch, .put 143 .get = snd_tea6330t_get_master_switch, .put = snd_tea6330t_put_master_switch } 127 144 128 #define snd_tea6330t_info_master_switch 145 #define snd_tea6330t_info_master_switch snd_ctl_boolean_stereo_info 129 146 130 static int snd_tea6330t_get_master_switch(stru 147 static int snd_tea6330t_get_master_switch(struct snd_kcontrol *kcontrol, 131 stru 148 struct snd_ctl_elem_value *ucontrol) 132 { 149 { 133 struct tea6330t *tea = snd_kcontrol_ch 150 struct tea6330t *tea = snd_kcontrol_chip(kcontrol); 134 151 135 snd_i2c_lock(tea->bus); 152 snd_i2c_lock(tea->bus); 136 ucontrol->value.integer.value[0] = tea 153 ucontrol->value.integer.value[0] = tea->regs[TEA6330T_SADDR_VOLUME_LEFT] == 0 ? 0 : 1; 137 ucontrol->value.integer.value[1] = tea 154 ucontrol->value.integer.value[1] = tea->regs[TEA6330T_SADDR_VOLUME_RIGHT] == 0 ? 0 : 1; 138 snd_i2c_unlock(tea->bus); 155 snd_i2c_unlock(tea->bus); 139 return 0; 156 return 0; 140 } 157 } 141 158 142 static int snd_tea6330t_put_master_switch(stru 159 static int snd_tea6330t_put_master_switch(struct snd_kcontrol *kcontrol, 143 stru 160 struct snd_ctl_elem_value *ucontrol) 144 { 161 { 145 struct tea6330t *tea = snd_kcontrol_ch 162 struct tea6330t *tea = snd_kcontrol_chip(kcontrol); 146 int change, err; 163 int change, err; 147 unsigned char bytes[3]; 164 unsigned char bytes[3]; 148 unsigned char oval1, oval2, val1, val2 165 unsigned char oval1, oval2, val1, val2; 149 166 150 val1 = ucontrol->value.integer.value[0 167 val1 = ucontrol->value.integer.value[0] & 1; 151 val2 = ucontrol->value.integer.value[1 168 val2 = ucontrol->value.integer.value[1] & 1; 152 snd_i2c_lock(tea->bus); 169 snd_i2c_lock(tea->bus); 153 oval1 = tea->regs[TEA6330T_SADDR_VOLUM 170 oval1 = tea->regs[TEA6330T_SADDR_VOLUME_LEFT] == 0 ? 0 : 1; 154 oval2 = tea->regs[TEA6330T_SADDR_VOLUM 171 oval2 = tea->regs[TEA6330T_SADDR_VOLUME_RIGHT] == 0 ? 0 : 1; 155 change = val1 != oval1 || val2 != oval 172 change = val1 != oval1 || val2 != oval2; 156 tea->regs[TEA6330T_SADDR_VOLUME_LEFT] 173 tea->regs[TEA6330T_SADDR_VOLUME_LEFT] = val1 ? tea->mleft : 0; 157 tea->regs[TEA6330T_SADDR_VOLUME_RIGHT] 174 tea->regs[TEA6330T_SADDR_VOLUME_RIGHT] = val2 ? tea->mright : 0; 158 bytes[0] = TEA6330T_SADDR_VOLUME_LEFT; 175 bytes[0] = TEA6330T_SADDR_VOLUME_LEFT; 159 bytes[1] = tea->regs[TEA6330T_SADDR_VO 176 bytes[1] = tea->regs[TEA6330T_SADDR_VOLUME_LEFT]; 160 bytes[2] = tea->regs[TEA6330T_SADDR_VO 177 bytes[2] = tea->regs[TEA6330T_SADDR_VOLUME_RIGHT]; 161 err = snd_i2c_sendbytes(tea->device, b !! 178 if ((err = snd_i2c_sendbytes(tea->device, bytes, 3)) < 0) 162 if (err < 0) << 163 change = err; 179 change = err; 164 snd_i2c_unlock(tea->bus); 180 snd_i2c_unlock(tea->bus); 165 return change; 181 return change; 166 } 182 } 167 183 168 #define TEA6330T_BASS(xname, xindex) \ 184 #define TEA6330T_BASS(xname, xindex) \ 169 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = 185 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ 170 .info = snd_tea6330t_info_bass, \ 186 .info = snd_tea6330t_info_bass, \ 171 .get = snd_tea6330t_get_bass, .put = snd_tea 187 .get = snd_tea6330t_get_bass, .put = snd_tea6330t_put_bass } 172 188 173 static int snd_tea6330t_info_bass(struct snd_k 189 static int snd_tea6330t_info_bass(struct snd_kcontrol *kcontrol, 174 struct snd_c 190 struct snd_ctl_elem_info *uinfo) 175 { 191 { 176 struct tea6330t *tea = snd_kcontrol_ch 192 struct tea6330t *tea = snd_kcontrol_chip(kcontrol); 177 193 178 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTE 194 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 179 uinfo->count = 1; 195 uinfo->count = 1; 180 uinfo->value.integer.min = 0; 196 uinfo->value.integer.min = 0; 181 uinfo->value.integer.max = tea->max_ba 197 uinfo->value.integer.max = tea->max_bass; 182 return 0; 198 return 0; 183 } 199 } 184 200 185 static int snd_tea6330t_get_bass(struct snd_kc 201 static int snd_tea6330t_get_bass(struct snd_kcontrol *kcontrol, 186 struct snd_ct 202 struct snd_ctl_elem_value *ucontrol) 187 { 203 { 188 struct tea6330t *tea = snd_kcontrol_ch 204 struct tea6330t *tea = snd_kcontrol_chip(kcontrol); 189 205 190 ucontrol->value.integer.value[0] = tea 206 ucontrol->value.integer.value[0] = tea->bass; 191 return 0; 207 return 0; 192 } 208 } 193 209 194 static int snd_tea6330t_put_bass(struct snd_kc 210 static int snd_tea6330t_put_bass(struct snd_kcontrol *kcontrol, 195 struct snd_ct 211 struct snd_ctl_elem_value *ucontrol) 196 { 212 { 197 struct tea6330t *tea = snd_kcontrol_ch 213 struct tea6330t *tea = snd_kcontrol_chip(kcontrol); 198 int change, err; 214 int change, err; 199 unsigned char bytes[2]; 215 unsigned char bytes[2]; 200 unsigned char val1; 216 unsigned char val1; 201 217 202 val1 = ucontrol->value.integer.value[0 218 val1 = ucontrol->value.integer.value[0] % (tea->max_bass + 1); 203 snd_i2c_lock(tea->bus); 219 snd_i2c_lock(tea->bus); 204 tea->bass = val1; 220 tea->bass = val1; 205 val1 += tea->equalizer ? 7 : 3; 221 val1 += tea->equalizer ? 7 : 3; 206 change = tea->regs[TEA6330T_SADDR_BASS 222 change = tea->regs[TEA6330T_SADDR_BASS] != val1; 207 bytes[0] = TEA6330T_SADDR_BASS; 223 bytes[0] = TEA6330T_SADDR_BASS; 208 bytes[1] = tea->regs[TEA6330T_SADDR_BA 224 bytes[1] = tea->regs[TEA6330T_SADDR_BASS] = val1; 209 err = snd_i2c_sendbytes(tea->device, b !! 225 if ((err = snd_i2c_sendbytes(tea->device, bytes, 2)) < 0) 210 if (err < 0) << 211 change = err; 226 change = err; 212 snd_i2c_unlock(tea->bus); 227 snd_i2c_unlock(tea->bus); 213 return change; 228 return change; 214 } 229 } 215 230 216 #define TEA6330T_TREBLE(xname, xindex) \ 231 #define TEA6330T_TREBLE(xname, xindex) \ 217 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = 232 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ 218 .info = snd_tea6330t_info_treble, \ 233 .info = snd_tea6330t_info_treble, \ 219 .get = snd_tea6330t_get_treble, .put = snd_t 234 .get = snd_tea6330t_get_treble, .put = snd_tea6330t_put_treble } 220 235 221 static int snd_tea6330t_info_treble(struct snd 236 static int snd_tea6330t_info_treble(struct snd_kcontrol *kcontrol, 222 struct snd 237 struct snd_ctl_elem_info *uinfo) 223 { 238 { 224 struct tea6330t *tea = snd_kcontrol_ch 239 struct tea6330t *tea = snd_kcontrol_chip(kcontrol); 225 240 226 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTE 241 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 227 uinfo->count = 1; 242 uinfo->count = 1; 228 uinfo->value.integer.min = 0; 243 uinfo->value.integer.min = 0; 229 uinfo->value.integer.max = tea->max_tr 244 uinfo->value.integer.max = tea->max_treble; 230 return 0; 245 return 0; 231 } 246 } 232 247 233 static int snd_tea6330t_get_treble(struct snd_ 248 static int snd_tea6330t_get_treble(struct snd_kcontrol *kcontrol, 234 struct snd_ 249 struct snd_ctl_elem_value *ucontrol) 235 { 250 { 236 struct tea6330t *tea = snd_kcontrol_ch 251 struct tea6330t *tea = snd_kcontrol_chip(kcontrol); 237 252 238 ucontrol->value.integer.value[0] = tea 253 ucontrol->value.integer.value[0] = tea->treble; 239 return 0; 254 return 0; 240 } 255 } 241 256 242 static int snd_tea6330t_put_treble(struct snd_ 257 static int snd_tea6330t_put_treble(struct snd_kcontrol *kcontrol, 243 struct snd_ 258 struct snd_ctl_elem_value *ucontrol) 244 { 259 { 245 struct tea6330t *tea = snd_kcontrol_ch 260 struct tea6330t *tea = snd_kcontrol_chip(kcontrol); 246 int change, err; 261 int change, err; 247 unsigned char bytes[2]; 262 unsigned char bytes[2]; 248 unsigned char val1; 263 unsigned char val1; 249 264 250 val1 = ucontrol->value.integer.value[0 265 val1 = ucontrol->value.integer.value[0] % (tea->max_treble + 1); 251 snd_i2c_lock(tea->bus); 266 snd_i2c_lock(tea->bus); 252 tea->treble = val1; 267 tea->treble = val1; 253 val1 += 3; 268 val1 += 3; 254 change = tea->regs[TEA6330T_SADDR_TREB 269 change = tea->regs[TEA6330T_SADDR_TREBLE] != val1; 255 bytes[0] = TEA6330T_SADDR_TREBLE; 270 bytes[0] = TEA6330T_SADDR_TREBLE; 256 bytes[1] = tea->regs[TEA6330T_SADDR_TR 271 bytes[1] = tea->regs[TEA6330T_SADDR_TREBLE] = val1; 257 err = snd_i2c_sendbytes(tea->device, b !! 272 if ((err = snd_i2c_sendbytes(tea->device, bytes, 2)) < 0) 258 if (err < 0) << 259 change = err; 273 change = err; 260 snd_i2c_unlock(tea->bus); 274 snd_i2c_unlock(tea->bus); 261 return change; 275 return change; 262 } 276 } 263 277 264 static const struct snd_kcontrol_new snd_tea63 !! 278 static struct snd_kcontrol_new snd_tea6330t_controls[] = { 265 TEA6330T_MASTER_SWITCH("Master Playback Switch 279 TEA6330T_MASTER_SWITCH("Master Playback Switch", 0), 266 TEA6330T_MASTER_VOLUME("Master Playback Volume 280 TEA6330T_MASTER_VOLUME("Master Playback Volume", 0), 267 TEA6330T_BASS("Tone Control - Bass", 0), 281 TEA6330T_BASS("Tone Control - Bass", 0), 268 TEA6330T_TREBLE("Tone Control - Treble", 0) 282 TEA6330T_TREBLE("Tone Control - Treble", 0) 269 }; 283 }; 270 284 271 static void snd_tea6330_free(struct snd_i2c_de 285 static void snd_tea6330_free(struct snd_i2c_device *device) 272 { 286 { 273 kfree(device->private_data); 287 kfree(device->private_data); 274 } 288 } 275 289 276 int snd_tea6330t_update_mixer(struct snd_card 290 int snd_tea6330t_update_mixer(struct snd_card *card, 277 struct snd_i2c_b 291 struct snd_i2c_bus *bus, 278 int equalizer, i 292 int equalizer, int fader) 279 { 293 { 280 struct snd_i2c_device *device; 294 struct snd_i2c_device *device; 281 struct tea6330t *tea; 295 struct tea6330t *tea; 282 const struct snd_kcontrol_new *knew; !! 296 struct snd_kcontrol_new *knew; 283 unsigned int idx; 297 unsigned int idx; 284 int err; !! 298 int err = -ENOMEM; 285 u8 default_treble, default_bass; 299 u8 default_treble, default_bass; 286 unsigned char bytes[7]; 300 unsigned char bytes[7]; 287 301 288 tea = kzalloc(sizeof(*tea), GFP_KERNEL 302 tea = kzalloc(sizeof(*tea), GFP_KERNEL); 289 if (tea == NULL) 303 if (tea == NULL) 290 return -ENOMEM; 304 return -ENOMEM; 291 err = snd_i2c_device_create(bus, "TEA6 !! 305 if ((err = snd_i2c_device_create(bus, "TEA6330T", TEA6330T_ADDR, &device)) < 0) { 292 if (err < 0) { << 293 kfree(tea); 306 kfree(tea); 294 return err; 307 return err; 295 } 308 } 296 tea->device = device; 309 tea->device = device; 297 tea->bus = bus; 310 tea->bus = bus; 298 tea->equalizer = equalizer; 311 tea->equalizer = equalizer; 299 tea->fader = fader; 312 tea->fader = fader; 300 device->private_data = tea; 313 device->private_data = tea; 301 device->private_free = snd_tea6330_fre 314 device->private_free = snd_tea6330_free; 302 315 303 snd_i2c_lock(bus); 316 snd_i2c_lock(bus); 304 317 305 /* turn fader off and handle equalizer 318 /* turn fader off and handle equalizer */ 306 tea->regs[TEA6330T_SADDR_FADER] = 0x3f 319 tea->regs[TEA6330T_SADDR_FADER] = 0x3f; 307 tea->regs[TEA6330T_SADDR_AUDIO_SWITCH] 320 tea->regs[TEA6330T_SADDR_AUDIO_SWITCH] = equalizer ? 0 : TEA6330T_EQN; 308 /* initialize mixer */ 321 /* initialize mixer */ 309 if (!tea->equalizer) { 322 if (!tea->equalizer) { 310 tea->max_bass = 9; 323 tea->max_bass = 9; 311 tea->max_treble = 8; 324 tea->max_treble = 8; 312 default_bass = 3 + 4; 325 default_bass = 3 + 4; 313 tea->bass = 4; 326 tea->bass = 4; 314 default_treble = 3 + 4; 327 default_treble = 3 + 4; 315 tea->treble = 4; 328 tea->treble = 4; 316 } else { 329 } else { 317 tea->max_bass = 5; 330 tea->max_bass = 5; 318 tea->max_treble = 0; 331 tea->max_treble = 0; 319 default_bass = 7 + 4; 332 default_bass = 7 + 4; 320 tea->bass = 4; 333 tea->bass = 4; 321 default_treble = 3; 334 default_treble = 3; 322 tea->treble = 0; 335 tea->treble = 0; 323 } 336 } 324 tea->mleft = tea->mright = 0x14; 337 tea->mleft = tea->mright = 0x14; 325 tea->regs[TEA6330T_SADDR_BASS] = defau 338 tea->regs[TEA6330T_SADDR_BASS] = default_bass; 326 tea->regs[TEA6330T_SADDR_TREBLE] = def 339 tea->regs[TEA6330T_SADDR_TREBLE] = default_treble; 327 340 328 /* compose I2C message and put the har 341 /* compose I2C message and put the hardware to initial state */ 329 bytes[0] = TEA6330T_SADDR_VOLUME_LEFT; 342 bytes[0] = TEA6330T_SADDR_VOLUME_LEFT; 330 for (idx = 0; idx < 6; idx++) 343 for (idx = 0; idx < 6; idx++) 331 bytes[idx+1] = tea->regs[idx]; 344 bytes[idx+1] = tea->regs[idx]; 332 err = snd_i2c_sendbytes(device, bytes, !! 345 if ((err = snd_i2c_sendbytes(device, bytes, 7)) < 0) 333 if (err < 0) << 334 goto __error; 346 goto __error; 335 347 336 strcat(card->mixername, ",TEA6330T"); 348 strcat(card->mixername, ",TEA6330T"); 337 err = snd_component_add(card, "TEA6330 !! 349 if ((err = snd_component_add(card, "TEA6330T")) < 0) 338 if (err < 0) << 339 goto __error; 350 goto __error; 340 351 341 for (idx = 0; idx < ARRAY_SIZE(snd_tea 352 for (idx = 0; idx < ARRAY_SIZE(snd_tea6330t_controls); idx++) { 342 knew = &snd_tea6330t_controls[ 353 knew = &snd_tea6330t_controls[idx]; 343 if (tea->treble == 0 && !strcm 354 if (tea->treble == 0 && !strcmp(knew->name, "Tone Control - Treble")) 344 continue; 355 continue; 345 err = snd_ctl_add(card, snd_ct !! 356 if ((err = snd_ctl_add(card, snd_ctl_new1(knew, tea))) < 0) 346 if (err < 0) << 347 goto __error; 357 goto __error; 348 } 358 } 349 359 350 snd_i2c_unlock(bus); 360 snd_i2c_unlock(bus); 351 return 0; 361 return 0; 352 362 353 __error: 363 __error: 354 snd_i2c_unlock(bus); 364 snd_i2c_unlock(bus); 355 snd_i2c_device_free(device); 365 snd_i2c_device_free(device); 356 return err; 366 return err; 357 } 367 } 358 368 359 EXPORT_SYMBOL(snd_tea6330t_detect); 369 EXPORT_SYMBOL(snd_tea6330t_detect); 360 EXPORT_SYMBOL(snd_tea6330t_update_mixer); 370 EXPORT_SYMBOL(snd_tea6330t_update_mixer); 361 371
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.