diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2015-03-15 13:30:25 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-04-02 22:54:47 -0400 |
commit | cc7d2dfb75b3ac0f248801ceed65f69465eb0389 (patch) | |
tree | 91e777bc40f151634eb0570dd2d28adb67165fa7 | |
parent | 03c278f01d70ce168a24f85a08e11636df30f580 (diff) |
[media] v4l2_plane_pix_format: use __u32 bytesperline instead of __u16
While running v4l2-compliance tests on vivid I suddenly got errors due to
a call to vmalloc_user with size 0 from vb2.
Digging deeper into the cause I discovered that this was due to the fact that
struct v4l2_plane_pix_format defines bytesperline as a __u16 instead of a __u32.
The test I was running selected a format of 4 * 4096 by 4 * 2048 with a 32
bit pixelformat.
So bytesperline was 4 * 4 * 4096 = 65536, which becomes 0 in a __u16. And
bytesperline * height is suddenly 0 as well. While the vivid driver may be
a virtual driver, it is to be expected that this limit will be hit for real
hardware as well in the near future: 8k deep-color video will already reach
it.
The solution is to change the type to __u32. The only drivers besides vivid
that use the multiplanar API are little-endian ARM and SH platforms (exynos,
ti-vpe, vsp1), so this is safe.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
-rw-r--r-- | Documentation/DocBook/media/v4l/pixfmt.xml | 4 | ||||
-rw-r--r-- | drivers/media/platform/s5p-tv/mixer_video.c | 2 | ||||
-rw-r--r-- | include/uapi/linux/videodev2.h | 4 |
3 files changed, 5 insertions, 5 deletions
diff --git a/Documentation/DocBook/media/v4l/pixfmt.xml b/Documentation/DocBook/media/v4l/pixfmt.xml index 0a1528f3e891..fcde4e20205e 100644 --- a/Documentation/DocBook/media/v4l/pixfmt.xml +++ b/Documentation/DocBook/media/v4l/pixfmt.xml | |||
@@ -182,14 +182,14 @@ see <xref linkend="colorspaces" />.</entry> | |||
182 | </entry> | 182 | </entry> |
183 | </row> | 183 | </row> |
184 | <row> | 184 | <row> |
185 | <entry>__u16</entry> | 185 | <entry>__u32</entry> |
186 | <entry><structfield>bytesperline</structfield></entry> | 186 | <entry><structfield>bytesperline</structfield></entry> |
187 | <entry>Distance in bytes between the leftmost pixels in two adjacent | 187 | <entry>Distance in bytes between the leftmost pixels in two adjacent |
188 | lines. See &v4l2-pix-format;.</entry> | 188 | lines. See &v4l2-pix-format;.</entry> |
189 | </row> | 189 | </row> |
190 | <row> | 190 | <row> |
191 | <entry>__u16</entry> | 191 | <entry>__u16</entry> |
192 | <entry><structfield>reserved[7]</structfield></entry> | 192 | <entry><structfield>reserved[6]</structfield></entry> |
193 | <entry>Reserved for future extensions. Should be zeroed by the | 193 | <entry>Reserved for future extensions. Should be zeroed by the |
194 | application.</entry> | 194 | application.</entry> |
195 | </row> | 195 | </row> |
diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c index 72d4f2e1efc0..751f3b618337 100644 --- a/drivers/media/platform/s5p-tv/mixer_video.c +++ b/drivers/media/platform/s5p-tv/mixer_video.c | |||
@@ -287,7 +287,7 @@ static void mxr_mplane_fill(struct v4l2_plane_pix_format *planes, | |||
287 | u32 bl_width = divup(width, blk->width); | 287 | u32 bl_width = divup(width, blk->width); |
288 | u32 bl_height = divup(height, blk->height); | 288 | u32 bl_height = divup(height, blk->height); |
289 | u32 sizeimage = bl_width * bl_height * blk->size; | 289 | u32 sizeimage = bl_width * bl_height * blk->size; |
290 | u16 bytesperline = bl_width * blk->size / blk->height; | 290 | u32 bytesperline = bl_width * blk->size / blk->height; |
291 | 291 | ||
292 | plane->sizeimage += sizeimage; | 292 | plane->sizeimage += sizeimage; |
293 | plane->bytesperline = max(plane->bytesperline, bytesperline); | 293 | plane->bytesperline = max(plane->bytesperline, bytesperline); |
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 15b21e481246..47df18f36c4b 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h | |||
@@ -1842,8 +1842,8 @@ struct v4l2_mpeg_vbi_fmt_ivtv { | |||
1842 | */ | 1842 | */ |
1843 | struct v4l2_plane_pix_format { | 1843 | struct v4l2_plane_pix_format { |
1844 | __u32 sizeimage; | 1844 | __u32 sizeimage; |
1845 | __u16 bytesperline; | 1845 | __u32 bytesperline; |
1846 | __u16 reserved[7]; | 1846 | __u16 reserved[6]; |
1847 | } __attribute__ ((packed)); | 1847 | } __attribute__ ((packed)); |
1848 | 1848 | ||
1849 | /** | 1849 | /** |