Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) #ifndef _USB_VIDEO_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #define _USB_VIDEO_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #ifndef __KERNEL__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #error "The uvcvideo.h header is deprecated, use linux/uvcvideo.h instead."
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #endif /* __KERNEL__ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/poll.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/usb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/usb/video.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/uvcvideo.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/videodev2.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/workqueue.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <media/media-device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <media/v4l2-device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <media/v4l2-event.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <media/v4l2-fh.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <media/videobuf2-v4l2.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) /* --------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * UVC constants
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #define UVC_TERM_INPUT			0x0000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #define UVC_TERM_OUTPUT			0x8000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #define UVC_TERM_DIRECTION(term)	((term)->type & 0x8000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #define UVC_ENTITY_TYPE(entity)		((entity)->type & 0x7fff)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #define UVC_ENTITY_IS_UNIT(entity)	(((entity)->type & 0xff00) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #define UVC_ENTITY_IS_TERM(entity)	(((entity)->type & 0xff00) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #define UVC_ENTITY_IS_ITERM(entity) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	(UVC_ENTITY_IS_TERM(entity) && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	((entity)->type & 0x8000) == UVC_TERM_INPUT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #define UVC_ENTITY_IS_OTERM(entity) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	(UVC_ENTITY_IS_TERM(entity) && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	((entity)->type & 0x8000) == UVC_TERM_OUTPUT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) /* ------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  * GUIDs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #define UVC_GUID_UVC_CAMERA \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) #define UVC_GUID_UVC_OUTPUT \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #define UVC_GUID_UVC_MEDIA_TRANSPORT_INPUT \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) #define UVC_GUID_UVC_PROCESSING \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) #define UVC_GUID_UVC_SELECTOR \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) #define UVC_GUID_FORMAT_MJPEG \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	{ 'M',  'J',  'P',  'G', 0x00, 0x00, 0x10, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) #define UVC_GUID_FORMAT_YUY2 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	{ 'Y',  'U',  'Y',  '2', 0x00, 0x00, 0x10, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) #define UVC_GUID_FORMAT_YUY2_ISIGHT \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	{ 'Y',  'U',  'Y',  '2', 0x00, 0x00, 0x10, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	 0x80, 0x00, 0x00, 0x00, 0x00, 0x38, 0x9b, 0x71}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) #define UVC_GUID_FORMAT_NV12 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	{ 'N',  'V',  '1',  '2', 0x00, 0x00, 0x10, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) #define UVC_GUID_FORMAT_YV12 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	{ 'Y',  'V',  '1',  '2', 0x00, 0x00, 0x10, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) #define UVC_GUID_FORMAT_I420 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	{ 'I',  '4',  '2',  '0', 0x00, 0x00, 0x10, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) #define UVC_GUID_FORMAT_UYVY \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	{ 'U',  'Y',  'V',  'Y', 0x00, 0x00, 0x10, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) #define UVC_GUID_FORMAT_Y800 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	{ 'Y',  '8',  '0',  '0', 0x00, 0x00, 0x10, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) #define UVC_GUID_FORMAT_Y8 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	{ 'Y',  '8',  ' ',  ' ', 0x00, 0x00, 0x10, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) #define UVC_GUID_FORMAT_Y10 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	{ 'Y',  '1',  '0',  ' ', 0x00, 0x00, 0x10, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) #define UVC_GUID_FORMAT_Y12 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	{ 'Y',  '1',  '2',  ' ', 0x00, 0x00, 0x10, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) #define UVC_GUID_FORMAT_Y16 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	{ 'Y',  '1',  '6',  ' ', 0x00, 0x00, 0x10, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) #define UVC_GUID_FORMAT_BY8 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	{ 'B',  'Y',  '8',  ' ', 0x00, 0x00, 0x10, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) #define UVC_GUID_FORMAT_BA81 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	{ 'B',  'A',  '8',  '1', 0x00, 0x00, 0x10, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) #define UVC_GUID_FORMAT_GBRG \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	{ 'G',  'B',  'R',  'G', 0x00, 0x00, 0x10, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) #define UVC_GUID_FORMAT_GRBG \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	{ 'G',  'R',  'B',  'G', 0x00, 0x00, 0x10, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) #define UVC_GUID_FORMAT_RGGB \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	{ 'R',  'G',  'G',  'B', 0x00, 0x00, 0x10, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) #define UVC_GUID_FORMAT_BG16 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	{ 'B',  'G',  '1',  '6', 0x00, 0x00, 0x10, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) #define UVC_GUID_FORMAT_GB16 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	{ 'G',  'B',  '1',  '6', 0x00, 0x00, 0x10, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) #define UVC_GUID_FORMAT_RG16 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	{ 'R',  'G',  '1',  '6', 0x00, 0x00, 0x10, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) #define UVC_GUID_FORMAT_GR16 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	{ 'G',  'R',  '1',  '6', 0x00, 0x00, 0x10, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) #define UVC_GUID_FORMAT_RGBP \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	{ 'R',  'G',  'B',  'P', 0x00, 0x00, 0x10, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) #define UVC_GUID_FORMAT_BGR3 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	{ 0x7d, 0xeb, 0x36, 0xe4, 0x4f, 0x52, 0xce, 0x11, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	 0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) #define UVC_GUID_FORMAT_M420 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	{ 'M',  '4',  '2',  '0', 0x00, 0x00, 0x10, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) #define UVC_GUID_FORMAT_H264 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	{ 'H',  '2',  '6',  '4', 0x00, 0x00, 0x10, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) #define UVC_GUID_FORMAT_Y8I \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	{ 'Y',  '8',  'I',  ' ', 0x00, 0x00, 0x10, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) #define UVC_GUID_FORMAT_Y12I \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	{ 'Y',  '1',  '2',  'I', 0x00, 0x00, 0x10, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) #define UVC_GUID_FORMAT_Z16 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	{ 'Z',  '1',  '6',  ' ', 0x00, 0x00, 0x10, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) #define UVC_GUID_FORMAT_RW10 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	{ 'R',  'W',  '1',  '0', 0x00, 0x00, 0x10, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) #define UVC_GUID_FORMAT_INVZ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	{ 'I',  'N',  'V',  'Z', 0x90, 0x2d, 0x58, 0x4a, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	 0x92, 0x0b, 0x77, 0x3f, 0x1f, 0x2c, 0x55, 0x6b}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) #define UVC_GUID_FORMAT_INZI \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	{ 'I',  'N',  'Z',  'I', 0x66, 0x1a, 0x42, 0xa2, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	 0x90, 0x65, 0xd0, 0x18, 0x14, 0xa8, 0xef, 0x8a}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) #define UVC_GUID_FORMAT_INVI \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	{ 'I',  'N',  'V',  'I', 0xdb, 0x57, 0x49, 0x5e, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	 0x8e, 0x3f, 0xf4, 0x79, 0x53, 0x2b, 0x94, 0x6f}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) #define UVC_GUID_FORMAT_CNF4 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	{ 'C',  ' ',  ' ',  ' ', 0x00, 0x00, 0x10, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) #define UVC_GUID_FORMAT_D3DFMT_L8 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	{0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) #define UVC_GUID_FORMAT_KSMEDIA_L8_IR \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	{0x32, 0x00, 0x00, 0x00, 0x02, 0x00, 0x10, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) #define UVC_GUID_FORMAT_HEVC \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	{ 'H',  'E',  'V',  'C', 0x00, 0x00, 0x10, 0x00, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) /* ------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)  * Driver specific constants.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) #define DRIVER_VERSION		"1.1.1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) /* Number of isochronous URBs. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) #define UVC_URBS		5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) /* Maximum number of packets per URB. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) #define UVC_MAX_PACKETS		32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) /* Maximum status buffer size in bytes of interrupt URB. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) #define UVC_MAX_STATUS_SIZE	16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) #define UVC_CTRL_CONTROL_TIMEOUT	5000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) #define UVC_CTRL_STREAMING_TIMEOUT	5000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) /* Maximum allowed number of control mappings per device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) #define UVC_MAX_CONTROL_MAPPINGS	1024
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) #define UVC_MAX_CONTROL_MENU_ENTRIES	32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) /* Devices quirks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) #define UVC_QUIRK_STATUS_INTERVAL	0x00000001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) #define UVC_QUIRK_PROBE_MINMAX		0x00000002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) #define UVC_QUIRK_PROBE_EXTRAFIELDS	0x00000004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) #define UVC_QUIRK_BUILTIN_ISIGHT	0x00000008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) #define UVC_QUIRK_STREAM_NO_FID		0x00000010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) #define UVC_QUIRK_IGNORE_SELECTOR_UNIT	0x00000020
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) #define UVC_QUIRK_FIX_BANDWIDTH		0x00000080
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) #define UVC_QUIRK_PROBE_DEF		0x00000100
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) #define UVC_QUIRK_RESTRICT_FRAME_RATE	0x00000200
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) #define UVC_QUIRK_RESTORE_CTRLS_ON_INIT	0x00000400
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) #define UVC_QUIRK_FORCE_Y8		0x00000800
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) #define UVC_QUIRK_FORCE_BPP		0x00001000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) /* Format flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) #define UVC_FMT_FLAG_COMPRESSED		0x00000001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) #define UVC_FMT_FLAG_STREAM		0x00000002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) /* ------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)  * Structures.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) struct uvc_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) /* TODO: Put the most frequently accessed fields at the beginning of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)  * structures to maximize cache efficiency.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) struct uvc_control_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	struct list_head mappings;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	u8 entity[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	u8 index;	/* Bit index in bmControls */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	u8 selector;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	u16 size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) struct uvc_control_mapping {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	struct list_head ev_subs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	u32 id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	u8 name[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	u8 entity[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	u8 selector;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	u8 size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	u8 offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	enum v4l2_ctrl_type v4l2_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	u32 data_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	const struct uvc_menu_info *menu_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	u32 menu_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	u32 master_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	s32 master_manual;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	u32 slave_ids[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	s32 (*get)(struct uvc_control_mapping *mapping, u8 query,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		   const u8 *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	void (*set)(struct uvc_control_mapping *mapping, s32 value,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 		    u8 *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) struct uvc_control {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	struct uvc_entity *entity;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	struct uvc_control_info info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	u8 index;	/* Used to match the uvc_control entry with a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 			   uvc_control_info. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	u8 dirty:1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	   loaded:1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	   modified:1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	   cached:1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	   initialized:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	u8 *uvc_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	struct uvc_fh *handle;	/* File handle that last changed the control. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) struct uvc_format_desc {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	u8 guid[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	u32 fcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) /* The term 'entity' refers to both UVC units and UVC terminals.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)  * The type field is either the terminal type (wTerminalType in the terminal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)  * descriptor), or the unit type (bDescriptorSubtype in the unit descriptor).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)  * As the bDescriptorSubtype field is one byte long, the type value will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)  * always have a null MSB for units. All terminal types defined by the UVC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)  * specification have a non-null MSB, so it is safe to use the MSB to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)  * differentiate between units and terminals as long as the descriptor parsing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)  * code makes sure terminal types have a non-null MSB.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)  * For terminals, the type's most significant bit stores the terminal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)  * direction (either UVC_TERM_INPUT or UVC_TERM_OUTPUT). The type field should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293)  * always be accessed with the UVC_ENTITY_* macros and never directly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) #define UVC_ENTITY_FLAG_DEFAULT		(1 << 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) struct uvc_entity {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	struct list_head list;		/* Entity as part of a UVC device. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	struct list_head chain;		/* Entity as part of a video device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 					 * chain. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	unsigned int flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	u8 id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	u16 type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	char name[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	/* Media controller-related fields. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	struct video_device *vdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	struct v4l2_subdev subdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	unsigned int num_pads;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	unsigned int num_links;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 	struct media_pad *pads;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 		struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 			u16 wObjectiveFocalLengthMin;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 			u16 wObjectiveFocalLengthMax;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 			u16 wOcularFocalLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 			u8  bControlSize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 			u8  *bmControls;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 		} camera;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 		struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 			u8  bControlSize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 			u8  *bmControls;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 			u8  bTransportModeSize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 			u8  *bmTransportModes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 		} media;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 		struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 		} output;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 		struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 			u16 wMaxMultiplier;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 			u8  bControlSize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 			u8  *bmControls;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 			u8  bmVideoStandards;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 		} processing;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 		struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 		} selector;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 		struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 			u8  guidExtensionCode[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 			u8  bNumControls;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 			u8  bControlSize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 			u8  *bmControls;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 			u8  *bmControlsType;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 		} extension;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	u8 bNrInPins;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	u8 *baSourceID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	unsigned int ncontrols;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	struct uvc_control *controls;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) struct uvc_frame {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	u8  bFrameIndex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 	u8  bmCapabilities;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	u16 wWidth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 	u16 wHeight;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	u32 dwMinBitRate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	u32 dwMaxBitRate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	u32 dwMaxVideoFrameBufferSize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	u8  bFrameIntervalType;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	u32 dwDefaultFrameInterval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	u32 *dwFrameInterval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) struct uvc_format {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	u8 type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 	u8 index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	u8 bpp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 	enum v4l2_colorspace colorspace;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	enum v4l2_xfer_func xfer_func;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 	enum v4l2_ycbcr_encoding ycbcr_enc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 	u32 fcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 	u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 	char name[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	unsigned int nframes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 	struct uvc_frame *frame;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) struct uvc_streaming_header {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	u8 bNumFormats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 	u8 bEndpointAddress;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 	u8 bTerminalLink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 	u8 bControlSize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 	u8 *bmaControls;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	/* The following fields are used by input headers only. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 	u8 bmInfo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	u8 bStillCaptureMethod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 	u8 bTriggerSupport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 	u8 bTriggerUsage;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) enum uvc_buffer_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	UVC_BUF_STATE_IDLE	= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	UVC_BUF_STATE_QUEUED	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 	UVC_BUF_STATE_ACTIVE	= 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 	UVC_BUF_STATE_READY	= 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	UVC_BUF_STATE_DONE	= 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	UVC_BUF_STATE_ERROR	= 5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) struct uvc_buffer {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 	struct vb2_v4l2_buffer buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	struct list_head queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	enum uvc_buffer_state state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 	unsigned int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 	void *mem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	unsigned int length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	unsigned int bytesused;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 	u32 pts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 	/* Asynchronous buffer handling. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	struct kref ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) #define UVC_QUEUE_DISCONNECTED		(1 << 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) #define UVC_QUEUE_DROP_CORRUPTED	(1 << 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) struct uvc_video_queue {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 	struct vb2_queue queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 	struct mutex mutex;			/* Protects queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 	unsigned int flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 	unsigned int buf_used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 	spinlock_t irqlock;			/* Protects irqqueue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 	struct list_head irqqueue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) struct uvc_video_chain {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 	struct uvc_device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 	struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	struct list_head entities;		/* All entities */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 	struct uvc_entity *processing;		/* Processing unit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	struct uvc_entity *selector;		/* Selector unit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 	struct mutex ctrl_mutex;		/* Protects ctrl.info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	struct v4l2_prio_state prio;		/* V4L2 priority state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	u32 caps;				/* V4L2 chain-wide caps */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) struct uvc_stats_frame {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 	unsigned int size;		/* Number of bytes captured */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 	unsigned int first_data;	/* Index of the first non-empty packet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 	unsigned int nb_packets;	/* Number of packets */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 	unsigned int nb_empty;		/* Number of empty packets */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 	unsigned int nb_invalid;	/* Number of packets with an invalid header */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 	unsigned int nb_errors;		/* Number of packets with the error bit set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 	unsigned int nb_pts;		/* Number of packets with a PTS timestamp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 	unsigned int nb_pts_diffs;	/* Number of PTS differences inside a frame */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 	unsigned int last_pts_diff;	/* Index of the last PTS difference */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	bool has_initial_pts;		/* Whether the first non-empty packet has a PTS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	bool has_early_pts;		/* Whether a PTS is present before the first non-empty packet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 	u32 pts;			/* PTS of the last packet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 	unsigned int nb_scr;		/* Number of packets with a SCR timestamp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 	unsigned int nb_scr_diffs;	/* Number of SCR.STC differences inside a frame */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 	u16 scr_sof;			/* SCR.SOF of the last packet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 	u32 scr_stc;			/* SCR.STC of the last packet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) struct uvc_stats_stream {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 	ktime_t start_ts;		/* Stream start timestamp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 	ktime_t stop_ts;		/* Stream stop timestamp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 	unsigned int nb_frames;		/* Number of frames */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 	unsigned int nb_packets;	/* Number of packets */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 	unsigned int nb_empty;		/* Number of empty packets */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 	unsigned int nb_invalid;	/* Number of packets with an invalid header */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 	unsigned int nb_errors;		/* Number of packets with the error bit set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 	unsigned int nb_pts_constant;	/* Number of frames with constant PTS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 	unsigned int nb_pts_early;	/* Number of frames with early PTS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 	unsigned int nb_pts_initial;	/* Number of frames with initial PTS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 	unsigned int nb_scr_count_ok;	/* Number of frames with at least one SCR per non empty packet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 	unsigned int nb_scr_diffs_ok;	/* Number of frames with varying SCR.STC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 	unsigned int scr_sof_count;	/* STC.SOF counter accumulated since stream start */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 	unsigned int scr_sof;		/* STC.SOF of the last packet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 	unsigned int min_sof;		/* Minimum STC.SOF value */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 	unsigned int max_sof;		/* Maximum STC.SOF value */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) #define UVC_METADATA_BUF_SIZE 1024
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504)  * struct uvc_copy_op: Context structure to schedule asynchronous memcpy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506)  * @buf: active buf object for this operation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507)  * @dst: copy destination address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508)  * @src: copy source address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509)  * @len: copy length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) struct uvc_copy_op {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 	struct uvc_buffer *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 	void *dst;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 	const __u8 *src;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 	size_t len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519)  * struct uvc_urb - URB context management structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521)  * @urb: the URB described by this context structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522)  * @stream: UVC streaming context
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523)  * @buffer: memory storage for the URB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524)  * @dma: DMA coherent addressing for the urb_buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525)  * @async_operations: counter to indicate the number of copy operations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526)  * @copy_operations: work descriptors for asynchronous copy operations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527)  * @work: work queue entry for asynchronous decode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) struct uvc_urb {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 	struct urb *urb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 	struct uvc_streaming *stream;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 	char *buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 	dma_addr_t dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 	unsigned int async_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 	struct uvc_copy_op copy_operations[UVC_MAX_PACKETS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) 	struct work_struct work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) struct uvc_streaming {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 	struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) 	struct uvc_device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 	struct video_device vdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 	struct uvc_video_chain *chain;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 	atomic_t active;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 	struct usb_interface *intf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 	int intfnum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 	u16 maxpsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 	struct uvc_streaming_header header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 	enum v4l2_buf_type type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 	unsigned int nformats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 	struct uvc_format *format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 	struct uvc_streaming_control ctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 	struct uvc_format *def_format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 	struct uvc_format *cur_format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 	struct uvc_frame *cur_frame;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) 	/* Protect access to ctrl, cur_format, cur_frame and hardware video
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 	 * probe control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 	struct mutex mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 	/* Buffers queue. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 	unsigned int frozen : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 	struct uvc_video_queue queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 	struct workqueue_struct *async_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 	void (*decode)(struct uvc_urb *uvc_urb, struct uvc_buffer *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) 		       struct uvc_buffer *meta_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) 	struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) 		struct video_device vdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) 		struct uvc_video_queue queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 		u32 format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 	} meta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) 	/* Context data used by the bulk completion handler. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) 	struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 		u8 header[256];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) 		unsigned int header_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) 		int skip_payload;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) 		u32 payload_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) 		u32 max_payload_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) 	} bulk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 	struct uvc_urb uvc_urb[UVC_URBS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) 	unsigned int urb_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) 	u32 sequence;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) 	u8 last_fid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) 	/* debugfs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) 	struct dentry *debugfs_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 	struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) 		struct uvc_stats_frame frame;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 		struct uvc_stats_stream stream;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) 	} stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) 	/* Timestamps support. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) 	struct uvc_clock {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) 		struct uvc_clock_sample {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) 			u32 dev_stc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) 			u16 dev_sof;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) 			u16 host_sof;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) 			ktime_t host_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) 		} *samples;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) 		unsigned int head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 		unsigned int count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) 		unsigned int size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) 		u16 last_sof;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) 		u16 sof_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) 		u8 last_scr[6];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) 		spinlock_t lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) 	} clock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) #define for_each_uvc_urb(uvc_urb, uvc_streaming) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) 	for ((uvc_urb) = &(uvc_streaming)->uvc_urb[0]; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) 	     (uvc_urb) < &(uvc_streaming)->uvc_urb[UVC_URBS]; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) 	     ++(uvc_urb))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) static inline u32 uvc_urb_index(const struct uvc_urb *uvc_urb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) 	return uvc_urb - &uvc_urb->stream->uvc_urb[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) struct uvc_device_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) 	u32	quirks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) 	u32	meta_format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) struct uvc_device {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) 	struct usb_device *udev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) 	struct usb_interface *intf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) 	unsigned long warnings;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) 	u32 quirks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) 	int intfnum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) 	char name[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) 	const struct uvc_device_info *info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) 	struct mutex lock;		/* Protects users */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) 	unsigned int users;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) 	atomic_t nmappings;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) 	/* Video control interface */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) #ifdef CONFIG_MEDIA_CONTROLLER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) 	struct media_device mdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) 	struct v4l2_device vdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) 	u16 uvc_version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) 	u32 clock_frequency;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) 	struct list_head entities;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) 	struct list_head chains;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) 	/* Video Streaming interfaces */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) 	struct list_head streams;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) 	struct kref ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) 	/* Status Interrupt Endpoint */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) 	struct usb_host_endpoint *int_ep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) 	struct urb *int_urb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) 	u8 *status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) 	struct input_dev *input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) 	char input_phys[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) 	struct uvc_ctrl_work {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) 		struct work_struct work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) 		struct urb *urb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) 		struct uvc_video_chain *chain;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) 		struct uvc_control *ctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) 		const void *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) 	} async_ctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) enum uvc_handle_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) 	UVC_HANDLE_PASSIVE	= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) 	UVC_HANDLE_ACTIVE	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) struct uvc_fh {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) 	struct v4l2_fh vfh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) 	struct uvc_video_chain *chain;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) 	struct uvc_streaming *stream;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) 	enum uvc_handle_state state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) struct uvc_driver {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) 	struct usb_driver driver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) /* ------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702)  * Debugging, printing and logging
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) #define UVC_TRACE_PROBE		(1 << 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) #define UVC_TRACE_DESCR		(1 << 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) #define UVC_TRACE_CONTROL	(1 << 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) #define UVC_TRACE_FORMAT	(1 << 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) #define UVC_TRACE_CAPTURE	(1 << 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) #define UVC_TRACE_CALLS		(1 << 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) #define UVC_TRACE_FRAME		(1 << 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) #define UVC_TRACE_SUSPEND	(1 << 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) #define UVC_TRACE_STATUS	(1 << 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) #define UVC_TRACE_VIDEO		(1 << 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) #define UVC_TRACE_STATS		(1 << 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) #define UVC_TRACE_CLOCK		(1 << 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) #define UVC_WARN_MINMAX		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) #define UVC_WARN_PROBE_DEF	1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) #define UVC_WARN_XU_GET_RES	2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) extern unsigned int uvc_clock_param;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) extern unsigned int uvc_no_drop_param;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) extern unsigned int uvc_trace_param;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) extern unsigned int uvc_timeout_param;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) extern unsigned int uvc_hw_timestamps_param;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) #define uvc_trace(flag, msg...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) 	do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) 		if (uvc_trace_param & flag) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) 			printk(KERN_DEBUG "uvcvideo: " msg); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) 	} while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) #define uvc_warn_once(dev, warn, msg...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) 	do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) 		if (!test_and_set_bit(warn, &dev->warnings)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) 			printk(KERN_INFO "uvcvideo: " msg); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) 	} while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) #define uvc_printk(level, msg...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) 	printk(level "uvcvideo: " msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) /* --------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744)  * Internal functions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) /* Core driver */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) extern struct uvc_driver uvc_driver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) struct uvc_entity *uvc_entity_by_id(struct uvc_device *dev, int id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) /* Video buffers queue management. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) 		   int drop_corrupted);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) void uvc_queue_release(struct uvc_video_queue *queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) int uvc_request_buffers(struct uvc_video_queue *queue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) 			struct v4l2_requestbuffers *rb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) int uvc_query_buffer(struct uvc_video_queue *queue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) 		     struct v4l2_buffer *v4l2_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) int uvc_create_buffers(struct uvc_video_queue *queue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) 		       struct v4l2_create_buffers *v4l2_cb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) int uvc_queue_buffer(struct uvc_video_queue *queue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) 		     struct media_device *mdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) 		     struct v4l2_buffer *v4l2_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) int uvc_export_buffer(struct uvc_video_queue *queue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) 		      struct v4l2_exportbuffer *exp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) int uvc_dequeue_buffer(struct uvc_video_queue *queue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) 		       struct v4l2_buffer *v4l2_buf, int nonblocking);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) int uvc_queue_streamon(struct uvc_video_queue *queue, enum v4l2_buf_type type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) int uvc_queue_streamoff(struct uvc_video_queue *queue, enum v4l2_buf_type type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) void uvc_queue_cancel(struct uvc_video_queue *queue, int disconnect);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) 					 struct uvc_buffer *buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) struct uvc_buffer *uvc_queue_get_current_buffer(struct uvc_video_queue *queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) void uvc_queue_buffer_release(struct uvc_buffer *buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) int uvc_queue_mmap(struct uvc_video_queue *queue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) 		   struct vm_area_struct *vma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) __poll_t uvc_queue_poll(struct uvc_video_queue *queue, struct file *file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) 			poll_table *wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) #ifndef CONFIG_MMU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) unsigned long uvc_queue_get_unmapped_area(struct uvc_video_queue *queue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) 					  unsigned long pgoff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) int uvc_queue_allocated(struct uvc_video_queue *queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) static inline int uvc_queue_streaming(struct uvc_video_queue *queue)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) 	return vb2_is_streaming(&queue->queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) /* V4L2 interface */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) extern const struct v4l2_ioctl_ops uvc_ioctl_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) extern const struct v4l2_file_operations uvc_fops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) /* Media controller */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) int uvc_mc_register_entities(struct uvc_video_chain *chain);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) void uvc_mc_cleanup_entity(struct uvc_entity *entity);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) /* Video */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) int uvc_video_init(struct uvc_streaming *stream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) int uvc_video_suspend(struct uvc_streaming *stream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) int uvc_video_resume(struct uvc_streaming *stream, int reset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) int uvc_video_start_streaming(struct uvc_streaming *stream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) void uvc_video_stop_streaming(struct uvc_streaming *stream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) int uvc_probe_video(struct uvc_streaming *stream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) 		    struct uvc_streaming_control *probe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) int uvc_query_ctrl(struct uvc_device *dev, u8 query, u8 unit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) 		   u8 intfnum, u8 cs, void *data, u16 size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) void uvc_video_clock_update(struct uvc_streaming *stream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) 			    struct vb2_v4l2_buffer *vbuf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) 			    struct uvc_buffer *buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) int uvc_meta_register(struct uvc_streaming *stream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) int uvc_register_video_device(struct uvc_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) 			      struct uvc_streaming *stream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) 			      struct video_device *vdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) 			      struct uvc_video_queue *queue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) 			      enum v4l2_buf_type type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) 			      const struct v4l2_file_operations *fops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) 			      const struct v4l2_ioctl_ops *ioctl_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) /* Status */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) int uvc_status_init(struct uvc_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) void uvc_status_unregister(struct uvc_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) void uvc_status_cleanup(struct uvc_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) int uvc_status_start(struct uvc_device *dev, gfp_t flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) void uvc_status_stop(struct uvc_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) /* Controls */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) extern const struct v4l2_subscribed_event_ops uvc_ctrl_sub_ev_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) int uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) 			struct v4l2_queryctrl *v4l2_ctrl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) int uvc_query_v4l2_menu(struct uvc_video_chain *chain,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) 			struct v4l2_querymenu *query_menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) int uvc_ctrl_add_mapping(struct uvc_video_chain *chain,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) 			 const struct uvc_control_mapping *mapping);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) int uvc_ctrl_init_device(struct uvc_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) void uvc_ctrl_cleanup_device(struct uvc_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) int uvc_ctrl_restore_values(struct uvc_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) bool uvc_ctrl_status_event(struct urb *urb, struct uvc_video_chain *chain,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) 			   struct uvc_control *ctrl, const u8 *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) int uvc_ctrl_begin(struct uvc_video_chain *chain);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) int __uvc_ctrl_commit(struct uvc_fh *handle, int rollback,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) 		      const struct v4l2_ext_control *xctrls,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) 		      unsigned int xctrls_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) static inline int uvc_ctrl_commit(struct uvc_fh *handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) 				  const struct v4l2_ext_control *xctrls,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) 				  unsigned int xctrls_count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) 	return __uvc_ctrl_commit(handle, 0, xctrls, xctrls_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) static inline int uvc_ctrl_rollback(struct uvc_fh *handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) 	return __uvc_ctrl_commit(handle, 1, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) int uvc_ctrl_get(struct uvc_video_chain *chain, struct v4l2_ext_control *xctrl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) int uvc_ctrl_set(struct uvc_fh *handle, struct v4l2_ext_control *xctrl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) int uvc_xu_ctrl_query(struct uvc_video_chain *chain,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) 		      struct uvc_xu_control_query *xqry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) /* Utility functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) void uvc_simplify_fraction(u32 *numerator, u32 *denominator,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) 			   unsigned int n_terms, unsigned int threshold);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) u32 uvc_fraction_to_interval(u32 numerator, u32 denominator);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) struct usb_host_endpoint *uvc_find_endpoint(struct usb_host_interface *alts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) 					    u8 epaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) /* Quirks support */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) void uvc_video_decode_isight(struct uvc_urb *uvc_urb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) 			     struct uvc_buffer *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) 			     struct uvc_buffer *meta_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) /* debugfs and statistics */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) void uvc_debugfs_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) void uvc_debugfs_cleanup(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) void uvc_debugfs_init_stream(struct uvc_streaming *stream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) void uvc_debugfs_cleanup_stream(struct uvc_streaming *stream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) size_t uvc_video_stats_dump(struct uvc_streaming *stream, char *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) 			    size_t size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) #endif