Loading...
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * u_uvc.h
4 *
5 * Utility definitions for the uvc function
6 *
7 * Copyright (c) 2013-2014 Samsung Electronics Co., Ltd.
8 * http://www.samsung.com
9 *
10 * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
11 */
12
13#ifndef U_UVC_H
14#define U_UVC_H
15
16#include <linux/mutex.h>
17#include <linux/usb/composite.h>
18#include <linux/usb/video.h>
19
20#define fi_to_f_uvc_opts(f) container_of(f, struct f_uvc_opts, func_inst)
21
22struct f_uvc_opts {
23 struct usb_function_instance func_inst;
24 unsigned int streaming_interval;
25 unsigned int streaming_maxpacket;
26 unsigned int streaming_maxburst;
27
28 unsigned int control_interface;
29 unsigned int streaming_interface;
30 char function_name[32];
31 unsigned int last_unit_id;
32
33 bool enable_interrupt_ep;
34
35 /*
36 * Control descriptors array pointers for full-/high-speed and
37 * super-speed. They point by default to the uvc_fs_control_cls and
38 * uvc_ss_control_cls arrays respectively. Legacy gadgets must
39 * override them in their gadget bind callback.
40 */
41 const struct uvc_descriptor_header * const *fs_control;
42 const struct uvc_descriptor_header * const *ss_control;
43
44 /*
45 * Streaming descriptors array pointers for full-speed, high-speed and
46 * super-speed. They will point to the uvc_[fhs]s_streaming_cls arrays
47 * for configfs-based gadgets. Legacy gadgets must initialize them in
48 * their gadget bind callback.
49 */
50 const struct uvc_descriptor_header * const *fs_streaming;
51 const struct uvc_descriptor_header * const *hs_streaming;
52 const struct uvc_descriptor_header * const *ss_streaming;
53
54 /* Default control descriptors for configfs-based gadgets. */
55 struct uvc_camera_terminal_descriptor uvc_camera_terminal;
56 struct uvc_processing_unit_descriptor uvc_processing;
57 struct uvc_output_terminal_descriptor uvc_output_terminal;
58
59 /*
60 * Control descriptors pointers arrays for full-/high-speed and
61 * super-speed. The first element is a configurable control header
62 * descriptor, the other elements point to the fixed default control
63 * descriptors. Used by configfs only, must not be touched by legacy
64 * gadgets.
65 */
66 struct uvc_descriptor_header *uvc_fs_control_cls[5];
67 struct uvc_descriptor_header *uvc_ss_control_cls[5];
68
69 /*
70 * Control descriptors for extension units. There could be any number
71 * of these, including none at all.
72 */
73 struct list_head extension_units;
74
75 /*
76 * Streaming descriptors for full-speed, high-speed and super-speed.
77 * Used by configfs only, must not be touched by legacy gadgets. The
78 * arrays are allocated at runtime as the number of descriptors isn't
79 * known in advance.
80 */
81 struct uvc_descriptor_header **uvc_fs_streaming_cls;
82 struct uvc_descriptor_header **uvc_hs_streaming_cls;
83 struct uvc_descriptor_header **uvc_ss_streaming_cls;
84
85 /*
86 * Indexes into the function's string descriptors allowing users to set
87 * custom descriptions rather than the hard-coded defaults.
88 */
89 u8 iad_index;
90 u8 vs0_index;
91 u8 vs1_index;
92
93 /*
94 * Read/write access to configfs attributes is handled by configfs.
95 *
96 * This lock protects the descriptors from concurrent access by
97 * read/write and symlink creation/removal.
98 */
99 struct mutex lock;
100 int refcnt;
101
102 /*
103 * Only for legacy gadget. Shall be NULL for configfs-composed gadgets,
104 * which is guaranteed by alloc_inst implementation of f_uvc doing kzalloc.
105 */
106 struct uvcg_streaming_header *header;
107};
108
109#endif /* U_UVC_H */
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * u_uvc.h
4 *
5 * Utility definitions for the uvc function
6 *
7 * Copyright (c) 2013-2014 Samsung Electronics Co., Ltd.
8 * http://www.samsung.com
9 *
10 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
11 */
12
13#ifndef U_UVC_H
14#define U_UVC_H
15
16#include <linux/usb/composite.h>
17#include <linux/usb/video.h>
18
19#define fi_to_f_uvc_opts(f) container_of(f, struct f_uvc_opts, func_inst)
20
21struct f_uvc_opts {
22 struct usb_function_instance func_inst;
23 unsigned int uvc_gadget_trace_param;
24 unsigned int streaming_interval;
25 unsigned int streaming_maxpacket;
26 unsigned int streaming_maxburst;
27
28 /*
29 * Control descriptors array pointers for full-/high-speed and
30 * super-speed. They point by default to the uvc_fs_control_cls and
31 * uvc_ss_control_cls arrays respectively. Legacy gadgets must
32 * override them in their gadget bind callback.
33 */
34 const struct uvc_descriptor_header * const *fs_control;
35 const struct uvc_descriptor_header * const *ss_control;
36
37 /*
38 * Streaming descriptors array pointers for full-speed, high-speed and
39 * super-speed. They will point to the uvc_[fhs]s_streaming_cls arrays
40 * for configfs-based gadgets. Legacy gadgets must initialize them in
41 * their gadget bind callback.
42 */
43 const struct uvc_descriptor_header * const *fs_streaming;
44 const struct uvc_descriptor_header * const *hs_streaming;
45 const struct uvc_descriptor_header * const *ss_streaming;
46
47 /* Default control descriptors for configfs-based gadgets. */
48 struct uvc_camera_terminal_descriptor uvc_camera_terminal;
49 struct uvc_processing_unit_descriptor uvc_processing;
50 struct uvc_output_terminal_descriptor uvc_output_terminal;
51 struct uvc_color_matching_descriptor uvc_color_matching;
52
53 /*
54 * Control descriptors pointers arrays for full-/high-speed and
55 * super-speed. The first element is a configurable control header
56 * descriptor, the other elements point to the fixed default control
57 * descriptors. Used by configfs only, must not be touched by legacy
58 * gadgets.
59 */
60 struct uvc_descriptor_header *uvc_fs_control_cls[5];
61 struct uvc_descriptor_header *uvc_ss_control_cls[5];
62
63 /*
64 * Streaming descriptors for full-speed, high-speed and super-speed.
65 * Used by configfs only, must not be touched by legacy gadgets. The
66 * arrays are allocated at runtime as the number of descriptors isn't
67 * known in advance.
68 */
69 struct uvc_descriptor_header **uvc_fs_streaming_cls;
70 struct uvc_descriptor_header **uvc_hs_streaming_cls;
71 struct uvc_descriptor_header **uvc_ss_streaming_cls;
72
73 /*
74 * Read/write access to configfs attributes is handled by configfs.
75 *
76 * This lock protects the descriptors from concurrent access by
77 * read/write and symlink creation/removal.
78 */
79 struct mutex lock;
80 int refcnt;
81};
82
83void uvc_set_trace_param(unsigned int trace);
84
85#endif /* U_UVC_H */
86