Linux 4.16.11
[linux/fpc-iii.git] / drivers / media / platform / mtk-jpeg / mtk_jpeg_hw.h
blob37152a630dea903d4f5145a0c6a6958b9fa49e10
1 /*
2 * Copyright (c) 2016 MediaTek Inc.
3 * Author: Ming Hsiu Tsai <minghsiu.tsai@mediatek.com>
4 * Rick Chang <rick.chang@mediatek.com>
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.
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.
16 #ifndef _MTK_JPEG_HW_H
17 #define _MTK_JPEG_HW_H
19 #include <media/videobuf2-core.h>
21 #include "mtk_jpeg_core.h"
22 #include "mtk_jpeg_reg.h"
24 enum {
25 MTK_JPEG_DEC_RESULT_EOF_DONE = 0,
26 MTK_JPEG_DEC_RESULT_PAUSE = 1,
27 MTK_JPEG_DEC_RESULT_UNDERFLOW = 2,
28 MTK_JPEG_DEC_RESULT_OVERFLOW = 3,
29 MTK_JPEG_DEC_RESULT_ERROR_BS = 4,
30 MTK_JPEG_DEC_RESULT_ERROR_UNKNOWN = 6
33 struct mtk_jpeg_dec_param {
34 u32 pic_w;
35 u32 pic_h;
36 u32 dec_w;
37 u32 dec_h;
38 u32 src_color;
39 u32 dst_fourcc;
40 u32 mcu_w;
41 u32 mcu_h;
42 u32 total_mcu;
43 u32 unit_num;
44 u32 comp_num;
45 u32 comp_id[MTK_JPEG_COMP_MAX];
46 u32 sampling_w[MTK_JPEG_COMP_MAX];
47 u32 sampling_h[MTK_JPEG_COMP_MAX];
48 u32 qtbl_num[MTK_JPEG_COMP_MAX];
49 u32 blk_num;
50 u32 blk_comp[MTK_JPEG_COMP_MAX];
51 u32 membership;
52 u32 dma_mcu;
53 u32 dma_group;
54 u32 dma_last_mcu;
55 u32 img_stride[MTK_JPEG_COMP_MAX];
56 u32 mem_stride[MTK_JPEG_COMP_MAX];
57 u32 comp_w[MTK_JPEG_COMP_MAX];
58 u32 comp_size[MTK_JPEG_COMP_MAX];
59 u32 y_size;
60 u32 uv_size;
61 u32 dec_size;
62 u8 uv_brz_w;
65 static inline u32 mtk_jpeg_align(u32 val, u32 align)
67 return (val + align - 1) & ~(align - 1);
70 struct mtk_jpeg_bs {
71 dma_addr_t str_addr;
72 dma_addr_t end_addr;
73 size_t size;
76 struct mtk_jpeg_fb {
77 dma_addr_t plane_addr[MTK_JPEG_COMP_MAX];
78 size_t size;
81 int mtk_jpeg_dec_fill_param(struct mtk_jpeg_dec_param *param);
82 u32 mtk_jpeg_dec_get_int_status(void __iomem *dec_reg_base);
83 u32 mtk_jpeg_dec_enum_result(u32 irq_result);
84 void mtk_jpeg_dec_set_config(void __iomem *base,
85 struct mtk_jpeg_dec_param *config,
86 struct mtk_jpeg_bs *bs,
87 struct mtk_jpeg_fb *fb);
88 void mtk_jpeg_dec_reset(void __iomem *dec_reg_base);
89 void mtk_jpeg_dec_start(void __iomem *dec_reg_base);
91 #endif /* _MTK_JPEG_HW_H */