2008-06-30 15:04:50 -03:00
# ifndef _USB_VIDEO_H_
# define _USB_VIDEO_H_
2010-11-21 17:15:44 -03:00
# ifndef __KERNEL__
2011-07-30 16:19:49 -03:00
# error "The uvcvideo.h header is deprecated, use linux / uvcvideo.h instead."
# endif /* __KERNEL__ */
2008-06-30 15:04:50 -03:00
2011-07-30 16:19:49 -03:00
# include <linux/kernel.h>
2008-06-30 15:04:50 -03:00
# include <linux/poll.h>
2010-01-21 05:39:52 -03:00
# include <linux/usb.h>
2009-06-26 12:15:38 -03:00
# include <linux/usb/video.h>
2010-11-21 17:15:44 -03:00
# include <linux/uvcvideo.h>
2011-07-30 16:19:49 -03:00
# include <linux/videodev2.h>
2010-01-21 05:39:47 -03:00
# include <media/media-device.h>
# include <media/v4l2-device.h>
2012-04-08 12:59:51 -03:00
# include <media/v4l2-event.h>
# include <media/v4l2-fh.h>
2015-09-22 10:30:29 -03:00
# include <media/videobuf2-v4l2.h>
2008-06-30 15:04:50 -03:00
/* --------------------------------------------------------------------------
* UVC constants
*/
# define UVC_TERM_INPUT 0x0000
# define UVC_TERM_OUTPUT 0x8000
2009-11-25 12:00:22 -03:00
# define UVC_TERM_DIRECTION(term) ((term)->type & 0x8000)
2008-06-30 15:04:50 -03:00
# define UVC_ENTITY_TYPE(entity) ((entity)->type & 0x7fff)
# define UVC_ENTITY_IS_UNIT(entity) (((entity)->type & 0xff00) == 0)
# define UVC_ENTITY_IS_TERM(entity) (((entity)->type & 0xff00) != 0)
# define UVC_ENTITY_IS_ITERM(entity) \
2009-07-01 20:24:47 -03:00
( UVC_ENTITY_IS_TERM ( entity ) & & \
( ( entity ) - > type & 0x8000 ) = = UVC_TERM_INPUT )
2008-06-30 15:04:50 -03:00
# define UVC_ENTITY_IS_OTERM(entity) \
2009-07-01 20:24:47 -03:00
( UVC_ENTITY_IS_TERM ( entity ) & & \
( ( entity ) - > type & 0x8000 ) = = UVC_TERM_OUTPUT )
2008-06-30 15:04:50 -03:00
/* ------------------------------------------------------------------------
* GUIDs
*/
# define UVC_GUID_UVC_CAMERA \
{ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , \
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x01 }
# define UVC_GUID_UVC_OUTPUT \
{ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , \
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x02 }
# define UVC_GUID_UVC_MEDIA_TRANSPORT_INPUT \
{ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , \
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x03 }
# define UVC_GUID_UVC_PROCESSING \
{ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , \
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x01 , 0x01 }
# define UVC_GUID_UVC_SELECTOR \
{ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , \
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x01 , 0x02 }
# define UVC_GUID_FORMAT_MJPEG \
{ ' M ' , ' J ' , ' P ' , ' G ' , 0x00 , 0x00 , 0x10 , 0x00 , \
0x80 , 0x00 , 0x00 , 0xaa , 0x00 , 0x38 , 0x9b , 0x71 }
# define UVC_GUID_FORMAT_YUY2 \
{ ' Y ' , ' U ' , ' Y ' , ' 2 ' , 0x00 , 0x00 , 0x10 , 0x00 , \
0x80 , 0x00 , 0x00 , 0xaa , 0x00 , 0x38 , 0x9b , 0x71 }
2009-12-12 14:57:17 -03:00
# define UVC_GUID_FORMAT_YUY2_ISIGHT \
{ ' Y ' , ' U ' , ' Y ' , ' 2 ' , 0x00 , 0x00 , 0x10 , 0x00 , \
0x80 , 0x00 , 0x00 , 0x00 , 0x00 , 0x38 , 0x9b , 0x71 }
2008-06-30 15:04:50 -03:00
# define UVC_GUID_FORMAT_NV12 \
{ ' N ' , ' V ' , ' 1 ' , ' 2 ' , 0x00 , 0x00 , 0x10 , 0x00 , \
0x80 , 0x00 , 0x00 , 0xaa , 0x00 , 0x38 , 0x9b , 0x71 }
# define UVC_GUID_FORMAT_YV12 \
{ ' Y ' , ' V ' , ' 1 ' , ' 2 ' , 0x00 , 0x00 , 0x10 , 0x00 , \
0x80 , 0x00 , 0x00 , 0xaa , 0x00 , 0x38 , 0x9b , 0x71 }
# define UVC_GUID_FORMAT_I420 \
{ ' I ' , ' 4 ' , ' 2 ' , ' 0 ' , 0x00 , 0x00 , 0x10 , 0x00 , \
0x80 , 0x00 , 0x00 , 0xaa , 0x00 , 0x38 , 0x9b , 0x71 }
# define UVC_GUID_FORMAT_UYVY \
{ ' U ' , ' Y ' , ' V ' , ' Y ' , 0x00 , 0x00 , 0x10 , 0x00 , \
0x80 , 0x00 , 0x00 , 0xaa , 0x00 , 0x38 , 0x9b , 0x71 }
# define UVC_GUID_FORMAT_Y800 \
{ ' Y ' , ' 8 ' , ' 0 ' , ' 0 ' , 0x00 , 0x00 , 0x10 , 0x00 , \
2012-07-28 19:49:14 -03:00
0x80 , 0x00 , 0x00 , 0xaa , 0x00 , 0x38 , 0x9b , 0x71 }
# define UVC_GUID_FORMAT_Y8 \
{ ' Y ' , ' 8 ' , ' ' , ' ' , 0x00 , 0x00 , 0x10 , 0x00 , \
0x80 , 0x00 , 0x00 , 0xaa , 0x00 , 0x38 , 0x9b , 0x71 }
# define UVC_GUID_FORMAT_Y10 \
{ ' Y ' , ' 1 ' , ' 0 ' , ' ' , 0x00 , 0x00 , 0x10 , 0x00 , \
0x80 , 0x00 , 0x00 , 0xaa , 0x00 , 0x38 , 0x9b , 0x71 }
# define UVC_GUID_FORMAT_Y12 \
{ ' Y ' , ' 1 ' , ' 2 ' , ' ' , 0x00 , 0x00 , 0x10 , 0x00 , \
2008-06-30 15:04:50 -03:00
0x80 , 0x00 , 0x00 , 0xaa , 0x00 , 0x38 , 0x9b , 0x71 }
2010-04-12 10:41:22 -03:00
# define UVC_GUID_FORMAT_Y16 \
{ ' Y ' , ' 1 ' , ' 6 ' , ' ' , 0x00 , 0x00 , 0x10 , 0x00 , \
0x80 , 0x00 , 0x00 , 0xaa , 0x00 , 0x38 , 0x9b , 0x71 }
2008-06-30 15:04:50 -03:00
# define UVC_GUID_FORMAT_BY8 \
{ ' B ' , ' Y ' , ' 8 ' , ' ' , 0x00 , 0x00 , 0x10 , 0x00 , \
0x80 , 0x00 , 0x00 , 0xaa , 0x00 , 0x38 , 0x9b , 0x71 }
2014-02-20 04:12:51 -03:00
# define UVC_GUID_FORMAT_BA81 \
{ ' B ' , ' A ' , ' 8 ' , ' 1 ' , 0x00 , 0x00 , 0x10 , 0x00 , \
0x80 , 0x00 , 0x00 , 0xaa , 0x00 , 0x38 , 0x9b , 0x71 }
# define UVC_GUID_FORMAT_GBRG \
{ ' G ' , ' B ' , ' R ' , ' G ' , 0x00 , 0x00 , 0x10 , 0x00 , \
0x80 , 0x00 , 0x00 , 0xaa , 0x00 , 0x38 , 0x9b , 0x71 }
# define UVC_GUID_FORMAT_GRBG \
{ ' G ' , ' R ' , ' B ' , ' G ' , 0x00 , 0x00 , 0x10 , 0x00 , \
0x80 , 0x00 , 0x00 , 0xaa , 0x00 , 0x38 , 0x9b , 0x71 }
# define UVC_GUID_FORMAT_RGGB \
{ ' R ' , ' G ' , ' G ' , ' B ' , 0x00 , 0x00 , 0x10 , 0x00 , \
0x80 , 0x00 , 0x00 , 0xaa , 0x00 , 0x38 , 0x9b , 0x71 }
2016-11-15 03:33:10 -02:00
# define UVC_GUID_FORMAT_BG16 \
{ ' B ' , ' G ' , ' 1 ' , ' 6 ' , 0x00 , 0x00 , 0x10 , 0x00 , \
0x80 , 0x00 , 0x00 , 0xaa , 0x00 , 0x38 , 0x9b , 0x71 }
# define UVC_GUID_FORMAT_GB16 \
{ ' G ' , ' B ' , ' 1 ' , ' 6 ' , 0x00 , 0x00 , 0x10 , 0x00 , \
0x80 , 0x00 , 0x00 , 0xaa , 0x00 , 0x38 , 0x9b , 0x71 }
# define UVC_GUID_FORMAT_RG16 \
{ ' R ' , ' G ' , ' 1 ' , ' 6 ' , 0x00 , 0x00 , 0x10 , 0x00 , \
0x80 , 0x00 , 0x00 , 0xaa , 0x00 , 0x38 , 0x9b , 0x71 }
# define UVC_GUID_FORMAT_GR16 \
{ ' G ' , ' R ' , ' 1 ' , ' 6 ' , 0x00 , 0x00 , 0x10 , 0x00 , \
0x80 , 0x00 , 0x00 , 0xaa , 0x00 , 0x38 , 0x9b , 0x71 }
2011-03-06 08:32:04 -03:00
# define UVC_GUID_FORMAT_RGBP \
{ ' R ' , ' G ' , ' B ' , ' P ' , 0x00 , 0x00 , 0x10 , 0x00 , \
0x80 , 0x00 , 0x00 , 0xaa , 0x00 , 0x38 , 0x9b , 0x71 }
2014-12-08 15:57:58 -03:00
# define UVC_GUID_FORMAT_BGR3 \
{ 0x7d , 0xeb , 0x36 , 0xe4 , 0x4f , 0x52 , 0xce , 0x11 , \
0x9f , 0x53 , 0x00 , 0x20 , 0xaf , 0x0b , 0xa7 , 0x70 }
2011-05-11 09:56:20 -03:00
# define UVC_GUID_FORMAT_M420 \
{ ' M ' , ' 4 ' , ' 2 ' , ' 0 ' , 0x00 , 0x00 , 0x10 , 0x00 , \
0x80 , 0x00 , 0x00 , 0xaa , 0x00 , 0x38 , 0x9b , 0x71 }
2008-06-30 15:04:50 -03:00
2011-01-28 16:38:58 -03:00
# define UVC_GUID_FORMAT_H264 \
{ ' H ' , ' 2 ' , ' 6 ' , ' 4 ' , 0x00 , 0x00 , 0x10 , 0x00 , \
0x80 , 0x00 , 0x00 , 0xaa , 0x00 , 0x38 , 0x9b , 0x71 }
2016-02-03 15:08:52 -02:00
# define UVC_GUID_FORMAT_Y8I \
{ ' Y ' , ' 8 ' , ' I ' , ' ' , 0x00 , 0x00 , 0x10 , 0x00 , \
0x80 , 0x00 , 0x00 , 0xaa , 0x00 , 0x38 , 0x9b , 0x71 }
# define UVC_GUID_FORMAT_Y12I \
{ ' Y ' , ' 1 ' , ' 2 ' , ' I ' , 0x00 , 0x00 , 0x10 , 0x00 , \
0x80 , 0x00 , 0x00 , 0xaa , 0x00 , 0x38 , 0x9b , 0x71 }
# define UVC_GUID_FORMAT_Z16 \
{ ' Z ' , ' 1 ' , ' 6 ' , ' ' , 0x00 , 0x00 , 0x10 , 0x00 , \
0x80 , 0x00 , 0x00 , 0xaa , 0x00 , 0x38 , 0x9b , 0x71 }
# define UVC_GUID_FORMAT_RW10 \
{ ' R ' , ' W ' , ' 1 ' , ' 0 ' , 0x00 , 0x00 , 0x10 , 0x00 , \
0x80 , 0x00 , 0x00 , 0xaa , 0x00 , 0x38 , 0x9b , 0x71 }
2017-03-02 20:43:20 -03:00
# define UVC_GUID_FORMAT_INVZ \
{ ' I ' , ' N ' , ' V ' , ' Z ' , 0x90 , 0x2d , 0x58 , 0x4a , \
0x92 , 0x0b , 0x77 , 0x3f , 0x1f , 0x2c , 0x55 , 0x6b }
# define UVC_GUID_FORMAT_INZI \
{ ' I ' , ' N ' , ' Z ' , ' I ' , 0x66 , 0x1a , 0x42 , 0xa2 , \
0x90 , 0x65 , 0xd0 , 0x18 , 0x14 , 0xa8 , 0xef , 0x8a }
# define UVC_GUID_FORMAT_INVI \
{ ' I ' , ' N ' , ' V ' , ' I ' , 0xdb , 0x57 , 0x49 , 0x5e , \
0x8e , 0x3f , 0xf4 , 0x79 , 0x53 , 0x2b , 0x94 , 0x6f }
2011-01-28 16:38:58 -03:00
2008-06-30 15:04:50 -03:00
/* ------------------------------------------------------------------------
* Driver specific constants .
*/
2011-06-25 13:50:37 -03:00
# define DRIVER_VERSION "1.1.1"
2008-06-30 15:04:50 -03:00
/* Number of isochronous URBs. */
# define UVC_URBS 5
2009-01-18 17:46:30 -03:00
/* Maximum number of packets per URB. */
# define UVC_MAX_PACKETS 32
2008-09-16 03:32:20 -03:00
/* Maximum status buffer size in bytes of interrupt URB. */
# define UVC_MAX_STATUS_SIZE 16
2008-06-30 15:04:50 -03:00
2017-08-08 08:56:20 -04:00
# define UVC_CTRL_CONTROL_TIMEOUT 500
2010-01-19 08:59:21 -03:00
# define UVC_CTRL_STREAMING_TIMEOUT 5000
2008-06-30 15:04:50 -03:00
2010-09-08 04:15:23 -03:00
/* Maximum allowed number of control mappings per device */
# define UVC_MAX_CONTROL_MAPPINGS 1024
2011-11-29 18:32:25 -03:00
# define UVC_MAX_CONTROL_MENU_ENTRIES 32
2010-09-08 04:15:23 -03:00
2008-06-30 15:04:50 -03:00
/* Devices quirks */
# define UVC_QUIRK_STATUS_INTERVAL 0x00000001
# define UVC_QUIRK_PROBE_MINMAX 0x00000002
# define UVC_QUIRK_PROBE_EXTRAFIELDS 0x00000004
# define UVC_QUIRK_BUILTIN_ISIGHT 0x00000008
# define UVC_QUIRK_STREAM_NO_FID 0x00000010
# define UVC_QUIRK_IGNORE_SELECTOR_UNIT 0x00000020
2009-02-16 17:41:52 -03:00
# define UVC_QUIRK_FIX_BANDWIDTH 0x00000080
2009-07-19 18:39:56 -03:00
# define UVC_QUIRK_PROBE_DEF 0x00000100
2010-09-16 12:37:26 -03:00
# define UVC_QUIRK_RESTRICT_FRAME_RATE 0x00000200
2014-03-13 09:38:48 -03:00
# define UVC_QUIRK_RESTORE_CTRLS_ON_INIT 0x00000400
2014-08-06 17:50:49 -03:00
# define UVC_QUIRK_FORCE_Y8 0x00000800
2008-06-30 15:04:50 -03:00
/* Format flags */
# define UVC_FMT_FLAG_COMPRESSED 0x00000001
# define UVC_FMT_FLAG_STREAM 0x00000002
/* ------------------------------------------------------------------------
* Structures .
*/
struct uvc_device ;
/* TODO: Put the most frequently accessed fields at the beginning of
* structures to maximize cache efficiency .
*/
struct uvc_control_info {
struct list_head mappings ;
__u8 entity [ 16 ] ;
2010-09-20 05:53:21 -03:00
__u8 index ; /* Bit index in bmControls */
2008-06-30 15:04:50 -03:00
__u8 selector ;
__u16 size ;
__u32 flags ;
} ;
struct uvc_control_mapping {
struct list_head list ;
2012-04-08 12:59:51 -03:00
struct list_head ev_subs ;
2008-06-30 15:04:50 -03:00
__u32 id ;
__u8 name [ 32 ] ;
__u8 entity [ 16 ] ;
__u8 selector ;
__u8 size ;
__u8 offset ;
enum v4l2_ctrl_type v4l2_type ;
__u32 data_type ;
struct uvc_menu_info * menu_info ;
__u32 menu_count ;
2008-12-16 06:46:32 -03:00
2012-04-08 12:59:52 -03:00
__u32 master_id ;
__s32 master_manual ;
__u32 slave_ids [ 2 ] ;
2008-12-16 06:46:32 -03:00
__s32 ( * get ) ( struct uvc_control_mapping * mapping , __u8 query ,
const __u8 * data ) ;
void ( * set ) ( struct uvc_control_mapping * mapping , __s32 value ,
__u8 * data ) ;
2008-06-30 15:04:50 -03:00
} ;
struct uvc_control {
struct uvc_entity * entity ;
2010-09-29 16:00:08 -03:00
struct uvc_control_info info ;
2008-06-30 15:04:50 -03:00
__u8 index ; /* Used to match the uvc_control entry with a
uvc_control_info . */
2010-09-29 16:00:08 -03:00
__u8 dirty : 1 ,
loaded : 1 ,
modified : 1 ,
cached : 1 ,
initialized : 1 ;
2008-06-30 15:04:50 -03:00
2010-06-18 11:31:24 -03:00
__u8 * uvc_data ;
2008-06-30 15:04:50 -03:00
} ;
struct uvc_format_desc {
char * name ;
__u8 guid [ 16 ] ;
__u32 fcc ;
} ;
/* The term 'entity' refers to both UVC units and UVC terminals.
*
* The type field is either the terminal type ( wTerminalType in the terminal
* descriptor ) , or the unit type ( bDescriptorSubtype in the unit descriptor ) .
* As the bDescriptorSubtype field is one byte long , the type value will
* always have a null MSB for units . All terminal types defined by the UVC
* specification have a non - null MSB , so it is safe to use the MSB to
* differentiate between units and terminals as long as the descriptor parsing
* code makes sure terminal types have a non - null MSB .
*
* For terminals , the type ' s most significant bit stores the terminal
* direction ( either UVC_TERM_INPUT or UVC_TERM_OUTPUT ) . The type field should
* always be accessed with the UVC_ENTITY_ * macros and never directly .
*/
2012-08-03 04:35:10 -03:00
# define UVC_ENTITY_FLAG_DEFAULT (1 << 0)
2008-06-30 15:04:50 -03:00
struct uvc_entity {
struct list_head list ; /* Entity as part of a UVC device. */
struct list_head chain ; /* Entity as part of a video device
* chain . */
2012-08-03 04:35:10 -03:00
unsigned int flags ;
2008-06-30 15:04:50 -03:00
__u8 id ;
__u16 type ;
char name [ 64 ] ;
2010-01-21 05:39:52 -03:00
/* Media controller-related fields. */
2010-01-21 08:56:19 -03:00
struct video_device * vdev ;
2010-01-21 05:39:52 -03:00
struct v4l2_subdev subdev ;
unsigned int num_pads ;
unsigned int num_links ;
struct media_pad * pads ;
2008-06-30 15:04:50 -03:00
union {
struct {
__u16 wObjectiveFocalLengthMin ;
__u16 wObjectiveFocalLengthMax ;
__u16 wOcularFocalLength ;
__u8 bControlSize ;
__u8 * bmControls ;
} camera ;
struct {
__u8 bControlSize ;
__u8 * bmControls ;
__u8 bTransportModeSize ;
__u8 * bmTransportModes ;
} media ;
struct {
} output ;
struct {
__u16 wMaxMultiplier ;
__u8 bControlSize ;
__u8 * bmControls ;
__u8 bmVideoStandards ;
} processing ;
struct {
} selector ;
struct {
__u8 guidExtensionCode [ 16 ] ;
__u8 bNumControls ;
__u8 bControlSize ;
__u8 * bmControls ;
__u8 * bmControlsType ;
} extension ;
} ;
2009-11-25 12:00:30 -03:00
__u8 bNrInPins ;
__u8 * baSourceID ;
2008-06-30 15:04:50 -03:00
unsigned int ncontrols ;
struct uvc_control * controls ;
} ;
struct uvc_frame {
__u8 bFrameIndex ;
__u8 bmCapabilities ;
__u16 wWidth ;
__u16 wHeight ;
__u32 dwMinBitRate ;
__u32 dwMaxBitRate ;
__u32 dwMaxVideoFrameBufferSize ;
__u8 bFrameIntervalType ;
__u32 dwDefaultFrameInterval ;
__u32 * dwFrameInterval ;
} ;
struct uvc_format {
__u8 type ;
__u8 index ;
__u8 bpp ;
__u8 colorspace ;
__u32 fcc ;
__u32 flags ;
char name [ 32 ] ;
unsigned int nframes ;
struct uvc_frame * frame ;
} ;
struct uvc_streaming_header {
__u8 bNumFormats ;
__u8 bEndpointAddress ;
__u8 bTerminalLink ;
__u8 bControlSize ;
__u8 * bmaControls ;
/* The following fields are used by input headers only. */
__u8 bmInfo ;
__u8 bStillCaptureMethod ;
__u8 bTriggerSupport ;
__u8 bTriggerUsage ;
} ;
enum uvc_buffer_state {
2009-01-03 19:12:40 -03:00
UVC_BUF_STATE_IDLE = 0 ,
UVC_BUF_STATE_QUEUED = 1 ,
UVC_BUF_STATE_ACTIVE = 2 ,
2009-12-16 21:20:45 -03:00
UVC_BUF_STATE_READY = 3 ,
UVC_BUF_STATE_DONE = 4 ,
UVC_BUF_STATE_ERROR = 5 ,
2008-06-30 15:04:50 -03:00
} ;
struct uvc_buffer {
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 10:30:30 -03:00
struct vb2_v4l2_buffer buf ;
2008-06-30 15:04:50 -03:00
struct list_head queue ;
2011-10-24 11:53:59 -03:00
2008-06-30 15:04:50 -03:00
enum uvc_buffer_state state ;
2010-06-17 06:52:37 -03:00
unsigned int error ;
2011-10-24 11:49:19 -03:00
void * mem ;
unsigned int length ;
unsigned int bytesused ;
2011-09-24 10:46:55 -03:00
u32 pts ;
2008-06-30 15:04:50 -03:00
} ;
2011-10-24 11:53:59 -03:00
# define UVC_QUEUE_DISCONNECTED (1 << 0)
# define UVC_QUEUE_DROP_CORRUPTED (1 << 1)
2008-06-30 15:04:50 -03:00
struct uvc_video_queue {
2011-10-24 11:53:59 -03:00
struct vb2_queue queue ;
struct mutex mutex ; /* Protects queue */
2008-12-28 22:32:29 -03:00
2008-06-30 15:04:50 -03:00
unsigned int flags ;
2008-12-28 22:32:29 -03:00
unsigned int buf_used ;
2008-06-30 15:04:50 -03:00
2011-10-24 11:53:59 -03:00
spinlock_t irqlock ; /* Protects irqqueue */
2008-06-30 15:04:50 -03:00
struct list_head irqqueue ;
} ;
2009-07-01 20:24:47 -03:00
struct uvc_video_chain {
struct uvc_device * dev ;
struct list_head list ;
2009-11-25 12:00:22 -03:00
struct list_head entities ; /* All entities */
2009-07-01 20:24:47 -03:00
struct uvc_entity * processing ; /* Processing unit */
struct uvc_entity * selector ; /* Selector unit */
2010-10-02 09:04:53 -03:00
struct mutex ctrl_mutex ; /* Protects ctrl.info */
2012-08-28 18:38:58 -03:00
2012-08-28 20:29:56 -03:00
struct v4l2_prio_state prio ; /* V4L2 priority state */
2012-08-28 18:38:58 -03:00
u32 caps ; /* V4L2 chain-wide caps */
2009-07-01 20:24:47 -03:00
} ;
2011-11-03 11:40:08 -03:00
struct uvc_stats_frame {
unsigned int size ; /* Number of bytes captured */
unsigned int first_data ; /* Index of the first non-empty packet */
unsigned int nb_packets ; /* Number of packets */
unsigned int nb_empty ; /* Number of empty packets */
unsigned int nb_invalid ; /* Number of packets with an invalid header */
unsigned int nb_errors ; /* Number of packets with the error bit set */
2011-11-03 12:30:17 -03:00
unsigned int nb_pts ; /* Number of packets with a PTS timestamp */
unsigned int nb_pts_diffs ; /* Number of PTS differences inside a frame */
unsigned int last_pts_diff ; /* Index of the last PTS difference */
bool has_initial_pts ; /* Whether the first non-empty packet has a PTS */
bool has_early_pts ; /* Whether a PTS is present before the first non-empty packet */
u32 pts ; /* PTS of the last packet */
unsigned int nb_scr ; /* Number of packets with a SCR timestamp */
unsigned int nb_scr_diffs ; /* Number of SCR.STC differences inside a frame */
u16 scr_sof ; /* SCR.SOF of the last packet */
u32 scr_stc ; /* SCR.STC of the last packet */
2011-11-03 11:40:08 -03:00
} ;
struct uvc_stats_stream {
struct timespec start_ts ; /* Stream start timestamp */
struct timespec stop_ts ; /* Stream stop timestamp */
unsigned int nb_frames ; /* Number of frames */
unsigned int nb_packets ; /* Number of packets */
unsigned int nb_empty ; /* Number of empty packets */
unsigned int nb_invalid ; /* Number of packets with an invalid header */
unsigned int nb_errors ; /* Number of packets with the error bit set */
2011-11-03 12:30:17 -03:00
unsigned int nb_pts_constant ; /* Number of frames with constant PTS */
unsigned int nb_pts_early ; /* Number of frames with early PTS */
unsigned int nb_pts_initial ; /* Number of frames with initial PTS */
unsigned int nb_scr_count_ok ; /* Number of frames with at least one SCR per non empty packet */
unsigned int nb_scr_diffs_ok ; /* Number of frames with varying SCR.STC */
unsigned int scr_sof_count ; /* STC.SOF counter accumulated since stream start */
unsigned int scr_sof ; /* STC.SOF of the last packet */
unsigned int min_sof ; /* Minimum STC.SOF value */
unsigned int max_sof ; /* Maximum STC.SOF value */
2011-11-03 11:40:08 -03:00
} ;
2009-06-28 08:37:50 -03:00
struct uvc_streaming {
struct list_head list ;
2008-06-30 15:04:50 -03:00
struct uvc_device * dev ;
2015-03-09 13:34:11 -03:00
struct video_device vdev ;
2009-07-01 20:24:47 -03:00
struct uvc_video_chain * chain ;
2008-06-30 15:04:50 -03:00
atomic_t active ;
2009-06-28 08:37:50 -03:00
struct usb_interface * intf ;
int intfnum ;
__u16 maxpsize ;
2008-06-30 15:04:50 -03:00
2009-06-28 08:37:50 -03:00
struct uvc_streaming_header header ;
enum v4l2_buf_type type ;
unsigned int nformats ;
struct uvc_format * format ;
2008-06-30 15:04:50 -03:00
2009-06-28 08:37:50 -03:00
struct uvc_streaming_control ctrl ;
2012-08-28 18:38:58 -03:00
struct uvc_format * def_format ;
2009-06-28 08:37:50 -03:00
struct uvc_format * cur_format ;
struct uvc_frame * cur_frame ;
2014-09-09 04:42:43 -03:00
2010-11-21 13:36:34 -03:00
/* Protect access to ctrl, cur_format, cur_frame and hardware video
* probe control .
*/
2009-06-28 08:37:50 -03:00
struct mutex mutex ;
2008-06-30 15:04:50 -03:00
2011-10-24 11:53:59 -03:00
/* Buffers queue. */
2009-06-28 08:37:50 -03:00
unsigned int frozen : 1 ;
struct uvc_video_queue queue ;
void ( * decode ) ( struct urb * urb , struct uvc_streaming * video ,
2008-06-30 15:04:50 -03:00
struct uvc_buffer * buf ) ;
/* Context data used by the bulk completion handler. */
struct {
__u8 header [ 256 ] ;
unsigned int header_size ;
int skip_payload ;
__u32 payload_size ;
__u32 max_payload_size ;
} bulk ;
struct urb * urb [ UVC_URBS ] ;
char * urb_buffer [ UVC_URBS ] ;
2008-07-04 00:36:21 -03:00
dma_addr_t urb_dma [ UVC_URBS ] ;
unsigned int urb_size ;
2008-06-30 15:04:50 -03:00
2010-10-02 11:06:05 -03:00
__u32 sequence ;
2008-06-30 15:04:50 -03:00
__u8 last_fid ;
2011-11-03 09:39:37 -03:00
/* debugfs */
struct dentry * debugfs_dir ;
2011-11-03 11:40:08 -03:00
struct {
struct uvc_stats_frame frame ;
struct uvc_stats_stream stream ;
} stats ;
2011-09-24 10:46:55 -03:00
/* Timestamps support. */
struct uvc_clock {
struct uvc_clock_sample {
u32 dev_stc ;
u16 dev_sof ;
struct timespec host_ts ;
u16 host_sof ;
} * samples ;
unsigned int head ;
unsigned int count ;
unsigned int size ;
u16 last_sof ;
u16 sof_offset ;
spinlock_t lock ;
} clock ;
2008-06-30 15:04:50 -03:00
} ;
struct uvc_device {
struct usb_device * udev ;
struct usb_interface * intf ;
2008-11-08 19:14:50 -03:00
unsigned long warnings ;
2008-06-30 15:04:50 -03:00
__u32 quirks ;
int intfnum ;
char name [ 32 ] ;
2013-04-25 22:28:51 -03:00
struct mutex lock ; /* Protects users */
unsigned int users ;
2010-09-08 04:15:23 -03:00
atomic_t nmappings ;
2008-06-30 15:04:50 -03:00
/* Video control interface */
2010-01-21 05:39:47 -03:00
# ifdef CONFIG_MEDIA_CONTROLLER
struct media_device mdev ;
# endif
struct v4l2_device vdev ;
2008-06-30 15:04:50 -03:00
__u16 uvc_version ;
__u32 clock_frequency ;
struct list_head entities ;
2009-07-01 20:24:47 -03:00
struct list_head chains ;
2008-06-30 15:04:50 -03:00
2009-06-28 08:37:50 -03:00
/* Video Streaming interfaces */
struct list_head streams ;
2017-08-08 08:56:23 -04:00
struct kref ref ;
2009-06-28 08:37:50 -03:00
2008-06-30 15:04:50 -03:00
/* Status Interrupt Endpoint */
struct usb_host_endpoint * int_ep ;
struct urb * int_urb ;
2008-09-16 03:32:20 -03:00
__u8 * status ;
2008-06-30 15:04:50 -03:00
struct input_dev * input ;
2009-01-22 12:45:10 -03:00
char input_phys [ 64 ] ;
2008-06-30 15:04:50 -03:00
} ;
enum uvc_handle_state {
UVC_HANDLE_PASSIVE = 0 ,
UVC_HANDLE_ACTIVE = 1 ,
} ;
struct uvc_fh {
2012-04-08 12:59:51 -03:00
struct v4l2_fh vfh ;
2009-07-01 20:24:47 -03:00
struct uvc_video_chain * chain ;
2009-06-28 08:37:50 -03:00
struct uvc_streaming * stream ;
2008-06-30 15:04:50 -03:00
enum uvc_handle_state state ;
} ;
struct uvc_driver {
struct usb_driver driver ;
} ;
/* ------------------------------------------------------------------------
* Debugging , printing and logging
*/
# define UVC_TRACE_PROBE (1 << 0)
# define UVC_TRACE_DESCR (1 << 1)
# define UVC_TRACE_CONTROL (1 << 2)
# define UVC_TRACE_FORMAT (1 << 3)
# define UVC_TRACE_CAPTURE (1 << 4)
# define UVC_TRACE_CALLS (1 << 5)
# define UVC_TRACE_FRAME (1 << 7)
# define UVC_TRACE_SUSPEND (1 << 8)
# define UVC_TRACE_STATUS (1 << 9)
2009-08-06 11:41:17 -03:00
# define UVC_TRACE_VIDEO (1 << 10)
2011-11-03 11:40:08 -03:00
# define UVC_TRACE_STATS (1 << 11)
2011-09-24 10:46:55 -03:00
# define UVC_TRACE_CLOCK (1 << 12)
2008-06-30 15:04:50 -03:00
2008-11-08 19:14:50 -03:00
# define UVC_WARN_MINMAX 0
# define UVC_WARN_PROBE_DEF 1
2010-09-30 09:04:03 -03:00
# define UVC_WARN_XU_GET_RES 2
2008-11-08 19:14:50 -03:00
2009-12-09 22:57:48 -03:00
extern unsigned int uvc_clock_param ;
2008-12-06 16:25:14 -03:00
extern unsigned int uvc_no_drop_param ;
2008-06-30 15:04:50 -03:00
extern unsigned int uvc_trace_param ;
2009-10-09 20:55:23 -03:00
extern unsigned int uvc_timeout_param ;
2015-07-27 11:06:48 -03:00
extern unsigned int uvc_hw_timestamps_param ;
2008-06-30 15:04:50 -03:00
# define uvc_trace(flag, msg...) \
do { \
if ( uvc_trace_param & flag ) \
printk ( KERN_DEBUG " uvcvideo: " msg ) ; \
} while ( 0 )
2008-11-08 19:14:50 -03:00
# define uvc_warn_once(dev, warn, msg...) \
do { \
if ( ! test_and_set_bit ( warn , & dev - > warnings ) ) \
printk ( KERN_INFO " uvcvideo: " msg ) ; \
} while ( 0 )
2008-06-30 15:04:50 -03:00
# define uvc_printk(level, msg...) \
printk ( level " uvcvideo: " msg )
/* --------------------------------------------------------------------------
* Internal functions .
*/
/* Core driver */
extern struct uvc_driver uvc_driver ;
2010-01-21 05:39:52 -03:00
extern struct uvc_entity * uvc_entity_by_id ( struct uvc_device * dev , int id ) ;
2008-06-30 15:04:50 -03:00
/* Video buffers queue management. */
2012-09-26 07:30:34 -03:00
extern int uvc_queue_init ( struct uvc_video_queue * queue ,
2010-06-17 06:52:37 -03:00
enum v4l2_buf_type type , int drop_corrupted ) ;
2014-10-21 16:07:15 -03:00
extern void uvc_queue_release ( struct uvc_video_queue * queue ) ;
2014-10-21 16:02:00 -03:00
extern int uvc_request_buffers ( struct uvc_video_queue * queue ,
2011-10-24 11:53:59 -03:00
struct v4l2_requestbuffers * rb ) ;
2008-06-30 15:04:50 -03:00
extern int uvc_query_buffer ( struct uvc_video_queue * queue ,
struct v4l2_buffer * v4l2_buf ) ;
2014-01-29 13:13:52 -03:00
extern int uvc_create_buffers ( struct uvc_video_queue * queue ,
struct v4l2_create_buffers * v4l2_cb ) ;
2008-06-30 15:04:50 -03:00
extern int uvc_queue_buffer ( struct uvc_video_queue * queue ,
struct v4l2_buffer * v4l2_buf ) ;
2015-04-14 04:19:51 -03:00
extern int uvc_export_buffer ( struct uvc_video_queue * queue ,
struct v4l2_exportbuffer * exp ) ;
2008-06-30 15:04:50 -03:00
extern int uvc_dequeue_buffer ( struct uvc_video_queue * queue ,
struct v4l2_buffer * v4l2_buf , int nonblocking ) ;
2014-10-21 16:19:04 -03:00
extern int uvc_queue_streamon ( struct uvc_video_queue * queue ,
enum v4l2_buf_type type ) ;
extern int uvc_queue_streamoff ( struct uvc_video_queue * queue ,
enum v4l2_buf_type type ) ;
2008-06-30 15:04:50 -03:00
extern void uvc_queue_cancel ( struct uvc_video_queue * queue , int disconnect ) ;
extern struct uvc_buffer * uvc_queue_next_buffer ( struct uvc_video_queue * queue ,
struct uvc_buffer * buf ) ;
2010-11-21 15:18:08 -03:00
extern int uvc_queue_mmap ( struct uvc_video_queue * queue ,
struct vm_area_struct * vma ) ;
2008-06-30 15:04:50 -03:00
extern unsigned int uvc_queue_poll ( struct uvc_video_queue * queue ,
struct file * file , poll_table * wait ) ;
2011-04-29 07:11:35 -03:00
# ifndef CONFIG_MMU
extern unsigned long uvc_queue_get_unmapped_area ( struct uvc_video_queue * queue ,
unsigned long pgoff ) ;
# endif
2009-06-04 09:26:39 -03:00
extern int uvc_queue_allocated ( struct uvc_video_queue * queue ) ;
2008-06-30 15:04:50 -03:00
static inline int uvc_queue_streaming ( struct uvc_video_queue * queue )
{
2011-10-24 11:53:59 -03:00
return vb2_is_streaming ( & queue - > queue ) ;
2008-06-30 15:04:50 -03:00
}
/* V4L2 interface */
2010-09-30 10:17:54 -03:00
extern const struct v4l2_ioctl_ops uvc_ioctl_ops ;
2008-12-30 06:58:20 -03:00
extern const struct v4l2_file_operations uvc_fops ;
2008-06-30 15:04:50 -03:00
2010-01-21 05:39:52 -03:00
/* Media controller */
extern int uvc_mc_register_entities ( struct uvc_video_chain * chain ) ;
extern void uvc_mc_cleanup_entity ( struct uvc_entity * entity ) ;
2008-06-30 15:04:50 -03:00
/* Video */
2009-06-28 08:37:50 -03:00
extern int uvc_video_init ( struct uvc_streaming * stream ) ;
extern int uvc_video_suspend ( struct uvc_streaming * stream ) ;
2011-07-16 00:51:00 -03:00
extern int uvc_video_resume ( struct uvc_streaming * stream , int reset ) ;
2009-06-28 08:37:50 -03:00
extern int uvc_video_enable ( struct uvc_streaming * stream , int enable ) ;
extern int uvc_probe_video ( struct uvc_streaming * stream ,
2008-06-30 15:04:50 -03:00
struct uvc_streaming_control * probe ) ;
extern int uvc_query_ctrl ( struct uvc_device * dev , __u8 query , __u8 unit ,
__u8 intfnum , __u8 cs , void * data , __u16 size ) ;
2011-09-24 10:46:55 -03:00
void uvc_video_clock_update ( struct uvc_streaming * stream ,
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 10:30:30 -03:00
struct vb2_v4l2_buffer * vbuf ,
2011-09-24 10:46:55 -03:00
struct uvc_buffer * buf ) ;
2008-06-30 15:04:50 -03:00
/* Status */
extern int uvc_status_init ( struct uvc_device * dev ) ;
extern void uvc_status_cleanup ( struct uvc_device * dev ) ;
2013-04-25 22:28:51 -03:00
extern int uvc_status_start ( struct uvc_device * dev , gfp_t flags ) ;
2009-05-19 10:08:03 -03:00
extern void uvc_status_stop ( struct uvc_device * dev ) ;
2008-06-30 15:04:50 -03:00
/* Controls */
2012-04-08 12:59:51 -03:00
extern const struct v4l2_subscribed_event_ops uvc_ctrl_sub_ev_ops ;
2009-07-01 20:24:47 -03:00
extern int uvc_query_v4l2_ctrl ( struct uvc_video_chain * chain ,
2008-06-30 15:04:50 -03:00
struct v4l2_queryctrl * v4l2_ctrl ) ;
2010-11-21 07:58:54 -03:00
extern int uvc_query_v4l2_menu ( struct uvc_video_chain * chain ,
struct v4l2_querymenu * query_menu ) ;
2008-06-30 15:04:50 -03:00
2010-09-20 05:53:21 -03:00
extern int uvc_ctrl_add_mapping ( struct uvc_video_chain * chain ,
const struct uvc_control_mapping * mapping ) ;
2008-06-30 15:04:50 -03:00
extern int uvc_ctrl_init_device ( struct uvc_device * dev ) ;
extern void uvc_ctrl_cleanup_device ( struct uvc_device * dev ) ;
2014-03-13 09:38:48 -03:00
extern int uvc_ctrl_restore_values ( struct uvc_device * dev ) ;
2008-06-30 15:04:50 -03:00
2009-07-01 20:24:47 -03:00
extern int uvc_ctrl_begin ( struct uvc_video_chain * chain ) ;
2012-04-08 12:59:51 -03:00
extern int __uvc_ctrl_commit ( struct uvc_fh * handle , int rollback ,
const struct v4l2_ext_control * xctrls ,
unsigned int xctrls_count ) ;
static inline int uvc_ctrl_commit ( struct uvc_fh * handle ,
const struct v4l2_ext_control * xctrls ,
unsigned int xctrls_count )
2008-06-30 15:04:50 -03:00
{
2012-04-08 12:59:51 -03:00
return __uvc_ctrl_commit ( handle , 0 , xctrls , xctrls_count ) ;
2008-06-30 15:04:50 -03:00
}
2012-04-08 12:59:51 -03:00
static inline int uvc_ctrl_rollback ( struct uvc_fh * handle )
2008-06-30 15:04:50 -03:00
{
2012-04-08 12:59:51 -03:00
return __uvc_ctrl_commit ( handle , 1 , NULL , 0 ) ;
2008-06-30 15:04:50 -03:00
}
2009-07-01 20:24:47 -03:00
extern int uvc_ctrl_get ( struct uvc_video_chain * chain ,
2008-06-30 15:04:50 -03:00
struct v4l2_ext_control * xctrl ) ;
2009-07-01 20:24:47 -03:00
extern int uvc_ctrl_set ( struct uvc_video_chain * chain ,
2008-06-30 15:04:50 -03:00
struct v4l2_ext_control * xctrl ) ;
2009-07-01 20:24:47 -03:00
extern int uvc_xu_ctrl_query ( struct uvc_video_chain * chain ,
2010-10-02 19:10:16 -03:00
struct uvc_xu_control_query * xqry ) ;
2008-06-30 15:04:50 -03:00
/* Utility functions */
extern void uvc_simplify_fraction ( uint32_t * numerator , uint32_t * denominator ,
unsigned int n_terms , unsigned int threshold ) ;
extern uint32_t uvc_fraction_to_interval ( uint32_t numerator ,
uint32_t denominator ) ;
extern struct usb_host_endpoint * uvc_find_endpoint (
struct usb_host_interface * alts , __u8 epaddr ) ;
/* Quirks support */
2009-06-28 08:37:50 -03:00
void uvc_video_decode_isight ( struct urb * urb , struct uvc_streaming * stream ,
2008-06-30 15:04:50 -03:00
struct uvc_buffer * buf ) ;
2011-11-03 11:40:08 -03:00
/* debugfs and statistics */
2017-01-11 23:31:21 -02:00
void uvc_debugfs_init ( void ) ;
2011-11-03 09:39:37 -03:00
void uvc_debugfs_cleanup ( void ) ;
2017-01-11 23:31:21 -02:00
void uvc_debugfs_init_stream ( struct uvc_streaming * stream ) ;
2011-11-03 09:39:37 -03:00
void uvc_debugfs_cleanup_stream ( struct uvc_streaming * stream ) ;
2011-11-03 11:40:08 -03:00
size_t uvc_video_stats_dump ( struct uvc_streaming * stream , char * buf ,
size_t size ) ;
2008-06-30 15:04:50 -03:00
# endif