2017-11-03 11:28:30 +01:00
// SPDX-License-Identifier: GPL-2.0+
2010-05-02 20:57:41 +02:00
/*
* uvc_gadget . h - - USB Video Class Gadget driver
*
* Copyright ( C ) 2009 - 2010
* Laurent Pinchart ( laurent . pinchart @ ideasonboard . com )
*/
# ifndef _UVC_GADGET_H_
# define _UVC_GADGET_H_
2018-05-21 11:28:52 +03:00
# include <linux/list.h>
# include <linux/mutex.h>
# include <linux/spinlock.h>
2014-09-09 02:02:09 +03:00
# include <linux/usb/composite.h>
2010-05-02 20:57:41 +02:00
# include <linux/videodev2.h>
2018-05-21 11:28:52 +03:00
2013-06-12 06:02:38 -03:00
# include <media/v4l2-device.h>
2018-05-21 11:28:52 +03:00
# include <media/v4l2-dev.h>
# include <media/v4l2-fh.h>
2010-05-02 20:57:41 +02:00
# include "uvc_queue.h"
2018-05-21 11:28:52 +03:00
struct usb_ep ;
struct usb_request ;
struct uvc_descriptor_header ;
2018-05-21 11:28:51 +03:00
/* ------------------------------------------------------------------------
* Debugging , printing and logging
*/
2010-05-02 20:57:41 +02:00
# define UVC_TRACE_PROBE (1 << 0)
# define UVC_TRACE_DESCR (1 << 1)
# define UVC_TRACE_CONTROL (1 << 2)
# define UVC_TRACE_FORMAT (1 << 3)
# define UVC_TRACE_CAPTURE (1 << 4)
# define UVC_TRACE_CALLS (1 << 5)
# define UVC_TRACE_IOCTL (1 << 6)
# define UVC_TRACE_FRAME (1 << 7)
# define UVC_TRACE_SUSPEND (1 << 8)
# define UVC_TRACE_STATUS (1 << 9)
# define UVC_WARN_MINMAX 0
# define UVC_WARN_PROBE_DEF 1
2010-07-10 16:13:05 -03:00
extern unsigned int uvc_gadget_trace_param ;
2010-05-02 20:57:41 +02:00
# define uvc_trace(flag, msg...) \
do { \
2010-07-10 16:13:05 -03:00
if ( uvc_gadget_trace_param & flag ) \
2010-05-02 20:57:41 +02:00
printk ( KERN_DEBUG " uvcvideo: " msg ) ; \
} while ( 0 )
# define uvc_warn_once(dev, warn, msg...) \
do { \
if ( ! test_and_set_bit ( warn , & dev - > warnings ) ) \
printk ( KERN_INFO " uvcvideo: " msg ) ; \
} while ( 0 )
# define uvc_printk(level, msg...) \
printk ( level " uvcvideo: " msg )
/* ------------------------------------------------------------------------
* Driver specific constants
*/
# define UVC_NUM_REQUESTS 4
# define UVC_MAX_REQUEST_SIZE 64
# define UVC_MAX_EVENTS 4
/* ------------------------------------------------------------------------
* Structures
*/
2016-11-11 19:07:01 -05:00
struct uvc_video {
2010-05-02 20:57:41 +02:00
struct usb_ep * ep ;
/* Frame parameters */
u8 bpp ;
u32 fcc ;
unsigned int width ;
unsigned int height ;
unsigned int imagesize ;
2015-02-17 05:44:06 -03:00
struct mutex mutex ; /* protects frame parameters */
2010-05-02 20:57:41 +02:00
/* Requests */
unsigned int req_size ;
struct usb_request * req [ UVC_NUM_REQUESTS ] ;
__u8 * req_buffer [ UVC_NUM_REQUESTS ] ;
struct list_head req_free ;
spinlock_t req_lock ;
void ( * encode ) ( struct usb_request * req , struct uvc_video * video ,
struct uvc_buffer * buf ) ;
/* Context data used by the completion handler */
__u32 payload_size ;
__u32 max_payload_size ;
struct uvc_video_queue queue ;
unsigned int fid ;
} ;
2016-11-11 19:07:01 -05:00
enum uvc_state {
2010-05-02 20:57:41 +02:00
UVC_STATE_DISCONNECTED ,
UVC_STATE_CONNECTED ,
UVC_STATE_STREAMING ,
} ;
2016-11-11 19:07:01 -05:00
struct uvc_device {
2015-03-09 13:34:08 -03:00
struct video_device vdev ;
2013-06-12 06:02:38 -03:00
struct v4l2_device v4l2_dev ;
2010-05-02 20:57:41 +02:00
enum uvc_state state ;
struct usb_function func ;
struct uvc_video video ;
/* Descriptors */
struct {
2012-06-01 15:08:56 +05:30
const struct uvc_descriptor_header * const * fs_control ;
const struct uvc_descriptor_header * const * ss_control ;
2010-05-02 20:57:41 +02:00
const struct uvc_descriptor_header * const * fs_streaming ;
const struct uvc_descriptor_header * const * hs_streaming ;
2012-06-01 15:08:56 +05:30
const struct uvc_descriptor_header * const * ss_streaming ;
2010-05-02 20:57:41 +02:00
} desc ;
unsigned int control_intf ;
struct usb_ep * control_ep ;
struct usb_request * control_req ;
void * control_buf ;
unsigned int streaming_intf ;
/* Events */
unsigned int event_length ;
unsigned int event_setup_out : 1 ;
} ;
static inline struct uvc_device * to_uvc ( struct usb_function * f )
{
return container_of ( f , struct uvc_device , func ) ;
}
2016-11-11 19:07:01 -05:00
struct uvc_file_handle {
2010-05-02 20:57:41 +02:00
struct v4l2_fh vfh ;
struct uvc_video * device ;
} ;
# define to_uvc_file_handle(handle) \
container_of ( handle , struct uvc_file_handle , vfh )
/* ------------------------------------------------------------------------
* Functions
*/
2013-03-01 20:46:30 +01:00
extern void uvc_function_setup_continue ( struct uvc_device * uvc ) ;
2010-05-02 20:57:41 +02:00
extern void uvc_endpoint_stream ( struct uvc_device * dev ) ;
extern void uvc_function_connect ( struct uvc_device * uvc ) ;
extern void uvc_function_disconnect ( struct uvc_device * uvc ) ;
# endif /* _UVC_GADGET_H_ */