aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2007-11-24 08:13:42 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-01-25 16:02:51 -0500
commit00deff1a076dc1cf6743813657623626720bf0f5 (patch)
treecc217f5d6f44bbdc25903433967209e9aac23f26 /drivers/media
parentf36224d3992a7734349cdd6289ff73c3d007ce09 (diff)
V4L/DVB (6671): Avoids checking digital/analog at check_firmware
Since check_firmware is called via analog or digital set freq routines, move type selection to those routines. This avoids having several if's at the code, and simplifies the source code. A sideback effect is that implementing radio and other dvb types will become simpler. Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/tuner-xc2028.c106
1 files changed, 50 insertions, 56 deletions
diff --git a/drivers/media/video/tuner-xc2028.c b/drivers/media/video/tuner-xc2028.c
index 1f14892a883a..94f367ab5718 100644
--- a/drivers/media/video/tuner-xc2028.c
+++ b/drivers/media/video/tuner-xc2028.c
@@ -608,15 +608,14 @@ static int load_scode(struct dvb_frontend *fe, unsigned int type,
608 return 0; 608 return 0;
609} 609}
610 610
611static int check_firmware(struct dvb_frontend *fe, enum tuner_mode new_mode, 611static int check_firmware(struct dvb_frontend *fe, unsigned int type,
612 v4l2_std_id std, fe_bandwidth_t bandwidth) 612 v4l2_std_id std)
613{ 613{
614 struct xc2028_data *priv = fe->tuner_priv; 614 struct xc2028_data *priv = fe->tuner_priv;
615 int rc = 0, is_retry = 0;
616 unsigned int type = 0;
617 struct firmware_properties new_fw; 615 struct firmware_properties new_fw;
618 u16 version, hwmodel; 616 int rc = 0, is_retry = 0;
619 v4l2_std_id std0; 617 u16 version, hwmodel;
618 v4l2_std_id std0;
620 619
621 tuner_dbg("%s called\n", __FUNCTION__); 620 tuner_dbg("%s called\n", __FUNCTION__);
622 621
@@ -633,32 +632,6 @@ static int check_firmware(struct dvb_frontend *fe, enum tuner_mode new_mode,
633 632
634 if (priv->ctrl.mts) 633 if (priv->ctrl.mts)
635 type |= MTS; 634 type |= MTS;
636 if (bandwidth == BANDWIDTH_7_MHZ || bandwidth == BANDWIDTH_8_MHZ)
637 type |= F8MHZ;
638
639 /* FIXME: How to load FM and FM|INPUT1 firmwares? */
640
641 if (new_mode == T_DIGITAL_TV) {
642 if (priv->ctrl.d2633)
643 type |= D2633;
644 else
645 type |= D2620;
646
647 switch (bandwidth) {
648 case BANDWIDTH_8_MHZ:
649 type |= DTV8;
650 break;
651 case BANDWIDTH_7_MHZ:
652 type |= DTV7;
653 break;
654 case BANDWIDTH_6_MHZ:
655 /* FIXME: Should allow select also ATSC */
656 type |= DTV6 | QAM;
657 break;
658 default:
659 tuner_err("error: bandwidth not supported.\n");
660 };
661 }
662 635
663retry: 636retry:
664 new_fw.type = type; 637 new_fw.type = type;
@@ -729,10 +702,6 @@ skip_base:
729 /* Reloading std-specific firmware forces a SCODE update */ 702 /* Reloading std-specific firmware forces a SCODE update */
730 priv->cur_fw.scode_table = 0; 703 priv->cur_fw.scode_table = 0;
731 704
732 /* Add audio hack to std mask */
733 if (new_mode == T_ANALOG_TV)
734 new_fw.id |= parse_audio_std_option();
735
736 rc = load_firmware(fe, new_fw.type, &new_fw.id); 705 rc = load_firmware(fe, new_fw.type, &new_fw.id);
737 if (rc == -ENOENT) 706 if (rc == -ENOENT)
738 rc = load_firmware(fe, new_fw.type & ~F8MHZ, &new_fw.id); 707 rc = load_firmware(fe, new_fw.type & ~F8MHZ, &new_fw.id);
@@ -840,9 +809,10 @@ ret:
840 809
841#define DIV 15625 810#define DIV 15625
842 811
843static int generic_set_tv_freq(struct dvb_frontend *fe, u32 freq /* in Hz */ , 812static int generic_set_freq(struct dvb_frontend *fe, u32 freq /* in HZ */,
844 enum tuner_mode new_mode, 813 enum tuner_mode new_mode,
845 v4l2_std_id std, fe_bandwidth_t bandwidth) 814 unsigned int type,
815 v4l2_std_id std)
846{ 816{
847 struct xc2028_data *priv = fe->tuner_priv; 817 struct xc2028_data *priv = fe->tuner_priv;
848 int rc = -EINVAL; 818 int rc = -EINVAL;
@@ -855,7 +825,7 @@ static int generic_set_tv_freq(struct dvb_frontend *fe, u32 freq /* in Hz */ ,
855 825
856 tuner_dbg("should set frequency %d kHz\n", freq / 1000); 826 tuner_dbg("should set frequency %d kHz\n", freq / 1000);
857 827
858 if (check_firmware(fe, new_mode, std, bandwidth) < 0) 828 if (check_firmware(fe, type, std) < 0)
859 goto ret; 829 goto ret;
860 830
861 /* On some cases xc2028 can disable video output, if 831 /* On some cases xc2028 can disable video output, if
@@ -865,10 +835,9 @@ static int generic_set_tv_freq(struct dvb_frontend *fe, u32 freq /* in Hz */ ,
865 * that xc2028 will be in a safe state. 835 * that xc2028 will be in a safe state.
866 * Maybe this might also be needed for DTV. 836 * Maybe this might also be needed for DTV.
867 */ 837 */
868 if (new_mode != T_DIGITAL_TV) 838 if (new_mode == T_ANALOG_TV) {
869 rc = send_seq(priv, {0x00, 0x00}); 839 rc = send_seq(priv, {0x00, 0x00});
870 840 } else {
871 if (new_mode == T_DIGITAL_TV) {
872 offset = 2750000; 841 offset = 2750000;
873 if (priv->cur_fw.type & DTV7) 842 if (priv->cur_fw.type & DTV7)
874 offset -= 500000; 843 offset -= 500000;
@@ -914,32 +883,35 @@ ret:
914 return rc; 883 return rc;
915} 884}
916 885
917static int xc2028_set_tv_freq(struct dvb_frontend *fe, 886static int xc2028_set_analog_freq(struct dvb_frontend *fe,
918 struct analog_parameters *p) 887 struct analog_parameters *p)
919{ 888{
920 struct xc2028_data *priv = fe->tuner_priv; 889 struct xc2028_data *priv = fe->tuner_priv;
921 fe_bandwidth_t bw; 890 unsigned int type=0;
891
892 tuner_dbg("%s called\n", __FUNCTION__);
922 893
923 /* if std is not defined, choose one */ 894 /* if std is not defined, choose one */
924 if (!p->std) 895 if (!p->std)
925 p->std = V4L2_STD_MN; 896 p->std = V4L2_STD_MN;
926 897
927 /* PAL/M, PAL/N, PAL/Nc and NTSC variants should use 6MHz firmware */ 898 /* PAL/M, PAL/N, PAL/Nc and NTSC variants should use 6MHz firmware */
928 if (p->std & V4L2_STD_MN) 899 if (!(p->std & V4L2_STD_MN))
929 bw = BANDWIDTH_6_MHZ; 900 type |= F8MHZ;
930 else
931 bw = BANDWIDTH_8_MHZ;
932 901
933 tuner_dbg("%s called\n", __FUNCTION__); 902 /* Add audio hack to std mask */
903 p->std |= parse_audio_std_option();
934 904
935 return generic_set_tv_freq(fe, 62500l * p->frequency, T_ANALOG_TV, 905 return generic_set_freq(fe, 62500l * p->frequency,
936 p->std, bw); 906 T_ANALOG_TV, type, p->std);
937} 907}
938 908
939static int xc2028_set_params(struct dvb_frontend *fe, 909static int xc2028_set_params(struct dvb_frontend *fe,
940 struct dvb_frontend_parameters *p) 910 struct dvb_frontend_parameters *p)
941{ 911{
942 struct xc2028_data *priv = fe->tuner_priv; 912 struct xc2028_data *priv = fe->tuner_priv;
913 unsigned int type=0;
914 fe_bandwidth_t bw;
943 915
944 tuner_dbg("%s called\n", __FUNCTION__); 916 tuner_dbg("%s called\n", __FUNCTION__);
945 917
@@ -948,11 +920,33 @@ static int xc2028_set_params(struct dvb_frontend *fe,
948 tuner_err("DTV type not implemented.\n"); 920 tuner_err("DTV type not implemented.\n");
949 return -EINVAL; 921 return -EINVAL;
950 } 922 }
923 bw = p->u.ofdm.bandwidth;
951 924
952 return generic_set_tv_freq(fe, p->frequency, T_DIGITAL_TV, 925 if (bw == BANDWIDTH_7_MHZ || bw == BANDWIDTH_8_MHZ)
953 0 /* NOT USED */, 926 type |= F8MHZ;
954 p->u.ofdm.bandwidth);
955 927
928 if (priv->ctrl.d2633)
929 type |= D2633;
930 else
931 type |= D2620;
932
933 switch (bw) {
934 case BANDWIDTH_8_MHZ:
935 type |= DTV8;
936 break;
937 case BANDWIDTH_7_MHZ:
938 type |= DTV7;
939 break;
940 case BANDWIDTH_6_MHZ:
941 /* FIXME: Should allow select also ATSC */
942 type |= DTV6 | QAM;
943 break;
944 default:
945 tuner_err("error: bandwidth not supported.\n");
946 };
947
948 return generic_set_freq(fe, p->frequency,
949 T_DIGITAL_TV, type, 0);
956} 950}
957 951
958static int xc2028_sleep(struct dvb_frontend *fe) 952static int xc2028_sleep(struct dvb_frontend *fe)
@@ -1052,7 +1046,7 @@ static const struct dvb_tuner_ops xc2028_dvb_tuner_ops = {
1052 }, 1046 },
1053 1047
1054 .set_config = xc2028_set_config, 1048 .set_config = xc2028_set_config,
1055 .set_analog_params = xc2028_set_tv_freq, 1049 .set_analog_params = xc2028_set_analog_freq,
1056 .release = xc2028_dvb_release, 1050 .release = xc2028_dvb_release,
1057 .get_frequency = xc2028_get_frequency, 1051 .get_frequency = xc2028_get_frequency,
1058 .get_rf_strength = xc2028_signal, 1052 .get_rf_strength = xc2028_signal,