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 */
7
8 #ifndef _MTK_JPEG_HW_H
9 #define _MTK_JPEG_HW_H
10
11 #include <media/videobuf2-core.h>
12
13 #include "mtk_jpeg_core.h"
14 #include "mtk_jpeg_reg.h"
15
16 enum {
17 MTK_JPEG_DEC_RESULT_EOF_DONE = 0,
18 MTK_JPEG_DEC_RESULT_PAUSE = 1,
19 MTK_JPEG_DEC_RESULT_UNDERFLOW = 2,
20 MTK_JPEG_DEC_RESULT_OVERFLOW = 3,
21 MTK_JPEG_DEC_RESULT_ERROR_BS = 4,
22 MTK_JPEG_DEC_RESULT_ERROR_UNKNOWN = 6
23 };
24
25 struct mtk_jpeg_dec_param {
26 u32 pic_w;
27 u32 pic_h;
28 u32 dec_w;
29 u32 dec_h;
30 u32 src_color;
31 u32 dst_fourcc;
32 u32 mcu_w;
33 u32 mcu_h;
34 u32 total_mcu;
35 u32 unit_num;
36 u32 comp_num;
37 u32 comp_id[MTK_JPEG_COMP_MAX];
38 u32 sampling_w[MTK_JPEG_COMP_MAX];
39 u32 sampling_h[MTK_JPEG_COMP_MAX];
40 u32 qtbl_num[MTK_JPEG_COMP_MAX];
41 u32 blk_num;
42 u32 blk_comp[MTK_JPEG_COMP_MAX];
43 u32 membership;
44 u32 dma_mcu;
45 u32 dma_group;
46 u32 dma_last_mcu;
47 u32 img_stride[MTK_JPEG_COMP_MAX];
48 u32 mem_stride[MTK_JPEG_COMP_MAX];
49 u32 comp_w[MTK_JPEG_COMP_MAX];
50 u32 comp_size[MTK_JPEG_COMP_MAX];
51 u32 y_size;
52 u32 uv_size;
53 u32 dec_size;
54 u8 uv_brz_w;
55 };
56
mtk_jpeg_align(u32 val,u32 align)57 static inline u32 mtk_jpeg_align(u32 val, u32 align)
58 {
59 return (val + align - 1) & ~(align - 1);
60 }
61
62 struct mtk_jpeg_bs {
63 dma_addr_t str_addr;
64 dma_addr_t end_addr;
65 size_t size;
66 };
67
68 struct mtk_jpeg_fb {
69 dma_addr_t plane_addr[MTK_JPEG_COMP_MAX];
70 size_t size;
71 };
72
73 int mtk_jpeg_dec_fill_param(struct mtk_jpeg_dec_param *param);
74 u32 mtk_jpeg_dec_get_int_status(void __iomem *dec_reg_base);
75 u32 mtk_jpeg_dec_enum_result(u32 irq_result);
76 void mtk_jpeg_dec_set_config(void __iomem *base,
77 struct mtk_jpeg_dec_param *config,
78 struct mtk_jpeg_bs *bs,
79 struct mtk_jpeg_fb *fb);
80 void mtk_jpeg_dec_reset(void __iomem *dec_reg_base);
81 void mtk_jpeg_dec_start(void __iomem *dec_reg_base);
82
83 #endif /* _MTK_JPEG_HW_H */
84