~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/i2c/tea6330t.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /sound/i2c/tea6330t.c (Version linux-6.12-rc7) and /sound/i2c/tea6330t.c (Version linux-6.11.7)


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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php