| .. | .. |
|---|
| 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 | | - struct workqueue_struct *async_wq; |
|---|
| 81 | 90 | |
|---|
| 82 | 91 | /* Frame parameters */ |
|---|
| 83 | 92 | u8 bpp; |
|---|
| .. | .. |
|---|
| 87 | 96 | unsigned int imagesize; |
|---|
| 88 | 97 | struct mutex mutex; /* protects frame parameters */ |
|---|
| 89 | 98 | |
|---|
| 99 | + unsigned int uvc_num_requests; |
|---|
| 100 | + |
|---|
| 90 | 101 | /* Requests */ |
|---|
| 91 | 102 | unsigned int req_size; |
|---|
| 92 | | - struct usb_request *req[UVC_MAX_NUM_REQUESTS]; |
|---|
| 93 | | - __u8 *req_buffer[UVC_MAX_NUM_REQUESTS]; |
|---|
| 103 | + struct uvc_request *ureq; |
|---|
| 94 | 104 | struct list_head req_free; |
|---|
| 95 | 105 | spinlock_t req_lock; |
|---|
| 96 | 106 | |
|---|
| .. | .. |
|---|
| 117 | 127 | enum uvc_state state; |
|---|
| 118 | 128 | struct usb_function func; |
|---|
| 119 | 129 | struct uvc_video video; |
|---|
| 130 | + bool func_connected; |
|---|
| 131 | + wait_queue_head_t func_connected_queue; |
|---|
| 120 | 132 | /* for creating and issuing QoS requests */ |
|---|
| 121 | 133 | struct pm_qos_request pm_qos; |
|---|
| 122 | 134 | |
|---|
| .. | .. |
|---|
| 150 | 162 | struct uvc_file_handle { |
|---|
| 151 | 163 | struct v4l2_fh vfh; |
|---|
| 152 | 164 | struct uvc_video *device; |
|---|
| 165 | + bool is_uvc_app_handle; |
|---|
| 153 | 166 | }; |
|---|
| 154 | 167 | |
|---|
| 155 | 168 | #define to_uvc_file_handle(handle) \ |
|---|