Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: dvb kAPI docs: document dvb_vb2.h

Document the data structures and functions inside this kAPI header.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>

+184 -6
+5
Documentation/media/kapi/dtv-common.rst
··· 53 53 Two or more writers must be locked against each other. 54 54 55 55 .. kernel-doc:: include/media/dvb_ringbuffer.h 56 + 57 + Digital TV VB2 handler 58 + ~~~~~~~~~~~~~~~~~~~~~~ 59 + 60 + .. kernel-doc:: include/media/dvb_vb2.h
+2
include/media/dmxdev.h
··· 112 112 * @state: state of the dmxdev filter, as defined by &enum dmxdev_state. 113 113 * @dev: pointer to &struct dmxdev. 114 114 * @buffer: an embedded &struct dvb_ringbuffer buffer. 115 + * @vb2_ctx: control struct for VB2 handler 115 116 * @mutex: protects the access to &struct dmxdev_filter. 116 117 * @timer: &struct timer_list embedded timer, used to check for 117 118 * feed timeouts. ··· 166 165 * @exit: flag to indicate that the demux is being released. 167 166 * @dvr_orig_fe: pointer to &struct dmx_frontend. 168 167 * @dvr_buffer: embedded &struct dvb_ringbuffer for DVB output. 168 + * @dvr_vb2_ctx: control struct for VB2 handler 169 169 * @mutex: protects the usage of this structure. 170 170 * @lock: protects access to &dmxdev->filter->data. 171 171 */
+177 -6
include/media/dvb_vb2.h
··· 22 22 #include <media/videobuf2-dma-contig.h> 23 23 #include <media/videobuf2-vmalloc.h> 24 24 25 + /** 26 + * enum dvb_buf_type - types of Digital TV memory-mapped buffers 27 + * 28 + * @DVB_BUF_TYPE_CAPTURE: buffer is filled by the Kernel, 29 + * with a received Digital TV stream 30 + */ 25 31 enum dvb_buf_type { 26 32 DVB_BUF_TYPE_CAPTURE = 1, 27 33 }; 28 34 29 - #define DVB_VB2_STATE_NONE (0x0) 30 - #define DVB_VB2_STATE_INIT (0x1) 31 - #define DVB_VB2_STATE_REQBUFS (0x2) 32 - #define DVB_VB2_STATE_STREAMON (0x4) 35 + /** 36 + * enum dvb_vb2_states - states to control VB2 state machine 37 + * @DVB_VB2_STATE_NONE: 38 + * VB2 engine not initialized yet, init failed or VB2 was released. 39 + * @DVB_VB2_STATE_INIT: 40 + * VB2 engine initialized. 41 + * @DVB_VB2_STATE_REQBUFS: 42 + * Buffers were requested 43 + * @DVB_VB2_STATE_STREAMON: 44 + * VB2 is streaming. Callers should not check it directly. Instead, 45 + * they should use dvb_vb2_is_streaming(). 46 + * 47 + * Note: 48 + * 49 + * Callers should not touch at the state machine directly. This 50 + * is handled inside dvb_vb2.c. 51 + */ 52 + enum dvb_vb2_states { 53 + DVB_VB2_STATE_NONE = 0x0, 54 + DVB_VB2_STATE_INIT = 0x1, 55 + DVB_VB2_STATE_REQBUFS = 0x2, 56 + DVB_VB2_STATE_STREAMON = 0x4, 57 + }; 33 58 34 59 #define DVB_VB2_NAME_MAX (20) 35 60 61 + /** 62 + * struct dvb_buffer - video buffer information for v4l2. 63 + * 64 + * @vb: embedded struct &vb2_buffer. 65 + * @list: list of &struct dvb_buffer. 66 + */ 36 67 struct dvb_buffer { 37 68 struct vb2_buffer vb; 38 69 struct list_head list; 39 70 }; 40 71 72 + /** 73 + * struct dvb_vb2_ctx - control struct for VB2 handler 74 + * @vb_q: pointer to &struct vb2_queue with videobuf2 queue. 75 + * @mutex: mutex to serialize vb2 operations. Used by 76 + * vb2 core %wait_prepare and %wait_finish operations. 77 + * @slock: spin lock used to protect buffer filling at dvb_vb2.c. 78 + * @dvb_q: List of buffers that are not filled yet. 79 + * @buf: Pointer to the buffer that are currently being filled. 80 + * @offset: index to the next position at the @buf to be filled. 81 + * @remain: How many bytes are left to be filled at @buf. 82 + * @state: bitmask of buffer states as defined by &enum dvb_vb2_states. 83 + * @buf_siz: size of each VB2 buffer. 84 + * @buf_cnt: number of VB2 buffers. 85 + * @nonblocking: 86 + * If different than zero, device is operating on non-blocking 87 + * mode. 88 + * @name: name of the device type. Currently, it can either be 89 + * "dvr" or "demux_filter". 90 + */ 41 91 struct dvb_vb2_ctx { 42 92 struct vb2_queue vb_q; 43 93 struct mutex mutex; ··· 103 53 char name[DVB_VB2_NAME_MAX + 1]; 104 54 }; 105 55 106 - int dvb_vb2_stream_on(struct dvb_vb2_ctx *ctx); 107 - int dvb_vb2_stream_off(struct dvb_vb2_ctx *ctx); 108 56 #ifndef DVB_MMAP 109 57 static inline int dvb_vb2_init(struct dvb_vb2_ctx *ctx, 110 58 const char *name, int non_blocking) ··· 123 75 return 0; 124 76 } 125 77 #else 78 + /** 79 + * dvb_vb2_init - initializes VB2 handler 80 + * 81 + * @ctx: control struct for VB2 handler 82 + * @name: name for the VB2 handler 83 + * @non_blocking: 84 + * if not zero, it means that the device is at non-blocking mode 85 + */ 126 86 int dvb_vb2_init(struct dvb_vb2_ctx *ctx, const char *name, int non_blocking); 87 + 88 + /** 89 + * dvb_vb2_release - Releases the VB2 handler allocated resources and 90 + * put @ctx at DVB_VB2_STATE_NONE state. 91 + * @ctx: control struct for VB2 handler 92 + */ 127 93 int dvb_vb2_release(struct dvb_vb2_ctx *ctx); 94 + 95 + /** 96 + * dvb_vb2_is_streaming - checks if the VB2 handler is streaming 97 + * @ctx: control struct for VB2 handler 98 + * 99 + * Return: 0 if not streaming, 1 otherwise. 100 + */ 128 101 int dvb_vb2_is_streaming(struct dvb_vb2_ctx *ctx); 102 + 103 + /** 104 + * dvb_vb2_fill_buffer - fills a VB2 buffer 105 + * @ctx: control struct for VB2 handler 106 + * @src: place where the data is stored 107 + * @len: number of bytes to be copied from @src 108 + */ 129 109 int dvb_vb2_fill_buffer(struct dvb_vb2_ctx *ctx, 130 110 const unsigned char *src, int len); 111 + 112 + /** 113 + * dvb_vb2_poll - Wrapper to vb2_core_streamon() for Digital TV 114 + * buffer handling. 115 + * 116 + * @ctx: control struct for VB2 handler 117 + * @file: &struct file argument passed to the poll 118 + * file operation handler. 119 + * @wait: &poll_table wait argument passed to the poll 120 + * file operation handler. 121 + * 122 + * Implements poll syscall() logic. 123 + */ 131 124 unsigned int dvb_vb2_poll(struct dvb_vb2_ctx *ctx, struct file *file, 132 125 poll_table *wait); 133 126 #endif 134 127 128 + /** 129 + * dvb_vb2_stream_on() - Wrapper to vb2_core_streamon() for Digital TV 130 + * buffer handling. 131 + * 132 + * @ctx: control struct for VB2 handler 133 + * 134 + * Starts dvb streaming 135 + */ 136 + int dvb_vb2_stream_on(struct dvb_vb2_ctx *ctx); 137 + /** 138 + * dvb_vb2_stream_off() - Wrapper to vb2_core_streamoff() for Digital TV 139 + * buffer handling. 140 + * 141 + * @ctx: control struct for VB2 handler 142 + * 143 + * Stops dvb streaming 144 + */ 145 + int dvb_vb2_stream_off(struct dvb_vb2_ctx *ctx); 135 146 147 + /** 148 + * dvb_vb2_reqbufs() - Wrapper to vb2_core_reqbufs() for Digital TV 149 + * buffer handling. 150 + * 151 + * @ctx: control struct for VB2 handler 152 + * @req: &struct dmx_requestbuffers passed from userspace in 153 + * order to handle &DMX_REQBUFS. 154 + * 155 + * Initiate streaming by requesting a number of buffers. Also used to 156 + * free previously requested buffers, is ``req->count`` is zero. 157 + */ 136 158 int dvb_vb2_reqbufs(struct dvb_vb2_ctx *ctx, struct dmx_requestbuffers *req); 159 + 160 + /** 161 + * dvb_vb2_querybuf() - Wrapper to vb2_core_querybuf() for Digital TV 162 + * buffer handling. 163 + * 164 + * @ctx: control struct for VB2 handler 165 + * @b: &struct dmx_buffer passed from userspace in 166 + * order to handle &DMX_QUERYBUF. 167 + * 168 + * 169 + */ 137 170 int dvb_vb2_querybuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b); 171 + 172 + /** 173 + * dvb_vb2_expbuf() - Wrapper to vb2_core_expbuf() for Digital TV 174 + * buffer handling. 175 + * 176 + * @ctx: control struct for VB2 handler 177 + * @exp: &struct dmx_exportbuffer passed from userspace in 178 + * order to handle &DMX_EXPBUF. 179 + * 180 + * Export a buffer as a file descriptor. 181 + */ 138 182 int dvb_vb2_expbuf(struct dvb_vb2_ctx *ctx, struct dmx_exportbuffer *exp); 183 + 184 + /** 185 + * dvb_vb2_qbuf() - Wrapper to vb2_core_qbuf() for Digital TV buffer handling. 186 + * 187 + * @ctx: control struct for VB2 handler 188 + * @b: &struct dmx_buffer passed from userspace in 189 + * order to handle &DMX_QBUF. 190 + * 191 + * Queue a Digital TV buffer as requested by userspace 192 + */ 139 193 int dvb_vb2_qbuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b); 194 + 195 + /** 196 + * dvb_vb2_dqbuf() - Wrapper to vb2_core_dqbuf() for Digital TV 197 + * buffer handling. 198 + * 199 + * @ctx: control struct for VB2 handler 200 + * @b: &struct dmx_buffer passed from userspace in 201 + * order to handle &DMX_DQBUF. 202 + * 203 + * Dequeue a Digital TV buffer to the userspace 204 + */ 140 205 int dvb_vb2_dqbuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b); 206 + 207 + /** 208 + * dvb_vb2_mmap() - Wrapper to vb2_mmap() for Digital TV buffer handling. 209 + * 210 + * @ctx: control struct for VB2 handler 211 + * @vma: pointer to &struct vm_area_struct with the vma passed 212 + * to the mmap file operation handler in the driver. 213 + * 214 + * map Digital TV video buffers into application address space. 215 + */ 141 216 int dvb_vb2_mmap(struct dvb_vb2_ctx *ctx, struct vm_area_struct *vma); 142 217 143 218 #endif /* _DVB_VB2_H */