aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/common/tuners/tuner-xc2028.c46
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.h1
-rw-r--r--drivers/media/video/tuner-core.c11
3 files changed, 57 insertions, 1 deletions
diff --git a/drivers/media/common/tuners/tuner-xc2028.c b/drivers/media/common/tuners/tuner-xc2028.c
index 42fdf5c57091..4857e86259a1 100644
--- a/drivers/media/common/tuners/tuner-xc2028.c
+++ b/drivers/media/common/tuners/tuner-xc2028.c
@@ -924,7 +924,7 @@ static int xc2028_signal(struct dvb_frontend *fe, u16 *strength)
924 msleep(6); 924 msleep(6);
925 } 925 }
926 926
927 /* Frequency was not locked */ 927 /* Frequency didn't lock */
928 if (frq_lock == 2) 928 if (frq_lock == 2)
929 goto ret; 929 goto ret;
930 930
@@ -947,6 +947,49 @@ ret:
947 return rc; 947 return rc;
948} 948}
949 949
950static int xc2028_get_afc(struct dvb_frontend *fe, s32 *afc)
951{
952 struct xc2028_data *priv = fe->tuner_priv;
953 int i, rc;
954 u16 frq_lock = 0;
955 s16 afc_reg = 0;
956
957 rc = check_device_status(priv);
958 if (rc < 0)
959 return rc;
960
961 mutex_lock(&priv->lock);
962
963 /* Sync Lock Indicator */
964 for (i = 0; i < 3; i++) {
965 rc = xc2028_get_reg(priv, XREG_LOCK, &frq_lock);
966 if (rc < 0)
967 goto ret;
968
969 if (frq_lock)
970 break;
971 msleep(6);
972 }
973
974 /* Frequency didn't lock */
975 if (frq_lock == 2)
976 goto ret;
977
978 /* Get AFC */
979 rc = xc2028_get_reg(priv, XREG_FREQ_ERROR, &afc_reg);
980 if (rc < 0)
981 return rc;
982
983 *afc = afc_reg * 15625; /* Hz */
984
985 tuner_dbg("AFC is %d Hz\n", *afc);
986
987ret:
988 mutex_unlock(&priv->lock);
989
990 return rc;
991}
992
950#define DIV 15625 993#define DIV 15625
951 994
952static int generic_set_freq(struct dvb_frontend *fe, u32 freq /* in HZ */, 995static int generic_set_freq(struct dvb_frontend *fe, u32 freq /* in HZ */,
@@ -1392,6 +1435,7 @@ static const struct dvb_tuner_ops xc2028_dvb_tuner_ops = {
1392 .release = xc2028_dvb_release, 1435 .release = xc2028_dvb_release,
1393 .get_frequency = xc2028_get_frequency, 1436 .get_frequency = xc2028_get_frequency,
1394 .get_rf_strength = xc2028_signal, 1437 .get_rf_strength = xc2028_signal,
1438 .get_afc = xc2028_get_afc,
1395 .set_params = xc2028_set_params, 1439 .set_params = xc2028_set_params,
1396 .sleep = xc2028_sleep, 1440 .sleep = xc2028_sleep,
1397}; 1441};
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.h b/drivers/media/dvb/dvb-core/dvb_frontend.h
index e929d5697b87..7c64c09103a9 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.h
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.h
@@ -220,6 +220,7 @@ struct dvb_tuner_ops {
220#define TUNER_STATUS_STEREO 2 220#define TUNER_STATUS_STEREO 2
221 int (*get_status)(struct dvb_frontend *fe, u32 *status); 221 int (*get_status)(struct dvb_frontend *fe, u32 *status);
222 int (*get_rf_strength)(struct dvb_frontend *fe, u16 *strength); 222 int (*get_rf_strength)(struct dvb_frontend *fe, u16 *strength);
223 int (*get_afc)(struct dvb_frontend *fe, s32 *afc);
223 224
224 /** These are provided separately from set_params in order to facilitate silicon 225 /** These are provided separately from set_params in order to facilitate silicon
225 * tuners which require sophisticated tuning loops, controlling each parameter separately. */ 226 * tuners which require sophisticated tuning loops, controlling each parameter separately. */
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index 98adeeebb8b0..b5a819af2b8c 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -228,6 +228,16 @@ static int fe_has_signal(struct dvb_frontend *fe)
228 return strength; 228 return strength;
229} 229}
230 230
231static int fe_get_afc(struct dvb_frontend *fe)
232{
233 s32 afc = 0;
234
235 if (fe->ops.tuner_ops.get_afc)
236 fe->ops.tuner_ops.get_afc(fe, &afc);
237
238 return 0;
239}
240
231static int fe_set_config(struct dvb_frontend *fe, void *priv_cfg) 241static int fe_set_config(struct dvb_frontend *fe, void *priv_cfg)
232{ 242{
233 struct dvb_tuner_ops *fe_tuner_ops = &fe->ops.tuner_ops; 243 struct dvb_tuner_ops *fe_tuner_ops = &fe->ops.tuner_ops;
@@ -247,6 +257,7 @@ static struct analog_demod_ops tuner_analog_ops = {
247 .set_params = fe_set_params, 257 .set_params = fe_set_params,
248 .standby = fe_standby, 258 .standby = fe_standby,
249 .has_signal = fe_has_signal, 259 .has_signal = fe_has_signal,
260 .get_afc = fe_get_afc,
250 .set_config = fe_set_config, 261 .set_config = fe_set_config,
251 .tuner_status = tuner_status 262 .tuner_status = tuner_status
252}; 263};