diff options
author | Andrew de Quincey <adq_dvb@lidskialf.net> | 2006-04-18 16:47:11 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-06-25 00:59:05 -0400 |
commit | e87d41c4952ceef7a9f760f38f9343d015279662 (patch) | |
tree | f3c5623d83d3351361f01fed526fa2cf6f26f9cd /drivers/media/dvb/ttpci | |
parent | 0f591d409b63999ee8053df9cfbedd77bfbf3b22 (diff) |
V4L/DVB (3877): Convert ttpci/budget-av to refactored tuner code
Rename pll calls to appropriate tuner calls.
Remove pll functions from demod structures.
Hook tuner call into tuner_ops.
Add pll gate control calls where appropriate.
Signed-off-by: Andrew de Quincey <adq_dvb@lidskialf.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/dvb/ttpci')
-rw-r--r-- | drivers/media/dvb/ttpci/budget-av.c | 85 |
1 files changed, 58 insertions, 27 deletions
diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c index dc78aadf002a..9bd069e4e11a 100644 --- a/drivers/media/dvb/ttpci/budget-av.c +++ b/drivers/media/dvb/ttpci/budget-av.c | |||
@@ -472,12 +472,12 @@ static int philips_su1278_ty_ci_set_symbol_rate(struct dvb_frontend *fe, u32 sra | |||
472 | return 0; | 472 | return 0; |
473 | } | 473 | } |
474 | 474 | ||
475 | static int philips_su1278_ty_ci_pll_set(struct dvb_frontend *fe, | 475 | static int philips_su1278_ty_ci_tuner_set_params(struct dvb_frontend *fe, |
476 | struct i2c_adapter *i2c, | 476 | struct dvb_frontend_parameters *params) |
477 | struct dvb_frontend_parameters *params) | ||
478 | { | 477 | { |
479 | u32 div; | 478 | u32 div; |
480 | u8 buf[4]; | 479 | u8 buf[4]; |
480 | struct budget *budget = (struct budget *) fe->dvb->priv; | ||
481 | struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) }; | 481 | struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) }; |
482 | 482 | ||
483 | if ((params->frequency < 950000) || (params->frequency > 2150000)) | 483 | if ((params->frequency < 950000) || (params->frequency > 2150000)) |
@@ -501,7 +501,9 @@ static int philips_su1278_ty_ci_pll_set(struct dvb_frontend *fe, | |||
501 | else if (params->frequency < 2150000) | 501 | else if (params->frequency < 2150000) |
502 | buf[3] |= 0xC0; | 502 | buf[3] |= 0xC0; |
503 | 503 | ||
504 | if (i2c_transfer(i2c, &msg, 1) != 1) | 504 | if (fe->ops->i2c_gate_ctrl) |
505 | fe->ops->i2c_gate_ctrl(fe, 1); | ||
506 | if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1) | ||
505 | return -EIO; | 507 | return -EIO; |
506 | return 0; | 508 | return 0; |
507 | } | 509 | } |
@@ -509,9 +511,8 @@ static int philips_su1278_ty_ci_pll_set(struct dvb_frontend *fe, | |||
509 | #define MIN2(a,b) ((a) < (b) ? (a) : (b)) | 511 | #define MIN2(a,b) ((a) < (b) ? (a) : (b)) |
510 | #define MIN3(a,b,c) MIN2(MIN2(a,b),c) | 512 | #define MIN3(a,b,c) MIN2(MIN2(a,b),c) |
511 | 513 | ||
512 | static int philips_su1278sh2_tua6100_pll_set(struct dvb_frontend *fe, | 514 | static int philips_su1278sh2_tua6100_tuner_set_params(struct dvb_frontend *fe, |
513 | struct i2c_adapter *i2c, | 515 | struct dvb_frontend_parameters *params) |
514 | struct dvb_frontend_parameters *params) | ||
515 | { | 516 | { |
516 | u8 reg0 [2] = { 0x00, 0x00 }; | 517 | u8 reg0 [2] = { 0x00, 0x00 }; |
517 | u8 reg1 [4] = { 0x01, 0x00, 0x00, 0x00 }; | 518 | u8 reg1 [4] = { 0x01, 0x00, 0x00, 0x00 }; |
@@ -521,6 +522,7 @@ static int philips_su1278sh2_tua6100_pll_set(struct dvb_frontend *fe, | |||
521 | int R, A, N, P, M; | 522 | int R, A, N, P, M; |
522 | struct i2c_msg msg = {.addr = 0x60,.flags = 0,.buf = NULL,.len = 0 }; | 523 | struct i2c_msg msg = {.addr = 0x60,.flags = 0,.buf = NULL,.len = 0 }; |
523 | int freq = params->frequency; | 524 | int freq = params->frequency; |
525 | struct budget *budget = (struct budget *) fe->dvb->priv; | ||
524 | 526 | ||
525 | first_ZF = (freq) / 1000; | 527 | first_ZF = (freq) / 1000; |
526 | 528 | ||
@@ -620,21 +622,25 @@ static int philips_su1278sh2_tua6100_pll_set(struct dvb_frontend *fe, | |||
620 | reg0[1] |= 0x03; | 622 | reg0[1] |= 0x03; |
621 | 623 | ||
622 | /* already enabled - do not reenable i2c repeater or TX fails */ | 624 | /* already enabled - do not reenable i2c repeater or TX fails */ |
625 | if (fe->ops->i2c_gate_ctrl) | ||
626 | fe->ops->i2c_gate_ctrl(fe, 1); | ||
623 | msg.buf = reg0; | 627 | msg.buf = reg0; |
624 | msg.len = sizeof(reg0); | 628 | msg.len = sizeof(reg0); |
625 | if (i2c_transfer(i2c, &msg, 1) != 1) | 629 | if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1) |
626 | return -EIO; | 630 | return -EIO; |
627 | 631 | ||
628 | stv0299_enable_plli2c(fe); | 632 | if (fe->ops->i2c_gate_ctrl) |
633 | fe->ops->i2c_gate_ctrl(fe, 1); | ||
629 | msg.buf = reg1; | 634 | msg.buf = reg1; |
630 | msg.len = sizeof(reg1); | 635 | msg.len = sizeof(reg1); |
631 | if (i2c_transfer(i2c, &msg, 1) != 1) | 636 | if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1) |
632 | return -EIO; | 637 | return -EIO; |
633 | 638 | ||
634 | stv0299_enable_plli2c(fe); | 639 | if (fe->ops->i2c_gate_ctrl) |
640 | fe->ops->i2c_gate_ctrl(fe, 1); | ||
635 | msg.buf = reg2; | 641 | msg.buf = reg2; |
636 | msg.len = sizeof(reg2); | 642 | msg.len = sizeof(reg2); |
637 | if (i2c_transfer(i2c, &msg, 1) != 1) | 643 | if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1) |
638 | return -EIO; | 644 | return -EIO; |
639 | 645 | ||
640 | return 0; | 646 | return 0; |
@@ -692,7 +698,6 @@ static struct stv0299_config typhoon_config = { | |||
692 | .volt13_op0_op1 = STV0299_VOLT13_OP0, | 698 | .volt13_op0_op1 = STV0299_VOLT13_OP0, |
693 | .min_delay_ms = 100, | 699 | .min_delay_ms = 100, |
694 | .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate, | 700 | .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate, |
695 | .pll_set = philips_su1278_ty_ci_pll_set, | ||
696 | }; | 701 | }; |
697 | 702 | ||
698 | 703 | ||
@@ -706,7 +711,6 @@ static struct stv0299_config cinergy_1200s_config = { | |||
706 | .volt13_op0_op1 = STV0299_VOLT13_OP0, | 711 | .volt13_op0_op1 = STV0299_VOLT13_OP0, |
707 | .min_delay_ms = 100, | 712 | .min_delay_ms = 100, |
708 | .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate, | 713 | .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate, |
709 | .pll_set = philips_su1278_ty_ci_pll_set, | ||
710 | }; | 714 | }; |
711 | 715 | ||
712 | static struct stv0299_config cinergy_1200s_1894_0010_config = { | 716 | static struct stv0299_config cinergy_1200s_1894_0010_config = { |
@@ -719,10 +723,9 @@ static struct stv0299_config cinergy_1200s_1894_0010_config = { | |||
719 | .volt13_op0_op1 = STV0299_VOLT13_OP0, | 723 | .volt13_op0_op1 = STV0299_VOLT13_OP0, |
720 | .min_delay_ms = 100, | 724 | .min_delay_ms = 100, |
721 | .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate, | 725 | .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate, |
722 | .pll_set = philips_su1278sh2_tua6100_pll_set, | ||
723 | }; | 726 | }; |
724 | 727 | ||
725 | static int philips_cu1216_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) | 728 | static int philips_cu1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) |
726 | { | 729 | { |
727 | struct budget *budget = (struct budget *) fe->dvb->priv; | 730 | struct budget *budget = (struct budget *) fe->dvb->priv; |
728 | u8 buf[4]; | 731 | u8 buf[4]; |
@@ -738,6 +741,8 @@ static int philips_cu1216_pll_set(struct dvb_frontend *fe, struct dvb_frontend_p | |||
738 | buf[3] = (params->frequency < 150000000 ? 0x01 : | 741 | buf[3] = (params->frequency < 150000000 ? 0x01 : |
739 | params->frequency < 445000000 ? 0x02 : 0x04); | 742 | params->frequency < 445000000 ? 0x02 : 0x04); |
740 | 743 | ||
744 | if (fe->ops->i2c_gate_ctrl) | ||
745 | fe->ops->i2c_gate_ctrl(fe, 1); | ||
741 | if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1) | 746 | if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1) |
742 | return -EIO; | 747 | return -EIO; |
743 | return 0; | 748 | return 0; |
@@ -745,19 +750,20 @@ static int philips_cu1216_pll_set(struct dvb_frontend *fe, struct dvb_frontend_p | |||
745 | 750 | ||
746 | static struct tda10021_config philips_cu1216_config = { | 751 | static struct tda10021_config philips_cu1216_config = { |
747 | .demod_address = 0x0c, | 752 | .demod_address = 0x0c, |
748 | .pll_set = philips_cu1216_pll_set, | ||
749 | }; | 753 | }; |
750 | 754 | ||
751 | 755 | ||
752 | 756 | ||
753 | 757 | ||
754 | static int philips_tu1216_pll_init(struct dvb_frontend *fe) | 758 | static int philips_tu1216_tuner_init(struct dvb_frontend *fe) |
755 | { | 759 | { |
756 | struct budget *budget = (struct budget *) fe->dvb->priv; | 760 | struct budget *budget = (struct budget *) fe->dvb->priv; |
757 | static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab }; | 761 | static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab }; |
758 | struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) }; | 762 | struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) }; |
759 | 763 | ||
760 | // setup PLL configuration | 764 | // setup PLL configuration |
765 | if (fe->ops->i2c_gate_ctrl) | ||
766 | fe->ops->i2c_gate_ctrl(fe, 1); | ||
761 | if (i2c_transfer(&budget->i2c_adap, &tuner_msg, 1) != 1) | 767 | if (i2c_transfer(&budget->i2c_adap, &tuner_msg, 1) != 1) |
762 | return -EIO; | 768 | return -EIO; |
763 | msleep(1); | 769 | msleep(1); |
@@ -765,7 +771,7 @@ static int philips_tu1216_pll_init(struct dvb_frontend *fe) | |||
765 | return 0; | 771 | return 0; |
766 | } | 772 | } |
767 | 773 | ||
768 | static int philips_tu1216_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) | 774 | static int philips_tu1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) |
769 | { | 775 | { |
770 | struct budget *budget = (struct budget *) fe->dvb->priv; | 776 | struct budget *budget = (struct budget *) fe->dvb->priv; |
771 | u8 tuner_buf[4]; | 777 | u8 tuner_buf[4]; |
@@ -839,6 +845,8 @@ static int philips_tu1216_pll_set(struct dvb_frontend *fe, struct dvb_frontend_p | |||
839 | tuner_buf[2] = 0xca; | 845 | tuner_buf[2] = 0xca; |
840 | tuner_buf[3] = (cp << 5) | (filter << 3) | band; | 846 | tuner_buf[3] = (cp << 5) | (filter << 3) | band; |
841 | 847 | ||
848 | if (fe->ops->i2c_gate_ctrl) | ||
849 | fe->ops->i2c_gate_ctrl(fe, 1); | ||
842 | if (i2c_transfer(&budget->i2c_adap, &tuner_msg, 1) != 1) | 850 | if (i2c_transfer(&budget->i2c_adap, &tuner_msg, 1) != 1) |
843 | return -EIO; | 851 | return -EIO; |
844 | 852 | ||
@@ -862,9 +870,6 @@ static struct tda1004x_config philips_tu1216_config = { | |||
862 | .xtal_freq = TDA10046_XTAL_4M, | 870 | .xtal_freq = TDA10046_XTAL_4M, |
863 | .agc_config = TDA10046_AGC_DEFAULT, | 871 | .agc_config = TDA10046_AGC_DEFAULT, |
864 | .if_freq = TDA10046_FREQ_3617, | 872 | .if_freq = TDA10046_FREQ_3617, |
865 | .pll_init = philips_tu1216_pll_init, | ||
866 | .pll_set = philips_tu1216_pll_set, | ||
867 | .pll_sleep = NULL, | ||
868 | .request_firmware = philips_tu1216_request_firmware, | 873 | .request_firmware = philips_tu1216_request_firmware, |
869 | }; | 874 | }; |
870 | 875 | ||
@@ -911,13 +916,13 @@ static u8 philips_sd1878_inittab[] = { | |||
911 | 0xff, 0xff | 916 | 0xff, 0xff |
912 | }; | 917 | }; |
913 | 918 | ||
914 | static int philips_sd1878_tda8261_pll_set(struct dvb_frontend *fe, | 919 | static int philips_sd1878_tda8261_tuner_set_params(struct dvb_frontend *fe, |
915 | struct i2c_adapter *i2c, | 920 | struct dvb_frontend_parameters *params) |
916 | struct dvb_frontend_parameters *params) | ||
917 | { | 921 | { |
918 | u8 buf[4]; | 922 | u8 buf[4]; |
919 | int rc; | 923 | int rc; |
920 | struct i2c_msg tuner_msg = {.addr=0x60,.flags=0,.buf=buf,.len=sizeof(buf)}; | 924 | struct i2c_msg tuner_msg = {.addr=0x60,.flags=0,.buf=buf,.len=sizeof(buf)}; |
925 | struct budget *budget = (struct budget *) fe->dvb->priv; | ||
921 | 926 | ||
922 | if((params->frequency < 950000) || (params->frequency > 2150000)) | 927 | if((params->frequency < 950000) || (params->frequency > 2150000)) |
923 | return -EINVAL; | 928 | return -EINVAL; |
@@ -926,7 +931,9 @@ static int philips_sd1878_tda8261_pll_set(struct dvb_frontend *fe, | |||
926 | params->frequency, 0); | 931 | params->frequency, 0); |
927 | if(rc < 0) return rc; | 932 | if(rc < 0) return rc; |
928 | 933 | ||
929 | if(i2c_transfer(i2c, &tuner_msg, 1) != 1) | 934 | if (fe->ops->i2c_gate_ctrl) |
935 | fe->ops->i2c_gate_ctrl(fe, 1); | ||
936 | if(i2c_transfer(&budget->i2c_adap, &tuner_msg, 1) != 1) | ||
930 | return -EIO; | 937 | return -EIO; |
931 | 938 | ||
932 | return 0; | 939 | return 0; |
@@ -977,7 +984,6 @@ static struct stv0299_config philips_sd1878_config = { | |||
977 | .volt13_op0_op1 = STV0299_VOLT13_OP0, | 984 | .volt13_op0_op1 = STV0299_VOLT13_OP0, |
978 | .min_delay_ms = 100, | 985 | .min_delay_ms = 100, |
979 | .set_symbol_rate = philips_sd1878_ci_set_symbol_rate, | 986 | .set_symbol_rate = philips_sd1878_ci_set_symbol_rate, |
980 | .pll_set = philips_sd1878_tda8261_pll_set, | ||
981 | }; | 987 | }; |
982 | 988 | ||
983 | static u8 read_pwm(struct budget_av *budget_av) | 989 | static u8 read_pwm(struct budget_av *budget_av) |
@@ -1035,9 +1041,15 @@ static void frontend_init(struct budget_av *budget_av) | |||
1035 | if (saa->pci->subsystem_vendor == 0x1894) { | 1041 | if (saa->pci->subsystem_vendor == 0x1894) { |
1036 | fe = stv0299_attach(&cinergy_1200s_1894_0010_config, | 1042 | fe = stv0299_attach(&cinergy_1200s_1894_0010_config, |
1037 | &budget_av->budget.i2c_adap); | 1043 | &budget_av->budget.i2c_adap); |
1044 | if (fe) { | ||
1045 | fe->ops->tuner_ops.set_params = philips_su1278sh2_tua6100_tuner_set_params; | ||
1046 | } | ||
1038 | } else { | 1047 | } else { |
1039 | fe = stv0299_attach(&typhoon_config, | 1048 | fe = stv0299_attach(&typhoon_config, |
1040 | &budget_av->budget.i2c_adap); | 1049 | &budget_av->budget.i2c_adap); |
1050 | if (fe) { | ||
1051 | fe->ops->tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params; | ||
1052 | } | ||
1041 | } | 1053 | } |
1042 | break; | 1054 | break; |
1043 | 1055 | ||
@@ -1047,17 +1059,26 @@ static void frontend_init(struct budget_av *budget_av) | |||
1047 | case SUBID_DVBS_EASYWATCH: | 1059 | case SUBID_DVBS_EASYWATCH: |
1048 | fe = stv0299_attach(&philips_sd1878_config, | 1060 | fe = stv0299_attach(&philips_sd1878_config, |
1049 | &budget_av->budget.i2c_adap); | 1061 | &budget_av->budget.i2c_adap); |
1062 | if (fe) { | ||
1063 | fe->ops->tuner_ops.set_params = philips_sd1878_tda8261_tuner_set_params; | ||
1064 | } | ||
1050 | break; | 1065 | break; |
1051 | 1066 | ||
1052 | case SUBID_DVBS_KNC1_PLUS: | 1067 | case SUBID_DVBS_KNC1_PLUS: |
1053 | case SUBID_DVBS_TYPHOON: | 1068 | case SUBID_DVBS_TYPHOON: |
1054 | fe = stv0299_attach(&typhoon_config, | 1069 | fe = stv0299_attach(&typhoon_config, |
1055 | &budget_av->budget.i2c_adap); | 1070 | &budget_av->budget.i2c_adap); |
1071 | if (fe) { | ||
1072 | fe->ops->tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params; | ||
1073 | } | ||
1056 | break; | 1074 | break; |
1057 | 1075 | ||
1058 | case SUBID_DVBS_CINERGY1200: | 1076 | case SUBID_DVBS_CINERGY1200: |
1059 | fe = stv0299_attach(&cinergy_1200s_config, | 1077 | fe = stv0299_attach(&cinergy_1200s_config, |
1060 | &budget_av->budget.i2c_adap); | 1078 | &budget_av->budget.i2c_adap); |
1079 | if (fe) { | ||
1080 | fe->ops->tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params; | ||
1081 | } | ||
1061 | break; | 1082 | break; |
1062 | 1083 | ||
1063 | case SUBID_DVBC_KNC1: | 1084 | case SUBID_DVBC_KNC1: |
@@ -1065,18 +1086,28 @@ static void frontend_init(struct budget_av *budget_av) | |||
1065 | fe = tda10021_attach(&philips_cu1216_config, | 1086 | fe = tda10021_attach(&philips_cu1216_config, |
1066 | &budget_av->budget.i2c_adap, | 1087 | &budget_av->budget.i2c_adap, |
1067 | read_pwm(budget_av)); | 1088 | read_pwm(budget_av)); |
1089 | if (fe) { | ||
1090 | fe->ops->tuner_ops.set_params = philips_cu1216_tuner_set_params; | ||
1091 | } | ||
1068 | break; | 1092 | break; |
1069 | 1093 | ||
1070 | case SUBID_DVBT_KNC1: | 1094 | case SUBID_DVBT_KNC1: |
1071 | case SUBID_DVBT_KNC1_PLUS: | 1095 | case SUBID_DVBT_KNC1_PLUS: |
1072 | fe = tda10046_attach(&philips_tu1216_config, | 1096 | fe = tda10046_attach(&philips_tu1216_config, |
1073 | &budget_av->budget.i2c_adap); | 1097 | &budget_av->budget.i2c_adap); |
1098 | if (fe) { | ||
1099 | fe->ops->tuner_ops.init = philips_tu1216_tuner_init; | ||
1100 | fe->ops->tuner_ops.set_params = philips_tu1216_tuner_set_params; | ||
1101 | } | ||
1074 | break; | 1102 | break; |
1075 | 1103 | ||
1076 | case SUBID_DVBC_CINERGY1200: | 1104 | case SUBID_DVBC_CINERGY1200: |
1077 | fe = tda10021_attach(&philips_cu1216_config, | 1105 | fe = tda10021_attach(&philips_cu1216_config, |
1078 | &budget_av->budget.i2c_adap, | 1106 | &budget_av->budget.i2c_adap, |
1079 | read_pwm(budget_av)); | 1107 | read_pwm(budget_av)); |
1108 | if (fe) { | ||
1109 | fe->ops->tuner_ops.set_params = philips_cu1216_tuner_set_params; | ||
1110 | } | ||
1080 | break; | 1111 | break; |
1081 | 1112 | ||
1082 | case SUBID_DVBT_CINERGY1200: | 1113 | case SUBID_DVBT_CINERGY1200: |