1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * u_uvc.h 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * Utility definitions for the uvc function 6*4882a593Smuzhiyun * 7*4882a593Smuzhiyun * Copyright (c) 2013-2014 Samsung Electronics Co., Ltd. 8*4882a593Smuzhiyun * http://www.samsung.com 9*4882a593Smuzhiyun * 10*4882a593Smuzhiyun * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com> 11*4882a593Smuzhiyun */ 12*4882a593Smuzhiyun 13*4882a593Smuzhiyun #ifndef U_UVC_H 14*4882a593Smuzhiyun #define U_UVC_H 15*4882a593Smuzhiyun 16*4882a593Smuzhiyun #include <linux/mutex.h> 17*4882a593Smuzhiyun #include <linux/usb/composite.h> 18*4882a593Smuzhiyun #include <linux/usb/video.h> 19*4882a593Smuzhiyun 20*4882a593Smuzhiyun #define fi_to_f_uvc_opts(f) container_of(f, struct f_uvc_opts, func_inst) 21*4882a593Smuzhiyun DECLARE_UVC_EXTENSION_UNIT_DESCRIPTOR(1, 1); 22*4882a593Smuzhiyun 23*4882a593Smuzhiyun struct f_uvc_opts { 24*4882a593Smuzhiyun struct usb_function_instance func_inst; 25*4882a593Smuzhiyun bool streaming_bulk; 26*4882a593Smuzhiyun unsigned int streaming_interval; 27*4882a593Smuzhiyun unsigned int streaming_maxpacket; 28*4882a593Smuzhiyun unsigned int streaming_maxburst; 29*4882a593Smuzhiyun #if defined(CONFIG_ARCH_ROCKCHIP) && defined(CONFIG_NO_GKI) 30*4882a593Smuzhiyun bool device_name_allocated; 31*4882a593Smuzhiyun const char *device_name; 32*4882a593Smuzhiyun unsigned int uvc_num_request; 33*4882a593Smuzhiyun unsigned int uvc_zero_copy; 34*4882a593Smuzhiyun #endif 35*4882a593Smuzhiyun 36*4882a593Smuzhiyun unsigned int control_interface; 37*4882a593Smuzhiyun unsigned int streaming_interface; 38*4882a593Smuzhiyun char function_name[32]; 39*4882a593Smuzhiyun 40*4882a593Smuzhiyun /* 41*4882a593Smuzhiyun * Control descriptors array pointers for full-/high-speed and 42*4882a593Smuzhiyun * super-speed. They point by default to the uvc_fs_control_cls and 43*4882a593Smuzhiyun * uvc_ss_control_cls arrays respectively. Legacy gadgets must 44*4882a593Smuzhiyun * override them in their gadget bind callback. 45*4882a593Smuzhiyun */ 46*4882a593Smuzhiyun const struct uvc_descriptor_header * const *fs_control; 47*4882a593Smuzhiyun const struct uvc_descriptor_header * const *ss_control; 48*4882a593Smuzhiyun 49*4882a593Smuzhiyun /* 50*4882a593Smuzhiyun * Streaming descriptors array pointers for full-speed, high-speed and 51*4882a593Smuzhiyun * super-speed. They will point to the uvc_[fhs]s_streaming_cls arrays 52*4882a593Smuzhiyun * for configfs-based gadgets. Legacy gadgets must initialize them in 53*4882a593Smuzhiyun * their gadget bind callback. 54*4882a593Smuzhiyun */ 55*4882a593Smuzhiyun const struct uvc_descriptor_header * const *fs_streaming; 56*4882a593Smuzhiyun const struct uvc_descriptor_header * const *hs_streaming; 57*4882a593Smuzhiyun const struct uvc_descriptor_header * const *ss_streaming; 58*4882a593Smuzhiyun 59*4882a593Smuzhiyun /* Default control descriptors for configfs-based gadgets. */ 60*4882a593Smuzhiyun struct uvc_camera_terminal_descriptor uvc_camera_terminal; 61*4882a593Smuzhiyun struct uvc_processing_unit_descriptor uvc_processing; 62*4882a593Smuzhiyun struct uvc_output_terminal_descriptor uvc_output_terminal; 63*4882a593Smuzhiyun struct UVC_EXTENSION_UNIT_DESCRIPTOR(1, 1) uvc_extension; 64*4882a593Smuzhiyun struct uvc_color_matching_descriptor uvc_color_matching; 65*4882a593Smuzhiyun 66*4882a593Smuzhiyun /* 67*4882a593Smuzhiyun * Control descriptors pointers arrays for full-/high-speed and 68*4882a593Smuzhiyun * super-speed. The first element is a configurable control header 69*4882a593Smuzhiyun * descriptor, the other elements point to the fixed default control 70*4882a593Smuzhiyun * descriptors. Used by configfs only, must not be touched by legacy 71*4882a593Smuzhiyun * gadgets. 72*4882a593Smuzhiyun */ 73*4882a593Smuzhiyun struct uvc_descriptor_header *uvc_fs_control_cls[6]; 74*4882a593Smuzhiyun struct uvc_descriptor_header *uvc_ss_control_cls[6]; 75*4882a593Smuzhiyun 76*4882a593Smuzhiyun /* 77*4882a593Smuzhiyun * Streaming descriptors for full-speed, high-speed and super-speed. 78*4882a593Smuzhiyun * Used by configfs only, must not be touched by legacy gadgets. The 79*4882a593Smuzhiyun * arrays are allocated at runtime as the number of descriptors isn't 80*4882a593Smuzhiyun * known in advance. 81*4882a593Smuzhiyun */ 82*4882a593Smuzhiyun struct uvc_descriptor_header **uvc_fs_streaming_cls; 83*4882a593Smuzhiyun struct uvc_descriptor_header **uvc_hs_streaming_cls; 84*4882a593Smuzhiyun struct uvc_descriptor_header **uvc_ss_streaming_cls; 85*4882a593Smuzhiyun 86*4882a593Smuzhiyun /* 87*4882a593Smuzhiyun * Read/write access to configfs attributes is handled by configfs. 88*4882a593Smuzhiyun * 89*4882a593Smuzhiyun * This lock protects the descriptors from concurrent access by 90*4882a593Smuzhiyun * read/write and symlink creation/removal. 91*4882a593Smuzhiyun */ 92*4882a593Smuzhiyun struct mutex lock; 93*4882a593Smuzhiyun int refcnt; 94*4882a593Smuzhiyun int pm_qos_latency; 95*4882a593Smuzhiyun }; 96*4882a593Smuzhiyun 97*4882a593Smuzhiyun #endif /* U_UVC_H */ 98