[media] soc_camera: remove the now obsolete struct soc_camera_ops
[pandora-kernel.git] / drivers / media / video / saa7115.c
index e443d0d..5cfdbc7 100644 (file)
@@ -793,7 +793,6 @@ static int saa711x_s_ctrl(struct v4l2_ctrl *ctrl)
                        saa711x_write(sd, R_0F_CHROMA_GAIN_CNTL, state->gain->val);
                else
                        saa711x_write(sd, R_0F_CHROMA_GAIN_CNTL, state->gain->val | 0x80);
-               v4l2_ctrl_activate(state->gain, !state->agc->val);
                break;
 
        default:
@@ -1345,35 +1344,57 @@ static int saa711x_g_vbi_data(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_dat
 static int saa711x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std)
 {
        struct saa711x_state *state = to_state(sd);
-       int reg1e;
+       int reg1f, reg1e;
 
-       *std = V4L2_STD_ALL;
-       if (state->ident != V4L2_IDENT_SAA7115) {
-               int reg1f = saa711x_read(sd, R_1F_STATUS_BYTE_2_VD_DEC);
+       /*
+        * The V4L2 core already initializes std with all supported
+        * Standards. All driver needs to do is to mask it, to remove
+        * standards that don't apply from the mask
+        */
 
-               if (reg1f & 0x20)
-                       *std = V4L2_STD_525_60;
-               else
-                       *std = V4L2_STD_625_50;
+       reg1f = saa711x_read(sd, R_1F_STATUS_BYTE_2_VD_DEC);
+       v4l2_dbg(1, debug, sd, "Status byte 2 (0x1f)=0x%02x\n", reg1f);
 
-               return 0;
-       }
+       /* horizontal/vertical not locked */
+       if (reg1f & 0x40)
+               goto ret;
+
+       if (reg1f & 0x20)
+               *std &= V4L2_STD_525_60;
+       else
+               *std &= V4L2_STD_625_50;
+
+       if (state->ident != V4L2_IDENT_SAA7115)
+               goto ret;
 
        reg1e = saa711x_read(sd, R_1E_STATUS_BYTE_1_VD_DEC);
 
        switch (reg1e & 0x03) {
        case 1:
-               *std = V4L2_STD_NTSC;
+               *std &= V4L2_STD_NTSC;
                break;
        case 2:
-               *std = V4L2_STD_PAL;
+               /*
+                * V4L2_STD_PAL just cover the european PAL standards.
+                * This is wrong, as the device could also be using an
+                * other PAL standard.
+                */
+               *std &= V4L2_STD_PAL   | V4L2_STD_PAL_N  | V4L2_STD_PAL_Nc |
+                       V4L2_STD_PAL_M | V4L2_STD_PAL_60;
                break;
        case 3:
-               *std = V4L2_STD_SECAM;
+               *std &= V4L2_STD_SECAM;
                break;
        default:
+               /* Can't detect anything */
                break;
        }
+
+       v4l2_dbg(1, debug, sd, "Status byte 1 (0x1e)=0x%02x\n", reg1e);
+
+ret:
+       v4l2_dbg(1, debug, sd, "detected std mask = %08Lx\n", *std);
+
        return 0;
 }
 
@@ -1601,7 +1622,6 @@ static int saa711x_probe(struct i2c_client *client,
                        V4L2_CID_CHROMA_AGC, 0, 1, 1, 1);
        state->gain = v4l2_ctrl_new_std(hdl, &saa711x_ctrl_ops,
                        V4L2_CID_CHROMA_GAIN, 0, 127, 1, 40);
-       state->gain->flags |= V4L2_CTRL_FLAG_VOLATILE;
        sd->ctrl_handler = hdl;
        if (hdl->error) {
                int err = hdl->error;
@@ -1610,8 +1630,7 @@ static int saa711x_probe(struct i2c_client *client,
                kfree(state);
                return err;
        }
-       state->agc->flags |= V4L2_CTRL_FLAG_UPDATE;
-       v4l2_ctrl_cluster(2, &state->agc);
+       v4l2_ctrl_auto_cluster(2, &state->agc, 0, true);
 
        state->input = -1;
        state->output = SAA7115_IPORT_ON;