blob: 7a529844c5e1abc29e1b8123d48439b2feeab213 [file] [log] [blame]
Satendra Singh Thakur57868ac2017-12-18 22:35:53 -05001/*
Mauro Carvalho Chehab7b361cf2017-12-21 11:09:29 -05002 * SPDX-License-Identifier: GPL-2.0
3 *
Satendra Singh Thakur57868ac2017-12-18 22:35:53 -05004 * dvb-vb2.h - DVB driver helper framework for streaming I/O
5 *
6 * Copyright (C) 2015 Samsung Electronics
7 *
8 * Author: jh1009.sung@samsung.com
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation.
13 */
14
15#ifndef _DVB_VB2_H
16#define _DVB_VB2_H
17
18#include <linux/mutex.h>
19#include <linux/poll.h>
20#include <linux/dvb/dmx.h>
21#include <media/videobuf2-core.h>
22#include <media/videobuf2-dma-contig.h>
23#include <media/videobuf2-vmalloc.h>
24
25enum dvb_buf_type {
26 DVB_BUF_TYPE_CAPTURE = 1,
27 DVB_BUF_TYPE_OUTPUT = 2,
28};
29
30#define DVB_VB2_STATE_NONE (0x0)
31#define DVB_VB2_STATE_INIT (0x1)
32#define DVB_VB2_STATE_REQBUFS (0x2)
33#define DVB_VB2_STATE_STREAMON (0x4)
34
35#define DVB_VB2_NAME_MAX (20)
36
37struct dvb_buffer {
38 struct vb2_buffer vb;
39 struct list_head list;
40};
41
42struct dvb_vb2_ctx {
43 struct vb2_queue vb_q;
44 struct mutex mutex;
45 spinlock_t slock;
46 struct list_head dvb_q;
47 struct dvb_buffer *buf;
48 int offset;
49 int remain;
50 int state;
51 int buf_siz;
52 int buf_cnt;
53 int nonblocking;
54 char name[DVB_VB2_NAME_MAX + 1];
55};
56
Satendra Singh Thakur57868ac2017-12-18 22:35:53 -050057int dvb_vb2_stream_on(struct dvb_vb2_ctx *ctx);
58int dvb_vb2_stream_off(struct dvb_vb2_ctx *ctx);
Mauro Carvalho Chehab40210532017-12-28 09:24:20 -050059#ifndef DVB_MMAP
60static inline int dvb_vb2_init(struct dvb_vb2_ctx *ctx,
61 const char *name, int non_blocking)
62{
63 return 0;
64};
65static inline int dvb_vb2_release(struct dvb_vb2_ctx *ctx)
66{
67 return 0;
68};
69#define dvb_vb2_is_streaming(ctx) (0)
70#define dvb_vb2_fill_buffer(ctx, file, wait) (0)
71
72static inline unsigned int dvb_vb2_poll(struct dvb_vb2_ctx *ctx,
73 struct file *file,
74 poll_table *wait)
75{
76 return 0;
77}
78#else
79int dvb_vb2_init(struct dvb_vb2_ctx *ctx, const char *name, int non_blocking);
80int dvb_vb2_release(struct dvb_vb2_ctx *ctx);
Satendra Singh Thakur57868ac2017-12-18 22:35:53 -050081int dvb_vb2_is_streaming(struct dvb_vb2_ctx *ctx);
82int dvb_vb2_fill_buffer(struct dvb_vb2_ctx *ctx,
83 const unsigned char *src, int len);
Mauro Carvalho Chehab40210532017-12-28 09:24:20 -050084unsigned int dvb_vb2_poll(struct dvb_vb2_ctx *ctx, struct file *file,
85 poll_table *wait);
86#endif
87
Satendra Singh Thakur57868ac2017-12-18 22:35:53 -050088
89int dvb_vb2_reqbufs(struct dvb_vb2_ctx *ctx, struct dmx_requestbuffers *req);
90int dvb_vb2_querybuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b);
91int dvb_vb2_expbuf(struct dvb_vb2_ctx *ctx, struct dmx_exportbuffer *exp);
92int dvb_vb2_qbuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b);
93int dvb_vb2_dqbuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b);
94int dvb_vb2_mmap(struct dvb_vb2_ctx *ctx, struct vm_area_struct *vma);
Satendra Singh Thakur57868ac2017-12-18 22:35:53 -050095
96#endif /* _DVB_VB2_H */