nvme-rdma: use dynamic dma mapping per command
[sfrench/cifs-2.6.git] / drivers / media / platform / mtk-vcodec / mtk_vcodec_dec.h
1 /*
2  * Copyright (c) 2016 MediaTek Inc.
3  * Author: PC Chen <pc.chen@mediatek.com>
4  *         Tiffany Lin <tiffany.lin@mediatek.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  */
15
16 #ifndef _MTK_VCODEC_DEC_H_
17 #define _MTK_VCODEC_DEC_H_
18
19 #include <media/videobuf2-core.h>
20 #include <media/videobuf2-v4l2.h>
21
22 #define VCODEC_CAPABILITY_4K_DISABLED   0x10
23 #define VCODEC_DEC_4K_CODED_WIDTH       4096U
24 #define VCODEC_DEC_4K_CODED_HEIGHT      2304U
25 #define MTK_VDEC_MAX_W  2048U
26 #define MTK_VDEC_MAX_H  1088U
27
28 #define MTK_VDEC_IRQ_STATUS_DEC_SUCCESS        0x10000
29
30 /**
31  * struct vdec_fb  - decoder frame buffer
32  * @base_y      : Y plane memory info
33  * @base_c      : C plane memory info
34  * @status      : frame buffer status (vdec_fb_status)
35  */
36 struct vdec_fb {
37         struct mtk_vcodec_mem   base_y;
38         struct mtk_vcodec_mem   base_c;
39         unsigned int    status;
40 };
41
42 /**
43  * struct mtk_video_dec_buf - Private data related to each VB2 buffer.
44  * @b:          VB2 buffer
45  * @list:       link list
46  * @used:       Capture buffer contain decoded frame data and keep in
47  *                      codec data structure
48  * @queued_in_vb2:      Capture buffer is queue in vb2
49  * @queued_in_v4l2:     Capture buffer is in v4l2 driver, but not in vb2
50  *                      queue yet
51  * @lastframe:          Intput buffer is last buffer - EOS
52  * @error:              An unrecoverable error occurs on this buffer.
53  * @frame_buffer:       Decode status, and buffer information of Capture buffer
54  *
55  * Note : These status information help us track and debug buffer state
56  */
57 struct mtk_video_dec_buf {
58         struct vb2_v4l2_buffer  vb;
59         struct list_head        list;
60
61         bool    used;
62         bool    queued_in_vb2;
63         bool    queued_in_v4l2;
64         bool    lastframe;
65         bool    error;
66         struct vdec_fb  frame_buffer;
67 };
68
69 extern const struct v4l2_ioctl_ops mtk_vdec_ioctl_ops;
70 extern const struct v4l2_m2m_ops mtk_vdec_m2m_ops;
71
72
73 /*
74  * mtk_vdec_lock/mtk_vdec_unlock are for ctx instance to
75  * get/release lock before/after access decoder hw.
76  * mtk_vdec_lock get decoder hw lock and set curr_ctx
77  * to ctx instance that get lock
78  */
79 void mtk_vdec_unlock(struct mtk_vcodec_ctx *ctx);
80 void mtk_vdec_lock(struct mtk_vcodec_ctx *ctx);
81 int mtk_vcodec_dec_queue_init(void *priv, struct vb2_queue *src_vq,
82                            struct vb2_queue *dst_vq);
83 void mtk_vcodec_dec_set_default_params(struct mtk_vcodec_ctx *ctx);
84 void mtk_vcodec_dec_release(struct mtk_vcodec_ctx *ctx);
85 int mtk_vcodec_dec_ctrls_setup(struct mtk_vcodec_ctx *ctx);
86
87
88 #endif /* _MTK_VCODEC_DEC_H_ */