diff options
Diffstat (limited to 'drivers/media/common/tuners')
-rw-r--r-- | drivers/media/common/tuners/Kconfig | 1 | ||||
-rw-r--r-- | drivers/media/common/tuners/mxl5005s.c | 4 | ||||
-rw-r--r-- | drivers/media/common/tuners/tda18271-common.c | 4 | ||||
-rw-r--r-- | drivers/media/common/tuners/tda827x.c | 4 | ||||
-rw-r--r-- | drivers/media/common/tuners/tea5761.c | 2 | ||||
-rw-r--r-- | drivers/media/common/tuners/tuner-i2c.h | 8 | ||||
-rw-r--r-- | drivers/media/common/tuners/tuner-simple.c | 6 | ||||
-rw-r--r-- | drivers/media/common/tuners/tuner-xc2028.c | 87 |
8 files changed, 61 insertions, 55 deletions
diff --git a/drivers/media/common/tuners/Kconfig b/drivers/media/common/tuners/Kconfig index d6206540476b..85482960d012 100644 --- a/drivers/media/common/tuners/Kconfig +++ b/drivers/media/common/tuners/Kconfig | |||
@@ -21,6 +21,7 @@ config MEDIA_TUNER | |||
21 | tristate | 21 | tristate |
22 | default VIDEO_MEDIA && I2C | 22 | default VIDEO_MEDIA && I2C |
23 | depends on VIDEO_MEDIA && I2C | 23 | depends on VIDEO_MEDIA && I2C |
24 | select FW_LOADER if !MEDIA_TUNER_CUSTOMIZE && HOTPLUG | ||
24 | select MEDIA_TUNER_XC2028 if !MEDIA_TUNER_CUSTOMIZE && HOTPLUG | 25 | select MEDIA_TUNER_XC2028 if !MEDIA_TUNER_CUSTOMIZE && HOTPLUG |
25 | select MEDIA_TUNER_XC5000 if !MEDIA_TUNER_CUSTOMIZE && HOTPLUG | 26 | select MEDIA_TUNER_XC5000 if !MEDIA_TUNER_CUSTOMIZE && HOTPLUG |
26 | select MEDIA_TUNER_MT20XX if !MEDIA_TUNER_CUSTOMIZE | 27 | select MEDIA_TUNER_MT20XX if !MEDIA_TUNER_CUSTOMIZE |
diff --git a/drivers/media/common/tuners/mxl5005s.c b/drivers/media/common/tuners/mxl5005s.c index 5d05b5390f66..0dc2bef9f6a3 100644 --- a/drivers/media/common/tuners/mxl5005s.c +++ b/drivers/media/common/tuners/mxl5005s.c | |||
@@ -101,7 +101,7 @@ enum { | |||
101 | MXL_QAM, | 101 | MXL_QAM, |
102 | MXL_ANALOG_CABLE, | 102 | MXL_ANALOG_CABLE, |
103 | MXL_ANALOG_OTA | 103 | MXL_ANALOG_OTA |
104 | } tuner_modu_type; | 104 | }; |
105 | 105 | ||
106 | /* MXL5005 Tuner Register Struct */ | 106 | /* MXL5005 Tuner Register Struct */ |
107 | struct TunerReg { | 107 | struct TunerReg { |
@@ -194,7 +194,7 @@ enum { | |||
194 | RFSYN_DIVM, /* 88 */ | 194 | RFSYN_DIVM, /* 88 */ |
195 | DN_BYPASS_AGC_I2C /* 89 */ | 195 | DN_BYPASS_AGC_I2C /* 89 */ |
196 | #endif | 196 | #endif |
197 | } MXL5005_ControlName; | 197 | }; |
198 | 198 | ||
199 | /* | 199 | /* |
200 | * The following context is source code provided by MaxLinear. | 200 | * The following context is source code provided by MaxLinear. |
diff --git a/drivers/media/common/tuners/tda18271-common.c b/drivers/media/common/tuners/tda18271-common.c index 42b5f5d4bfe6..f1894fec32b9 100644 --- a/drivers/media/common/tuners/tda18271-common.c +++ b/drivers/media/common/tuners/tda18271-common.c | |||
@@ -648,11 +648,11 @@ int tda18271_calc_rf_cal(struct dvb_frontend *fe, u32 *freq) | |||
648 | unsigned char *regs = priv->tda18271_regs; | 648 | unsigned char *regs = priv->tda18271_regs; |
649 | u8 val; | 649 | u8 val; |
650 | 650 | ||
651 | tda18271_lookup_map(fe, RF_CAL, freq, &val); | 651 | int ret = tda18271_lookup_map(fe, RF_CAL, freq, &val); |
652 | 652 | ||
653 | regs[R_EB14] = val; | 653 | regs[R_EB14] = val; |
654 | 654 | ||
655 | return 0; | 655 | return ret; |
656 | } | 656 | } |
657 | 657 | ||
658 | /* | 658 | /* |
diff --git a/drivers/media/common/tuners/tda827x.c b/drivers/media/common/tuners/tda827x.c index d30d2c9094d9..8555d9cf9051 100644 --- a/drivers/media/common/tuners/tda827x.c +++ b/drivers/media/common/tuners/tda827x.c | |||
@@ -418,13 +418,13 @@ static void tda827xa_lna_gain(struct dvb_frontend *fe, int high, | |||
418 | unsigned char buf[] = {0x22, 0x01}; | 418 | unsigned char buf[] = {0x22, 0x01}; |
419 | int arg; | 419 | int arg; |
420 | int gp_func; | 420 | int gp_func; |
421 | struct i2c_msg msg = { .addr = priv->cfg->switch_addr, .flags = 0, | 421 | struct i2c_msg msg = { .flags = 0, .buf = buf, .len = sizeof(buf) }; |
422 | .buf = buf, .len = sizeof(buf) }; | ||
423 | 422 | ||
424 | if (NULL == priv->cfg) { | 423 | if (NULL == priv->cfg) { |
425 | dprintk("tda827x_config not defined, cannot set LNA gain!\n"); | 424 | dprintk("tda827x_config not defined, cannot set LNA gain!\n"); |
426 | return; | 425 | return; |
427 | } | 426 | } |
427 | msg.addr = priv->cfg->switch_addr; | ||
428 | if (priv->cfg->config) { | 428 | if (priv->cfg->config) { |
429 | if (high) | 429 | if (high) |
430 | dprintk("setting LNA to high gain\n"); | 430 | dprintk("setting LNA to high gain\n"); |
diff --git a/drivers/media/common/tuners/tea5761.c b/drivers/media/common/tuners/tea5761.c index b93cdef9ac73..b23dadeecd05 100644 --- a/drivers/media/common/tuners/tea5761.c +++ b/drivers/media/common/tuners/tea5761.c | |||
@@ -295,7 +295,7 @@ struct dvb_frontend *tea5761_attach(struct dvb_frontend *fe, | |||
295 | { | 295 | { |
296 | struct tea5761_priv *priv = NULL; | 296 | struct tea5761_priv *priv = NULL; |
297 | 297 | ||
298 | if (tea5761_autodetection(i2c_adap, i2c_addr) == EINVAL) | 298 | if (tea5761_autodetection(i2c_adap, i2c_addr) != 0) |
299 | return NULL; | 299 | return NULL; |
300 | 300 | ||
301 | priv = kzalloc(sizeof(struct tea5761_priv), GFP_KERNEL); | 301 | priv = kzalloc(sizeof(struct tea5761_priv), GFP_KERNEL); |
diff --git a/drivers/media/common/tuners/tuner-i2c.h b/drivers/media/common/tuners/tuner-i2c.h index 3ad6c8e0b04c..cb1c7141f0c6 100644 --- a/drivers/media/common/tuners/tuner-i2c.h +++ b/drivers/media/common/tuners/tuner-i2c.h | |||
@@ -170,4 +170,12 @@ __fail: \ | |||
170 | __ret; \ | 170 | __ret; \ |
171 | }) | 171 | }) |
172 | 172 | ||
173 | #define hybrid_tuner_report_instance_count(state) \ | ||
174 | ({ \ | ||
175 | int __ret = 0; \ | ||
176 | if (state) \ | ||
177 | __ret = state->i2c_props.count; \ | ||
178 | __ret; \ | ||
179 | }) | ||
180 | |||
173 | #endif /* __TUNER_I2C_H__ */ | 181 | #endif /* __TUNER_I2C_H__ */ |
diff --git a/drivers/media/common/tuners/tuner-simple.c b/drivers/media/common/tuners/tuner-simple.c index be8d903171b7..266c255cf0d8 100644 --- a/drivers/media/common/tuners/tuner-simple.c +++ b/drivers/media/common/tuners/tuner-simple.c | |||
@@ -1018,8 +1018,10 @@ struct dvb_frontend *simple_tuner_attach(struct dvb_frontend *fe, | |||
1018 | fe->ops.i2c_gate_ctrl(fe, 1); | 1018 | fe->ops.i2c_gate_ctrl(fe, 1); |
1019 | 1019 | ||
1020 | if (1 != i2c_transfer(i2c_adap, &msg, 1)) | 1020 | if (1 != i2c_transfer(i2c_adap, &msg, 1)) |
1021 | tuner_warn("unable to probe %s, proceeding anyway.", | 1021 | printk(KERN_WARNING "tuner-simple %d-%04x: " |
1022 | tuners[type].name); | 1022 | "unable to probe %s, proceeding anyway.", |
1023 | i2c_adapter_id(i2c_adap), i2c_addr, | ||
1024 | tuners[type].name); | ||
1023 | 1025 | ||
1024 | if (fe->ops.i2c_gate_ctrl) | 1026 | if (fe->ops.i2c_gate_ctrl) |
1025 | fe->ops.i2c_gate_ctrl(fe, 0); | 1027 | fe->ops.i2c_gate_ctrl(fe, 0); |
diff --git a/drivers/media/common/tuners/tuner-xc2028.c b/drivers/media/common/tuners/tuner-xc2028.c index 9e9003cffc7f..0cbde17bfbb7 100644 --- a/drivers/media/common/tuners/tuner-xc2028.c +++ b/drivers/media/common/tuners/tuner-xc2028.c | |||
@@ -46,7 +46,7 @@ module_param_string(firmware_name, firmware_name, sizeof(firmware_name), 0); | |||
46 | MODULE_PARM_DESC(firmware_name, "Firmware file name. Allows overriding the " | 46 | MODULE_PARM_DESC(firmware_name, "Firmware file name. Allows overriding the " |
47 | "default firmware name\n"); | 47 | "default firmware name\n"); |
48 | 48 | ||
49 | static LIST_HEAD(xc2028_list); | 49 | static LIST_HEAD(hybrid_tuner_instance_list); |
50 | static DEFINE_MUTEX(xc2028_list_mutex); | 50 | static DEFINE_MUTEX(xc2028_list_mutex); |
51 | 51 | ||
52 | /* struct for storing firmware table */ | 52 | /* struct for storing firmware table */ |
@@ -68,12 +68,11 @@ struct firmware_properties { | |||
68 | }; | 68 | }; |
69 | 69 | ||
70 | struct xc2028_data { | 70 | struct xc2028_data { |
71 | struct list_head xc2028_list; | 71 | struct list_head hybrid_tuner_instance_list; |
72 | struct tuner_i2c_props i2c_props; | 72 | struct tuner_i2c_props i2c_props; |
73 | int (*tuner_callback) (void *dev, | 73 | int (*tuner_callback) (void *dev, |
74 | int command, int arg); | 74 | int command, int arg); |
75 | void *video_dev; | 75 | void *video_dev; |
76 | int count; | ||
77 | __u32 frequency; | 76 | __u32 frequency; |
78 | 77 | ||
79 | struct firmware_description *firm; | 78 | struct firmware_description *firm; |
@@ -1072,20 +1071,19 @@ static int xc2028_dvb_release(struct dvb_frontend *fe) | |||
1072 | 1071 | ||
1073 | mutex_lock(&xc2028_list_mutex); | 1072 | mutex_lock(&xc2028_list_mutex); |
1074 | 1073 | ||
1075 | priv->count--; | 1074 | /* only perform final cleanup if this is the last instance */ |
1076 | 1075 | if (hybrid_tuner_report_instance_count(priv) == 1) { | |
1077 | if (!priv->count) { | ||
1078 | list_del(&priv->xc2028_list); | ||
1079 | |||
1080 | kfree(priv->ctrl.fname); | 1076 | kfree(priv->ctrl.fname); |
1081 | |||
1082 | free_firmware(priv); | 1077 | free_firmware(priv); |
1083 | kfree(priv); | ||
1084 | fe->tuner_priv = NULL; | ||
1085 | } | 1078 | } |
1086 | 1079 | ||
1080 | if (priv) | ||
1081 | hybrid_tuner_release_state(priv); | ||
1082 | |||
1087 | mutex_unlock(&xc2028_list_mutex); | 1083 | mutex_unlock(&xc2028_list_mutex); |
1088 | 1084 | ||
1085 | fe->tuner_priv = NULL; | ||
1086 | |||
1089 | return 0; | 1087 | return 0; |
1090 | } | 1088 | } |
1091 | 1089 | ||
@@ -1150,7 +1148,7 @@ struct dvb_frontend *xc2028_attach(struct dvb_frontend *fe, | |||
1150 | struct xc2028_config *cfg) | 1148 | struct xc2028_config *cfg) |
1151 | { | 1149 | { |
1152 | struct xc2028_data *priv; | 1150 | struct xc2028_data *priv; |
1153 | void *video_dev; | 1151 | int instance; |
1154 | 1152 | ||
1155 | if (debug) | 1153 | if (debug) |
1156 | printk(KERN_DEBUG "xc2028: Xcv2028/3028 init called!\n"); | 1154 | printk(KERN_DEBUG "xc2028: Xcv2028/3028 init called!\n"); |
@@ -1163,48 +1161,40 @@ struct dvb_frontend *xc2028_attach(struct dvb_frontend *fe, | |||
1163 | return NULL; | 1161 | return NULL; |
1164 | } | 1162 | } |
1165 | 1163 | ||
1166 | video_dev = cfg->i2c_adap->algo_data; | ||
1167 | |||
1168 | if (debug) | ||
1169 | printk(KERN_DEBUG "xc2028: video_dev =%p\n", video_dev); | ||
1170 | |||
1171 | mutex_lock(&xc2028_list_mutex); | 1164 | mutex_lock(&xc2028_list_mutex); |
1172 | 1165 | ||
1173 | list_for_each_entry(priv, &xc2028_list, xc2028_list) { | 1166 | instance = hybrid_tuner_request_state(struct xc2028_data, priv, |
1174 | if (&priv->i2c_props.adap->dev == &cfg->i2c_adap->dev) { | 1167 | hybrid_tuner_instance_list, |
1175 | video_dev = NULL; | 1168 | cfg->i2c_adap, cfg->i2c_addr, |
1176 | if (debug) | 1169 | "xc2028"); |
1177 | printk(KERN_DEBUG "xc2028: reusing device\n"); | 1170 | switch (instance) { |
1178 | 1171 | case 0: | |
1179 | break; | 1172 | /* memory allocation failure */ |
1180 | } | 1173 | goto fail; |
1181 | } | 1174 | break; |
1182 | 1175 | case 1: | |
1183 | if (video_dev) { | 1176 | /* new tuner instance */ |
1184 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); | ||
1185 | if (priv == NULL) { | ||
1186 | mutex_unlock(&xc2028_list_mutex); | ||
1187 | return NULL; | ||
1188 | } | ||
1189 | |||
1190 | priv->i2c_props.addr = cfg->i2c_addr; | ||
1191 | priv->i2c_props.adap = cfg->i2c_adap; | ||
1192 | priv->i2c_props.name = "xc2028"; | ||
1193 | |||
1194 | priv->video_dev = video_dev; | ||
1195 | priv->tuner_callback = cfg->callback; | 1177 | priv->tuner_callback = cfg->callback; |
1196 | priv->ctrl.max_len = 13; | 1178 | priv->ctrl.max_len = 13; |
1197 | 1179 | ||
1198 | mutex_init(&priv->lock); | 1180 | mutex_init(&priv->lock); |
1199 | 1181 | ||
1200 | list_add_tail(&priv->xc2028_list, &xc2028_list); | 1182 | /* analog side (tuner-core) uses i2c_adap->algo_data. |
1201 | } | 1183 | * digital side is not guaranteed to have algo_data defined. |
1202 | 1184 | * | |
1203 | fe->tuner_priv = priv; | 1185 | * digital side will always have fe->dvb defined. |
1204 | priv->count++; | 1186 | * analog side (tuner-core) doesn't (yet) define fe->dvb. |
1187 | */ | ||
1188 | priv->video_dev = ((fe->dvb) && (fe->dvb->priv)) ? | ||
1189 | fe->dvb->priv : cfg->i2c_adap->algo_data; | ||
1205 | 1190 | ||
1206 | if (debug) | 1191 | fe->tuner_priv = priv; |
1207 | printk(KERN_DEBUG "xc2028: usage count is %i\n", priv->count); | 1192 | break; |
1193 | case 2: | ||
1194 | /* existing tuner instance */ | ||
1195 | fe->tuner_priv = priv; | ||
1196 | break; | ||
1197 | } | ||
1208 | 1198 | ||
1209 | memcpy(&fe->ops.tuner_ops, &xc2028_dvb_tuner_ops, | 1199 | memcpy(&fe->ops.tuner_ops, &xc2028_dvb_tuner_ops, |
1210 | sizeof(xc2028_dvb_tuner_ops)); | 1200 | sizeof(xc2028_dvb_tuner_ops)); |
@@ -1217,6 +1207,11 @@ struct dvb_frontend *xc2028_attach(struct dvb_frontend *fe, | |||
1217 | mutex_unlock(&xc2028_list_mutex); | 1207 | mutex_unlock(&xc2028_list_mutex); |
1218 | 1208 | ||
1219 | return fe; | 1209 | return fe; |
1210 | fail: | ||
1211 | mutex_unlock(&xc2028_list_mutex); | ||
1212 | |||
1213 | xc2028_dvb_release(fe); | ||
1214 | return NULL; | ||
1220 | } | 1215 | } |
1221 | 1216 | ||
1222 | EXPORT_SYMBOL(xc2028_attach); | 1217 | EXPORT_SYMBOL(xc2028_attach); |