[media] media: i2c: ADV7604: In free run mode, signal is locked
authorjean-michel.hautbois@vodalys.com <jean-michel.hautbois@vodalys.com>
Fri, 6 Feb 2015 14:37:58 +0000 (11:37 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Mon, 2 Mar 2015 17:54:22 +0000 (14:54 -0300)
The CP_NON_STD_VIDEO bit indicates an input not aligned with DV timings.
If there is no input, and chip is in free run mode, consider we are locked.

Signed-off-by: Jean-Michel Hautbois <jean-michel.hautbois@vodalys.com>
[hans.verkuil@cisco.com: put both conditions in one 'if']
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/i2c/adv7604.c

index d228b7c82310c4d5c8cd0b4fca9e5f714e78d35d..5f34e0ab06f36594fbdd21bde51881a9b0bba57e 100644 (file)
@@ -1253,13 +1253,19 @@ static inline bool no_lock_cp(struct v4l2_subdev *sd)
        return io_read(sd, 0x12) & 0x01;
 }
 
+static inline bool in_free_run(struct v4l2_subdev *sd)
+{
+       return cp_read(sd, 0xff) & 0x10;
+}
+
 static int adv7604_g_input_status(struct v4l2_subdev *sd, u32 *status)
 {
        *status = 0;
        *status |= no_power(sd) ? V4L2_IN_ST_NO_POWER : 0;
        *status |= no_signal(sd) ? V4L2_IN_ST_NO_SIGNAL : 0;
-       if (no_lock_cp(sd))
-               *status |= is_digital_input(sd) ? V4L2_IN_ST_NO_SYNC : V4L2_IN_ST_NO_H_LOCK;
+       if (!in_free_run(sd) && no_lock_cp(sd))
+               *status |= is_digital_input(sd) ?
+                          V4L2_IN_ST_NO_SYNC : V4L2_IN_ST_NO_H_LOCK;
 
        v4l2_dbg(1, debug, sd, "%s: status = 0x%x\n", __func__, *status);
 
@@ -2200,7 +2206,7 @@ static int adv7604_log_status(struct v4l2_subdev *sd)
        v4l2_info(sd, "STDI locked: %s\n", no_lock_stdi(sd) ? "false" : "true");
        v4l2_info(sd, "CP locked: %s\n", no_lock_cp(sd) ? "false" : "true");
        v4l2_info(sd, "CP free run: %s\n",
-                       (!!(cp_read(sd, 0xff) & 0x10) ? "on" : "off"));
+                       (in_free_run(sd)) ? "on" : "off");
        v4l2_info(sd, "Prim-mode = 0x%x, video std = 0x%x, v_freq = 0x%x\n",
                        io_read(sd, 0x01) & 0x0f, io_read(sd, 0x00) & 0x3f,
                        (io_read(sd, 0x01) & 0x70) >> 4);