brintos

brintos / linux-shallow public Read only

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