aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>2014-05-27 08:41:05 -0400
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-07-17 11:44:47 -0400
commitd52e23813672c3c72f92e7b39c7408d4b9a40a96 (patch)
treea06c0a574588b3222a6795064c2ca4da37ceea91
parentb04ef7c075e8806fa18bc849e32d6a3163150cec (diff)
[media] v4l: Support extending the v4l2_pix_format structure
The v4l2_pix_format structure has no reserved field. It is embedded in the v4l2_framebuffer structure which has no reserved fields either, and in the v4l2_format structure which has reserved fields that were not previously required to be zeroed out by applications. To allow extending v4l2_pix_format, inline it in the v4l2_framebuffer structure, and use the priv field as a magic value to indicate that the application has set all v4l2_pix_format extended fields and zeroed all reserved fields following the v4l2_pix_format field in the v4l2_format structure. The availability of this API extension is reported to userspace through the new V4L2_CAP_EXT_PIX_FORMAT capability flag. Just checking that the priv field is still set to the magic value at [GS]_FMT return wouldn't be enough, as older kernels don't zero the priv field on return. To simplify the internal API towards drivers zero the extended fields and set the priv field to the magic value for applications not aware of the extensions. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
-rw-r--r--Documentation/DocBook/media/Makefile2
-rw-r--r--Documentation/DocBook/media/v4l/pixfmt.xml25
-rw-r--r--Documentation/DocBook/media/v4l/v4l2.xml8
-rw-r--r--Documentation/DocBook/media/v4l/vidioc-g-fbuf.xml12
-rw-r--r--Documentation/DocBook/media/v4l/vidioc-querycap.xml6
-rw-r--r--drivers/media/parport/bw-qcam.c2
-rw-r--r--drivers/media/pci/cx18/cx18-ioctl.c1
-rw-r--r--drivers/media/pci/cx25821/cx25821-video.c3
-rw-r--r--drivers/media/pci/ivtv/ivtv-ioctl.c3
-rw-r--r--drivers/media/pci/meye/meye.c2
-rw-r--r--drivers/media/pci/saa7134/saa7134-empress.c3
-rw-r--r--drivers/media/pci/saa7134/saa7134-video.c2
-rw-r--r--drivers/media/pci/sta2x11/sta2x11_vip.c1
-rw-r--r--drivers/media/platform/coda.c2
-rw-r--r--drivers/media/platform/davinci/vpif_display.c1
-rw-r--r--drivers/media/platform/mem2mem_testdev.c1
-rw-r--r--drivers/media/platform/omap/omap_vout.c2
-rw-r--r--drivers/media/platform/sh_veu.c2
-rw-r--r--drivers/media/platform/vino.c5
-rw-r--r--drivers/media/platform/vivi.c1
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-417.c2
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-video.c2
-rw-r--r--drivers/media/usb/gspca/gspca.c8
-rw-r--r--drivers/media/usb/hdpvr/hdpvr-video.c1
-rw-r--r--drivers/media/usb/stkwebcam/stk-webcam.c2
-rw-r--r--drivers/media/usb/tlg2300/pd-video.c1
-rw-r--r--drivers/media/usb/tm6000/tm6000-video.c2
-rw-r--r--drivers/media/usb/zr364xx/zr364xx.c3
-rw-r--r--drivers/media/v4l2-core/v4l2-compat-ioctl32.c19
-rw-r--r--drivers/media/v4l2-core/v4l2-ioctl.c65
-rw-r--r--include/uapi/linux/videodev2.h15
31 files changed, 134 insertions, 70 deletions
diff --git a/Documentation/DocBook/media/Makefile b/Documentation/DocBook/media/Makefile
index 639e74857968..df2962d9e11e 100644
--- a/Documentation/DocBook/media/Makefile
+++ b/Documentation/DocBook/media/Makefile
@@ -174,7 +174,7 @@ FILENAME = \
174DOCUMENTED = \ 174DOCUMENTED = \
175 -e "s/\(enum *\)v4l2_mpeg_cx2341x_video_\([a-z]*_spatial_filter_type\)/\1<link linkend=\"\2\">v4l2_mpeg_cx2341x_video_\2<\/link>/g" \ 175 -e "s/\(enum *\)v4l2_mpeg_cx2341x_video_\([a-z]*_spatial_filter_type\)/\1<link linkend=\"\2\">v4l2_mpeg_cx2341x_video_\2<\/link>/g" \
176 -e "s/\(\(enum\|struct\) *\)\(v4l2_[a-zA-Z0-9_]*\)/\1<link linkend=\"\3\">\3<\/link>/g" \ 176 -e "s/\(\(enum\|struct\) *\)\(v4l2_[a-zA-Z0-9_]*\)/\1<link linkend=\"\3\">\3<\/link>/g" \
177 -e "s/\(V4L2_PIX_FMT_[A-Z0-9_]\+\) /<link linkend=\"\1\">\1<\/link> /g" \ 177 -e "s/\(V4L2_PIX_FMT_[A-Z0-9_]\+\)\(\s\+v4l2_fourcc\)/<link linkend=\"\1\">\1<\/link>\2/g" \
178 -e ":a;s/\(linkend=\".*\)_\(.*\">\)/\1-\2/;ta" \ 178 -e ":a;s/\(linkend=\".*\)_\(.*\">\)/\1-\2/;ta" \
179 -e "s/v4l2\-mpeg\-vbi\-ITV0/v4l2-mpeg-vbi-itv0-1/g" 179 -e "s/v4l2\-mpeg\-vbi\-ITV0/v4l2-mpeg-vbi-itv0-1/g"
180 180
diff --git a/Documentation/DocBook/media/v4l/pixfmt.xml b/Documentation/DocBook/media/v4l/pixfmt.xml
index 91dcbc84f3f8..bb36b3829cf9 100644
--- a/Documentation/DocBook/media/v4l/pixfmt.xml
+++ b/Documentation/DocBook/media/v4l/pixfmt.xml
@@ -112,9 +112,28 @@ see <xref linkend="colorspaces" />.</entry>
112 <row> 112 <row>
113 <entry>__u32</entry> 113 <entry>__u32</entry>
114 <entry><structfield>priv</structfield></entry> 114 <entry><structfield>priv</structfield></entry>
115 <entry>Reserved for custom (driver defined) additional 115 <entry><para>This field indicates whether the remaining fields of the
116information about formats. When not used drivers and applications must 116<structname>v4l2_pix_format</structname> structure, also called the extended
117set this field to zero.</entry> 117fields, are valid. When set to <constant>V4L2_PIX_FMT_PRIV_MAGIC</constant>, it
118indicates that the extended fields have been correctly initialized. When set to
119any other value it indicates that the extended fields contain undefined values.
120</para>
121<para>Applications that wish to use the pixel format extended fields must first
122ensure that the feature is supported by querying the device for the
123<link linkend="querycap"><constant>V4L2_CAP_EXT_PIX_FORMAT</constant></link>
124capability. If the capability isn't set the pixel format extended fields are not
125supported and using the extended fields will lead to undefined results.</para>
126<para>To use the extended fields, applications must set the
127<structfield>priv</structfield> field to
128<constant>V4L2_PIX_FMT_PRIV_MAGIC</constant>, initialize all the extended fields
129and zero the unused bytes of the <structname>v4l2_format</structname>
130<structfield>raw_data</structfield> field.</para>
131<para>When the <structfield>priv</structfield> field isn't set to
132<constant>V4L2_PIX_FMT_PRIV_MAGIC</constant> drivers must act as if all the
133extended fields were set to zero. On return drivers must set the
134<structfield>priv</structfield> field to
135<constant>V4L2_PIX_FMT_PRIV_MAGIC</constant> and all the extended fields to
136applicable values.</para></entry>
118 </row> 137 </row>
119 </tbody> 138 </tbody>
120 </tgroup> 139 </tgroup>
diff --git a/Documentation/DocBook/media/v4l/v4l2.xml b/Documentation/DocBook/media/v4l/v4l2.xml
index b445161b912c..d0a48bebfa52 100644
--- a/Documentation/DocBook/media/v4l/v4l2.xml
+++ b/Documentation/DocBook/media/v4l/v4l2.xml
@@ -152,6 +152,14 @@ structs, ioctls) must be noted in more detail in the history chapter
152applications. --> 152applications. -->
153 153
154 <revision> 154 <revision>
155 <revnumber>3.16</revnumber>
156 <date>2014-05-27</date>
157 <authorinitials>lp</authorinitials>
158 <revremark>Extended &v4l2-pix-format;.
159 </revremark>
160 </revision>
161
162 <revision>
155 <revnumber>3.15</revnumber> 163 <revnumber>3.15</revnumber>
156 <date>2014-02-03</date> 164 <date>2014-02-03</date>
157 <authorinitials>hv, ap</authorinitials> 165 <authorinitials>hv, ap</authorinitials>
diff --git a/Documentation/DocBook/media/v4l/vidioc-g-fbuf.xml b/Documentation/DocBook/media/v4l/vidioc-g-fbuf.xml
index 7c63815e7afd..20460730b02c 100644
--- a/Documentation/DocBook/media/v4l/vidioc-g-fbuf.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-g-fbuf.xml
@@ -152,13 +152,10 @@ a valid base address, so applications can find the corresponding Linux
152framebuffer device (see <xref linkend="osd" />).</entry> 152framebuffer device (see <xref linkend="osd" />).</entry>
153 </row> 153 </row>
154 <row> 154 <row>
155 <entry>&v4l2-pix-format;</entry> 155 <entry>struct</entry>
156 <entry><structfield>fmt</structfield></entry> 156 <entry><structfield>fmt</structfield></entry>
157 <entry></entry> 157 <entry></entry>
158 <entry>Layout of the frame buffer. The 158 <entry>Layout of the frame buffer.</entry>
159<structname>v4l2_pix_format</structname> structure is defined in <xref
160linkend="pixfmt" />, for clarification the fields and acceptable values
161 are listed below:</entry>
162 </row> 159 </row>
163 <row> 160 <row>
164 <entry></entry> 161 <entry></entry>
@@ -276,9 +273,8 @@ see <xref linkend="colorspaces" />.</entry>
276 <entry></entry> 273 <entry></entry>
277 <entry>__u32</entry> 274 <entry>__u32</entry>
278 <entry><structfield>priv</structfield></entry> 275 <entry><structfield>priv</structfield></entry>
279 <entry>Reserved for additional information about custom 276 <entry>Reserved. Drivers and applications must set this field to
280(driver defined) formats. When not used drivers and applications must 277zero.</entry>
281set this field to zero.</entry>
282 </row> 278 </row>
283 </tbody> 279 </tbody>
284 </tgroup> 280 </tgroup>
diff --git a/Documentation/DocBook/media/v4l/vidioc-querycap.xml b/Documentation/DocBook/media/v4l/vidioc-querycap.xml
index 370d49d6fb64..d0c5e604f014 100644
--- a/Documentation/DocBook/media/v4l/vidioc-querycap.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-querycap.xml
@@ -302,6 +302,12 @@ modulator programming see
302<link linkend="sdr">SDR Capture</link> interface.</entry> 302<link linkend="sdr">SDR Capture</link> interface.</entry>
303 </row> 303 </row>
304 <row> 304 <row>
305 <entry><constant>V4L2_CAP_EXT_PIX_FORMAT</constant></entry>
306 <entry>0x00200000</entry>
307 <entry>The device supports the &v4l2-pix-format; extended
308fields.</entry>
309 </row>
310 <row>
305 <entry><constant>V4L2_CAP_READWRITE</constant></entry> 311 <entry><constant>V4L2_CAP_READWRITE</constant></entry>
306 <entry>0x01000000</entry> 312 <entry>0x01000000</entry>
307 <entry>The device supports the <link 313 <entry>The device supports the <link
diff --git a/drivers/media/parport/bw-qcam.c b/drivers/media/parport/bw-qcam.c
index 3c5dac4c1eab..67b9da1dc43f 100644
--- a/drivers/media/parport/bw-qcam.c
+++ b/drivers/media/parport/bw-qcam.c
@@ -759,7 +759,6 @@ static int qcam_g_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f
759 pix->sizeimage = pix->width * pix->height; 759 pix->sizeimage = pix->width * pix->height;
760 /* Just a guess */ 760 /* Just a guess */
761 pix->colorspace = V4L2_COLORSPACE_SRGB; 761 pix->colorspace = V4L2_COLORSPACE_SRGB;
762 pix->priv = 0;
763 return 0; 762 return 0;
764} 763}
765 764
@@ -785,7 +784,6 @@ static int qcam_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format
785 pix->sizeimage = pix->width * pix->height; 784 pix->sizeimage = pix->width * pix->height;
786 /* Just a guess */ 785 /* Just a guess */
787 pix->colorspace = V4L2_COLORSPACE_SRGB; 786 pix->colorspace = V4L2_COLORSPACE_SRGB;
788 pix->priv = 0;
789 return 0; 787 return 0;
790} 788}
791 789
diff --git a/drivers/media/pci/cx18/cx18-ioctl.c b/drivers/media/pci/cx18/cx18-ioctl.c
index fefb2cd35838..6f2b59042b73 100644
--- a/drivers/media/pci/cx18/cx18-ioctl.c
+++ b/drivers/media/pci/cx18/cx18-ioctl.c
@@ -156,7 +156,6 @@ static int cx18_g_fmt_vid_cap(struct file *file, void *fh,
156 pixfmt->height = cx->cxhdl.height; 156 pixfmt->height = cx->cxhdl.height;
157 pixfmt->colorspace = V4L2_COLORSPACE_SMPTE170M; 157 pixfmt->colorspace = V4L2_COLORSPACE_SMPTE170M;
158 pixfmt->field = V4L2_FIELD_INTERLACED; 158 pixfmt->field = V4L2_FIELD_INTERLACED;
159 pixfmt->priv = 0;
160 if (id->type == CX18_ENC_STREAM_TYPE_YUV) { 159 if (id->type == CX18_ENC_STREAM_TYPE_YUV) {
161 pixfmt->pixelformat = s->pixelformat; 160 pixfmt->pixelformat = s->pixelformat;
162 pixfmt->sizeimage = s->vb_bytes_per_frame; 161 pixfmt->sizeimage = s->vb_bytes_per_frame;
diff --git a/drivers/media/pci/cx25821/cx25821-video.c b/drivers/media/pci/cx25821/cx25821-video.c
index 8d2f1abeef77..3a419f134584 100644
--- a/drivers/media/pci/cx25821/cx25821-video.c
+++ b/drivers/media/pci/cx25821/cx25821-video.c
@@ -576,7 +576,6 @@ static int cx25821_vidioc_g_fmt_vid_cap(struct file *file, void *priv,
576 f->fmt.pix.bytesperline = (chan->width * chan->fmt->depth) >> 3; 576 f->fmt.pix.bytesperline = (chan->width * chan->fmt->depth) >> 3;
577 f->fmt.pix.sizeimage = chan->height * f->fmt.pix.bytesperline; 577 f->fmt.pix.sizeimage = chan->height * f->fmt.pix.bytesperline;
578 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; 578 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
579 f->fmt.pix.priv = 0;
580 579
581 return 0; 580 return 0;
582} 581}
@@ -615,7 +614,6 @@ static int cx25821_vidioc_try_fmt_vid_cap(struct file *file, void *priv,
615 f->fmt.pix.bytesperline = (f->fmt.pix.width * fmt->depth) >> 3; 614 f->fmt.pix.bytesperline = (f->fmt.pix.width * fmt->depth) >> 3;
616 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; 615 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
617 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; 616 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
618 f->fmt.pix.priv = 0;
619 617
620 return 0; 618 return 0;
621} 619}
@@ -867,7 +865,6 @@ static int cx25821_vidioc_try_fmt_vid_out(struct file *file, void *priv,
867 f->fmt.pix.bytesperline = (f->fmt.pix.width * fmt->depth) >> 3; 865 f->fmt.pix.bytesperline = (f->fmt.pix.width * fmt->depth) >> 3;
868 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; 866 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
869 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; 867 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
870 f->fmt.pix.priv = 0;
871 return 0; 868 return 0;
872} 869}
873 870
diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c b/drivers/media/pci/ivtv/ivtv-ioctl.c
index b3667a00db3a..3e0cb77d5930 100644
--- a/drivers/media/pci/ivtv/ivtv-ioctl.c
+++ b/drivers/media/pci/ivtv/ivtv-ioctl.c
@@ -351,7 +351,6 @@ static int ivtv_g_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f
351 pixfmt->height = itv->cxhdl.height; 351 pixfmt->height = itv->cxhdl.height;
352 pixfmt->colorspace = V4L2_COLORSPACE_SMPTE170M; 352 pixfmt->colorspace = V4L2_COLORSPACE_SMPTE170M;
353 pixfmt->field = V4L2_FIELD_INTERLACED; 353 pixfmt->field = V4L2_FIELD_INTERLACED;
354 pixfmt->priv = 0;
355 if (id->type == IVTV_ENC_STREAM_TYPE_YUV) { 354 if (id->type == IVTV_ENC_STREAM_TYPE_YUV) {
356 pixfmt->pixelformat = V4L2_PIX_FMT_HM12; 355 pixfmt->pixelformat = V4L2_PIX_FMT_HM12;
357 /* YUV size is (Y=(h*720) + UV=(h*(720/2))) */ 356 /* YUV size is (Y=(h*720) + UV=(h*(720/2))) */
@@ -418,7 +417,6 @@ static int ivtv_g_fmt_vid_out(struct file *file, void *fh, struct v4l2_format *f
418 pixfmt->height = itv->main_rect.height; 417 pixfmt->height = itv->main_rect.height;
419 pixfmt->colorspace = V4L2_COLORSPACE_SMPTE170M; 418 pixfmt->colorspace = V4L2_COLORSPACE_SMPTE170M;
420 pixfmt->field = V4L2_FIELD_INTERLACED; 419 pixfmt->field = V4L2_FIELD_INTERLACED;
421 pixfmt->priv = 0;
422 if (id->type == IVTV_DEC_STREAM_TYPE_YUV) { 420 if (id->type == IVTV_DEC_STREAM_TYPE_YUV) {
423 switch (itv->yuv_info.lace_mode & IVTV_YUV_MODE_MASK) { 421 switch (itv->yuv_info.lace_mode & IVTV_YUV_MODE_MASK) {
424 case IVTV_YUV_MODE_INTERLACED: 422 case IVTV_YUV_MODE_INTERLACED:
@@ -1384,7 +1382,6 @@ static int ivtv_g_fbuf(struct file *file, void *fh, struct v4l2_framebuffer *fb)
1384 fb->fmt.bytesperline = fb->fmt.width; 1382 fb->fmt.bytesperline = fb->fmt.width;
1385 fb->fmt.colorspace = V4L2_COLORSPACE_SMPTE170M; 1383 fb->fmt.colorspace = V4L2_COLORSPACE_SMPTE170M;
1386 fb->fmt.field = V4L2_FIELD_INTERLACED; 1384 fb->fmt.field = V4L2_FIELD_INTERLACED;
1387 fb->fmt.priv = 0;
1388 if (fb->fmt.pixelformat != V4L2_PIX_FMT_PAL8) 1385 if (fb->fmt.pixelformat != V4L2_PIX_FMT_PAL8)
1389 fb->fmt.bytesperline *= 2; 1386 fb->fmt.bytesperline *= 2;
1390 if (fb->fmt.pixelformat == V4L2_PIX_FMT_RGB32 || 1387 if (fb->fmt.pixelformat == V4L2_PIX_FMT_RGB32 ||
diff --git a/drivers/media/pci/meye/meye.c b/drivers/media/pci/meye/meye.c
index 1a77f8dfafa5..aeae54708811 100644
--- a/drivers/media/pci/meye/meye.c
+++ b/drivers/media/pci/meye/meye.c
@@ -1166,7 +1166,6 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *fh,
1166 f->fmt.pix.sizeimage = f->fmt.pix.height * 1166 f->fmt.pix.sizeimage = f->fmt.pix.height *
1167 f->fmt.pix.bytesperline; 1167 f->fmt.pix.bytesperline;
1168 f->fmt.pix.colorspace = 0; 1168 f->fmt.pix.colorspace = 0;
1169 f->fmt.pix.priv = 0;
1170 1169
1171 return 0; 1170 return 0;
1172} 1171}
@@ -1232,7 +1231,6 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *fh,
1232 f->fmt.pix.sizeimage = f->fmt.pix.height * 1231 f->fmt.pix.sizeimage = f->fmt.pix.height *
1233 f->fmt.pix.bytesperline; 1232 f->fmt.pix.bytesperline;
1234 f->fmt.pix.colorspace = 0; 1233 f->fmt.pix.colorspace = 0;
1235 f->fmt.pix.priv = 0;
1236 1234
1237 return 0; 1235 return 0;
1238} 1236}
diff --git a/drivers/media/pci/saa7134/saa7134-empress.c b/drivers/media/pci/saa7134/saa7134-empress.c
index 5526ed5444fb..ef39261c1f20 100644
--- a/drivers/media/pci/saa7134/saa7134-empress.c
+++ b/drivers/media/pci/saa7134/saa7134-empress.c
@@ -130,7 +130,6 @@ static int empress_g_fmt_vid_cap(struct file *file, void *priv,
130 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; 130 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
131 f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets; 131 f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets;
132 f->fmt.pix.bytesperline = 0; 132 f->fmt.pix.bytesperline = 0;
133 f->fmt.pix.priv = 0;
134 133
135 return 0; 134 return 0;
136} 135}
@@ -148,7 +147,6 @@ static int empress_s_fmt_vid_cap(struct file *file, void *priv,
148 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; 147 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
149 f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets; 148 f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets;
150 f->fmt.pix.bytesperline = 0; 149 f->fmt.pix.bytesperline = 0;
151 f->fmt.pix.priv = 0;
152 150
153 return 0; 151 return 0;
154} 152}
@@ -166,7 +164,6 @@ static int empress_try_fmt_vid_cap(struct file *file, void *priv,
166 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; 164 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
167 f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets; 165 f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets;
168 f->fmt.pix.bytesperline = 0; 166 f->fmt.pix.bytesperline = 0;
169 f->fmt.pix.priv = 0;
170 167
171 return 0; 168 return 0;
172} 169}
diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c
index d37599980768..0cfa2ca6a32a 100644
--- a/drivers/media/pci/saa7134/saa7134-video.c
+++ b/drivers/media/pci/saa7134/saa7134-video.c
@@ -1235,7 +1235,6 @@ static int saa7134_g_fmt_vid_cap(struct file *file, void *priv,
1235 f->fmt.pix.sizeimage = 1235 f->fmt.pix.sizeimage =
1236 f->fmt.pix.height * f->fmt.pix.bytesperline; 1236 f->fmt.pix.height * f->fmt.pix.bytesperline;
1237 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; 1237 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
1238 f->fmt.pix.priv = 0;
1239 return 0; 1238 return 0;
1240} 1239}
1241 1240
@@ -1315,7 +1314,6 @@ static int saa7134_try_fmt_vid_cap(struct file *file, void *priv,
1315 f->fmt.pix.sizeimage = 1314 f->fmt.pix.sizeimage =
1316 f->fmt.pix.height * f->fmt.pix.bytesperline; 1315 f->fmt.pix.height * f->fmt.pix.bytesperline;
1317 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; 1316 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
1318 f->fmt.pix.priv = 0;
1319 1317
1320 return 0; 1318 return 0;
1321} 1319}
diff --git a/drivers/media/pci/sta2x11/sta2x11_vip.c b/drivers/media/pci/sta2x11/sta2x11_vip.c
index f2d8c70d35f5..365bd21301ba 100644
--- a/drivers/media/pci/sta2x11/sta2x11_vip.c
+++ b/drivers/media/pci/sta2x11/sta2x11_vip.c
@@ -640,7 +640,6 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
640 f->fmt.pix.bytesperline = f->fmt.pix.width * 2; 640 f->fmt.pix.bytesperline = f->fmt.pix.width * 2;
641 f->fmt.pix.sizeimage = f->fmt.pix.width * 2 * f->fmt.pix.height; 641 f->fmt.pix.sizeimage = f->fmt.pix.width * 2 * f->fmt.pix.height;
642 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; 642 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
643 f->fmt.pix.priv = 0;
644 return 0; 643 return 0;
645} 644}
646 645
diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c
index b1783791d426..54886606ed68 100644
--- a/drivers/media/platform/coda.c
+++ b/drivers/media/platform/coda.c
@@ -613,8 +613,6 @@ static int coda_try_fmt(struct coda_ctx *ctx, struct coda_codec *codec,
613 BUG(); 613 BUG();
614 } 614 }
615 615
616 f->fmt.pix.priv = 0;
617
618 return 0; 616 return 0;
619} 617}
620 618
diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c
index 877b46e8b2e4..0bd6dcb13cbc 100644
--- a/drivers/media/platform/davinci/vpif_display.c
+++ b/drivers/media/platform/davinci/vpif_display.c
@@ -648,7 +648,6 @@ static int vpif_try_fmt_vid_out(struct file *file, void *priv,
648 pixfmt->width = common->fmt.fmt.pix.width; 648 pixfmt->width = common->fmt.fmt.pix.width;
649 pixfmt->height = common->fmt.fmt.pix.height; 649 pixfmt->height = common->fmt.fmt.pix.height;
650 pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height * 2; 650 pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height * 2;
651 pixfmt->priv = 0;
652 651
653 return 0; 652 return 0;
654} 653}
diff --git a/drivers/media/platform/mem2mem_testdev.c b/drivers/media/platform/mem2mem_testdev.c
index 0714070ed7fa..c1b03cfd6ded 100644
--- a/drivers/media/platform/mem2mem_testdev.c
+++ b/drivers/media/platform/mem2mem_testdev.c
@@ -532,7 +532,6 @@ static int vidioc_try_fmt(struct v4l2_format *f, struct m2mtest_fmt *fmt)
532 f->fmt.pix.bytesperline = (f->fmt.pix.width * fmt->depth) >> 3; 532 f->fmt.pix.bytesperline = (f->fmt.pix.width * fmt->depth) >> 3;
533 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; 533 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
534 f->fmt.pix.field = V4L2_FIELD_NONE; 534 f->fmt.pix.field = V4L2_FIELD_NONE;
535 f->fmt.pix.priv = 0;
536 535
537 return 0; 536 return 0;
538} 537}
diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
index 9a726eacb29b..2d177fa58471 100644
--- a/drivers/media/platform/omap/omap_vout.c
+++ b/drivers/media/platform/omap/omap_vout.c
@@ -165,7 +165,6 @@ static int omap_vout_try_format(struct v4l2_pix_format *pix)
165 165
166 pix->pixelformat = omap_formats[ifmt].pixelformat; 166 pix->pixelformat = omap_formats[ifmt].pixelformat;
167 pix->field = V4L2_FIELD_ANY; 167 pix->field = V4L2_FIELD_ANY;
168 pix->priv = 0;
169 168
170 switch (pix->pixelformat) { 169 switch (pix->pixelformat) {
171 case V4L2_PIX_FMT_YUYV: 170 case V4L2_PIX_FMT_YUYV:
@@ -1896,7 +1895,6 @@ static int __init omap_vout_setup_video_data(struct omap_vout_device *vout)
1896 pix->field = V4L2_FIELD_ANY; 1895 pix->field = V4L2_FIELD_ANY;
1897 pix->bytesperline = pix->width * 2; 1896 pix->bytesperline = pix->width * 2;
1898 pix->sizeimage = pix->bytesperline * pix->height; 1897 pix->sizeimage = pix->bytesperline * pix->height;
1899 pix->priv = 0;
1900 pix->colorspace = V4L2_COLORSPACE_JPEG; 1898 pix->colorspace = V4L2_COLORSPACE_JPEG;
1901 1899
1902 vout->bpp = RGB565_BPP; 1900 vout->bpp = RGB565_BPP;
diff --git a/drivers/media/platform/sh_veu.c b/drivers/media/platform/sh_veu.c
index 744e43b480bc..8dc279d4d561 100644
--- a/drivers/media/platform/sh_veu.c
+++ b/drivers/media/platform/sh_veu.c
@@ -425,7 +425,6 @@ static int sh_veu_g_fmt(struct sh_veu_file *veu_file, struct v4l2_format *f)
425 pix->bytesperline = vfmt->bytesperline; 425 pix->bytesperline = vfmt->bytesperline;
426 pix->sizeimage = vfmt->bytesperline * pix->height * 426 pix->sizeimage = vfmt->bytesperline * pix->height *
427 vfmt->fmt->depth / vfmt->fmt->ydepth; 427 vfmt->fmt->depth / vfmt->fmt->ydepth;
428 pix->priv = 0;
429 dev_dbg(veu->dev, "%s(): type: %d, size %u @ %ux%u, fmt %x\n", __func__, 428 dev_dbg(veu->dev, "%s(): type: %d, size %u @ %ux%u, fmt %x\n", __func__,
430 f->type, pix->sizeimage, pix->width, pix->height, pix->pixelformat); 429 f->type, pix->sizeimage, pix->width, pix->height, pix->pixelformat);
431 430
@@ -473,7 +472,6 @@ static int sh_veu_try_fmt(struct v4l2_format *f, const struct sh_veu_format *fmt
473 472
474 pix->pixelformat = fmt->fourcc; 473 pix->pixelformat = fmt->fourcc;
475 pix->colorspace = sh_veu_4cc2cspace(pix->pixelformat); 474 pix->colorspace = sh_veu_4cc2cspace(pix->pixelformat);
476 pix->priv = 0;
477 475
478 pr_debug("%s(): type: %d, size %u\n", __func__, f->type, pix->sizeimage); 476 pr_debug("%s(): type: %d, size %u\n", __func__, f->type, pix->sizeimage);
479 477
diff --git a/drivers/media/platform/vino.c b/drivers/media/platform/vino.c
index 470d35336119..91d44ea16f27 100644
--- a/drivers/media/platform/vino.c
+++ b/drivers/media/platform/vino.c
@@ -3147,7 +3147,6 @@ static int vino_try_fmt_vid_cap(struct file *file, void *__fh,
3147 pf->colorspace = 3147 pf->colorspace =
3148 vino_data_formats[tempvcs.data_format].colorspace; 3148 vino_data_formats[tempvcs.data_format].colorspace;
3149 3149
3150 pf->priv = 0;
3151 return 0; 3150 return 0;
3152} 3151}
3153 3152
@@ -3175,8 +3174,6 @@ static int vino_g_fmt_vid_cap(struct file *file, void *__fh,
3175 pf->colorspace = 3174 pf->colorspace =
3176 vino_data_formats[vcs->data_format].colorspace; 3175 vino_data_formats[vcs->data_format].colorspace;
3177 3176
3178 pf->priv = 0;
3179
3180 spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); 3177 spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
3181 return 0; 3178 return 0;
3182} 3179}
@@ -3219,8 +3216,6 @@ static int vino_s_fmt_vid_cap(struct file *file, void *__fh,
3219 pf->colorspace = 3216 pf->colorspace =
3220 vino_data_formats[vcs->data_format].colorspace; 3217 vino_data_formats[vcs->data_format].colorspace;
3221 3218
3222 pf->priv = 0;
3223
3224 spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); 3219 spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
3225 return 0; 3220 return 0;
3226} 3221}
diff --git a/drivers/media/platform/vivi.c b/drivers/media/platform/vivi.c
index 7542b5dd9910..80333714ffa7 100644
--- a/drivers/media/platform/vivi.c
+++ b/drivers/media/platform/vivi.c
@@ -1014,7 +1014,6 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
1014 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; 1014 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
1015 else 1015 else
1016 f->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB; 1016 f->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB;
1017 f->fmt.pix.priv = 0;
1018 return 0; 1017 return 0;
1019} 1018}
1020 1019
diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c b/drivers/media/usb/cx231xx/cx231xx-417.c
index f0400e260eb7..459bb0e98971 100644
--- a/drivers/media/usb/cx231xx/cx231xx-417.c
+++ b/drivers/media/usb/cx231xx/cx231xx-417.c
@@ -1563,7 +1563,6 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
1563 f->fmt.pix.width = dev->ts1.width; 1563 f->fmt.pix.width = dev->ts1.width;
1564 f->fmt.pix.height = dev->ts1.height; 1564 f->fmt.pix.height = dev->ts1.height;
1565 f->fmt.pix.field = V4L2_FIELD_INTERLACED; 1565 f->fmt.pix.field = V4L2_FIELD_INTERLACED;
1566 f->fmt.pix.priv = 0;
1567 dprintk(1, "VIDIOC_G_FMT: w: %d, h: %d\n", 1566 dprintk(1, "VIDIOC_G_FMT: w: %d, h: %d\n",
1568 dev->ts1.width, dev->ts1.height); 1567 dev->ts1.width, dev->ts1.height);
1569 dprintk(3, "exit vidioc_g_fmt_vid_cap()\n"); 1568 dprintk(3, "exit vidioc_g_fmt_vid_cap()\n");
@@ -1582,7 +1581,6 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
1582 f->fmt.pix.sizeimage = mpeglines * mpeglinesize; 1581 f->fmt.pix.sizeimage = mpeglines * mpeglinesize;
1583 f->fmt.pix.field = V4L2_FIELD_INTERLACED; 1582 f->fmt.pix.field = V4L2_FIELD_INTERLACED;
1584 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; 1583 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
1585 f->fmt.pix.priv = 0;
1586 dprintk(1, "VIDIOC_TRY_FMT: w: %d, h: %d\n", 1584 dprintk(1, "VIDIOC_TRY_FMT: w: %d, h: %d\n",
1587 dev->ts1.width, dev->ts1.height); 1585 dev->ts1.width, dev->ts1.height);
1588 dprintk(3, "exit vidioc_try_fmt_vid_cap()\n"); 1586 dprintk(3, "exit vidioc_try_fmt_vid_cap()\n");
diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c
index ae31ca2fc9a1..3b3ada6562ca 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -885,7 +885,6 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
885 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; 885 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
886 886
887 f->fmt.pix.field = V4L2_FIELD_INTERLACED; 887 f->fmt.pix.field = V4L2_FIELD_INTERLACED;
888 f->fmt.pix.priv = 0;
889 888
890 return 0; 889 return 0;
891} 890}
@@ -930,7 +929,6 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
930 f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * height; 929 f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * height;
931 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; 930 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
932 f->fmt.pix.field = V4L2_FIELD_INTERLACED; 931 f->fmt.pix.field = V4L2_FIELD_INTERLACED;
933 f->fmt.pix.priv = 0;
934 932
935 return 0; 933 return 0;
936} 934}
diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspca.c
index 42d223239206..e8cf23c91cef 100644
--- a/drivers/media/usb/gspca/gspca.c
+++ b/drivers/media/usb/gspca/gspca.c
@@ -1109,8 +1109,8 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
1109 struct gspca_dev *gspca_dev = video_drvdata(file); 1109 struct gspca_dev *gspca_dev = video_drvdata(file);
1110 1110
1111 fmt->fmt.pix = gspca_dev->pixfmt; 1111 fmt->fmt.pix = gspca_dev->pixfmt;
1112 /* some drivers use priv internally, zero it before giving it to 1112 /* some drivers use priv internally, zero it before giving it back to
1113 userspace */ 1113 the core */
1114 fmt->fmt.pix.priv = 0; 1114 fmt->fmt.pix.priv = 0;
1115 return 0; 1115 return 0;
1116} 1116}
@@ -1146,8 +1146,8 @@ static int try_fmt_vid_cap(struct gspca_dev *gspca_dev,
1146 fmt->fmt.pix.height = h; 1146 fmt->fmt.pix.height = h;
1147 gspca_dev->sd_desc->try_fmt(gspca_dev, fmt); 1147 gspca_dev->sd_desc->try_fmt(gspca_dev, fmt);
1148 } 1148 }
1149 /* some drivers use priv internally, zero it before giving it to 1149 /* some drivers use priv internally, zero it before giving it back to
1150 userspace */ 1150 the core */
1151 fmt->fmt.pix.priv = 0; 1151 fmt->fmt.pix.priv = 0;
1152 return mode; /* used when s_fmt */ 1152 return mode; /* used when s_fmt */
1153} 1153}
diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpvr/hdpvr-video.c
index dca4b65053aa..4b7653fd4b0b 100644
--- a/drivers/media/usb/hdpvr/hdpvr-video.c
+++ b/drivers/media/usb/hdpvr/hdpvr-video.c
@@ -1022,7 +1022,6 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *_fh,
1022 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; 1022 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
1023 f->fmt.pix.sizeimage = dev->bulk_in_size; 1023 f->fmt.pix.sizeimage = dev->bulk_in_size;
1024 f->fmt.pix.bytesperline = 0; 1024 f->fmt.pix.bytesperline = 0;
1025 f->fmt.pix.priv = 0;
1026 if (f->fmt.pix.width == 720) { 1025 if (f->fmt.pix.width == 720) {
1027 /* SDTV formats */ 1026 /* SDTV formats */
1028 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; 1027 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
diff --git a/drivers/media/usb/stkwebcam/stk-webcam.c b/drivers/media/usb/stkwebcam/stk-webcam.c
index d76860b6a0b8..3588dc38db87 100644
--- a/drivers/media/usb/stkwebcam/stk-webcam.c
+++ b/drivers/media/usb/stkwebcam/stk-webcam.c
@@ -923,7 +923,6 @@ static int stk_vidioc_g_fmt_vid_cap(struct file *filp,
923 pix_format->bytesperline = 2 * pix_format->width; 923 pix_format->bytesperline = 2 * pix_format->width;
924 pix_format->sizeimage = pix_format->bytesperline 924 pix_format->sizeimage = pix_format->bytesperline
925 * pix_format->height; 925 * pix_format->height;
926 pix_format->priv = 0;
927 return 0; 926 return 0;
928} 927}
929 928
@@ -967,7 +966,6 @@ static int stk_try_fmt_vid_cap(struct file *filp,
967 fmtd->fmt.pix.bytesperline = 2 * fmtd->fmt.pix.width; 966 fmtd->fmt.pix.bytesperline = 2 * fmtd->fmt.pix.width;
968 fmtd->fmt.pix.sizeimage = fmtd->fmt.pix.bytesperline 967 fmtd->fmt.pix.sizeimage = fmtd->fmt.pix.bytesperline
969 * fmtd->fmt.pix.height; 968 * fmtd->fmt.pix.height;
970 fmtd->fmt.pix.priv = 0;
971 return 0; 969 return 0;
972} 970}
973 971
diff --git a/drivers/media/usb/tlg2300/pd-video.c b/drivers/media/usb/tlg2300/pd-video.c
index 8df668d06552..8cd7f02fcf9f 100644
--- a/drivers/media/usb/tlg2300/pd-video.c
+++ b/drivers/media/usb/tlg2300/pd-video.c
@@ -1321,7 +1321,6 @@ static void init_video_context(struct running_context *context)
1321 .bytesperline = 720 * 2, 1321 .bytesperline = 720 * 2,
1322 .sizeimage = 720 * 576 * 2, 1322 .sizeimage = 720 * 576 * 2,
1323 .colorspace = V4L2_COLORSPACE_SMPTE170M, 1323 .colorspace = V4L2_COLORSPACE_SMPTE170M,
1324 .priv = 0
1325 }; 1324 };
1326} 1325}
1327 1326
diff --git a/drivers/media/usb/tm6000/tm6000-video.c b/drivers/media/usb/tm6000/tm6000-video.c
index 9bde0642ffd1..793577fc4633 100644
--- a/drivers/media/usb/tm6000/tm6000-video.c
+++ b/drivers/media/usb/tm6000/tm6000-video.c
@@ -918,7 +918,6 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
918 (f->fmt.pix.width * fh->fmt->depth) >> 3; 918 (f->fmt.pix.width * fh->fmt->depth) >> 3;
919 f->fmt.pix.sizeimage = 919 f->fmt.pix.sizeimage =
920 f->fmt.pix.height * f->fmt.pix.bytesperline; 920 f->fmt.pix.height * f->fmt.pix.bytesperline;
921 f->fmt.pix.priv = 0;
922 921
923 return 0; 922 return 0;
924} 923}
@@ -959,7 +958,6 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
959 f->fmt.pix.width &= ~0x01; 958 f->fmt.pix.width &= ~0x01;
960 959
961 f->fmt.pix.field = field; 960 f->fmt.pix.field = field;
962 f->fmt.pix.priv = 0;
963 961
964 f->fmt.pix.bytesperline = 962 f->fmt.pix.bytesperline =
965 (f->fmt.pix.width * fmt->depth) >> 3; 963 (f->fmt.pix.width * fmt->depth) >> 3;
diff --git a/drivers/media/usb/zr364xx/zr364xx.c b/drivers/media/usb/zr364xx/zr364xx.c
index 3b80579a82c5..5c006277b8b1 100644
--- a/drivers/media/usb/zr364xx/zr364xx.c
+++ b/drivers/media/usb/zr364xx/zr364xx.c
@@ -806,7 +806,6 @@ static int zr364xx_vidioc_try_fmt_vid_cap(struct file *file, void *priv,
806 f->fmt.pix.bytesperline = f->fmt.pix.width * 2; 806 f->fmt.pix.bytesperline = f->fmt.pix.width * 2;
807 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; 807 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
808 f->fmt.pix.colorspace = V4L2_COLORSPACE_JPEG; 808 f->fmt.pix.colorspace = V4L2_COLORSPACE_JPEG;
809 f->fmt.pix.priv = 0;
810 DBG("%s: V4L2_PIX_FMT_%s (%d) ok!\n", __func__, 809 DBG("%s: V4L2_PIX_FMT_%s (%d) ok!\n", __func__,
811 decode_fourcc(f->fmt.pix.pixelformat, pixelformat_name), 810 decode_fourcc(f->fmt.pix.pixelformat, pixelformat_name),
812 f->fmt.pix.field); 811 f->fmt.pix.field);
@@ -829,7 +828,6 @@ static int zr364xx_vidioc_g_fmt_vid_cap(struct file *file, void *priv,
829 f->fmt.pix.bytesperline = f->fmt.pix.width * 2; 828 f->fmt.pix.bytesperline = f->fmt.pix.width * 2;
830 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; 829 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
831 f->fmt.pix.colorspace = V4L2_COLORSPACE_JPEG; 830 f->fmt.pix.colorspace = V4L2_COLORSPACE_JPEG;
832 f->fmt.pix.priv = 0;
833 return 0; 831 return 0;
834} 832}
835 833
@@ -866,7 +864,6 @@ static int zr364xx_vidioc_s_fmt_vid_cap(struct file *file, void *priv,
866 f->fmt.pix.bytesperline = f->fmt.pix.width * 2; 864 f->fmt.pix.bytesperline = f->fmt.pix.width * 2;
867 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; 865 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
868 f->fmt.pix.colorspace = V4L2_COLORSPACE_JPEG; 866 f->fmt.pix.colorspace = V4L2_COLORSPACE_JPEG;
869 f->fmt.pix.priv = 0;
870 cam->vb_vidq.field = f->fmt.pix.field; 867 cam->vb_vidq.field = f->fmt.pix.field;
871 868
872 if (f->fmt.pix.width == 160 && f->fmt.pix.height == 120) 869 if (f->fmt.pix.width == 160 && f->fmt.pix.height == 120)
diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
index 7e2411c36419..cca6c2f76b3a 100644
--- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
+++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
@@ -540,7 +540,16 @@ struct v4l2_framebuffer32 {
540 __u32 capability; 540 __u32 capability;
541 __u32 flags; 541 __u32 flags;
542 compat_caddr_t base; 542 compat_caddr_t base;
543 struct v4l2_pix_format fmt; 543 struct {
544 __u32 width;
545 __u32 height;
546 __u32 pixelformat;
547 __u32 field;
548 __u32 bytesperline;
549 __u32 sizeimage;
550 __u32 colorspace;
551 __u32 priv;
552 } fmt;
544}; 553};
545 554
546static int get_v4l2_framebuffer32(struct v4l2_framebuffer *kp, struct v4l2_framebuffer32 __user *up) 555static int get_v4l2_framebuffer32(struct v4l2_framebuffer *kp, struct v4l2_framebuffer32 __user *up)
@@ -550,10 +559,10 @@ static int get_v4l2_framebuffer32(struct v4l2_framebuffer *kp, struct v4l2_frame
550 if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_framebuffer32)) || 559 if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_framebuffer32)) ||
551 get_user(tmp, &up->base) || 560 get_user(tmp, &up->base) ||
552 get_user(kp->capability, &up->capability) || 561 get_user(kp->capability, &up->capability) ||
553 get_user(kp->flags, &up->flags)) 562 get_user(kp->flags, &up->flags) ||
563 copy_from_user(&kp->fmt, &up->fmt, sizeof(up->fmt)))
554 return -EFAULT; 564 return -EFAULT;
555 kp->base = compat_ptr(tmp); 565 kp->base = compat_ptr(tmp);
556 get_v4l2_pix_format(&kp->fmt, &up->fmt);
557 return 0; 566 return 0;
558} 567}
559 568
@@ -564,9 +573,9 @@ static int put_v4l2_framebuffer32(struct v4l2_framebuffer *kp, struct v4l2_frame
564 if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_framebuffer32)) || 573 if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_framebuffer32)) ||
565 put_user(tmp, &up->base) || 574 put_user(tmp, &up->base) ||
566 put_user(kp->capability, &up->capability) || 575 put_user(kp->capability, &up->capability) ||
567 put_user(kp->flags, &up->flags)) 576 put_user(kp->flags, &up->flags) ||
577 copy_to_user(&up->fmt, &kp->fmt, sizeof(up->fmt)))
568 return -EFAULT; 578 return -EFAULT;
569 put_v4l2_pix_format(&kp->fmt, &up->fmt);
570 return 0; 579 return 0;
571} 580}
572 581
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 96bc117f66b2..2e630005676f 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -973,13 +973,48 @@ static int check_fmt(struct file *file, enum v4l2_buf_type type)
973 return -EINVAL; 973 return -EINVAL;
974} 974}
975 975
976static void v4l_sanitize_format(struct v4l2_format *fmt)
977{
978 unsigned int offset;
979
980 /*
981 * The v4l2_pix_format structure has been extended with fields that were
982 * not previously required to be set to zero by applications. The priv
983 * field, when set to a magic value, indicates the the extended fields
984 * are valid. Otherwise they will contain undefined values. To simplify
985 * the API towards drivers zero the extended fields and set the priv
986 * field to the magic value when the extended pixel format structure
987 * isn't used by applications.
988 */
989
990 if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE &&
991 fmt->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
992 return;
993
994 if (fmt->fmt.pix.priv == V4L2_PIX_FMT_PRIV_MAGIC)
995 return;
996
997 fmt->fmt.pix.priv = V4L2_PIX_FMT_PRIV_MAGIC;
998
999 offset = offsetof(struct v4l2_pix_format, priv)
1000 + sizeof(fmt->fmt.pix.priv);
1001 memset(((void *)&fmt->fmt.pix) + offset, 0,
1002 sizeof(fmt->fmt.pix) - offset);
1003}
1004
976static int v4l_querycap(const struct v4l2_ioctl_ops *ops, 1005static int v4l_querycap(const struct v4l2_ioctl_ops *ops,
977 struct file *file, void *fh, void *arg) 1006 struct file *file, void *fh, void *arg)
978{ 1007{
979 struct v4l2_capability *cap = (struct v4l2_capability *)arg; 1008 struct v4l2_capability *cap = (struct v4l2_capability *)arg;
1009 int ret;
980 1010
981 cap->version = LINUX_VERSION_CODE; 1011 cap->version = LINUX_VERSION_CODE;
982 return ops->vidioc_querycap(file, fh, cap); 1012
1013 ret = ops->vidioc_querycap(file, fh, cap);
1014
1015 cap->capabilities |= V4L2_CAP_EXT_PIX_FORMAT;
1016
1017 return ret;
983} 1018}
984 1019
985static int v4l_s_input(const struct v4l2_ioctl_ops *ops, 1020static int v4l_s_input(const struct v4l2_ioctl_ops *ops,
@@ -1103,12 +1138,17 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,
1103 bool is_sdr = vfd->vfl_type == VFL_TYPE_SDR; 1138 bool is_sdr = vfd->vfl_type == VFL_TYPE_SDR;
1104 bool is_rx = vfd->vfl_dir != VFL_DIR_TX; 1139 bool is_rx = vfd->vfl_dir != VFL_DIR_TX;
1105 bool is_tx = vfd->vfl_dir != VFL_DIR_RX; 1140 bool is_tx = vfd->vfl_dir != VFL_DIR_RX;
1141 int ret;
1142
1143 p->fmt.pix.priv = V4L2_PIX_FMT_PRIV_MAGIC;
1106 1144
1107 switch (p->type) { 1145 switch (p->type) {
1108 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 1146 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
1109 if (unlikely(!is_rx || !is_vid || !ops->vidioc_g_fmt_vid_cap)) 1147 if (unlikely(!is_rx || !is_vid || !ops->vidioc_g_fmt_vid_cap))
1110 break; 1148 break;
1111 return ops->vidioc_g_fmt_vid_cap(file, fh, arg); 1149 ret = ops->vidioc_g_fmt_vid_cap(file, fh, arg);
1150 p->fmt.pix.priv = V4L2_PIX_FMT_PRIV_MAGIC;
1151 return ret;
1112 case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: 1152 case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
1113 if (unlikely(!is_rx || !is_vid || !ops->vidioc_g_fmt_vid_cap_mplane)) 1153 if (unlikely(!is_rx || !is_vid || !ops->vidioc_g_fmt_vid_cap_mplane))
1114 break; 1154 break;
@@ -1128,7 +1168,9 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,
1128 case V4L2_BUF_TYPE_VIDEO_OUTPUT: 1168 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
1129 if (unlikely(!is_tx || !is_vid || !ops->vidioc_g_fmt_vid_out)) 1169 if (unlikely(!is_tx || !is_vid || !ops->vidioc_g_fmt_vid_out))
1130 break; 1170 break;
1131 return ops->vidioc_g_fmt_vid_out(file, fh, arg); 1171 ret = ops->vidioc_g_fmt_vid_out(file, fh, arg);
1172 p->fmt.pix.priv = V4L2_PIX_FMT_PRIV_MAGIC;
1173 return ret;
1132 case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: 1174 case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
1133 if (unlikely(!is_tx || !is_vid || !ops->vidioc_g_fmt_vid_out_mplane)) 1175 if (unlikely(!is_tx || !is_vid || !ops->vidioc_g_fmt_vid_out_mplane))
1134 break; 1176 break;
@@ -1163,6 +1205,8 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops,
1163 bool is_rx = vfd->vfl_dir != VFL_DIR_TX; 1205 bool is_rx = vfd->vfl_dir != VFL_DIR_TX;
1164 bool is_tx = vfd->vfl_dir != VFL_DIR_RX; 1206 bool is_tx = vfd->vfl_dir != VFL_DIR_RX;
1165 1207
1208 v4l_sanitize_format(p);
1209
1166 switch (p->type) { 1210 switch (p->type) {
1167 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 1211 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
1168 if (unlikely(!is_rx || !is_vid || !ops->vidioc_s_fmt_vid_cap)) 1212 if (unlikely(!is_rx || !is_vid || !ops->vidioc_s_fmt_vid_cap))
@@ -1233,6 +1277,8 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops,
1233 bool is_rx = vfd->vfl_dir != VFL_DIR_TX; 1277 bool is_rx = vfd->vfl_dir != VFL_DIR_TX;
1234 bool is_tx = vfd->vfl_dir != VFL_DIR_RX; 1278 bool is_tx = vfd->vfl_dir != VFL_DIR_RX;
1235 1279
1280 v4l_sanitize_format(p);
1281
1236 switch (p->type) { 1282 switch (p->type) {
1237 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 1283 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
1238 if (unlikely(!is_rx || !is_vid || !ops->vidioc_try_fmt_vid_cap)) 1284 if (unlikely(!is_rx || !is_vid || !ops->vidioc_try_fmt_vid_cap))
@@ -1516,7 +1562,18 @@ static int v4l_create_bufs(const struct v4l2_ioctl_ops *ops,
1516 struct v4l2_create_buffers *create = arg; 1562 struct v4l2_create_buffers *create = arg;
1517 int ret = check_fmt(file, create->format.type); 1563 int ret = check_fmt(file, create->format.type);
1518 1564
1519 return ret ? ret : ops->vidioc_create_bufs(file, fh, create); 1565 if (ret)
1566 return ret;
1567
1568 v4l_sanitize_format(&create->format);
1569
1570 ret = ops->vidioc_create_bufs(file, fh, create);
1571
1572 if (create->format.type == V4L2_BUF_TYPE_VIDEO_CAPTURE ||
1573 create->format.type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
1574 create->format.fmt.pix.priv = V4L2_PIX_FMT_PRIV_MAGIC;
1575
1576 return ret;
1520} 1577}
1521 1578
1522static int v4l_prepare_buf(const struct v4l2_ioctl_ops *ops, 1579static int v4l_prepare_buf(const struct v4l2_ioctl_ops *ops,
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index a498d8b58679..eb3bdd33816b 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -268,6 +268,7 @@ struct v4l2_capability {
268#define V4L2_CAP_MODULATOR 0x00080000 /* has a modulator */ 268#define V4L2_CAP_MODULATOR 0x00080000 /* has a modulator */
269 269
270#define V4L2_CAP_SDR_CAPTURE 0x00100000 /* Is a SDR capture device */ 270#define V4L2_CAP_SDR_CAPTURE 0x00100000 /* Is a SDR capture device */
271#define V4L2_CAP_EXT_PIX_FORMAT 0x00200000 /* Supports the extended pixel format */
271 272
272#define V4L2_CAP_READWRITE 0x01000000 /* read/write systemcalls */ 273#define V4L2_CAP_READWRITE 0x01000000 /* read/write systemcalls */
273#define V4L2_CAP_ASYNCIO 0x02000000 /* async I/O */ 274#define V4L2_CAP_ASYNCIO 0x02000000 /* async I/O */
@@ -448,6 +449,9 @@ struct v4l2_pix_format {
448#define V4L2_SDR_FMT_CU8 v4l2_fourcc('C', 'U', '0', '8') /* IQ u8 */ 449#define V4L2_SDR_FMT_CU8 v4l2_fourcc('C', 'U', '0', '8') /* IQ u8 */
449#define V4L2_SDR_FMT_CU16LE v4l2_fourcc('C', 'U', '1', '6') /* IQ u16le */ 450#define V4L2_SDR_FMT_CU16LE v4l2_fourcc('C', 'U', '1', '6') /* IQ u16le */
450 451
452/* priv field value to indicates that subsequent fields are valid. */
453#define V4L2_PIX_FMT_PRIV_MAGIC 0xfeedcafe
454
451/* 455/*
452 * F O R M A T E N U M E R A T I O N 456 * F O R M A T E N U M E R A T I O N
453 */ 457 */
@@ -752,7 +756,16 @@ struct v4l2_framebuffer {
752/* FIXME: in theory we should pass something like PCI device + memory 756/* FIXME: in theory we should pass something like PCI device + memory
753 * region + offset instead of some physical address */ 757 * region + offset instead of some physical address */
754 void *base; 758 void *base;
755 struct v4l2_pix_format fmt; 759 struct {
760 __u32 width;
761 __u32 height;
762 __u32 pixelformat;
763 __u32 field; /* enum v4l2_field */
764 __u32 bytesperline; /* for padding, zero if unused */
765 __u32 sizeimage;
766 __u32 colorspace; /* enum v4l2_colorspace */
767 __u32 priv; /* reserved field, set to 0 */
768 } fmt;
756}; 769};
757/* Flags for the 'capability' field. Read only */ 770/* Flags for the 'capability' field. Read only */
758#define V4L2_FBUF_CAP_EXTERNOVERLAY 0x0001 771#define V4L2_FBUF_CAP_EXTERNOVERLAY 0x0001