Skip to content

Commit 5f70881

Browse files
pinchartlMauro Carvalho Chehab
authored andcommitted
[media] uvcvideo: Make the API public
Move the public API definitions to include/linux/uvcvideo.h and bump the version number to 1.1.0. Compatibility with the old API is kept, application can still be compiled against the private header and will not break. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
1 parent f411f10 commit 5f70881

5 files changed

Lines changed: 108 additions & 45 deletions

File tree

‎Documentation/ioctl/ioctl-number.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ Code Seq#(hex) Include File Comments
166166
'T' all arch/x86/include/asm/ioctls.h conflict!
167167
'T' C0-DF linux/if_tun.h conflict!
168168
'U' all sound/asound.h conflict!
169-
'U' 00-0F drivers/media/video/uvc/uvcvideo.h conflict!
170169
'U' 00-CF linux/uinput.h conflict!
171170
'U' 00-EF linux/usbdevice_fs.h
172171
'U' C0-CF drivers/bluetooth/hci_uart.h
@@ -259,6 +258,7 @@ Code Seq#(hex) Include File Comments
259258
't' 80-8F linux/isdn_ppp.h
260259
't' 90 linux/toshiba.h
261260
'u' 00-1F linux/smb_fs.h gone
261+
'u' 20-3F linux/uvcvideo.h USB video class host driver
262262
'v' 00-1F linux/ext2_fs.h conflict!
263263
'v' 00-1F linux/fs.h conflict!
264264
'v' 00-0F linux/sonypi.h conflict!

‎drivers/media/video/uvc/uvc_v4l2.c‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,24 +1036,25 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
10361036
* UVCIOC_CTRL_GET and UVCIOC_CTRL_SET are deprecated and scheduled for
10371037
* removal in 2.6.42.
10381038
*/
1039-
case UVCIOC_CTRL_ADD:
1039+
case __UVCIOC_CTRL_ADD:
10401040
uvc_v4l2_ioctl_warn();
10411041
return -EEXIST;
10421042

1043-
case UVCIOC_CTRL_MAP_OLD:
1043+
case __UVCIOC_CTRL_MAP_OLD:
10441044
uvc_v4l2_ioctl_warn();
1045+
case __UVCIOC_CTRL_MAP:
10451046
case UVCIOC_CTRL_MAP:
10461047
return uvc_ioctl_ctrl_map(chain, arg,
1047-
cmd == UVCIOC_CTRL_MAP_OLD);
1048+
cmd == __UVCIOC_CTRL_MAP_OLD);
10481049

1049-
case UVCIOC_CTRL_GET:
1050-
case UVCIOC_CTRL_SET:
1050+
case __UVCIOC_CTRL_GET:
1051+
case __UVCIOC_CTRL_SET:
10511052
{
10521053
struct uvc_xu_control *xctrl = arg;
10531054
struct uvc_xu_control_query xqry = {
10541055
.unit = xctrl->unit,
10551056
.selector = xctrl->selector,
1056-
.query = cmd == UVCIOC_CTRL_GET
1057+
.query = cmd == __UVCIOC_CTRL_GET
10571058
? UVC_GET_CUR : UVC_SET_CUR,
10581059
.size = xctrl->size,
10591060
.data = xctrl->data,

‎drivers/media/video/uvc/uvcvideo.h‎

Lines changed: 30 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44
#include <linux/kernel.h>
55
#include <linux/videodev2.h>
66

7+
#ifndef __KERNEL__
8+
/*
9+
* This header provides binary compatibility with applications using the private
10+
* uvcvideo API. This API is deprecated and will be removed in 2.6.42.
11+
* Applications should be recompiled against the public linux/uvcvideo.h header.
12+
*/
13+
#warn "The uvcvideo.h header is deprecated, use linux/uvcvideo.h instead."
14+
715
/*
816
* Dynamic controls
917
*/
@@ -17,23 +25,6 @@
1725
#define UVC_CTRL_DATA_TYPE_BITMASK 5
1826

1927
/* Control flags */
20-
#define UVC_CTRL_FLAG_SET_CUR (1 << 0)
21-
#define UVC_CTRL_FLAG_GET_CUR (1 << 1)
22-
#define UVC_CTRL_FLAG_GET_MIN (1 << 2)
23-
#define UVC_CTRL_FLAG_GET_MAX (1 << 3)
24-
#define UVC_CTRL_FLAG_GET_RES (1 << 4)
25-
#define UVC_CTRL_FLAG_GET_DEF (1 << 5)
26-
/* Control should be saved at suspend and restored at resume. */
27-
#define UVC_CTRL_FLAG_RESTORE (1 << 6)
28-
/* Control can be updated by the camera. */
29-
#define UVC_CTRL_FLAG_AUTO_UPDATE (1 << 7)
30-
31-
#define UVC_CTRL_FLAG_GET_RANGE \
32-
(UVC_CTRL_FLAG_GET_CUR | UVC_CTRL_FLAG_GET_MIN | \
33-
UVC_CTRL_FLAG_GET_MAX | UVC_CTRL_FLAG_GET_RES | \
34-
UVC_CTRL_FLAG_GET_DEF)
35-
36-
/* Old control flags, don't use */
3728
#define UVC_CONTROL_SET_CUR (1 << 0)
3829
#define UVC_CONTROL_GET_CUR (1 << 1)
3930
#define UVC_CONTROL_GET_MIN (1 << 2)
@@ -47,23 +38,11 @@
4738
UVC_CONTROL_GET_MAX | UVC_CONTROL_GET_RES | \
4839
UVC_CONTROL_GET_DEF)
4940

50-
struct uvc_xu_control_info {
51-
__u8 entity[16];
52-
__u8 index;
53-
__u8 selector;
54-
__u16 size;
55-
__u32 flags;
56-
};
57-
5841
struct uvc_menu_info {
5942
__u32 value;
6043
__u8 name[32];
6144
};
6245

63-
struct uvc_xu_control_mapping_old {
64-
__u8 reserved[64];
65-
};
66-
6746
struct uvc_xu_control_mapping {
6847
__u32 id;
6948
__u8 name[32];
@@ -81,32 +60,46 @@ struct uvc_xu_control_mapping {
8160
__u32 reserved[4];
8261
};
8362

84-
struct uvc_xu_control {
85-
__u8 unit;
63+
#endif
64+
65+
struct uvc_xu_control_info {
66+
__u8 entity[16];
67+
__u8 index;
8668
__u8 selector;
8769
__u16 size;
88-
__u8 __user *data;
70+
__u32 flags;
8971
};
9072

91-
struct uvc_xu_control_query {
73+
struct uvc_xu_control_mapping_old {
74+
__u8 reserved[64];
75+
};
76+
77+
struct uvc_xu_control {
9278
__u8 unit;
9379
__u8 selector;
94-
__u8 query;
9580
__u16 size;
9681
__u8 __user *data;
9782
};
9883

84+
#ifndef __KERNEL__
9985
#define UVCIOC_CTRL_ADD _IOW('U', 1, struct uvc_xu_control_info)
10086
#define UVCIOC_CTRL_MAP_OLD _IOWR('U', 2, struct uvc_xu_control_mapping_old)
10187
#define UVCIOC_CTRL_MAP _IOWR('U', 2, struct uvc_xu_control_mapping)
10288
#define UVCIOC_CTRL_GET _IOWR('U', 3, struct uvc_xu_control)
10389
#define UVCIOC_CTRL_SET _IOW('U', 4, struct uvc_xu_control)
104-
#define UVCIOC_CTRL_QUERY _IOWR('U', 5, struct uvc_xu_control_query)
90+
#else
91+
#define __UVCIOC_CTRL_ADD _IOW('U', 1, struct uvc_xu_control_info)
92+
#define __UVCIOC_CTRL_MAP_OLD _IOWR('U', 2, struct uvc_xu_control_mapping_old)
93+
#define __UVCIOC_CTRL_MAP _IOWR('U', 2, struct uvc_xu_control_mapping)
94+
#define __UVCIOC_CTRL_GET _IOWR('U', 3, struct uvc_xu_control)
95+
#define __UVCIOC_CTRL_SET _IOW('U', 4, struct uvc_xu_control)
96+
#endif
10597

10698
#ifdef __KERNEL__
10799

108100
#include <linux/poll.h>
109101
#include <linux/usb/video.h>
102+
#include <linux/uvcvideo.h>
110103

111104
/* --------------------------------------------------------------------------
112105
* UVC constants
@@ -184,8 +177,8 @@ struct uvc_xu_control_query {
184177
* Driver specific constants.
185178
*/
186179

187-
#define DRIVER_VERSION_NUMBER KERNEL_VERSION(1, 0, 0)
188-
#define DRIVER_VERSION "v1.0.0"
180+
#define DRIVER_VERSION_NUMBER KERNEL_VERSION(1, 1, 0)
181+
#define DRIVER_VERSION "v1.1.0"
189182

190183
/* Number of isochronous URBs. */
191184
#define UVC_URBS 5
@@ -682,4 +675,3 @@ void uvc_video_decode_isight(struct urb *urb, struct uvc_streaming *stream,
682675
#endif /* __KERNEL__ */
683676

684677
#endif
685-

‎include/linux/Kbuild‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ header-y += unistd.h
372372
header-y += usbdevice_fs.h
373373
header-y += utime.h
374374
header-y += utsname.h
375+
header-y += uvcvideo.h
375376
header-y += v4l2-mediabus.h
376377
header-y += v4l2-subdev.h
377378
header-y += veth.h

‎include/linux/uvcvideo.h‎

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#ifndef __LINUX_UVCVIDEO_H_
2+
#define __LINUX_UVCVIDEO_H_
3+
4+
#include <linux/ioctl.h>
5+
#include <linux/types.h>
6+
7+
/*
8+
* Dynamic controls
9+
*/
10+
11+
/* Data types for UVC control data */
12+
#define UVC_CTRL_DATA_TYPE_RAW 0
13+
#define UVC_CTRL_DATA_TYPE_SIGNED 1
14+
#define UVC_CTRL_DATA_TYPE_UNSIGNED 2
15+
#define UVC_CTRL_DATA_TYPE_BOOLEAN 3
16+
#define UVC_CTRL_DATA_TYPE_ENUM 4
17+
#define UVC_CTRL_DATA_TYPE_BITMASK 5
18+
19+
/* Control flags */
20+
#define UVC_CTRL_FLAG_SET_CUR (1 << 0)
21+
#define UVC_CTRL_FLAG_GET_CUR (1 << 1)
22+
#define UVC_CTRL_FLAG_GET_MIN (1 << 2)
23+
#define UVC_CTRL_FLAG_GET_MAX (1 << 3)
24+
#define UVC_CTRL_FLAG_GET_RES (1 << 4)
25+
#define UVC_CTRL_FLAG_GET_DEF (1 << 5)
26+
/* Control should be saved at suspend and restored at resume. */
27+
#define UVC_CTRL_FLAG_RESTORE (1 << 6)
28+
/* Control can be updated by the camera. */
29+
#define UVC_CTRL_FLAG_AUTO_UPDATE (1 << 7)
30+
31+
#define UVC_CTRL_FLAG_GET_RANGE \
32+
(UVC_CTRL_FLAG_GET_CUR | UVC_CTRL_FLAG_GET_MIN | \
33+
UVC_CTRL_FLAG_GET_MAX | UVC_CTRL_FLAG_GET_RES | \
34+
UVC_CTRL_FLAG_GET_DEF)
35+
36+
struct uvc_menu_info {
37+
__u32 value;
38+
__u8 name[32];
39+
};
40+
41+
struct uvc_xu_control_mapping {
42+
__u32 id;
43+
__u8 name[32];
44+
__u8 entity[16];
45+
__u8 selector;
46+
47+
__u8 size;
48+
__u8 offset;
49+
__u32 v4l2_type;
50+
__u32 data_type;
51+
52+
struct uvc_menu_info __user *menu_info;
53+
__u32 menu_count;
54+
55+
__u32 reserved[4];
56+
};
57+
58+
struct uvc_xu_control_query {
59+
__u8 unit;
60+
__u8 selector;
61+
__u8 query;
62+
__u16 size;
63+
__u8 __user *data;
64+
};
65+
66+
#define UVCIOC_CTRL_MAP _IOWR('u', 0x20, struct uvc_xu_control_mapping)
67+
#define UVCIOC_CTRL_QUERY _IOWR('u', 0x21, struct uvc_xu_control_query)
68+
69+
#endif

0 commit comments

Comments
 (0)