mirror of
https://github.com/pvvx/RTL00MP3.git
synced 2025-07-31 12:41:06 +00:00
first commit
This commit is contained in:
parent
2ee525362e
commit
d108756e9b
792 changed files with 336059 additions and 0 deletions
|
|
@ -0,0 +1,71 @@
|
|||
#ifndef __LINUX_UVCVIDEO_H_
|
||||
#define __LINUX_UVCVIDEO_H_
|
||||
#if 0
|
||||
#include <linux/ioctl.h>
|
||||
#include <linux/types.h>
|
||||
#endif
|
||||
#include "uvc_os_wrap_via_osdep_api.h"
|
||||
/*
|
||||
* Dynamic controls
|
||||
*/
|
||||
|
||||
/* Data types for UVC control data */
|
||||
#define UVC_CTRL_DATA_TYPE_RAW 0
|
||||
#define UVC_CTRL_DATA_TYPE_SIGNED 1
|
||||
#define UVC_CTRL_DATA_TYPE_UNSIGNED 2
|
||||
#define UVC_CTRL_DATA_TYPE_BOOLEAN 3
|
||||
#define UVC_CTRL_DATA_TYPE_ENUM 4
|
||||
#define UVC_CTRL_DATA_TYPE_BITMASK 5
|
||||
|
||||
/* Control flags */
|
||||
#define UVC_CTRL_FLAG_SET_CUR (1 << 0)
|
||||
#define UVC_CTRL_FLAG_GET_CUR (1 << 1)
|
||||
#define UVC_CTRL_FLAG_GET_MIN (1 << 2)
|
||||
#define UVC_CTRL_FLAG_GET_MAX (1 << 3)
|
||||
#define UVC_CTRL_FLAG_GET_RES (1 << 4)
|
||||
#define UVC_CTRL_FLAG_GET_DEF (1 << 5)
|
||||
/* Control should be saved at suspend and restored at resume. */
|
||||
#define UVC_CTRL_FLAG_RESTORE (1 << 6)
|
||||
/* Control can be updated by the camera. */
|
||||
#define UVC_CTRL_FLAG_AUTO_UPDATE (1 << 7)
|
||||
|
||||
#define UVC_CTRL_FLAG_GET_RANGE \
|
||||
(UVC_CTRL_FLAG_GET_CUR | UVC_CTRL_FLAG_GET_MIN | \
|
||||
UVC_CTRL_FLAG_GET_MAX | UVC_CTRL_FLAG_GET_RES | \
|
||||
UVC_CTRL_FLAG_GET_DEF)
|
||||
|
||||
struct uvc_menu_info {
|
||||
__u32 value;
|
||||
__u8 name[32];
|
||||
};
|
||||
|
||||
struct uvc_xu_control_mapping {
|
||||
__u32 id;
|
||||
__u8 name[32];
|
||||
__u8 entity[16];
|
||||
__u8 selector;
|
||||
|
||||
__u8 size;
|
||||
__u8 offset;
|
||||
__u32 v4l2_type;
|
||||
__u32 data_type;
|
||||
|
||||
struct uvc_menu_info __user *menu_info;
|
||||
__u32 menu_count;
|
||||
|
||||
__u32 reserved[4];
|
||||
};
|
||||
|
||||
struct uvc_xu_control_query {
|
||||
__u8 unit;
|
||||
__u8 selector;
|
||||
__u8 query; /* Video Class-Specific Request Code, */
|
||||
/* defined in linux/usb/video.h A.8. */
|
||||
__u16 size;
|
||||
__u8 __user *data;
|
||||
};
|
||||
|
||||
#define UVCIOC_CTRL_MAP _IOWR('u', 0x20, struct uvc_xu_control_mapping)
|
||||
#define UVCIOC_CTRL_QUERY _IOWR('u', 0x21, struct uvc_xu_control_query)
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
#ifndef _UVC_INTF_H_
|
||||
#define _UVC_INTF_H_
|
||||
|
||||
enum uvc_format_type{
|
||||
UVC_FORMAT_MJPEG = 1,
|
||||
UVC_FORMAT_H264 = 2,
|
||||
UVC_FORMAT_UNKNOWN = -1,
|
||||
};
|
||||
|
||||
typedef enum uvc_format_type uvc_fmt_t;
|
||||
|
||||
struct uvc_context
|
||||
{
|
||||
uvc_fmt_t fmt_type; //video format type
|
||||
int width;//video frame width
|
||||
int height;//video frame height
|
||||
int frame_rate;//video frame rate
|
||||
int compression_ratio;//compression format video compression ratio
|
||||
};
|
||||
|
||||
#define USER_CTRL_SATURATION 1
|
||||
|
||||
struct uvc_user_ctrl
|
||||
{
|
||||
u32 ctrl_id;
|
||||
s32 ctrl_value;
|
||||
};
|
||||
|
||||
struct uvc_buf_context
|
||||
{
|
||||
int index; //index of internal uvc buffer
|
||||
unsigned char *data; //address of uvc data
|
||||
int len; //length of uvc data
|
||||
u32 timestamp; //timestamp
|
||||
};
|
||||
|
||||
int uvc_stream_init(void); //entry function to start uvc
|
||||
void uvc_stream_free(void); // free streaming resources
|
||||
int uvc_is_stream_ready(void); // return true if uvc device is initialized successfully
|
||||
int uvc_is_stream_on(void); //return true if uvc device is streaming now
|
||||
int uvc_stream_on(void); //enable camera streaming
|
||||
void uvc_stream_off(void); //disable camera streaming
|
||||
int uvc_set_param(uvc_fmt_t fmt_type, int *width, int *height, int *frame_rate, int *compression_ratio);//set camera streaming video parameters:video format, resolution and frame rate.
|
||||
int uvc_get_user_ctrl(struct uvc_user_ctrl *user_ctrl);
|
||||
int uvc_set_user_ctrl(struct uvc_user_ctrl *user_ctrl);
|
||||
int uvc_buf_check(struct uvc_buf_context *b); //check if uvc_buf_context is legal (return 0 is legal otherwise -1)
|
||||
int uvc_dqbuf(struct uvc_buf_context *b); //dequeue internal buffer & get internal buffer info
|
||||
int uvc_qbuf(struct uvc_buf_context *b); //queue internal buffer
|
||||
int is_pure_thru_on(void); //return 1 if pure throughput test mode is on otherwise return 0
|
||||
void uvc_pure_thru_on(void); //turn on pure uvc throughput test mode (i.e. no decoding is involved)
|
||||
void uvc_dec_thru_on(void); //turn on uvc throughput test mode with uvc payload decoding
|
||||
void uvc_thru_off(void); //turn off uvc throughput log service
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,570 @@
|
|||
#ifndef _UVC_OSDEP_WRAP_H_
|
||||
#define _UVC_OSDEP_WRAP_H_
|
||||
|
||||
//#include "rtl_utility.h"
|
||||
#include "platform/platform_stdlib.h"
|
||||
#include "basic_types.h"
|
||||
#include "osdep_api.h"
|
||||
#include "usb_defs.h"
|
||||
|
||||
#include "errno.h"
|
||||
#include "dlist.h"
|
||||
|
||||
|
||||
|
||||
#define UVC_LAYER_DEBUG 0
|
||||
#if UVC_LAYER_DEBUG
|
||||
#define UVC_PRINTF(fmt, args...) printf("\n\r%s: " fmt, __FUNCTION__, ## args)
|
||||
#define UVC_ERROR(fmt, args...) printf("\n\r%s: " fmt, __FUNCTION__, ## args)
|
||||
#define FUN_ENTER //printf("\n\r%s ==>\n", __func__)
|
||||
#define FUN_EXIT //printf("\n\r%s <==\n", __func__)
|
||||
#define FUN_TRACE //printf("\n\r%s:%d \n", __func__, __LINE__)
|
||||
#else
|
||||
#define UVC_PRINTF(fmt, args...)
|
||||
#define UVC_ERROR(fmt, args...) printf("\n\r%s: " fmt, __FUNCTION__, ## args)
|
||||
#define FUN_ENTER
|
||||
#define FUN_EXIT
|
||||
#define FUN_TRACE
|
||||
#endif
|
||||
|
||||
/* add by Ian -- define uvc task priority */
|
||||
#define UVC_TASK_PRIORITY 2
|
||||
|
||||
#ifndef __u8
|
||||
#define __u8 u8
|
||||
#endif
|
||||
#ifndef __u16
|
||||
#define __u16 u16
|
||||
#endif
|
||||
#ifndef __u32
|
||||
#define __u32 u32
|
||||
#endif
|
||||
#ifndef __u64
|
||||
#define __u64 u64
|
||||
#endif
|
||||
#ifndef __s8
|
||||
#define __s8 s8
|
||||
#endif
|
||||
#ifndef __s16
|
||||
#define __s16 s16
|
||||
#endif
|
||||
#ifndef __s32
|
||||
#define __s32 s32
|
||||
#endif
|
||||
#ifndef __s64
|
||||
#define __s64 s64
|
||||
#endif
|
||||
|
||||
#ifndef gfp_t
|
||||
#define gfp_t u32
|
||||
#endif
|
||||
|
||||
#define ALIGN(x, a, type_of_x) (((x) + ((type_of_x)(a) - 1)) & ~((type_of_x)(a) - 1))
|
||||
|
||||
#ifndef IS_ALIGNED
|
||||
#define IS_ALIGNED(x, a, type_of_x) (((x) & ((type_of_x)(a) - 1)) == 0)
|
||||
#endif
|
||||
#ifndef ARRAY_SIZE
|
||||
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
|
||||
#endif
|
||||
|
||||
#ifndef BITS_PER_LONG
|
||||
#define BITS_PER_LONG (32)
|
||||
#endif
|
||||
#ifndef BITS_PER_LONG_LONG
|
||||
#define BITS_PER_LONG_LONG (32)
|
||||
#endif
|
||||
|
||||
/* Atomic integer operations */
|
||||
#ifndef atomic_set
|
||||
#define atomic_set(v, i) RTL_ATOMIC_SET((v), (i))
|
||||
#endif
|
||||
#ifndef atomic_read
|
||||
#define atomic_read(v) RTL_ATOMIC_READ((v))
|
||||
#endif
|
||||
#ifndef atomic_add
|
||||
#define atomic_add(v, i) RTL_ATOMIC_ADD((v), (i))
|
||||
#endif
|
||||
#ifndef atomic_sub
|
||||
#define atomic_sub(v, i) RTL_ATOMIC_SUB((v), (i))
|
||||
#endif
|
||||
#ifndef atomic_inc
|
||||
#define atomic_inc(v) RTL_ATOMIC_INC((v))
|
||||
#endif
|
||||
#ifndef atomic_dec
|
||||
#define atomic_dec(v) RTL_ATOMIC_DEC((v))
|
||||
#endif
|
||||
|
||||
#ifndef MEDIA_PAD_FL_SINK
|
||||
#define MEDIA_PAD_FL_SINK (1 << 0)
|
||||
#endif
|
||||
#ifndef MEDIA_PAD_FL_SOURCE
|
||||
#define MEDIA_PAD_FL_SOURCE (1 << 1)
|
||||
#endif
|
||||
#ifndef MEDIA_PAD_FL_MUST_CONNECT
|
||||
#define MEDIA_PAD_FL_MUST_CONNECT (1 << 2)
|
||||
#endif
|
||||
|
||||
static inline u16 __get_unaligned_le16(const u8 *p)
|
||||
{
|
||||
return p[0] | p[1] << 8;
|
||||
}
|
||||
|
||||
static inline u32 __get_unaligned_le32(const u8 *p)
|
||||
{
|
||||
return p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24;
|
||||
}
|
||||
|
||||
static inline u64 __get_unaligned_le64(const u8 *p)
|
||||
{
|
||||
return (u64)__get_unaligned_le32(p + 4) << 32 |
|
||||
__get_unaligned_le32(p);
|
||||
}
|
||||
|
||||
static inline void __put_unaligned_le16(u16 val, u8 *p)
|
||||
{
|
||||
*p++ = val;
|
||||
*p++ = val >> 8;
|
||||
}
|
||||
|
||||
static inline void __put_unaligned_le32(u32 val, u8 *p)
|
||||
{
|
||||
__put_unaligned_le16(val >> 16, p + 2);
|
||||
__put_unaligned_le16(val, p);
|
||||
}
|
||||
|
||||
static inline void __put_unaligned_le64(u64 val, u8 *p)
|
||||
{
|
||||
__put_unaligned_le32(val >> 32, p + 4);
|
||||
__put_unaligned_le32(val, p);
|
||||
}
|
||||
|
||||
static inline u16 get_unaligned_le16(const void *p)
|
||||
{
|
||||
return __get_unaligned_le16((const u8 *)p);
|
||||
}
|
||||
|
||||
static inline u32 get_unaligned_le32(const void *p)
|
||||
{
|
||||
return __get_unaligned_le32((const u8 *)p);
|
||||
}
|
||||
|
||||
static inline u64 get_unaligned_le64(const void *p)
|
||||
{
|
||||
return __get_unaligned_le64((const u8 *)p);
|
||||
}
|
||||
|
||||
static inline void put_unaligned_le16(u16 val, void *p)
|
||||
{
|
||||
__put_unaligned_le16(val, p);
|
||||
}
|
||||
|
||||
static inline void put_unaligned_le32(u32 val, void *p)
|
||||
{
|
||||
__put_unaligned_le32(val, p);
|
||||
}
|
||||
|
||||
static inline void put_unaligned_le64(u64 val, void *p)
|
||||
{
|
||||
__put_unaligned_le64(val, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* kmemdup - duplicate region of memory
|
||||
*
|
||||
* @src: memory region to duplicate
|
||||
* @len: memory region length
|
||||
* @gfp: GFP mask to use
|
||||
*/
|
||||
static inline void *kmemdup(const void *src, size_t len, gfp_t gfp)
|
||||
{
|
||||
void *p;
|
||||
|
||||
//p = kmalloc_track_caller(len, gfp);
|
||||
//p = kmalloc(len, gfp);
|
||||
p = malloc(len);
|
||||
if (p)
|
||||
memcpy(p, src, len);
|
||||
return p;
|
||||
}
|
||||
#ifndef __force
|
||||
#define __force __attribute__((force))
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
typedef __u16 __bitwise __le16;
|
||||
typedef __u16 __bitwise __be16;
|
||||
typedef __u32 __bitwise __le32;
|
||||
typedef __u32 __bitwise __be32;
|
||||
typedef __u64 __bitwise __le64;
|
||||
typedef __u64 __bitwise __be64;
|
||||
typedef __u16 __bitwise __sum16;
|
||||
typedef __u32 __bitwise __wsum;
|
||||
#endif
|
||||
//edit by Ian -- remove duplicated definitions
|
||||
#if 0
|
||||
typedef __u16 __le16;
|
||||
typedef __u16 __be16;
|
||||
typedef __u32 __le32;
|
||||
typedef __u32 __be32;
|
||||
typedef __u64 __le64;
|
||||
typedef __u64 __be64;
|
||||
typedef __u16 __sum16;
|
||||
typedef __u32 __wsum;
|
||||
#endif
|
||||
|
||||
#ifndef __le16
|
||||
#define __le16 __u16
|
||||
#endif
|
||||
#ifndef __be16
|
||||
#define __be16 __u16
|
||||
#endif
|
||||
#ifndef __le32
|
||||
#define __le32 __u32
|
||||
#endif
|
||||
#ifndef __be32
|
||||
#define __be32 __u32
|
||||
#endif
|
||||
static inline __u32 le32_to_cpup(const __le32 *p)
|
||||
{
|
||||
//return (__force __u32)*p;
|
||||
return (__u32)*p;
|
||||
}
|
||||
static inline __u16 le16_to_cpup(const __le16 *p)
|
||||
{
|
||||
//return (__force __u16)*p;
|
||||
return (__u16)*p;
|
||||
}
|
||||
|
||||
|
||||
/* Endian macros */
|
||||
#ifndef htonl
|
||||
#define htonl(x) rtk_cpu_to_be32(x)
|
||||
#endif
|
||||
|
||||
#ifndef ntohl
|
||||
#define ntohl(x) rtk_be32_to_cpu(x)
|
||||
#endif
|
||||
|
||||
#ifndef htons
|
||||
#define htons(x) rtk_cpu_to_be16(x)
|
||||
#endif
|
||||
|
||||
#ifndef ntohs
|
||||
#define ntohs(x) rtk_be16_to_cpu(x)
|
||||
#endif
|
||||
|
||||
#ifndef cpu_to_le32
|
||||
#define cpu_to_le32(x) rtk_cpu_to_le32(x)
|
||||
#endif
|
||||
|
||||
#ifndef le32_to_cpu
|
||||
#define le32_to_cpu(x) rtk_le32_to_cpu(x)
|
||||
#endif
|
||||
|
||||
#ifndef cpu_to_le16
|
||||
#define cpu_to_le16(x) rtk_cpu_to_le16(x)
|
||||
#endif
|
||||
|
||||
#ifndef le16_to_cpu
|
||||
#define le16_to_cpu(x) rtk_le16_to_cpu(x)
|
||||
#endif
|
||||
|
||||
#ifndef cpu_to_be32
|
||||
#define cpu_to_be32(x) rtk_cpu_to_be32(x)
|
||||
#endif
|
||||
|
||||
#ifndef be32_to_cpu
|
||||
#define be32_to_cpu(x) rtk_be32_to_cpu(x)
|
||||
#endif
|
||||
|
||||
#ifndef cpu_to_be16
|
||||
#define cpu_to_be16(x) rtk_cpu_to_be16(x)
|
||||
#endif
|
||||
|
||||
#ifndef be16_to_cpu
|
||||
#define be16_to_cpu(x) rtk_be16_to_cpu(x)
|
||||
#endif
|
||||
|
||||
/* Parameters used to convert the timespec values: */
|
||||
#ifndef MSEC_PER_SEC
|
||||
#define MSEC_PER_SEC 1000L
|
||||
#endif
|
||||
#ifndef USEC_PER_MSEC
|
||||
#define USEC_PER_MSEC 1000L
|
||||
#endif
|
||||
#ifndef NSEC_PER_USEC
|
||||
#define NSEC_PER_USEC 1000L
|
||||
#endif
|
||||
#ifndef NSEC_PER_MSEC
|
||||
#define NSEC_PER_MSEC 1000000L
|
||||
#endif
|
||||
#ifndef USEC_PER_SEC
|
||||
#define USEC_PER_SEC 1000000L
|
||||
#endif
|
||||
#ifndef NSEC_PER_SEC
|
||||
#define NSEC_PER_SEC 1000000000L
|
||||
#endif
|
||||
#ifndef FSEC_PER_SEC
|
||||
#define FSEC_PER_SEC 1000000000000000LL
|
||||
#endif
|
||||
#ifndef TIME_T_MAX
|
||||
#define TIME_T_MAX (time_t)((1UL << ((sizeof(time_t) << 3) - 1)) - 1)
|
||||
#endif
|
||||
|
||||
#ifndef __GFP_WAIT
|
||||
#define __GFP_WAIT (0x10u)
|
||||
#endif
|
||||
#ifndef __GFP_HIGH
|
||||
#define __GFP_HIGH (0x20u)
|
||||
#endif
|
||||
#ifndef __GFP_IO
|
||||
#define __GFP_IO (0x40u)
|
||||
#endif
|
||||
#ifndef __GFP_FS
|
||||
#define __GFP_FS (0x80u)
|
||||
#endif
|
||||
#ifndef GFP_NOIO
|
||||
#define GFP_NOIO (0x10u)
|
||||
#endif
|
||||
#ifndef __GFP_NOWARN
|
||||
#define __GFP_NOWARN (0x200u)
|
||||
#endif
|
||||
#ifndef GFP_KERNEL
|
||||
#define GFP_KERNEL (__GFP_WAIT | __GFP_IO | __GFP_FS)
|
||||
#endif
|
||||
|
||||
#ifndef copy_from_user
|
||||
#define copy_from_user(to, from, sz) RtlMemcpy((to), (from), (sz))
|
||||
#endif
|
||||
#ifndef copy_to_user
|
||||
#define copy_to_user(to, from, sz) RtlMemcpy((to), (from), (sz))
|
||||
#endif
|
||||
|
||||
typedef u32 compat_caddr_t; //used for compatibility in uvc_v4l2.c
|
||||
|
||||
/**
|
||||
* strlcpy - Copy a %NUL terminated string into a sized buffer
|
||||
* @dest: Where to copy the string to
|
||||
* @src: Where to copy the string from
|
||||
* @size: size of destination buffer
|
||||
*
|
||||
* Compatible with *BSD: the result is always a valid
|
||||
* NUL-terminated string that fits in the buffer (unless,
|
||||
* of course, the buffer size is zero). It does not pad
|
||||
* out the result like strncpy() does.
|
||||
*/
|
||||
static inline size_t strlcpy(char *dest, const char *src, size_t size)
|
||||
{
|
||||
size_t ret = _strlen(src);
|
||||
|
||||
if (size) {
|
||||
size_t len = (ret >= size) ? size - 1 : ret;
|
||||
memcpy(dest, src, len);
|
||||
dest[len] = '\0';
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* clamp - return a value clamped to a given range with strict typechecking
|
||||
* @val: current value
|
||||
* @min: minimum allowable value
|
||||
* @max: maximum allowable value
|
||||
*
|
||||
* This macro does strict typechecking of min/max to make sure they are of the
|
||||
* same type as val. See the unnecessary pointer comparisons.
|
||||
*/
|
||||
|
||||
#ifndef clamp
|
||||
#define clamp(new_val, val, min, max, type) do{ \
|
||||
type __val = (val); \
|
||||
type __min = (min); \
|
||||
type __max = (max); \
|
||||
(void) (&__val == &__min); \
|
||||
(void) (&__val == &__max); \
|
||||
__val = (__val < __min) ? __min: __val; \
|
||||
new_val = (__val > __max) ? __max: __val; }while(0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Compile time versions of __arch_hweightN()
|
||||
*/
|
||||
#ifndef __const_hweight8
|
||||
#define __const_hweight8(w) \
|
||||
( (!!((w) & (1ULL << 0))) + \
|
||||
(!!((w) & (1ULL << 1))) + \
|
||||
(!!((w) & (1ULL << 2))) + \
|
||||
(!!((w) & (1ULL << 3))) + \
|
||||
(!!((w) & (1ULL << 4))) + \
|
||||
(!!((w) & (1ULL << 5))) + \
|
||||
(!!((w) & (1ULL << 6))) + \
|
||||
(!!((w) & (1ULL << 7))) )
|
||||
#endif
|
||||
#ifndef hweight8
|
||||
#define hweight8(w) __const_hweight8(w)
|
||||
#endif
|
||||
#ifndef BITMAP_LAST_WORD_MASK
|
||||
#define BITMAP_LAST_WORD_MASK(nbits) \
|
||||
( \
|
||||
((nbits) % BITS_PER_LONG) ? \
|
||||
(1UL<<((nbits) % BITS_PER_LONG))-1 : ~0UL \
|
||||
)
|
||||
#endif
|
||||
/**
|
||||
* hweightN - returns the hamming weight of a N-bit word
|
||||
* @x: the word to weigh
|
||||
*
|
||||
* The Hamming Weight of a number is the total number of bits set in it.
|
||||
*/
|
||||
static inline unsigned int hweight32(unsigned int w)
|
||||
{
|
||||
unsigned int res = w - ((w >> 1) & 0x55555555);
|
||||
res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
|
||||
res = (res + (res >> 4)) & 0x0F0F0F0F;
|
||||
res = res + (res >> 8);
|
||||
return (res + (res >> 16)) & 0x000000FF;
|
||||
}
|
||||
|
||||
static inline unsigned long hweight64(__u64 w)
|
||||
{
|
||||
#if BITS_PER_LONG == 32
|
||||
return hweight32((unsigned int)(w >> 32)) + hweight32((unsigned int)w);
|
||||
#elif BITS_PER_LONG == 64
|
||||
__u64 res = w - ((w >> 1) & 0x5555555555555555ul);
|
||||
res = (res & 0x3333333333333333ul) + ((res >> 2) & 0x3333333333333333ul);
|
||||
res = (res + (res >> 4)) & 0x0F0F0F0F0F0F0F0Ful;
|
||||
res = res + (res >> 8);
|
||||
res = res + (res >> 16);
|
||||
return (res + (res >> 32)) & 0x00000000000000FFul;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static inline unsigned long hweight_long(unsigned long w)
|
||||
{
|
||||
return sizeof(w) == 4 ? hweight32(w) : hweight64(w);
|
||||
}
|
||||
|
||||
static inline int __bitmap_weight(const unsigned long *bitmap, int bits)
|
||||
{
|
||||
int k, w = 0, lim = bits/BITS_PER_LONG;
|
||||
|
||||
for (k = 0; k < lim; k++)
|
||||
w += hweight_long(bitmap[k]);
|
||||
|
||||
if (bits % BITS_PER_LONG)
|
||||
w += hweight_long(bitmap[k] & BITMAP_LAST_WORD_MASK(bits));
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
static inline int bitmap_weight(const unsigned long *src, int nbits)
|
||||
{
|
||||
// if (small_const_nbits(nbits))
|
||||
// return hweight_long(*src & BITMAP_LAST_WORD_MASK(nbits));
|
||||
return __bitmap_weight(src, nbits);
|
||||
}
|
||||
|
||||
/**
|
||||
* memweight - count the total number of bits set in memory area
|
||||
* @ptr: pointer to the start of the area
|
||||
* @bytes: the size of the area
|
||||
*/
|
||||
static inline size_t memweight(const void *ptr, size_t bytes)
|
||||
{
|
||||
size_t ret = 0;
|
||||
size_t longs;
|
||||
const unsigned char *bitmap = ptr;
|
||||
|
||||
for (; bytes > 0 && ((unsigned long)bitmap) % sizeof(long);
|
||||
bytes--, bitmap++)
|
||||
ret += hweight8(*bitmap);
|
||||
|
||||
longs = bytes / sizeof(long);
|
||||
if (longs) {
|
||||
//BUG_ON(longs >= INT_MAX / BITS_PER_LONG);
|
||||
ret += bitmap_weight((unsigned long *)bitmap, longs * BITS_PER_LONG);
|
||||
bytes -= longs * sizeof(long);
|
||||
bitmap += longs * sizeof(long);
|
||||
}
|
||||
/*
|
||||
* The reason that this last loop is distinct from the preceding
|
||||
* bitmap_weight() call is to compute 1-bits in the last region smaller
|
||||
* than sizeof(long) properly on big-endian systems.
|
||||
*/
|
||||
for (; bytes > 0; bytes--, bitmap++)
|
||||
ret += hweight8(*bitmap);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* strlcat - Append a length-limited, %NUL-terminated string to another
|
||||
* @dest: The string to be appended to
|
||||
* @src: The string to append to it
|
||||
* @count: The size of the destination buffer.
|
||||
*/
|
||||
static inline size_t strlcat(char *dest, const char *src, size_t count)
|
||||
{
|
||||
size_t dsize = _strlen(dest);
|
||||
size_t len = _strlen(src);
|
||||
size_t res = dsize + len;
|
||||
|
||||
/* This would be a bug */
|
||||
//BUG_ON(dsize >= count);
|
||||
|
||||
dest += dsize;
|
||||
count -= dsize;
|
||||
if (len >= count)
|
||||
len = count-1;
|
||||
memcpy(dest, src, len);
|
||||
dest[len] = 0;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* atomic_dec_and_test - decrement and test
|
||||
* @v: pointer of type atomic_t
|
||||
*
|
||||
* Atomically decrements @v by 1 and
|
||||
* returns true if the result is 0, or false for all other
|
||||
* cases.
|
||||
*/
|
||||
static inline int atomic_dec_and_test(atomic_t *v)
|
||||
{
|
||||
atomic_dec(v);
|
||||
if (v->counter == 0)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* kcalloc - allocate memory for an array. The memory is set to zero.
|
||||
* @n: number of elements.
|
||||
* @size: element size.
|
||||
* @flags: the type of memory to allocate (see kmalloc).
|
||||
*/
|
||||
static inline void *kcalloc(size_t n, size_t size, gfp_t flags)
|
||||
{
|
||||
return RtlZmalloc(((n) * (size)));
|
||||
}
|
||||
|
||||
#ifndef GFP_ATOMIC
|
||||
#define GFP_ATOMIC GFP_KERNEL
|
||||
#endif
|
||||
#ifndef offsetof
|
||||
#define offsetof(s,m) (size_t)&(((s *)0)->m)
|
||||
#endif
|
||||
|
||||
//enum linux kernel version
|
||||
#ifndef KERNEL_VERSION
|
||||
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
|
||||
#endif
|
||||
#ifndef LINUX_VERSION_CODE
|
||||
#define LINUX_VERSION_CODE KERNEL_VERSION(3, 12, 0)
|
||||
#endif
|
||||
|
||||
#endif //_UVC_OSDEP_WRAP_H_
|
||||
|
|
@ -0,0 +1,774 @@
|
|||
#ifndef _USB_VIDEO_H_
|
||||
#define _USB_VIDEO_H_
|
||||
#if 0
|
||||
#ifndef __KERNEL__
|
||||
#error "The uvcvideo.h header is deprecated, use linux/uvcvideo.h instead."
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/poll.h>
|
||||
#endif
|
||||
|
||||
#include "usb.h"
|
||||
#include "video.h"
|
||||
#include "uvcvideo.h"
|
||||
|
||||
#include "videodev2.h"
|
||||
#include "media-device.h"
|
||||
#include "v4l2-device.h"
|
||||
#include "v4l2-event.h"
|
||||
#include "v4l2-fh.h"
|
||||
#include "videobuf2-core.h"
|
||||
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* UVC constants
|
||||
*/
|
||||
|
||||
#define UVC_TERM_INPUT 0x0000
|
||||
#define UVC_TERM_OUTPUT 0x8000
|
||||
#define UVC_TERM_DIRECTION(term) ((term)->type & 0x8000)
|
||||
|
||||
#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) \
|
||||
(UVC_ENTITY_IS_TERM(entity) && \
|
||||
((entity)->type & 0x8000) == UVC_TERM_INPUT)
|
||||
#define UVC_ENTITY_IS_OTERM(entity) \
|
||||
(UVC_ENTITY_IS_TERM(entity) && \
|
||||
((entity)->type & 0x8000) == UVC_TERM_OUTPUT)
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
* 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}
|
||||
#define UVC_GUID_FORMAT_YUY2_ISIGHT \
|
||||
{ 'Y', 'U', 'Y', '2', 0x00, 0x00, 0x10, 0x00, \
|
||||
0x80, 0x00, 0x00, 0x00, 0x00, 0x38, 0x9b, 0x71}
|
||||
#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, \
|
||||
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, \
|
||||
0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
|
||||
#define UVC_GUID_FORMAT_Y16 \
|
||||
{ 'Y', '1', '6', ' ', 0x00, 0x00, 0x10, 0x00, \
|
||||
0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
|
||||
#define UVC_GUID_FORMAT_BY8 \
|
||||
{ 'B', 'Y', '8', ' ', 0x00, 0x00, 0x10, 0x00, \
|
||||
0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
|
||||
#define UVC_GUID_FORMAT_RGBP \
|
||||
{ 'R', 'G', 'B', 'P', 0x00, 0x00, 0x10, 0x00, \
|
||||
0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
|
||||
#define UVC_GUID_FORMAT_M420 \
|
||||
{ 'M', '4', '2', '0', 0x00, 0x00, 0x10, 0x00, \
|
||||
0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
|
||||
|
||||
#define UVC_GUID_FORMAT_H264 \
|
||||
{ 'H', '2', '6', '4', 0x00, 0x00, 0x10, 0x00, \
|
||||
0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
|
||||
/* edit by Ian -- patch for GEO add two new guids*/
|
||||
#define UVC_GUID_FORMAT_MPEG \
|
||||
{ 'M', 'P', 'E', 'G', 0x00, 0x00, 0x10, 0x00, \
|
||||
0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
|
||||
#define UVC_GUID_FORMAT_MUX \
|
||||
{ 'M', 'U', 'X', 0x00, 0x00, 0x00, 0x10, 0x00, \
|
||||
0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
|
||||
/* ------------------------------------------------------------------------
|
||||
* Driver specific constants.
|
||||
*/
|
||||
|
||||
#define DRIVER_VERSION "1.1.1"
|
||||
|
||||
/* Number of isochronous URBs. */
|
||||
#define UVC_URBS 2
|
||||
/* Maximum number of packets per URB. */
|
||||
#define UVC_MAX_PACKETS 32
|
||||
/* Maximum number of video buffers. */
|
||||
#define UVC_MAX_VIDEO_BUFFERS 8
|
||||
/* Maximum status buffer size in bytes of interrupt URB. */
|
||||
#define UVC_MAX_STATUS_SIZE 16
|
||||
|
||||
//modified by Ian
|
||||
#define UVC_REQBUF_SIZE (150000)
|
||||
|
||||
#define UVC_CTRL_CONTROL_TIMEOUT 300
|
||||
#define UVC_CTRL_STREAMING_TIMEOUT 5000
|
||||
|
||||
/* Maximum allowed number of control mappings per device */
|
||||
#define UVC_MAX_CONTROL_MAPPINGS 1024
|
||||
#define UVC_MAX_CONTROL_MENU_ENTRIES 32
|
||||
|
||||
/* 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
|
||||
#define UVC_QUIRK_FIX_BANDWIDTH 0x00000080
|
||||
#define UVC_QUIRK_PROBE_DEF 0x00000100
|
||||
#define UVC_QUIRK_RESTRICT_FRAME_RATE 0x00000200
|
||||
|
||||
/* 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];
|
||||
__u8 index; /* Bit index in bmControls */
|
||||
__u8 selector;
|
||||
|
||||
__u16 size;
|
||||
__u32 flags;
|
||||
};
|
||||
|
||||
struct uvc_control_mapping {
|
||||
struct list_head list;
|
||||
struct list_head ev_subs;
|
||||
|
||||
__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;
|
||||
|
||||
__u32 master_id;
|
||||
__s32 master_manual;
|
||||
__u32 slave_ids[2];
|
||||
|
||||
__s32 (*get) (struct uvc_control_mapping *mapping, __u8 query,
|
||||
const __u8 *data);
|
||||
void (*set) (struct uvc_control_mapping *mapping, __s32 value,
|
||||
__u8 *data);
|
||||
};
|
||||
|
||||
struct uvc_control {
|
||||
struct uvc_entity *entity;
|
||||
struct uvc_control_info info;
|
||||
|
||||
__u8 index; /* Used to match the uvc_control entry with a
|
||||
uvc_control_info. */
|
||||
__u8 dirty:1,
|
||||
loaded:1,
|
||||
modified:1,
|
||||
cached:1,
|
||||
initialized:1;
|
||||
|
||||
__u8 *uvc_data;
|
||||
};
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#define UVC_ENTITY_FLAG_DEFAULT (1 << 0)
|
||||
|
||||
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. */
|
||||
unsigned int flags;
|
||||
|
||||
__u8 id;
|
||||
__u16 type;
|
||||
char name[64];
|
||||
|
||||
/* Media controller-related fields. */
|
||||
struct video_device *vdev;
|
||||
struct v4l2_subdev subdev;
|
||||
unsigned int num_pads;
|
||||
unsigned int num_links;
|
||||
struct media_pad *pads;
|
||||
|
||||
union {
|
||||
struct {
|
||||
__u16 wObjectiveFocalLengthMin;
|
||||
__u16 wObjectiveFocalLengthMax;
|
||||
__u16 wOcularFocalLength;
|
||||
__u8 bControlSize;
|
||||
__u8 *bmControls;
|
||||
} camera;
|
||||
|
||||
struct {
|
||||
__u8 bControlSize;
|
||||
__u8 *bmControls;
|
||||
__u8 bTransportModeSize;
|
||||
__u8 *bmTransportModes;
|
||||
} media;
|
||||
#if 0
|
||||
struct {
|
||||
} output;
|
||||
#endif
|
||||
struct {
|
||||
__u16 wMaxMultiplier;
|
||||
__u8 bControlSize;
|
||||
__u8 *bmControls;
|
||||
__u8 bmVideoStandards;
|
||||
} processing;
|
||||
#if 0
|
||||
struct {
|
||||
} selector;
|
||||
#endif
|
||||
struct {
|
||||
__u8 guidExtensionCode[16];
|
||||
__u8 bNumControls;
|
||||
__u8 bControlSize;
|
||||
__u8 *bmControls;
|
||||
__u8 *bmControlsType;
|
||||
} extension;
|
||||
};
|
||||
|
||||
__u8 bNrInPins;
|
||||
__u8 *baSourceID;
|
||||
|
||||
unsigned int ncontrols;
|
||||
struct uvc_control *controls;
|
||||
};
|
||||
|
||||
// total (27)-> 28 Bytes
|
||||
struct uvc_frame {
|
||||
__u8 bFrameIndex;
|
||||
__u8 bmCapabilities;
|
||||
__u16 wWidth;
|
||||
__u16 wHeight;
|
||||
__u32 dwMinBitRate;
|
||||
__u32 dwMaxBitRate;
|
||||
__u32 dwMaxVideoFrameBufferSize;
|
||||
__u8 bFrameIntervalType;
|
||||
__u32 dwDefaultFrameInterval;
|
||||
__u32 *dwFrameInterval;
|
||||
};
|
||||
|
||||
// total 52 Bytes
|
||||
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 {
|
||||
UVC_BUF_STATE_IDLE = 0,
|
||||
UVC_BUF_STATE_QUEUED = 1,
|
||||
UVC_BUF_STATE_ACTIVE = 2,
|
||||
UVC_BUF_STATE_READY = 3,
|
||||
UVC_BUF_STATE_DONE = 4,
|
||||
UVC_BUF_STATE_ERROR = 5,
|
||||
};
|
||||
|
||||
struct uvc_buffer {
|
||||
struct vb2_buffer buf;
|
||||
struct list_head queue;
|
||||
_Mutex mutex;
|
||||
enum uvc_buffer_state state;
|
||||
unsigned int error;
|
||||
|
||||
void *mem;
|
||||
unsigned int length;
|
||||
unsigned int bytesused;
|
||||
|
||||
u32 pts;
|
||||
};
|
||||
|
||||
#define UVC_QUEUE_DISCONNECTED (1 << 0)
|
||||
#define UVC_QUEUE_DROP_CORRUPTED (1 << 1)
|
||||
|
||||
struct uvc_video_queue {
|
||||
struct vb2_queue queue;
|
||||
//struct mutex mutex; /* Protects queue */
|
||||
_Mutex mutex;
|
||||
unsigned int flags;
|
||||
unsigned int buf_used;
|
||||
|
||||
//spinlock_t irqlock; /* Protects irqqueue */
|
||||
//_LOCK_T irqlock;
|
||||
_Mutex irqlock;
|
||||
struct list_head irqqueue;
|
||||
};
|
||||
|
||||
struct uvc_video_chain {
|
||||
struct uvc_device *dev;
|
||||
struct list_head list;
|
||||
|
||||
struct list_head entities; /* All entities */
|
||||
struct uvc_entity *processing; /* Processing unit */
|
||||
struct uvc_entity *selector; /* Selector unit */
|
||||
|
||||
//struct mutex ctrl_mutex; /* Protects ctrl.info */
|
||||
_Mutex ctrl_mutex;
|
||||
|
||||
struct v4l2_prio_state prio; /* V4L2 priority state */
|
||||
u32 caps; /* V4L2 chain-wide caps */
|
||||
};
|
||||
|
||||
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 */
|
||||
|
||||
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 */
|
||||
};
|
||||
|
||||
struct uvc_stats_stream {
|
||||
//struct timespec start_ts; /* Stream start timestamp */
|
||||
//struct timespec stop_ts; /* Stream stop timestamp */
|
||||
u32 start_ts;
|
||||
u32 stop_ts;
|
||||
|
||||
|
||||
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 */
|
||||
|
||||
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 */
|
||||
};
|
||||
|
||||
struct uvc_streaming {
|
||||
struct list_head list;
|
||||
struct uvc_device *dev;
|
||||
struct video_device *vdev;
|
||||
struct uvc_video_chain *chain;
|
||||
atomic_t active;
|
||||
|
||||
struct usb_interface *intf;
|
||||
int intfnum;
|
||||
__u16 maxpsize;
|
||||
|
||||
struct uvc_streaming_header header;
|
||||
enum v4l2_buf_type type;
|
||||
|
||||
unsigned int nformats;
|
||||
struct uvc_format *format;
|
||||
|
||||
struct uvc_streaming_control ctrl;
|
||||
struct uvc_format *def_format;
|
||||
struct uvc_format *cur_format;
|
||||
struct uvc_frame *cur_frame;
|
||||
/* Protect access to ctrl, cur_format, cur_frame and hardware video
|
||||
* probe control.
|
||||
*/
|
||||
//struct mutex mutex;
|
||||
_Mutex mutex;
|
||||
|
||||
/* Buffers queue. */
|
||||
unsigned int frozen : 1;
|
||||
struct uvc_video_queue queue;
|
||||
void (*decode) (struct urb *urb, struct uvc_streaming *video,
|
||||
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];
|
||||
dma_addr_t urb_dma[UVC_URBS];
|
||||
unsigned int urb_size;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
__u32 sequence;
|
||||
__u8 last_fid;
|
||||
|
||||
/* debugfs */
|
||||
//struct dentry *debugfs_dir;
|
||||
struct {
|
||||
struct uvc_stats_frame frame;
|
||||
struct uvc_stats_stream stream;
|
||||
} stats;
|
||||
|
||||
/* Timestamps support. */
|
||||
struct uvc_clock {
|
||||
struct uvc_clock_sample {
|
||||
u32 dev_stc;
|
||||
u16 dev_sof;
|
||||
//struct timespec host_ts;
|
||||
u32 host_ts; //change to tick
|
||||
u16 host_sof;
|
||||
} *samples;
|
||||
|
||||
unsigned int head;
|
||||
unsigned int count;
|
||||
unsigned int size;
|
||||
|
||||
u16 last_sof;
|
||||
u16 sof_offset;
|
||||
|
||||
//spinlock_t lock;
|
||||
_Lock lock;
|
||||
} clock;
|
||||
};
|
||||
|
||||
enum uvc_device_state {
|
||||
UVC_DEV_DISCONNECTED = 1,
|
||||
};
|
||||
|
||||
struct uvc_device {
|
||||
struct usb_device *udev;
|
||||
struct usb_interface *intf;
|
||||
unsigned long warnings;
|
||||
__u32 quirks;
|
||||
int intfnum;
|
||||
char name[32];
|
||||
|
||||
enum uvc_device_state state;
|
||||
//struct mutex lock; /* Protects users */
|
||||
_Mutex lock;
|
||||
unsigned int users;
|
||||
atomic_t nmappings;
|
||||
|
||||
/* Video control interface */
|
||||
#ifdef CONFIG_MEDIA_CONTROLLER
|
||||
struct media_device mdev;
|
||||
#endif
|
||||
struct v4l2_device vdev;
|
||||
__u16 uvc_version;
|
||||
__u32 clock_frequency;
|
||||
|
||||
struct list_head entities; // VC_EXTENSION_UNIT ->VC_INPUT_TERMINAL ->VC_PROCESSING_UNIT ->VC_OUTPUT_TERMINAL
|
||||
struct list_head chains;
|
||||
|
||||
/* Video Streaming interfaces */
|
||||
struct list_head streams;
|
||||
atomic_t nstreams;
|
||||
|
||||
/* Status Interrupt Endpoint */
|
||||
struct usb_host_endpoint *int_ep;
|
||||
struct urb *int_urb;
|
||||
__u8 *status;
|
||||
//struct input_dev *input;
|
||||
char input_phys[64];
|
||||
};
|
||||
|
||||
enum uvc_handle_state {
|
||||
UVC_HANDLE_PASSIVE = 0,
|
||||
UVC_HANDLE_ACTIVE = 1,
|
||||
};
|
||||
|
||||
/* uvc file handle */
|
||||
struct uvc_fh {
|
||||
struct v4l2_fh vfh;
|
||||
struct uvc_video_chain *chain;
|
||||
struct uvc_streaming *stream;
|
||||
enum uvc_handle_state state;
|
||||
};
|
||||
#if 0
|
||||
/* uvc_driver = usb_driver for interface
|
||||
* - identifies USB interface driver to usbcore
|
||||
*/
|
||||
struct uvc_driver {
|
||||
struct usb_driver driver;
|
||||
};
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
* 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_IOCTL (1 << 6)
|
||||
#define UVC_TRACE_FRAME (1 << 7)
|
||||
#define UVC_TRACE_SUSPEND (1 << 8)
|
||||
#define UVC_TRACE_STATUS (1 << 9)
|
||||
#define UVC_TRACE_VIDEO (1 << 10)
|
||||
#define UVC_TRACE_STATS (1 << 11)
|
||||
#define UVC_TRACE_CLOCK (1 << 12)
|
||||
|
||||
#define UVC_WARN_MINMAX 0
|
||||
#define UVC_WARN_PROBE_DEF 1
|
||||
#define UVC_WARN_XU_GET_RES 2
|
||||
|
||||
extern unsigned int uvc_clock_param;
|
||||
extern unsigned int uvc_no_drop_param;
|
||||
extern unsigned int uvc_trace_param;
|
||||
extern unsigned int uvc_timeout_param;
|
||||
|
||||
#if 0
|
||||
#define uvc_trace(flag, msg...) \
|
||||
do { \
|
||||
if (uvc_trace_param & flag) \
|
||||
printk(KERN_DEBUG "uvcvideo: " msg); \
|
||||
} while (0)
|
||||
|
||||
#define uvc_warn_once(dev, warn, msg...) \
|
||||
do { \
|
||||
if (!test_and_set_bit(warn, &dev->warnings)) \
|
||||
printk(KERN_INFO "uvcvideo: " msg); \
|
||||
} while (0)
|
||||
|
||||
#define uvc_printk(level, msg...) \
|
||||
printk(level "uvcvideo: " msg)
|
||||
#endif
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* Internal functions.
|
||||
*/
|
||||
|
||||
/* Core driver */
|
||||
extern struct uvc_driver uvc_driver;
|
||||
|
||||
extern struct uvc_entity *uvc_entity_by_id(struct uvc_device *dev, int id);
|
||||
|
||||
/* Video buffers queue management. */
|
||||
extern int uvc_queue_init(struct uvc_video_queue *queue,
|
||||
enum v4l2_buf_type type, int drop_corrupted);
|
||||
extern int uvc_alloc_buffers(struct uvc_video_queue *queue,
|
||||
struct v4l2_requestbuffers *rb);
|
||||
extern void uvc_free_buffers(struct uvc_video_queue *queue);
|
||||
extern int uvc_query_buffer(struct uvc_video_queue *queue,
|
||||
struct v4l2_buffer *v4l2_buf);
|
||||
extern int uvc_queue_buffer(struct uvc_video_queue *queue,
|
||||
struct v4l2_buffer *v4l2_buf);
|
||||
extern int uvc_dequeue_buffer(struct uvc_video_queue *queue,
|
||||
struct v4l2_buffer *v4l2_buf, int nonblocking);
|
||||
extern int uvc_queue_enable(struct uvc_video_queue *queue, int enable);
|
||||
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);
|
||||
extern int uvc_queue_mmap(struct uvc_video_queue *queue);
|
||||
#if 0
|
||||
extern unsigned int uvc_queue_poll(struct uvc_video_queue *queue,
|
||||
struct file *file, poll_table *wait);
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_MMU
|
||||
extern unsigned long uvc_queue_get_unmapped_area(struct uvc_video_queue *queue,
|
||||
unsigned long pgoff);
|
||||
#endif
|
||||
|
||||
extern int uvc_queue_allocated(struct uvc_video_queue *queue);
|
||||
static inline int uvc_queue_streaming(struct uvc_video_queue *queue)
|
||||
{
|
||||
return vb2_is_streaming(&queue->queue);
|
||||
}
|
||||
|
||||
/* V4L2 interface */
|
||||
extern const struct v4l2_file_operations uvc_fops;
|
||||
|
||||
/* Media controller */
|
||||
extern int uvc_mc_register_entities(struct uvc_video_chain *chain);
|
||||
extern void uvc_mc_cleanup_entity(struct uvc_entity *entity);
|
||||
|
||||
/* Video */
|
||||
extern int uvc_video_init(struct uvc_streaming *stream);
|
||||
extern int uvc_video_suspend(struct uvc_streaming *stream);
|
||||
extern int uvc_video_resume(struct uvc_streaming *stream, int reset);
|
||||
extern int uvc_video_enable(struct uvc_streaming *stream, int enable);
|
||||
extern int uvc_probe_video(struct uvc_streaming *stream,
|
||||
struct uvc_streaming_control *probe);
|
||||
/* edit by Ian -- patch for GEO */
|
||||
extern int uvc_commit_video(struct uvc_streaming *stream,
|
||||
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);
|
||||
/* edit by Ian -- disable uvc clock api*/
|
||||
#if 0
|
||||
void uvc_video_clock_update(struct uvc_streaming *stream,
|
||||
struct v4l2_buffer *v4l2_buf,
|
||||
struct uvc_buffer *buf);
|
||||
#endif
|
||||
/* Status */
|
||||
//#define UVC_STATUS_EN
|
||||
#ifdef UVC_STATUS_EN
|
||||
extern int uvc_status_init(struct uvc_device *dev);
|
||||
extern void uvc_status_cleanup(struct uvc_device *dev);
|
||||
extern int uvc_status_start(struct uvc_device *dev, gfp_t flags);
|
||||
extern void uvc_status_stop(struct uvc_device *dev);
|
||||
#endif
|
||||
|
||||
/* Controls */
|
||||
extern const struct v4l2_subscribed_event_ops uvc_ctrl_sub_ev_ops;
|
||||
|
||||
extern int uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
|
||||
struct v4l2_queryctrl *v4l2_ctrl);
|
||||
extern int uvc_query_v4l2_menu(struct uvc_video_chain *chain,
|
||||
struct v4l2_querymenu *query_menu);
|
||||
|
||||
extern int uvc_ctrl_add_mapping(struct uvc_video_chain *chain,
|
||||
const struct uvc_control_mapping *mapping);
|
||||
extern int uvc_ctrl_init_device(struct uvc_device *dev);
|
||||
extern void uvc_ctrl_cleanup_device(struct uvc_device *dev);
|
||||
extern int uvc_ctrl_resume_device(struct uvc_device *dev);
|
||||
extern int uvc_ctrl_begin(struct uvc_video_chain *chain);
|
||||
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)
|
||||
{
|
||||
return __uvc_ctrl_commit(handle, 0, xctrls, xctrls_count);
|
||||
}
|
||||
static inline int uvc_ctrl_rollback(struct uvc_fh *handle)
|
||||
{
|
||||
return __uvc_ctrl_commit(handle, 1, NULL, 0);
|
||||
}
|
||||
|
||||
extern int uvc_ctrl_get(struct uvc_video_chain *chain,
|
||||
struct v4l2_ext_control *xctrl);
|
||||
extern int uvc_ctrl_set(struct uvc_video_chain *chain,
|
||||
struct v4l2_ext_control *xctrl);
|
||||
|
||||
//edit by Ian -- remove uvc_xu_ctrl_query declaration
|
||||
//extern int uvc_xu_ctrl_query(struct uvc_video_chain *chain, struct uvc_xu_control_query *xqry);
|
||||
|
||||
/* 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 */
|
||||
void uvc_video_decode_isight(struct urb *urb, struct uvc_streaming *stream,
|
||||
struct uvc_buffer *buf);
|
||||
|
||||
/* debugfs and statistics */
|
||||
#if 0
|
||||
int uvc_debugfs_init(void);
|
||||
void uvc_debugfs_cleanup(void);
|
||||
int uvc_debugfs_init_stream(struct uvc_streaming *stream);
|
||||
void uvc_debugfs_cleanup_stream(struct uvc_streaming *stream);
|
||||
|
||||
size_t uvc_video_stats_dump(struct uvc_streaming *stream, char *buf,
|
||||
size_t size);
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,726 @@
|
|||
/*
|
||||
* USB Video Class definitions.
|
||||
*
|
||||
* Copyright (C) 2009 Laurent Pinchart <laurent.pinchart@skynet.be>
|
||||
*
|
||||
* This file holds USB constants and structures defined by the USB Device
|
||||
* Class Definition for Video Devices. Unless otherwise stated, comments
|
||||
* below reference relevant sections of the USB Video Class 1.1 specification
|
||||
* available at
|
||||
*
|
||||
* http://www.usb.org/developers/devclass_docs/USB_Video_Class_1_1.zip
|
||||
*/
|
||||
|
||||
#ifndef __LINUX_USB_VIDEO_H
|
||||
#define __LINUX_USB_VIDEO_H
|
||||
#if 0
|
||||
#include <linux/types.h>
|
||||
#endif
|
||||
#include "uvc_os_wrap_via_osdep_api.h"
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* UVC constants
|
||||
*/
|
||||
|
||||
/* A.2. Video Interface Subclass Codes */
|
||||
#define UVC_SC_UNDEFINED 0x00
|
||||
#define UVC_SC_VIDEOCONTROL 0x01
|
||||
#define UVC_SC_VIDEOSTREAMING 0x02
|
||||
#define UVC_SC_VIDEO_INTERFACE_COLLECTION 0x03
|
||||
|
||||
/* A.3. Video Interface Protocol Codes */
|
||||
#define UVC_PC_PROTOCOL_UNDEFINED 0x00
|
||||
|
||||
/* A.5. Video Class-Specific VC Interface Descriptor Subtypes */
|
||||
#define UVC_VC_DESCRIPTOR_UNDEFINED 0x00
|
||||
#define UVC_VC_HEADER 0x01
|
||||
#define UVC_VC_INPUT_TERMINAL 0x02
|
||||
#define UVC_VC_OUTPUT_TERMINAL 0x03
|
||||
#define UVC_VC_SELECTOR_UNIT 0x04
|
||||
#define UVC_VC_PROCESSING_UNIT 0x05
|
||||
#define UVC_VC_EXTENSION_UNIT 0x06
|
||||
|
||||
/* A.6. Video Class-Specific VS Interface Descriptor Subtypes */
|
||||
#define UVC_VS_UNDEFINED 0x00
|
||||
#define UVC_VS_INPUT_HEADER 0x01
|
||||
#define UVC_VS_OUTPUT_HEADER 0x02
|
||||
#define UVC_VS_STILL_IMAGE_FRAME 0x03
|
||||
#define UVC_VS_FORMAT_UNCOMPRESSED 0x04
|
||||
#define UVC_VS_FRAME_UNCOMPRESSED 0x05
|
||||
#define UVC_VS_FORMAT_MJPEG 0x06
|
||||
#define UVC_VS_FRAME_MJPEG 0x07
|
||||
#define UVC_VS_FORMAT_MPEG2TS 0x0a
|
||||
#define UVC_VS_FORMAT_DV 0x0c
|
||||
#define UVC_VS_COLORFORMAT 0x0d
|
||||
#define UVC_VS_FORMAT_FRAME_BASED 0x10
|
||||
#define UVC_VS_FRAME_FRAME_BASED 0x11
|
||||
#define UVC_VS_FORMAT_STREAM_BASED 0x12
|
||||
|
||||
/* A.7. Video Class-Specific Endpoint Descriptor Subtypes */
|
||||
#define UVC_EP_UNDEFINED 0x00
|
||||
#define UVC_EP_GENERAL 0x01
|
||||
#define UVC_EP_ENDPOINT 0x02
|
||||
#define UVC_EP_INTERRUPT 0x03
|
||||
|
||||
/* A.8. Video Class-Specific Request Codes */
|
||||
#define UVC_RC_UNDEFINED 0x00
|
||||
#define UVC_SET_CUR 0x01
|
||||
#define UVC_GET_CUR 0x81
|
||||
#define UVC_GET_MIN 0x82
|
||||
#define UVC_GET_MAX 0x83
|
||||
#define UVC_GET_RES 0x84
|
||||
#define UVC_GET_LEN 0x85
|
||||
#define UVC_GET_INFO 0x86
|
||||
#define UVC_GET_DEF 0x87
|
||||
|
||||
/* A.9.1. VideoControl Interface Control Selectors */
|
||||
#define UVC_VC_CONTROL_UNDEFINED 0x00
|
||||
#define UVC_VC_VIDEO_POWER_MODE_CONTROL 0x01
|
||||
#define UVC_VC_REQUEST_ERROR_CODE_CONTROL 0x02
|
||||
|
||||
/* A.9.2. Terminal Control Selectors */
|
||||
#define UVC_TE_CONTROL_UNDEFINED 0x00
|
||||
|
||||
/* A.9.3. Selector Unit Control Selectors */
|
||||
#define UVC_SU_CONTROL_UNDEFINED 0x00
|
||||
#define UVC_SU_INPUT_SELECT_CONTROL 0x01
|
||||
|
||||
/* A.9.4. Camera Terminal Control Selectors */
|
||||
#define UVC_CT_CONTROL_UNDEFINED 0x00
|
||||
#define UVC_CT_SCANNING_MODE_CONTROL 0x01
|
||||
#define UVC_CT_AE_MODE_CONTROL 0x02
|
||||
#define UVC_CT_AE_PRIORITY_CONTROL 0x03
|
||||
#define UVC_CT_EXPOSURE_TIME_ABSOLUTE_CONTROL 0x04
|
||||
#define UVC_CT_EXPOSURE_TIME_RELATIVE_CONTROL 0x05
|
||||
#define UVC_CT_FOCUS_ABSOLUTE_CONTROL 0x06
|
||||
#define UVC_CT_FOCUS_RELATIVE_CONTROL 0x07
|
||||
#define UVC_CT_FOCUS_AUTO_CONTROL 0x08
|
||||
#define UVC_CT_IRIS_ABSOLUTE_CONTROL 0x09
|
||||
#define UVC_CT_IRIS_RELATIVE_CONTROL 0x0a
|
||||
#define UVC_CT_ZOOM_ABSOLUTE_CONTROL 0x0b
|
||||
#define UVC_CT_ZOOM_RELATIVE_CONTROL 0x0c
|
||||
#define UVC_CT_PANTILT_ABSOLUTE_CONTROL 0x0d
|
||||
#define UVC_CT_PANTILT_RELATIVE_CONTROL 0x0e
|
||||
#define UVC_CT_ROLL_ABSOLUTE_CONTROL 0x0f
|
||||
#define UVC_CT_ROLL_RELATIVE_CONTROL 0x10
|
||||
#define UVC_CT_PRIVACY_CONTROL 0x11
|
||||
|
||||
/* A.9.5. Processing Unit Control Selectors */
|
||||
#define UVC_PU_CONTROL_UNDEFINED 0x00
|
||||
#define UVC_PU_BACKLIGHT_COMPENSATION_CONTROL 0x01
|
||||
#define UVC_PU_BRIGHTNESS_CONTROL 0x02
|
||||
#define UVC_PU_CONTRAST_CONTROL 0x03
|
||||
#define UVC_PU_GAIN_CONTROL 0x04
|
||||
#define UVC_PU_POWER_LINE_FREQUENCY_CONTROL 0x05
|
||||
#define UVC_PU_HUE_CONTROL 0x06
|
||||
#define UVC_PU_SATURATION_CONTROL 0x07
|
||||
#define UVC_PU_SHARPNESS_CONTROL 0x08
|
||||
#define UVC_PU_GAMMA_CONTROL 0x09
|
||||
#define UVC_PU_WHITE_BALANCE_TEMPERATURE_CONTROL 0x0a
|
||||
#define UVC_PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL 0x0b
|
||||
#define UVC_PU_WHITE_BALANCE_COMPONENT_CONTROL 0x0c
|
||||
#define UVC_PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL 0x0d
|
||||
#define UVC_PU_DIGITAL_MULTIPLIER_CONTROL 0x0e
|
||||
#define UVC_PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL 0x0f
|
||||
#define UVC_PU_HUE_AUTO_CONTROL 0x10
|
||||
#define UVC_PU_ANALOG_VIDEO_STANDARD_CONTROL 0x11
|
||||
#define UVC_PU_ANALOG_LOCK_STATUS_CONTROL 0x12
|
||||
|
||||
/* A.9.7. VideoStreaming Interface Control Selectors */
|
||||
#define UVC_VS_CONTROL_UNDEFINED 0x00
|
||||
#define UVC_VS_PROBE_CONTROL 0x01
|
||||
#define UVC_VS_COMMIT_CONTROL 0x02
|
||||
#define UVC_VS_STILL_PROBE_CONTROL 0x03
|
||||
#define UVC_VS_STILL_COMMIT_CONTROL 0x04
|
||||
#define UVC_VS_STILL_IMAGE_TRIGGER_CONTROL 0x05
|
||||
#define UVC_VS_STREAM_ERROR_CODE_CONTROL 0x06
|
||||
#define UVC_VS_GENERATE_KEY_FRAME_CONTROL 0x07
|
||||
#define UVC_VS_UPDATE_FRAME_SEGMENT_CONTROL 0x08
|
||||
#define UVC_VS_SYNC_DELAY_CONTROL 0x09
|
||||
|
||||
/* B.1. USB Terminal Types */
|
||||
#define UVC_TT_VENDOR_SPECIFIC 0x0100
|
||||
#define UVC_TT_STREAMING 0x0101
|
||||
|
||||
/* B.2. Input Terminal Types */
|
||||
#define UVC_ITT_VENDOR_SPECIFIC 0x0200
|
||||
#define UVC_ITT_CAMERA 0x0201
|
||||
#define UVC_ITT_MEDIA_TRANSPORT_INPUT 0x0202
|
||||
|
||||
/* B.3. Output Terminal Types */
|
||||
#define UVC_OTT_VENDOR_SPECIFIC 0x0300
|
||||
#define UVC_OTT_DISPLAY 0x0301
|
||||
#define UVC_OTT_MEDIA_TRANSPORT_OUTPUT 0x0302
|
||||
|
||||
/* B.4. External Terminal Types */
|
||||
#define UVC_EXTERNAL_VENDOR_SPECIFIC 0x0400
|
||||
#define UVC_COMPOSITE_CONNECTOR 0x0401
|
||||
#define UVC_SVIDEO_CONNECTOR 0x0402
|
||||
#define UVC_COMPONENT_CONNECTOR 0x0403
|
||||
|
||||
/* 2.4.2.2. Status Packet Type */
|
||||
#define UVC_STATUS_TYPE_CONTROL 1
|
||||
#define UVC_STATUS_TYPE_STREAMING 2
|
||||
|
||||
/* 2.4.3.3. Payload Header Information */
|
||||
#define UVC_STREAM_EOH (1 << 7)
|
||||
#define UVC_STREAM_ERR (1 << 6)
|
||||
#define UVC_STREAM_STI (1 << 5)
|
||||
#define UVC_STREAM_RES (1 << 4)
|
||||
#define UVC_STREAM_SCR (1 << 3)
|
||||
#define UVC_STREAM_PTS (1 << 2)
|
||||
#define UVC_STREAM_EOF (1 << 1)
|
||||
#define UVC_STREAM_FID (1 << 0)
|
||||
|
||||
/* 4.1.2. Control Capabilities */
|
||||
#define UVC_CONTROL_CAP_GET (1 << 0)
|
||||
#define UVC_CONTROL_CAP_SET (1 << 1)
|
||||
#define UVC_CONTROL_CAP_DISABLED (1 << 2)
|
||||
#define UVC_CONTROL_CAP_AUTOUPDATE (1 << 3)
|
||||
#define UVC_CONTROL_CAP_ASYNCHRONOUS (1 << 4)
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
* UVC structures
|
||||
*/
|
||||
|
||||
/* All UVC descriptors have these 3 fields at the beginning */
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_begin.h"
|
||||
#endif
|
||||
RTW_PACK_STRUCT_BEGIN
|
||||
struct uvc_descriptor_header {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubType;
|
||||
} //__attribute__((packed));
|
||||
RTW_PACK_STRUCT_STRUCT;
|
||||
RTW_PACK_STRUCT_END
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_end.h"
|
||||
#endif
|
||||
|
||||
/* 3.7.2. Video Control Interface Header Descriptor */
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_begin.h"
|
||||
#endif
|
||||
RTW_PACK_STRUCT_BEGIN
|
||||
struct uvc_header_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubType;
|
||||
__u16 bcdUVC;
|
||||
__u16 wTotalLength;
|
||||
__u32 dwClockFrequency;
|
||||
__u8 bInCollection;
|
||||
__u8 baInterfaceNr[];
|
||||
} //__attribute__((__packed__));
|
||||
RTW_PACK_STRUCT_STRUCT;
|
||||
RTW_PACK_STRUCT_END
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_end.h"
|
||||
#endif
|
||||
|
||||
#define UVC_DT_HEADER_SIZE(n) (12+(n))
|
||||
|
||||
#define UVC_HEADER_DESCRIPTOR(n) \
|
||||
uvc_header_descriptor_##n
|
||||
|
||||
#define DECLARE_UVC_HEADER_DESCRIPTOR(n) \
|
||||
struct UVC_HEADER_DESCRIPTOR(n) { \
|
||||
__u8 bLength; \
|
||||
__u8 bDescriptorType; \
|
||||
__u8 bDescriptorSubType; \
|
||||
__u16 bcdUVC; \
|
||||
__u16 wTotalLength; \
|
||||
__u32 dwClockFrequency; \
|
||||
__u8 bInCollection; \
|
||||
__u8 baInterfaceNr[n]; \
|
||||
} __attribute__ ((packed))
|
||||
|
||||
/* 3.7.2.1. Input Terminal Descriptor */
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_begin.h"
|
||||
#endif
|
||||
RTW_PACK_STRUCT_BEGIN
|
||||
struct uvc_input_terminal_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubType;
|
||||
__u8 bTerminalID;
|
||||
__u16 wTerminalType;
|
||||
__u8 bAssocTerminal;
|
||||
__u8 iTerminal;
|
||||
} //__attribute__((__packed__));
|
||||
RTW_PACK_STRUCT_STRUCT;
|
||||
RTW_PACK_STRUCT_END
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_end.h"
|
||||
#endif
|
||||
|
||||
#define UVC_DT_INPUT_TERMINAL_SIZE 8
|
||||
|
||||
/* 3.7.2.2. Output Terminal Descriptor */
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_begin.h"
|
||||
#endif
|
||||
RTW_PACK_STRUCT_BEGIN
|
||||
struct uvc_output_terminal_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubType;
|
||||
__u8 bTerminalID;
|
||||
__u16 wTerminalType;
|
||||
__u8 bAssocTerminal;
|
||||
__u8 bSourceID;
|
||||
__u8 iTerminal;
|
||||
} //__attribute__((__packed__));
|
||||
RTW_PACK_STRUCT_STRUCT;
|
||||
RTW_PACK_STRUCT_END
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_end.h"
|
||||
#endif
|
||||
|
||||
#define UVC_DT_OUTPUT_TERMINAL_SIZE 9
|
||||
|
||||
/* 3.7.2.3. Camera Terminal Descriptor */
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_begin.h"
|
||||
#endif
|
||||
RTW_PACK_STRUCT_BEGIN
|
||||
struct uvc_camera_terminal_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubType;
|
||||
__u8 bTerminalID;
|
||||
__u16 wTerminalType;
|
||||
__u8 bAssocTerminal;
|
||||
__u8 iTerminal;
|
||||
__u16 wObjectiveFocalLengthMin;
|
||||
__u16 wObjectiveFocalLengthMax;
|
||||
__u16 wOcularFocalLength;
|
||||
__u8 bControlSize;
|
||||
__u8 bmControls[3];
|
||||
} //__attribute__((__packed__));
|
||||
RTW_PACK_STRUCT_STRUCT;
|
||||
RTW_PACK_STRUCT_END
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_end.h"
|
||||
#endif
|
||||
|
||||
#define UVC_DT_CAMERA_TERMINAL_SIZE(n) (15+(n))
|
||||
|
||||
/* 3.7.2.4. Selector Unit Descriptor */
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_begin.h"
|
||||
#endif
|
||||
RTW_PACK_STRUCT_BEGIN
|
||||
struct uvc_selector_unit_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubType;
|
||||
__u8 bUnitID;
|
||||
__u8 bNrInPins;
|
||||
// __u8 baSourceID[0];
|
||||
__u8 * baSourceID;
|
||||
__u8 iSelector;
|
||||
} //__attribute__((__packed__));
|
||||
RTW_PACK_STRUCT_STRUCT;
|
||||
RTW_PACK_STRUCT_END
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_end.h"
|
||||
#endif
|
||||
|
||||
#define UVC_DT_SELECTOR_UNIT_SIZE(n) (6+(n))
|
||||
|
||||
#define UVC_SELECTOR_UNIT_DESCRIPTOR(n) \
|
||||
uvc_selector_unit_descriptor_##n
|
||||
|
||||
#define DECLARE_UVC_SELECTOR_UNIT_DESCRIPTOR(n) \
|
||||
struct UVC_SELECTOR_UNIT_DESCRIPTOR(n) { \
|
||||
__u8 bLength; \
|
||||
__u8 bDescriptorType; \
|
||||
__u8 bDescriptorSubType; \
|
||||
__u8 bUnitID; \
|
||||
__u8 bNrInPins; \
|
||||
__u8 baSourceID[n]; \
|
||||
__u8 iSelector; \
|
||||
} __attribute__ ((packed))
|
||||
|
||||
/* 3.7.2.5. Processing Unit Descriptor */
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_begin.h"
|
||||
#endif
|
||||
RTW_PACK_STRUCT_BEGIN
|
||||
struct uvc_processing_unit_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubType;
|
||||
__u8 bUnitID;
|
||||
__u8 bSourceID;
|
||||
__u16 wMaxMultiplier;
|
||||
__u8 bControlSize;
|
||||
__u8 bmControls[2];
|
||||
__u8 iProcessing;
|
||||
} //__attribute__((__packed__));
|
||||
RTW_PACK_STRUCT_STRUCT;
|
||||
RTW_PACK_STRUCT_END
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_end.h"
|
||||
#endif
|
||||
|
||||
#define UVC_DT_PROCESSING_UNIT_SIZE(n) (9+(n))
|
||||
|
||||
/* 3.7.2.6. Extension Unit Descriptor */
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_begin.h"
|
||||
#endif
|
||||
RTW_PACK_STRUCT_BEGIN
|
||||
struct uvc_extension_unit_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubType;
|
||||
__u8 bUnitID;
|
||||
__u8 guidExtensionCode[16];
|
||||
__u8 bNumControls;
|
||||
__u8 bNrInPins;
|
||||
// __u8 baSourceID[0];
|
||||
__u8 * baSourceID;
|
||||
__u8 bControlSize;
|
||||
// __u8 bmControls[0];
|
||||
__u8 * bmControls;
|
||||
__u8 iExtension;
|
||||
} //__attribute__((__packed__));
|
||||
RTW_PACK_STRUCT_STRUCT;
|
||||
RTW_PACK_STRUCT_END
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_end.h"
|
||||
#endif
|
||||
|
||||
#define UVC_DT_EXTENSION_UNIT_SIZE(p, n) (24+(p)+(n))
|
||||
|
||||
#define UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) \
|
||||
uvc_extension_unit_descriptor_##p_##n
|
||||
|
||||
#define DECLARE_UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) \
|
||||
struct UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) { \
|
||||
__u8 bLength; \
|
||||
__u8 bDescriptorType; \
|
||||
__u8 bDescriptorSubType; \
|
||||
__u8 bUnitID; \
|
||||
__u8 guidExtensionCode[16]; \
|
||||
__u8 bNumControls; \
|
||||
__u8 bNrInPins; \
|
||||
__u8 baSourceID[p]; \
|
||||
__u8 bControlSize; \
|
||||
__u8 bmControls[n]; \
|
||||
__u8 iExtension; \
|
||||
} __attribute__ ((packed))
|
||||
|
||||
/* 3.8.2.2. Video Control Interrupt Endpoint Descriptor */
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_begin.h"
|
||||
#endif
|
||||
RTW_PACK_STRUCT_BEGIN
|
||||
struct uvc_control_endpoint_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubType;
|
||||
__u16 wMaxTransferSize;
|
||||
} //__attribute__((__packed__));
|
||||
RTW_PACK_STRUCT_STRUCT;
|
||||
RTW_PACK_STRUCT_END
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_end.h"
|
||||
#endif
|
||||
|
||||
#define UVC_DT_CONTROL_ENDPOINT_SIZE 5
|
||||
|
||||
/* 3.9.2.1. Input Header Descriptor */
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_begin.h"
|
||||
#endif
|
||||
RTW_PACK_STRUCT_BEGIN
|
||||
struct uvc_input_header_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubType;
|
||||
__u8 bNumFormats;
|
||||
__u16 wTotalLength;
|
||||
__u8 bEndpointAddress;
|
||||
__u8 bmInfo;
|
||||
__u8 bTerminalLink;
|
||||
__u8 bStillCaptureMethod;
|
||||
__u8 bTriggerSupport;
|
||||
__u8 bTriggerUsage;
|
||||
__u8 bControlSize;
|
||||
__u8 bmaControls[];
|
||||
} //__attribute__((__packed__));
|
||||
RTW_PACK_STRUCT_STRUCT;
|
||||
RTW_PACK_STRUCT_END
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_end.h"
|
||||
#endif
|
||||
|
||||
#define UVC_DT_INPUT_HEADER_SIZE(n, p) (13+(n*p))
|
||||
|
||||
#define UVC_INPUT_HEADER_DESCRIPTOR(n, p) \
|
||||
uvc_input_header_descriptor_##n_##p
|
||||
|
||||
#define DECLARE_UVC_INPUT_HEADER_DESCRIPTOR(n, p) \
|
||||
struct UVC_INPUT_HEADER_DESCRIPTOR(n, p) { \
|
||||
__u8 bLength; \
|
||||
__u8 bDescriptorType; \
|
||||
__u8 bDescriptorSubType; \
|
||||
__u8 bNumFormats; \
|
||||
__u16 wTotalLength; \
|
||||
__u8 bEndpointAddress; \
|
||||
__u8 bmInfo; \
|
||||
__u8 bTerminalLink; \
|
||||
__u8 bStillCaptureMethod; \
|
||||
__u8 bTriggerSupport; \
|
||||
__u8 bTriggerUsage; \
|
||||
__u8 bControlSize; \
|
||||
__u8 bmaControls[p][n]; \
|
||||
} __attribute__ ((packed))
|
||||
|
||||
/* 3.9.2.2. Output Header Descriptor */
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_begin.h"
|
||||
#endif
|
||||
RTW_PACK_STRUCT_BEGIN
|
||||
struct uvc_output_header_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubType;
|
||||
__u8 bNumFormats;
|
||||
__u16 wTotalLength;
|
||||
__u8 bEndpointAddress;
|
||||
__u8 bTerminalLink;
|
||||
__u8 bControlSize;
|
||||
__u8 bmaControls[];
|
||||
} //__attribute__((__packed__));
|
||||
RTW_PACK_STRUCT_STRUCT;
|
||||
RTW_PACK_STRUCT_END
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_end.h"
|
||||
#endif
|
||||
|
||||
#define UVC_DT_OUTPUT_HEADER_SIZE(n, p) (9+(n*p))
|
||||
|
||||
#define UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) \
|
||||
uvc_output_header_descriptor_##n_##p
|
||||
|
||||
#define DECLARE_UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) \
|
||||
struct UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) { \
|
||||
__u8 bLength; \
|
||||
__u8 bDescriptorType; \
|
||||
__u8 bDescriptorSubType; \
|
||||
__u8 bNumFormats; \
|
||||
__u16 wTotalLength; \
|
||||
__u8 bEndpointAddress; \
|
||||
__u8 bTerminalLink; \
|
||||
__u8 bControlSize; \
|
||||
__u8 bmaControls[p][n]; \
|
||||
} __attribute__ ((packed))
|
||||
|
||||
/* 3.9.2.6. Color matching descriptor */
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_begin.h"
|
||||
#endif
|
||||
RTW_PACK_STRUCT_BEGIN
|
||||
struct uvc_color_matching_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubType;
|
||||
__u8 bColorPrimaries;
|
||||
__u8 bTransferCharacteristics;
|
||||
__u8 bMatrixCoefficients;
|
||||
} //__attribute__((__packed__));
|
||||
RTW_PACK_STRUCT_STRUCT;
|
||||
RTW_PACK_STRUCT_END
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_end.h"
|
||||
#endif
|
||||
|
||||
#define UVC_DT_COLOR_MATCHING_SIZE 6
|
||||
|
||||
/* 4.3.1.1. Video Probe and Commit Controls */
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_begin.h"
|
||||
#endif
|
||||
RTW_PACK_STRUCT_BEGIN
|
||||
struct uvc_streaming_control {
|
||||
__u16 bmHint;
|
||||
__u8 bFormatIndex;
|
||||
__u8 bFrameIndex;
|
||||
__u32 dwFrameInterval;
|
||||
__u16 wKeyFrameRate;
|
||||
__u16 wPFrameRate;
|
||||
__u16 wCompQuality;
|
||||
__u16 wCompWindowSize;
|
||||
__u16 wDelay;
|
||||
__u32 dwMaxVideoFrameSize;
|
||||
__u32 dwMaxPayloadTransferSize;
|
||||
__u32 dwClockFrequency;
|
||||
__u8 bmFramingInfo;
|
||||
__u8 bPreferedVersion;
|
||||
__u8 bMinVersion;
|
||||
__u8 bMaxVersion;
|
||||
} //__attribute__((__packed__));
|
||||
RTW_PACK_STRUCT_STRUCT;
|
||||
RTW_PACK_STRUCT_END
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_end.h"
|
||||
#endif
|
||||
|
||||
/* Uncompressed Payload - 3.1.1. Uncompressed Video Format Descriptor */
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_begin.h"
|
||||
#endif
|
||||
RTW_PACK_STRUCT_BEGIN
|
||||
struct uvc_format_uncompressed {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubType;
|
||||
__u8 bFormatIndex;
|
||||
__u8 bNumFrameDescriptors;
|
||||
__u8 guidFormat[16];
|
||||
__u8 bBitsPerPixel;
|
||||
__u8 bDefaultFrameIndex;
|
||||
__u8 bAspectRatioX;
|
||||
__u8 bAspectRatioY;
|
||||
__u8 bmInterfaceFlags;
|
||||
__u8 bCopyProtect;
|
||||
} //__attribute__((__packed__));
|
||||
RTW_PACK_STRUCT_STRUCT;
|
||||
RTW_PACK_STRUCT_END
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_end.h"
|
||||
#endif
|
||||
|
||||
#define UVC_DT_FORMAT_UNCOMPRESSED_SIZE 27
|
||||
|
||||
/* Uncompressed Payload - 3.1.2. Uncompressed Video Frame Descriptor */
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_begin.h"
|
||||
#endif
|
||||
RTW_PACK_STRUCT_BEGIN
|
||||
struct uvc_frame_uncompressed {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubType;
|
||||
__u8 bFrameIndex;
|
||||
__u8 bmCapabilities;
|
||||
__u16 wWidth;
|
||||
__u16 wHeight;
|
||||
__u32 dwMinBitRate;
|
||||
__u32 dwMaxBitRate;
|
||||
__u32 dwMaxVideoFrameBufferSize;
|
||||
__u32 dwDefaultFrameInterval;
|
||||
__u8 bFrameIntervalType;
|
||||
__u32 dwFrameInterval[];
|
||||
} //__attribute__((__packed__));
|
||||
RTW_PACK_STRUCT_STRUCT;
|
||||
RTW_PACK_STRUCT_END
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_end.h"
|
||||
#endif
|
||||
|
||||
#define UVC_DT_FRAME_UNCOMPRESSED_SIZE(n) (26+4*(n))
|
||||
|
||||
#define UVC_FRAME_UNCOMPRESSED(n) \
|
||||
uvc_frame_uncompressed_##n
|
||||
|
||||
#define DECLARE_UVC_FRAME_UNCOMPRESSED(n) \
|
||||
struct UVC_FRAME_UNCOMPRESSED(n) { \
|
||||
__u8 bLength; \
|
||||
__u8 bDescriptorType; \
|
||||
__u8 bDescriptorSubType; \
|
||||
__u8 bFrameIndex; \
|
||||
__u8 bmCapabilities; \
|
||||
__u16 wWidth; \
|
||||
__u16 wHeight; \
|
||||
__u32 dwMinBitRate; \
|
||||
__u32 dwMaxBitRate; \
|
||||
__u32 dwMaxVideoFrameBufferSize; \
|
||||
__u32 dwDefaultFrameInterval; \
|
||||
__u8 bFrameIntervalType; \
|
||||
__u32 dwFrameInterval[n]; \
|
||||
} __attribute__ ((packed))
|
||||
|
||||
/* MJPEG Payload - 3.1.1. MJPEG Video Format Descriptor */
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_begin.h"
|
||||
#endif
|
||||
RTW_PACK_STRUCT_BEGIN
|
||||
struct uvc_format_mjpeg {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubType;
|
||||
__u8 bFormatIndex;
|
||||
__u8 bNumFrameDescriptors;
|
||||
__u8 bmFlags;
|
||||
__u8 bDefaultFrameIndex;
|
||||
__u8 bAspectRatioX;
|
||||
__u8 bAspectRatioY;
|
||||
__u8 bmInterfaceFlags;
|
||||
__u8 bCopyProtect;
|
||||
} //__attribute__((__packed__));
|
||||
RTW_PACK_STRUCT_STRUCT;
|
||||
RTW_PACK_STRUCT_END
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_end.h"
|
||||
#endif
|
||||
|
||||
#define UVC_DT_FORMAT_MJPEG_SIZE 11
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_begin.h"
|
||||
#endif
|
||||
RTW_PACK_STRUCT_BEGIN
|
||||
/* MJPEG Payload - 3.1.2. MJPEG Video Frame Descriptor */
|
||||
|
||||
struct uvc_frame_mjpeg {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubType;
|
||||
__u8 bFrameIndex;
|
||||
__u8 bmCapabilities;
|
||||
__u16 wWidth;
|
||||
__u16 wHeight;
|
||||
__u32 dwMinBitRate;
|
||||
__u32 dwMaxBitRate;
|
||||
__u32 dwMaxVideoFrameBufferSize;
|
||||
__u32 dwDefaultFrameInterval;
|
||||
__u8 bFrameIntervalType;
|
||||
__u32 dwFrameInterval[];
|
||||
} //__attribute__((__packed__));
|
||||
RTW_PACK_STRUCT_STRUCT;
|
||||
RTW_PACK_STRUCT_END
|
||||
#ifdef RTW_PACK_STRUCT_USE_INCLUDES
|
||||
# include "pack_end.h"
|
||||
#endif
|
||||
|
||||
#define UVC_DT_FRAME_MJPEG_SIZE(n) (26+4*(n))
|
||||
|
||||
#define UVC_FRAME_MJPEG(n) \
|
||||
uvc_frame_mjpeg_##n
|
||||
|
||||
#define DECLARE_UVC_FRAME_MJPEG(n) \
|
||||
struct UVC_FRAME_MJPEG(n) { \
|
||||
__u8 bLength; \
|
||||
__u8 bDescriptorType; \
|
||||
__u8 bDescriptorSubType; \
|
||||
__u8 bFrameIndex; \
|
||||
__u8 bmCapabilities; \
|
||||
__u16 wWidth; \
|
||||
__u16 wHeight; \
|
||||
__u32 dwMinBitRate; \
|
||||
__u32 dwMaxBitRate; \
|
||||
__u32 dwMaxVideoFrameBufferSize; \
|
||||
__u32 dwDefaultFrameInterval; \
|
||||
__u8 bFrameIntervalType; \
|
||||
__u32 dwFrameInterval[n]; \
|
||||
} __attribute__ ((packed))
|
||||
|
||||
#endif /* __LINUX_USB_VIDEO_H */
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue