summaryrefslogtreecommitdiff
path: root/drivers/usb/gadget/function/u_uvc.h
blob: 1ce58f61253c9afaa53f51bf3e6164bb87a90321 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * u_uvc.h
 *
 * Utility definitions for the uvc function
 *
 * Copyright (c) 2013-2014 Samsung Electronics Co., Ltd.
 *		http://www.samsung.com
 *
 * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
 */

#ifndef U_UVC_H
#define U_UVC_H

#include <linux/mutex.h>
#include <linux/usb/composite.h>
#include <linux/usb/video.h>

#define fi_to_f_uvc_opts(f)	container_of(f, struct f_uvc_opts, func_inst)

struct f_uvc_opts {
	struct usb_function_instance			func_inst;
	unsigned int					streaming_interval;
	unsigned int					streaming_maxpacket;
	unsigned int					streaming_maxburst;

	unsigned int					control_interface;
	unsigned int					streaming_interface;
	char						function_name[32];
	unsigned int					last_unit_id;

	bool						enable_interrupt_ep;

	/*
	 * Control descriptors array pointers for full-/high-speed and
	 * super-speed. They point by default to the uvc_fs_control_cls and
	 * uvc_ss_control_cls arrays respectively. Legacy gadgets must
	 * override them in their gadget bind callback.
	 */
	const struct uvc_descriptor_header * const	*fs_control;
	const struct uvc_descriptor_header * const	*ss_control;

	/*
	 * Streaming descriptors array pointers for full-speed, high-speed and
	 * super-speed. They will point to the uvc_[fhs]s_streaming_cls arrays
	 * for configfs-based gadgets. Legacy gadgets must initialize them in
	 * their gadget bind callback.
	 */
	const struct uvc_descriptor_header * const	*fs_streaming;
	const struct uvc_descriptor_header * const	*hs_streaming;
	const struct uvc_descriptor_header * const	*ss_streaming;

	/* Default control descriptors for configfs-based gadgets. */
	struct uvc_camera_terminal_descriptor		uvc_camera_terminal;
	struct uvc_processing_unit_descriptor		uvc_processing;
	struct uvc_output_terminal_descriptor		uvc_output_terminal;

	/*
	 * Control descriptors pointers arrays for full-/high-speed and
	 * super-speed. The first element is a configurable control header
	 * descriptor, the other elements point to the fixed default control
	 * descriptors. Used by configfs only, must not be touched by legacy
	 * gadgets.
	 */
	struct uvc_descriptor_header			*uvc_fs_control_cls[5];
	struct uvc_descriptor_header			*uvc_ss_control_cls[5];

	/*
	 * Control descriptors for extension units. There could be any number
	 * of these, including none at all.
	 */
	struct list_head				extension_units;

	/*
	 * Streaming descriptors for full-speed, high-speed and super-speed.
	 * Used by configfs only, must not be touched by legacy gadgets. The
	 * arrays are allocated at runtime as the number of descriptors isn't
	 * known in advance.
	 */
	struct uvc_descriptor_header			**uvc_fs_streaming_cls;
	struct uvc_descriptor_header			**uvc_hs_streaming_cls;
	struct uvc_descriptor_header			**uvc_ss_streaming_cls;

	/*
	 * Indexes into the function's string descriptors allowing users to set
	 * custom descriptions rather than the hard-coded defaults.
	 */
	u8						iad_index;
	u8						vs0_index;
	u8						vs1_index;

	/*
	 * Read/write access to configfs attributes is handled by configfs.
	 *
	 * This lock protects the descriptors from concurrent access by
	 * read/write and symlink creation/removal.
	 */
	struct mutex			lock;
	int				refcnt;
};

#endif /* U_UVC_H */