Satendra Singh Thakur | 57868ac | 2017-12-18 22:35:53 -0500 | [diff] [blame] | 1 | /* |
Mauro Carvalho Chehab | 7b361cf | 2017-12-21 11:09:29 -0500 | [diff] [blame] | 2 | * SPDX-License-Identifier: GPL-2.0 |
| 3 | * |
Satendra Singh Thakur | 57868ac | 2017-12-18 22:35:53 -0500 | [diff] [blame] | 4 | * 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 | |
| 25 | enum 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 | |
| 37 | struct dvb_buffer { |
| 38 | struct vb2_buffer vb; |
| 39 | struct list_head list; |
| 40 | }; |
| 41 | |
| 42 | struct 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 Thakur | 57868ac | 2017-12-18 22:35:53 -0500 | [diff] [blame] | 57 | int dvb_vb2_stream_on(struct dvb_vb2_ctx *ctx); |
| 58 | int dvb_vb2_stream_off(struct dvb_vb2_ctx *ctx); |
Mauro Carvalho Chehab | 4021053 | 2017-12-28 09:24:20 -0500 | [diff] [blame] | 59 | #ifndef DVB_MMAP |
| 60 | static inline int dvb_vb2_init(struct dvb_vb2_ctx *ctx, |
| 61 | const char *name, int non_blocking) |
| 62 | { |
| 63 | return 0; |
| 64 | }; |
| 65 | static 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 | |
| 72 | static 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 |
| 79 | int dvb_vb2_init(struct dvb_vb2_ctx *ctx, const char *name, int non_blocking); |
| 80 | int dvb_vb2_release(struct dvb_vb2_ctx *ctx); |
Satendra Singh Thakur | 57868ac | 2017-12-18 22:35:53 -0500 | [diff] [blame] | 81 | int dvb_vb2_is_streaming(struct dvb_vb2_ctx *ctx); |
| 82 | int dvb_vb2_fill_buffer(struct dvb_vb2_ctx *ctx, |
| 83 | const unsigned char *src, int len); |
Mauro Carvalho Chehab | 4021053 | 2017-12-28 09:24:20 -0500 | [diff] [blame] | 84 | unsigned int dvb_vb2_poll(struct dvb_vb2_ctx *ctx, struct file *file, |
| 85 | poll_table *wait); |
| 86 | #endif |
| 87 | |
Satendra Singh Thakur | 57868ac | 2017-12-18 22:35:53 -0500 | [diff] [blame] | 88 | |
| 89 | int dvb_vb2_reqbufs(struct dvb_vb2_ctx *ctx, struct dmx_requestbuffers *req); |
| 90 | int dvb_vb2_querybuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b); |
| 91 | int dvb_vb2_expbuf(struct dvb_vb2_ctx *ctx, struct dmx_exportbuffer *exp); |
| 92 | int dvb_vb2_qbuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b); |
| 93 | int dvb_vb2_dqbuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b); |
| 94 | int dvb_vb2_mmap(struct dvb_vb2_ctx *ctx, struct vm_area_struct *vma); |
Satendra Singh Thakur | 57868ac | 2017-12-18 22:35:53 -0500 | [diff] [blame] | 95 | |
| 96 | #endif /* _DVB_VB2_H */ |