[media] cxd2820r: improve lock detection
Check demod and ts locks and report lock status according to those. Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
This commit is contained in:

committed by
Mauro Carvalho Chehab

parent
c98975f92c
commit
d51dc91761
@@ -160,25 +160,32 @@ int cxd2820r_read_status_c(struct dvb_frontend *fe, enum fe_status *status)
|
|||||||
struct i2c_client *client = priv->client[0];
|
struct i2c_client *client = priv->client[0];
|
||||||
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
|
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
|
||||||
int ret;
|
int ret;
|
||||||
unsigned int utmp;
|
unsigned int utmp, utmp1, utmp2;
|
||||||
u8 buf[3];
|
u8 buf[3];
|
||||||
*status = 0;
|
|
||||||
|
|
||||||
ret = cxd2820r_rd_regs(priv, 0x10088, buf, 2);
|
/* Lock detection */
|
||||||
|
ret = cxd2820r_rd_reg(priv, 0x10088, &buf[0]);
|
||||||
|
if (ret)
|
||||||
|
goto error;
|
||||||
|
ret = cxd2820r_rd_reg(priv, 0x10073, &buf[1]);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (((buf[0] >> 0) & 0x01) == 1) {
|
utmp1 = (buf[0] >> 0) & 0x01;
|
||||||
*status |= FE_HAS_SIGNAL | FE_HAS_CARRIER |
|
utmp2 = (buf[1] >> 3) & 0x01;
|
||||||
FE_HAS_VITERBI | FE_HAS_SYNC;
|
|
||||||
|
|
||||||
if (((buf[1] >> 3) & 0x01) == 1) {
|
if (utmp1 == 1 && utmp2 == 1) {
|
||||||
*status |= FE_HAS_SIGNAL | FE_HAS_CARRIER |
|
*status = FE_HAS_SIGNAL | FE_HAS_CARRIER |
|
||||||
FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
|
FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
|
||||||
}
|
} else if (utmp1 == 1 || utmp2 == 1) {
|
||||||
|
*status = FE_HAS_SIGNAL | FE_HAS_CARRIER |
|
||||||
|
FE_HAS_VITERBI | FE_HAS_SYNC;
|
||||||
|
} else {
|
||||||
|
*status = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev_dbg(&client->dev, "lock=%*ph\n", 2, buf);
|
dev_dbg(&client->dev, "status=%02x raw=%*ph sync=%u ts=%u\n",
|
||||||
|
*status, 2, buf, utmp1, utmp2);
|
||||||
|
|
||||||
/* Signal strength */
|
/* Signal strength */
|
||||||
if (*status & FE_HAS_SIGNAL) {
|
if (*status & FE_HAS_SIGNAL) {
|
||||||
|
@@ -265,42 +265,32 @@ int cxd2820r_read_status_t(struct dvb_frontend *fe, enum fe_status *status)
|
|||||||
struct i2c_client *client = priv->client[0];
|
struct i2c_client *client = priv->client[0];
|
||||||
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
|
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
|
||||||
int ret;
|
int ret;
|
||||||
unsigned int utmp;
|
unsigned int utmp, utmp1, utmp2;
|
||||||
u8 buf[4];
|
u8 buf[3];
|
||||||
*status = 0;
|
|
||||||
|
|
||||||
|
/* Lock detection */
|
||||||
ret = cxd2820r_rd_reg(priv, 0x00010, &buf[0]);
|
ret = cxd2820r_rd_reg(priv, 0x00010, &buf[0]);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if ((buf[0] & 0x07) == 6) {
|
|
||||||
ret = cxd2820r_rd_reg(priv, 0x00073, &buf[1]);
|
ret = cxd2820r_rd_reg(priv, 0x00073, &buf[1]);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (((buf[1] >> 3) & 0x01) == 1) {
|
utmp1 = (buf[0] >> 0) & 0x07;
|
||||||
*status |= FE_HAS_SIGNAL | FE_HAS_CARRIER |
|
utmp2 = (buf[1] >> 3) & 0x01;
|
||||||
|
|
||||||
|
if (utmp1 == 6 && utmp2 == 1) {
|
||||||
|
*status = FE_HAS_SIGNAL | FE_HAS_CARRIER |
|
||||||
FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
|
FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
|
||||||
} else {
|
} else if (utmp1 == 6 || utmp2 == 1) {
|
||||||
*status |= FE_HAS_SIGNAL | FE_HAS_CARRIER |
|
*status = FE_HAS_SIGNAL | FE_HAS_CARRIER |
|
||||||
FE_HAS_VITERBI | FE_HAS_SYNC;
|
FE_HAS_VITERBI | FE_HAS_SYNC;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
ret = cxd2820r_rd_reg(priv, 0x00014, &buf[2]);
|
*status = 0;
|
||||||
if (ret)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
if ((buf[2] & 0x0f) >= 4) {
|
|
||||||
ret = cxd2820r_rd_reg(priv, 0x00a14, &buf[3]);
|
|
||||||
if (ret)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (((buf[3] >> 4) & 0x01) == 1)
|
|
||||||
*status |= FE_HAS_SIGNAL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dev_dbg(&client->dev, "lock=%*ph\n", 4, buf);
|
dev_dbg(&client->dev, "status=%02x raw=%*ph sync=%u ts=%u\n",
|
||||||
|
*status, 2, buf, utmp1, utmp2);
|
||||||
|
|
||||||
/* Signal strength */
|
/* Signal strength */
|
||||||
if (*status & FE_HAS_SIGNAL) {
|
if (*status & FE_HAS_SIGNAL) {
|
||||||
|
@@ -293,25 +293,29 @@ int cxd2820r_read_status_t2(struct dvb_frontend *fe, enum fe_status *status)
|
|||||||
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
|
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
|
||||||
struct i2c_client *client = priv->client[0];
|
struct i2c_client *client = priv->client[0];
|
||||||
int ret;
|
int ret;
|
||||||
unsigned int utmp;
|
unsigned int utmp, utmp1, utmp2;
|
||||||
u8 buf[4];
|
u8 buf[4];
|
||||||
*status = 0;
|
|
||||||
|
|
||||||
|
/* Lock detection */
|
||||||
ret = cxd2820r_rd_reg(priv, 0x02010 , &buf[0]);
|
ret = cxd2820r_rd_reg(priv, 0x02010 , &buf[0]);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if ((buf[0] & 0x07) == 6) {
|
utmp1 = (buf[0] >> 0) & 0x07;
|
||||||
if (((buf[0] >> 5) & 0x01) == 1) {
|
utmp2 = (buf[0] >> 5) & 0x01;
|
||||||
*status |= FE_HAS_SIGNAL | FE_HAS_CARRIER |
|
|
||||||
|
if (utmp1 == 6 && utmp2 == 1) {
|
||||||
|
*status = FE_HAS_SIGNAL | FE_HAS_CARRIER |
|
||||||
FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
|
FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
|
||||||
} else {
|
} else if (utmp1 == 6 || utmp2 == 1) {
|
||||||
*status |= FE_HAS_SIGNAL | FE_HAS_CARRIER |
|
*status = FE_HAS_SIGNAL | FE_HAS_CARRIER |
|
||||||
FE_HAS_VITERBI | FE_HAS_SYNC;
|
FE_HAS_VITERBI | FE_HAS_SYNC;
|
||||||
}
|
} else {
|
||||||
|
*status = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev_dbg(&client->dev, "lock=%*ph\n", 1, buf);
|
dev_dbg(&client->dev, "status=%02x raw=%*ph sync=%u ts=%u\n",
|
||||||
|
*status, 1, buf, utmp1, utmp2);
|
||||||
|
|
||||||
/* Signal strength */
|
/* Signal strength */
|
||||||
if (*status & FE_HAS_SIGNAL) {
|
if (*status & FE_HAS_SIGNAL) {
|
||||||
|
Reference in New Issue
Block a user