Commit 8407653f authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[media] stk-webcam: zero the priv field of v4l2_pix_format

The priv field should be set to 0. In this case the driver abused the priv
field for internal housekeeping. Modify the code so priv is no longer used
for that purpose.
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Tested-by: default avatarArvydas Sidorenko <asido4@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent b27763f0
...@@ -897,11 +897,12 @@ static int stk_vidioc_g_fmt_vid_cap(struct file *filp, ...@@ -897,11 +897,12 @@ static int stk_vidioc_g_fmt_vid_cap(struct file *filp,
pix_format->bytesperline = 2 * pix_format->width; pix_format->bytesperline = 2 * pix_format->width;
pix_format->sizeimage = pix_format->bytesperline pix_format->sizeimage = pix_format->bytesperline
* pix_format->height; * pix_format->height;
pix_format->priv = 0;
return 0; return 0;
} }
static int stk_vidioc_try_fmt_vid_cap(struct file *filp, static int stk_try_fmt_vid_cap(struct file *filp,
void *priv, struct v4l2_format *fmtd) struct v4l2_format *fmtd, int *idx)
{ {
int i; int i;
switch (fmtd->fmt.pix.pixelformat) { switch (fmtd->fmt.pix.pixelformat) {
...@@ -923,11 +924,13 @@ static int stk_vidioc_try_fmt_vid_cap(struct file *filp, ...@@ -923,11 +924,13 @@ static int stk_vidioc_try_fmt_vid_cap(struct file *filp,
< abs(fmtd->fmt.pix.width - stk_sizes[i].w))) { < abs(fmtd->fmt.pix.width - stk_sizes[i].w))) {
fmtd->fmt.pix.height = stk_sizes[i-1].h; fmtd->fmt.pix.height = stk_sizes[i-1].h;
fmtd->fmt.pix.width = stk_sizes[i-1].w; fmtd->fmt.pix.width = stk_sizes[i-1].w;
fmtd->fmt.pix.priv = i - 1; if (idx)
*idx = i - 1;
} else { } else {
fmtd->fmt.pix.height = stk_sizes[i].h; fmtd->fmt.pix.height = stk_sizes[i].h;
fmtd->fmt.pix.width = stk_sizes[i].w; fmtd->fmt.pix.width = stk_sizes[i].w;
fmtd->fmt.pix.priv = i; if (idx)
*idx = i;
} }
fmtd->fmt.pix.field = V4L2_FIELD_NONE; fmtd->fmt.pix.field = V4L2_FIELD_NONE;
...@@ -938,9 +941,16 @@ static int stk_vidioc_try_fmt_vid_cap(struct file *filp, ...@@ -938,9 +941,16 @@ static int stk_vidioc_try_fmt_vid_cap(struct file *filp,
fmtd->fmt.pix.bytesperline = 2 * fmtd->fmt.pix.width; fmtd->fmt.pix.bytesperline = 2 * fmtd->fmt.pix.width;
fmtd->fmt.pix.sizeimage = fmtd->fmt.pix.bytesperline fmtd->fmt.pix.sizeimage = fmtd->fmt.pix.bytesperline
* fmtd->fmt.pix.height; * fmtd->fmt.pix.height;
fmtd->fmt.pix.priv = 0;
return 0; return 0;
} }
static int stk_vidioc_try_fmt_vid_cap(struct file *filp,
void *priv, struct v4l2_format *fmtd)
{
return stk_try_fmt_vid_cap(filp, fmtd, NULL);
}
static int stk_setup_format(struct stk_camera *dev) static int stk_setup_format(struct stk_camera *dev)
{ {
int i = 0; int i = 0;
...@@ -981,6 +991,7 @@ static int stk_vidioc_s_fmt_vid_cap(struct file *filp, ...@@ -981,6 +991,7 @@ static int stk_vidioc_s_fmt_vid_cap(struct file *filp,
void *priv, struct v4l2_format *fmtd) void *priv, struct v4l2_format *fmtd)
{ {
int ret; int ret;
int idx;
struct stk_camera *dev = video_drvdata(filp); struct stk_camera *dev = video_drvdata(filp);
if (dev == NULL) if (dev == NULL)
...@@ -991,7 +1002,7 @@ static int stk_vidioc_s_fmt_vid_cap(struct file *filp, ...@@ -991,7 +1002,7 @@ static int stk_vidioc_s_fmt_vid_cap(struct file *filp,
return -EBUSY; return -EBUSY;
if (dev->owner && dev->owner != filp) if (dev->owner && dev->owner != filp)
return -EBUSY; return -EBUSY;
ret = stk_vidioc_try_fmt_vid_cap(filp, priv, fmtd); ret = stk_try_fmt_vid_cap(filp, fmtd, &idx);
if (ret) if (ret)
return ret; return ret;
dev->owner = filp; dev->owner = filp;
...@@ -999,7 +1010,7 @@ static int stk_vidioc_s_fmt_vid_cap(struct file *filp, ...@@ -999,7 +1010,7 @@ static int stk_vidioc_s_fmt_vid_cap(struct file *filp,
dev->vsettings.palette = fmtd->fmt.pix.pixelformat; dev->vsettings.palette = fmtd->fmt.pix.pixelformat;
stk_free_buffers(dev); stk_free_buffers(dev);
dev->frame_size = fmtd->fmt.pix.sizeimage; dev->frame_size = fmtd->fmt.pix.sizeimage;
dev->vsettings.mode = stk_sizes[fmtd->fmt.pix.priv].m; dev->vsettings.mode = stk_sizes[idx].m;
stk_initialise(dev); stk_initialise(dev);
return stk_setup_format(dev); return stk_setup_format(dev);
......
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