aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb
diff options
context:
space:
mode:
authorMichael Krufky <mkrufky@linuxtv.org>2007-03-26 15:39:20 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-05-09 09:13:00 -0400
commite7b419b69212f3c3489ae808f26d2a0d2b52fe9c (patch)
tree380f9ecf8e909ef50e4f06136b291f6f21d88659 /drivers/media/dvb
parent5afb707120ec269725c71a2282ee3473c5bc04c1 (diff)
V4L/DVB (5610): M920x: remove duplicated code
Some of the devices supported by the m920x driver have identical functions used for tuner_attach and frontend_attach. This patch consolidates the functions in question, and updates the debug code to be generic for each. This patch decreases the size of the kernel. Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r--drivers/media/dvb/dvb-usb/m920x.c131
1 files changed, 44 insertions, 87 deletions
diff --git a/drivers/media/dvb/dvb-usb/m920x.c b/drivers/media/dvb/dvb-usb/m920x.c
index 3ebf0bcf47c9..f9fb791102be 100644
--- a/drivers/media/dvb/dvb-usb/m920x.c
+++ b/drivers/media/dvb/dvb-usb/m920x.c
@@ -381,7 +381,7 @@ static int m920x_identify_state(struct usb_device *udev,
381} 381}
382 382
383/* demod configurations */ 383/* demod configurations */
384static int megasky_mt352_demod_init(struct dvb_frontend *fe) 384static int m920x_mt352_demod_init(struct dvb_frontend *fe)
385{ 385{
386 u8 config[] = { CONFIG, 0x3d }; 386 u8 config[] = { CONFIG, 0x3d };
387 u8 clock[] = { CLOCK_CTL, 0x30 }; 387 u8 clock[] = { CLOCK_CTL, 0x30 };
@@ -406,13 +406,13 @@ static int megasky_mt352_demod_init(struct dvb_frontend *fe)
406 return 0; 406 return 0;
407} 407}
408 408
409static struct mt352_config megasky_mt352_config = { 409static struct mt352_config m920x_mt352_config = {
410 .demod_address = 0x0f, 410 .demod_address = 0x0f,
411 .no_tuner = 1, 411 .no_tuner = 1,
412 .demod_init = megasky_mt352_demod_init, 412 .demod_init = m920x_mt352_demod_init,
413}; 413};
414 414
415static struct tda1004x_config digivox_tda10046_config = { 415static struct tda1004x_config m920x_tda10046_08_config = {
416 .demod_address = 0x08, 416 .demod_address = 0x08,
417 .invert = 0, 417 .invert = 0,
418 .invert_oclk = 0, 418 .invert_oclk = 0,
@@ -424,19 +424,7 @@ static struct tda1004x_config digivox_tda10046_config = {
424 .request_firmware = NULL, 424 .request_firmware = NULL,
425}; 425};
426 426
427static struct tda1004x_config tvwalkertwin_0_tda10046_config = { 427static struct tda1004x_config m920x_tda10046_0b_config = {
428 .demod_address = 0x08,
429 .invert = 0,
430 .invert_oclk = 0,
431 .ts_mode = TDA10046_TS_SERIAL,
432 .xtal_freq = TDA10046_XTAL_16M,
433 .if_freq = TDA10046_FREQ_045,
434 .agc_config = TDA10046_AGC_TDA827X,
435 .gpio_config = TDA10046_GPTRI,
436 .request_firmware = NULL, /* uses firmware EEPROM */
437};
438
439static struct tda1004x_config tvwalkertwin_1_tda10046_config = {
440 .demod_address = 0x0b, 428 .demod_address = 0x0b,
441 .invert = 0, 429 .invert = 0,
442 .invert_oclk = 0, 430 .invert_oclk = 0,
@@ -449,114 +437,76 @@ static struct tda1004x_config tvwalkertwin_1_tda10046_config = {
449}; 437};
450 438
451/* tuner configurations */ 439/* tuner configurations */
452static struct qt1010_config megasky_qt1010_config = { 440static struct qt1010_config m920x_qt1010_config = {
453 .i2c_address = 0x62 441 .i2c_address = 0x62
454}; 442};
455 443
456/* Callbacks for DVB USB */ 444/* Callbacks for DVB USB */
457static int megasky_mt352_frontend_attach(struct dvb_usb_adapter *adap) 445static int m920x_mt352_frontend_attach(struct dvb_usb_adapter *adap)
458{ 446{
459 deb_rc("megasky_frontend_attach!\n"); 447 deb_rc("%s\n",__FUNCTION__);
460 448
461 if ((adap->fe = dvb_attach(mt352_attach, &megasky_mt352_config, 449 if ((adap->fe = dvb_attach(mt352_attach, &m920x_mt352_config,
462 &adap->dev->i2c_adap)) == NULL) 450 &adap->dev->i2c_adap)) == NULL)
463 return -EIO; 451 return -EIO;
464 452
465 return 0; 453 return 0;
466} 454}
467 455
468static int digivox_tda10046_frontend_attach(struct dvb_usb_adapter *adap) 456static int m920x_tda10046_08_frontend_attach(struct dvb_usb_adapter *adap)
469{
470 deb_rc("digivox_tda10046_frontend_attach!\n");
471
472 if ((adap->fe = dvb_attach(tda10046_attach, &digivox_tda10046_config,
473 &adap->dev->i2c_adap)) == NULL)
474 return -EIO;
475
476 return 0;
477}
478
479/* LifeView TV Walker Twin has 1 x M9206, 2 x TDA10046, 2 x TDA8275A
480 * TDA10046 #0 is located at i2c address 0x08
481 * TDA10046 #1 is located at i2c address 0x0b
482 * TDA8275A #0 is located at i2c address 0x60
483 * TDA8275A #1 is located at i2c address 0x61
484 */
485
486static int tvwalkertwin_0_tda10046_frontend_attach(struct dvb_usb_adapter *adap)
487{ 457{
488 deb_rc("tvwalkertwin_0_tda10046_frontend_attach!\n"); 458 deb_rc("%s\n",__FUNCTION__);
489 459
490 if ((adap->fe = dvb_attach(tda10046_attach, 460 if ((adap->fe = dvb_attach(tda10046_attach,
491 &tvwalkertwin_0_tda10046_config, 461 &m920x_tda10046_08_config,
492 &adap->dev->i2c_adap)) == NULL) 462 &adap->dev->i2c_adap)) == NULL)
493 return -EIO; 463 return -EIO;
494 464
495 deb_rc("Attached demod 0 at address %02x\n",
496 tvwalkertwin_0_tda10046_config.demod_address);
497
498 return 0; 465 return 0;
499} 466}
500 467
501static int tvwalkertwin_1_tda10046_frontend_attach(struct dvb_usb_adapter *adap) 468static int m920x_tda10046_0b_frontend_attach(struct dvb_usb_adapter *adap)
502{ 469{
503 deb_rc("tvwalkertwin_1_tda10046_frontend_attach!\n"); 470 deb_rc("%s\n",__FUNCTION__);
504 471
505 if ((adap->fe = dvb_attach(tda10046_attach, 472 if ((adap->fe = dvb_attach(tda10046_attach,
506 &tvwalkertwin_1_tda10046_config, 473 &m920x_tda10046_0b_config,
507 &adap->dev->i2c_adap)) == NULL) 474 &adap->dev->i2c_adap)) == NULL)
508 return -EIO; 475 return -EIO;
509 476
510 deb_rc("Attached demod 1 at address %02x\n",
511 tvwalkertwin_1_tda10046_config.demod_address);
512
513 return 0; 477 return 0;
514} 478}
515 479
516static int megasky_qt1010_tuner_attach(struct dvb_usb_adapter *adap) 480static int m920x_qt1010_tuner_attach(struct dvb_usb_adapter *adap)
517{ 481{
482 deb_rc("%s\n",__FUNCTION__);
483
518 if (dvb_attach(qt1010_attach, adap->fe, &adap->dev->i2c_adap, 484 if (dvb_attach(qt1010_attach, adap->fe, &adap->dev->i2c_adap,
519 &megasky_qt1010_config) == NULL) 485 &m920x_qt1010_config) == NULL)
520 return -ENODEV; 486 return -ENODEV;
521 487
522 return 0; 488 return 0;
523} 489}
524 490
525static int digivox_tda8275_tuner_attach(struct dvb_usb_adapter *adap) 491static int m920x_tda8275_60_tuner_attach(struct dvb_usb_adapter *adap)
526{
527 if (dvb_attach(tda827x_attach, adap->fe, 0x60, &adap->dev->i2c_adap,
528 NULL) == NULL)
529 return -ENODEV;
530 return 0;
531}
532
533static int tvwalkertwin_0_tda8275_tuner_attach(struct dvb_usb_adapter *adap)
534{ 492{
535 int address = 0x60; 493 deb_rc("%s\n",__FUNCTION__);
536 494
537 deb_rc("tvwalkertwin_0_tda8275_tuner_attach!\n"); 495 if (dvb_attach(tda827x_attach, adap->fe, 0x60, &adap->dev->i2c_adap,
538
539 if (dvb_attach(tda827x_attach, adap->fe, address, &adap->dev->i2c_adap,
540 NULL) == NULL) 496 NULL) == NULL)
541 return -ENODEV; 497 return -ENODEV;
542 498
543 deb_rc("Attached tuner 0 at address %02x\n", address);
544
545 return 0; 499 return 0;
546} 500}
547 501
548static int tvwalkertwin_1_tda8275_tuner_attach(struct dvb_usb_adapter *adap) 502static int m920x_tda8275_61_tuner_attach(struct dvb_usb_adapter *adap)
549{ 503{
550 int address = 0x61; 504 deb_rc("%s\n",__FUNCTION__);
551 505
552 deb_rc("tvwalkertwin_1_tda8275_tuner_attach!\n"); 506 if (dvb_attach(tda827x_attach, adap->fe, 0x61, &adap->dev->i2c_adap,
553
554 if (dvb_attach(tda827x_attach, adap->fe, address, &adap->dev->i2c_adap,
555 NULL) == NULL) 507 NULL) == NULL)
556 return -ENODEV; 508 return -ENODEV;
557 509
558 deb_rc("Attached tuner 1 at address %02x\n", address);
559
560 return 0; 510 return 0;
561} 511}
562 512
@@ -676,7 +626,7 @@ static int m920x_probe(struct usb_interface *intf,
676 return -ENODEV; 626 return -ENODEV;
677 } 627 }
678 628
679found: 629 found:
680 alt = usb_altnum_to_altsetting(intf, 1); 630 alt = usb_altnum_to_altsetting(intf, 1);
681 if (alt == NULL) { 631 if (alt == NULL) {
682 deb_rc("No alt found!\n"); 632 deb_rc("No alt found!\n");
@@ -732,8 +682,8 @@ static struct dvb_usb_device_properties megasky_properties = {
732 .pid_filter = m9206_pid_filter, 682 .pid_filter = m9206_pid_filter,
733 .pid_filter_ctrl = m9206_pid_filter_ctrl, 683 .pid_filter_ctrl = m9206_pid_filter_ctrl,
734 684
735 .frontend_attach = megasky_mt352_frontend_attach, 685 .frontend_attach = m920x_mt352_frontend_attach,
736 .tuner_attach = megasky_qt1010_tuner_attach, 686 .tuner_attach = m920x_qt1010_tuner_attach,
737 687
738 .stream = { 688 .stream = {
739 .type = USB_BULK, 689 .type = USB_BULK,
@@ -776,8 +726,8 @@ static struct dvb_usb_device_properties digivox_mini_ii_properties = {
776 .pid_filter = m9206_pid_filter, 726 .pid_filter = m9206_pid_filter,
777 .pid_filter_ctrl = m9206_pid_filter_ctrl, 727 .pid_filter_ctrl = m9206_pid_filter_ctrl,
778 728
779 .frontend_attach = digivox_tda10046_frontend_attach, 729 .frontend_attach = m920x_tda10046_08_frontend_attach,
780 .tuner_attach = digivox_tda8275_tuner_attach, 730 .tuner_attach = m920x_tda8275_60_tuner_attach,
781 731
782 .stream = { 732 .stream = {
783 .type = USB_BULK, 733 .type = USB_BULK,
@@ -801,7 +751,14 @@ static struct dvb_usb_device_properties digivox_mini_ii_properties = {
801 } 751 }
802}; 752};
803 753
804/* LifeView TV Walker Twin support by Nick Andrew <nick@nick-andrew.net> */ 754/* LifeView TV Walker Twin support by Nick Andrew <nick@nick-andrew.net>
755 *
756 * LifeView TV Walker Twin has 1 x M9206, 2 x TDA10046, 2 x TDA8275A
757 * TDA10046 #0 is located at i2c address 0x08
758 * TDA10046 #1 is located at i2c address 0x0b
759 * TDA8275A #0 is located at i2c address 0x60
760 * TDA8275A #1 is located at i2c address 0x61
761 */
805static struct dvb_usb_device_properties tvwalkertwin_properties = { 762static struct dvb_usb_device_properties tvwalkertwin_properties = {
806 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 763 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
807 764
@@ -826,8 +783,8 @@ static struct dvb_usb_device_properties tvwalkertwin_properties = {
826 .pid_filter = m9206_pid_filter, 783 .pid_filter = m9206_pid_filter,
827 .pid_filter_ctrl = m9206_pid_filter_ctrl, 784 .pid_filter_ctrl = m9206_pid_filter_ctrl,
828 785
829 .frontend_attach = tvwalkertwin_0_tda10046_frontend_attach, 786 .frontend_attach = m920x_tda10046_08_frontend_attach,
830 .tuner_attach = tvwalkertwin_0_tda8275_tuner_attach, 787 .tuner_attach = m920x_tda8275_60_tuner_attach,
831 788
832 .stream = { 789 .stream = {
833 .type = USB_BULK, 790 .type = USB_BULK,
@@ -846,8 +803,8 @@ static struct dvb_usb_device_properties tvwalkertwin_properties = {
846 .pid_filter = m9206_pid_filter, 803 .pid_filter = m9206_pid_filter,
847 .pid_filter_ctrl = m9206_pid_filter_ctrl, 804 .pid_filter_ctrl = m9206_pid_filter_ctrl,
848 805
849 .frontend_attach = tvwalkertwin_1_tda10046_frontend_attach, 806 .frontend_attach = m920x_tda10046_0b_frontend_attach,
850 .tuner_attach = tvwalkertwin_1_tda8275_tuner_attach, 807 .tuner_attach = m920x_tda8275_61_tuner_attach,
851 808
852 .stream = { 809 .stream = {
853 .type = USB_BULK, 810 .type = USB_BULK,
@@ -885,8 +842,8 @@ static struct dvb_usb_device_properties dposh_properties = {
885 .adapter = {{ 842 .adapter = {{
886 /* Hardware pid filters don't work with this device/firmware */ 843 /* Hardware pid filters don't work with this device/firmware */
887 844
888 .frontend_attach = megasky_mt352_frontend_attach, 845 .frontend_attach = m920x_mt352_frontend_attach,
889 .tuner_attach = megasky_qt1010_tuner_attach, 846 .tuner_attach = m920x_qt1010_tuner_attach,
890 847
891 .stream = { 848 .stream = {
892 .type = USB_BULK, 849 .type = USB_BULK,