media: cropcap/g_selection split
[sfrench/cifs-2.6.git] / drivers / media / usb / cx231xx / cx231xx-video.c
index f2f034c5cd6207ade6e786b8853a6bb5129e118a..34b55e6699717526cba0b68b6cda18af5d5baaf7 100644 (file)
@@ -1492,17 +1492,35 @@ static int vidioc_cropcap(struct file *file, void *priv,
        if (cc->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
                return -EINVAL;
 
-       cc->bounds.left = 0;
-       cc->bounds.top = 0;
-       cc->bounds.width = dev->width;
-       cc->bounds.height = dev->height;
-       cc->defrect = cc->bounds;
        cc->pixelaspect.numerator = is_50hz ? 54 : 11;
        cc->pixelaspect.denominator = is_50hz ? 59 : 10;
 
        return 0;
 }
 
+static int vidioc_g_selection(struct file *file, void *priv,
+                             struct v4l2_selection *s)
+{
+       struct cx231xx_fh *fh = priv;
+       struct cx231xx *dev = fh->dev;
+
+       if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+               return -EINVAL;
+
+       switch (s->target) {
+       case V4L2_SEL_TGT_CROP_BOUNDS:
+       case V4L2_SEL_TGT_CROP_DEFAULT:
+               s->r.left = 0;
+               s->r.top = 0;
+               s->r.width = dev->width;
+               s->r.height = dev->height;
+               break;
+       default:
+               return -EINVAL;
+       }
+       return 0;
+}
+
 static int vidioc_streamon(struct file *file, void *priv,
                           enum v4l2_buf_type type)
 {
@@ -2094,6 +2112,7 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
        .vidioc_try_fmt_vbi_cap        = vidioc_try_fmt_vbi_cap,
        .vidioc_s_fmt_vbi_cap          = vidioc_s_fmt_vbi_cap,
        .vidioc_cropcap                = vidioc_cropcap,
+       .vidioc_g_selection            = vidioc_g_selection,
        .vidioc_reqbufs                = vidioc_reqbufs,
        .vidioc_querybuf               = vidioc_querybuf,
        .vidioc_qbuf                   = vidioc_qbuf,
@@ -2204,10 +2223,10 @@ int cx231xx_register_analog_devices(struct cx231xx *dev)
 
        if (dev->sd_cx25840) {
                v4l2_ctrl_add_handler(&dev->ctrl_handler,
-                               dev->sd_cx25840->ctrl_handler, NULL);
+                               dev->sd_cx25840->ctrl_handler, NULL, true);
                v4l2_ctrl_add_handler(&dev->radio_ctrl_handler,
                                dev->sd_cx25840->ctrl_handler,
-                               v4l2_ctrl_radio_filter);
+                               v4l2_ctrl_radio_filter, true);
        }
 
        if (dev->ctrl_handler.error)