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