···5353 Two or more writers must be locked against each other.54545555.. kernel-doc:: include/media/dvb_ringbuffer.h5656+5757+Digital TV VB2 handler5858+~~~~~~~~~~~~~~~~~~~~~~5959+6060+.. kernel-doc:: include/media/dvb_vb2.h
+2
include/media/dmxdev.h
···112112 * @state: state of the dmxdev filter, as defined by &enum dmxdev_state.113113 * @dev: pointer to &struct dmxdev.114114 * @buffer: an embedded &struct dvb_ringbuffer buffer.115115+ * @vb2_ctx: control struct for VB2 handler115116 * @mutex: protects the access to &struct dmxdev_filter.116117 * @timer: &struct timer_list embedded timer, used to check for117118 * feed timeouts.···166165 * @exit: flag to indicate that the demux is being released.167166 * @dvr_orig_fe: pointer to &struct dmx_frontend.168167 * @dvr_buffer: embedded &struct dvb_ringbuffer for DVB output.168168+ * @dvr_vb2_ctx: control struct for VB2 handler169169 * @mutex: protects the usage of this structure.170170 * @lock: protects access to &dmxdev->filter->data.171171 */
+177-6
include/media/dvb_vb2.h
···2222#include <media/videobuf2-dma-contig.h>2323#include <media/videobuf2-vmalloc.h>24242525+/**2626+ * enum dvb_buf_type - types of Digital TV memory-mapped buffers2727+ *2828+ * @DVB_BUF_TYPE_CAPTURE: buffer is filled by the Kernel,2929+ * with a received Digital TV stream3030+ */2531enum dvb_buf_type {2632 DVB_BUF_TYPE_CAPTURE = 1,2733};28342929-#define DVB_VB2_STATE_NONE (0x0)3030-#define DVB_VB2_STATE_INIT (0x1)3131-#define DVB_VB2_STATE_REQBUFS (0x2)3232-#define DVB_VB2_STATE_STREAMON (0x4)3535+/**3636+ * enum dvb_vb2_states - states to control VB2 state machine3737+ * @DVB_VB2_STATE_NONE:3838+ * VB2 engine not initialized yet, init failed or VB2 was released.3939+ * @DVB_VB2_STATE_INIT:4040+ * VB2 engine initialized.4141+ * @DVB_VB2_STATE_REQBUFS:4242+ * Buffers were requested4343+ * @DVB_VB2_STATE_STREAMON:4444+ * VB2 is streaming. Callers should not check it directly. Instead,4545+ * they should use dvb_vb2_is_streaming().4646+ *4747+ * Note:4848+ *4949+ * Callers should not touch at the state machine directly. This5050+ * is handled inside dvb_vb2.c.5151+ */5252+enum dvb_vb2_states {5353+ DVB_VB2_STATE_NONE = 0x0,5454+ DVB_VB2_STATE_INIT = 0x1,5555+ DVB_VB2_STATE_REQBUFS = 0x2,5656+ DVB_VB2_STATE_STREAMON = 0x4,5757+};33583459#define DVB_VB2_NAME_MAX (20)35606161+/**6262+ * struct dvb_buffer - video buffer information for v4l2.6363+ *6464+ * @vb: embedded struct &vb2_buffer.6565+ * @list: list of &struct dvb_buffer.6666+ */3667struct dvb_buffer {3768 struct vb2_buffer vb;3869 struct list_head list;3970};40717272+/**7373+ * struct dvb_vb2_ctx - control struct for VB2 handler7474+ * @vb_q: pointer to &struct vb2_queue with videobuf2 queue.7575+ * @mutex: mutex to serialize vb2 operations. Used by7676+ * vb2 core %wait_prepare and %wait_finish operations.7777+ * @slock: spin lock used to protect buffer filling at dvb_vb2.c.7878+ * @dvb_q: List of buffers that are not filled yet.7979+ * @buf: Pointer to the buffer that are currently being filled.8080+ * @offset: index to the next position at the @buf to be filled.8181+ * @remain: How many bytes are left to be filled at @buf.8282+ * @state: bitmask of buffer states as defined by &enum dvb_vb2_states.8383+ * @buf_siz: size of each VB2 buffer.8484+ * @buf_cnt: number of VB2 buffers.8585+ * @nonblocking:8686+ * If different than zero, device is operating on non-blocking8787+ * mode.8888+ * @name: name of the device type. Currently, it can either be8989+ * "dvr" or "demux_filter".9090+ */4191struct dvb_vb2_ctx {4292 struct vb2_queue vb_q;4393 struct mutex mutex;···10353 char name[DVB_VB2_NAME_MAX + 1];10454};10555106106-int dvb_vb2_stream_on(struct dvb_vb2_ctx *ctx);107107-int dvb_vb2_stream_off(struct dvb_vb2_ctx *ctx);10856#ifndef DVB_MMAP10957static inline int dvb_vb2_init(struct dvb_vb2_ctx *ctx,11058 const char *name, int non_blocking)···12375 return 0;12476}12577#else7878+/**7979+ * dvb_vb2_init - initializes VB2 handler8080+ *8181+ * @ctx: control struct for VB2 handler8282+ * @name: name for the VB2 handler8383+ * @non_blocking:8484+ * if not zero, it means that the device is at non-blocking mode8585+ */12686int dvb_vb2_init(struct dvb_vb2_ctx *ctx, const char *name, int non_blocking);8787+8888+/**8989+ * dvb_vb2_release - Releases the VB2 handler allocated resources and9090+ * put @ctx at DVB_VB2_STATE_NONE state.9191+ * @ctx: control struct for VB2 handler9292+ */12793int dvb_vb2_release(struct dvb_vb2_ctx *ctx);9494+9595+/**9696+ * dvb_vb2_is_streaming - checks if the VB2 handler is streaming9797+ * @ctx: control struct for VB2 handler9898+ *9999+ * Return: 0 if not streaming, 1 otherwise.100100+ */128101int dvb_vb2_is_streaming(struct dvb_vb2_ctx *ctx);102102+103103+/**104104+ * dvb_vb2_fill_buffer - fills a VB2 buffer105105+ * @ctx: control struct for VB2 handler106106+ * @src: place where the data is stored107107+ * @len: number of bytes to be copied from @src108108+ */129109int dvb_vb2_fill_buffer(struct dvb_vb2_ctx *ctx,130110 const unsigned char *src, int len);111111+112112+/**113113+ * dvb_vb2_poll - Wrapper to vb2_core_streamon() for Digital TV114114+ * buffer handling.115115+ *116116+ * @ctx: control struct for VB2 handler117117+ * @file: &struct file argument passed to the poll118118+ * file operation handler.119119+ * @wait: &poll_table wait argument passed to the poll120120+ * file operation handler.121121+ *122122+ * Implements poll syscall() logic.123123+ */131124unsigned int dvb_vb2_poll(struct dvb_vb2_ctx *ctx, struct file *file,132125 poll_table *wait);133126#endif134127128128+/**129129+ * dvb_vb2_stream_on() - Wrapper to vb2_core_streamon() for Digital TV130130+ * buffer handling.131131+ *132132+ * @ctx: control struct for VB2 handler133133+ *134134+ * Starts dvb streaming135135+ */136136+int dvb_vb2_stream_on(struct dvb_vb2_ctx *ctx);137137+/**138138+ * dvb_vb2_stream_off() - Wrapper to vb2_core_streamoff() for Digital TV139139+ * buffer handling.140140+ *141141+ * @ctx: control struct for VB2 handler142142+ *143143+ * Stops dvb streaming144144+ */145145+int dvb_vb2_stream_off(struct dvb_vb2_ctx *ctx);135146147147+/**148148+ * dvb_vb2_reqbufs() - Wrapper to vb2_core_reqbufs() for Digital TV149149+ * buffer handling.150150+ *151151+ * @ctx: control struct for VB2 handler152152+ * @req: &struct dmx_requestbuffers passed from userspace in153153+ * order to handle &DMX_REQBUFS.154154+ *155155+ * Initiate streaming by requesting a number of buffers. Also used to156156+ * free previously requested buffers, is ``req->count`` is zero.157157+ */136158int dvb_vb2_reqbufs(struct dvb_vb2_ctx *ctx, struct dmx_requestbuffers *req);159159+160160+/**161161+ * dvb_vb2_querybuf() - Wrapper to vb2_core_querybuf() for Digital TV162162+ * buffer handling.163163+ *164164+ * @ctx: control struct for VB2 handler165165+ * @b: &struct dmx_buffer passed from userspace in166166+ * order to handle &DMX_QUERYBUF.167167+ *168168+ * 169169+ */137170int dvb_vb2_querybuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b);171171+172172+/**173173+ * dvb_vb2_expbuf() - Wrapper to vb2_core_expbuf() for Digital TV174174+ * buffer handling.175175+ *176176+ * @ctx: control struct for VB2 handler177177+ * @exp: &struct dmx_exportbuffer passed from userspace in178178+ * order to handle &DMX_EXPBUF.179179+ *180180+ * Export a buffer as a file descriptor.181181+ */138182int dvb_vb2_expbuf(struct dvb_vb2_ctx *ctx, struct dmx_exportbuffer *exp);183183+184184+/**185185+ * dvb_vb2_qbuf() - Wrapper to vb2_core_qbuf() for Digital TV buffer handling.186186+ *187187+ * @ctx: control struct for VB2 handler188188+ * @b: &struct dmx_buffer passed from userspace in189189+ * order to handle &DMX_QBUF.190190+ *191191+ * Queue a Digital TV buffer as requested by userspace192192+ */139193int dvb_vb2_qbuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b);194194+195195+/**196196+ * dvb_vb2_dqbuf() - Wrapper to vb2_core_dqbuf() for Digital TV197197+ * buffer handling.198198+ *199199+ * @ctx: control struct for VB2 handler200200+ * @b: &struct dmx_buffer passed from userspace in201201+ * order to handle &DMX_DQBUF.202202+ *203203+ * Dequeue a Digital TV buffer to the userspace204204+ */140205int dvb_vb2_dqbuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b);206206+207207+/**208208+ * dvb_vb2_mmap() - Wrapper to vb2_mmap() for Digital TV buffer handling.209209+ *210210+ * @ctx: control struct for VB2 handler211211+ * @vma: pointer to &struct vm_area_struct with the vma passed212212+ * to the mmap file operation handler in the driver.213213+ *214214+ * map Digital TV video buffers into application address space.215215+ */141216int dvb_vb2_mmap(struct dvb_vb2_ctx *ctx, struct vm_area_struct *vma);142217143218#endif /* _DVB_VB2_H */