Skip to content

Commit

Permalink
[media] v4l2: make vidioc_s_crop const
Browse files Browse the repository at this point in the history
Write-only ioctls should have a const argument in the ioctl op.
Do this conversion for vidioc_s_crop.
Adding const for write-only ioctls was decided during the 2012 Media Workshop.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Sep 26, 2012
1 parent 3f70e1f commit 4f99659
Show file tree
Hide file tree
Showing 30 changed files with 79 additions and 79 deletions.
2 changes: 1 addition & 1 deletion drivers/media/i2c/soc_camera/mt9m001.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ static int mt9m001_s_stream(struct v4l2_subdev *sd, int enable)
return 0;
}

static int mt9m001_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
static int mt9m001_s_crop(struct v4l2_subdev *sd, const struct v4l2_crop *a)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct mt9m001 *mt9m001 = to_mt9m001(client);
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/i2c/soc_camera/mt9m111.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ static int mt9m111_reset(struct mt9m111 *mt9m111)
return ret;
}

static int mt9m111_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
static int mt9m111_s_crop(struct v4l2_subdev *sd, const struct v4l2_crop *a)
{
struct v4l2_rect rect = a->c;
struct mt9m111 *mt9m111 = container_of(sd, struct mt9m111, subdev);
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/i2c/soc_camera/mt9t031.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ static int mt9t031_set_params(struct i2c_client *client,
return ret < 0 ? ret : 0;
}

static int mt9t031_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
static int mt9t031_s_crop(struct v4l2_subdev *sd, const struct v4l2_crop *a)
{
struct v4l2_rect rect = a->c;
struct i2c_client *client = v4l2_get_subdevdata(sd);
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/i2c/soc_camera/mt9t112.c
Original file line number Diff line number Diff line change
Expand Up @@ -907,11 +907,11 @@ static int mt9t112_g_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
return 0;
}

static int mt9t112_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
static int mt9t112_s_crop(struct v4l2_subdev *sd, const struct v4l2_crop *a)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct mt9t112_priv *priv = to_mt9t112(client);
struct v4l2_rect *rect = &a->c;
const struct v4l2_rect *rect = &a->c;

return mt9t112_set_params(priv, rect, priv->format->code);
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/i2c/soc_camera/mt9v022.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ static int mt9v022_s_stream(struct v4l2_subdev *sd, int enable)
return 0;
}

static int mt9v022_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
static int mt9v022_s_crop(struct v4l2_subdev *sd, const struct v4l2_crop *a)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct mt9v022 *mt9v022 = to_mt9v022(client);
Expand Down
20 changes: 10 additions & 10 deletions drivers/media/i2c/soc_camera/ov5642.c
Original file line number Diff line number Diff line change
Expand Up @@ -865,24 +865,24 @@ static int ov5642_g_chip_ident(struct v4l2_subdev *sd,
return 0;
}

static int ov5642_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
static int ov5642_s_crop(struct v4l2_subdev *sd, const struct v4l2_crop *a)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct ov5642 *priv = to_ov5642(client);
struct v4l2_rect *rect = &a->c;
struct v4l2_rect rect = a->c;
int ret;

v4l_bound_align_image(&rect->width, 48, OV5642_MAX_WIDTH, 1,
&rect->height, 32, OV5642_MAX_HEIGHT, 1, 0);
v4l_bound_align_image(&rect.width, 48, OV5642_MAX_WIDTH, 1,
&rect.height, 32, OV5642_MAX_HEIGHT, 1, 0);

priv->crop_rect.width = rect->width;
priv->crop_rect.height = rect->height;
priv->total_width = rect->width + BLANKING_EXTRA_WIDTH;
priv->total_height = max_t(int, rect->height +
priv->crop_rect.width = rect.width;
priv->crop_rect.height = rect.height;
priv->total_width = rect.width + BLANKING_EXTRA_WIDTH;
priv->total_height = max_t(int, rect.height +
BLANKING_EXTRA_HEIGHT,
BLANKING_MIN_HEIGHT);
priv->crop_rect.width = rect->width;
priv->crop_rect.height = rect->height;
priv->crop_rect.width = rect.width;
priv->crop_rect.height = rect.height;

ret = ov5642_write_array(client, ov5642_default_regs_init);
if (!ret)
Expand Down
32 changes: 16 additions & 16 deletions drivers/media/i2c/soc_camera/ov6650.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,42 +451,42 @@ static int ov6650_g_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
return 0;
}

static int ov6650_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
static int ov6650_s_crop(struct v4l2_subdev *sd, const struct v4l2_crop *a)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct ov6650 *priv = to_ov6650(client);
struct v4l2_rect *rect = &a->c;
struct v4l2_rect rect = a->c;
int ret;

if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;

rect->left = ALIGN(rect->left, 2);
rect->width = ALIGN(rect->width, 2);
rect->top = ALIGN(rect->top, 2);
rect->height = ALIGN(rect->height, 2);
soc_camera_limit_side(&rect->left, &rect->width,
rect.left = ALIGN(rect.left, 2);
rect.width = ALIGN(rect.width, 2);
rect.top = ALIGN(rect.top, 2);
rect.height = ALIGN(rect.height, 2);
soc_camera_limit_side(&rect.left, &rect.width,
DEF_HSTRT << 1, 2, W_CIF);
soc_camera_limit_side(&rect->top, &rect->height,
soc_camera_limit_side(&rect.top, &rect.height,
DEF_VSTRT << 1, 2, H_CIF);

ret = ov6650_reg_write(client, REG_HSTRT, rect->left >> 1);
ret = ov6650_reg_write(client, REG_HSTRT, rect.left >> 1);
if (!ret) {
priv->rect.left = rect->left;
priv->rect.left = rect.left;
ret = ov6650_reg_write(client, REG_HSTOP,
(rect->left + rect->width) >> 1);
(rect.left + rect.width) >> 1);
}
if (!ret) {
priv->rect.width = rect->width;
ret = ov6650_reg_write(client, REG_VSTRT, rect->top >> 1);
priv->rect.width = rect.width;
ret = ov6650_reg_write(client, REG_VSTRT, rect.top >> 1);
}
if (!ret) {
priv->rect.top = rect->top;
priv->rect.top = rect.top;
ret = ov6650_reg_write(client, REG_VSTOP,
(rect->top + rect->height) >> 1);
(rect.top + rect.height) >> 1);
}
if (!ret)
priv->rect.height = rect->height;
priv->rect.height = rect.height;

return ret;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/i2c/soc_camera/rj54n1cb0c.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,11 +536,11 @@ static int rj54n1_commit(struct i2c_client *client)
static int rj54n1_sensor_scale(struct v4l2_subdev *sd, s32 *in_w, s32 *in_h,
s32 *out_w, s32 *out_h);

static int rj54n1_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
static int rj54n1_s_crop(struct v4l2_subdev *sd, const struct v4l2_crop *a)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct rj54n1 *rj54n1 = to_rj54n1(client);
struct v4l2_rect *rect = &a->c;
const struct v4l2_rect *rect = &a->c;
int dummy = 0, output_w, output_h,
input_w = rect->width, input_h = rect->height;
int ret;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/i2c/tvp5150.c
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ static int tvp5150_mbus_fmt(struct v4l2_subdev *sd,
return 0;
}

static int tvp5150_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
static int tvp5150_s_crop(struct v4l2_subdev *sd, const struct v4l2_crop *a)
{
struct v4l2_rect rect = a->c;
struct tvp5150 *decoder = to_tvp5150(sd);
Expand Down
10 changes: 5 additions & 5 deletions drivers/media/pci/bt8xx/bttv-driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -2986,7 +2986,7 @@ static int bttv_g_crop(struct file *file, void *f, struct v4l2_crop *crop)
return 0;
}

static int bttv_s_crop(struct file *file, void *f, struct v4l2_crop *crop)
static int bttv_s_crop(struct file *file, void *f, const struct v4l2_crop *crop)
{
struct bttv_fh *fh = f;
struct bttv *btv = fh->btv;
Expand Down Expand Up @@ -3028,17 +3028,17 @@ static int bttv_s_crop(struct file *file, void *f, struct v4l2_crop *crop)
}

/* Min. scaled size 48 x 32. */
c.rect.left = clamp(crop->c.left, b_left, b_right - 48);
c.rect.left = clamp_t(s32, crop->c.left, b_left, b_right - 48);
c.rect.left = min(c.rect.left, (__s32) MAX_HDELAY);

c.rect.width = clamp(crop->c.width,
c.rect.width = clamp_t(s32, crop->c.width,
48, b_right - c.rect.left);

c.rect.top = clamp(crop->c.top, b_top, b_bottom - 32);
c.rect.top = clamp_t(s32, crop->c.top, b_top, b_bottom - 32);
/* Top and height must be a multiple of two. */
c.rect.top = (c.rect.top + 1) & ~1;

c.rect.height = clamp(crop->c.height,
c.rect.height = clamp_t(s32, crop->c.height,
32, b_bottom - c.rect.top);
c.rect.height = (c.rect.height + 1) & ~1;

Expand Down
2 changes: 1 addition & 1 deletion drivers/media/pci/cx18/cx18-ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ static int cx18_cropcap(struct file *file, void *fh,
return 0;
}

static int cx18_s_crop(struct file *file, void *fh, struct v4l2_crop *crop)
static int cx18_s_crop(struct file *file, void *fh, const struct v4l2_crop *crop)
{
struct cx18_open_id *id = fh2id(fh);
struct cx18 *cx = id->cx;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/pci/cx25821/cx25821-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1610,7 +1610,7 @@ int cx25821_vidioc_cropcap(struct file *file, void *priv,
return 0;
}

int cx25821_vidioc_s_crop(struct file *file, void *priv, struct v4l2_crop *crop)
int cx25821_vidioc_s_crop(struct file *file, void *priv, const struct v4l2_crop *crop)
{
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
struct cx25821_fh *fh = priv;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/pci/cx25821/cx25821-video.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ extern int cx25821_set_control(struct cx25821_dev *dev,
extern int cx25821_vidioc_cropcap(struct file *file, void *fh,
struct v4l2_cropcap *cropcap);
extern int cx25821_vidioc_s_crop(struct file *file, void *priv,
struct v4l2_crop *crop);
const struct v4l2_crop *crop);
extern int cx25821_vidioc_g_crop(struct file *file, void *priv,
struct v4l2_crop *crop);

Expand Down
2 changes: 1 addition & 1 deletion drivers/media/pci/ivtv/ivtv-ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ static int ivtv_cropcap(struct file *file, void *fh, struct v4l2_cropcap *cropca
return 0;
}

static int ivtv_s_crop(struct file *file, void *fh, struct v4l2_crop *crop)
static int ivtv_s_crop(struct file *file, void *fh, const struct v4l2_crop *crop)
{
struct ivtv_open_id *id = fh2id(fh);
struct ivtv *itv = id->itv;
Expand Down
32 changes: 16 additions & 16 deletions drivers/media/pci/saa7134/saa7134-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1953,11 +1953,12 @@ static int saa7134_g_crop(struct file *file, void *f, struct v4l2_crop *crop)
return 0;
}

static int saa7134_s_crop(struct file *file, void *f, struct v4l2_crop *crop)
static int saa7134_s_crop(struct file *file, void *f, const struct v4l2_crop *crop)
{
struct saa7134_fh *fh = f;
struct saa7134_dev *dev = fh->dev;
struct v4l2_rect *b = &dev->crop_bounds;
struct v4l2_rect *c = &dev->crop_current;

if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE &&
crop->type != V4L2_BUF_TYPE_VIDEO_OVERLAY)
Expand All @@ -1972,21 +1973,20 @@ static int saa7134_s_crop(struct file *file, void *f, struct v4l2_crop *crop)
if (res_locked(fh->dev, RESOURCE_VIDEO))
return -EBUSY;

if (crop->c.top < b->top)
crop->c.top = b->top;
if (crop->c.top > b->top + b->height)
crop->c.top = b->top + b->height;
if (crop->c.height > b->top - crop->c.top + b->height)
crop->c.height = b->top - crop->c.top + b->height;

if (crop->c.left < b->left)
crop->c.left = b->left;
if (crop->c.left > b->left + b->width)
crop->c.left = b->left + b->width;
if (crop->c.width > b->left - crop->c.left + b->width)
crop->c.width = b->left - crop->c.left + b->width;

dev->crop_current = crop->c;
*c = crop->c;
if (c->top < b->top)
c->top = b->top;
if (c->top > b->top + b->height)
c->top = b->top + b->height;
if (c->height > b->top - c->top + b->height)
c->height = b->top - c->top + b->height;

if (c->left < b->left)
c->left = b->left;
if (c->left > b->left + b->width)
c->left = b->left + b->width;
if (c->width > b->left - c->left + b->width)
c->width = b->left - c->left + b->width;
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/media/pci/zoran/zoran_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -2598,7 +2598,7 @@ static int zoran_g_crop(struct file *file, void *__fh, struct v4l2_crop *crop)
return res;
}

static int zoran_s_crop(struct file *file, void *__fh, struct v4l2_crop *crop)
static int zoran_s_crop(struct file *file, void *__fh, const struct v4l2_crop *crop)
{
struct zoran_fh *fh = __fh;
struct zoran *zr = fh->zr;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/platform/davinci/vpbe_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ static int vpbe_display_querycap(struct file *file, void *priv,
}

static int vpbe_display_s_crop(struct file *file, void *priv,
struct v4l2_crop *crop)
const struct v4l2_crop *crop)
{
struct vpbe_fh *fh = file->private_data;
struct vpbe_layer *layer = fh->layer;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/platform/davinci/vpfe_capture.c
Original file line number Diff line number Diff line change
Expand Up @@ -1666,7 +1666,7 @@ static int vpfe_g_crop(struct file *file, void *priv,
}

static int vpfe_s_crop(struct file *file, void *priv,
struct v4l2_crop *crop)
const struct v4l2_crop *crop)
{
struct vpfe_device *vpfe_dev = video_drvdata(file);
int ret = 0;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/platform/omap/omap_vout.c
Original file line number Diff line number Diff line change
Expand Up @@ -1291,7 +1291,7 @@ static int vidioc_g_crop(struct file *file, void *fh, struct v4l2_crop *crop)
return 0;
}

static int vidioc_s_crop(struct file *file, void *fh, struct v4l2_crop *crop)
static int vidioc_s_crop(struct file *file, void *fh, const struct v4l2_crop *crop)
{
int ret = -EINVAL;
struct omap_vout_device *vout = fh;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/platform/s5p-fimc/fimc-m2m.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ static int fimc_m2m_try_crop(struct fimc_ctx *ctx, struct v4l2_crop *cr)
return 0;
}

static int fimc_m2m_s_crop(struct file *file, void *fh, struct v4l2_crop *cr)
static int fimc_m2m_s_crop(struct file *file, void *fh, const struct v4l2_crop *cr)
{
struct fimc_ctx *ctx = fh_to_ctx(fh);
struct fimc_dev *fimc = ctx->fimc_dev;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/platform/s5p-g2d/g2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ static int vidioc_try_crop(struct file *file, void *prv, struct v4l2_crop *cr)
return 0;
}

static int vidioc_s_crop(struct file *file, void *prv, struct v4l2_crop *cr)
static int vidioc_s_crop(struct file *file, void *prv, const struct v4l2_crop *cr)
{
struct g2d_ctx *ctx = prv;
struct g2d_frame *f;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/platform/sh_vou.c
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ static int sh_vou_g_crop(struct file *file, void *fh, struct v4l2_crop *a)
}

/* Assume a dull encoder, do all the work ourselves. */
static int sh_vou_s_crop(struct file *file, void *fh, struct v4l2_crop *a)
static int sh_vou_s_crop(struct file *file, void *fh, const struct v4l2_crop *a)
{
struct video_device *vdev = video_devdata(file);
struct sh_vou_device *vou_dev = video_get_drvdata(vdev);
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,7 @@ static void update_subrect(struct sh_mobile_ceu_cam *cam)
* 3. if (2) failed, try to request the maximum image
*/
static int client_s_crop(struct soc_camera_device *icd, struct v4l2_crop *crop,
struct v4l2_crop *cam_crop)
const struct v4l2_crop *cam_crop)
{
struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
struct v4l2_rect *rect = &crop->c, *cam_rect = &cam_crop->c;
Expand Down Expand Up @@ -1517,7 +1517,7 @@ static int client_scale(struct soc_camera_device *icd,
* scaling and cropping algorithms and for the meaning of referenced here steps.
*/
static int sh_mobile_ceu_set_crop(struct soc_camera_device *icd,
struct v4l2_crop *a)
const struct v4l2_crop *a)
{
struct v4l2_rect *rect = &a->c;
struct device *dev = icd->parent;
Expand Down
6 changes: 3 additions & 3 deletions drivers/media/platform/soc_camera/soc_camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -888,11 +888,11 @@ static int soc_camera_g_crop(struct file *file, void *fh,
* retrieve it.
*/
static int soc_camera_s_crop(struct file *file, void *fh,
struct v4l2_crop *a)
const struct v4l2_crop *a)
{
struct soc_camera_device *icd = file->private_data;
struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
struct v4l2_rect *rect = &a->c;
const struct v4l2_rect *rect = &a->c;
struct v4l2_crop current_crop;
int ret;

Expand Down Expand Up @@ -1289,7 +1289,7 @@ static int default_g_crop(struct soc_camera_device *icd, struct v4l2_crop *a)
return v4l2_subdev_call(sd, video, g_crop, a);
}

static int default_s_crop(struct soc_camera_device *icd, struct v4l2_crop *a)
static int default_s_crop(struct soc_camera_device *icd, const struct v4l2_crop *a)
{
struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
return v4l2_subdev_call(sd, video, s_crop, a);
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/platform/vino.c
Original file line number Diff line number Diff line change
Expand Up @@ -3284,7 +3284,7 @@ static int vino_g_crop(struct file *file, void *__fh,
}

static int vino_s_crop(struct file *file, void *__fh,
struct v4l2_crop *c)
const struct v4l2_crop *c)
{
struct vino_channel_settings *vcs = video_drvdata(file);
unsigned long flags;
Expand Down
Loading

0 comments on commit 4f99659

Please sign in to comment.