aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/frontends/tda18271-fe.c
diff options
context:
space:
mode:
authorMichael Krufky <mkrufky@linuxtv.org>2008-01-02 01:01:54 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-01-25 16:04:36 -0500
commitf21e0d7f0513e743b14df3197fdeeb9a9b7edbb2 (patch)
treefed91b8a1b032f3ebf827378b0517ceca9d7793a /drivers/media/dvb/frontends/tda18271-fe.c
parent59067f7ed491ec95e6e9033e35e1ae726cff3cee (diff)
V4L/DVB (6962): tda18271: allow device-specific configuration of IF frequency and std bits
Allow drivers to pass device-specific configuration parameters during attach. If these parameters are omitted, default values will be used. Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/dvb/frontends/tda18271-fe.c')
-rw-r--r--drivers/media/dvb/frontends/tda18271-fe.c82
1 files changed, 76 insertions, 6 deletions
diff --git a/drivers/media/dvb/frontends/tda18271-fe.c b/drivers/media/dvb/frontends/tda18271-fe.c
index 537d520de22f..b17ab4ace08c 100644
--- a/drivers/media/dvb/frontends/tda18271-fe.c
+++ b/drivers/media/dvb/frontends/tda18271-fe.c
@@ -768,12 +768,12 @@ static int tda18271_set_params(struct dvb_frontend *fe,
768 struct dvb_frontend_parameters *params) 768 struct dvb_frontend_parameters *params)
769{ 769{
770 struct tda18271_priv *priv = fe->tuner_priv; 770 struct tda18271_priv *priv = fe->tuner_priv;
771 struct tda18271_std_map *std_map = priv->std; 771 struct tda18271_std_map *std_map = &priv->std;
772 u8 std; 772 u8 std;
773 u32 bw, sgIF = 0; 773 u32 bw, sgIF = 0;
774 u32 freq = params->frequency; 774 u32 freq = params->frequency;
775 775
776 BUG_ON(!priv->tune || !priv->std); 776 BUG_ON(!priv->tune);
777 777
778 priv->mode = TDA18271_DIGITAL; 778 priv->mode = TDA18271_DIGITAL;
779 779
@@ -832,12 +832,12 @@ static int tda18271_set_analog_params(struct dvb_frontend *fe,
832 struct analog_parameters *params) 832 struct analog_parameters *params)
833{ 833{
834 struct tda18271_priv *priv = fe->tuner_priv; 834 struct tda18271_priv *priv = fe->tuner_priv;
835 struct tda18271_std_map *std_map = priv->std; 835 struct tda18271_std_map *std_map = &priv->std;
836 char *mode; 836 char *mode;
837 u8 std; 837 u8 std;
838 u32 sgIF, freq = params->frequency * 62500; 838 u32 sgIF, freq = params->frequency * 62500;
839 839
840 BUG_ON(!priv->tune || !priv->std); 840 BUG_ON(!priv->tune);
841 841
842 priv->mode = TDA18271_ANALOG; 842 priv->mode = TDA18271_ANALOG;
843 843
@@ -901,6 +901,69 @@ static int tda18271_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth)
901 return 0; 901 return 0;
902} 902}
903 903
904/* ------------------------------------------------------------------ */
905
906#define tda18271_update_std(std_cfg, name) do { \
907 if (map->std_cfg.if_freq + map->std_cfg.std_bits > 0) { \
908 tda_dbg("Using custom std config for %s\n", name); \
909 memcpy(&std->std_cfg, &map->std_cfg, \
910 sizeof(struct tda18271_std_map_item)); \
911 } } while (0)
912
913#define tda18271_dump_std_item(std_cfg, name) do { \
914 tda_dbg("(%s) if freq = %d, std bits = 0x%02x\n", \
915 name, std->std_cfg.if_freq, std->std_cfg.std_bits); \
916 } while (0)
917
918static int tda18271_dump_std_map(struct dvb_frontend *fe)
919{
920 struct tda18271_priv *priv = fe->tuner_priv;
921 struct tda18271_std_map *std = &priv->std;
922
923 tda_dbg("========== STANDARD MAP SETTINGS ==========\n");
924 tda18271_dump_std_item(atv_b, "pal b");
925 tda18271_dump_std_item(atv_dk, "pal dk");
926 tda18271_dump_std_item(atv_gh, "pal gh");
927 tda18271_dump_std_item(atv_i, "pal i");
928 tda18271_dump_std_item(atv_l, "pal l");
929 tda18271_dump_std_item(atv_lc, "pal l'");
930 tda18271_dump_std_item(atv_mn, "atv mn");
931 tda18271_dump_std_item(atsc_6, "atsc 6");
932 tda18271_dump_std_item(dvbt_6, "dvbt 6");
933 tda18271_dump_std_item(dvbt_7, "dvbt 7");
934 tda18271_dump_std_item(dvbt_8, "dvbt 8");
935 tda18271_dump_std_item(qam_6, "qam 6");
936 tda18271_dump_std_item(qam_8, "qam 8");
937
938 return 0;
939}
940
941static int tda18271_update_std_map(struct dvb_frontend *fe,
942 struct tda18271_std_map *map)
943{
944 struct tda18271_priv *priv = fe->tuner_priv;
945 struct tda18271_std_map *std = &priv->std;
946
947 if (!map)
948 return -EINVAL;
949
950 tda18271_update_std(atv_b, "atv b");
951 tda18271_update_std(atv_dk, "atv dk");
952 tda18271_update_std(atv_gh, "atv gh");
953 tda18271_update_std(atv_i, "atv i");
954 tda18271_update_std(atv_l, "atv l");
955 tda18271_update_std(atv_lc, "atv l'");
956 tda18271_update_std(atv_mn, "atv mn");
957 tda18271_update_std(atsc_6, "atsc 6");
958 tda18271_update_std(dvbt_6, "dvbt 6");
959 tda18271_update_std(dvbt_7, "dvbt 7");
960 tda18271_update_std(dvbt_8, "dvbt 8");
961 tda18271_update_std(qam_6, "qam 6");
962 tda18271_update_std(qam_8, "qam 8");
963
964 return 0;
965}
966
904static int tda18271_get_id(struct dvb_frontend *fe) 967static int tda18271_get_id(struct dvb_frontend *fe)
905{ 968{
906 struct tda18271_priv *priv = fe->tuner_priv; 969 struct tda18271_priv *priv = fe->tuner_priv;
@@ -951,7 +1014,7 @@ static struct dvb_tuner_ops tda18271_tuner_ops = {
951 1014
952struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr, 1015struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr,
953 struct i2c_adapter *i2c, 1016 struct i2c_adapter *i2c,
954 enum tda18271_i2c_gate gate) 1017 struct tda18271_config *cfg)
955{ 1018{
956 struct tda18271_priv *priv = NULL; 1019 struct tda18271_priv *priv = NULL;
957 1020
@@ -961,7 +1024,7 @@ struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr,
961 1024
962 priv->i2c_addr = addr; 1025 priv->i2c_addr = addr;
963 priv->i2c_adap = i2c; 1026 priv->i2c_adap = i2c;
964 priv->gate = gate; 1027 priv->gate = (cfg) ? cfg->gate : TDA18271_GATE_AUTO;
965 priv->cal_initialized = false; 1028 priv->cal_initialized = false;
966 1029
967 fe->tuner_priv = priv; 1030 fe->tuner_priv = priv;
@@ -975,6 +1038,13 @@ struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr,
975 memcpy(&fe->ops.tuner_ops, &tda18271_tuner_ops, 1038 memcpy(&fe->ops.tuner_ops, &tda18271_tuner_ops,
976 sizeof(struct dvb_tuner_ops)); 1039 sizeof(struct dvb_tuner_ops));
977 1040
1041 /* override default std map with values in config struct */
1042 if ((cfg) && (cfg->std_map))
1043 tda18271_update_std_map(fe, cfg->std_map);
1044
1045 if (tda18271_debug & DBG_MAP)
1046 tda18271_dump_std_map(fe);
1047
978 tda18271_init_regs(fe); 1048 tda18271_init_regs(fe);
979 1049
980 return fe; 1050 return fe;