00001 #ifndef _USB_VIDEO_H_
00002 #define _USB_VIDEO_H_
00003
00004 #include <linux/kernel.h>
00005 #include <linux/videodev2.h>
00006
00007 #include "uvc_compat.h"
00008
00009
00010
00011
00012
00013
00014 #define UVC_CTRL_DATA_TYPE_RAW 0
00015 #define UVC_CTRL_DATA_TYPE_SIGNED 1
00016 #define UVC_CTRL_DATA_TYPE_UNSIGNED 2
00017 #define UVC_CTRL_DATA_TYPE_BOOLEAN 3
00018 #define UVC_CTRL_DATA_TYPE_ENUM 4
00019 #define UVC_CTRL_DATA_TYPE_BITMASK 5
00020
00021
00022 #define UVC_CONTROL_SET_CUR (1 << 0)
00023 #define UVC_CONTROL_GET_CUR (1 << 1)
00024 #define UVC_CONTROL_GET_MIN (1 << 2)
00025 #define UVC_CONTROL_GET_MAX (1 << 3)
00026 #define UVC_CONTROL_GET_RES (1 << 4)
00027 #define UVC_CONTROL_GET_DEF (1 << 5)
00028
00029 #define UVC_CONTROL_RESTORE (1 << 6)
00030
00031 #define UVC_CONTROL_AUTO_UPDATE (1 << 7)
00032
00033 #define UVC_CONTROL_GET_RANGE (UVC_CONTROL_GET_CUR | UVC_CONTROL_GET_MIN | \
00034 UVC_CONTROL_GET_MAX | UVC_CONTROL_GET_RES | \
00035 UVC_CONTROL_GET_DEF)
00036
00037 struct uvc_xu_control_info {
00038 __u8 entity[16];
00039 __u8 index;
00040 __u8 selector;
00041 __u16 size;
00042 __u32 flags;
00043 };
00044
00045 struct uvc_xu_control_mapping {
00046 __u32 id;
00047 __u8 name[32];
00048 __u8 entity[16];
00049 __u8 selector;
00050
00051 __u8 size;
00052 __u8 offset;
00053 enum v4l2_ctrl_type v4l2_type;
00054 __u32 data_type;
00055 };
00056
00057 struct uvc_xu_control {
00058 __u8 unit;
00059 __u8 selector;
00060 __u16 size;
00061 __u8 __user *data;
00062 };
00063
00064 #define UVCIOC_CTRL_ADD _IOW('U', 1, struct uvc_xu_control_info)
00065 #define UVCIOC_CTRL_MAP _IOWR('U', 2, struct uvc_xu_control_mapping)
00066 #define UVCIOC_CTRL_GET _IOWR('U', 3, struct uvc_xu_control)
00067 #define UVCIOC_CTRL_SET _IOW('U', 4, struct uvc_xu_control)
00068
00069 #ifdef __KERNEL__
00070
00071 #include <linux/poll.h>
00072
00073
00074
00075
00076
00077 #define SC_UNDEFINED 0x00
00078 #define SC_VIDEOCONTROL 0x01
00079 #define SC_VIDEOSTREAMING 0x02
00080 #define SC_VIDEO_INTERFACE_COLLECTION 0x03
00081
00082 #define PC_PROTOCOL_UNDEFINED 0x00
00083
00084 #define CS_UNDEFINED 0x20
00085 #define CS_DEVICE 0x21
00086 #define CS_CONFIGURATION 0x22
00087 #define CS_STRING 0x23
00088 #define CS_INTERFACE 0x24
00089 #define CS_ENDPOINT 0x25
00090
00091
00092 #define VC_DESCRIPTOR_UNDEFINED 0x00
00093 #define VC_HEADER 0x01
00094 #define VC_INPUT_TERMINAL 0x02
00095 #define VC_OUTPUT_TERMINAL 0x03
00096 #define VC_SELECTOR_UNIT 0x04
00097 #define VC_PROCESSING_UNIT 0x05
00098 #define VC_EXTENSION_UNIT 0x06
00099
00100
00101 #define VS_UNDEFINED 0x00
00102 #define VS_INPUT_HEADER 0x01
00103 #define VS_OUTPUT_HEADER 0x02
00104 #define VS_STILL_IMAGE_FRAME 0x03
00105 #define VS_FORMAT_UNCOMPRESSED 0x04
00106 #define VS_FRAME_UNCOMPRESSED 0x05
00107 #define VS_FORMAT_MJPEG 0x06
00108 #define VS_FRAME_MJPEG 0x07
00109 #define VS_FORMAT_MPEG2TS 0x0a
00110 #define VS_FORMAT_DV 0x0c
00111 #define VS_COLORFORMAT 0x0d
00112 #define VS_FORMAT_FRAME_BASED 0x10
00113 #define VS_FRAME_FRAME_BASED 0x11
00114 #define VS_FORMAT_STREAM_BASED 0x12
00115
00116
00117 #define EP_UNDEFINED 0x00
00118 #define EP_GENERAL 0x01
00119 #define EP_ENDPOINT 0x02
00120 #define EP_INTERRUPT 0x03
00121
00122
00123 #define RC_UNDEFINED 0x00
00124 #define SET_CUR 0x01
00125 #define GET_CUR 0x81
00126 #define GET_MIN 0x82
00127 #define GET_MAX 0x83
00128 #define GET_RES 0x84
00129 #define GET_LEN 0x85
00130 #define GET_INFO 0x86
00131 #define GET_DEF 0x87
00132
00133
00134 #define VC_CONTROL_UNDEFINED 0x00
00135 #define VC_VIDEO_POWER_MODE_CONTROL 0x01
00136 #define VC_REQUEST_ERROR_CODE_CONTROL 0x02
00137
00138
00139 #define TE_CONTROL_UNDEFINED 0x00
00140
00141
00142 #define SU_CONTROL_UNDEFINED 0x00
00143 #define SU_INPUT_SELECT_CONTROL 0x01
00144
00145
00146 #define CT_CONTROL_UNDEFINED 0x00
00147 #define CT_SCANNING_MODE_CONTROL 0x01
00148 #define CT_AE_MODE_CONTROL 0x02
00149 #define CT_AE_PRIORITY_CONTROL 0x03
00150 #define CT_EXPOSURE_TIME_ABSOLUTE_CONTROL 0x04
00151 #define CT_EXPOSURE_TIME_RELATIVE_CONTROL 0x05
00152 #define CT_FOCUS_ABSOLUTE_CONTROL 0x06
00153 #define CT_FOCUS_RELATIVE_CONTROL 0x07
00154 #define CT_FOCUS_AUTO_CONTROL 0x08
00155 #define CT_IRIS_ABSOLUTE_CONTROL 0x09
00156 #define CT_IRIS_RELATIVE_CONTROL 0x0a
00157 #define CT_ZOOM_ABSOLUTE_CONTROL 0x0b
00158 #define CT_ZOOM_RELATIVE_CONTROL 0x0c
00159 #define CT_PANTILT_ABSOLUTE_CONTROL 0x0d
00160 #define CT_PANTILT_RELATIVE_CONTROL 0x0e
00161 #define CT_ROLL_ABSOLUTE_CONTROL 0x0f
00162 #define CT_ROLL_RELATIVE_CONTROL 0x10
00163 #define CT_PRIVACY_CONTROL 0x11
00164
00165
00166 #define PU_CONTROL_UNDEFINED 0x00
00167 #define PU_BACKLIGHT_COMPENSATION_CONTROL 0x01
00168 #define PU_BRIGHTNESS_CONTROL 0x02
00169 #define PU_CONTRAST_CONTROL 0x03
00170 #define PU_GAIN_CONTROL 0x04
00171 #define PU_POWER_LINE_FREQUENCY_CONTROL 0x05
00172 #define PU_HUE_CONTROL 0x06
00173 #define PU_SATURATION_CONTROL 0x07
00174 #define PU_SHARPNESS_CONTROL 0x08
00175 #define PU_GAMMA_CONTROL 0x09
00176 #define PU_WHITE_BALANCE_TEMPERATURE_CONTROL 0x0a
00177 #define PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL 0x0b
00178 #define PU_WHITE_BALANCE_COMPONENT_CONTROL 0x0c
00179 #define PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL 0x0d
00180 #define PU_DIGITAL_MULTIPLIER_CONTROL 0x0e
00181 #define PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL 0x0f
00182 #define PU_HUE_AUTO_CONTROL 0x10
00183 #define PU_ANALOG_VIDEO_STANDARD_CONTROL 0x11
00184 #define PU_ANALOG_LOCK_STATUS_CONTROL 0x12
00185
00186 #define LXU_MOTOR_PANTILT_RELATIVE_CONTROL 0x01
00187 #define LXU_MOTOR_PANTILT_RESET_CONTROL 0x02
00188 #define LXU_MOTOR_FOCUS_MOTOR_CONTROL 0x03
00189
00190
00191 #define VS_CONTROL_UNDEFINED 0x00
00192 #define VS_PROBE_CONTROL 0x01
00193 #define VS_COMMIT_CONTROL 0x02
00194 #define VS_STILL_PROBE_CONTROL 0x03
00195 #define VS_STILL_COMMIT_CONTROL 0x04
00196 #define VS_STILL_IMAGE_TRIGGER_CONTROL 0x05
00197 #define VS_STREAM_ERROR_CODE_CONTROL 0x06
00198 #define VS_GENERATE_KEY_FRAME_CONTROL 0x07
00199 #define VS_UPDATE_FRAME_SEGMENT_CONTROL 0x08
00200 #define VS_SYNC_DELAY_CONTROL 0x09
00201
00202 #define TT_VENDOR_SPECIFIC 0x0100
00203 #define TT_STREAMING 0x0101
00204
00205
00206 #define ITT_VENDOR_SPECIFIC 0x0200
00207 #define ITT_CAMERA 0x0201
00208 #define ITT_MEDIA_TRANSPORT_INPUT 0x0202
00209
00210
00211 #define OTT_VENDOR_SPECIFIC 0x0300
00212 #define OTT_DISPLAY 0x0301
00213 #define OTT_MEDIA_TRANSPORT_OUTPUT 0x0302
00214
00215
00216 #define EXTERNAL_VENDOR_SPECIFIC 0x0400
00217 #define COMPOSITE_CONNECTOR 0x0401
00218 #define SVIDEO_CONNECTOR 0x0402
00219 #define COMPONENT_CONNECTOR 0x0403
00220
00221 #define UVC_TERM_INPUT 0x0000
00222 #define UVC_TERM_OUTPUT 0x8000
00223
00224 #define UVC_ENTITY_TYPE(entity) ((entity)->type & 0x7fff)
00225 #define UVC_ENTITY_IS_UNIT(entity) (((entity)->type & 0xff00) == 0)
00226 #define UVC_ENTITY_IS_TERM(entity) (((entity)->type & 0xff00) != 0)
00227 #define UVC_ENTITY_IS_ITERM(entity) \
00228 (((entity)->type & 0x8000) == UVC_TERM_INPUT)
00229 #define UVC_ENTITY_IS_OTERM(entity) \
00230 (((entity)->type & 0x8000) == UVC_TERM_OUTPUT)
00231
00232 #define UVC_STATUS_TYPE_CONTROL 1
00233 #define UVC_STATUS_TYPE_STREAMING 2
00234
00235
00236
00237
00238 #define UVC_GUID_UVC_CAMERA \
00239 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
00240 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}
00241 #define UVC_GUID_UVC_OUTPUT \
00242 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
00243 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}
00244 #define UVC_GUID_UVC_MEDIA_TRANSPORT_INPUT \
00245 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
00246 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03}
00247 #define UVC_GUID_UVC_PROCESSING \
00248 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
00249 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01}
00250 #define UVC_GUID_UVC_SELECTOR \
00251 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
00252 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02}
00253
00254 #define UVC_GUID_LOGITECH_DEV_INFO \
00255 {0x82, 0x06, 0x61, 0x63, 0x70, 0x50, 0xab, 0x49, \
00256 0xb8, 0xcc, 0xb3, 0x85, 0x5e, 0x8d, 0x22, 0x1e}
00257 #define UVC_GUID_LOGITECH_USER_HW \
00258 {0x82, 0x06, 0x61, 0x63, 0x70, 0x50, 0xab, 0x49, \
00259 0xb8, 0xcc, 0xb3, 0x85, 0x5e, 0x8d, 0x22, 0x1f}
00260 #define UVC_GUID_LOGITECH_VIDEO \
00261 {0x82, 0x06, 0x61, 0x63, 0x70, 0x50, 0xab, 0x49, \
00262 0xb8, 0xcc, 0xb3, 0x85, 0x5e, 0x8d, 0x22, 0x50}
00263 #define UVC_GUID_LOGITECH_MOTOR \
00264 {0x82, 0x06, 0x61, 0x63, 0x70, 0x50, 0xab, 0x49, \
00265 0xb8, 0xcc, 0xb3, 0x85, 0x5e, 0x8d, 0x22, 0x56}
00266
00267 #define UVC_GUID_FORMAT_MJPEG \
00268 { 'M', 'J', 'P', 'G', 0x00, 0x00, 0x10, 0x00, \
00269 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
00270 #define UVC_GUID_FORMAT_YUY2 \
00271 { 'Y', 'U', 'Y', '2', 0x00, 0x00, 0x10, 0x00, \
00272 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
00273 #define UVC_GUID_FORMAT_NV12 \
00274 { 'N', 'V', '1', '2', 0x00, 0x00, 0x10, 0x00, \
00275 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
00276 #define UVC_GUID_FORMAT_YV12 \
00277 { 'Y', 'V', '1', '2', 0x00, 0x00, 0x10, 0x00, \
00278 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
00279 #define UVC_GUID_FORMAT_I420 \
00280 { 'I', '4', '2', '0', 0x00, 0x00, 0x10, 0x00, \
00281 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
00282 #define UVC_GUID_FORMAT_UYVY \
00283 { 'U', 'Y', 'V', 'Y', 0x00, 0x00, 0x10, 0x00, \
00284 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
00285 #define UVC_GUID_FORMAT_Y800 \
00286 { 'Y', '8', '0', '0', 0x00, 0x00, 0x10, 0x00, \
00287 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
00288 #define UVC_GUID_FORMAT_BY8 \
00289 { 'B', 'Y', '8', ' ', 0x00, 0x00, 0x10, 0x00, \
00290 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
00291
00292
00293
00294
00295
00296
00297 #define DRIVER_VERSION_NUMBER KERNEL_VERSION(0, 1, 0)
00298
00299
00300 #define UVC_URBS 5
00301
00302 #define UVC_MAX_ISO_PACKETS 40
00303
00304 #define UVC_MAX_FRAME_SIZE (16*1024*1024)
00305
00306 #define UVC_MAX_VIDEO_BUFFERS 32
00307
00308 #define UVC_MAX_STATUS_SIZE 16
00309
00310 #define UVC_CTRL_CONTROL_TIMEOUT 300
00311 #define UVC_CTRL_STREAMING_TIMEOUT 1000
00312
00313
00314 #define UVC_QUIRK_STATUS_INTERVAL 0x00000001
00315 #define UVC_QUIRK_PROBE_MINMAX 0x00000002
00316 #define UVC_QUIRK_PROBE_EXTRAFIELDS 0x00000004
00317 #define UVC_QUIRK_BUILTIN_ISIGHT 0x00000008
00318 #define UVC_QUIRK_STREAM_NO_FID 0x00000010
00319 #define UVC_QUIRK_IGNORE_SELECTOR_UNIT 0x00000020
00320
00321
00322 #define UVC_FMT_FLAG_COMPRESSED 0x00000001
00323 #define UVC_FMT_FLAG_STREAM 0x00000002
00324
00325
00326
00327
00328
00329 struct uvc_device;
00330
00331
00332
00333
00334 struct uvc_streaming_control {
00335 __u16 bmHint;
00336 __u8 bFormatIndex;
00337 __u8 bFrameIndex;
00338 __u32 dwFrameInterval;
00339 __u16 wKeyFrameRate;
00340 __u16 wPFrameRate;
00341 __u16 wCompQuality;
00342 __u16 wCompWindowSize;
00343 __u16 wDelay;
00344 __u32 dwMaxVideoFrameSize;
00345 __u32 dwMaxPayloadTransferSize;
00346 __u32 dwClockFrequency;
00347 __u8 bmFramingInfo;
00348 __u8 bPreferedVersion;
00349 __u8 bMinVersion;
00350 __u8 bMaxVersion;
00351 };
00352
00353 struct uvc_menu_info {
00354 __u32 value;
00355 __u8 name[32];
00356 };
00357
00358 struct uvc_control_info {
00359 struct list_head list;
00360 struct list_head mappings;
00361
00362 __u8 entity[16];
00363 __u8 index;
00364 __u8 selector;
00365
00366 __u16 size;
00367 __u32 flags;
00368 };
00369
00370 struct uvc_control_mapping {
00371 struct list_head list;
00372
00373 struct uvc_control_info *ctrl;
00374
00375 __u32 id;
00376 __u8 name[32];
00377 __u8 entity[16];
00378 __u8 selector;
00379
00380 __u8 size;
00381 __u8 offset;
00382 enum v4l2_ctrl_type v4l2_type;
00383 __u32 data_type;
00384
00385 struct uvc_menu_info *menu_info;
00386 __u32 menu_count;
00387 };
00388
00389 struct uvc_control {
00390 struct uvc_entity *entity;
00391 struct uvc_control_info *info;
00392
00393 __u8 index;
00394
00395 __u8 dirty : 1,
00396 loaded : 1,
00397 modified : 1;
00398
00399 __u8 *data;
00400 };
00401
00402 struct uvc_format_desc {
00403 char *name;
00404 __u8 guid[16];
00405 __u32 fcc;
00406 };
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423 struct uvc_entity {
00424 struct list_head list;
00425 struct list_head chain;
00426
00427 __u8 id;
00428 __u16 type;
00429 char name[64];
00430
00431 union {
00432 struct {
00433 __u16 wObjectiveFocalLengthMin;
00434 __u16 wObjectiveFocalLengthMax;
00435 __u16 wOcularFocalLength;
00436 __u8 bControlSize;
00437 __u8 *bmControls;
00438 } camera;
00439
00440 struct {
00441 __u8 bControlSize;
00442 __u8 *bmControls;
00443 __u8 bTransportModeSize;
00444 __u8 *bmTransportModes;
00445 } media;
00446
00447 struct {
00448 __u8 bSourceID;
00449 } output;
00450
00451 struct {
00452 __u8 bSourceID;
00453 __u16 wMaxMultiplier;
00454 __u8 bControlSize;
00455 __u8 *bmControls;
00456 __u8 bmVideoStandards;
00457 } processing;
00458
00459 struct {
00460 __u8 bNrInPins;
00461 __u8 *baSourceID;
00462 } selector;
00463
00464 struct {
00465 __u8 guidExtensionCode[16];
00466 __u8 bNumControls;
00467 __u8 bNrInPins;
00468 __u8 *baSourceID;
00469 __u8 bControlSize;
00470 __u8 *bmControls;
00471 __u8 *bmControlsType;
00472 } extension;
00473 };
00474
00475 unsigned int ncontrols;
00476 struct uvc_control *controls;
00477 };
00478
00479 struct uvc_frame {
00480 __u8 bFrameIndex;
00481 __u8 bmCapabilities;
00482 __u16 wWidth;
00483 __u16 wHeight;
00484 __u32 dwMinBitRate;
00485 __u32 dwMaxBitRate;
00486 __u32 dwMaxVideoFrameBufferSize;
00487 __u8 bFrameIntervalType;
00488 __u32 dwDefaultFrameInterval;
00489 __u32 *dwFrameInterval;
00490 };
00491
00492 struct uvc_format {
00493 __u8 type;
00494 __u8 index;
00495 __u8 bpp;
00496 __u8 colorspace;
00497 __u32 fcc;
00498 __u32 flags;
00499
00500 char name[32];
00501
00502 unsigned int nframes;
00503 struct uvc_frame *frame;
00504 };
00505
00506 struct uvc_streaming_header {
00507 __u8 bNumFormats;
00508 __u8 bEndpointAddress;
00509 __u8 bTerminalLink;
00510 __u8 bControlSize;
00511 __u8 *bmaControls;
00512
00513 __u8 bmInfo;
00514 __u8 bStillCaptureMethod;
00515 __u8 bTriggerSupport;
00516 __u8 bTriggerUsage;
00517 };
00518
00519 struct uvc_streaming {
00520 struct list_head list;
00521
00522 struct usb_interface *intf;
00523 int intfnum;
00524 __u16 maxpsize;
00525
00526 struct uvc_streaming_header header;
00527
00528 unsigned int nformats;
00529 struct uvc_format *format;
00530
00531 struct uvc_streaming_control ctrl;
00532 struct uvc_format *cur_format;
00533 struct uvc_frame *cur_frame;
00534
00535 struct mutex mutex;
00536 };
00537
00538 enum uvc_buffer_state {
00539 UVC_BUF_STATE_IDLE = 0,
00540 UVC_BUF_STATE_QUEUED = 1,
00541 UVC_BUF_STATE_ACTIVE = 2,
00542 UVC_BUF_STATE_DONE = 3,
00543 UVC_BUF_STATE_ERROR = 4,
00544 };
00545
00546 struct uvc_buffer {
00547 unsigned long vma_use_count;
00548 struct list_head stream;
00549
00550
00551 struct v4l2_buffer buf;
00552 struct list_head queue;
00553 wait_queue_head_t wait;
00554 enum uvc_buffer_state state;
00555 };
00556
00557 #define UVC_QUEUE_STREAMING (1 << 0)
00558 #define UVC_QUEUE_DISCONNECTED (1 << 1)
00559 #define UVC_QUEUE_DROP_INCOMPLETE (1 << 2)
00560
00561 struct uvc_video_queue {
00562 void *mem;
00563 unsigned int flags;
00564 __u32 sequence;
00565
00566 unsigned int count;
00567 unsigned int buf_size;
00568 struct uvc_buffer buffer[UVC_MAX_VIDEO_BUFFERS];
00569 struct mutex mutex;
00570 spinlock_t irqlock;
00571
00572 struct list_head mainqueue;
00573 struct list_head irqqueue;
00574 };
00575
00576 struct uvc_video_device {
00577 struct uvc_device *dev;
00578 struct video_device *vdev;
00579 atomic_t active;
00580 unsigned int frozen : 1;
00581
00582 struct list_head iterms;
00583 struct uvc_entity *oterm;
00584 struct uvc_entity *processing;
00585 struct uvc_entity *selector;
00586 struct list_head extensions;
00587 struct mutex ctrl_mutex;
00588
00589 struct uvc_video_queue queue;
00590
00591
00592 struct uvc_streaming *streaming;
00593
00594 void (*decode) (struct urb *urb, struct uvc_video_device *video,
00595 struct uvc_buffer *buf);
00596
00597
00598 struct {
00599 __u8 header[256];
00600 unsigned int header_size;
00601 int skip_payload;
00602 __u32 payload_size;
00603 __u32 max_payload_size;
00604 } bulk;
00605
00606 struct urb *urb[UVC_URBS];
00607 char *urb_buffer[UVC_URBS];
00608 dma_addr_t urb_dma[UVC_URBS];
00609 unsigned int urb_size;
00610
00611 __u8 last_fid;
00612 };
00613
00614 enum uvc_device_state {
00615 UVC_DEV_DISCONNECTED = 1,
00616 };
00617
00618 struct uvc_device {
00619 struct usb_device *udev;
00620 struct usb_interface *intf;
00621 __u32 quirks;
00622 int intfnum;
00623 char name[32];
00624
00625 enum uvc_device_state state;
00626 struct kref kref;
00627 struct list_head list;
00628
00629
00630 __u16 uvc_version;
00631 __u32 clock_frequency;
00632
00633 struct list_head entities;
00634
00635 struct uvc_video_device video;
00636
00637
00638 struct usb_host_endpoint *int_ep;
00639 struct urb *int_urb;
00640 __u8 *status;
00641 struct input_dev *input;
00642
00643
00644 struct list_head streaming;
00645 };
00646
00647 enum uvc_handle_state {
00648 UVC_HANDLE_PASSIVE = 0,
00649 UVC_HANDLE_ACTIVE = 1,
00650 };
00651
00652 struct uvc_fh {
00653 struct uvc_video_device *device;
00654 enum uvc_handle_state state;
00655 };
00656
00657 struct uvc_driver {
00658 struct usb_driver driver;
00659
00660 struct mutex open_mutex;
00661
00662 struct list_head devices;
00663 struct list_head controls;
00664 struct mutex ctrl_mutex;
00665
00666 };
00667
00668
00669
00670
00671
00672 #define UVC_TRACE_PROBE (1 << 0)
00673 #define UVC_TRACE_DESCR (1 << 1)
00674 #define UVC_TRACE_CONTROL (1 << 2)
00675 #define UVC_TRACE_FORMAT (1 << 3)
00676 #define UVC_TRACE_CAPTURE (1 << 4)
00677 #define UVC_TRACE_CALLS (1 << 5)
00678 #define UVC_TRACE_IOCTL (1 << 6)
00679 #define UVC_TRACE_FRAME (1 << 7)
00680 #define UVC_TRACE_SUSPEND (1 << 8)
00681 #define UVC_TRACE_STATUS (1 << 9)
00682
00683 extern unsigned int uvc_trace_param;
00684
00685 #define uvc_trace(flag, msg...) \
00686 do { \
00687 if (uvc_trace_param & flag) \
00688 printk(KERN_DEBUG "uvcvideo: " msg); \
00689 } while (0)
00690
00691 #define uvc_printk(level, msg...) \
00692 printk(level "uvcvideo: " msg)
00693
00694 #define UVC_GUID_FORMAT "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-" \
00695 "%02x%02x%02x%02x%02x%02x"
00696 #define UVC_GUID_ARGS(guid) \
00697 (guid)[3], (guid)[2], (guid)[1], (guid)[0], \
00698 (guid)[5], (guid)[4], \
00699 (guid)[7], (guid)[6], \
00700 (guid)[8], (guid)[9], \
00701 (guid)[10], (guid)[11], (guid)[12], \
00702 (guid)[13], (guid)[14], (guid)[15]
00703
00704
00705
00706
00707
00708
00709 extern struct uvc_driver uvc_driver;
00710 extern void uvc_delete(struct kref *kref);
00711
00712
00713 extern void uvc_queue_init(struct uvc_video_queue *queue);
00714 extern int uvc_alloc_buffers(struct uvc_video_queue *queue,
00715 unsigned int nbuffers, unsigned int buflength);
00716 extern int uvc_free_buffers(struct uvc_video_queue *queue);
00717 extern int uvc_query_buffer(struct uvc_video_queue *queue,
00718 struct v4l2_buffer *v4l2_buf);
00719 extern int uvc_queue_buffer(struct uvc_video_queue *queue,
00720 struct v4l2_buffer *v4l2_buf);
00721 extern int uvc_dequeue_buffer(struct uvc_video_queue *queue,
00722 struct v4l2_buffer *v4l2_buf, int nonblocking);
00723 extern int uvc_queue_enable(struct uvc_video_queue *queue, int enable);
00724 extern void uvc_queue_cancel(struct uvc_video_queue *queue, int disconnect);
00725 extern struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue,
00726 struct uvc_buffer *buf);
00727 extern unsigned int uvc_queue_poll(struct uvc_video_queue *queue,
00728 struct file *file, poll_table *wait);
00729 static inline int uvc_queue_streaming(struct uvc_video_queue *queue)
00730 {
00731 return queue->flags & UVC_QUEUE_STREAMING;
00732 }
00733
00734
00735 extern struct file_operations uvc_fops;
00736
00737
00738 extern int uvc_video_init(struct uvc_video_device *video);
00739 extern int uvc_video_suspend(struct uvc_video_device *video);
00740 extern int uvc_video_resume(struct uvc_video_device *video);
00741 extern int uvc_video_enable(struct uvc_video_device *video, int enable);
00742 extern int uvc_probe_video(struct uvc_video_device *video,
00743 struct uvc_streaming_control *probe);
00744 extern int uvc_query_ctrl(struct uvc_device *dev, __u8 query, __u8 unit,
00745 __u8 intfnum, __u8 cs, void *data, __u16 size);
00746 extern int uvc_set_video_ctrl(struct uvc_video_device *video,
00747 struct uvc_streaming_control *ctrl, int probe);
00748
00749
00750 extern int uvc_status_init(struct uvc_device *dev);
00751 extern void uvc_status_cleanup(struct uvc_device *dev);
00752 extern int uvc_status_suspend(struct uvc_device *dev);
00753 extern int uvc_status_resume(struct uvc_device *dev);
00754
00755
00756 extern struct uvc_control *uvc_find_control(struct uvc_video_device *video,
00757 __u32 v4l2_id, struct uvc_control_mapping **mapping);
00758 extern int uvc_query_v4l2_ctrl(struct uvc_video_device *video,
00759 struct v4l2_queryctrl *v4l2_ctrl);
00760
00761 extern int uvc_ctrl_add_info(struct uvc_control_info *info);
00762 extern int uvc_ctrl_add_mapping(struct uvc_control_mapping *mapping);
00763 extern int uvc_ctrl_init_device(struct uvc_device *dev);
00764 extern void uvc_ctrl_cleanup_device(struct uvc_device *dev);
00765 extern int uvc_ctrl_resume_device(struct uvc_device *dev);
00766 extern void uvc_ctrl_init(void);
00767
00768 extern int uvc_ctrl_begin(struct uvc_video_device *video);
00769 extern int __uvc_ctrl_commit(struct uvc_video_device *video, int rollback);
00770 static inline int uvc_ctrl_commit(struct uvc_video_device *video)
00771 {
00772 return __uvc_ctrl_commit(video, 0);
00773 }
00774 static inline int uvc_ctrl_rollback(struct uvc_video_device *video)
00775 {
00776 return __uvc_ctrl_commit(video, 1);
00777 }
00778
00779 extern int uvc_ctrl_get(struct uvc_video_device *video,
00780 struct v4l2_ext_control *xctrl);
00781 extern int uvc_ctrl_set(struct uvc_video_device *video,
00782 struct v4l2_ext_control *xctrl);
00783
00784 extern int uvc_xu_ctrl_query(struct uvc_video_device *video,
00785 struct uvc_xu_control *ctrl, int set);
00786
00787
00788 extern void uvc_simplify_fraction(uint32_t *numerator, uint32_t *denominator,
00789 unsigned int n_terms, unsigned int threshold);
00790 extern uint32_t uvc_fraction_to_interval(uint32_t numerator,
00791 uint32_t denominator);
00792 extern struct usb_host_endpoint *uvc_find_endpoint(
00793 struct usb_host_interface *alts, __u8 epaddr);
00794
00795
00796 void uvc_video_decode_isight(struct urb *urb, struct uvc_video_device *video,
00797 struct uvc_buffer *buf);
00798
00799 #endif
00800
00801 #endif
00802