media: tvp5150: implement decoder lock when irq is not used
authorMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Wed, 1 Aug 2018 14:09:24 +0000 (10:09 -0400)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Mon, 17 Sep 2018 17:33:41 +0000 (13:33 -0400)
When irq is used, the lock is set via IRQ code. When it isn't,
the driver just assumes it is always locked. Instead, read the
lock status from the status register.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/i2c/tvp5150.c

index cbb19001c9e42544d77ad8d8755a4fbd7622a175..f4cd73d90f7f062f1edc571eac74d06ca0066ce6 100644 (file)
@@ -810,11 +810,25 @@ static v4l2_std_id tvp5150_read_std(struct v4l2_subdev *sd)
        }
 }
 
+static int query_lock(struct v4l2_subdev *sd)
+{
+       struct tvp5150 *decoder = to_tvp5150(sd);
+       int status;
+
+       if (decoder->irq)
+               return decoder->lock;
+
+       regmap_read(decoder->regmap, TVP5150_STATUS_REG_1, &status);
+
+       /* For standard detection, we need the 3 locks */
+       return (status & 0x0e) == 0x0e;
+}
+
 static int tvp5150_querystd(struct v4l2_subdev *sd, v4l2_std_id *std_id)
 {
        struct tvp5150 *decoder = to_tvp5150(sd);
 
-       *std_id = decoder->lock ? tvp5150_read_std(sd) : V4L2_STD_UNKNOWN;
+       *std_id = query_lock(sd) ? tvp5150_read_std(sd) : V4L2_STD_UNKNOWN;
 
        return 0;
 }
@@ -1208,7 +1222,10 @@ static int tvp5150_s_stream(struct v4l2_subdev *sd, int enable)
                tvp5150_enable(sd);
 
                /* Enable outputs if decoder is locked */
-               val = decoder->lock ? decoder->oe : 0;
+               if (decoder->irq)
+                       val = decoder->lock ? decoder->oe : 0;
+               else
+                       val = decoder->oe;
                int_val = TVP5150_INT_A_LOCK;
                v4l2_subdev_notify_event(&decoder->sd, &tvp5150_ev_fmt);
        }
@@ -1777,8 +1794,6 @@ static int tvp5150_probe(struct i2c_client *c,
                                                IRQF_ONESHOT, "tvp5150", core);
                if (res)
                        return res;
-       } else {
-               core->lock = true;
        }
 
        res = v4l2_async_register_subdev(sd);