summaryrefslogtreecommitdiff
path: root/drivers/media/dvb-frontends
diff options
context:
space:
mode:
authorMatthias Schwarzott <zzam@gentoo.org>2017-11-05 09:25:02 -0500
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2017-12-12 05:52:57 -0500
commit1e5fde1bc224267ea2c58f9ff8db19c2f67efebf (patch)
tree4e3cba1abce0b7e399f5d9a8702599cb6e78dbff /drivers/media/dvb-frontends
parent548b1f94904ae1616f9338a772e89a9f2e705325 (diff)
media: si2165: improve read_status
Use check_signal register for DVB-T additionally. For DVB-C use ps_lock additionally. Signed-off-by: Matthias Schwarzott <zzam@gentoo.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/dvb-frontends')
-rw-r--r--drivers/media/dvb-frontends/si2165.c41
-rw-r--r--drivers/media/dvb-frontends/si2165_priv.h2
2 files changed, 37 insertions, 6 deletions
diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c
index ea9d23e7e266..30ceba664f5f 100644
--- a/drivers/media/dvb-frontends/si2165.c
+++ b/drivers/media/dvb-frontends/si2165.c
@@ -651,18 +651,47 @@ static int si2165_sleep(struct dvb_frontend *fe)
static int si2165_read_status(struct dvb_frontend *fe, enum fe_status *status)
{
int ret;
- u8 fec_lock = 0;
+ u8 u8tmp;
struct si2165_state *state = fe->demodulator_priv;
+ struct dtv_frontend_properties *p = &fe->dtv_property_cache;
+ u32 delsys = p->delivery_system;
- if (!state->has_dvbt)
- return -EINVAL;
+ *status = 0;
+
+ switch (delsys) {
+ case SYS_DVBT:
+ /* check fast signal type */
+ ret = si2165_readreg8(state, REG_CHECK_SIGNAL, &u8tmp);
+ if (ret < 0)
+ return ret;
+ switch (u8tmp & 0x3) {
+ case 0: /* searching */
+ case 1: /* nothing */
+ break;
+ case 2: /* digital signal */
+ *status |= FE_HAS_SIGNAL | FE_HAS_CARRIER;
+ break;
+ }
+ break;
+ case SYS_DVBC_ANNEX_A:
+ /* check packet sync lock */
+ ret = si2165_readreg8(state, REG_PS_LOCK, &u8tmp);
+ if (ret < 0)
+ return ret;
+ if (u8tmp & 0x01) {
+ *status |= FE_HAS_SIGNAL;
+ *status |= FE_HAS_CARRIER;
+ *status |= FE_HAS_VITERBI;
+ *status |= FE_HAS_SYNC;
+ }
+ break;
+ }
/* check fec_lock */
- ret = si2165_readreg8(state, REG_FEC_LOCK, &fec_lock);
+ ret = si2165_readreg8(state, REG_FEC_LOCK, &u8tmp);
if (ret < 0)
return ret;
- *status = 0;
- if (fec_lock & 0x01) {
+ if (u8tmp & 0x01) {
*status |= FE_HAS_SIGNAL;
*status |= FE_HAS_CARRIER;
*status |= FE_HAS_VITERBI;
diff --git a/drivers/media/dvb-frontends/si2165_priv.h b/drivers/media/dvb-frontends/si2165_priv.h
index da8bbda8a4e3..47f18ff69fe5 100644
--- a/drivers/media/dvb-frontends/si2165_priv.h
+++ b/drivers/media/dvb-frontends/si2165_priv.h
@@ -93,6 +93,8 @@ struct si2165_config {
#define REG_GP_REG0_LSB 0x0384
#define REG_GP_REG0_MSB 0x0387
#define REG_CRC 0x037a
+#define REG_CHECK_SIGNAL 0x03a8
+#define REG_PS_LOCK 0x0440
#define REG_BER_PKT 0x0470
#define REG_FEC_LOCK 0x04e0
#define REG_TS_DATA_MODE 0x04e4