Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 320071
b: refs/heads/master
c: 1d432a3
h: refs/heads/master
i:
  320069: 5f48ff4
  320067: 913cffb
  320063: 0c9ad7c
v: v3
  • Loading branch information
Mauro Carvalho Chehab committed Jul 4, 2012
1 parent 1d1f27f commit 3a3bef2
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 90acb85fb48372f30e0a2f6d516d2285faea6e6c
refs/heads/master: 1d432a3d7783b0b86ff08a111b7a4bea550fc4a2
46 changes: 45 additions & 1 deletion trunk/drivers/media/common/tuners/tuner-xc2028.c
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ static int xc2028_signal(struct dvb_frontend *fe, u16 *strength)
msleep(6);
}

/* Frequency was not locked */
/* Frequency didn't lock */
if (frq_lock == 2)
goto ret;

Expand All @@ -947,6 +947,49 @@ static int xc2028_signal(struct dvb_frontend *fe, u16 *strength)
return rc;
}

static int xc2028_get_afc(struct dvb_frontend *fe, s32 *afc)
{
struct xc2028_data *priv = fe->tuner_priv;
int i, rc;
u16 frq_lock = 0;
s16 afc_reg = 0;

rc = check_device_status(priv);
if (rc < 0)
return rc;

mutex_lock(&priv->lock);

/* Sync Lock Indicator */
for (i = 0; i < 3; i++) {
rc = xc2028_get_reg(priv, XREG_LOCK, &frq_lock);
if (rc < 0)
goto ret;

if (frq_lock)
break;
msleep(6);
}

/* Frequency didn't lock */
if (frq_lock == 2)
goto ret;

/* Get AFC */
rc = xc2028_get_reg(priv, XREG_FREQ_ERROR, &afc_reg);
if (rc < 0)
return rc;

*afc = afc_reg * 15625; /* Hz */

tuner_dbg("AFC is %d Hz\n", *afc);

ret:
mutex_unlock(&priv->lock);

return rc;
}

#define DIV 15625

static int generic_set_freq(struct dvb_frontend *fe, u32 freq /* in HZ */,
Expand Down Expand Up @@ -1392,6 +1435,7 @@ static const struct dvb_tuner_ops xc2028_dvb_tuner_ops = {
.release = xc2028_dvb_release,
.get_frequency = xc2028_get_frequency,
.get_rf_strength = xc2028_signal,
.get_afc = xc2028_get_afc,
.set_params = xc2028_set_params,
.sleep = xc2028_sleep,
};
Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/media/dvb/dvb-core/dvb_frontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ struct dvb_tuner_ops {
#define TUNER_STATUS_STEREO 2
int (*get_status)(struct dvb_frontend *fe, u32 *status);
int (*get_rf_strength)(struct dvb_frontend *fe, u16 *strength);
int (*get_afc)(struct dvb_frontend *fe, s32 *afc);

/** These are provided separately from set_params in order to facilitate silicon
* tuners which require sophisticated tuning loops, controlling each parameter separately. */
Expand Down
11 changes: 11 additions & 0 deletions trunk/drivers/media/video/tuner-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,16 @@ static int fe_has_signal(struct dvb_frontend *fe)
return strength;
}

static int fe_get_afc(struct dvb_frontend *fe)
{
s32 afc = 0;

if (fe->ops.tuner_ops.get_afc)
fe->ops.tuner_ops.get_afc(fe, &afc);

return 0;
}

static int fe_set_config(struct dvb_frontend *fe, void *priv_cfg)
{
struct dvb_tuner_ops *fe_tuner_ops = &fe->ops.tuner_ops;
Expand All @@ -247,6 +257,7 @@ static struct analog_demod_ops tuner_analog_ops = {
.set_params = fe_set_params,
.standby = fe_standby,
.has_signal = fe_has_signal,
.get_afc = fe_get_afc,
.set_config = fe_set_config,
.tuner_status = tuner_status
};
Expand Down

0 comments on commit 3a3bef2

Please sign in to comment.