.. | .. |
---|
1 | | -// SPDX-License-Identifier: GPL-2.0+ |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0+ */ |
---|
2 | 2 | /* |
---|
3 | 3 | * uvc_gadget.h -- USB Video Class Gadget driver |
---|
4 | 4 | * |
---|
.. | .. |
---|
11 | 11 | |
---|
12 | 12 | #include <linux/list.h> |
---|
13 | 13 | #include <linux/mutex.h> |
---|
| 14 | +#include <linux/pm_qos.h> |
---|
14 | 15 | #include <linux/spinlock.h> |
---|
15 | 16 | #include <linux/usb/composite.h> |
---|
16 | 17 | #include <linux/videodev2.h> |
---|
17 | | -#include <linux/pm_qos.h> |
---|
| 18 | +#include <linux/wait.h> |
---|
18 | 19 | |
---|
19 | 20 | #include <media/v4l2-device.h> |
---|
20 | 21 | #include <media/v4l2-dev.h> |
---|
.. | .. |
---|
25 | 26 | struct usb_ep; |
---|
26 | 27 | struct usb_request; |
---|
27 | 28 | struct uvc_descriptor_header; |
---|
| 29 | +struct uvc_device; |
---|
28 | 30 | |
---|
29 | 31 | /* ------------------------------------------------------------------------ |
---|
30 | 32 | * Debugging, printing and logging |
---|
.. | .. |
---|
52 | 54 | printk(KERN_DEBUG "uvcvideo: " msg); \ |
---|
53 | 55 | } while (0) |
---|
54 | 56 | |
---|
55 | | -#define uvc_warn_once(dev, warn, msg...) \ |
---|
56 | | - do { \ |
---|
57 | | - if (!test_and_set_bit(warn, &dev->warnings)) \ |
---|
58 | | - printk(KERN_INFO "uvcvideo: " msg); \ |
---|
59 | | - } while (0) |
---|
60 | | - |
---|
61 | | -#define uvc_printk(level, msg...) \ |
---|
62 | | - printk(level "uvcvideo: " msg) |
---|
| 57 | +#define uvcg_dbg(f, fmt, args...) \ |
---|
| 58 | + dev_dbg(&(f)->config->cdev->gadget->dev, "%s: " fmt, (f)->name, ##args) |
---|
| 59 | +#define uvcg_info(f, fmt, args...) \ |
---|
| 60 | + dev_info(&(f)->config->cdev->gadget->dev, "%s: " fmt, (f)->name, ##args) |
---|
| 61 | +#define uvcg_warn(f, fmt, args...) \ |
---|
| 62 | + dev_warn(&(f)->config->cdev->gadget->dev, "%s: " fmt, (f)->name, ##args) |
---|
| 63 | +#define uvcg_err(f, fmt, args...) \ |
---|
| 64 | + dev_err(&(f)->config->cdev->gadget->dev, "%s: " fmt, (f)->name, ##args) |
---|
63 | 65 | |
---|
64 | 66 | /* ------------------------------------------------------------------------ |
---|
65 | 67 | * Driver specific constants |
---|
66 | 68 | */ |
---|
67 | 69 | |
---|
68 | | -#define UVC_NUM_REQUESTS 4 |
---|
69 | 70 | #define UVC_MAX_REQUEST_SIZE 64 |
---|
70 | 71 | #define UVC_MAX_EVENTS 4 |
---|
71 | | -#define UVC_MAX_NUM_REQUESTS 8 |
---|
72 | 72 | |
---|
73 | 73 | /* ------------------------------------------------------------------------ |
---|
74 | 74 | * Structures |
---|
75 | 75 | */ |
---|
| 76 | +struct uvc_request { |
---|
| 77 | + struct usb_request *req; |
---|
| 78 | + u8 *req_buffer; |
---|
| 79 | + struct uvc_video *video; |
---|
| 80 | +#if defined(CONFIG_ARCH_ROCKCHIP) && defined(CONFIG_NO_GKI) |
---|
| 81 | + struct completion req_done; |
---|
| 82 | +#endif |
---|
| 83 | +}; |
---|
76 | 84 | |
---|
77 | 85 | struct uvc_video { |
---|
| 86 | + struct uvc_device *uvc; |
---|
78 | 87 | struct usb_ep *ep; |
---|
| 88 | + |
---|
79 | 89 | struct work_struct pump; |
---|
80 | 90 | struct workqueue_struct *async_wq; |
---|
81 | 91 | |
---|
.. | .. |
---|
87 | 97 | unsigned int imagesize; |
---|
88 | 98 | struct mutex mutex; /* protects frame parameters */ |
---|
89 | 99 | |
---|
| 100 | + unsigned int uvc_num_requests; |
---|
| 101 | + |
---|
90 | 102 | /* Requests */ |
---|
91 | 103 | unsigned int req_size; |
---|
92 | | - struct usb_request *req[UVC_MAX_NUM_REQUESTS]; |
---|
93 | | - __u8 *req_buffer[UVC_MAX_NUM_REQUESTS]; |
---|
| 104 | + struct uvc_request *ureq; |
---|
94 | 105 | struct list_head req_free; |
---|
95 | 106 | spinlock_t req_lock; |
---|
96 | 107 | |
---|
.. | .. |
---|
117 | 128 | enum uvc_state state; |
---|
118 | 129 | struct usb_function func; |
---|
119 | 130 | struct uvc_video video; |
---|
| 131 | + bool func_connected; |
---|
| 132 | + wait_queue_head_t func_connected_queue; |
---|
120 | 133 | /* for creating and issuing QoS requests */ |
---|
121 | 134 | struct pm_qos_request pm_qos; |
---|
122 | 135 | |
---|
.. | .. |
---|
150 | 163 | struct uvc_file_handle { |
---|
151 | 164 | struct v4l2_fh vfh; |
---|
152 | 165 | struct uvc_video *device; |
---|
| 166 | + bool is_uvc_app_handle; |
---|
153 | 167 | }; |
---|
154 | 168 | |
---|
155 | 169 | #define to_uvc_file_handle(handle) \ |
---|