xref: /linux/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.h (revision 7ae9fb1b7ecbb5d85d07857943f677fd1a559b18)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (c) 2016 MediaTek Inc.
4  * Author: Ming Hsiu Tsai <minghsiu.tsai@mediatek.com>
5  *         Rick Chang <rick.chang@mediatek.com>
6  *         Xia Jiang <xia.jiang@mediatek.com>
7  */
8 
9 #ifndef _MTK_JPEG_DEC_HW_H
10 #define _MTK_JPEG_DEC_HW_H
11 
12 #include <media/videobuf2-core.h>
13 
14 #include "mtk_jpeg_dec_reg.h"
15 
16 #define MTK_JPEG_COMP_MAX		3
17 
18 enum {
19 	MTK_JPEG_DEC_RESULT_EOF_DONE		= 0,
20 	MTK_JPEG_DEC_RESULT_PAUSE		= 1,
21 	MTK_JPEG_DEC_RESULT_UNDERFLOW		= 2,
22 	MTK_JPEG_DEC_RESULT_OVERFLOW		= 3,
23 	MTK_JPEG_DEC_RESULT_ERROR_BS		= 4,
24 	MTK_JPEG_DEC_RESULT_ERROR_UNKNOWN	= 6
25 };
26 
27 struct mtk_jpeg_dec_param {
28 	u32 pic_w;
29 	u32 pic_h;
30 	u32 dec_w;
31 	u32 dec_h;
32 	u32 src_color;
33 	u32 dst_fourcc;
34 	u32 mcu_w;
35 	u32 mcu_h;
36 	u32 total_mcu;
37 	u32 unit_num;
38 	u32 comp_num;
39 	u32 comp_id[MTK_JPEG_COMP_MAX];
40 	u32 sampling_w[MTK_JPEG_COMP_MAX];
41 	u32 sampling_h[MTK_JPEG_COMP_MAX];
42 	u32 qtbl_num[MTK_JPEG_COMP_MAX];
43 	u32 blk_num;
44 	u32 blk_comp[MTK_JPEG_COMP_MAX];
45 	u32 membership;
46 	u32 dma_mcu;
47 	u32 dma_group;
48 	u32 dma_last_mcu;
49 	u32 img_stride[MTK_JPEG_COMP_MAX];
50 	u32 mem_stride[MTK_JPEG_COMP_MAX];
51 	u32 comp_w[MTK_JPEG_COMP_MAX];
52 	u32 comp_size[MTK_JPEG_COMP_MAX];
53 	u32 y_size;
54 	u32 uv_size;
55 	u32 dec_size;
56 	u8 uv_brz_w;
57 };
58 
59 struct mtk_jpeg_bs {
60 	dma_addr_t	str_addr;
61 	dma_addr_t	end_addr;
62 	size_t		size;
63 };
64 
65 struct mtk_jpeg_fb {
66 	dma_addr_t	plane_addr[MTK_JPEG_COMP_MAX];
67 	size_t		size;
68 };
69 
70 int mtk_jpeg_dec_fill_param(struct mtk_jpeg_dec_param *param);
71 u32 mtk_jpeg_dec_get_int_status(void __iomem *dec_reg_base);
72 u32 mtk_jpeg_dec_enum_result(u32 irq_result);
73 void mtk_jpeg_dec_set_config(void __iomem *base,
74 			     struct mtk_jpeg_dec_param *cfg,
75 			     u32 bitstream_size,
76 			     struct mtk_jpeg_bs *bs,
77 			     struct mtk_jpeg_fb *fb);
78 void mtk_jpeg_dec_reset(void __iomem *dec_reg_base);
79 void mtk_jpeg_dec_start(void __iomem *dec_reg_base);
80 
81 #endif /* _MTK_JPEG_HW_H */
82