|
|
|
[PATCH] [RFC] videodev2.h: ARM's old ABI support on EABI kernels | |
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] | |
Hi guys,
I am working for Nokia on an ARM based platform (Nokia 770 and stuff), and we're running a v4l2 camera driver.
This machine is running a 2.6.16 kernel, with ARM's EABI enabled. For those unfamiliar with ARM different ABIs, you can have a look at:
http://www.arm.com/products/DevTools/ABI.html
ARM's EABI defines sizeof(enum) as 1 byte, and an EABI kernel is supposed to be able to support old ABI userspace calls.
The current videodev2.h defines a bunch of enum, structures containing enums, and ioctl codes depending directly or indirectly on the size of enum.
This is problematic for us, in the particular case of running old ABI userspace code on top of an EABI kernel. If the userspace app calls for example the VIDIOC_G_PRIORITY ioctl, it won't work since the kernel ioctl code and the userspace one won't match.
And even if our production software uses EABI exclusively, we still want people to be able to use their old ABI binaries on top of it.
I know my main argument here is mainly about supporting our corner case platform, but I also think that using enums in a struct in a kernel<->userspace API may not be a good idea. Enum size is not guaranted to be constant across kernel boundaries.
So, I tried to come up with the less intrusive patch as possible for videodev2.h. I simply modified the structures definition so that enums are replaced by u32. Alignment and both kernel and userspace compatibility should be kept safe that way.
Here goes the patch. I would really appreciate your comments on it.
Signed-off-by: Samuel Ortiz <samuel.ortiz@xxxxxxxxx>
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 6f6c697..60b6a2d 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -265,10 +265,10 @@ struct v4l2_pix_format
__u32 width;
__u32 height;
__u32 pixelformat;
- enum v4l2_field field;
+ __u32 field;
__u32 bytesperline; /* for padding, zero if unused */
__u32 sizeimage;
- enum v4l2_colorspace colorspace;
+ __u32 colorspace;
__u32 priv; /* private data, depends on pixelformat */
};
@@ -323,7 +323,7 @@ struct v4l2_pix_format
struct v4l2_fmtdesc
{
__u32 index; /* Format number */
- enum v4l2_buf_type type; /* buffer type */
+ __u32 type; /* buffer type */
__u32 flags;
__u8 description[32]; /* Description string */
__u32 pixelformat; /* Format fourcc */
@@ -379,7 +379,7 @@ enum v4l2_bitrate_mode {
};
struct v4l2_bitrate {
/* rates are specified in kbit/sec */
- enum v4l2_bitrate_mode mode;
+ __u32 mode;
__u32 min;
__u32 target; /* use this one for CBR */
__u32 max;
@@ -411,7 +411,7 @@ enum v4l2_mpeg_aspectratio {
struct v4l2_mpeg_compression {
/* general */
- enum v4l2_mpeg_streamtype st_type;
+ __u32 st_type;
struct v4l2_bitrate st_bitrate;
/* transport streams */
@@ -425,15 +425,15 @@ struct v4l2_mpeg_compression {
__u16 reserved_1; /* align */
/* audio */
- enum v4l2_mpeg_audiotype au_type;
+ __u32 au_type;
struct v4l2_bitrate au_bitrate;
__u32 au_sample_rate;
__u8 au_pesid;
__u8 reserved_2[3]; /* align */
/* video */
- enum v4l2_mpeg_videotype vi_type;
- enum v4l2_mpeg_aspectratio vi_aspect_ratio;
+ __u32 vi_type;
+ __u32 vi_aspect_ratio;
struct v4l2_bitrate vi_bitrate;
__u32 vi_frame_rate;
__u16 vi_frames_per_gop;
@@ -487,24 +487,24 @@ struct v4l2_jpegcompression
struct v4l2_requestbuffers
{
__u32 count;
- enum v4l2_buf_type type;
- enum v4l2_memory memory;
+ __u32 type;
+ __u32 memory;
__u32 reserved[2];
};
struct v4l2_buffer
{
__u32 index;
- enum v4l2_buf_type type;
+ __u32 type;
__u32 bytesused;
__u32 flags;
- enum v4l2_field field;
+ __u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
/* memory location */
- enum v4l2_memory memory;
+ __u32 memory;
union {
__u32 offset;
unsigned long userptr;
@@ -555,7 +555,7 @@ struct v4l2_clip
struct v4l2_window
{
struct v4l2_rect w;
- enum v4l2_field field;
+ __u32 field;
__u32 chromakey;
struct v4l2_clip __user *clips;
__u32 clipcount;
@@ -594,14 +594,14 @@ struct v4l2_outputparm
*/
struct v4l2_cropcap {
- enum v4l2_buf_type type;
+ __u32 type;
struct v4l2_rect bounds;
struct v4l2_rect defrect;
struct v4l2_fract pixelaspect;
};
struct v4l2_crop {
- enum v4l2_buf_type type;
+ __u32 type;
struct v4l2_rect c;
};
@@ -766,7 +766,7 @@ struct v4l2_control
struct v4l2_queryctrl
{
__u32 id;
- enum v4l2_ctrl_type type;
+ __u32 type;
__u8 name[32]; /* Whatever */
__s32 minimum; /* Note signedness */
__s32 maximum;
@@ -827,7 +827,7 @@ struct v4l2_tuner
{
__u32 index;
__u8 name[32];
- enum v4l2_tuner_type type;
+ __u32 type;
__u32 capability;
__u32 rangelow;
__u32 rangehigh;
@@ -874,7 +874,7 @@ struct v4l2_modulator
struct v4l2_frequency
{
__u32 tuner;
- enum v4l2_tuner_type type;
+ __u32 type;
__u32 frequency;
__u32 reserved[8];
};
@@ -987,7 +987,7 @@ struct v4l2_sliced_vbi_data
*/
struct v4l2_format
{
- enum v4l2_buf_type type;
+ __u32 type;
union
{
struct v4l2_pix_format pix; // V4L2_BUF_TYPE_VIDEO_CAPTURE
@@ -1005,7 +1005,7 @@ struct v4l2_format
*/
struct v4l2_streamparm
{
- enum v4l2_buf_type type;
+ __u32 type;
union
{
struct v4l2_captureparm capture;
@@ -1070,8 +1070,8 @@ struct v4l2_streamparm
#define VIDIOC_TRY_FMT _IOWR ('V', 64, struct v4l2_format)
#define VIDIOC_ENUMAUDIO _IOWR ('V', 65, struct v4l2_audio)
#define VIDIOC_ENUMAUDOUT _IOWR ('V', 66, struct v4l2_audioout)
-#define VIDIOC_G_PRIORITY _IOR ('V', 67, enum v4l2_priority)
-#define VIDIOC_S_PRIORITY _IOW ('V', 68, enum v4l2_priority)
+#define VIDIOC_G_PRIORITY _IOR ('V', 67, int)
+#define VIDIOC_S_PRIORITY _IOW ('V', 68, int)
#if 1
#define VIDIOC_G_SLICED_VBI_CAP _IOR ('V', 69, struct v4l2_sliced_vbi_cap)
#endif
--
Unsubscribe mailto:video4linux-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
[Linux Media] [Older V4L] [Linux DVB] [Video Disk Recorder] [Linux Kernel] [Asterisk] [Photo] [DCCP] [Netdev] [Xorg] [Util Linux NG] [Xfree86] [Free Photo Albums] [Fedora Users] [Fedora Women] [ALSA Users] [ALSA Devel] [SSH] [DVB Maintainers] [Linux USB] [Yosemite Information]
![]() |
![]() |