aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@iki.fi>2011-11-14 13:30:24 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-04-10 14:02:26 -0400
commit5b9d770fa3f5cf210b31137404ae702a33e00473 (patch)
treec79c49be9318f88cdecb0b147d70a89f9b3c6163
parent5e6ff7c17bf468b8bc012e49174771e5f718e72c (diff)
[media] v4l: Support s_crop and g_crop through s/g_selection
Fall back to s_selection if s_crop isn't implemented by a driver. Same for g_selection / g_crop. Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/video/v4l2-subdev.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/drivers/media/video/v4l2-subdev.c b/drivers/media/video/v4l2-subdev.c
index 7d225389bfb1..268d80584101 100644
--- a/drivers/media/video/v4l2-subdev.c
+++ b/drivers/media/video/v4l2-subdev.c
@@ -228,6 +228,8 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
228 228
229 case VIDIOC_SUBDEV_G_CROP: { 229 case VIDIOC_SUBDEV_G_CROP: {
230 struct v4l2_subdev_crop *crop = arg; 230 struct v4l2_subdev_crop *crop = arg;
231 struct v4l2_subdev_selection sel;
232 int rval;
231 233
232 if (crop->which != V4L2_SUBDEV_FORMAT_TRY && 234 if (crop->which != V4L2_SUBDEV_FORMAT_TRY &&
233 crop->which != V4L2_SUBDEV_FORMAT_ACTIVE) 235 crop->which != V4L2_SUBDEV_FORMAT_ACTIVE)
@@ -236,11 +238,27 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
236 if (crop->pad >= sd->entity.num_pads) 238 if (crop->pad >= sd->entity.num_pads)
237 return -EINVAL; 239 return -EINVAL;
238 240
239 return v4l2_subdev_call(sd, pad, get_crop, subdev_fh, crop); 241 rval = v4l2_subdev_call(sd, pad, get_crop, subdev_fh, crop);
242 if (rval != -ENOIOCTLCMD)
243 return rval;
244
245 memset(&sel, 0, sizeof(sel));
246 sel.which = crop->which;
247 sel.pad = crop->pad;
248 sel.target = V4L2_SUBDEV_SEL_TGT_CROP_ACTUAL;
249
250 rval = v4l2_subdev_call(
251 sd, pad, get_selection, subdev_fh, &sel);
252
253 crop->rect = sel.r;
254
255 return rval;
240 } 256 }
241 257
242 case VIDIOC_SUBDEV_S_CROP: { 258 case VIDIOC_SUBDEV_S_CROP: {
243 struct v4l2_subdev_crop *crop = arg; 259 struct v4l2_subdev_crop *crop = arg;
260 struct v4l2_subdev_selection sel;
261 int rval;
244 262
245 if (crop->which != V4L2_SUBDEV_FORMAT_TRY && 263 if (crop->which != V4L2_SUBDEV_FORMAT_TRY &&
246 crop->which != V4L2_SUBDEV_FORMAT_ACTIVE) 264 crop->which != V4L2_SUBDEV_FORMAT_ACTIVE)
@@ -249,7 +267,22 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
249 if (crop->pad >= sd->entity.num_pads) 267 if (crop->pad >= sd->entity.num_pads)
250 return -EINVAL; 268 return -EINVAL;
251 269
252 return v4l2_subdev_call(sd, pad, set_crop, subdev_fh, crop); 270 rval = v4l2_subdev_call(sd, pad, set_crop, subdev_fh, crop);
271 if (rval != -ENOIOCTLCMD)
272 return rval;
273
274 memset(&sel, 0, sizeof(sel));
275 sel.which = crop->which;
276 sel.pad = crop->pad;
277 sel.target = V4L2_SUBDEV_SEL_TGT_CROP_ACTUAL;
278 sel.r = crop->rect;
279
280 rval = v4l2_subdev_call(
281 sd, pad, set_selection, subdev_fh, &sel);
282
283 crop->rect = sel.r;
284
285 return rval;
253 } 286 }
254 287
255 case VIDIOC_SUBDEV_ENUM_MBUS_CODE: { 288 case VIDIOC_SUBDEV_ENUM_MBUS_CODE: {