Commit 540da025 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[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: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 802d62c1
...@@ -2365,94 +2365,80 @@ static int zoran_s_output(struct file *file, void *__fh, unsigned int output) ...@@ -2365,94 +2365,80 @@ static int zoran_s_output(struct file *file, void *__fh, unsigned int output)
} }
/* cropping (sub-frame capture) */ /* cropping (sub-frame capture) */
static int zoran_cropcap(struct file *file, void *__fh, static int zoran_g_selection(struct file *file, void *__fh, struct v4l2_selection *sel)
struct v4l2_cropcap *cropcap)
{ {
struct zoran_fh *fh = __fh; struct zoran_fh *fh = __fh;
struct zoran *zr = fh->zr; struct zoran *zr = fh->zr;
int type = cropcap->type, res = 0;
memset(cropcap, 0, sizeof(*cropcap)); if (sel->type != V4L2_BUF_TYPE_VIDEO_OUTPUT &&
cropcap->type = type; sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
if (cropcap->type != V4L2_BUF_TYPE_VIDEO_OUTPUT && if (fh->map_mode == ZORAN_MAP_MODE_RAW) {
(cropcap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE ||
fh->map_mode == ZORAN_MAP_MODE_RAW)) {
dprintk(1, KERN_ERR dprintk(1, KERN_ERR
"%s: VIDIOC_CROPCAP - subcapture only supported for compressed capture\n", "%s: VIDIOC_G_SELECTION - subcapture only supported for compressed capture\n",
ZR_DEVNAME(zr)); ZR_DEVNAME(zr));
res = -EINVAL; return -EINVAL;
return res;
} }
cropcap->bounds.top = cropcap->bounds.left = 0; switch (sel->target) {
cropcap->bounds.width = BUZ_MAX_WIDTH; case V4L2_SEL_TGT_CROP:
cropcap->bounds.height = BUZ_MAX_HEIGHT; sel->r.top = fh->jpg_settings.img_y;
cropcap->defrect.top = cropcap->defrect.left = 0; sel->r.left = fh->jpg_settings.img_x;
cropcap->defrect.width = BUZ_MIN_WIDTH; sel->r.width = fh->jpg_settings.img_width;
cropcap->defrect.height = BUZ_MIN_HEIGHT; sel->r.height = fh->jpg_settings.img_height;
return res; break;
} case V4L2_SEL_TGT_CROP_DEFAULT:
sel->r.top = sel->r.left = 0;
static int zoran_g_crop(struct file *file, void *__fh, struct v4l2_crop *crop) sel->r.width = BUZ_MIN_WIDTH;
{ sel->r.height = BUZ_MIN_HEIGHT;
struct zoran_fh *fh = __fh; break;
struct zoran *zr = fh->zr; case V4L2_SEL_TGT_CROP_BOUNDS:
int type = crop->type, res = 0; sel->r.top = sel->r.left = 0;
sel->r.width = BUZ_MAX_WIDTH;
memset(crop, 0, sizeof(*crop)); sel->r.height = BUZ_MAX_HEIGHT;
crop->type = type; break;
default:
if (crop->type != V4L2_BUF_TYPE_VIDEO_OUTPUT && return -EINVAL;
(crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE ||
fh->map_mode == ZORAN_MAP_MODE_RAW)) {
dprintk(1,
KERN_ERR
"%s: VIDIOC_G_CROP - subcapture only supported for compressed capture\n",
ZR_DEVNAME(zr));
res = -EINVAL;
return res;
} }
return 0;
crop->c.top = fh->jpg_settings.img_y;
crop->c.left = fh->jpg_settings.img_x;
crop->c.width = fh->jpg_settings.img_width;
crop->c.height = fh->jpg_settings.img_height;
return res;
} }
static int zoran_s_crop(struct file *file, void *__fh, const struct v4l2_crop *crop) static int zoran_s_selection(struct file *file, void *__fh, struct v4l2_selection *sel)
{ {
struct zoran_fh *fh = __fh; struct zoran_fh *fh = __fh;
struct zoran *zr = fh->zr; struct zoran *zr = fh->zr;
int res = 0;
struct zoran_jpg_settings settings; struct zoran_jpg_settings settings;
int res;
settings = fh->jpg_settings; if (sel->type != V4L2_BUF_TYPE_VIDEO_OUTPUT &&
sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
if (fh->buffers.allocated) { if (sel->target != V4L2_SEL_TGT_CROP)
return -EINVAL;
if (fh->map_mode == ZORAN_MAP_MODE_RAW) {
dprintk(1, KERN_ERR dprintk(1, KERN_ERR
"%s: VIDIOC_S_CROP - cannot change settings while active\n", "%s: VIDIOC_S_SELECTION - subcapture only supported for compressed capture\n",
ZR_DEVNAME(zr)); ZR_DEVNAME(zr));
res = -EBUSY; return -EINVAL;
return res;
} }
if (crop->type != V4L2_BUF_TYPE_VIDEO_OUTPUT && settings = fh->jpg_settings;
(crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE ||
fh->map_mode == ZORAN_MAP_MODE_RAW)) { if (fh->buffers.allocated) {
dprintk(1, KERN_ERR dprintk(1, KERN_ERR
"%s: VIDIOC_G_CROP - subcapture only supported for compressed capture\n", "%s: VIDIOC_S_SELECTION - cannot change settings while active\n",
ZR_DEVNAME(zr)); ZR_DEVNAME(zr));
res = -EINVAL; return -EBUSY;
return res;
} }
/* move into a form that we understand */ /* move into a form that we understand */
settings.img_x = crop->c.left; settings.img_x = sel->r.left;
settings.img_y = crop->c.top; settings.img_y = sel->r.top;
settings.img_width = crop->c.width; settings.img_width = sel->r.width;
settings.img_height = crop->c.height; settings.img_height = sel->r.height;
/* check validity */ /* check validity */
res = zoran_check_jpg_settings(zr, &settings, 0); res = zoran_check_jpg_settings(zr, &settings, 0);
...@@ -2808,9 +2794,8 @@ zoran_mmap (struct file *file, ...@@ -2808,9 +2794,8 @@ zoran_mmap (struct file *file,
static const struct v4l2_ioctl_ops zoran_ioctl_ops = { static const struct v4l2_ioctl_ops zoran_ioctl_ops = {
.vidioc_querycap = zoran_querycap, .vidioc_querycap = zoran_querycap,
.vidioc_cropcap = zoran_cropcap, .vidioc_s_selection = zoran_s_selection,
.vidioc_s_crop = zoran_s_crop, .vidioc_g_selection = zoran_g_selection,
.vidioc_g_crop = zoran_g_crop,
.vidioc_enum_input = zoran_enum_input, .vidioc_enum_input = zoran_enum_input,
.vidioc_g_input = zoran_g_input, .vidioc_g_input = zoran_g_input,
.vidioc_s_input = zoran_s_input, .vidioc_s_input = zoran_s_input,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment