FILE
uvcvideo.h
File preview with syntax highlighting.
linux-6.19.14/drivers/media/usb/uvc/uvcvideo.h
1/* SPDX-License-Identifier: GPL-2.0 */ 2#ifndef _USB_VIDEO_H_ 3#define _USB_VIDEO_H_ 4 5#ifndef __KERNEL__ 6#error "The uvcvideo.h header is deprecated, use linux/uvcvideo.h instead." 7#endif /* __KERNEL__ */ 8 9#include <linux/atomic.h> 10#include <linux/kernel.h> 11#include <linux/poll.h> 12#include <linux/usb.h> 13#include <linux/usb/video.h> 14#include <linux/uvcvideo.h> 15#include <linux/videodev2.h> 16#include <linux/workqueue.h> 17#include <media/media-device.h> 18#include <media/v4l2-device.h> 19#include <media/v4l2-event.h> 20#include <media/v4l2-fh.h> 21#include <media/videobuf2-v4l2.h> 22 23/* -------------------------------------------------------------------------- 24 * UVC constants 25 */ 26 27#define UVC_TERM_INPUT 0x0000 28#define UVC_TERM_OUTPUT 0x8000 29#define UVC_TERM_DIRECTION(term) ((term)->type & 0x8000) 30 31#define UVC_ENTITY_TYPE(entity) ((entity)->type & 0x7fff) 32#define UVC_ENTITY_IS_UNIT(entity) (((entity)->type & 0xff00) == 0) 33#define UVC_ENTITY_IS_TERM(entity) (((entity)->type & 0xff00) != 0) 34#define UVC_ENTITY_IS_ITERM(entity) \ 35 (UVC_ENTITY_IS_TERM(entity) && \ 36 ((entity)->type & 0x8000) == UVC_TERM_INPUT) 37#define UVC_ENTITY_IS_OTERM(entity) \ 38 (UVC_ENTITY_IS_TERM(entity) && \ 39 ((entity)->type & 0x8000) == UVC_TERM_OUTPUT) 40 41#define UVC_EXT_GPIO_UNIT 0x7ffe 42#define UVC_EXT_GPIO_UNIT_ID 0x100 43 44#define UVC_HARDWARE_ENTITY_ID(id) ((id) & 0xff) 45#define UVC_INVALID_ENTITY_ID 0xffff 46 47/* ------------------------------------------------------------------------ 48 * Driver specific constants. 49 */ 50 51#define DRIVER_VERSION "1.1.1" 52 53/* Number of isochronous URBs. */ 54#define UVC_URBS 5 55/* Maximum number of packets per URB. */ 56#define UVC_MAX_PACKETS 32 57 58#define UVC_CTRL_CONTROL_TIMEOUT 5000 59#define UVC_CTRL_STREAMING_TIMEOUT 5000 60 61/* Maximum allowed number of control mappings per device */ 62#define UVC_MAX_CONTROL_MAPPINGS 1024 63#define UVC_MAX_CONTROL_MENU_ENTRIES 32 64 65/* Devices quirks */ 66#define UVC_QUIRK_STATUS_INTERVAL 0x00000001 67#define UVC_QUIRK_PROBE_MINMAX 0x00000002 68#define UVC_QUIRK_PROBE_EXTRAFIELDS 0x00000004 69#define UVC_QUIRK_BUILTIN_ISIGHT 0x00000008 70#define UVC_QUIRK_STREAM_NO_FID 0x00000010 71#define UVC_QUIRK_IGNORE_SELECTOR_UNIT 0x00000020 72#define UVC_QUIRK_FIX_BANDWIDTH 0x00000080 73#define UVC_QUIRK_PROBE_DEF 0x00000100 74#define UVC_QUIRK_RESTRICT_FRAME_RATE 0x00000200 75#define UVC_QUIRK_RESTORE_CTRLS_ON_INIT 0x00000400 76#define UVC_QUIRK_FORCE_Y8 0x00000800 77#define UVC_QUIRK_FORCE_BPP 0x00001000 78#define UVC_QUIRK_WAKE_AUTOSUSPEND 0x00002000 79#define UVC_QUIRK_NO_RESET_RESUME 0x00004000 80#define UVC_QUIRK_DISABLE_AUTOSUSPEND 0x00008000 81#define UVC_QUIRK_INVALID_DEVICE_SOF 0x00010000 82#define UVC_QUIRK_MJPEG_NO_EOF 0x00020000 83#define UVC_QUIRK_MSXU_META 0x00040000 84 85/* Format flags */ 86#define UVC_FMT_FLAG_COMPRESSED 0x00000001 87#define UVC_FMT_FLAG_STREAM 0x00000002 88 89/* ------------------------------------------------------------------------ 90 * Structures. 91 */ 92 93struct gpio_desc; 94struct sg_table; 95struct uvc_control; 96struct uvc_device; 97struct uvc_video_chain; 98 99/* 100 * TODO: Put the most frequently accessed fields at the beginning of 101 * structures to maximize cache efficiency. 102 */ 103struct uvc_control_info { 104 struct list_head mappings; 105 106 u8 entity[16]; 107 u8 index; /* Bit index in bmControls */ 108 u8 selector; 109 110 u16 size; 111 u32 flags; 112}; 113 114struct uvc_control_mapping { 115 struct list_head list; 116 struct list_head ev_subs; 117 118 u32 id; 119 char *name; 120 u8 entity[16]; 121 u8 selector; 122 123 /* 124 * Size of the control data in the payload of the UVC control GET and 125 * SET requests, expressed in bits. 126 */ 127 u8 size; 128 129 u8 offset; 130 enum v4l2_ctrl_type v4l2_type; 131 u32 data_type; 132 133 const u32 *menu_mapping; 134 const char (*menu_names)[UVC_MENU_NAME_LEN]; 135 unsigned long menu_mask; 136 137 u32 master_id; 138 s32 master_manual; 139 u32 slave_ids[2]; 140 141 bool disabled; 142 143 const struct uvc_control_mapping *(*filter_mapping) 144 (struct uvc_video_chain *chain, 145 struct uvc_control *ctrl); 146 int (*get)(struct uvc_control_mapping *mapping, u8 query, 147 const void *uvc_in, size_t v4l2_size, void *v4l2_out); 148 int (*set)(struct uvc_control_mapping *mapping, size_t v4l2_size, 149 const void *v4l2_in, void *uvc_out); 150}; 151 152struct uvc_control { 153 struct uvc_entity *entity; 154 struct uvc_control_info info; 155 156 u8 index; /* Used to match the uvc_control entry with a uvc_control_info. */ 157 u8 dirty:1, 158 loaded:1, 159 modified:1, 160 cached:1, 161 initialized:1; 162 163 u8 *uvc_data; 164 165 struct uvc_fh *handle; /* File handle that last changed the control. */ 166}; 167 168/* 169 * The term 'entity' refers to both UVC units and UVC terminals. 170 * 171 * The type field is either the terminal type (wTerminalType in the terminal 172 * descriptor), or the unit type (bDescriptorSubtype in the unit descriptor). 173 * As the bDescriptorSubtype field is one byte long, the type value will 174 * always have a null MSB for units. All terminal types defined by the UVC 175 * specification have a non-null MSB, so it is safe to use the MSB to 176 * differentiate between units and terminals as long as the descriptor parsing 177 * code makes sure terminal types have a non-null MSB. 178 * 179 * For terminals, the type's most significant bit stores the terminal 180 * direction (either UVC_TERM_INPUT or UVC_TERM_OUTPUT). The type field should 181 * always be accessed with the UVC_ENTITY_* macros and never directly. 182 */ 183 184#define UVC_ENTITY_FLAG_DEFAULT (1 << 0) 185 186struct uvc_entity { 187 struct list_head list; /* Entity as part of a UVC device. */ 188 struct list_head chain; /* Entity as part of a video device chain. */ 189 unsigned int flags; 190 191 /* 192 * Entities exposed by the UVC device use IDs 0-255, extra entities 193 * implemented by the driver (such as the GPIO entity) use IDs 256 and 194 * up. 195 */ 196 u16 id; 197 u16 type; 198 char name[64]; 199 u8 guid[16]; 200 201 /* Media controller-related fields. */ 202 struct video_device *vdev; 203 struct v4l2_subdev subdev; 204 unsigned int num_pads; 205 unsigned int num_links; 206 struct media_pad *pads; 207 208 union { 209 struct { 210 u16 wObjectiveFocalLengthMin; 211 u16 wObjectiveFocalLengthMax; 212 u16 wOcularFocalLength; 213 u8 bControlSize; 214 u8 *bmControls; 215 } camera; 216 217 struct { 218 u8 bControlSize; 219 u8 *bmControls; 220 u8 bTransportModeSize; 221 u8 *bmTransportModes; 222 } media; 223 224 struct { 225 } output; 226 227 struct { 228 u16 wMaxMultiplier; 229 u8 bControlSize; 230 u8 *bmControls; 231 u8 bmVideoStandards; 232 } processing; 233 234 struct { 235 } selector; 236 237 struct { 238 u8 bNumControls; 239 u8 bControlSize; 240 u8 *bmControls; 241 u8 *bmControlsType; 242 } extension; 243 244 struct { 245 u8 bControlSize; 246 u8 *bmControls; 247 struct gpio_desc *gpio_privacy; 248 int irq; 249 bool initialized; 250 } gpio; 251 }; 252 253 u8 bNrInPins; 254 u8 *baSourceID; 255 256 int (*get_info)(struct uvc_device *dev, struct uvc_entity *entity, 257 u8 cs, u8 *caps); 258 int (*get_cur)(struct uvc_device *dev, struct uvc_entity *entity, 259 u8 cs, void *data, u16 size); 260 261 unsigned int ncontrols; 262 struct uvc_control *controls; 263}; 264 265struct uvc_frame { 266 u8 bFrameIndex; 267 u8 bmCapabilities; 268 u16 wWidth; 269 u16 wHeight; 270 u32 dwMinBitRate; 271 u32 dwMaxBitRate; 272 u32 dwMaxVideoFrameBufferSize; 273 u8 bFrameIntervalType; 274 u32 dwDefaultFrameInterval; 275 const u32 *dwFrameInterval; 276}; 277 278struct uvc_format { 279 u8 type; 280 u8 index; 281 u8 bpp; 282 enum v4l2_colorspace colorspace; 283 enum v4l2_xfer_func xfer_func; 284 enum v4l2_ycbcr_encoding ycbcr_enc; 285 u32 fcc; 286 u32 flags; 287 288 unsigned int nframes; 289 const struct uvc_frame *frames; 290}; 291 292struct uvc_streaming_header { 293 u8 bNumFormats; 294 u8 bEndpointAddress; 295 u8 bTerminalLink; 296 u8 bControlSize; 297 u8 *bmaControls; 298 /* The following fields are used by input headers only. */ 299 u8 bmInfo; 300 u8 bStillCaptureMethod; 301 u8 bTriggerSupport; 302 u8 bTriggerUsage; 303}; 304 305enum uvc_buffer_state { 306 UVC_BUF_STATE_IDLE = 0, 307 UVC_BUF_STATE_QUEUED = 1, 308 UVC_BUF_STATE_ACTIVE = 2, 309 UVC_BUF_STATE_READY = 3, 310 UVC_BUF_STATE_DONE = 4, 311 UVC_BUF_STATE_ERROR = 5, 312}; 313 314struct uvc_buffer { 315 struct vb2_v4l2_buffer buf; 316 struct list_head queue; 317 318 enum uvc_buffer_state state; 319 unsigned int error; 320 321 void *mem; 322 unsigned int length; 323 unsigned int bytesused; 324 325 u32 pts; 326 327 /* Asynchronous buffer handling. */ 328 struct kref ref; 329}; 330 331#define UVC_QUEUE_DISCONNECTED (1 << 0) 332 333struct uvc_video_queue { 334 struct video_device vdev; 335 struct vb2_queue queue; 336 struct mutex mutex; /* 337 * Serializes vb2_queue and 338 * fops 339 */ 340 341 unsigned int flags; 342 unsigned int buf_used; 343 344 spinlock_t irqlock; /* Protects irqqueue */ 345 struct list_head irqqueue; 346}; 347 348struct uvc_video_chain { 349 struct uvc_device *dev; 350 struct list_head list; 351 352 struct list_head entities; /* All entities */ 353 struct uvc_entity *processing; /* Processing unit */ 354 struct uvc_entity *selector; /* Selector unit */ 355 356 struct mutex ctrl_mutex; /* 357 * Protects ctrl.info, 358 * ctrl.handle and 359 * uvc_fh.pending_async_ctrls 360 */ 361 362 struct v4l2_prio_state prio; /* V4L2 priority state */ 363 u32 caps; /* V4L2 chain-wide caps */ 364 u8 ctrl_class_bitmap; /* Bitmap of valid classes */ 365}; 366 367struct uvc_stats_frame { 368 unsigned int size; /* Number of bytes captured */ 369 unsigned int first_data; /* Index of the first non-empty packet */ 370 371 unsigned int nb_packets; /* Number of packets */ 372 unsigned int nb_empty; /* Number of empty packets */ 373 unsigned int nb_invalid; /* Number of packets with an invalid header */ 374 unsigned int nb_errors; /* Number of packets with the error bit set */ 375 376 unsigned int nb_pts; /* Number of packets with a PTS timestamp */ 377 unsigned int nb_pts_diffs; /* Number of PTS differences inside a frame */ 378 unsigned int last_pts_diff; /* Index of the last PTS difference */ 379 bool has_initial_pts; /* Whether the first non-empty packet has a PTS */ 380 bool has_early_pts; /* Whether a PTS is present before the first non-empty packet */ 381 u32 pts; /* PTS of the last packet */ 382 383 unsigned int nb_scr; /* Number of packets with a SCR timestamp */ 384 unsigned int nb_scr_diffs; /* Number of SCR.STC differences inside a frame */ 385 u16 scr_sof; /* SCR.SOF of the last packet */ 386 u32 scr_stc; /* SCR.STC of the last packet */ 387}; 388 389struct uvc_stats_stream { 390 ktime_t start_ts; /* Stream start timestamp */ 391 ktime_t stop_ts; /* Stream stop timestamp */ 392 393 unsigned int nb_frames; /* Number of frames */ 394 395 unsigned int nb_packets; /* Number of packets */ 396 unsigned int nb_empty; /* Number of empty packets */ 397 unsigned int nb_invalid; /* Number of packets with an invalid header */ 398 unsigned int nb_errors; /* Number of packets with the error bit set */ 399 400 unsigned int nb_pts_constant; /* Number of frames with constant PTS */ 401 unsigned int nb_pts_early; /* Number of frames with early PTS */ 402 unsigned int nb_pts_initial; /* Number of frames with initial PTS */ 403 404 unsigned int nb_scr_count_ok; /* Number of frames with at least one SCR per non empty packet */ 405 unsigned int nb_scr_diffs_ok; /* Number of frames with varying SCR.STC */ 406 unsigned int scr_sof_count; /* STC.SOF counter accumulated since stream start */ 407 unsigned int scr_sof; /* STC.SOF of the last packet */ 408 unsigned int min_sof; /* Minimum STC.SOF value */ 409 unsigned int max_sof; /* Maximum STC.SOF value */ 410}; 411 412#define UVC_METADATA_BUF_SIZE 10240 413 414/** 415 * struct uvc_copy_op: Context structure to schedule asynchronous memcpy 416 * 417 * @buf: active buf object for this operation 418 * @dst: copy destination address 419 * @src: copy source address 420 * @len: copy length 421 */ 422struct uvc_copy_op { 423 struct uvc_buffer *buf; 424 void *dst; 425 const __u8 *src; 426 size_t len; 427}; 428 429/** 430 * struct uvc_urb - URB context management structure 431 * 432 * @urb: the URB described by this context structure 433 * @stream: UVC streaming context 434 * @buffer: memory storage for the URB 435 * @dma: Allocated DMA handle 436 * @sgt: sgt_table with the urb locations in memory 437 * @async_operations: counter to indicate the number of copy operations 438 * @copy_operations: work descriptors for asynchronous copy operations 439 * @work: work queue entry for asynchronous decode 440 */ 441struct uvc_urb { 442 struct urb *urb; 443 struct uvc_streaming *stream; 444 445 char *buffer; 446 dma_addr_t dma; 447 struct sg_table *sgt; 448 449 unsigned int async_operations; 450 struct uvc_copy_op copy_operations[UVC_MAX_PACKETS]; 451 struct work_struct work; 452}; 453 454struct uvc_streaming { 455 struct list_head list; 456 struct uvc_device *dev; 457 struct uvc_video_chain *chain; 458 atomic_t active; 459 460 struct usb_interface *intf; 461 int intfnum; 462 u32 maxpsize; 463 464 struct uvc_streaming_header header; 465 enum v4l2_buf_type type; 466 467 unsigned int nformats; 468 const struct uvc_format *formats; 469 470 struct uvc_streaming_control ctrl; 471 const struct uvc_format *def_format; 472 const struct uvc_format *cur_format; 473 const struct uvc_frame *cur_frame; 474 475 /* Buffers queue. */ 476 unsigned int frozen : 1; 477 struct uvc_video_queue queue; 478 struct workqueue_struct *async_wq; 479 void (*decode)(struct uvc_urb *uvc_urb, struct uvc_buffer *buf, 480 struct uvc_buffer *meta_buf); 481 482 struct { 483 struct uvc_video_queue queue; 484 u32 format; 485 } meta; 486 487 /* Context data used by the bulk completion handler. */ 488 struct { 489 u8 header[256]; 490 unsigned int header_size; 491 int skip_payload; 492 u32 payload_size; 493 u32 max_payload_size; 494 } bulk; 495 496 struct uvc_urb uvc_urb[UVC_URBS]; 497 unsigned int urb_size; 498 499 u32 sequence; 500 u8 last_fid; 501 502 /* debugfs */ 503 struct dentry *debugfs_dir; 504 struct { 505 struct uvc_stats_frame frame; 506 struct uvc_stats_stream stream; 507 } stats; 508 509 /* Timestamps support. */ 510 struct uvc_clock { 511 struct uvc_clock_sample { 512 u32 dev_stc; 513 u16 dev_sof; 514 u16 host_sof; 515 ktime_t host_time; 516 } *samples; 517 518 unsigned int head; 519 unsigned int count; 520 unsigned int size; 521 unsigned int last_sof_overflow; 522 523 u16 last_sof; 524 u16 sof_offset; 525 526 u8 last_scr[6]; 527 528 spinlock_t lock; 529 } clock; 530}; 531 532#define for_each_uvc_urb(uvc_urb, uvc_streaming) \ 533 for ((uvc_urb) = &(uvc_streaming)->uvc_urb[0]; \ 534 (uvc_urb) < &(uvc_streaming)->uvc_urb[UVC_URBS]; \ 535 ++(uvc_urb)) 536 537static inline u32 uvc_urb_index(const struct uvc_urb *uvc_urb) 538{ 539 return uvc_urb - &uvc_urb->stream->uvc_urb[0]; 540} 541 542struct uvc_device_info { 543 u32 quirks; 544 u32 meta_format; 545 u16 uvc_version; 546}; 547 548struct uvc_rect { 549 u16 top; 550 u16 left; 551 u16 bottom; 552 u16 right; 553} __packed; 554 555struct uvc_status_streaming { 556 u8 button; 557} __packed; 558 559struct uvc_status_control { 560 u8 bSelector; 561 u8 bAttribute; 562 u8 bValue[11]; 563} __packed; 564 565struct uvc_status { 566 u8 bStatusType; 567 u8 bOriginator; 568 u8 bEvent; 569 union { 570 struct uvc_status_control control; 571 struct uvc_status_streaming streaming; 572 }; 573} __packed; 574 575#define UVC_MAX_META_DATA_FORMATS 3 576 577struct uvc_device { 578 struct usb_device *udev; 579 struct usb_interface *intf; 580 unsigned long warnings; 581 u32 quirks; 582 int intfnum; 583 char name[32]; 584 585 const struct uvc_device_info *info; 586 587 u32 meta_formats[UVC_MAX_META_DATA_FORMATS]; 588 unsigned int nmeta_formats; 589 590 atomic_t nmappings; 591 592 /* Video control interface */ 593#ifdef CONFIG_MEDIA_CONTROLLER 594 struct media_device mdev; 595#endif 596 struct v4l2_device vdev; 597 u16 uvc_version; 598 u32 clock_frequency; 599 600 struct list_head entities; 601 struct list_head chains; 602 603 /* Video Streaming interfaces */ 604 struct list_head streams; 605 struct kref ref; 606 607 /* Status Interrupt Endpoint */ 608 struct usb_host_endpoint *int_ep; 609 struct urb *int_urb; 610 struct uvc_status *status; 611 struct mutex status_lock; /* Protects status_users */ 612 unsigned int status_users; 613 bool flush_status; 614 615 struct input_dev *input; 616 char input_phys[64]; 617 618 struct uvc_ctrl_work { 619 struct work_struct work; 620 struct urb *urb; 621 struct uvc_video_chain *chain; 622 struct uvc_control *ctrl; 623 const void *data; 624 } async_ctrl; 625 626 struct uvc_entity *gpio_unit; 627}; 628 629struct uvc_fh { 630 struct v4l2_fh vfh; 631 struct uvc_video_chain *chain; 632 struct uvc_streaming *stream; 633 unsigned int pending_async_ctrls; 634}; 635 636static inline struct uvc_fh *to_uvc_fh(struct file *filp) 637{ 638 return container_of(file_to_v4l2_fh(filp), struct uvc_fh, vfh); 639} 640 641/* ------------------------------------------------------------------------ 642 * Debugging, printing and logging 643 */ 644 645#define UVC_DBG_PROBE (1 << 0) 646#define UVC_DBG_DESCR (1 << 1) 647#define UVC_DBG_CONTROL (1 << 2) 648#define UVC_DBG_FORMAT (1 << 3) 649#define UVC_DBG_CAPTURE (1 << 4) 650#define UVC_DBG_CALLS (1 << 5) 651#define UVC_DBG_FRAME (1 << 7) 652#define UVC_DBG_SUSPEND (1 << 8) 653#define UVC_DBG_STATUS (1 << 9) 654#define UVC_DBG_VIDEO (1 << 10) 655#define UVC_DBG_STATS (1 << 11) 656#define UVC_DBG_CLOCK (1 << 12) 657 658#define UVC_WARN_MINMAX 0 659#define UVC_WARN_PROBE_DEF 1 660#define UVC_WARN_XU_GET_RES 2 661 662extern unsigned int uvc_clock_param; 663extern unsigned int uvc_no_drop_param; 664extern unsigned int uvc_dbg_param; 665extern unsigned int uvc_timeout_param; 666extern unsigned int uvc_hw_timestamps_param; 667 668#define uvc_dbg(_dev, flag, fmt, ...) \ 669do { \ 670 if (uvc_dbg_param & UVC_DBG_##flag) \ 671 dev_printk(KERN_DEBUG, &(_dev)->intf->dev, fmt, \ 672 ##__VA_ARGS__); \ 673} while (0) 674 675#define uvc_dbg_cont(flag, fmt, ...) \ 676do { \ 677 if (uvc_dbg_param & UVC_DBG_##flag) \ 678 pr_cont(fmt, ##__VA_ARGS__); \ 679} while (0) 680 681#define uvc_warn_once(_dev, warn, fmt, ...) \ 682do { \ 683 if (!test_and_set_bit(warn, &(_dev)->warnings)) \ 684 dev_info(&(_dev)->intf->dev, fmt, ##__VA_ARGS__); \ 685} while (0) 686 687/* -------------------------------------------------------------------------- 688 * Internal functions. 689 */ 690 691struct uvc_entity *uvc_entity_by_id(struct uvc_device *dev, int id); 692 693/* Video buffers queue management. */ 694int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type); 695void uvc_queue_cancel(struct uvc_video_queue *queue, int disconnect); 696struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue, 697 struct uvc_buffer *buf); 698struct uvc_buffer *uvc_queue_get_current_buffer(struct uvc_video_queue *queue); 699void uvc_queue_buffer_release(struct uvc_buffer *buf); 700static inline int uvc_queue_streaming(struct uvc_video_queue *queue) 701{ 702 return vb2_is_streaming(&queue->queue); 703} 704 705static inline struct uvc_streaming * 706uvc_queue_to_stream(struct uvc_video_queue *queue) 707{ 708 return container_of(queue, struct uvc_streaming, queue); 709} 710 711/* V4L2 interface */ 712extern const struct v4l2_ioctl_ops uvc_ioctl_ops; 713extern const struct v4l2_file_operations uvc_fops; 714 715/* Media controller */ 716int uvc_mc_register_entities(struct uvc_video_chain *chain); 717void uvc_mc_cleanup_entity(struct uvc_entity *entity); 718 719/* Video */ 720int uvc_video_init(struct uvc_streaming *stream); 721int uvc_video_suspend(struct uvc_streaming *stream); 722int uvc_video_resume(struct uvc_streaming *stream, int reset); 723int uvc_video_start_streaming(struct uvc_streaming *stream); 724void uvc_video_stop_streaming(struct uvc_streaming *stream); 725int uvc_probe_video(struct uvc_streaming *stream, 726 struct uvc_streaming_control *probe); 727int uvc_query_ctrl(struct uvc_device *dev, u8 query, u8 unit, 728 u8 intfnum, u8 cs, void *data, u16 size); 729void uvc_video_clock_update(struct uvc_streaming *stream, 730 struct vb2_v4l2_buffer *vbuf, 731 struct uvc_buffer *buf); 732int uvc_meta_init(struct uvc_device *dev); 733int uvc_meta_register(struct uvc_streaming *stream); 734 735int uvc_register_video_device(struct uvc_device *dev, 736 struct uvc_streaming *stream, 737 struct uvc_video_queue *queue, 738 enum v4l2_buf_type type, 739 const struct v4l2_file_operations *fops, 740 const struct v4l2_ioctl_ops *ioctl_ops); 741 742/* Status */ 743int uvc_status_init(struct uvc_device *dev); 744void uvc_status_unregister(struct uvc_device *dev); 745void uvc_status_cleanup(struct uvc_device *dev); 746int uvc_status_resume(struct uvc_device *dev); 747void uvc_status_suspend(struct uvc_device *dev); 748int uvc_status_get(struct uvc_device *dev); 749void uvc_status_put(struct uvc_device *dev); 750 751/* PM */ 752int uvc_pm_get(struct uvc_device *dev); 753void uvc_pm_put(struct uvc_device *dev); 754 755/* Controls */ 756extern const struct v4l2_subscribed_event_ops uvc_ctrl_sub_ev_ops; 757 758int uvc_query_v4l2_ctrl(struct uvc_video_chain *chain, 759 struct v4l2_query_ext_ctrl *v4l2_ctrl); 760int uvc_query_v4l2_menu(struct uvc_video_chain *chain, 761 struct v4l2_querymenu *query_menu); 762 763int uvc_ctrl_add_mapping(struct uvc_video_chain *chain, 764 const struct uvc_control_mapping *mapping); 765int uvc_ctrl_init_device(struct uvc_device *dev); 766void uvc_ctrl_cleanup_device(struct uvc_device *dev); 767int uvc_ctrl_restore_values(struct uvc_device *dev); 768bool uvc_ctrl_status_event_async(struct urb *urb, struct uvc_video_chain *chain, 769 struct uvc_control *ctrl, const u8 *data); 770void uvc_ctrl_status_event(struct uvc_video_chain *chain, 771 struct uvc_control *ctrl, const u8 *data); 772 773int uvc_ctrl_begin(struct uvc_video_chain *chain); 774int __uvc_ctrl_commit(struct uvc_fh *handle, int rollback, 775 struct v4l2_ext_controls *ctrls); 776static inline int uvc_ctrl_commit(struct uvc_fh *handle, 777 struct v4l2_ext_controls *ctrls) 778{ 779 return __uvc_ctrl_commit(handle, 0, ctrls); 780} 781static inline int uvc_ctrl_rollback(struct uvc_fh *handle) 782{ 783 return __uvc_ctrl_commit(handle, 1, NULL); 784} 785 786int uvc_ctrl_get(struct uvc_video_chain *chain, u32 which, 787 struct v4l2_ext_control *xctrl); 788int uvc_ctrl_set(struct uvc_fh *handle, struct v4l2_ext_control *xctrl); 789int uvc_ctrl_is_accessible(struct uvc_video_chain *chain, u32 v4l2_id, 790 const struct v4l2_ext_controls *ctrls, u32 which, 791 unsigned long ioctl); 792 793int uvc_xu_ctrl_query(struct uvc_video_chain *chain, 794 struct uvc_xu_control_query *xqry); 795 796void uvc_ctrl_cleanup_fh(struct uvc_fh *handle); 797 798/* Utility functions */ 799struct usb_host_endpoint *uvc_find_endpoint(struct usb_host_interface *alts, 800 u8 epaddr); 801/* Quirks support */ 802void uvc_video_decode_isight(struct uvc_urb *uvc_urb, 803 struct uvc_buffer *buf, 804 struct uvc_buffer *meta_buf); 805 806/* debugfs and statistics */ 807void uvc_debugfs_init(void); 808void uvc_debugfs_cleanup(void); 809void uvc_debugfs_init_stream(struct uvc_streaming *stream); 810void uvc_debugfs_cleanup_stream(struct uvc_streaming *stream); 811 812size_t uvc_video_stats_dump(struct uvc_streaming *stream, char *buf, 813 size_t size); 814 815#endif
~/
Read-only file preview.