USB: add SPDX identifiers to all remaining files in drivers/usb/
[linux-2.6-block.git] / drivers / usb / gadget / function / 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  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License version 2 as
14  * published by the Free Software Foundation.
15  */
16
17 #ifndef U_UVC_H
18 #define U_UVC_H
19
20 #include <linux/usb/composite.h>
21 #include <linux/usb/video.h>
22
23 #define fi_to_f_uvc_opts(f)     container_of(f, struct f_uvc_opts, func_inst)
24
25 struct f_uvc_opts {
26         struct usb_function_instance                    func_inst;
27         unsigned int                                    uvc_gadget_trace_param;
28         unsigned int                                    streaming_interval;
29         unsigned int                                    streaming_maxpacket;
30         unsigned int                                    streaming_maxburst;
31
32         /*
33          * Control descriptors array pointers for full-/high-speed and
34          * super-speed. They point by default to the uvc_fs_control_cls and
35          * uvc_ss_control_cls arrays respectively. Legacy gadgets must
36          * override them in their gadget bind callback.
37          */
38         const struct uvc_descriptor_header * const      *fs_control;
39         const struct uvc_descriptor_header * const      *ss_control;
40
41         /*
42          * Streaming descriptors array pointers for full-speed, high-speed and
43          * super-speed. They will point to the uvc_[fhs]s_streaming_cls arrays
44          * for configfs-based gadgets. Legacy gadgets must initialize them in
45          * their gadget bind callback.
46          */
47         const struct uvc_descriptor_header * const      *fs_streaming;
48         const struct uvc_descriptor_header * const      *hs_streaming;
49         const struct uvc_descriptor_header * const      *ss_streaming;
50
51         /* Default control descriptors for configfs-based gadgets. */
52         struct uvc_camera_terminal_descriptor           uvc_camera_terminal;
53         struct uvc_processing_unit_descriptor           uvc_processing;
54         struct uvc_output_terminal_descriptor           uvc_output_terminal;
55         struct uvc_color_matching_descriptor            uvc_color_matching;
56
57         /*
58          * Control descriptors pointers arrays for full-/high-speed and
59          * super-speed. The first element is a configurable control header
60          * descriptor, the other elements point to the fixed default control
61          * descriptors. Used by configfs only, must not be touched by legacy
62          * gadgets.
63          */
64         struct uvc_descriptor_header                    *uvc_fs_control_cls[5];
65         struct uvc_descriptor_header                    *uvc_ss_control_cls[5];
66
67         /*
68          * Streaming descriptors for full-speed, high-speed and super-speed.
69          * Used by configfs only, must not be touched by legacy gadgets. The
70          * arrays are allocated at runtime as the number of descriptors isn't
71          * known in advance.
72          */
73         struct uvc_descriptor_header                    **uvc_fs_streaming_cls;
74         struct uvc_descriptor_header                    **uvc_hs_streaming_cls;
75         struct uvc_descriptor_header                    **uvc_ss_streaming_cls;
76
77         /*
78          * Read/write access to configfs attributes is handled by configfs.
79          *
80          * This lock protects the descriptors from concurrent access by
81          * read/write and symlink creation/removal.
82          */
83         struct mutex                    lock;
84         int                             refcnt;
85 };
86
87 void uvc_set_trace_param(unsigned int trace);
88
89 #endif /* U_UVC_H */
90