diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2005-11-09 00:38:50 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-09 10:56:31 -0500 |
commit | 7bde80769ddf76a2c2e3672f2a932cfc029a1d35 (patch) | |
tree | 7a0884e1b79ad69f7ff01df9de6c124dd7ad47a5 /drivers | |
parent | c5d4a70ff82aab638b871debc9c8b27216cf1ecd (diff) |
[PATCH] V4L: 917: fixes some bugs in msp3400
- Adds missing msp34xxg_reset to VIDIOC_S_STD (just like VIDIOCSCHAN).
- Improves msp3400 debug messages.
Now, all kernel message in msp3400.c use the same prefix
and include the I2C bus to differentiate between multiple
msp3400 I2C chips.
- Correctly prints the chip identifier for the msp44xx chips.
- msp34xxg cleanups.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/video/msp3400.c | 301 |
1 files changed, 159 insertions, 142 deletions
diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c index 035dee4ce3f5..a23fb0338986 100644 --- a/drivers/media/video/msp3400.c +++ b/drivers/media/video/msp3400.c | |||
@@ -56,6 +56,39 @@ | |||
56 | #include <media/audiochip.h> | 56 | #include <media/audiochip.h> |
57 | #include "msp3400.h" | 57 | #include "msp3400.h" |
58 | 58 | ||
59 | #define msp3400_dbg(fmt, arg...) \ | ||
60 | do { \ | ||
61 | if (debug) \ | ||
62 | printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \ | ||
63 | i2c_adapter_id(client->adapter), client->addr , ## arg); \ | ||
64 | } while (0) | ||
65 | |||
66 | /* Medium volume debug. */ | ||
67 | #define msp3400_dbg_mediumvol(fmt, arg...) \ | ||
68 | do { \ | ||
69 | if (debug >= 2) \ | ||
70 | printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \ | ||
71 | i2c_adapter_id(client->adapter), client->addr , ## arg); \ | ||
72 | } while (0) | ||
73 | |||
74 | /* High volume debug. Use with care. */ | ||
75 | #define msp3400_dbg_highvol(fmt, arg...) \ | ||
76 | do { \ | ||
77 | if (debug >= 16) \ | ||
78 | printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \ | ||
79 | i2c_adapter_id(client->adapter), client->addr , ## arg); \ | ||
80 | } while (0) | ||
81 | |||
82 | #define msp3400_err(fmt, arg...) do { \ | ||
83 | printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->name, \ | ||
84 | i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) | ||
85 | #define msp3400_warn(fmt, arg...) do { \ | ||
86 | printk(KERN_WARNING "%s %d-%04x: " fmt, client->driver->name, \ | ||
87 | i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) | ||
88 | #define msp3400_info(fmt, arg...) do { \ | ||
89 | printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->name, \ | ||
90 | i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) | ||
91 | |||
59 | #define OPMODE_AUTO -1 | 92 | #define OPMODE_AUTO -1 |
60 | #define OPMODE_MANUAL 0 | 93 | #define OPMODE_MANUAL 0 |
61 | #define OPMODE_SIMPLE 1 /* use short programming (>= msp3410 only) */ | 94 | #define OPMODE_SIMPLE 1 /* use short programming (>= msp3410 only) */ |
@@ -125,10 +158,6 @@ struct msp3400c { | |||
125 | 158 | ||
126 | /* ---------------------------------------------------------------------- */ | 159 | /* ---------------------------------------------------------------------- */ |
127 | 160 | ||
128 | #define dprintk if (debug >= 1) printk | ||
129 | #define d2printk if (debug >= 2) printk | ||
130 | #define dprintk_trace if (debug>=16) printk | ||
131 | |||
132 | /* read-only */ | 161 | /* read-only */ |
133 | module_param(opmode, int, 0444); | 162 | module_param(opmode, int, 0444); |
134 | 163 | ||
@@ -187,11 +216,11 @@ static int msp3400c_reset(struct i2c_client *client) | |||
187 | { client->addr, I2C_M_RD, 2, read }, | 216 | { client->addr, I2C_M_RD, 2, read }, |
188 | }; | 217 | }; |
189 | 218 | ||
190 | dprintk_trace("trace: msp3400c_reset\n"); | 219 | msp3400_dbg_highvol("msp3400c_reset\n"); |
191 | if ( (1 != i2c_transfer(client->adapter,&reset[0],1)) || | 220 | if ( (1 != i2c_transfer(client->adapter,&reset[0],1)) || |
192 | (1 != i2c_transfer(client->adapter,&reset[1],1)) || | 221 | (1 != i2c_transfer(client->adapter,&reset[1],1)) || |
193 | (2 != i2c_transfer(client->adapter,test,2)) ) { | 222 | (2 != i2c_transfer(client->adapter,test,2)) ) { |
194 | printk(KERN_ERR "msp3400: chip reset failed\n"); | 223 | msp3400_err("chip reset failed\n"); |
195 | return -1; | 224 | return -1; |
196 | } | 225 | } |
197 | return 0; | 226 | return 0; |
@@ -216,21 +245,18 @@ static int msp3400c_read(struct i2c_client *client, int dev, int addr) | |||
216 | if (2 == i2c_transfer(client->adapter,msgs,2)) | 245 | if (2 == i2c_transfer(client->adapter,msgs,2)) |
217 | break; | 246 | break; |
218 | err++; | 247 | err++; |
219 | printk(KERN_WARNING | 248 | msp3400_warn("I/O error #%d (read 0x%02x/0x%02x)\n", err, |
220 | "msp34xx: I/O error #%d (read 0x%02x/0x%02x)\n", err, | ||
221 | dev, addr); | 249 | dev, addr); |
222 | current->state = TASK_INTERRUPTIBLE; | 250 | current->state = TASK_INTERRUPTIBLE; |
223 | schedule_timeout(msecs_to_jiffies(10)); | 251 | schedule_timeout(msecs_to_jiffies(10)); |
224 | } | 252 | } |
225 | if (3 == err) { | 253 | if (3 == err) { |
226 | printk(KERN_WARNING | 254 | msp3400_warn("giving up, resetting chip. Sound will go off, sorry folks :-|\n"); |
227 | "msp34xx: giving up, reseting chip. Sound will go off, sorry folks :-|\n"); | ||
228 | msp3400c_reset(client); | 255 | msp3400c_reset(client); |
229 | return -1; | 256 | return -1; |
230 | } | 257 | } |
231 | retval = read[0] << 8 | read[1]; | 258 | retval = read[0] << 8 | read[1]; |
232 | dprintk_trace("trace: msp3400c_read(0x%x, 0x%x): 0x%x\n", dev, addr, | 259 | msp3400_dbg_highvol("msp3400c_read(0x%x, 0x%x): 0x%x\n", dev, addr, retval); |
233 | retval); | ||
234 | return retval; | 260 | return retval; |
235 | } | 261 | } |
236 | 262 | ||
@@ -245,21 +271,18 @@ static int msp3400c_write(struct i2c_client *client, int dev, int addr, int val) | |||
245 | buffer[3] = val >> 8; | 271 | buffer[3] = val >> 8; |
246 | buffer[4] = val & 0xff; | 272 | buffer[4] = val & 0xff; |
247 | 273 | ||
248 | dprintk_trace("trace: msp3400c_write(0x%x, 0x%x, 0x%x)\n", dev, addr, | 274 | msp3400_dbg_highvol("msp3400c_write(0x%x, 0x%x, 0x%x)\n", dev, addr, val); |
249 | val); | ||
250 | for (err = 0; err < 3;) { | 275 | for (err = 0; err < 3;) { |
251 | if (5 == i2c_master_send(client, buffer, 5)) | 276 | if (5 == i2c_master_send(client, buffer, 5)) |
252 | break; | 277 | break; |
253 | err++; | 278 | err++; |
254 | printk(KERN_WARNING | 279 | msp3400_warn("I/O error #%d (write 0x%02x/0x%02x)\n", err, |
255 | "msp34xx: I/O error #%d (write 0x%02x/0x%02x)\n", err, | ||
256 | dev, addr); | 280 | dev, addr); |
257 | current->state = TASK_INTERRUPTIBLE; | 281 | current->state = TASK_INTERRUPTIBLE; |
258 | schedule_timeout(msecs_to_jiffies(10)); | 282 | schedule_timeout(msecs_to_jiffies(10)); |
259 | } | 283 | } |
260 | if (3 == err) { | 284 | if (3 == err) { |
261 | printk(KERN_WARNING | 285 | msp3400_warn("giving up, reseting chip. Sound will go off, sorry folks :-|\n"); |
262 | "msp34xx: giving up, reseting chip. Sound will go off, sorry folks :-|\n"); | ||
263 | msp3400c_reset(client); | 286 | msp3400c_reset(client); |
264 | return -1; | 287 | return -1; |
265 | } | 288 | } |
@@ -422,7 +445,7 @@ static void msp3400c_set_scart(struct i2c_client *client, int in, int out) | |||
422 | } else | 445 | } else |
423 | msp->acb = 0xf60; /* Mute Input and SCART 1 Output */ | 446 | msp->acb = 0xf60; /* Mute Input and SCART 1 Output */ |
424 | 447 | ||
425 | dprintk("msp34xx: scart switch: %s => %d (ACB=0x%04x)\n", | 448 | msp3400_dbg("scart switch: %s => %d (ACB=0x%04x)\n", |
426 | scart_names[in], out, msp->acb); | 449 | scart_names[in], out, msp->acb); |
427 | msp3400c_write(client,I2C_MSP3400C_DFP, 0x13, msp->acb); | 450 | msp3400c_write(client,I2C_MSP3400C_DFP, 0x13, msp->acb); |
428 | 451 | ||
@@ -456,7 +479,7 @@ static void msp3400c_setvolume(struct i2c_client *client, | |||
456 | balance = ((right - left) * 127) / vol; | 479 | balance = ((right - left) * 127) / vol; |
457 | } | 480 | } |
458 | 481 | ||
459 | dprintk("msp34xx: setvolume: mute=%s %d:%d v=0x%02x b=0x%02x\n", | 482 | msp3400_dbg("setvolume: mute=%s %d:%d v=0x%02x b=0x%02x\n", |
460 | muted ? "on" : "off", left, right, val >> 8, balance); | 483 | muted ? "on" : "off", left, right, val >> 8, balance); |
461 | msp3400c_write(client,I2C_MSP3400C_DFP, 0x0000, val); /* loudspeaker */ | 484 | msp3400c_write(client,I2C_MSP3400C_DFP, 0x0000, val); /* loudspeaker */ |
462 | msp3400c_write(client,I2C_MSP3400C_DFP, 0x0006, val); /* headphones */ | 485 | msp3400c_write(client,I2C_MSP3400C_DFP, 0x0006, val); /* headphones */ |
@@ -469,7 +492,7 @@ static void msp3400c_setbass(struct i2c_client *client, int bass) | |||
469 | { | 492 | { |
470 | int val = ((bass-32768) * 0x60 / 65535) << 8; | 493 | int val = ((bass-32768) * 0x60 / 65535) << 8; |
471 | 494 | ||
472 | dprintk("msp34xx: setbass: %d 0x%02x\n", bass, val >> 8); | 495 | msp3400_dbg("setbass: %d 0x%02x\n", bass, val >> 8); |
473 | msp3400c_write(client,I2C_MSP3400C_DFP, 0x0002, val); /* loudspeaker */ | 496 | msp3400c_write(client,I2C_MSP3400C_DFP, 0x0002, val); /* loudspeaker */ |
474 | } | 497 | } |
475 | 498 | ||
@@ -477,7 +500,7 @@ static void msp3400c_settreble(struct i2c_client *client, int treble) | |||
477 | { | 500 | { |
478 | int val = ((treble-32768) * 0x60 / 65535) << 8; | 501 | int val = ((treble-32768) * 0x60 / 65535) << 8; |
479 | 502 | ||
480 | dprintk("msp34xx: settreble: %d 0x%02x\n",treble, val>>8); | 503 | msp3400_dbg("settreble: %d 0x%02x\n",treble, val>>8); |
481 | msp3400c_write(client,I2C_MSP3400C_DFP, 0x0003, val); /* loudspeaker */ | 504 | msp3400c_write(client,I2C_MSP3400C_DFP, 0x0003, val); /* loudspeaker */ |
482 | } | 505 | } |
483 | 506 | ||
@@ -486,7 +509,7 @@ static void msp3400c_setmode(struct i2c_client *client, int type) | |||
486 | struct msp3400c *msp = i2c_get_clientdata(client); | 509 | struct msp3400c *msp = i2c_get_clientdata(client); |
487 | int i; | 510 | int i; |
488 | 511 | ||
489 | dprintk("msp3400: setmode: %d\n",type); | 512 | msp3400_dbg("setmode: %d\n",type); |
490 | msp->mode = type; | 513 | msp->mode = type; |
491 | msp->audmode = V4L2_TUNER_MODE_MONO; | 514 | msp->audmode = V4L2_TUNER_MODE_MONO; |
492 | msp->rxsubchans = V4L2_TUNER_SUB_MONO; | 515 | msp->rxsubchans = V4L2_TUNER_SUB_MONO; |
@@ -565,8 +588,8 @@ static void msp3400c_setstereo(struct i2c_client *client, int mode) | |||
565 | /* this method would break everything, let's make sure | 588 | /* this method would break everything, let's make sure |
566 | * it's never called | 589 | * it's never called |
567 | */ | 590 | */ |
568 | dprintk | 591 | msp3400_dbg |
569 | ("msp34xxg: DEBUG WARNING setstereo called with mode=%d instead of set_source (ignored)\n", | 592 | ("DEBUG WARNING setstereo called with mode=%d instead of set_source (ignored)\n", |
570 | mode); | 593 | mode); |
571 | return; | 594 | return; |
572 | } | 595 | } |
@@ -574,8 +597,7 @@ static void msp3400c_setstereo(struct i2c_client *client, int mode) | |||
574 | /* switch demodulator */ | 597 | /* switch demodulator */ |
575 | switch (msp->mode) { | 598 | switch (msp->mode) { |
576 | case MSP_MODE_FM_TERRA: | 599 | case MSP_MODE_FM_TERRA: |
577 | dprintk("msp3400: FM setstereo: %s\n", | 600 | msp3400_dbg("FM setstereo: %s\n", strmode[mode]); |
578 | strmode[mode]); | ||
579 | msp3400c_setcarrier(client,msp->second,msp->main); | 601 | msp3400c_setcarrier(client,msp->second,msp->main); |
580 | switch (mode) { | 602 | switch (mode) { |
581 | case V4L2_TUNER_MODE_STEREO: | 603 | case V4L2_TUNER_MODE_STEREO: |
@@ -589,7 +611,7 @@ static void msp3400c_setstereo(struct i2c_client *client, int mode) | |||
589 | } | 611 | } |
590 | break; | 612 | break; |
591 | case MSP_MODE_FM_SAT: | 613 | case MSP_MODE_FM_SAT: |
592 | dprintk("msp3400: SAT setstereo: %s\n", strmode[mode]); | 614 | msp3400_dbg("SAT setstereo: %s\n", strmode[mode]); |
593 | switch (mode) { | 615 | switch (mode) { |
594 | case V4L2_TUNER_MODE_MONO: | 616 | case V4L2_TUNER_MODE_MONO: |
595 | msp3400c_setcarrier(client, MSP_CARRIER(6.5), MSP_CARRIER(6.5)); | 617 | msp3400c_setcarrier(client, MSP_CARRIER(6.5), MSP_CARRIER(6.5)); |
@@ -608,24 +630,24 @@ static void msp3400c_setstereo(struct i2c_client *client, int mode) | |||
608 | case MSP_MODE_FM_NICAM1: | 630 | case MSP_MODE_FM_NICAM1: |
609 | case MSP_MODE_FM_NICAM2: | 631 | case MSP_MODE_FM_NICAM2: |
610 | case MSP_MODE_AM_NICAM: | 632 | case MSP_MODE_AM_NICAM: |
611 | dprintk("msp3400: NICAM setstereo: %s\n",strmode[mode]); | 633 | msp3400_dbg("NICAM setstereo: %s\n",strmode[mode]); |
612 | msp3400c_setcarrier(client,msp->second,msp->main); | 634 | msp3400c_setcarrier(client,msp->second,msp->main); |
613 | if (msp->nicam_on) | 635 | if (msp->nicam_on) |
614 | nicam=0x0100; | 636 | nicam=0x0100; |
615 | break; | 637 | break; |
616 | case MSP_MODE_BTSC: | 638 | case MSP_MODE_BTSC: |
617 | dprintk("msp3400: BTSC setstereo: %s\n",strmode[mode]); | 639 | msp3400_dbg("BTSC setstereo: %s\n",strmode[mode]); |
618 | nicam=0x0300; | 640 | nicam=0x0300; |
619 | break; | 641 | break; |
620 | case MSP_MODE_EXTERN: | 642 | case MSP_MODE_EXTERN: |
621 | dprintk("msp3400: extern setstereo: %s\n",strmode[mode]); | 643 | msp3400_dbg("extern setstereo: %s\n",strmode[mode]); |
622 | nicam = 0x0200; | 644 | nicam = 0x0200; |
623 | break; | 645 | break; |
624 | case MSP_MODE_FM_RADIO: | 646 | case MSP_MODE_FM_RADIO: |
625 | dprintk("msp3400: FM-Radio setstereo: %s\n",strmode[mode]); | 647 | msp3400_dbg("FM-Radio setstereo: %s\n",strmode[mode]); |
626 | break; | 648 | break; |
627 | default: | 649 | default: |
628 | dprintk("msp3400: mono setstereo\n"); | 650 | msp3400_dbg("mono setstereo\n"); |
629 | return; | 651 | return; |
630 | } | 652 | } |
631 | 653 | ||
@@ -636,7 +658,7 @@ static void msp3400c_setstereo(struct i2c_client *client, int mode) | |||
636 | break; | 658 | break; |
637 | case V4L2_TUNER_MODE_MONO: | 659 | case V4L2_TUNER_MODE_MONO: |
638 | if (msp->mode == MSP_MODE_AM_NICAM) { | 660 | if (msp->mode == MSP_MODE_AM_NICAM) { |
639 | dprintk("msp3400: switching to AM mono\n"); | 661 | msp3400_dbg("switching to AM mono\n"); |
640 | /* AM mono decoding is handled by tuner, not MSP chip */ | 662 | /* AM mono decoding is handled by tuner, not MSP chip */ |
641 | /* SCART switching control register */ | 663 | /* SCART switching control register */ |
642 | msp3400c_set_scart(client,SCART_MONO,0); | 664 | msp3400c_set_scart(client,SCART_MONO,0); |
@@ -650,7 +672,7 @@ static void msp3400c_setstereo(struct i2c_client *client, int mode) | |||
650 | src = 0x0010 | nicam; | 672 | src = 0x0010 | nicam; |
651 | break; | 673 | break; |
652 | } | 674 | } |
653 | dprintk("msp3400: setstereo final source/matrix = 0x%x\n", src); | 675 | msp3400_dbg("setstereo final source/matrix = 0x%x\n", src); |
654 | 676 | ||
655 | if (dolby) { | 677 | if (dolby) { |
656 | msp3400c_write(client,I2C_MSP3400C_DFP, 0x0008,0x0520); | 678 | msp3400c_write(client,I2C_MSP3400C_DFP, 0x0008,0x0520); |
@@ -666,24 +688,26 @@ static void msp3400c_setstereo(struct i2c_client *client, int mode) | |||
666 | } | 688 | } |
667 | 689 | ||
668 | static void | 690 | static void |
669 | msp3400c_print_mode(struct msp3400c *msp) | 691 | msp3400c_print_mode(struct i2c_client *client) |
670 | { | 692 | { |
693 | struct msp3400c *msp = i2c_get_clientdata(client); | ||
694 | |||
671 | if (msp->main == msp->second) { | 695 | if (msp->main == msp->second) { |
672 | dprintk("msp3400: mono sound carrier: %d.%03d MHz\n", | 696 | msp3400_dbg("mono sound carrier: %d.%03d MHz\n", |
673 | msp->main/910000,(msp->main/910)%1000); | 697 | msp->main/910000,(msp->main/910)%1000); |
674 | } else { | 698 | } else { |
675 | dprintk("msp3400: main sound carrier: %d.%03d MHz\n", | 699 | msp3400_dbg("main sound carrier: %d.%03d MHz\n", |
676 | msp->main/910000,(msp->main/910)%1000); | 700 | msp->main/910000,(msp->main/910)%1000); |
677 | } | 701 | } |
678 | if (msp->mode == MSP_MODE_FM_NICAM1 || msp->mode == MSP_MODE_FM_NICAM2) | 702 | if (msp->mode == MSP_MODE_FM_NICAM1 || msp->mode == MSP_MODE_FM_NICAM2) |
679 | dprintk("msp3400: NICAM/FM carrier : %d.%03d MHz\n", | 703 | msp3400_dbg("NICAM/FM carrier : %d.%03d MHz\n", |
680 | msp->second/910000,(msp->second/910)%1000); | 704 | msp->second/910000,(msp->second/910)%1000); |
681 | if (msp->mode == MSP_MODE_AM_NICAM) | 705 | if (msp->mode == MSP_MODE_AM_NICAM) |
682 | dprintk("msp3400: NICAM/AM carrier : %d.%03d MHz\n", | 706 | msp3400_dbg("NICAM/AM carrier : %d.%03d MHz\n", |
683 | msp->second/910000,(msp->second/910)%1000); | 707 | msp->second/910000,(msp->second/910)%1000); |
684 | if (msp->mode == MSP_MODE_FM_TERRA && | 708 | if (msp->mode == MSP_MODE_FM_TERRA && |
685 | msp->main != msp->second) { | 709 | msp->main != msp->second) { |
686 | dprintk("msp3400: FM-stereo carrier : %d.%03d MHz\n", | 710 | msp3400_dbg("FM-stereo carrier : %d.%03d MHz\n", |
687 | msp->second/910000,(msp->second/910)%1000); | 711 | msp->second/910000,(msp->second/910)%1000); |
688 | } | 712 | } |
689 | } | 713 | } |
@@ -741,7 +765,7 @@ static int autodetect_stereo(struct i2c_client *client) | |||
741 | val = msp3400c_read(client, I2C_MSP3400C_DFP, 0x18); | 765 | val = msp3400c_read(client, I2C_MSP3400C_DFP, 0x18); |
742 | if (val > 32767) | 766 | if (val > 32767) |
743 | val -= 65536; | 767 | val -= 65536; |
744 | dprintk("msp34xx: stereo detect register: %d\n",val); | 768 | msp3400_dbg("stereo detect register: %d\n",val); |
745 | if (val > 4096) { | 769 | if (val > 4096) { |
746 | rxsubchans = V4L2_TUNER_SUB_STEREO | V4L2_TUNER_SUB_MONO; | 770 | rxsubchans = V4L2_TUNER_SUB_STEREO | V4L2_TUNER_SUB_MONO; |
747 | } else if (val < -4096) { | 771 | } else if (val < -4096) { |
@@ -755,7 +779,7 @@ static int autodetect_stereo(struct i2c_client *client) | |||
755 | case MSP_MODE_FM_NICAM2: | 779 | case MSP_MODE_FM_NICAM2: |
756 | case MSP_MODE_AM_NICAM: | 780 | case MSP_MODE_AM_NICAM: |
757 | val = msp3400c_read(client, I2C_MSP3400C_DEM, 0x23); | 781 | val = msp3400c_read(client, I2C_MSP3400C_DEM, 0x23); |
758 | dprintk("msp34xx: nicam sync=%d, mode=%d\n", | 782 | msp3400_dbg("nicam sync=%d, mode=%d\n", |
759 | val & 1, (val & 0x1e) >> 1); | 783 | val & 1, (val & 0x1e) >> 1); |
760 | 784 | ||
761 | if (val & 1) { | 785 | if (val & 1) { |
@@ -788,7 +812,7 @@ static int autodetect_stereo(struct i2c_client *client) | |||
788 | break; | 812 | break; |
789 | case MSP_MODE_BTSC: | 813 | case MSP_MODE_BTSC: |
790 | val = msp3400c_read(client, I2C_MSP3400C_DEM, 0x200); | 814 | val = msp3400c_read(client, I2C_MSP3400C_DEM, 0x200); |
791 | dprintk("msp3410: status=0x%x (pri=%s, sec=%s, %s%s%s)\n", | 815 | msp3400_dbg("status=0x%x (pri=%s, sec=%s, %s%s%s)\n", |
792 | val, | 816 | val, |
793 | (val & 0x0002) ? "no" : "yes", | 817 | (val & 0x0002) ? "no" : "yes", |
794 | (val & 0x0004) ? "no" : "yes", | 818 | (val & 0x0004) ? "no" : "yes", |
@@ -802,13 +826,13 @@ static int autodetect_stereo(struct i2c_client *client) | |||
802 | } | 826 | } |
803 | if (rxsubchans != msp->rxsubchans) { | 827 | if (rxsubchans != msp->rxsubchans) { |
804 | update = 1; | 828 | update = 1; |
805 | dprintk("msp34xx: watch: rxsubchans %d => %d\n", | 829 | msp3400_dbg("watch: rxsubchans %d => %d\n", |
806 | msp->rxsubchans,rxsubchans); | 830 | msp->rxsubchans,rxsubchans); |
807 | msp->rxsubchans = rxsubchans; | 831 | msp->rxsubchans = rxsubchans; |
808 | } | 832 | } |
809 | if (newnicam != msp->nicam_on) { | 833 | if (newnicam != msp->nicam_on) { |
810 | update = 1; | 834 | update = 1; |
811 | dprintk("msp34xx: watch: nicam %d => %d\n", | 835 | msp3400_dbg("watch: nicam %d => %d\n", |
812 | msp->nicam_on,newnicam); | 836 | msp->nicam_on,newnicam); |
813 | msp->nicam_on = newnicam; | 837 | msp->nicam_on = newnicam; |
814 | } | 838 | } |
@@ -865,14 +889,14 @@ static int msp3400c_thread(void *data) | |||
865 | struct CARRIER_DETECT *cd; | 889 | struct CARRIER_DETECT *cd; |
866 | int count, max1,max2,val1,val2, val,this; | 890 | int count, max1,max2,val1,val2, val,this; |
867 | 891 | ||
868 | printk("msp3400: kthread started\n"); | 892 | msp3400_info("msp3400 daemon started\n"); |
869 | for (;;) { | 893 | for (;;) { |
870 | d2printk("msp3400: thread: sleep\n"); | 894 | msp3400_dbg_mediumvol("msp3400 thread: sleep\n"); |
871 | msp34xx_sleep(msp,-1); | 895 | msp34xx_sleep(msp,-1); |
872 | d2printk("msp3400: thread: wakeup\n"); | 896 | msp3400_dbg_mediumvol("msp3400 thread: wakeup\n"); |
873 | 897 | ||
874 | restart: | 898 | restart: |
875 | dprintk("msp3410: thread: restart scan\n"); | 899 | msp3400_dbg("thread: restart scan\n"); |
876 | msp->restart = 0; | 900 | msp->restart = 0; |
877 | if (kthread_should_stop()) | 901 | if (kthread_should_stop()) |
878 | break; | 902 | break; |
@@ -880,7 +904,7 @@ static int msp3400c_thread(void *data) | |||
880 | if (VIDEO_MODE_RADIO == msp->norm || | 904 | if (VIDEO_MODE_RADIO == msp->norm || |
881 | MSP_MODE_EXTERN == msp->mode) { | 905 | MSP_MODE_EXTERN == msp->mode) { |
882 | /* no carrier scan, just unmute */ | 906 | /* no carrier scan, just unmute */ |
883 | printk("msp3400: thread: no carrier scan\n"); | 907 | msp3400_info("thread: no carrier scan\n"); |
884 | msp3400c_setvolume(client, msp->muted, msp->left, msp->right); | 908 | msp3400c_setvolume(client, msp->muted, msp->left, msp->right); |
885 | continue; | 909 | continue; |
886 | } | 910 | } |
@@ -904,7 +928,7 @@ static int msp3400c_thread(void *data) | |||
904 | /* autodetect doesn't work well with AM ... */ | 928 | /* autodetect doesn't work well with AM ... */ |
905 | max1 = 3; | 929 | max1 = 3; |
906 | count = 0; | 930 | count = 0; |
907 | dprintk("msp3400: AM sound override\n"); | 931 | msp3400_dbg("AM sound override\n"); |
908 | } | 932 | } |
909 | 933 | ||
910 | for (this = 0; this < count; this++) { | 934 | for (this = 0; this < count; this++) { |
@@ -916,7 +940,7 @@ static int msp3400c_thread(void *data) | |||
916 | val -= 65536; | 940 | val -= 65536; |
917 | if (val1 < val) | 941 | if (val1 < val) |
918 | val1 = val, max1 = this; | 942 | val1 = val, max1 = this; |
919 | dprintk("msp3400: carrier1 val: %5d / %s\n", val,cd[this].name); | 943 | msp3400_dbg("carrier1 val: %5d / %s\n", val,cd[this].name); |
920 | } | 944 | } |
921 | 945 | ||
922 | /* carrier detect pass #2 -- second (stereo) carrier */ | 946 | /* carrier detect pass #2 -- second (stereo) carrier */ |
@@ -952,7 +976,7 @@ static int msp3400c_thread(void *data) | |||
952 | val -= 65536; | 976 | val -= 65536; |
953 | if (val2 < val) | 977 | if (val2 < val) |
954 | val2 = val, max2 = this; | 978 | val2 = val, max2 = this; |
955 | dprintk("msp3400: carrier2 val: %5d / %s\n", val,cd[this].name); | 979 | msp3400_dbg("carrier2 val: %5d / %s\n", val,cd[this].name); |
956 | } | 980 | } |
957 | 981 | ||
958 | /* programm the msp3400 according to the results */ | 982 | /* programm the msp3400 according to the results */ |
@@ -1032,7 +1056,7 @@ static int msp3400c_thread(void *data) | |||
1032 | msp3400c_restore_dfp(client); | 1056 | msp3400c_restore_dfp(client); |
1033 | 1057 | ||
1034 | if (debug) | 1058 | if (debug) |
1035 | msp3400c_print_mode(msp); | 1059 | msp3400c_print_mode(client); |
1036 | 1060 | ||
1037 | /* monitor tv audio mode */ | 1061 | /* monitor tv audio mode */ |
1038 | while (msp->watch_stereo) { | 1062 | while (msp->watch_stereo) { |
@@ -1041,7 +1065,7 @@ static int msp3400c_thread(void *data) | |||
1041 | watch_stereo(client); | 1065 | watch_stereo(client); |
1042 | } | 1066 | } |
1043 | } | 1067 | } |
1044 | dprintk("msp3400: thread: exit\n"); | 1068 | msp3400_dbg("thread: exit\n"); |
1045 | return 0; | 1069 | return 0; |
1046 | } | 1070 | } |
1047 | 1071 | ||
@@ -1085,11 +1109,11 @@ static inline const char *msp34xx_standard_mode_name(int mode) | |||
1085 | return "unknown"; | 1109 | return "unknown"; |
1086 | } | 1110 | } |
1087 | 1111 | ||
1088 | static int msp34xx_modus(int norm) | 1112 | static int msp34xx_modus(struct i2c_client *client, int norm) |
1089 | { | 1113 | { |
1090 | switch (norm) { | 1114 | switch (norm) { |
1091 | case VIDEO_MODE_PAL: | 1115 | case VIDEO_MODE_PAL: |
1092 | dprintk("msp34xx: video mode selected to PAL\n"); | 1116 | msp3400_dbg("video mode selected to PAL\n"); |
1093 | 1117 | ||
1094 | #if 1 | 1118 | #if 1 |
1095 | /* experimental: not sure this works with all chip versions */ | 1119 | /* experimental: not sure this works with all chip versions */ |
@@ -1099,16 +1123,16 @@ static int msp34xx_modus(int norm) | |||
1099 | return 0x1003; | 1123 | return 0x1003; |
1100 | #endif | 1124 | #endif |
1101 | case VIDEO_MODE_NTSC: /* BTSC */ | 1125 | case VIDEO_MODE_NTSC: /* BTSC */ |
1102 | dprintk("msp34xx: video mode selected to NTSC\n"); | 1126 | msp3400_dbg("video mode selected to NTSC\n"); |
1103 | return 0x2003; | 1127 | return 0x2003; |
1104 | case VIDEO_MODE_SECAM: | 1128 | case VIDEO_MODE_SECAM: |
1105 | dprintk("msp34xx: video mode selected to SECAM\n"); | 1129 | msp3400_dbg("video mode selected to SECAM\n"); |
1106 | return 0x0003; | 1130 | return 0x0003; |
1107 | case VIDEO_MODE_RADIO: | 1131 | case VIDEO_MODE_RADIO: |
1108 | dprintk("msp34xx: video mode selected to Radio\n"); | 1132 | msp3400_dbg("video mode selected to Radio\n"); |
1109 | return 0x0003; | 1133 | return 0x0003; |
1110 | case VIDEO_MODE_AUTO: | 1134 | case VIDEO_MODE_AUTO: |
1111 | dprintk("msp34xx: video mode selected to Auto\n"); | 1135 | msp3400_dbg("video mode selected to Auto\n"); |
1112 | return 0x2003; | 1136 | return 0x2003; |
1113 | default: | 1137 | default: |
1114 | return 0x0003; | 1138 | return 0x0003; |
@@ -1137,21 +1161,21 @@ static int msp3410d_thread(void *data) | |||
1137 | struct msp3400c *msp = i2c_get_clientdata(client); | 1161 | struct msp3400c *msp = i2c_get_clientdata(client); |
1138 | int mode,val,i,std; | 1162 | int mode,val,i,std; |
1139 | 1163 | ||
1140 | printk("msp3410: daemon started\n"); | 1164 | msp3400_info("msp3410 daemon started\n"); |
1141 | for (;;) { | 1165 | for (;;) { |
1142 | d2printk("msp3410: thread: sleep\n"); | 1166 | msp3400_dbg_mediumvol("msp3410 thread: sleep\n"); |
1143 | msp34xx_sleep(msp,-1); | 1167 | msp34xx_sleep(msp,-1); |
1144 | d2printk("msp3410: thread: wakeup\n"); | 1168 | msp3400_dbg_mediumvol("msp3410 thread: wakeup\n"); |
1145 | 1169 | ||
1146 | restart: | 1170 | restart: |
1147 | dprintk("msp3410: thread: restart scan\n"); | 1171 | msp3400_dbg("thread: restart scan\n"); |
1148 | msp->restart = 0; | 1172 | msp->restart = 0; |
1149 | if (kthread_should_stop()) | 1173 | if (kthread_should_stop()) |
1150 | break; | 1174 | break; |
1151 | 1175 | ||
1152 | if (msp->mode == MSP_MODE_EXTERN) { | 1176 | if (msp->mode == MSP_MODE_EXTERN) { |
1153 | /* no carrier scan needed, just unmute */ | 1177 | /* no carrier scan needed, just unmute */ |
1154 | dprintk("msp3410: thread: no carrier scan\n"); | 1178 | msp3400_dbg("thread: no carrier scan\n"); |
1155 | msp3400c_setvolume(client, msp->muted, msp->left, msp->right); | 1179 | msp3400c_setvolume(client, msp->muted, msp->left, msp->right); |
1156 | continue; | 1180 | continue; |
1157 | } | 1181 | } |
@@ -1164,14 +1188,14 @@ static int msp3410d_thread(void *data) | |||
1164 | goto restart; | 1188 | goto restart; |
1165 | 1189 | ||
1166 | /* start autodetect */ | 1190 | /* start autodetect */ |
1167 | mode = msp34xx_modus(msp->norm); | 1191 | mode = msp34xx_modus(client, msp->norm); |
1168 | std = msp34xx_standard(msp->norm); | 1192 | std = msp34xx_standard(msp->norm); |
1169 | msp3400c_write(client, I2C_MSP3400C_DEM, 0x30, mode); | 1193 | msp3400c_write(client, I2C_MSP3400C_DEM, 0x30, mode); |
1170 | msp3400c_write(client, I2C_MSP3400C_DEM, 0x20, std); | 1194 | msp3400c_write(client, I2C_MSP3400C_DEM, 0x20, std); |
1171 | msp->watch_stereo = 0; | 1195 | msp->watch_stereo = 0; |
1172 | 1196 | ||
1173 | if (debug) | 1197 | if (debug) |
1174 | dprintk("msp3410: setting mode: %s (0x%04x)\n", | 1198 | msp3400_dbg("setting mode: %s (0x%04x)\n", |
1175 | msp34xx_standard_mode_name(std) ,std); | 1199 | msp34xx_standard_mode_name(std) ,std); |
1176 | 1200 | ||
1177 | if (std != 1) { | 1201 | if (std != 1) { |
@@ -1187,13 +1211,13 @@ static int msp3410d_thread(void *data) | |||
1187 | val = msp3400c_read(client, I2C_MSP3400C_DEM, 0x7e); | 1211 | val = msp3400c_read(client, I2C_MSP3400C_DEM, 0x7e); |
1188 | if (val < 0x07ff) | 1212 | if (val < 0x07ff) |
1189 | break; | 1213 | break; |
1190 | dprintk("msp3410: detection still in progress\n"); | 1214 | msp3400_dbg("detection still in progress\n"); |
1191 | } | 1215 | } |
1192 | } | 1216 | } |
1193 | for (i = 0; modelist[i].name != NULL; i++) | 1217 | for (i = 0; modelist[i].name != NULL; i++) |
1194 | if (modelist[i].retval == val) | 1218 | if (modelist[i].retval == val) |
1195 | break; | 1219 | break; |
1196 | dprintk("msp3410: current mode: %s (0x%04x)\n", | 1220 | msp3400_dbg("current mode: %s (0x%04x)\n", |
1197 | modelist[i].name ? modelist[i].name : "unknown", | 1221 | modelist[i].name ? modelist[i].name : "unknown", |
1198 | val); | 1222 | val); |
1199 | msp->main = modelist[i].main; | 1223 | msp->main = modelist[i].main; |
@@ -1201,7 +1225,7 @@ static int msp3410d_thread(void *data) | |||
1201 | 1225 | ||
1202 | if (amsound && (msp->norm == VIDEO_MODE_SECAM) && (val != 0x0009)) { | 1226 | if (amsound && (msp->norm == VIDEO_MODE_SECAM) && (val != 0x0009)) { |
1203 | /* autodetection has failed, let backup */ | 1227 | /* autodetection has failed, let backup */ |
1204 | dprintk("msp3410: autodetection failed," | 1228 | msp3400_dbg("autodetection failed," |
1205 | " switching to backup mode: %s (0x%04x)\n", | 1229 | " switching to backup mode: %s (0x%04x)\n", |
1206 | modelist[8].name ? modelist[8].name : "unknown",val); | 1230 | modelist[8].name ? modelist[8].name : "unknown",val); |
1207 | val = 0x0009; | 1231 | val = 0x0009; |
@@ -1286,7 +1310,7 @@ static int msp3410d_thread(void *data) | |||
1286 | watch_stereo(client); | 1310 | watch_stereo(client); |
1287 | } | 1311 | } |
1288 | } | 1312 | } |
1289 | dprintk("msp3410: thread: exit\n"); | 1313 | msp3400_dbg("thread: exit\n"); |
1290 | return 0; | 1314 | return 0; |
1291 | } | 1315 | } |
1292 | 1316 | ||
@@ -1319,7 +1343,7 @@ static int msp34xxg_reset(struct i2c_client *client) | |||
1319 | msp3400c_write(client,I2C_MSP3400C_DEM, 0x40, msp->i2s_mode); | 1343 | msp3400c_write(client,I2C_MSP3400C_DEM, 0x40, msp->i2s_mode); |
1320 | 1344 | ||
1321 | /* step-by-step initialisation, as described in the manual */ | 1345 | /* step-by-step initialisation, as described in the manual */ |
1322 | modus = msp34xx_modus(msp->norm); | 1346 | modus = msp34xx_modus(client, msp->norm); |
1323 | std = msp34xx_standard(msp->norm); | 1347 | std = msp34xx_standard(msp->norm); |
1324 | modus &= ~0x03; /* STATUS_CHANGE=0 */ | 1348 | modus &= ~0x03; /* STATUS_CHANGE=0 */ |
1325 | modus |= 0x01; /* AUTOMATIC_SOUND_DETECTION=1 */ | 1349 | modus |= 0x01; /* AUTOMATIC_SOUND_DETECTION=1 */ |
@@ -1359,15 +1383,15 @@ static int msp34xxg_thread(void *data) | |||
1359 | struct msp3400c *msp = i2c_get_clientdata(client); | 1383 | struct msp3400c *msp = i2c_get_clientdata(client); |
1360 | int val, std, i; | 1384 | int val, std, i; |
1361 | 1385 | ||
1362 | printk("msp34xxg: daemon started\n"); | 1386 | msp3400_info("msp34xxg daemon started\n"); |
1363 | msp->source = 1; /* default */ | 1387 | msp->source = 1; /* default */ |
1364 | for (;;) { | 1388 | for (;;) { |
1365 | d2printk("msp34xxg: thread: sleep\n"); | 1389 | msp3400_dbg_mediumvol("msp34xxg thread: sleep\n"); |
1366 | msp34xx_sleep(msp,-1); | 1390 | msp34xx_sleep(msp,-1); |
1367 | d2printk("msp34xxg: thread: wakeup\n"); | 1391 | msp3400_dbg_mediumvol("msp34xxg thread: wakeup\n"); |
1368 | 1392 | ||
1369 | restart: | 1393 | restart: |
1370 | dprintk("msp34xxg: thread: restart scan\n"); | 1394 | msp3400_dbg("thread: restart scan\n"); |
1371 | msp->restart = 0; | 1395 | msp->restart = 0; |
1372 | if (kthread_should_stop()) | 1396 | if (kthread_should_stop()) |
1373 | break; | 1397 | break; |
@@ -1379,7 +1403,7 @@ static int msp34xxg_thread(void *data) | |||
1379 | goto unmute; | 1403 | goto unmute; |
1380 | 1404 | ||
1381 | /* watch autodetect */ | 1405 | /* watch autodetect */ |
1382 | dprintk("msp34xxg: triggered autodetect, waiting for result\n"); | 1406 | msp3400_dbg("triggered autodetect, waiting for result\n"); |
1383 | for (i = 0; i < 10; i++) { | 1407 | for (i = 0; i < 10; i++) { |
1384 | if (msp34xx_sleep(msp,100)) | 1408 | if (msp34xx_sleep(msp,100)) |
1385 | goto restart; | 1409 | goto restart; |
@@ -1390,19 +1414,19 @@ static int msp34xxg_thread(void *data) | |||
1390 | std = val; | 1414 | std = val; |
1391 | break; | 1415 | break; |
1392 | } | 1416 | } |
1393 | dprintk("msp34xxg: detection still in progress\n"); | 1417 | msp3400_dbg("detection still in progress\n"); |
1394 | } | 1418 | } |
1395 | if (0x01 == std) { | 1419 | if (0x01 == std) { |
1396 | dprintk("msp34xxg: detection still in progress after 10 tries. giving up.\n"); | 1420 | msp3400_dbg("detection still in progress after 10 tries. giving up.\n"); |
1397 | continue; | 1421 | continue; |
1398 | } | 1422 | } |
1399 | 1423 | ||
1400 | unmute: | 1424 | unmute: |
1401 | dprintk("msp34xxg: current mode: %s (0x%04x)\n", | 1425 | msp3400_dbg("current mode: %s (0x%04x)\n", |
1402 | msp34xx_standard_mode_name(std), std); | 1426 | msp34xx_standard_mode_name(std), std); |
1403 | 1427 | ||
1404 | /* unmute: dispatch sound to scart output, set scart volume */ | 1428 | /* unmute: dispatch sound to scart output, set scart volume */ |
1405 | dprintk("msp34xxg: unmute\n"); | 1429 | msp3400_dbg("unmute\n"); |
1406 | 1430 | ||
1407 | msp3400c_setbass(client, msp->bass); | 1431 | msp3400c_setbass(client, msp->bass); |
1408 | msp3400c_settreble(client, msp->treble); | 1432 | msp3400c_settreble(client, msp->treble); |
@@ -1417,7 +1441,7 @@ static int msp34xxg_thread(void *data) | |||
1417 | 1441 | ||
1418 | msp3400c_write(client,I2C_MSP3400C_DEM, 0x40, msp->i2s_mode); | 1442 | msp3400c_write(client,I2C_MSP3400C_DEM, 0x40, msp->i2s_mode); |
1419 | } | 1443 | } |
1420 | dprintk("msp34xxg: thread: exit\n"); | 1444 | msp3400_dbg("thread: exit\n"); |
1421 | return 0; | 1445 | return 0; |
1422 | } | 1446 | } |
1423 | 1447 | ||
@@ -1436,7 +1460,7 @@ static void msp34xxg_set_source(struct i2c_client *client, int source) | |||
1436 | * for MONO (source==0) downmixing set bit[7:0] to 0x30 | 1460 | * for MONO (source==0) downmixing set bit[7:0] to 0x30 |
1437 | */ | 1461 | */ |
1438 | int value = (source&0x07)<<8|(source==0 ? 0x30:0x20); | 1462 | int value = (source&0x07)<<8|(source==0 ? 0x30:0x20); |
1439 | dprintk("msp34xxg: set source to %d (0x%x)\n", source, value); | 1463 | msp3400_dbg("set source to %d (0x%x)\n", source, value); |
1440 | msp3400c_write(client, | 1464 | msp3400c_write(client, |
1441 | I2C_MSP3400C_DFP, | 1465 | I2C_MSP3400C_DFP, |
1442 | 0x08, /* Loudspeaker Output */ | 1466 | 0x08, /* Loudspeaker Output */ |
@@ -1487,7 +1511,7 @@ static void msp34xxg_detect_stereo(struct i2c_client *client) | |||
1487 | * this is a problem, I'll handle SAP just like lang1/lang2. | 1511 | * this is a problem, I'll handle SAP just like lang1/lang2. |
1488 | */ | 1512 | */ |
1489 | } | 1513 | } |
1490 | dprintk("msp34xxg: status=0x%x, stereo=%d, bilingual=%d -> rxsubchans=%d\n", | 1514 | msp3400_dbg("status=0x%x, stereo=%d, bilingual=%d -> rxsubchans=%d\n", |
1491 | status, is_stereo, is_bilingual, msp->rxsubchans); | 1515 | status, is_stereo, is_bilingual, msp->rxsubchans); |
1492 | } | 1516 | } |
1493 | 1517 | ||
@@ -1534,7 +1558,7 @@ static void msp_wake_thread(struct i2c_client *client); | |||
1534 | 1558 | ||
1535 | static struct i2c_driver driver = { | 1559 | static struct i2c_driver driver = { |
1536 | .owner = THIS_MODULE, | 1560 | .owner = THIS_MODULE, |
1537 | .name = "i2c msp3400 driver", | 1561 | .name = "msp3400", |
1538 | .id = I2C_DRIVERID_MSP3400, | 1562 | .id = I2C_DRIVERID_MSP3400, |
1539 | .flags = I2C_DF_NOTIFY, | 1563 | .flags = I2C_DF_NOTIFY, |
1540 | .attach_adapter = msp_probe, | 1564 | .attach_adapter = msp_probe, |
@@ -1556,7 +1580,7 @@ static struct i2c_client client_template = | |||
1556 | static int msp_attach(struct i2c_adapter *adap, int addr, int kind) | 1580 | static int msp_attach(struct i2c_adapter *adap, int addr, int kind) |
1557 | { | 1581 | { |
1558 | struct msp3400c *msp; | 1582 | struct msp3400c *msp; |
1559 | struct i2c_client *c; | 1583 | struct i2c_client *client = &client_template; |
1560 | int (*thread_func)(void *data) = NULL; | 1584 | int (*thread_func)(void *data) = NULL; |
1561 | int i; | 1585 | int i; |
1562 | 1586 | ||
@@ -1564,15 +1588,15 @@ static int msp_attach(struct i2c_adapter *adap, int addr, int kind) | |||
1564 | client_template.addr = addr; | 1588 | client_template.addr = addr; |
1565 | 1589 | ||
1566 | if (-1 == msp3400c_reset(&client_template)) { | 1590 | if (-1 == msp3400c_reset(&client_template)) { |
1567 | dprintk("msp34xx: no chip found\n"); | 1591 | msp3400_dbg("no chip found\n"); |
1568 | return -1; | 1592 | return -1; |
1569 | } | 1593 | } |
1570 | 1594 | ||
1571 | if (NULL == (c = kmalloc(sizeof(struct i2c_client),GFP_KERNEL))) | 1595 | if (NULL == (client = kmalloc(sizeof(struct i2c_client),GFP_KERNEL))) |
1572 | return -ENOMEM; | 1596 | return -ENOMEM; |
1573 | memcpy(c,&client_template,sizeof(struct i2c_client)); | 1597 | memcpy(client,&client_template,sizeof(struct i2c_client)); |
1574 | if (NULL == (msp = kmalloc(sizeof(struct msp3400c),GFP_KERNEL))) { | 1598 | if (NULL == (msp = kmalloc(sizeof(struct msp3400c),GFP_KERNEL))) { |
1575 | kfree(c); | 1599 | kfree(client); |
1576 | return -ENOMEM; | 1600 | return -ENOMEM; |
1577 | } | 1601 | } |
1578 | 1602 | ||
@@ -1588,31 +1612,32 @@ static int msp_attach(struct i2c_adapter *adap, int addr, int kind) | |||
1588 | for (i = 0; i < DFP_COUNT; i++) | 1612 | for (i = 0; i < DFP_COUNT; i++) |
1589 | msp->dfp_regs[i] = -1; | 1613 | msp->dfp_regs[i] = -1; |
1590 | 1614 | ||
1591 | i2c_set_clientdata(c, msp); | 1615 | i2c_set_clientdata(client, msp); |
1592 | init_waitqueue_head(&msp->wq); | 1616 | init_waitqueue_head(&msp->wq); |
1593 | 1617 | ||
1594 | if (-1 == msp3400c_reset(c)) { | 1618 | if (-1 == msp3400c_reset(client)) { |
1595 | kfree(msp); | 1619 | kfree(msp); |
1596 | kfree(c); | 1620 | kfree(client); |
1597 | dprintk("msp34xx: no chip found\n"); | 1621 | msp3400_dbg("no chip found\n"); |
1598 | return -1; | 1622 | return -1; |
1599 | } | 1623 | } |
1600 | 1624 | ||
1601 | msp->rev1 = msp3400c_read(c, I2C_MSP3400C_DFP, 0x1e); | 1625 | msp->rev1 = msp3400c_read(client, I2C_MSP3400C_DFP, 0x1e); |
1602 | if (-1 != msp->rev1) | 1626 | if (-1 != msp->rev1) |
1603 | msp->rev2 = msp3400c_read(c, I2C_MSP3400C_DFP, 0x1f); | 1627 | msp->rev2 = msp3400c_read(client, I2C_MSP3400C_DFP, 0x1f); |
1604 | if ((-1 == msp->rev1) || (0 == msp->rev1 && 0 == msp->rev2)) { | 1628 | if ((-1 == msp->rev1) || (0 == msp->rev1 && 0 == msp->rev2)) { |
1605 | kfree(msp); | 1629 | kfree(msp); |
1606 | kfree(c); | 1630 | kfree(client); |
1607 | dprintk("msp34xx: error while reading chip version\n"); | 1631 | msp3400_dbg("error while reading chip version\n"); |
1608 | return -1; | 1632 | return -1; |
1609 | } | 1633 | } |
1610 | printk(KERN_INFO "msp34xx: rev1=0x%04x, rev2=0x%04x\n", msp->rev1, msp->rev2); | 1634 | msp3400_dbg("rev1=0x%04x, rev2=0x%04x\n", msp->rev1, msp->rev2); |
1611 | 1635 | ||
1612 | msp3400c_setvolume(c, msp->muted, msp->left, msp->right); | 1636 | msp3400c_setvolume(client, msp->muted, msp->left, msp->right); |
1613 | 1637 | ||
1614 | snprintf(c->name, sizeof(c->name), "MSP34%02d%c-%c%d", | 1638 | snprintf(client->name, sizeof(client->name), "MSP%c4%02d%c-%c%d", |
1615 | (msp->rev2>>8)&0xff, (msp->rev1&0xff)+'@', | 1639 | ((msp->rev1>>4)&0x0f) + '3', |
1640 | (msp->rev2>>8)&0xff, (msp->rev1&0x0f)+'@', | ||
1616 | ((msp->rev1>>8)&0xff)+'@', msp->rev2&0x1f); | 1641 | ((msp->rev1>>8)&0xff)+'@', msp->rev2&0x1f); |
1617 | 1642 | ||
1618 | msp->opmode = opmode; | 1643 | msp->opmode = opmode; |
@@ -1626,7 +1651,7 @@ static int msp_attach(struct i2c_adapter *adap, int addr, int kind) | |||
1626 | } | 1651 | } |
1627 | 1652 | ||
1628 | /* hello world :-) */ | 1653 | /* hello world :-) */ |
1629 | printk(KERN_INFO "msp34xx: init: chip=%s", c->name); | 1654 | msp3400_info("chip=%s", client->name); |
1630 | if (HAVE_NICAM(msp)) | 1655 | if (HAVE_NICAM(msp)) |
1631 | printk(" +nicam"); | 1656 | printk(" +nicam"); |
1632 | if (HAVE_SIMPLE(msp)) | 1657 | if (HAVE_SIMPLE(msp)) |
@@ -1655,20 +1680,20 @@ static int msp_attach(struct i2c_adapter *adap, int addr, int kind) | |||
1655 | 1680 | ||
1656 | /* startup control thread if needed */ | 1681 | /* startup control thread if needed */ |
1657 | if (thread_func) { | 1682 | if (thread_func) { |
1658 | msp->kthread = kthread_run(thread_func, c, "msp34xx"); | 1683 | msp->kthread = kthread_run(thread_func, client, "msp34xx"); |
1659 | 1684 | ||
1660 | if (NULL == msp->kthread) | 1685 | if (NULL == msp->kthread) |
1661 | printk(KERN_WARNING "msp34xx: kernel_thread() failed\n"); | 1686 | msp3400_warn("kernel_thread() failed\n"); |
1662 | msp_wake_thread(c); | 1687 | msp_wake_thread(client); |
1663 | } | 1688 | } |
1664 | 1689 | ||
1665 | /* done */ | 1690 | /* done */ |
1666 | i2c_attach_client(c); | 1691 | i2c_attach_client(client); |
1667 | 1692 | ||
1668 | /* update our own array */ | 1693 | /* update our own array */ |
1669 | for (i = 0; i < MSP3400_MAX; i++) { | 1694 | for (i = 0; i < MSP3400_MAX; i++) { |
1670 | if (NULL == msps[i]) { | 1695 | if (NULL == msps[i]) { |
1671 | msps[i] = c; | 1696 | msps[i] = client; |
1672 | break; | 1697 | break; |
1673 | } | 1698 | } |
1674 | } | 1699 | } |
@@ -1791,7 +1816,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
1791 | switch (cmd) { | 1816 | switch (cmd) { |
1792 | 1817 | ||
1793 | case AUDC_SET_INPUT: | 1818 | case AUDC_SET_INPUT: |
1794 | dprintk("msp34xx: AUDC_SET_INPUT(%d)\n",*sarg); | 1819 | msp3400_dbg("AUDC_SET_INPUT(%d)\n",*sarg); |
1795 | 1820 | ||
1796 | if (*sarg == msp->input) | 1821 | if (*sarg == msp->input) |
1797 | break; | 1822 | break; |
@@ -1832,12 +1857,9 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
1832 | break; | 1857 | break; |
1833 | 1858 | ||
1834 | case AUDC_SET_RADIO: | 1859 | case AUDC_SET_RADIO: |
1835 | dprintk("msp34xx: AUDC_SET_RADIO\n"); | 1860 | msp3400_dbg("AUDC_SET_RADIO\n"); |
1836 | msp->norm = VIDEO_MODE_RADIO; | 1861 | msp->norm = VIDEO_MODE_RADIO; |
1837 | dprintk("msp34xx: switching to radio mode\n"); | 1862 | msp3400_dbg("switching to radio mode\n"); |
1838 | if (IS_MSP34XX_G(msp)) | ||
1839 | msp34xxg_reset(client); | ||
1840 | |||
1841 | msp->watch_stereo = 0; | 1863 | msp->watch_stereo = 0; |
1842 | switch (msp->opmode) { | 1864 | switch (msp->opmode) { |
1843 | case OPMODE_MANUAL: | 1865 | case OPMODE_MANUAL: |
@@ -1886,7 +1908,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
1886 | { | 1908 | { |
1887 | struct video_audio *va = arg; | 1909 | struct video_audio *va = arg; |
1888 | 1910 | ||
1889 | dprintk("msp34xx: VIDIOCGAUDIO\n"); | 1911 | msp3400_dbg("VIDIOCGAUDIO\n"); |
1890 | va->flags |= VIDEO_AUDIO_VOLUME | | 1912 | va->flags |= VIDEO_AUDIO_VOLUME | |
1891 | VIDEO_AUDIO_BASS | | 1913 | VIDEO_AUDIO_BASS | |
1892 | VIDEO_AUDIO_TREBLE | | 1914 | VIDEO_AUDIO_TREBLE | |
@@ -1914,28 +1936,28 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
1914 | { | 1936 | { |
1915 | struct video_audio *va = arg; | 1937 | struct video_audio *va = arg; |
1916 | 1938 | ||
1917 | dprintk("msp34xx: VIDIOCSAUDIO\n"); | 1939 | msp3400_dbg("VIDIOCSAUDIO\n"); |
1918 | msp->muted = (va->flags & VIDEO_AUDIO_MUTE); | 1940 | msp->muted = (va->flags & VIDEO_AUDIO_MUTE); |
1919 | msp->left = (MIN(65536 - va->balance, 32768) * | 1941 | msp->left = (MIN(65536 - va->balance, 32768) * |
1920 | va->volume) / 32768; | 1942 | va->volume) / 32768; |
1921 | msp->right = (MIN(va->balance, 32768) * va->volume) / 32768; | 1943 | msp->right = (MIN(va->balance, 32768) * va->volume) / 32768; |
1922 | msp->bass = va->bass; | 1944 | msp->bass = va->bass; |
1923 | msp->treble = va->treble; | 1945 | msp->treble = va->treble; |
1924 | dprintk("msp34xx: VIDIOCSAUDIO setting va->volume to %d\n", | 1946 | msp3400_dbg("VIDIOCSAUDIO setting va->volume to %d\n", |
1925 | va->volume); | 1947 | va->volume); |
1926 | dprintk("msp34xx: VIDIOCSAUDIO setting va->balance to %d\n", | 1948 | msp3400_dbg("VIDIOCSAUDIO setting va->balance to %d\n", |
1927 | va->balance); | 1949 | va->balance); |
1928 | dprintk("msp34xx: VIDIOCSAUDIO setting va->flags to %d\n", | 1950 | msp3400_dbg("VIDIOCSAUDIO setting va->flags to %d\n", |
1929 | va->flags); | 1951 | va->flags); |
1930 | dprintk("msp34xx: VIDIOCSAUDIO setting msp->left to %d\n", | 1952 | msp3400_dbg("VIDIOCSAUDIO setting msp->left to %d\n", |
1931 | msp->left); | 1953 | msp->left); |
1932 | dprintk("msp34xx: VIDIOCSAUDIO setting msp->right to %d\n", | 1954 | msp3400_dbg("VIDIOCSAUDIO setting msp->right to %d\n", |
1933 | msp->right); | 1955 | msp->right); |
1934 | dprintk("msp34xx: VIDIOCSAUDIO setting msp->bass to %d\n", | 1956 | msp3400_dbg("VIDIOCSAUDIO setting msp->bass to %d\n", |
1935 | msp->bass); | 1957 | msp->bass); |
1936 | dprintk("msp34xx: VIDIOCSAUDIO setting msp->treble to %d\n", | 1958 | msp3400_dbg("VIDIOCSAUDIO setting msp->treble to %d\n", |
1937 | msp->treble); | 1959 | msp->treble); |
1938 | dprintk("msp34xx: VIDIOCSAUDIO setting msp->mode to %d\n", | 1960 | msp3400_dbg("VIDIOCSAUDIO setting msp->mode to %d\n", |
1939 | msp->mode); | 1961 | msp->mode); |
1940 | msp3400c_setvolume(client, msp->muted, msp->left, msp->right); | 1962 | msp3400c_setvolume(client, msp->muted, msp->left, msp->right); |
1941 | msp3400c_setbass(client, msp->bass); | 1963 | msp3400c_setbass(client, msp->bass); |
@@ -1950,11 +1972,8 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
1950 | { | 1972 | { |
1951 | struct video_channel *vc = arg; | 1973 | struct video_channel *vc = arg; |
1952 | 1974 | ||
1953 | dprintk("msp34xx: VIDIOCSCHAN (norm=%d)\n",vc->norm); | 1975 | msp3400_dbg("VIDIOCSCHAN (norm=%d)\n",vc->norm); |
1954 | msp->norm = vc->norm; | 1976 | msp->norm = vc->norm; |
1955 | if (IS_MSP34XX_G(msp)) | ||
1956 | msp34xxg_reset(client); | ||
1957 | |||
1958 | msp_wake_thread(client); | 1977 | msp_wake_thread(client); |
1959 | break; | 1978 | break; |
1960 | } | 1979 | } |
@@ -1963,10 +1982,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
1963 | case VIDIOC_S_FREQUENCY: | 1982 | case VIDIOC_S_FREQUENCY: |
1964 | { | 1983 | { |
1965 | /* new channel -- kick audio carrier scan */ | 1984 | /* new channel -- kick audio carrier scan */ |
1966 | dprintk("msp34xx: VIDIOCSFREQ\n"); | 1985 | msp3400_dbg("VIDIOCSFREQ\n"); |
1967 | if (IS_MSP34XX_G(msp)) | ||
1968 | msp34xxg_reset(client); | ||
1969 | |||
1970 | msp_wake_thread(client); | 1986 | msp_wake_thread(client); |
1971 | break; | 1987 | break; |
1972 | } | 1988 | } |
@@ -1976,7 +1992,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
1976 | { | 1992 | { |
1977 | struct msp_matrix *mspm = arg; | 1993 | struct msp_matrix *mspm = arg; |
1978 | 1994 | ||
1979 | dprintk("msp34xx: MSP_SET_MATRIX\n"); | 1995 | msp3400_dbg("MSP_SET_MATRIX\n"); |
1980 | msp3400c_set_scart(client, mspm->input, mspm->output); | 1996 | msp3400c_set_scart(client, mspm->input, mspm->output); |
1981 | break; | 1997 | break; |
1982 | } | 1998 | } |
@@ -2153,7 +2169,8 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
2153 | else | 2169 | else |
2154 | msp->i2s_mode=0; | 2170 | msp->i2s_mode=0; |
2155 | } | 2171 | } |
2156 | dprintk("Setting audio out on msp34xx to input %i, mode %i\n",a->index,msp->i2s_mode); | 2172 | msp3400_dbg("Setting audio out on msp34xx to input %i, mode %i\n", |
2173 | a->index,msp->i2s_mode); | ||
2157 | msp3400c_set_scart(client,msp->in_scart,a->index+1); | 2174 | msp3400c_set_scart(client,msp->in_scart,a->index+1); |
2158 | 2175 | ||
2159 | break; | 2176 | break; |
@@ -2168,19 +2185,19 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
2168 | 2185 | ||
2169 | static int msp_suspend(struct device * dev, pm_message_t state) | 2186 | static int msp_suspend(struct device * dev, pm_message_t state) |
2170 | { | 2187 | { |
2171 | struct i2c_client *c = container_of(dev, struct i2c_client, dev); | 2188 | struct i2c_client *client = container_of(dev, struct i2c_client, dev); |
2172 | 2189 | ||
2173 | dprintk("msp34xx: suspend\n"); | 2190 | msp3400_dbg("msp34xx: suspend\n"); |
2174 | msp3400c_reset(c); | 2191 | msp3400c_reset(client); |
2175 | return 0; | 2192 | return 0; |
2176 | } | 2193 | } |
2177 | 2194 | ||
2178 | static int msp_resume(struct device * dev) | 2195 | static int msp_resume(struct device * dev) |
2179 | { | 2196 | { |
2180 | struct i2c_client *c = container_of(dev, struct i2c_client, dev); | 2197 | struct i2c_client *client = container_of(dev, struct i2c_client, dev); |
2181 | 2198 | ||
2182 | dprintk("msp34xx: resume\n"); | 2199 | msp3400_dbg("msp34xx: resume\n"); |
2183 | msp_wake_thread(c); | 2200 | msp_wake_thread(client); |
2184 | return 0; | 2201 | return 0; |
2185 | } | 2202 | } |
2186 | 2203 | ||