diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2016-07-03 07:28:28 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2016-08-24 08:51:15 -0400 |
commit | 540da0258c6a8fe2d7ca3ee6fecb21ab75a6bbc7 (patch) | |
tree | c692d6a7bd7073223de39a28c91924e8f2d3a9e5 /drivers/media | |
parent | 802d62c1db166d4ef5a27c81b372437a409b033e (diff) |
[media] zoran: convert g/s_crop to g/s_selection
This is part of a final push to convert all drivers to g/s_selection.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/pci/zoran/zoran_driver.c | 113 |
1 files changed, 49 insertions, 64 deletions
diff --git a/drivers/media/pci/zoran/zoran_driver.c b/drivers/media/pci/zoran/zoran_driver.c index 80caa70c6360..d6b631add216 100644 --- a/drivers/media/pci/zoran/zoran_driver.c +++ b/drivers/media/pci/zoran/zoran_driver.c | |||
@@ -2365,94 +2365,80 @@ static int zoran_s_output(struct file *file, void *__fh, unsigned int output) | |||
2365 | } | 2365 | } |
2366 | 2366 | ||
2367 | /* cropping (sub-frame capture) */ | 2367 | /* cropping (sub-frame capture) */ |
2368 | static int zoran_cropcap(struct file *file, void *__fh, | 2368 | static int zoran_g_selection(struct file *file, void *__fh, struct v4l2_selection *sel) |
2369 | struct v4l2_cropcap *cropcap) | ||
2370 | { | 2369 | { |
2371 | struct zoran_fh *fh = __fh; | 2370 | struct zoran_fh *fh = __fh; |
2372 | struct zoran *zr = fh->zr; | 2371 | struct zoran *zr = fh->zr; |
2373 | int type = cropcap->type, res = 0; | ||
2374 | 2372 | ||
2375 | memset(cropcap, 0, sizeof(*cropcap)); | 2373 | if (sel->type != V4L2_BUF_TYPE_VIDEO_OUTPUT && |
2376 | cropcap->type = type; | 2374 | sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
2375 | return -EINVAL; | ||
2377 | 2376 | ||
2378 | if (cropcap->type != V4L2_BUF_TYPE_VIDEO_OUTPUT && | 2377 | if (fh->map_mode == ZORAN_MAP_MODE_RAW) { |
2379 | (cropcap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || | ||
2380 | fh->map_mode == ZORAN_MAP_MODE_RAW)) { | ||
2381 | dprintk(1, KERN_ERR | 2378 | dprintk(1, KERN_ERR |
2382 | "%s: VIDIOC_CROPCAP - subcapture only supported for compressed capture\n", | 2379 | "%s: VIDIOC_G_SELECTION - subcapture only supported for compressed capture\n", |
2383 | ZR_DEVNAME(zr)); | 2380 | ZR_DEVNAME(zr)); |
2384 | res = -EINVAL; | 2381 | return -EINVAL; |
2385 | return res; | ||
2386 | } | 2382 | } |
2387 | 2383 | ||
2388 | cropcap->bounds.top = cropcap->bounds.left = 0; | 2384 | switch (sel->target) { |
2389 | cropcap->bounds.width = BUZ_MAX_WIDTH; | 2385 | case V4L2_SEL_TGT_CROP: |
2390 | cropcap->bounds.height = BUZ_MAX_HEIGHT; | 2386 | sel->r.top = fh->jpg_settings.img_y; |
2391 | cropcap->defrect.top = cropcap->defrect.left = 0; | 2387 | sel->r.left = fh->jpg_settings.img_x; |
2392 | cropcap->defrect.width = BUZ_MIN_WIDTH; | 2388 | sel->r.width = fh->jpg_settings.img_width; |
2393 | cropcap->defrect.height = BUZ_MIN_HEIGHT; | 2389 | sel->r.height = fh->jpg_settings.img_height; |
2394 | return res; | 2390 | break; |
2395 | } | 2391 | case V4L2_SEL_TGT_CROP_DEFAULT: |
2396 | 2392 | sel->r.top = sel->r.left = 0; | |
2397 | static int zoran_g_crop(struct file *file, void *__fh, struct v4l2_crop *crop) | 2393 | sel->r.width = BUZ_MIN_WIDTH; |
2398 | { | 2394 | sel->r.height = BUZ_MIN_HEIGHT; |
2399 | struct zoran_fh *fh = __fh; | 2395 | break; |
2400 | struct zoran *zr = fh->zr; | 2396 | case V4L2_SEL_TGT_CROP_BOUNDS: |
2401 | int type = crop->type, res = 0; | 2397 | sel->r.top = sel->r.left = 0; |
2402 | 2398 | sel->r.width = BUZ_MAX_WIDTH; | |
2403 | memset(crop, 0, sizeof(*crop)); | 2399 | sel->r.height = BUZ_MAX_HEIGHT; |
2404 | crop->type = type; | 2400 | break; |
2405 | 2401 | default: | |
2406 | if (crop->type != V4L2_BUF_TYPE_VIDEO_OUTPUT && | 2402 | return -EINVAL; |
2407 | (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || | ||
2408 | fh->map_mode == ZORAN_MAP_MODE_RAW)) { | ||
2409 | dprintk(1, | ||
2410 | KERN_ERR | ||
2411 | "%s: VIDIOC_G_CROP - subcapture only supported for compressed capture\n", | ||
2412 | ZR_DEVNAME(zr)); | ||
2413 | res = -EINVAL; | ||
2414 | return res; | ||
2415 | } | 2403 | } |
2416 | 2404 | return 0; | |
2417 | crop->c.top = fh->jpg_settings.img_y; | ||
2418 | crop->c.left = fh->jpg_settings.img_x; | ||
2419 | crop->c.width = fh->jpg_settings.img_width; | ||
2420 | crop->c.height = fh->jpg_settings.img_height; | ||
2421 | return res; | ||
2422 | } | 2405 | } |
2423 | 2406 | ||
2424 | static int zoran_s_crop(struct file *file, void *__fh, const struct v4l2_crop *crop) | 2407 | static int zoran_s_selection(struct file *file, void *__fh, struct v4l2_selection *sel) |
2425 | { | 2408 | { |
2426 | struct zoran_fh *fh = __fh; | 2409 | struct zoran_fh *fh = __fh; |
2427 | struct zoran *zr = fh->zr; | 2410 | struct zoran *zr = fh->zr; |
2428 | int res = 0; | ||
2429 | struct zoran_jpg_settings settings; | 2411 | struct zoran_jpg_settings settings; |
2412 | int res; | ||
2430 | 2413 | ||
2431 | settings = fh->jpg_settings; | 2414 | if (sel->type != V4L2_BUF_TYPE_VIDEO_OUTPUT && |
2415 | sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
2416 | return -EINVAL; | ||
2432 | 2417 | ||
2433 | if (fh->buffers.allocated) { | 2418 | if (sel->target != V4L2_SEL_TGT_CROP) |
2419 | return -EINVAL; | ||
2420 | |||
2421 | if (fh->map_mode == ZORAN_MAP_MODE_RAW) { | ||
2434 | dprintk(1, KERN_ERR | 2422 | dprintk(1, KERN_ERR |
2435 | "%s: VIDIOC_S_CROP - cannot change settings while active\n", | 2423 | "%s: VIDIOC_S_SELECTION - subcapture only supported for compressed capture\n", |
2436 | ZR_DEVNAME(zr)); | 2424 | ZR_DEVNAME(zr)); |
2437 | res = -EBUSY; | 2425 | return -EINVAL; |
2438 | return res; | ||
2439 | } | 2426 | } |
2440 | 2427 | ||
2441 | if (crop->type != V4L2_BUF_TYPE_VIDEO_OUTPUT && | 2428 | settings = fh->jpg_settings; |
2442 | (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || | 2429 | |
2443 | fh->map_mode == ZORAN_MAP_MODE_RAW)) { | 2430 | if (fh->buffers.allocated) { |
2444 | dprintk(1, KERN_ERR | 2431 | dprintk(1, KERN_ERR |
2445 | "%s: VIDIOC_G_CROP - subcapture only supported for compressed capture\n", | 2432 | "%s: VIDIOC_S_SELECTION - cannot change settings while active\n", |
2446 | ZR_DEVNAME(zr)); | 2433 | ZR_DEVNAME(zr)); |
2447 | res = -EINVAL; | 2434 | return -EBUSY; |
2448 | return res; | ||
2449 | } | 2435 | } |
2450 | 2436 | ||
2451 | /* move into a form that we understand */ | 2437 | /* move into a form that we understand */ |
2452 | settings.img_x = crop->c.left; | 2438 | settings.img_x = sel->r.left; |
2453 | settings.img_y = crop->c.top; | 2439 | settings.img_y = sel->r.top; |
2454 | settings.img_width = crop->c.width; | 2440 | settings.img_width = sel->r.width; |
2455 | settings.img_height = crop->c.height; | 2441 | settings.img_height = sel->r.height; |
2456 | 2442 | ||
2457 | /* check validity */ | 2443 | /* check validity */ |
2458 | res = zoran_check_jpg_settings(zr, &settings, 0); | 2444 | res = zoran_check_jpg_settings(zr, &settings, 0); |
@@ -2808,9 +2794,8 @@ zoran_mmap (struct file *file, | |||
2808 | 2794 | ||
2809 | static const struct v4l2_ioctl_ops zoran_ioctl_ops = { | 2795 | static const struct v4l2_ioctl_ops zoran_ioctl_ops = { |
2810 | .vidioc_querycap = zoran_querycap, | 2796 | .vidioc_querycap = zoran_querycap, |
2811 | .vidioc_cropcap = zoran_cropcap, | 2797 | .vidioc_s_selection = zoran_s_selection, |
2812 | .vidioc_s_crop = zoran_s_crop, | 2798 | .vidioc_g_selection = zoran_g_selection, |
2813 | .vidioc_g_crop = zoran_g_crop, | ||
2814 | .vidioc_enum_input = zoran_enum_input, | 2799 | .vidioc_enum_input = zoran_enum_input, |
2815 | .vidioc_g_input = zoran_g_input, | 2800 | .vidioc_g_input = zoran_g_input, |
2816 | .vidioc_s_input = zoran_s_input, | 2801 | .vidioc_s_input = zoran_s_input, |