aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/videodev2.h
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@iki.fi>2012-05-10 01:02:07 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-05-14 07:09:02 -0400
commit6016af82eafcb6e086a8f2a2197b46029a843d68 (patch)
treea8133e0651a8e0d5d33fbce904471a9c42127b51 /include/linux/videodev2.h
parent121b3ddbe4ad17df77cb7284239be0a63d9a66bd (diff)
[media] v4l2: use __u32 rather than enums in ioctl() structs
V4L2 uses the enum type in IOCTL arguments in IOCTLs that were defined until the use of enum was considered less than ideal. Recently Rémi Denis-Courmont brought up the issue by proposing a patch to convert the enums to unsigned: <URL:http://www.spinics.net/lists/linux-media/msg46167.html> This sparked a long discussion where another solution to the issue was proposed: two sets of IOCTL structures, one with __u32 and the other with enums, and conversion code between the two: <URL:http://www.spinics.net/lists/linux-media/msg47168.html> Both approaches implement a complete solution that resolves the problem. The first one is simple but requires assuming enums and __u32 are the same in size (so we won't break the ABI) while the second one is more complex and less clean but does not require making that assumption. The issue boils down to whether enums are fundamentally different from __u32 or not, and can the former be substituted by the latter. During the discussion it was concluded that the __u32 has the same size as enums on all archs Linux is supported: it has not been shown that replacing those enums in IOCTL arguments would break neither source or binary compatibility. If no such reason is found, just replacing the enums with __u32s is the way to go. This is what this patch does. This patch is slightly different from Remi's first RFC (link above): it uses __u32 instead of unsigned and also changes the arguments of VIDIOC_G_PRIORITY and VIDIOC_S_PRIORITY. Signed-off-by: Rémi Denis-Courmont <remi@remlab.net> Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'include/linux/videodev2.h')
-rw-r--r--include/linux/videodev2.h64
1 files changed, 33 insertions, 31 deletions
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 5a09ac3f7683..ace8ac000b9b 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -292,10 +292,10 @@ struct v4l2_pix_format {
292 __u32 width; 292 __u32 width;
293 __u32 height; 293 __u32 height;
294 __u32 pixelformat; 294 __u32 pixelformat;
295 enum v4l2_field field; 295 __u32 field; /* enum v4l2_field */
296 __u32 bytesperline; /* for padding, zero if unused */ 296 __u32 bytesperline; /* for padding, zero if unused */
297 __u32 sizeimage; 297 __u32 sizeimage;
298 enum v4l2_colorspace colorspace; 298 __u32 colorspace; /* enum v4l2_colorspace */
299 __u32 priv; /* private data, depends on pixelformat */ 299 __u32 priv; /* private data, depends on pixelformat */
300}; 300};
301 301
@@ -432,7 +432,7 @@ struct v4l2_pix_format {
432 */ 432 */
433struct v4l2_fmtdesc { 433struct v4l2_fmtdesc {
434 __u32 index; /* Format number */ 434 __u32 index; /* Format number */
435 enum v4l2_buf_type type; /* buffer type */ 435 __u32 type; /* enum v4l2_buf_type */
436 __u32 flags; 436 __u32 flags;
437 __u8 description[32]; /* Description string */ 437 __u8 description[32]; /* Description string */
438 __u32 pixelformat; /* Format fourcc */ 438 __u32 pixelformat; /* Format fourcc */
@@ -573,8 +573,8 @@ struct v4l2_jpegcompression {
573 */ 573 */
574struct v4l2_requestbuffers { 574struct v4l2_requestbuffers {
575 __u32 count; 575 __u32 count;
576 enum v4l2_buf_type type; 576 __u32 type; /* enum v4l2_buf_type */
577 enum v4l2_memory memory; 577 __u32 memory; /* enum v4l2_memory */
578 __u32 reserved[2]; 578 __u32 reserved[2];
579}; 579};
580 580
@@ -610,15 +610,17 @@ struct v4l2_plane {
610/** 610/**
611 * struct v4l2_buffer - video buffer info 611 * struct v4l2_buffer - video buffer info
612 * @index: id number of the buffer 612 * @index: id number of the buffer
613 * @type: buffer type (type == *_MPLANE for multiplanar buffers) 613 * @type: enum v4l2_buf_type; buffer type (type == *_MPLANE for
614 * multiplanar buffers);
614 * @bytesused: number of bytes occupied by data in the buffer (payload); 615 * @bytesused: number of bytes occupied by data in the buffer (payload);
615 * unused (set to 0) for multiplanar buffers 616 * unused (set to 0) for multiplanar buffers
616 * @flags: buffer informational flags 617 * @flags: buffer informational flags
617 * @field: field order of the image in the buffer 618 * @field: enum v4l2_field; field order of the image in the buffer
618 * @timestamp: frame timestamp 619 * @timestamp: frame timestamp
619 * @timecode: frame timecode 620 * @timecode: frame timecode
620 * @sequence: sequence count of this frame 621 * @sequence: sequence count of this frame
621 * @memory: the method, in which the actual video data is passed 622 * @memory: enum v4l2_memory; the method, in which the actual video data is
623 * passed
622 * @offset: for non-multiplanar buffers with memory == V4L2_MEMORY_MMAP; 624 * @offset: for non-multiplanar buffers with memory == V4L2_MEMORY_MMAP;
623 * offset from the start of the device memory for this plane, 625 * offset from the start of the device memory for this plane,
624 * (or a "cookie" that should be passed to mmap() as offset) 626 * (or a "cookie" that should be passed to mmap() as offset)
@@ -636,16 +638,16 @@ struct v4l2_plane {
636 */ 638 */
637struct v4l2_buffer { 639struct v4l2_buffer {
638 __u32 index; 640 __u32 index;
639 enum v4l2_buf_type type; 641 __u32 type;
640 __u32 bytesused; 642 __u32 bytesused;
641 __u32 flags; 643 __u32 flags;
642 enum v4l2_field field; 644 __u32 field;
643 struct timeval timestamp; 645 struct timeval timestamp;
644 struct v4l2_timecode timecode; 646 struct v4l2_timecode timecode;
645 __u32 sequence; 647 __u32 sequence;
646 648
647 /* memory location */ 649 /* memory location */
648 enum v4l2_memory memory; 650 __u32 memory;
649 union { 651 union {
650 __u32 offset; 652 __u32 offset;
651 unsigned long userptr; 653 unsigned long userptr;
@@ -708,7 +710,7 @@ struct v4l2_clip {
708 710
709struct v4l2_window { 711struct v4l2_window {
710 struct v4l2_rect w; 712 struct v4l2_rect w;
711 enum v4l2_field field; 713 __u32 field; /* enum v4l2_field */
712 __u32 chromakey; 714 __u32 chromakey;
713 struct v4l2_clip __user *clips; 715 struct v4l2_clip __user *clips;
714 __u32 clipcount; 716 __u32 clipcount;
@@ -745,14 +747,14 @@ struct v4l2_outputparm {
745 * I N P U T I M A G E C R O P P I N G 747 * I N P U T I M A G E C R O P P I N G
746 */ 748 */
747struct v4l2_cropcap { 749struct v4l2_cropcap {
748 enum v4l2_buf_type type; 750 __u32 type; /* enum v4l2_buf_type */
749 struct v4l2_rect bounds; 751 struct v4l2_rect bounds;
750 struct v4l2_rect defrect; 752 struct v4l2_rect defrect;
751 struct v4l2_fract pixelaspect; 753 struct v4l2_fract pixelaspect;
752}; 754};
753 755
754struct v4l2_crop { 756struct v4l2_crop {
755 enum v4l2_buf_type type; 757 __u32 type; /* enum v4l2_buf_type */
756 struct v4l2_rect c; 758 struct v4l2_rect c;
757}; 759};
758 760
@@ -1040,7 +1042,7 @@ struct v4l2_input {
1040 __u8 name[32]; /* Label */ 1042 __u8 name[32]; /* Label */
1041 __u32 type; /* Type of input */ 1043 __u32 type; /* Type of input */
1042 __u32 audioset; /* Associated audios (bitfield) */ 1044 __u32 audioset; /* Associated audios (bitfield) */
1043 __u32 tuner; /* Associated tuner */ 1045 __u32 tuner; /* enum v4l2_tuner_type */
1044 v4l2_std_id std; 1046 v4l2_std_id std;
1045 __u32 status; 1047 __u32 status;
1046 __u32 capabilities; 1048 __u32 capabilities;
@@ -1157,7 +1159,7 @@ enum v4l2_ctrl_type {
1157/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */ 1159/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */
1158struct v4l2_queryctrl { 1160struct v4l2_queryctrl {
1159 __u32 id; 1161 __u32 id;
1160 enum v4l2_ctrl_type type; 1162 __u32 type; /* enum v4l2_ctrl_type */
1161 __u8 name[32]; /* Whatever */ 1163 __u8 name[32]; /* Whatever */
1162 __s32 minimum; /* Note signedness */ 1164 __s32 minimum; /* Note signedness */
1163 __s32 maximum; 1165 __s32 maximum;
@@ -1792,7 +1794,7 @@ enum v4l2_jpeg_chroma_subsampling {
1792struct v4l2_tuner { 1794struct v4l2_tuner {
1793 __u32 index; 1795 __u32 index;
1794 __u8 name[32]; 1796 __u8 name[32];
1795 enum v4l2_tuner_type type; 1797 __u32 type; /* enum v4l2_tuner_type */
1796 __u32 capability; 1798 __u32 capability;
1797 __u32 rangelow; 1799 __u32 rangelow;
1798 __u32 rangehigh; 1800 __u32 rangehigh;
@@ -1842,14 +1844,14 @@ struct v4l2_modulator {
1842 1844
1843struct v4l2_frequency { 1845struct v4l2_frequency {
1844 __u32 tuner; 1846 __u32 tuner;
1845 enum v4l2_tuner_type type; 1847 __u32 type; /* enum v4l2_tuner_type */
1846 __u32 frequency; 1848 __u32 frequency;
1847 __u32 reserved[8]; 1849 __u32 reserved[8];
1848}; 1850};
1849 1851
1850struct v4l2_hw_freq_seek { 1852struct v4l2_hw_freq_seek {
1851 __u32 tuner; 1853 __u32 tuner;
1852 enum v4l2_tuner_type type; 1854 __u32 type; /* enum v4l2_tuner_type */
1853 __u32 seek_upward; 1855 __u32 seek_upward;
1854 __u32 wrap_around; 1856 __u32 wrap_around;
1855 __u32 spacing; 1857 __u32 spacing;
@@ -2060,7 +2062,7 @@ struct v4l2_sliced_vbi_cap {
2060 (equals frame lines 313-336 for 625 line video 2062 (equals frame lines 313-336 for 625 line video
2061 standards, 263-286 for 525 line standards) */ 2063 standards, 263-286 for 525 line standards) */
2062 __u16 service_lines[2][24]; 2064 __u16 service_lines[2][24];
2063 enum v4l2_buf_type type; 2065 __u32 type; /* enum v4l2_buf_type */
2064 __u32 reserved[3]; /* must be 0 */ 2066 __u32 reserved[3]; /* must be 0 */
2065}; 2067};
2066 2068
@@ -2141,8 +2143,8 @@ struct v4l2_plane_pix_format {
2141 * @width: image width in pixels 2143 * @width: image width in pixels
2142 * @height: image height in pixels 2144 * @height: image height in pixels
2143 * @pixelformat: little endian four character code (fourcc) 2145 * @pixelformat: little endian four character code (fourcc)
2144 * @field: field order (for interlaced video) 2146 * @field: enum v4l2_field; field order (for interlaced video)
2145 * @colorspace: supplemental to pixelformat 2147 * @colorspace: enum v4l2_colorspace; supplemental to pixelformat
2146 * @plane_fmt: per-plane information 2148 * @plane_fmt: per-plane information
2147 * @num_planes: number of planes for this format 2149 * @num_planes: number of planes for this format
2148 */ 2150 */
@@ -2150,8 +2152,8 @@ struct v4l2_pix_format_mplane {
2150 __u32 width; 2152 __u32 width;
2151 __u32 height; 2153 __u32 height;
2152 __u32 pixelformat; 2154 __u32 pixelformat;
2153 enum v4l2_field field; 2155 __u32 field;
2154 enum v4l2_colorspace colorspace; 2156 __u32 colorspace;
2155 2157
2156 struct v4l2_plane_pix_format plane_fmt[VIDEO_MAX_PLANES]; 2158 struct v4l2_plane_pix_format plane_fmt[VIDEO_MAX_PLANES];
2157 __u8 num_planes; 2159 __u8 num_planes;
@@ -2160,7 +2162,7 @@ struct v4l2_pix_format_mplane {
2160 2162
2161/** 2163/**
2162 * struct v4l2_format - stream data format 2164 * struct v4l2_format - stream data format
2163 * @type: type of the data stream 2165 * @type: enum v4l2_buf_type; type of the data stream
2164 * @pix: definition of an image format 2166 * @pix: definition of an image format
2165 * @pix_mp: definition of a multiplanar image format 2167 * @pix_mp: definition of a multiplanar image format
2166 * @win: definition of an overlaid image 2168 * @win: definition of an overlaid image
@@ -2169,7 +2171,7 @@ struct v4l2_pix_format_mplane {
2169 * @raw_data: placeholder for future extensions and custom formats 2171 * @raw_data: placeholder for future extensions and custom formats
2170 */ 2172 */
2171struct v4l2_format { 2173struct v4l2_format {
2172 enum v4l2_buf_type type; 2174 __u32 type;
2173 union { 2175 union {
2174 struct v4l2_pix_format pix; /* V4L2_BUF_TYPE_VIDEO_CAPTURE */ 2176 struct v4l2_pix_format pix; /* V4L2_BUF_TYPE_VIDEO_CAPTURE */
2175 struct v4l2_pix_format_mplane pix_mp; /* V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE */ 2177 struct v4l2_pix_format_mplane pix_mp; /* V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE */
@@ -2183,7 +2185,7 @@ struct v4l2_format {
2183/* Stream type-dependent parameters 2185/* Stream type-dependent parameters
2184 */ 2186 */
2185struct v4l2_streamparm { 2187struct v4l2_streamparm {
2186 enum v4l2_buf_type type; 2188 __u32 type; /* enum v4l2_buf_type */
2187 union { 2189 union {
2188 struct v4l2_captureparm capture; 2190 struct v4l2_captureparm capture;
2189 struct v4l2_outputparm output; 2191 struct v4l2_outputparm output;
@@ -2296,14 +2298,14 @@ struct v4l2_dbg_chip_ident {
2296 * @index: on return, index of the first created buffer 2298 * @index: on return, index of the first created buffer
2297 * @count: entry: number of requested buffers, 2299 * @count: entry: number of requested buffers,
2298 * return: number of created buffers 2300 * return: number of created buffers
2299 * @memory: buffer memory type 2301 * @memory: enum v4l2_memory; buffer memory type
2300 * @format: frame format, for which buffers are requested 2302 * @format: frame format, for which buffers are requested
2301 * @reserved: future extensions 2303 * @reserved: future extensions
2302 */ 2304 */
2303struct v4l2_create_buffers { 2305struct v4l2_create_buffers {
2304 __u32 index; 2306 __u32 index;
2305 __u32 count; 2307 __u32 count;
2306 enum v4l2_memory memory; 2308 __u32 memory;
2307 struct v4l2_format format; 2309 struct v4l2_format format;
2308 __u32 reserved[8]; 2310 __u32 reserved[8];
2309}; 2311};
@@ -2360,8 +2362,8 @@ struct v4l2_create_buffers {
2360#define VIDIOC_TRY_FMT _IOWR('V', 64, struct v4l2_format) 2362#define VIDIOC_TRY_FMT _IOWR('V', 64, struct v4l2_format)
2361#define VIDIOC_ENUMAUDIO _IOWR('V', 65, struct v4l2_audio) 2363#define VIDIOC_ENUMAUDIO _IOWR('V', 65, struct v4l2_audio)
2362#define VIDIOC_ENUMAUDOUT _IOWR('V', 66, struct v4l2_audioout) 2364#define VIDIOC_ENUMAUDOUT _IOWR('V', 66, struct v4l2_audioout)
2363#define VIDIOC_G_PRIORITY _IOR('V', 67, enum v4l2_priority) 2365#define VIDIOC_G_PRIORITY _IOR('V', 67, __u32) /* enum v4l2_priority */
2364#define VIDIOC_S_PRIORITY _IOW('V', 68, enum v4l2_priority) 2366#define VIDIOC_S_PRIORITY _IOW('V', 68, __u32) /* enum v4l2_priority */
2365#define VIDIOC_G_SLICED_VBI_CAP _IOWR('V', 69, struct v4l2_sliced_vbi_cap) 2367#define VIDIOC_G_SLICED_VBI_CAP _IOWR('V', 69, struct v4l2_sliced_vbi_cap)
2366#define VIDIOC_LOG_STATUS _IO('V', 70) 2368#define VIDIOC_LOG_STATUS _IO('V', 70)
2367#define VIDIOC_G_EXT_CTRLS _IOWR('V', 71, struct v4l2_ext_controls) 2369#define VIDIOC_G_EXT_CTRLS _IOWR('V', 71, struct v4l2_ext_controls)