2 * programming the msp34* sound processor family
4 * (c) 1997-2001 Gerd Knorr <kraxel@bytesex.org>
6 * what works and what doesn't:
9 * Support for Hauppauge cards added (decoding handled by tuner) added by
10 * Frederic Crozat <fcrozat@mail.dotcom.fr>
13 * should work. The stereo modes are backward compatible to FM-mono,
14 * therefore FM-Mono should be allways available.
16 * FM-Stereo (B/G, used in germany)
17 * should work, with autodetect
19 * FM-Stereo (satellite)
20 * should work, no autodetect (i.e. default is mono, but you can
21 * switch to stereo -- untested)
23 * NICAM (B/G, L , used in UK, Scandinavia, Spain and France)
24 * should work, with autodetect. Support for NICAM was added by
25 * Pekka Pietikainen <pp@netppl.fi>
29 * - better SAT support
32 * 980623 Thomas Sailer (sailer@ife.ee.ethz.ch)
33 * using soundcore instead of OSS
37 #include <linux/config.h>
38 #include <linux/module.h>
39 #include <linux/kernel.h>
40 #include <linux/sched.h>
41 #include <linux/string.h>
42 #include <linux/timer.h>
43 #include <linux/delay.h>
44 #include <linux/errno.h>
45 #include <linux/slab.h>
46 #include <linux/i2c.h>
47 #include <linux/videodev.h>
48 #include <asm/semaphore.h>
49 #include <linux/init.h>
52 #include <asm/pgtable.h>
53 #include <linux/smp_lock.h>
56 #define __KERNEL_SYSCALLS__
57 #include <linux/unistd.h>
59 #include "audiochip.h"
62 /* Addresses to scan */
63 static unsigned short normal_i2c[] = {I2C_CLIENT_END};
64 static unsigned short normal_i2c_range[] = {0x40,0x40,I2C_CLIENT_END};
67 /* insmod parameters */
68 static int debug = 0; /* debug output */
69 static int once = 0; /* no continous stereo monitoring */
70 static int amsound = 0; /* hard-wire AM sound at 6.5 Hz (france),
71 the autoscan seems work well only with FM... */
72 static int simple = -1; /* use short programming (>= msp3410 only) */
75 #define DFP_COUNT 0x41
76 static const int bl_dfp[] = {
77 0x00, 0x01, 0x02, 0x03, 0x06, 0x08, 0x09, 0x0a,
78 0x0b, 0x0d, 0x0e, 0x10
89 int main, second; /* sound carrier */
93 int left, right; /* volume */
96 /* shadow register set */
97 int dfp_regs[DFP_COUNT];
100 struct task_struct *thread;
101 wait_queue_head_t wq;
103 struct semaphore *notify;
104 int active,restart,rmmod;
107 struct timer_list wake_stereo;
110 #define MSP3400_MAX 4
111 static struct i2c_client *msps[MSP3400_MAX];
113 #define VIDEO_MODE_RADIO 16 /* norm magic for radio mode */
115 /* ---------------------------------------------------------------------- */
117 #define dprintk if (debug) printk
119 MODULE_PARM(once,"i");
120 MODULE_PARM(debug,"i");
121 MODULE_PARM(simple,"i");
122 MODULE_PARM(amsound,"i");
123 MODULE_PARM(dolby,"i");
125 MODULE_DESCRIPTION("device driver for msp34xx TV sound processor");
126 MODULE_AUTHOR("Gerd Knorr");
127 MODULE_LICENSE("GPL");
129 /* ---------------------------------------------------------------------- */
131 #define I2C_MSP3400C 0x80
132 #define I2C_MSP3400C_DEM 0x10
133 #define I2C_MSP3400C_DFP 0x12
135 /* ----------------------------------------------------------------------- */
136 /* functions for talking to the MSP3400C Sound processor */
138 #ifndef I2C_M_IGNORE_NAK
139 # define I2C_M_IGNORE_NAK 0x1000
142 static int msp3400c_reset(struct i2c_client *client)
144 /* reset and read revision code */
145 static char reset_off[3] = { 0x00, 0x80, 0x00 };
146 static char reset_on[3] = { 0x00, 0x00, 0x00 };
147 static char write[3] = { I2C_MSP3400C_DFP + 1, 0x00, 0x1e };
149 struct i2c_msg reset[2] = {
150 { client->addr, I2C_M_IGNORE_NAK, 3, reset_off },
151 { client->addr, I2C_M_IGNORE_NAK, 3, reset_on },
153 struct i2c_msg test[2] = {
154 { client->addr, 0, 3, write },
155 { client->addr, I2C_M_RD, 2, read },
158 if ( (1 != i2c_transfer(client->adapter,&reset[0],1)) ||
159 (1 != i2c_transfer(client->adapter,&reset[1],1)) ||
160 (2 != i2c_transfer(client->adapter,test,2)) ) {
161 printk(KERN_ERR "msp3400: chip reset failed\n");
168 msp3400c_read(struct i2c_client *client, int dev, int addr)
172 unsigned char write[3];
173 unsigned char read[2];
174 struct i2c_msg msgs[2] = {
175 { client->addr, 0, 3, write },
176 { client->addr, I2C_M_RD, 2, read }
179 write[1] = addr >> 8;
180 write[2] = addr & 0xff;
182 for (err = 0; err < 3;) {
183 if (2 == i2c_transfer(client->adapter,msgs,2))
186 printk(KERN_WARNING "msp34xx: I/O error #%d (read 0x%02x/0x%02x)\n",
188 current->state = TASK_INTERRUPTIBLE;
189 schedule_timeout(HZ/10);
192 printk(KERN_WARNING "msp34xx: giving up, reseting chip. Sound will go off, sorry folks :-|\n");
193 msp3400c_reset(client);
196 return read[0] << 8 | read[1];
200 msp3400c_write(struct i2c_client *client, int dev, int addr, int val)
203 unsigned char buffer[5];
206 buffer[1] = addr >> 8;
207 buffer[2] = addr & 0xff;
208 buffer[3] = val >> 8;
209 buffer[4] = val & 0xff;
211 for (err = 0; err < 3;) {
212 if (5 == i2c_master_send(client, buffer, 5))
215 printk(KERN_WARNING "msp34xx: I/O error #%d (write 0x%02x/0x%02x)\n",
217 current->state = TASK_INTERRUPTIBLE;
218 schedule_timeout(HZ/10);
221 printk(KERN_WARNING "msp34xx: giving up, reseting chip. Sound will go off, sorry folks :-|\n");
222 msp3400c_reset(client);
228 /* ------------------------------------------------------------------------ */
230 /* This macro is allowed for *constants* only, gcc must calculate it
231 at compile time. Remember -- no floats in kernel mode */
232 #define MSP_CARRIER(freq) ((int)((float)(freq/18.432)*(1<<24)))
234 #define MSP_MODE_AM_DETECT 0
235 #define MSP_MODE_FM_RADIO 2
236 #define MSP_MODE_FM_TERRA 3
237 #define MSP_MODE_FM_SAT 4
238 #define MSP_MODE_FM_NICAM1 5
239 #define MSP_MODE_FM_NICAM2 6
240 #define MSP_MODE_AM_NICAM 7
241 #define MSP_MODE_BTSC 8
242 #define MSP_MODE_EXTERN 9
244 static struct MSP_INIT_DATA_DEM {
253 } msp_init_data[] = {
254 /* AM (for carrier detect / msp3400) */
255 { { 75, 19, 36, 35, 39, 40 }, { 75, 19, 36, 35, 39, 40 },
256 MSP_CARRIER(5.5), MSP_CARRIER(5.5),
257 0x00d0, 0x0500, 0x0020, 0x3000},
259 /* AM (for carrier detect / msp3410) */
260 { { -1, -1, -8, 2, 59, 126 }, { -1, -1, -8, 2, 59, 126 },
261 MSP_CARRIER(5.5), MSP_CARRIER(5.5),
262 0x00d0, 0x0100, 0x0020, 0x3000},
265 { { -8, -8, 4, 6, 78, 107 }, { -8, -8, 4, 6, 78, 107 },
266 MSP_CARRIER(10.7), MSP_CARRIER(10.7),
267 0x00d0, 0x0480, 0x0020, 0x3000 },
269 /* Terrestial FM-mono + FM-stereo */
270 { { 3, 18, 27, 48, 66, 72 }, { 3, 18, 27, 48, 66, 72 },
271 MSP_CARRIER(5.5), MSP_CARRIER(5.5),
272 0x00d0, 0x0480, 0x0030, 0x3000},
275 { { 1, 9, 14, 24, 33, 37 }, { 3, 18, 27, 48, 66, 72 },
276 MSP_CARRIER(6.5), MSP_CARRIER(6.5),
277 0x00c6, 0x0480, 0x0000, 0x3000},
279 /* NICAM/FM -- B/G (5.5/5.85), D/K (6.5/5.85) */
280 { { -2, -8, -10, 10, 50, 86 }, { 3, 18, 27, 48, 66, 72 },
281 MSP_CARRIER(5.5), MSP_CARRIER(5.5),
282 0x00d0, 0x0040, 0x0120, 0x3000},
284 /* NICAM/FM -- I (6.0/6.552) */
285 { { 2, 4, -6, -4, 40, 94 }, { 3, 18, 27, 48, 66, 72 },
286 MSP_CARRIER(6.0), MSP_CARRIER(6.0),
287 0x00d0, 0x0040, 0x0120, 0x3000},
289 /* NICAM/AM -- L (6.5/5.85) */
290 { { -2, -8, -10, 10, 50, 86 }, { -4, -12, -9, 23, 79, 126 },
291 MSP_CARRIER(6.5), MSP_CARRIER(6.5),
292 0x00c6, 0x0140, 0x0120, 0x7c03},
295 struct CARRIER_DETECT {
300 static struct CARRIER_DETECT carrier_detect_main[] = {
302 { MSP_CARRIER(4.5), "4.5 NTSC" },
303 { MSP_CARRIER(5.5), "5.5 PAL B/G" },
304 { MSP_CARRIER(6.0), "6.0 PAL I" },
305 { MSP_CARRIER(6.5), "6.5 PAL D/K + SAT + SECAM" }
308 static struct CARRIER_DETECT carrier_detect_55[] = {
310 { MSP_CARRIER(5.7421875), "5.742 PAL B/G FM-stereo" },
311 { MSP_CARRIER(5.85), "5.85 PAL B/G NICAM" }
314 static struct CARRIER_DETECT carrier_detect_65[] = {
315 /* PAL SAT / SECAM */
316 { MSP_CARRIER(5.85), "5.85 PAL D/K + SECAM NICAM" },
317 { MSP_CARRIER(6.2578125), "6.25 PAL D/K1 FM-stereo" },
318 { MSP_CARRIER(6.7421875), "6.74 PAL D/K2 FM-stereo" },
319 { MSP_CARRIER(7.02), "7.02 PAL SAT FM-stereo s/b" },
320 { MSP_CARRIER(7.20), "7.20 PAL SAT FM-stereo s" },
321 { MSP_CARRIER(7.38), "7.38 PAL SAT FM-stereo b" },
324 #define CARRIER_COUNT(x) (sizeof(x)/sizeof(struct CARRIER_DETECT))
326 /* ----------------------------------------------------------------------- */
331 #define SCART_IN1_DA 3
332 #define SCART_IN2_DA 4
338 static int scarts[3][9] = {
339 /* MASK IN1 IN2 IN1_DA IN2_DA IN3 IN4 MONO MUTE */
340 { 0x0320, 0x0000, 0x0200, -1, -1, 0x0300, 0x0020, 0x0100, 0x0320 },
341 { 0x0c40, 0x0440, 0x0400, 0x0c00, 0x0040, 0x0000, 0x0840, 0x0800, 0x0c40 },
342 { 0x3080, 0x1000, 0x1080, 0x0000, 0x0080, 0x2080, 0x3080, 0x2000, 0x3000 },
345 static char *scart_names[] = {
346 "mask", "in1", "in2", "in1 da", "in2 da", "in3", "in4", "mono", "mute"
350 msp3400c_set_scart(struct i2c_client *client, int in, int out)
352 struct msp3400c *msp = client->data;
354 if (-1 == scarts[out][in])
357 dprintk("msp34xx: scart switch: %s => %d\n",scart_names[in],out);
358 msp->acb &= ~scarts[out][SCART_MASK];
359 msp->acb |= scarts[out][in];
360 msp3400c_write(client,I2C_MSP3400C_DFP, 0x0013, msp->acb);
363 /* ------------------------------------------------------------------------ */
365 static void msp3400c_setcarrier(struct i2c_client *client, int cdo1, int cdo2)
367 msp3400c_write(client,I2C_MSP3400C_DEM, 0x0093, cdo1 & 0xfff);
368 msp3400c_write(client,I2C_MSP3400C_DEM, 0x009b, cdo1 >> 12);
369 msp3400c_write(client,I2C_MSP3400C_DEM, 0x00a3, cdo2 & 0xfff);
370 msp3400c_write(client,I2C_MSP3400C_DEM, 0x00ab, cdo2 >> 12);
371 msp3400c_write(client,I2C_MSP3400C_DEM, 0x0056, 0); /*LOAD_REG_1/2*/
374 static void msp3400c_setvolume(struct i2c_client *client,
375 int muted, int left, int right)
377 int vol = 0,val = 0,balance = 0;
380 vol = (left > right) ? left : right;
381 val = (vol * 0x73 / 65535) << 8;
384 balance = ((right-left) * 127) / vol;
387 dprintk("msp34xx: setvolume: mute=%s %d:%d v=0x%02x b=0x%02x\n",
388 muted ? "on" : "off", left, right, val>>8, balance);
389 msp3400c_write(client,I2C_MSP3400C_DFP, 0x0000, val); /* loudspeaker */
390 msp3400c_write(client,I2C_MSP3400C_DFP, 0x0006, val); /* headphones */
391 /* scart - on/off only */
392 msp3400c_write(client,I2C_MSP3400C_DFP, 0x0007, val ? 0x4000 : 0);
393 msp3400c_write(client,I2C_MSP3400C_DFP, 0x0001, balance << 8);
396 static void msp3400c_setbass(struct i2c_client *client, int bass)
398 int val = ((bass-32768) * 0x60 / 65535) << 8;
400 dprintk("msp34xx: setbass: %d 0x%02x\n",bass, val>>8);
401 msp3400c_write(client,I2C_MSP3400C_DFP, 0x0002, val); /* loudspeaker */
404 static void msp3400c_settreble(struct i2c_client *client, int treble)
406 int val = ((treble-32768) * 0x60 / 65535) << 8;
408 dprintk("msp34xx: settreble: %d 0x%02x\n",treble, val>>8);
409 msp3400c_write(client,I2C_MSP3400C_DFP, 0x0003, val); /* loudspeaker */
412 static void msp3400c_setmode(struct i2c_client *client, int type)
414 struct msp3400c *msp = client->data;
417 dprintk("msp3400: setmode: %d\n",type);
419 msp->stereo = VIDEO_SOUND_MONO;
421 msp3400c_write(client,I2C_MSP3400C_DEM, 0x00bb, /* ad_cv */
422 msp_init_data[type].ad_cv);
424 for (i = 5; i >= 0; i--) /* fir 1 */
425 msp3400c_write(client,I2C_MSP3400C_DEM, 0x0001,
426 msp_init_data[type].fir1[i]);
428 msp3400c_write(client,I2C_MSP3400C_DEM, 0x0005, 0x0004); /* fir 2 */
429 msp3400c_write(client,I2C_MSP3400C_DEM, 0x0005, 0x0040);
430 msp3400c_write(client,I2C_MSP3400C_DEM, 0x0005, 0x0000);
431 for (i = 5; i >= 0; i--)
432 msp3400c_write(client,I2C_MSP3400C_DEM, 0x0005,
433 msp_init_data[type].fir2[i]);
435 msp3400c_write(client,I2C_MSP3400C_DEM, 0x0083, /* MODE_REG */
436 msp_init_data[type].mode_reg);
438 msp3400c_setcarrier(client, msp_init_data[type].cdo1,
439 msp_init_data[type].cdo2);
441 msp3400c_write(client,I2C_MSP3400C_DEM, 0x0056, 0); /*LOAD_REG_1/2*/
444 msp3400c_write(client,I2C_MSP3400C_DFP, 0x0008,
446 msp3400c_write(client,I2C_MSP3400C_DFP, 0x0009,
448 msp3400c_write(client,I2C_MSP3400C_DFP, 0x000b,
449 msp_init_data[type].dfp_src);
451 msp3400c_write(client,I2C_MSP3400C_DFP, 0x0008,
452 msp_init_data[type].dfp_src);
453 msp3400c_write(client,I2C_MSP3400C_DFP, 0x0009,
454 msp_init_data[type].dfp_src);
455 msp3400c_write(client,I2C_MSP3400C_DFP, 0x000b,
456 msp_init_data[type].dfp_src);
458 msp3400c_write(client,I2C_MSP3400C_DFP, 0x000a,
459 msp_init_data[type].dfp_src);
460 msp3400c_write(client,I2C_MSP3400C_DFP, 0x000e,
461 msp_init_data[type].dfp_matrix);
465 msp3400c_write(client,I2C_MSP3400C_DFP, 0x0010, 0x5a00); /* was: 0x3000 */
469 /* turn on/off nicam + stereo */
470 static void msp3400c_setstereo(struct i2c_client *client, int mode)
472 static char *strmode[] = { "0", "mono", "stereo", "3",
473 "lang1", "5", "6", "7", "lang2" };
474 struct msp3400c *msp = client->data;
475 int nicam=0; /* channel source: FM/AM or nicam */
478 /* switch demodulator */
480 case MSP_MODE_FM_TERRA:
481 dprintk("msp3400: FM setstereo: %s\n",strmode[mode]);
482 msp3400c_setcarrier(client,msp->second,msp->main);
484 case VIDEO_SOUND_STEREO:
485 msp3400c_write(client,I2C_MSP3400C_DFP, 0x000e, 0x3001);
487 case VIDEO_SOUND_MONO:
488 case VIDEO_SOUND_LANG1:
489 case VIDEO_SOUND_LANG2:
490 msp3400c_write(client,I2C_MSP3400C_DFP, 0x000e, 0x3000);
494 case MSP_MODE_FM_SAT:
495 dprintk("msp3400: SAT setstereo: %s\n",strmode[mode]);
497 case VIDEO_SOUND_MONO:
498 msp3400c_setcarrier(client, MSP_CARRIER(6.5), MSP_CARRIER(6.5));
500 case VIDEO_SOUND_STEREO:
501 msp3400c_setcarrier(client, MSP_CARRIER(7.2), MSP_CARRIER(7.02));
503 case VIDEO_SOUND_LANG1:
504 msp3400c_setcarrier(client, MSP_CARRIER(7.38), MSP_CARRIER(7.02));
506 case VIDEO_SOUND_LANG2:
507 msp3400c_setcarrier(client, MSP_CARRIER(7.38), MSP_CARRIER(7.02));
511 case MSP_MODE_FM_NICAM1:
512 case MSP_MODE_FM_NICAM2:
513 case MSP_MODE_AM_NICAM:
514 dprintk("msp3400: NICAM setstereo: %s\n",strmode[mode]);
515 msp3400c_setcarrier(client,msp->second,msp->main);
520 dprintk("msp3400: BTSC setstereo: %s\n",strmode[mode]);
523 case MSP_MODE_EXTERN:
524 dprintk("msp3400: extern setstereo: %s\n",strmode[mode]);
527 case MSP_MODE_FM_RADIO:
528 dprintk("msp3400: FM-Radio setstereo: %s\n",strmode[mode]);
531 dprintk("msp3400: mono setstereo\n");
537 case VIDEO_SOUND_STEREO:
538 src = 0x0020 | nicam;
541 msp3400c_write(client,I2C_MSP3400C_DFP, 0x0005,0x4000);
544 case VIDEO_SOUND_MONO:
545 if (msp->mode == MSP_MODE_AM_NICAM) {
546 dprintk("msp3400: switching to AM mono\n");
547 /* AM mono decoding is handled by tuner, not MSP chip */
548 /* SCART switching control register */
549 msp3400c_set_scart(client,SCART_MONO,0);
553 case VIDEO_SOUND_LANG1:
554 src = 0x0000 | nicam;
556 case VIDEO_SOUND_LANG2:
557 src = 0x0010 | nicam;
560 dprintk("msp3400: setstereo final source/matrix = 0x%x\n", src);
563 msp3400c_write(client,I2C_MSP3400C_DFP, 0x0008,0x0520);
564 msp3400c_write(client,I2C_MSP3400C_DFP, 0x0009,0x0620);
565 msp3400c_write(client,I2C_MSP3400C_DFP, 0x000a,src);
566 msp3400c_write(client,I2C_MSP3400C_DFP, 0x000b,src);
568 msp3400c_write(client,I2C_MSP3400C_DFP, 0x0008,src);
569 msp3400c_write(client,I2C_MSP3400C_DFP, 0x0009,src);
570 msp3400c_write(client,I2C_MSP3400C_DFP, 0x000a,src);
571 msp3400c_write(client,I2C_MSP3400C_DFP, 0x000b,src);
576 msp3400c_print_mode(struct msp3400c *msp)
578 if (msp->main == msp->second) {
579 printk("msp3400: mono sound carrier: %d.%03d MHz\n",
580 msp->main/910000,(msp->main/910)%1000);
582 printk("msp3400: main sound carrier: %d.%03d MHz\n",
583 msp->main/910000,(msp->main/910)%1000);
585 if (msp->mode == MSP_MODE_FM_NICAM1 ||
586 msp->mode == MSP_MODE_FM_NICAM2)
587 printk("msp3400: NICAM/FM carrier : %d.%03d MHz\n",
588 msp->second/910000,(msp->second/910)%1000);
589 if (msp->mode == MSP_MODE_AM_NICAM)
590 printk("msp3400: NICAM/AM carrier : %d.%03d MHz\n",
591 msp->second/910000,(msp->second/910)%1000);
592 if (msp->mode == MSP_MODE_FM_TERRA &&
593 msp->main != msp->second) {
594 printk("msp3400: FM-stereo carrier : %d.%03d MHz\n",
595 msp->second/910000,(msp->second/910)%1000);
600 msp3400c_restore_dfp(struct i2c_client *client)
602 struct msp3400c *msp = client->data;
605 for (i = 0; i < DFP_COUNT; i++) {
606 if (-1 == msp->dfp_regs[i])
608 msp3400c_write(client,I2C_MSP3400C_DFP, i, msp->dfp_regs[i]);
612 /* ----------------------------------------------------------------------- */
614 struct REGISTER_DUMP {
619 struct REGISTER_DUMP d1[] = {
620 { 0x007e, "autodetect" },
621 { 0x0023, "C_AD_BITS " },
622 { 0x0038, "ADD_BITS " },
623 { 0x003e, "CIB_BITS " },
624 { 0x0057, "ERROR_RATE" },
628 autodetect_stereo(struct i2c_client *client)
630 struct msp3400c *msp = client->data;
632 int newstereo = msp->stereo;
633 int newnicam = msp->nicam_on;
637 case MSP_MODE_FM_TERRA:
638 val = msp3400c_read(client, I2C_MSP3400C_DFP, 0x18);
641 dprintk("msp34xx: stereo detect register: %d\n",val);
644 newstereo = VIDEO_SOUND_STEREO | VIDEO_SOUND_MONO;
645 } else if (val < -4096) {
646 newstereo = VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
648 newstereo = VIDEO_SOUND_MONO;
652 case MSP_MODE_FM_NICAM1:
653 case MSP_MODE_FM_NICAM2:
654 case MSP_MODE_AM_NICAM:
655 val = msp3400c_read(client, I2C_MSP3400C_DEM, 0x23);
656 dprintk("msp34xx: nicam sync=%d, mode=%d\n",val & 1, (val & 0x1e) >> 1);
660 switch ((val & 0x1e) >> 1) {
663 newstereo = VIDEO_SOUND_STEREO;
667 newstereo = VIDEO_SOUND_MONO
672 newstereo = VIDEO_SOUND_MONO
677 newstereo = VIDEO_SOUND_MONO;
683 newstereo = VIDEO_SOUND_MONO;
687 val = msp3400c_read(client, I2C_MSP3400C_DEM, 0x200);
688 dprintk("msp3410: status=0x%x (pri=%s, sec=%s, %s%s%s)\n",
690 (val & 0x0002) ? "no" : "yes",
691 (val & 0x0004) ? "no" : "yes",
692 (val & 0x0040) ? "stereo" : "mono",
693 (val & 0x0080) ? ", nicam 2nd mono" : "",
694 (val & 0x0100) ? ", bilingual/SAP" : "");
695 newstereo = VIDEO_SOUND_MONO;
696 if (val & 0x0040) newstereo |= VIDEO_SOUND_STEREO;
697 if (val & 0x0100) newstereo |= VIDEO_SOUND_LANG1;
700 if (newstereo != msp->stereo) {
702 dprintk("msp34xx: watch: stereo %d => %d\n",
703 msp->stereo,newstereo);
704 msp->stereo = newstereo;
706 if (newnicam != msp->nicam_on) {
708 dprintk("msp34xx: watch: nicam %d => %d\n",
709 msp->nicam_on,newnicam);
710 msp->nicam_on = newnicam;
716 * A kernel thread for msp3400 control -- we don't want to block the
717 * in the ioctl while doing the sound carrier & stereo detect
720 static void msp3400c_stereo_wake(unsigned long data)
722 struct msp3400c *msp = (struct msp3400c*)data; /* XXX alpha ??? */
724 wake_up_interruptible(&msp->wq);
727 /* stereo/multilang monitoring */
728 static void watch_stereo(struct i2c_client *client)
730 struct msp3400c *msp = client->data;
732 if (autodetect_stereo(client)) {
733 if (msp->stereo & VIDEO_SOUND_STEREO)
734 msp3400c_setstereo(client,VIDEO_SOUND_STEREO);
735 else if (msp->stereo & VIDEO_SOUND_LANG1)
736 msp3400c_setstereo(client,VIDEO_SOUND_LANG1);
738 msp3400c_setstereo(client,VIDEO_SOUND_MONO);
741 msp->watch_stereo = 0;
742 if (msp->watch_stereo)
743 mod_timer(&msp->wake_stereo, jiffies+5*HZ);
746 static int msp3400c_thread(void *data)
748 struct i2c_client *client = data;
749 struct msp3400c *msp = client->data;
751 struct CARRIER_DETECT *cd;
752 int count, max1,max2,val1,val2, val,this;
759 sigfillset(¤t->blocked);
760 strcpy(current->comm,"msp3400");
762 msp->thread = current;
768 printk("msp3400: daemon started\n");
769 if(msp->notify != NULL)
776 printk("msp3400: thread: sleep\n");
777 interruptible_sleep_on(&msp->wq);
779 printk("msp3400: thread: wakeup\n");
780 if (msp->rmmod || signal_pending(current))
783 if (VIDEO_MODE_RADIO == msp->norm ||
784 MSP_MODE_EXTERN == msp->mode)
785 continue; /* nothing to do */
789 if (msp->watch_stereo) {
790 watch_stereo(client);
795 /* some time for the tuner to sync */
796 current->state = TASK_INTERRUPTIBLE;
797 schedule_timeout(HZ/5);
798 if (signal_pending(current))
802 if (VIDEO_MODE_RADIO == msp->norm ||
803 MSP_MODE_EXTERN == msp->mode)
804 continue; /* nothing to do */
806 msp3400c_setvolume(client, msp->muted, 0, 0);
807 msp3400c_setmode(client, MSP_MODE_AM_DETECT /* +1 */ );
810 del_timer(&msp->wake_stereo);
811 msp->watch_stereo = 0;
813 /* carrier detect pass #1 -- main carrier */
814 cd = carrier_detect_main; count = CARRIER_COUNT(carrier_detect_main);
816 if (amsound && (msp->norm == VIDEO_MODE_SECAM)) {
817 /* autodetect doesn't work well with AM ... */
820 dprintk("msp3400: AM sound override\n");
823 for (this = 0; this < count; this++) {
824 msp3400c_setcarrier(client, cd[this].cdo,cd[this].cdo);
826 current->state = TASK_INTERRUPTIBLE;
827 schedule_timeout(HZ/10);
828 if (signal_pending(current))
833 val = msp3400c_read(client, I2C_MSP3400C_DFP, 0x1b);
837 val1 = val, max1 = this;
838 dprintk("msp3400: carrier1 val: %5d / %s\n", val,cd[this].name);
841 /* carrier detect pass #2 -- second (stereo) carrier */
844 cd = carrier_detect_55; count = CARRIER_COUNT(carrier_detect_55);
847 cd = carrier_detect_65; count = CARRIER_COUNT(carrier_detect_65);
852 cd = NULL; count = 0;
856 if (amsound && (msp->norm == VIDEO_MODE_SECAM)) {
857 /* autodetect doesn't work well with AM ... */
858 cd = NULL; count = 0; max2 = 0;
860 for (this = 0; this < count; this++) {
861 msp3400c_setcarrier(client, cd[this].cdo,cd[this].cdo);
863 current->state = TASK_INTERRUPTIBLE;
864 schedule_timeout(HZ/10);
865 if (signal_pending(current))
870 val = msp3400c_read(client, I2C_MSP3400C_DFP, 0x1b);
874 val2 = val, max2 = this;
875 dprintk("msp3400: carrier2 val: %5d / %s\n", val,cd[this].name);
878 /* programm the msp3400 according to the results */
879 msp->main = carrier_detect_main[max1].cdo;
884 msp->second = carrier_detect_55[max2].cdo;
885 msp3400c_setmode(client, MSP_MODE_FM_TERRA);
887 msp3400c_setstereo(client, VIDEO_SOUND_MONO);
888 msp->watch_stereo = 1;
889 } else if (max2 == 1 && msp->nicam) {
891 msp->second = carrier_detect_55[max2].cdo;
892 msp3400c_setmode(client, MSP_MODE_FM_NICAM1);
894 msp3400c_setcarrier(client, msp->second, msp->main);
895 msp->watch_stereo = 1;
902 msp->second = MSP_CARRIER(6.552);
903 msp3400c_setmode(client, MSP_MODE_FM_NICAM2);
905 msp3400c_setcarrier(client, msp->second, msp->main);
906 msp->watch_stereo = 1;
909 if (max2 == 1 || max2 == 2) {
911 msp->second = carrier_detect_65[max2].cdo;
912 msp3400c_setmode(client, MSP_MODE_FM_TERRA);
914 msp3400c_setstereo(client, VIDEO_SOUND_MONO);
915 msp->watch_stereo = 1;
916 } else if (max2 == 0 &&
917 msp->norm == VIDEO_MODE_SECAM) {
918 /* L NICAM or AM-mono */
919 msp->second = carrier_detect_65[max2].cdo;
920 msp3400c_setmode(client, MSP_MODE_AM_NICAM);
922 msp3400c_setstereo(client, VIDEO_SOUND_MONO);
923 msp3400c_setcarrier(client, msp->second, msp->main);
924 /* volume prescale for SCART (AM mono input) */
925 msp3400c_write(client,I2C_MSP3400C_DFP, 0x000d, 0x1900);
926 msp->watch_stereo = 1;
927 } else if (max2 == 0 && msp->nicam) {
929 msp->second = carrier_detect_65[max2].cdo;
930 msp3400c_setmode(client, MSP_MODE_FM_NICAM1);
932 msp3400c_setcarrier(client, msp->second, msp->main);
933 msp->watch_stereo = 1;
941 msp->second = carrier_detect_main[max1].cdo;
942 msp3400c_setmode(client, MSP_MODE_FM_TERRA);
944 msp3400c_setcarrier(client, msp->second, msp->main);
945 msp->stereo = VIDEO_SOUND_MONO;
946 msp3400c_setstereo(client, VIDEO_SOUND_MONO);
950 /* unmute + restore dfp registers */
951 msp3400c_setvolume(client, msp->muted, msp->left, msp->right);
952 msp3400c_restore_dfp(client);
954 if (msp->watch_stereo)
955 mod_timer(&msp->wake_stereo, jiffies+5*HZ);
958 msp3400c_print_mode(msp);
964 dprintk("msp3400: thread: exit\n");
968 if(msp->notify != NULL)
973 /* ----------------------------------------------------------------------- */
974 /* this one uses the automatic sound standard detection of newer */
975 /* msp34xx chip versions */
977 static struct MODES {
982 { 0x0000, 0, 0, "ERROR" },
983 { 0x0001, 0, 0, "autodetect start" },
984 { 0x0002, MSP_CARRIER(4.5), MSP_CARRIER(4.72), "4.5/4.72 M Dual FM-Stereo" },
985 { 0x0003, MSP_CARRIER(5.5), MSP_CARRIER(5.7421875), "5.5/5.74 B/G Dual FM-Stereo" },
986 { 0x0004, MSP_CARRIER(6.5), MSP_CARRIER(6.2578125), "6.5/6.25 D/K1 Dual FM-Stereo" },
987 { 0x0005, MSP_CARRIER(6.5), MSP_CARRIER(6.7421875), "6.5/6.74 D/K2 Dual FM-Stereo" },
988 { 0x0006, MSP_CARRIER(6.5), MSP_CARRIER(6.5), "6.5 D/K FM-Mono (HDEV3)" },
989 { 0x0008, MSP_CARRIER(5.5), MSP_CARRIER(5.85), "5.5/5.85 B/G NICAM FM" },
990 { 0x0009, MSP_CARRIER(6.5), MSP_CARRIER(5.85), "6.5/5.85 L NICAM AM" },
991 { 0x000a, MSP_CARRIER(6.0), MSP_CARRIER(6.55), "6.0/6.55 I NICAM FM" },
992 { 0x000b, MSP_CARRIER(6.5), MSP_CARRIER(5.85), "6.5/5.85 D/K NICAM FM" },
993 { 0x000c, MSP_CARRIER(6.5), MSP_CARRIER(5.85), "6.5/5.85 D/K NICAM FM (HDEV2)" },
994 { 0x0020, MSP_CARRIER(4.5), MSP_CARRIER(4.5), "4.5 M BTSC-Stereo" },
995 { 0x0021, MSP_CARRIER(4.5), MSP_CARRIER(4.5), "4.5 M BTSC-Mono + SAP" },
996 { 0x0030, MSP_CARRIER(4.5), MSP_CARRIER(4.5), "4.5 M EIA-J Japan Stereo" },
997 { 0x0040, MSP_CARRIER(10.7), MSP_CARRIER(10.7), "10.7 FM-Stereo Radio" },
998 { 0x0050, MSP_CARRIER(6.5), MSP_CARRIER(6.5), "6.5 SAT-Mono" },
999 { 0x0051, MSP_CARRIER(7.02), MSP_CARRIER(7.20), "7.02/7.20 SAT-Stereo" },
1000 { 0x0060, MSP_CARRIER(7.2), MSP_CARRIER(7.2), "7.2 SAT ADR" },
1001 { -1, 0, 0, NULL }, /* EOF */
1004 static int msp3410d_thread(void *data)
1006 struct i2c_client *client = data;
1007 struct msp3400c *msp = client->data;
1015 sigfillset(¤t->blocked);
1016 strcpy(current->comm,"msp3410 [auto]");
1018 msp->thread = current;
1024 printk("msp3410: daemon started\n");
1025 if(msp->notify != NULL)
1032 printk("msp3410: thread: sleep\n");
1033 interruptible_sleep_on(&msp->wq);
1035 printk("msp3410: thread: wakeup\n");
1036 if (msp->rmmod || signal_pending(current))
1039 if (msp->mode == MSP_MODE_EXTERN)
1044 if (msp->watch_stereo) {
1045 watch_stereo(client);
1050 /* some time for the tuner to sync */
1051 current->state = TASK_INTERRUPTIBLE;
1052 schedule_timeout(HZ/5);
1053 if (signal_pending(current))
1057 if (msp->mode == MSP_MODE_EXTERN)
1060 del_timer(&msp->wake_stereo);
1061 msp->watch_stereo = 0;
1063 /* put into sane state (and mute) */
1064 msp3400c_reset(client);
1066 /* start autodetect */
1067 switch (msp->norm) {
1068 case VIDEO_MODE_PAL:
1072 case VIDEO_MODE_NTSC: /* BTSC */
1076 case VIDEO_MODE_SECAM:
1080 case VIDEO_MODE_RADIO:
1089 msp3400c_write(client, I2C_MSP3400C_DEM, 0x30, mode);
1090 msp3400c_write(client, I2C_MSP3400C_DEM, 0x20, std);
1094 for (i = 0; modelist[i].name != NULL; i++)
1095 if (modelist[i].retval == std)
1097 printk("msp3410: setting mode: %s (0x%04x)\n",
1098 modelist[i].name ? modelist[i].name : "unknown",std);
1102 /* programmed some specific mode */
1105 /* triggered autodetect */
1107 current->state = TASK_INTERRUPTIBLE;
1108 schedule_timeout(HZ/10);
1109 if (signal_pending(current))
1115 val = msp3400c_read(client, I2C_MSP3400C_DEM, 0x7e);
1118 dprintk("msp3410: detection still in progress\n");
1121 for (i = 0; modelist[i].name != NULL; i++)
1122 if (modelist[i].retval == val)
1124 dprintk("msp3410: current mode: %s (0x%04x)\n",
1125 modelist[i].name ? modelist[i].name : "unknown",
1127 msp->main = modelist[i].main;
1128 msp->second = modelist[i].second;
1130 if (amsound && (msp->norm == VIDEO_MODE_SECAM) && (val != 0x0009)) {
1131 /* autodetection has failed, let backup */
1132 dprintk("msp3410: autodetection failed, switching to backup mode: %s (0x%04x)\n",
1133 modelist[8].name ? modelist[8].name : "unknown",val);
1135 msp3400c_write(client, I2C_MSP3400C_DEM, 0x20, val);
1138 /* set various prescales */
1139 msp3400c_write(client, I2C_MSP3400C_DFP, 0x0d, 0x1900); /* scart */
1140 msp3400c_write(client, I2C_MSP3400C_DFP, 0x0e, 0x2403); /* FM */
1141 msp3400c_write(client, I2C_MSP3400C_DFP, 0x10, 0x5a00); /* nicam */
1145 case 0x0008: /* B/G NICAM */
1146 case 0x000a: /* I NICAM */
1148 msp->mode = MSP_MODE_FM_NICAM1;
1150 msp->mode = MSP_MODE_FM_NICAM2;
1151 /* just turn on stereo */
1152 msp->stereo = VIDEO_SOUND_STEREO;
1154 msp->watch_stereo = 1;
1155 msp3400c_setstereo(client,VIDEO_SOUND_STEREO);
1158 msp->mode = MSP_MODE_AM_NICAM;
1159 msp->stereo = VIDEO_SOUND_MONO;
1161 msp3400c_setstereo(client,VIDEO_SOUND_MONO);
1162 msp->watch_stereo = 1;
1164 case 0x0020: /* BTSC */
1165 /* just turn on stereo */
1166 msp->mode = MSP_MODE_BTSC;
1167 msp->stereo = VIDEO_SOUND_STEREO;
1169 msp->watch_stereo = 1;
1170 msp3400c_setstereo(client,VIDEO_SOUND_STEREO);
1172 case 0x0040: /* FM radio */
1173 msp->mode = MSP_MODE_FM_RADIO;
1174 msp->stereo = VIDEO_SOUND_STEREO;
1176 msp->watch_stereo = 0;
1178 msp3400c_set_scart(client,SCART_IN2,0);
1179 msp3400c_write(client,I2C_MSP3400C_DFP, 0x08, 0x0220);
1180 msp3400c_write(client,I2C_MSP3400C_DFP, 0x09, 0x0220);
1181 msp3400c_write(client,I2C_MSP3400C_DFP, 0x0b, 0x0220);
1184 msp->mode = MSP_MODE_FM_TERRA;
1185 msp->stereo = VIDEO_SOUND_MONO;
1187 msp->watch_stereo = 1;
1191 /* unmute + restore dfp registers */
1192 msp3400c_setbass(client, msp->bass);
1193 msp3400c_settreble(client, msp->treble);
1194 msp3400c_setvolume(client, msp->muted, msp->left, msp->right);
1195 msp3400c_restore_dfp(client);
1197 if (msp->watch_stereo)
1198 mod_timer(&msp->wake_stereo, jiffies+HZ);
1204 dprintk("msp3410: thread: exit\n");
1208 if(msp->notify != NULL)
1213 /* ----------------------------------------------------------------------- */
1215 static int msp_attach(struct i2c_adapter *adap, int addr,
1216 unsigned short flags, int kind);
1217 static int msp_detach(struct i2c_client *client);
1218 static int msp_probe(struct i2c_adapter *adap);
1219 static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg);
1221 static struct i2c_driver driver = {
1222 .name = "i2c msp3400 driver",
1223 .id = I2C_DRIVERID_MSP3400,
1224 .flags = I2C_DF_NOTIFY,
1225 .attach_adapter = msp_probe,
1226 .detach_client = msp_detach,
1227 .command = msp_command,
1230 static struct i2c_client client_template =
1233 .flags = I2C_CLIENT_ALLOW_USE,
1237 static int msp_attach(struct i2c_adapter *adap, int addr,
1238 unsigned short flags, int kind)
1240 DECLARE_MUTEX_LOCKED(sem);
1241 struct msp3400c *msp;
1242 struct i2c_client *c;
1245 client_template.adapter = adap;
1246 client_template.addr = addr;
1248 if (-1 == msp3400c_reset(&client_template)) {
1249 dprintk("msp3400: no chip found\n");
1253 if (NULL == (c = kmalloc(sizeof(struct i2c_client),GFP_KERNEL)))
1255 memcpy(c,&client_template,sizeof(struct i2c_client));
1256 if (NULL == (msp = kmalloc(sizeof(struct msp3400c),GFP_KERNEL))) {
1261 memset(msp,0,sizeof(struct msp3400c));
1265 msp->treble = 32768;
1268 for (i = 0; i < DFP_COUNT; i++)
1269 msp->dfp_regs[i] = -1;
1272 init_waitqueue_head(&msp->wq);
1274 if (-1 == msp3400c_reset(c)) {
1277 dprintk("msp3400: no chip found\n");
1281 rev1 = msp3400c_read(c, I2C_MSP3400C_DFP, 0x1e);
1283 rev2 = msp3400c_read(c, I2C_MSP3400C_DFP, 0x1f);
1284 if ((-1 == rev1) || (0 == rev1 && 0 == rev2)) {
1287 printk("msp3400: error while reading chip version\n");
1292 /* this will turn on a 1kHz beep - might be useful for debugging... */
1293 msp3400c_write(c,I2C_MSP3400C_DFP, 0x0014, 0x1040);
1295 msp3400c_setvolume(c,msp->muted,msp->left,msp->right);
1297 sprintf(c->name,"MSP34%02d%c-%c%d",
1298 (rev2>>8)&0xff, (rev1&0xff)+'@', ((rev1>>8)&0xff)+'@', rev2&0x1f);
1299 msp->nicam = (((rev2>>8)&0xff) != 00) ? 1 : 0;
1303 /* msp->simple = (((rev2>>8)&0xff) == 0) ? 0 : 1; */
1304 msp->simple = ((rev1&0xff)+'@' > 'C');
1306 /* use insmod option */
1307 msp->simple = simple;
1310 /* timer for stereo checking */
1311 init_timer(&msp->wake_stereo);
1312 msp->wake_stereo.function = msp3400c_stereo_wake;
1313 msp->wake_stereo.data = (unsigned long)msp;
1315 /* hello world :-) */
1316 printk(KERN_INFO "msp34xx: init: chip=%s",c->name);
1318 printk(", has NICAM support");
1321 /* startup control thread */
1324 kernel_thread(msp->simple ? msp3410d_thread : msp3400c_thread,
1328 wake_up_interruptible(&msp->wq);
1330 /* update our own array */
1331 for (i = 0; i < MSP3400_MAX; i++) {
1332 if (NULL == msps[i]) {
1339 i2c_attach_client(c);
1343 static int msp_detach(struct i2c_client *client)
1345 DECLARE_MUTEX_LOCKED(sem);
1346 struct msp3400c *msp = (struct msp3400c*)client->data;
1349 /* shutdown control thread */
1350 del_timer(&msp->wake_stereo);
1355 wake_up_interruptible(&msp->wq);
1359 msp3400c_reset(client);
1361 /* update our own array */
1362 for (i = 0; i < MSP3400_MAX; i++) {
1363 if (client == msps[i]) {
1369 i2c_detach_client(client);
1376 static int msp_probe(struct i2c_adapter *adap)
1378 if (adap->id == (I2C_ALGO_BIT | I2C_HW_B_BT848))
1379 return i2c_probe(adap, &addr_data, msp_attach);
1383 static void msp_wake_thread(struct i2c_client *client)
1385 struct msp3400c *msp = (struct msp3400c*)client->data;
1387 msp3400c_setvolume(client,msp->muted,0,0);
1388 msp->watch_stereo=0;
1389 del_timer(&msp->wake_stereo);
1392 wake_up_interruptible(&msp->wq);
1395 static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
1397 struct msp3400c *msp = (struct msp3400c*)client->data;
1400 int *iarg = (int*)arg;
1405 case AUDC_SET_INPUT:
1407 - IN1 is often used for external input
1408 - Hauppauge uses IN2 for the radio */
1409 dprintk(KERN_DEBUG "msp34xx: AUDC_SET_INPUT(%d)\n",*sarg);
1410 if (*sarg == msp->input)
1415 msp->mode = MSP_MODE_FM_RADIO;
1416 msp->stereo = VIDEO_SOUND_STEREO;
1417 msp3400c_set_scart(client,SCART_IN2,0);
1418 msp3400c_write(client,I2C_MSP3400C_DFP,0x000d,0x1900);
1419 msp3400c_setstereo(client,msp->stereo);
1422 msp->mode = MSP_MODE_EXTERN;
1423 msp->stereo = VIDEO_SOUND_STEREO;
1424 msp3400c_set_scart(client,SCART_IN1,0);
1425 msp3400c_write(client,I2C_MSP3400C_DFP,0x000d,0x1900);
1426 msp3400c_setstereo(client,msp->stereo);
1430 msp_wake_thread(client);
1433 if (*sarg & AUDIO_MUTE)
1434 msp3400c_set_scart(client,SCART_MUTE,0);
1441 case AUDC_SET_RADIO:
1442 dprintk(KERN_DEBUG "msp34xx: AUDC_SET_RADIO\n");
1443 msp->norm = VIDEO_MODE_RADIO;
1444 msp->watch_stereo=0;
1445 del_timer(&msp->wake_stereo);
1446 dprintk("msp34xx: switching to radio mode\n");
1448 /* the thread will do for us */
1449 msp_wake_thread(client);
1451 /* set msp3400 to FM radio mode */
1452 msp3400c_setmode(client,MSP_MODE_FM_RADIO);
1453 msp3400c_setcarrier(client, MSP_CARRIER(10.7),MSP_CARRIER(10.7));
1454 msp3400c_setvolume(client,msp->muted,msp->left,msp->right);
1461 /* work-in-progress: hook to control the DFP registers */
1462 case MSP_SET_DFPREG:
1464 struct msp_dfpreg *r = arg;
1467 if (r->reg < 0 || r->reg >= DFP_COUNT)
1469 for (i = 0; i < sizeof(bl_dfp)/sizeof(int); i++)
1470 if (r->reg == bl_dfp[i])
1472 msp->dfp_regs[r->reg] = r->value;
1473 msp3400c_write(client,I2C_MSP3400C_DFP,r->reg,r->value);
1476 case MSP_GET_DFPREG:
1478 struct msp_dfpreg *r = arg;
1480 if (r->reg < 0 || r->reg >= DFP_COUNT)
1482 r->value = msp3400c_read(client,I2C_MSP3400C_DFP,r->reg);
1487 /* --- v4l ioctls --- */
1488 /* take care: bttv does userspace copying, we'll get a
1489 kernel pointer here... */
1492 struct video_audio *va = arg;
1494 dprintk(KERN_DEBUG "msp34xx: VIDIOCGAUDIO\n");
1495 va->flags |= VIDEO_AUDIO_VOLUME |
1497 VIDEO_AUDIO_TREBLE |
1498 VIDEO_AUDIO_MUTABLE;
1500 va->flags |= VIDEO_AUDIO_MUTE;
1501 va->volume=MAX(msp->left,msp->right);
1502 va->balance=(32768*MIN(msp->left,msp->right))/
1503 (va->volume ? va->volume : 1);
1504 va->balance=(msp->left<msp->right)?
1505 (65535-va->balance) : va->balance;
1506 if (0 == va->volume)
1507 va->balance = 32768;
1508 va->bass = msp->bass;
1509 va->treble = msp->treble;
1511 if (msp->norm != VIDEO_MODE_RADIO) {
1512 autodetect_stereo(client);
1513 va->mode = msp->stereo;
1519 struct video_audio *va = arg;
1521 dprintk(KERN_DEBUG "msp34xx: VIDIOCSAUDIO\n");
1522 msp->muted = (va->flags & VIDEO_AUDIO_MUTE);
1523 msp->left = (MIN(65536 - va->balance,32768) *
1524 va->volume) / 32768;
1525 msp->right = (MIN(va->balance,32768) *
1526 va->volume) / 32768;
1527 msp->bass = va->bass;
1528 msp->treble = va->treble;
1529 msp3400c_setvolume(client,msp->muted,msp->left,msp->right);
1530 msp3400c_setbass(client,msp->bass);
1531 msp3400c_settreble(client,msp->treble);
1533 if (va->mode != 0) {
1534 msp->watch_stereo=0;
1535 del_timer(&msp->wake_stereo);
1536 msp->stereo = va->mode;
1537 msp3400c_setstereo(client,va->mode);
1543 struct video_channel *vc = arg;
1545 dprintk(KERN_DEBUG "msp34xx: VIDIOCSCHAN\n");
1546 dprintk("msp34xx: switching to TV mode\n");
1547 msp->norm = vc->norm;
1552 /* new channel -- kick audio carrier scan */
1553 dprintk(KERN_DEBUG "msp34xx: VIDIOCSFREQ\n");
1554 msp_wake_thread(client);
1565 /* ----------------------------------------------------------------------- */
1567 static int msp3400_init_module(void)
1569 i2c_add_driver(&driver);
1573 static void msp3400_cleanup_module(void)
1575 i2c_del_driver(&driver);
1578 module_init(msp3400_init_module);
1579 module_exit(msp3400_cleanup_module);
1582 * Overrides for Emacs so that we follow Linus's tabbing style.
1583 * ---------------------------------------------------------------------------