aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/msp3400-kthreads.c
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2007-12-12 06:25:18 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-01-25 16:04:06 -0500
commitd52c7385ec8d4d2081b0db47e309723ce3eae816 (patch)
treeaf05ca1d3a625a6cf6ec825b45d5e73e79503775 /drivers/media/video/msp3400-kthreads.c
parent35df38c015866b3c28bfb1914b14eba92086cdd1 (diff)
V4L/DVB (6866): msp3400: CodingStyle cleanups
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/msp3400-kthreads.c')
-rw-r--r--drivers/media/video/msp3400-kthreads.c166
1 files changed, 98 insertions, 68 deletions
diff --git a/drivers/media/video/msp3400-kthreads.c b/drivers/media/video/msp3400-kthreads.c
index d5ee2629121e..61ec794a737e 100644
--- a/drivers/media/video/msp3400-kthreads.c
+++ b/drivers/media/video/msp3400-kthreads.c
@@ -15,7 +15,8 @@
15 * 15 *
16 * You should have received a copy of the GNU General Public License 16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 * 02110-1301, USA.
19 */ 20 */
20 21
21 22
@@ -78,37 +79,37 @@ static struct msp3400c_init_data_dem {
78 {75, 19, 36, 35, 39, 40}, 79 {75, 19, 36, 35, 39, 40},
79 MSP_CARRIER(5.5), MSP_CARRIER(5.5), 80 MSP_CARRIER(5.5), MSP_CARRIER(5.5),
80 0x00d0, 0x0500, 0x0020, 0x3000 81 0x00d0, 0x0500, 0x0020, 0x3000
81 },{ /* AM (for carrier detect / msp3410) */ 82 }, { /* AM (for carrier detect / msp3410) */
82 {-1, -1, -8, 2, 59, 126}, 83 {-1, -1, -8, 2, 59, 126},
83 {-1, -1, -8, 2, 59, 126}, 84 {-1, -1, -8, 2, 59, 126},
84 MSP_CARRIER(5.5), MSP_CARRIER(5.5), 85 MSP_CARRIER(5.5), MSP_CARRIER(5.5),
85 0x00d0, 0x0100, 0x0020, 0x3000 86 0x00d0, 0x0100, 0x0020, 0x3000
86 },{ /* FM Radio */ 87 }, { /* FM Radio */
87 {-8, -8, 4, 6, 78, 107}, 88 {-8, -8, 4, 6, 78, 107},
88 {-8, -8, 4, 6, 78, 107}, 89 {-8, -8, 4, 6, 78, 107},
89 MSP_CARRIER(10.7), MSP_CARRIER(10.7), 90 MSP_CARRIER(10.7), MSP_CARRIER(10.7),
90 0x00d0, 0x0480, 0x0020, 0x3000 91 0x00d0, 0x0480, 0x0020, 0x3000
91 },{ /* Terrestial FM-mono + FM-stereo */ 92 }, { /* Terrestial FM-mono + FM-stereo */
92 {3, 18, 27, 48, 66, 72}, 93 {3, 18, 27, 48, 66, 72},
93 {3, 18, 27, 48, 66, 72}, 94 {3, 18, 27, 48, 66, 72},
94 MSP_CARRIER(5.5), MSP_CARRIER(5.5), 95 MSP_CARRIER(5.5), MSP_CARRIER(5.5),
95 0x00d0, 0x0480, 0x0030, 0x3000 96 0x00d0, 0x0480, 0x0030, 0x3000
96 },{ /* Sat FM-mono */ 97 }, { /* Sat FM-mono */
97 { 1, 9, 14, 24, 33, 37}, 98 { 1, 9, 14, 24, 33, 37},
98 { 3, 18, 27, 48, 66, 72}, 99 { 3, 18, 27, 48, 66, 72},
99 MSP_CARRIER(6.5), MSP_CARRIER(6.5), 100 MSP_CARRIER(6.5), MSP_CARRIER(6.5),
100 0x00c6, 0x0480, 0x0000, 0x3000 101 0x00c6, 0x0480, 0x0000, 0x3000
101 },{ /* NICAM/FM -- B/G (5.5/5.85), D/K (6.5/5.85) */ 102 }, { /* NICAM/FM -- B/G (5.5/5.85), D/K (6.5/5.85) */
102 {-2, -8, -10, 10, 50, 86}, 103 {-2, -8, -10, 10, 50, 86},
103 {3, 18, 27, 48, 66, 72}, 104 {3, 18, 27, 48, 66, 72},
104 MSP_CARRIER(5.5), MSP_CARRIER(5.5), 105 MSP_CARRIER(5.5), MSP_CARRIER(5.5),
105 0x00d0, 0x0040, 0x0120, 0x3000 106 0x00d0, 0x0040, 0x0120, 0x3000
106 },{ /* NICAM/FM -- I (6.0/6.552) */ 107 }, { /* NICAM/FM -- I (6.0/6.552) */
107 {2, 4, -6, -4, 40, 94}, 108 {2, 4, -6, -4, 40, 94},
108 {3, 18, 27, 48, 66, 72}, 109 {3, 18, 27, 48, 66, 72},
109 MSP_CARRIER(6.0), MSP_CARRIER(6.0), 110 MSP_CARRIER(6.0), MSP_CARRIER(6.0),
110 0x00d0, 0x0040, 0x0120, 0x3000 111 0x00d0, 0x0040, 0x0120, 0x3000
111 },{ /* NICAM/AM -- L (6.5/5.85) */ 112 }, { /* NICAM/AM -- L (6.5/5.85) */
112 {-2, -8, -10, 10, 50, 86}, 113 {-2, -8, -10, 10, 50, 86},
113 {-4, -12, -9, 23, 79, 126}, 114 {-4, -12, -9, 23, 79, 126},
114 MSP_CARRIER(6.5), MSP_CARRIER(6.5), 115 MSP_CARRIER(6.5), MSP_CARRIER(6.5),
@@ -224,7 +225,9 @@ void msp3400c_set_mode(struct i2c_client *client, int mode)
224 nor do they support stereo BTSC. */ 225 nor do they support stereo BTSC. */
225static void msp3400c_set_audmode(struct i2c_client *client) 226static void msp3400c_set_audmode(struct i2c_client *client)
226{ 227{
227 static char *strmode[] = { "mono", "stereo", "lang2", "lang1", "lang1+lang2" }; 228 static char *strmode[] = {
229 "mono", "stereo", "lang2", "lang1", "lang1+lang2"
230 };
228 struct msp_state *state = i2c_get_clientdata(client); 231 struct msp_state *state = i2c_get_clientdata(client);
229 char *modestr = (state->audmode >= 0 && state->audmode < 5) ? 232 char *modestr = (state->audmode >= 0 && state->audmode < 5) ?
230 strmode[state->audmode] : "unknown"; 233 strmode[state->audmode] : "unknown";
@@ -298,19 +301,23 @@ static void msp3400c_set_audmode(struct i2c_client *client)
298 case MSP_MODE_FM_NICAM1: 301 case MSP_MODE_FM_NICAM1:
299 case MSP_MODE_FM_NICAM2: 302 case MSP_MODE_FM_NICAM2:
300 case MSP_MODE_AM_NICAM: 303 case MSP_MODE_AM_NICAM:
301 v4l_dbg(1, msp_debug, client, "NICAM set_audmode: %s\n",modestr); 304 v4l_dbg(1, msp_debug, client,
305 "NICAM set_audmode: %s\n", modestr);
302 if (state->nicam_on) 306 if (state->nicam_on)
303 src = 0x0100; /* NICAM */ 307 src = 0x0100; /* NICAM */
304 break; 308 break;
305 case MSP_MODE_BTSC: 309 case MSP_MODE_BTSC:
306 v4l_dbg(1, msp_debug, client, "BTSC set_audmode: %s\n",modestr); 310 v4l_dbg(1, msp_debug, client,
311 "BTSC set_audmode: %s\n", modestr);
307 break; 312 break;
308 case MSP_MODE_EXTERN: 313 case MSP_MODE_EXTERN:
309 v4l_dbg(1, msp_debug, client, "extern set_audmode: %s\n",modestr); 314 v4l_dbg(1, msp_debug, client,
315 "extern set_audmode: %s\n", modestr);
310 src = 0x0200; /* SCART */ 316 src = 0x0200; /* SCART */
311 break; 317 break;
312 case MSP_MODE_FM_RADIO: 318 case MSP_MODE_FM_RADIO:
313 v4l_dbg(1, msp_debug, client, "FM-Radio set_audmode: %s\n",modestr); 319 v4l_dbg(1, msp_debug, client,
320 "FM-Radio set_audmode: %s\n", modestr);
314 break; 321 break;
315 default: 322 default:
316 v4l_dbg(1, msp_debug, client, "mono set_audmode\n"); 323 v4l_dbg(1, msp_debug, client, "mono set_audmode\n");
@@ -342,7 +349,8 @@ static void msp3400c_set_audmode(struct i2c_client *client)
342 src |= 0x0010; 349 src |= 0x0010;
343 break; 350 break;
344 } 351 }
345 v4l_dbg(1, msp_debug, client, "set_audmode final source/matrix = 0x%x\n", src); 352 v4l_dbg(1, msp_debug, client,
353 "set_audmode final source/matrix = 0x%x\n", src);
346 354
347 msp_set_source(client, src); 355 msp_set_source(client, src);
348} 356}
@@ -351,22 +359,26 @@ static void msp3400c_print_mode(struct i2c_client *client)
351{ 359{
352 struct msp_state *state = i2c_get_clientdata(client); 360 struct msp_state *state = i2c_get_clientdata(client);
353 361
354 if (state->main == state->second) { 362 if (state->main == state->second)
355 v4l_dbg(1, msp_debug, client, "mono sound carrier: %d.%03d MHz\n", 363 v4l_dbg(1, msp_debug, client,
356 state->main / 910000, (state->main / 910) % 1000); 364 "mono sound carrier: %d.%03d MHz\n",
357 } else { 365 state->main / 910000, (state->main / 910) % 1000);
358 v4l_dbg(1, msp_debug, client, "main sound carrier: %d.%03d MHz\n", 366 else
359 state->main / 910000, (state->main / 910) % 1000); 367 v4l_dbg(1, msp_debug, client,
360 } 368 "main sound carrier: %d.%03d MHz\n",
369 state->main / 910000, (state->main / 910) % 1000);
361 if (state->mode == MSP_MODE_FM_NICAM1 || state->mode == MSP_MODE_FM_NICAM2) 370 if (state->mode == MSP_MODE_FM_NICAM1 || state->mode == MSP_MODE_FM_NICAM2)
362 v4l_dbg(1, msp_debug, client, "NICAM/FM carrier : %d.%03d MHz\n", 371 v4l_dbg(1, msp_debug, client,
363 state->second / 910000, (state->second/910) % 1000); 372 "NICAM/FM carrier : %d.%03d MHz\n",
373 state->second / 910000, (state->second/910) % 1000);
364 if (state->mode == MSP_MODE_AM_NICAM) 374 if (state->mode == MSP_MODE_AM_NICAM)
365 v4l_dbg(1, msp_debug, client, "NICAM/AM carrier : %d.%03d MHz\n", 375 v4l_dbg(1, msp_debug, client,
366 state->second / 910000, (state->second / 910) % 1000); 376 "NICAM/AM carrier : %d.%03d MHz\n",
377 state->second / 910000, (state->second / 910) % 1000);
367 if (state->mode == MSP_MODE_FM_TERRA && state->main != state->second) { 378 if (state->mode == MSP_MODE_FM_TERRA && state->main != state->second) {
368 v4l_dbg(1, msp_debug, client, "FM-stereo carrier : %d.%03d MHz\n", 379 v4l_dbg(1, msp_debug, client,
369 state->second / 910000, (state->second / 910) % 1000); 380 "FM-stereo carrier : %d.%03d MHz\n",
381 state->second / 910000, (state->second / 910) % 1000);
370 } 382 }
371} 383}
372 384
@@ -385,7 +397,8 @@ static int msp3400c_detect_stereo(struct i2c_client *client)
385 val = msp_read_dsp(client, 0x18); 397 val = msp_read_dsp(client, 0x18);
386 if (val > 32767) 398 if (val > 32767)
387 val -= 65536; 399 val -= 65536;
388 v4l_dbg(2, msp_debug, client, "stereo detect register: %d\n", val); 400 v4l_dbg(2, msp_debug, client,
401 "stereo detect register: %d\n", val);
389 if (val > 8192) { 402 if (val > 8192) {
390 rxsubchans = V4L2_TUNER_SUB_STEREO; 403 rxsubchans = V4L2_TUNER_SUB_STEREO;
391 } else if (val < -4096) { 404 } else if (val < -4096) {
@@ -430,7 +443,8 @@ static int msp3400c_detect_stereo(struct i2c_client *client)
430 } 443 }
431 if (rxsubchans != state->rxsubchans) { 444 if (rxsubchans != state->rxsubchans) {
432 update = 1; 445 update = 1;
433 v4l_dbg(1, msp_debug, client, "watch: rxsubchans %02x => %02x\n", 446 v4l_dbg(1, msp_debug, client,
447 "watch: rxsubchans %02x => %02x\n",
434 state->rxsubchans, rxsubchans); 448 state->rxsubchans, rxsubchans);
435 state->rxsubchans = rxsubchans; 449 state->rxsubchans = rxsubchans;
436 } 450 }
@@ -452,9 +466,8 @@ static void watch_stereo(struct i2c_client *client)
452{ 466{
453 struct msp_state *state = i2c_get_clientdata(client); 467 struct msp_state *state = i2c_get_clientdata(client);
454 468
455 if (msp_detect_stereo(client)) { 469 if (msp_detect_stereo(client))
456 msp_set_audmode(client); 470 msp_set_audmode(client);
457 }
458 471
459 if (msp_once) 472 if (msp_once)
460 state->watch_stereo = 0; 473 state->watch_stereo = 0;
@@ -465,7 +478,7 @@ int msp3400c_thread(void *data)
465 struct i2c_client *client = data; 478 struct i2c_client *client = data;
466 struct msp_state *state = i2c_get_clientdata(client); 479 struct msp_state *state = i2c_get_clientdata(client);
467 struct msp3400c_carrier_detect *cd; 480 struct msp3400c_carrier_detect *cd;
468 int count, max1, max2, val1, val2, val, this; 481 int count, max1, max2, val1, val2, val, i;
469 482
470 483
471 v4l_dbg(1, msp_debug, client, "msp3400 daemon started\n"); 484 v4l_dbg(1, msp_debug, client, "msp3400 daemon started\n");
@@ -475,7 +488,7 @@ int msp3400c_thread(void *data)
475 msp_sleep(state, -1); 488 msp_sleep(state, -1);
476 v4l_dbg(2, msp_debug, client, "msp3400 thread: wakeup\n"); 489 v4l_dbg(2, msp_debug, client, "msp3400 thread: wakeup\n");
477 490
478 restart: 491restart:
479 v4l_dbg(2, msp_debug, client, "thread: restart scan\n"); 492 v4l_dbg(2, msp_debug, client, "thread: restart scan\n");
480 state->restart = 0; 493 state->restart = 0;
481 if (kthread_should_stop()) 494 if (kthread_should_stop())
@@ -483,7 +496,8 @@ int msp3400c_thread(void *data)
483 496
484 if (state->radio || MSP_MODE_EXTERN == state->mode) { 497 if (state->radio || MSP_MODE_EXTERN == state->mode) {
485 /* no carrier scan, just unmute */ 498 /* no carrier scan, just unmute */
486 v4l_dbg(1, msp_debug, client, "thread: no carrier scan\n"); 499 v4l_dbg(1, msp_debug, client,
500 "thread: no carrier scan\n");
487 state->scan_in_progress = 0; 501 state->scan_in_progress = 0;
488 msp_set_audio(client); 502 msp_set_audio(client);
489 continue; 503 continue;
@@ -514,16 +528,17 @@ int msp3400c_thread(void *data)
514 v4l_dbg(1, msp_debug, client, "AM sound override\n"); 528 v4l_dbg(1, msp_debug, client, "AM sound override\n");
515 } 529 }
516 530
517 for (this = 0; this < count; this++) { 531 for (i = 0; i < count; i++) {
518 msp3400c_set_carrier(client, cd[this].cdo, cd[this].cdo); 532 msp3400c_set_carrier(client, cd[i].cdo, cd[i].cdo);
519 if (msp_sleep(state,100)) 533 if (msp_sleep(state, 100))
520 goto restart; 534 goto restart;
521 val = msp_read_dsp(client, 0x1b); 535 val = msp_read_dsp(client, 0x1b);
522 if (val > 32767) 536 if (val > 32767)
523 val -= 65536; 537 val -= 65536;
524 if (val1 < val) 538 if (val1 < val)
525 val1 = val, max1 = this; 539 val1 = val, max1 = i;
526 v4l_dbg(1, msp_debug, client, "carrier1 val: %5d / %s\n", val,cd[this].name); 540 v4l_dbg(1, msp_debug, client,
541 "carrier1 val: %5d / %s\n", val, cd[i].name);
527 } 542 }
528 543
529 /* carrier detect pass #2 -- second (stereo) carrier */ 544 /* carrier detect pass #2 -- second (stereo) carrier */
@@ -550,16 +565,17 @@ int msp3400c_thread(void *data)
550 count = 0; 565 count = 0;
551 max2 = 0; 566 max2 = 0;
552 } 567 }
553 for (this = 0; this < count; this++) { 568 for (i = 0; i < count; i++) {
554 msp3400c_set_carrier(client, cd[this].cdo, cd[this].cdo); 569 msp3400c_set_carrier(client, cd[i].cdo, cd[i].cdo);
555 if (msp_sleep(state,100)) 570 if (msp_sleep(state, 100))
556 goto restart; 571 goto restart;
557 val = msp_read_dsp(client, 0x1b); 572 val = msp_read_dsp(client, 0x1b);
558 if (val > 32767) 573 if (val > 32767)
559 val -= 65536; 574 val -= 65536;
560 if (val2 < val) 575 if (val2 < val)
561 val2 = val, max2 = this; 576 val2 = val, max2 = i;
562 v4l_dbg(1, msp_debug, client, "carrier2 val: %5d / %s\n", val,cd[this].name); 577 v4l_dbg(1, msp_debug, client,
578 "carrier2 val: %5d / %s\n", val, cd[i].name);
563 } 579 }
564 580
565 /* program the msp3400 according to the results */ 581 /* program the msp3400 according to the results */
@@ -611,7 +627,7 @@ int msp3400c_thread(void *data)
611 break; 627 break;
612 case 0: /* 4.5 */ 628 case 0: /* 4.5 */
613 default: 629 default:
614 no_second: 630no_second:
615 state->second = msp3400c_carrier_detect_main[max1].cdo; 631 state->second = msp3400c_carrier_detect_main[max1].cdo;
616 msp3400c_set_mode(client, MSP_MODE_FM_TERRA); 632 msp3400c_set_mode(client, MSP_MODE_FM_TERRA);
617 break; 633 break;
@@ -632,7 +648,8 @@ int msp3400c_thread(void *data)
632 while (state->watch_stereo) { 648 while (state->watch_stereo) {
633 if (msp_sleep(state, count ? 1000 : 5000)) 649 if (msp_sleep(state, count ? 1000 : 5000))
634 goto restart; 650 goto restart;
635 if (count) count--; 651 if (count)
652 count--;
636 watch_stereo(client); 653 watch_stereo(client);
637 } 654 }
638 } 655 }
@@ -651,10 +668,10 @@ int msp3410d_thread(void *data)
651 set_freezable(); 668 set_freezable();
652 for (;;) { 669 for (;;) {
653 v4l_dbg(2, msp_debug, client, "msp3410 thread: sleep\n"); 670 v4l_dbg(2, msp_debug, client, "msp3410 thread: sleep\n");
654 msp_sleep(state,-1); 671 msp_sleep(state, -1);
655 v4l_dbg(2, msp_debug, client, "msp3410 thread: wakeup\n"); 672 v4l_dbg(2, msp_debug, client, "msp3410 thread: wakeup\n");
656 673
657 restart: 674restart:
658 v4l_dbg(2, msp_debug, client, "thread: restart scan\n"); 675 v4l_dbg(2, msp_debug, client, "thread: restart scan\n");
659 state->restart = 0; 676 state->restart = 0;
660 if (kthread_should_stop()) 677 if (kthread_should_stop())
@@ -662,7 +679,8 @@ int msp3410d_thread(void *data)
662 679
663 if (state->mode == MSP_MODE_EXTERN) { 680 if (state->mode == MSP_MODE_EXTERN) {
664 /* no carrier scan needed, just unmute */ 681 /* no carrier scan needed, just unmute */
665 v4l_dbg(1, msp_debug, client, "thread: no carrier scan\n"); 682 v4l_dbg(1, msp_debug, client,
683 "thread: no carrier scan\n");
666 state->scan_in_progress = 0; 684 state->scan_in_progress = 0;
667 msp_set_audio(client); 685 msp_set_audio(client);
668 continue; 686 continue;
@@ -673,7 +691,8 @@ int msp3410d_thread(void *data)
673 msp_set_audio(client); 691 msp_set_audio(client);
674 692
675 /* start autodetect. Note: autodetect is not supported for 693 /* start autodetect. Note: autodetect is not supported for
676 NTSC-M and radio, hence we force the standard in those cases. */ 694 NTSC-M and radio, hence we force the standard in those
695 cases. */
677 if (state->radio) 696 if (state->radio)
678 std = 0x40; 697 std = 0x40;
679 else 698 else
@@ -686,8 +705,9 @@ int msp3410d_thread(void *data)
686 goto restart; 705 goto restart;
687 706
688 if (msp_debug) 707 if (msp_debug)
689 v4l_dbg(2, msp_debug, client, "setting standard: %s (0x%04x)\n", 708 v4l_dbg(2, msp_debug, client,
690 msp_standard_std_name(std), std); 709 "setting standard: %s (0x%04x)\n",
710 msp_standard_std_name(std), std);
691 711
692 if (std != 1) { 712 if (std != 1) {
693 /* programmed some specific mode */ 713 /* programmed some specific mode */
@@ -703,7 +723,8 @@ int msp3410d_thread(void *data)
703 val = msp_read_dem(client, 0x7e); 723 val = msp_read_dem(client, 0x7e);
704 if (val < 0x07ff) 724 if (val < 0x07ff)
705 break; 725 break;
706 v4l_dbg(2, msp_debug, client, "detection still in progress\n"); 726 v4l_dbg(2, msp_debug, client,
727 "detection still in progress\n");
707 } 728 }
708 } 729 }
709 for (i = 0; msp_stdlist[i].name != NULL; i++) 730 for (i = 0; msp_stdlist[i].name != NULL; i++)
@@ -716,12 +737,13 @@ int msp3410d_thread(void *data)
716 state->std = val; 737 state->std = val;
717 state->rxsubchans = V4L2_TUNER_SUB_MONO; 738 state->rxsubchans = V4L2_TUNER_SUB_MONO;
718 739
719 if (msp_amsound && !state->radio && (state->v4l2_std & V4L2_STD_SECAM) && 740 if (msp_amsound && !state->radio &&
720 (val != 0x0009)) { 741 (state->v4l2_std & V4L2_STD_SECAM) && (val != 0x0009)) {
721 /* autodetection has failed, let backup */ 742 /* autodetection has failed, let backup */
722 v4l_dbg(1, msp_debug, client, "autodetection failed," 743 v4l_dbg(1, msp_debug, client, "autodetection failed,"
723 " switching to backup standard: %s (0x%04x)\n", 744 " switching to backup standard: %s (0x%04x)\n",
724 msp_stdlist[8].name ? msp_stdlist[8].name : "unknown",val); 745 msp_stdlist[8].name ?
746 msp_stdlist[8].name : "unknown", val);
725 state->std = val = 0x0009; 747 state->std = val = 0x0009;
726 msp_write_dem(client, 0x20, val); 748 msp_write_dem(client, 0x20, val);
727 } 749 }
@@ -786,7 +808,8 @@ int msp3410d_thread(void *data)
786 while (state->watch_stereo) { 808 while (state->watch_stereo) {
787 if (msp_sleep(state, count ? 1000 : 5000)) 809 if (msp_sleep(state, count ? 1000 : 5000))
788 goto restart; 810 goto restart;
789 if (count) count--; 811 if (count)
812 count--;
790 watch_stereo(client); 813 watch_stereo(client);
791 } 814 }
792 } 815 }
@@ -872,8 +895,8 @@ static void msp34xxg_set_source(struct i2c_client *client, u16 reg, int in)
872 else 895 else
873 source = (in << 8) | matrix; 896 source = (in << 8) | matrix;
874 897
875 v4l_dbg(1, msp_debug, client, "set source to %d (0x%x) for output %02x\n", 898 v4l_dbg(1, msp_debug, client,
876 in, source, reg); 899 "set source to %d (0x%x) for output %02x\n", in, source, reg);
877 msp_write_dsp(client, reg, source); 900 msp_write_dsp(client, reg, source);
878} 901}
879 902
@@ -948,7 +971,7 @@ int msp34xxg_thread(void *data)
948 msp_sleep(state, -1); 971 msp_sleep(state, -1);
949 v4l_dbg(2, msp_debug, client, "msp34xxg thread: wakeup\n"); 972 v4l_dbg(2, msp_debug, client, "msp34xxg thread: wakeup\n");
950 973
951 restart: 974restart:
952 v4l_dbg(1, msp_debug, client, "thread: restart scan\n"); 975 v4l_dbg(1, msp_debug, client, "thread: restart scan\n");
953 state->restart = 0; 976 state->restart = 0;
954 if (kthread_should_stop()) 977 if (kthread_should_stop())
@@ -956,7 +979,8 @@ int msp34xxg_thread(void *data)
956 979
957 if (state->mode == MSP_MODE_EXTERN) { 980 if (state->mode == MSP_MODE_EXTERN) {
958 /* no carrier scan needed, just unmute */ 981 /* no carrier scan needed, just unmute */
959 v4l_dbg(1, msp_debug, client, "thread: no carrier scan\n"); 982 v4l_dbg(1, msp_debug, client,
983 "thread: no carrier scan\n");
960 state->scan_in_progress = 0; 984 state->scan_in_progress = 0;
961 msp_set_audio(client); 985 msp_set_audio(client);
962 continue; 986 continue;
@@ -972,7 +996,8 @@ int msp34xxg_thread(void *data)
972 goto unmute; 996 goto unmute;
973 997
974 /* watch autodetect */ 998 /* watch autodetect */
975 v4l_dbg(1, msp_debug, client, "started autodetect, waiting for result\n"); 999 v4l_dbg(1, msp_debug, client,
1000 "started autodetect, waiting for result\n");
976 for (i = 0; i < 10; i++) { 1001 for (i = 0; i < 10; i++) {
977 if (msp_sleep(state, 100)) 1002 if (msp_sleep(state, 100))
978 goto restart; 1003 goto restart;
@@ -983,15 +1008,18 @@ int msp34xxg_thread(void *data)
983 state->std = val; 1008 state->std = val;
984 break; 1009 break;
985 } 1010 }
986 v4l_dbg(2, msp_debug, client, "detection still in progress\n"); 1011 v4l_dbg(2, msp_debug, client,
1012 "detection still in progress\n");
987 } 1013 }
988 if (state->std == 1) { 1014 if (state->std == 1) {
989 v4l_dbg(1, msp_debug, client, "detection still in progress after 10 tries. giving up.\n"); 1015 v4l_dbg(1, msp_debug, client,
1016 "detection still in progress after 10 tries. giving up.\n");
990 continue; 1017 continue;
991 } 1018 }
992 1019
993 unmute: 1020unmute:
994 v4l_dbg(1, msp_debug, client, "detected standard: %s (0x%04x)\n", 1021 v4l_dbg(1, msp_debug, client,
1022 "detected standard: %s (0x%04x)\n",
995 msp_standard_std_name(state->std), state->std); 1023 msp_standard_std_name(state->std), state->std);
996 1024
997 if (state->std == 9) { 1025 if (state->std == 9) {
@@ -1046,9 +1074,11 @@ static int msp34xxg_detect_stereo(struct i2c_client *client)
1046 if (state->std == 0x20) 1074 if (state->std == 0x20)
1047 state->rxsubchans |= V4L2_TUNER_SUB_SAP; 1075 state->rxsubchans |= V4L2_TUNER_SUB_SAP;
1048 else 1076 else
1049 state->rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2; 1077 state->rxsubchans =
1078 V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
1050 } 1079 }
1051 v4l_dbg(1, msp_debug, client, "status=0x%x, stereo=%d, bilingual=%d -> rxsubchans=%d\n", 1080 v4l_dbg(1, msp_debug, client,
1081 "status=0x%x, stereo=%d, bilingual=%d -> rxsubchans=%d\n",
1052 status, is_stereo, is_bilingual, state->rxsubchans); 1082 status, is_stereo, is_bilingual, state->rxsubchans);
1053 return (oldrx != state->rxsubchans); 1083 return (oldrx != state->rxsubchans);
1054} 1084}