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 DECLARE_UVC_EXTENSION_UNIT_DESCRIPTOR(1, 1); 22 23 struct f_uvc_opts { 24 struct usb_function_instance func_inst; 25 bool streaming_bulk; 26 unsigned int streaming_interval; 27 unsigned int streaming_maxpacket; 28 unsigned int streaming_maxburst; 29 #if defined(CONFIG_ARCH_ROCKCHIP) && defined(CONFIG_NO_GKI) 30 bool device_name_allocated; 31 const char *device_name; 32 unsigned int uvc_num_request; 33 unsigned int uvc_zero_copy; 34 #endif 35 36 unsigned int control_interface; 37 unsigned int streaming_interface; 38 char function_name[32]; 39 40 /* 41 * Control descriptors array pointers for full-/high-speed and 42 * super-speed. They point by default to the uvc_fs_control_cls and 43 * uvc_ss_control_cls arrays respectively. Legacy gadgets must 44 * override them in their gadget bind callback. 45 */ 46 const struct uvc_descriptor_header * const *fs_control; 47 const struct uvc_descriptor_header * const *ss_control; 48 49 /* 50 * Streaming descriptors array pointers for full-speed, high-speed and 51 * super-speed. They will point to the uvc_[fhs]s_streaming_cls arrays 52 * for configfs-based gadgets. Legacy gadgets must initialize them in 53 * their gadget bind callback. 54 */ 55 const struct uvc_descriptor_header * const *fs_streaming; 56 const struct uvc_descriptor_header * const *hs_streaming; 57 const struct uvc_descriptor_header * const *ss_streaming; 58 59 /* Default control descriptors for configfs-based gadgets. */ 60 struct uvc_camera_terminal_descriptor uvc_camera_terminal; 61 struct uvc_processing_unit_descriptor uvc_processing; 62 struct uvc_output_terminal_descriptor uvc_output_terminal; 63 struct UVC_EXTENSION_UNIT_DESCRIPTOR(1, 1) uvc_extension; 64 struct uvc_color_matching_descriptor uvc_color_matching; 65 66 /* 67 * Control descriptors pointers arrays for full-/high-speed and 68 * super-speed. The first element is a configurable control header 69 * descriptor, the other elements point to the fixed default control 70 * descriptors. Used by configfs only, must not be touched by legacy 71 * gadgets. 72 */ 73 struct uvc_descriptor_header *uvc_fs_control_cls[6]; 74 struct uvc_descriptor_header *uvc_ss_control_cls[6]; 75 76 /* 77 * Streaming descriptors for full-speed, high-speed and super-speed. 78 * Used by configfs only, must not be touched by legacy gadgets. The 79 * arrays are allocated at runtime as the number of descriptors isn't 80 * known in advance. 81 */ 82 struct uvc_descriptor_header **uvc_fs_streaming_cls; 83 struct uvc_descriptor_header **uvc_hs_streaming_cls; 84 struct uvc_descriptor_header **uvc_ss_streaming_cls; 85 86 /* 87 * Read/write access to configfs attributes is handled by configfs. 88 * 89 * This lock protects the descriptors from concurrent access by 90 * read/write and symlink creation/removal. 91 */ 92 struct mutex lock; 93 int refcnt; 94 int pm_qos_latency; 95 }; 96 97 #endif /* U_UVC_H */ 98