]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
media: drivers/media: don't set pix->priv = 0
authorHans Verkuil <hverkuil@xs4all.nl>
Wed, 26 Jun 2019 09:58:02 +0000 (05:58 -0400)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Tue, 23 Jul 2019 12:48:33 +0000 (08:48 -0400)
The priv field of struct v4l2_pix_format shouldn't be set by drivers,
it's set by the v4l2 core instead to V4L2_PIX_FMT_PRIV_MAGIC.

Drop this from the few media drivers that still do this.

Note that the gspca patch is slightly more involved since some of the
sub-gspca drivers use the priv field internally.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
[hverkuil-cisco@xs4all.nl: fix clash in gspca between priv arg and priv variable]
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/pci/cobalt/cobalt-v4l2.c
drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c
drivers/media/pci/solo6x10/solo6x10-v4l2.c
drivers/media/pci/tw68/tw68-video.c
drivers/media/platform/davinci/vpif_capture.c
drivers/media/usb/au0828/au0828-video.c
drivers/media/usb/cpia2/cpia2_v4l.c
drivers/media/usb/em28xx/em28xx-video.c
drivers/media/usb/gspca/gspca.c
drivers/media/usb/s2255/s2255drv.c
drivers/media/usb/uvc/uvc_v4l2.c

index ea96f333ee2b7606d5bf919c6b1cbb7d12192bc9..c5207501d5e03cf7ae1bf44309f8ffd74ef60f5e 100644 (file)
@@ -785,7 +785,6 @@ static int cobalt_try_fmt_vid_cap(struct file *file, void *priv_fh,
 
        pix->sizeimage = pix->bytesperline * pix->height;
        pix->field = V4L2_FIELD_NONE;
-       pix->priv = 0;
 
        return 0;
 }
index a02f08459e146f5a73909404539a7526c317bc48..476d7f3b32d63a2e206f4db40301604f38d24c7a 100644 (file)
@@ -879,7 +879,6 @@ static int solo_enc_try_fmt_cap(struct file *file, void *priv,
        pix->colorspace = V4L2_COLORSPACE_SMPTE170M;
        pix->sizeimage = FRAME_BUF_SIZE;
        pix->bytesperline = 0;
-       pix->priv = 0;
 
        return 0;
 }
@@ -934,7 +933,6 @@ static int solo_enc_get_fmt_cap(struct file *file, void *priv,
                     V4L2_FIELD_NONE;
        pix->sizeimage = FRAME_BUF_SIZE;
        pix->colorspace = V4L2_COLORSPACE_SMPTE170M;
-       pix->priv = 0;
 
        return 0;
 }
index 2efa539d6075727dba0b918c00268a38620ad241..78792067e920f37e19c20b04ad7adfb15836d3e2 100644 (file)
@@ -477,7 +477,6 @@ static int solo_try_fmt_cap(struct file *file, void *priv,
        pix->field = V4L2_FIELD_INTERLACED;
        pix->pixelformat = V4L2_PIX_FMT_UYVY;
        pix->colorspace = V4L2_COLORSPACE_SMPTE170M;
-       pix->priv = 0;
        return 0;
 }
 
@@ -507,7 +506,6 @@ static int solo_get_fmt_cap(struct file *file, void *priv,
        pix->sizeimage = solo_image_size(solo_dev);
        pix->colorspace = V4L2_COLORSPACE_SMPTE170M;
        pix->bytesperline = solo_bytesperline(solo_dev);
-       pix->priv = 0;
 
        return 0;
 }
index 99e74c22d3bec35e7a791b3fc66ce529c8e5edc6..2fb82d50c53e52786e8d1a951ee7dbb0dcd0305f 100644 (file)
@@ -582,7 +582,6 @@ static int tw68_g_fmt_vid_cap(struct file *file, void *priv,
        f->fmt.pix.sizeimage =
                f->fmt.pix.height * f->fmt.pix.bytesperline;
        f->fmt.pix.colorspace   = V4L2_COLORSPACE_SMPTE170M;
-       f->fmt.pix.priv = 0;
        return 0;
 }
 
index 9fe7caf6aa13fc72e686d15d792a934dbd7f0b24..d5eadd45158776bb9b8b17fdf117a0b3e5fffe95 100644 (file)
@@ -972,7 +972,6 @@ static int vpif_try_fmt_vid_cap(struct file *file, void *priv,
                pixfmt->bytesperline = common->fmt.fmt.pix.width * 2;
                pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height;
        }
-       pixfmt->priv = 0;
 
        dev_dbg(vpif_dev, "%s: %d x %d; pitch=%d pixelformat=0x%08x, field=%d, size=%d\n", __func__,
                pixfmt->width, pixfmt->height,
index e390ca57520a2c3c6bb76c9a71b376fd7f8a1af0..d1895334cbbf7b6ea48093006dc7051adfbe6119 100644 (file)
@@ -1153,7 +1153,6 @@ static int au0828_set_format(struct au0828_dev *dev, unsigned int cmd,
        format->fmt.pix.sizeimage = width * height * 2;
        format->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
        format->fmt.pix.field = V4L2_FIELD_INTERLACED;
-       format->fmt.pix.priv = 0;
 
        if (cmd == VIDIOC_TRY_FMT)
                return 0;
@@ -1227,7 +1226,6 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
        f->fmt.pix.sizeimage = dev->frame_size;
        f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; /* NTSC/PAL */
        f->fmt.pix.field = V4L2_FIELD_INTERLACED;
-       f->fmt.pix.priv = 0;
        return 0;
 }
 
index ded7eb2dc40a8db7f8642fd5e1afdf8dbf288307..626264a56517f1966d13ee3af1479a0afa4d2436 100644 (file)
@@ -323,7 +323,6 @@ static int cpia2_try_fmt_vid_cap(struct file *file, void *fh,
        f->fmt.pix.bytesperline = 0;
        f->fmt.pix.sizeimage = cam->frame_size;
        f->fmt.pix.colorspace = V4L2_COLORSPACE_JPEG;
-       f->fmt.pix.priv = 0;
 
        switch (cpia2_match_video_size(f->fmt.pix.width, f->fmt.pix.height)) {
        case VIDEOSIZE_VGA:
@@ -434,7 +433,6 @@ static int cpia2_g_fmt_vid_cap(struct file *file, void *fh,
        f->fmt.pix.bytesperline = 0;
        f->fmt.pix.sizeimage = cam->frame_size;
        f->fmt.pix.colorspace = V4L2_COLORSPACE_JPEG;
-       f->fmt.pix.priv = 0;
 
        return 0;
 }
index 82eb1550ec3b105902394cf6bddc60e20fb00598..fc6d37d76dc9282b0445d768332219df4b1dc7a4 100644 (file)
@@ -1510,7 +1510,6 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
        else
                f->fmt.pix.field = v4l2->interlaced_fieldmode ?
                           V4L2_FIELD_INTERLACED : V4L2_FIELD_TOP;
-       f->fmt.pix.priv = 0;
 
        return 0;
 }
index 83b78a42414e704e2d2cf5bb679d8174be7b41d3..4add2b12d33023d3f340ebc12204d205e3e7e010 100644 (file)
@@ -1027,15 +1027,15 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void  *priv,
        return 0;
 }
 
-static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
-                           struct v4l2_format *fmt)
+static int vidioc_g_fmt_vid_cap(struct file *file, void *_priv,
+                               struct v4l2_format *fmt)
 {
        struct gspca_dev *gspca_dev = video_drvdata(file);
+       u32 priv = fmt->fmt.pix.priv;
 
        fmt->fmt.pix = gspca_dev->pixfmt;
-       /* some drivers use priv internally, zero it before giving it back to
-          the core */
-       fmt->fmt.pix.priv = 0;
+       /* some drivers use priv internally, so keep the original value */
+       fmt->fmt.pix.priv = priv;
        return 0;
 }
 
@@ -1070,27 +1070,27 @@ static int try_fmt_vid_cap(struct gspca_dev *gspca_dev,
                fmt->fmt.pix.height = h;
                gspca_dev->sd_desc->try_fmt(gspca_dev, fmt);
        }
-       /* some drivers use priv internally, zero it before giving it back to
-          the core */
-       fmt->fmt.pix.priv = 0;
        return mode;                    /* used when s_fmt */
 }
 
-static int vidioc_try_fmt_vid_cap(struct file *file,
-                             void *priv,
-                             struct v4l2_format *fmt)
+static int vidioc_try_fmt_vid_cap(struct file *file, void *_priv,
+                                 struct v4l2_format *fmt)
 {
        struct gspca_dev *gspca_dev = video_drvdata(file);
+       u32 priv = fmt->fmt.pix.priv;
 
        if (try_fmt_vid_cap(gspca_dev, fmt) < 0)
                return -EINVAL;
+       /* some drivers use priv internally, so keep the original value */
+       fmt->fmt.pix.priv = priv;
        return 0;
 }
 
-static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
-                           struct v4l2_format *fmt)
+static int vidioc_s_fmt_vid_cap(struct file *file, void *_priv,
+                               struct v4l2_format *fmt)
 {
        struct gspca_dev *gspca_dev = video_drvdata(file);
+       u32 priv = fmt->fmt.pix.priv;
        int mode;
 
        if (vb2_is_busy(&gspca_dev->queue))
@@ -1106,6 +1106,8 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
                gspca_dev->pixfmt = fmt->fmt.pix;
        else
                gspca_dev->pixfmt = gspca_dev->cam.cam_mode[mode];
+       /* some drivers use priv internally, so keep the original value */
+       fmt->fmt.pix.priv = priv;
        return 0;
 }
 
index 533f7f064a4437e2805e4b8d32aa6cfe0c2c061a..329ec808959276dc0e224ae3cb044173cdb4437b 100644 (file)
@@ -751,7 +751,6 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
        f->fmt.pix.bytesperline = f->fmt.pix.width * (vc->fmt->depth >> 3);
        f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
        f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
-       f->fmt.pix.priv = 0;
        return 0;
 }
 
@@ -803,7 +802,6 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
        f->fmt.pix.bytesperline = (f->fmt.pix.width * fmt->depth) >> 3;
        f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
        f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
-       f->fmt.pix.priv = 0;
        dprintk(vc->dev, 50, "%s: set width %d height %d field %d\n", __func__,
                f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.field);
        return 0;
index 203329cadbc4df4b44158d712af50be76dc7a192..0335e69b70abe7100b3fe8afb393b1a091fa7aef 100644 (file)
@@ -253,7 +253,6 @@ static int uvc_v4l2_try_format(struct uvc_streaming *stream,
        fmt->fmt.pix.bytesperline = uvc_v4l2_get_bytesperline(format, frame);
        fmt->fmt.pix.sizeimage = probe->dwMaxVideoFrameSize;
        fmt->fmt.pix.colorspace = format->colorspace;
-       fmt->fmt.pix.priv = 0;
 
        if (uvc_format != NULL)
                *uvc_format = format;
@@ -290,7 +289,6 @@ static int uvc_v4l2_get_format(struct uvc_streaming *stream,
        fmt->fmt.pix.bytesperline = uvc_v4l2_get_bytesperline(format, frame);
        fmt->fmt.pix.sizeimage = stream->ctrl.dwMaxVideoFrameSize;
        fmt->fmt.pix.colorspace = format->colorspace;
-       fmt->fmt.pix.priv = 0;
 
 done:
        mutex_unlock(&stream->mutex);