[media] mn88473: implement lock for all delivery systems
authorBenjamin Larsson <benjamin@southpole.se>
Sat, 21 Mar 2015 10:18:07 +0000 (07:18 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Fri, 3 Apr 2015 00:55:34 +0000 (21:55 -0300)
Add capability to check if digital TV has lock for all delivery
systems.

Signed-off-by: Benjamin Larsson <benjamin@southpole.se>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/staging/media/mn88473/mn88473.c

index f98b982398bc74b18d3ff95565e2a52750b90289..e909d62a086a350ddf1f4e705235b847011b4193 100644 (file)
@@ -167,7 +167,10 @@ static int mn88473_read_status(struct dvb_frontend *fe, fe_status_t *status)
 {
        struct i2c_client *client = fe->demodulator_priv;
        struct mn88473_dev *dev = i2c_get_clientdata(client);
+       struct dtv_frontend_properties *c = &fe->dtv_property_cache;
        int ret;
+       unsigned int utmp;
+       int lock = 0;
 
        *status = 0;
 
@@ -176,8 +179,51 @@ static int mn88473_read_status(struct dvb_frontend *fe, fe_status_t *status)
                goto err;
        }
 
-       *status = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI |
-                       FE_HAS_SYNC | FE_HAS_LOCK;
+       switch (c->delivery_system) {
+       case SYS_DVBT:
+               ret = regmap_read(dev->regmap[0], 0x62, &utmp);
+               if (ret)
+                       goto err;
+               if (!(utmp & 0xA0)) {
+                       if ((utmp & 0xF) >= 0x03)
+                               *status |= FE_HAS_SIGNAL;
+                       if ((utmp & 0xF) >= 0x09)
+                               lock = 1;
+               }
+               break;
+       case SYS_DVBT2:
+               ret = regmap_read(dev->regmap[2], 0x8B, &utmp);
+               if (ret)
+                       goto err;
+               if (!(utmp & 0x40)) {
+                       if ((utmp & 0xF) >= 0x07)
+                               *status |= FE_HAS_SIGNAL;
+                       if ((utmp & 0xF) >= 0x0a)
+                               *status |= FE_HAS_CARRIER;
+                       if ((utmp & 0xF) >= 0x0d)
+                               *status |= FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
+               }
+               break;
+       case SYS_DVBC_ANNEX_A:
+               ret = regmap_read(dev->regmap[1], 0x85, &utmp);
+               if (ret)
+                       goto err;
+               if (!(utmp & 0x40)) {
+                       ret = regmap_read(dev->regmap[1], 0x89, &utmp);
+                       if (ret)
+                               goto err;
+                       if (utmp & 0x01)
+                               lock = 1;
+               }
+               break;
+       default:
+               ret = -EINVAL;
+               goto err;
+       }
+
+       if (lock)
+               *status = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI |
+                               FE_HAS_SYNC | FE_HAS_LOCK;
 
        return 0;
 err: