root/drivers/usb/gadget/function/uvc_queue.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. uvc_queue_streaming

   1 /* SPDX-License-Identifier: GPL-2.0 */
   2 #ifndef _UVC_QUEUE_H_
   3 #define _UVC_QUEUE_H_
   4 
   5 #include <linux/list.h>
   6 #include <linux/poll.h>
   7 #include <linux/spinlock.h>
   8 
   9 #include <media/videobuf2-v4l2.h>
  10 
  11 struct file;
  12 struct mutex;
  13 
  14 /* Maximum frame size in bytes, for sanity checking. */
  15 #define UVC_MAX_FRAME_SIZE      (16*1024*1024)
  16 /* Maximum number of video buffers. */
  17 #define UVC_MAX_VIDEO_BUFFERS   32
  18 
  19 /* ------------------------------------------------------------------------
  20  * Structures.
  21  */
  22 
  23 enum uvc_buffer_state {
  24         UVC_BUF_STATE_IDLE      = 0,
  25         UVC_BUF_STATE_QUEUED    = 1,
  26         UVC_BUF_STATE_ACTIVE    = 2,
  27         UVC_BUF_STATE_DONE      = 3,
  28         UVC_BUF_STATE_ERROR     = 4,
  29 };
  30 
  31 struct uvc_buffer {
  32         struct vb2_v4l2_buffer buf;
  33         struct list_head queue;
  34 
  35         enum uvc_buffer_state state;
  36         void *mem;
  37         unsigned int length;
  38         unsigned int bytesused;
  39 };
  40 
  41 #define UVC_QUEUE_DISCONNECTED          (1 << 0)
  42 #define UVC_QUEUE_DROP_INCOMPLETE       (1 << 1)
  43 #define UVC_QUEUE_PAUSED                (1 << 2)
  44 
  45 struct uvc_video_queue {
  46         struct vb2_queue queue;
  47 
  48         unsigned int flags;
  49         __u32 sequence;
  50 
  51         unsigned int buf_used;
  52 
  53         spinlock_t irqlock;     /* Protects flags and irqqueue */
  54         struct list_head irqqueue;
  55 };
  56 
  57 static inline int uvc_queue_streaming(struct uvc_video_queue *queue)
  58 {
  59         return vb2_is_streaming(&queue->queue);
  60 }
  61 
  62 int uvcg_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type,
  63                     struct mutex *lock);
  64 
  65 void uvcg_free_buffers(struct uvc_video_queue *queue);
  66 
  67 int uvcg_alloc_buffers(struct uvc_video_queue *queue,
  68                        struct v4l2_requestbuffers *rb);
  69 
  70 int uvcg_query_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *buf);
  71 
  72 int uvcg_queue_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *buf);
  73 
  74 int uvcg_dequeue_buffer(struct uvc_video_queue *queue,
  75                         struct v4l2_buffer *buf, int nonblocking);
  76 
  77 __poll_t uvcg_queue_poll(struct uvc_video_queue *queue,
  78                              struct file *file, poll_table *wait);
  79 
  80 int uvcg_queue_mmap(struct uvc_video_queue *queue, struct vm_area_struct *vma);
  81 
  82 #ifndef CONFIG_MMU
  83 unsigned long uvcg_queue_get_unmapped_area(struct uvc_video_queue *queue,
  84                                            unsigned long pgoff);
  85 #endif /* CONFIG_MMU */
  86 
  87 void uvcg_queue_cancel(struct uvc_video_queue *queue, int disconnect);
  88 
  89 int uvcg_queue_enable(struct uvc_video_queue *queue, int enable);
  90 
  91 struct uvc_buffer *uvcg_queue_next_buffer(struct uvc_video_queue *queue,
  92                                           struct uvc_buffer *buf);
  93 
  94 struct uvc_buffer *uvcg_queue_head(struct uvc_video_queue *queue);
  95 
  96 #endif /* _UVC_QUEUE_H_ */
  97 

/* [<][>][^][v][top][bottom][index][help] */