• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * linux-5.4/drivers/media/platform/sunxi-vin/vin-vipp/vipp_reg.h
3  *
4  * Copyright (c) 2007-2017 Allwinnertech Co., Ltd.
5  *
6  * Authors:  Zhao Wei <zhaowei@allwinnertech.com>
7  *
8  * This software is licensed under the terms of the GNU General Public
9  * License version 2, as published by the Free Software Foundation, and
10  * may be copied, distributed, and modified under those terms.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  */
18 
19 #ifndef __VIPP__REG__H__
20 #define __VIPP__REG__H__
21 
22 #include <linux/types.h>
23 
24 #if defined CONFIG_ARCH_SUN8IW16P1
25 #define MAX_OVERLAY_NUM 8
26 #define OSD_PARA_SIZE 0
27 #define OSD_STAT_SIZE (2048 * 8)
28 #define MAX_OSD_NUM 2
29 #define MAX_COVER_NUM 8
30 #define MAX_ORL_NUM 0
31 #elif defined CONFIG_ARCH_SUN8IW19P1
32 #define MAX_OVERLAY_NUM 0
33 #define OSD_PARA_SIZE 0
34 #define OSD_STAT_SIZE 0
35 #define MAX_OSD_NUM 2
36 #define MAX_COVER_NUM 0
37 #define MAX_ORL_NUM 16
38 #elif defined CONFIG_ARCH_SUN8IW12P1
39 #define MAX_OVERLAY_NUM 64
40 #define OSD_PARA_SIZE (MAX_OVERLAY_NUM * 8 + MAX_COVER_NUM * 8 + MAX_COVER_NUM * 8)
41 #define OSD_STAT_SIZE (MAX_OVERLAY_NUM * 8)
42 #define MAX_OSD_NUM VIN_MAX_SCALER
43 #define MAX_COVER_NUM 8
44 #define MAX_ORL_NUM 0
45 #else
46 #define MAX_OVERLAY_NUM 0
47 #define OSD_PARA_SIZE 0
48 #define OSD_STAT_SIZE 0
49 #define MAX_OSD_NUM 0
50 #define MAX_COVER_NUM 0
51 #define MAX_ORL_NUM 0
52 #endif
53 
54 #define VIPP_REG_SIZE 0X400
55 
56 /*register value*/
57 enum vipp_ready_flag {
58 	NOT_READY = 0,
59 	HAS_READY = 1,
60 };
61 
62 enum vipp_update_flag {
63 	NOT_UPDATED = 0,
64 	HAS_UPDATED = 1,
65 };
66 
67 enum vipp_status_sel {
68 	REG_LOAD_PD = 0X1,
69 	BM_ERROR_PD = 0X4,
70 	STATUS_ALL = 0X5,
71 };
72 
73 enum vipp_format {
74 	YUV420 = 0,
75 	YUV422 = 1,
76 };
77 
78 enum vipp_osd_argb {
79 	ARGB1555 = 0,
80 	ARGB4444 = 1,
81 	ARGB8888 = 2,
82 };
83 
84 /*register data struct*/
85 
86 struct vipp_version {
87 	unsigned int ver_big;
88 	unsigned int ver_small;
89 };
90 
91 struct vipp_feature_list {
92 	unsigned int yuv422to420;
93 	unsigned int osd_exit;
94 };
95 
96 struct vipp_status {
97 	unsigned int reg_load_pd;
98 	unsigned int bm_error_pd;
99 };
100 
101 struct vipp_scaler_config {
102 	enum vipp_format sc_out_fmt;
103 	unsigned int sc_x_ratio;
104 	unsigned int sc_y_ratio;
105 	unsigned int sc_w_shift;
106 };
107 
108 struct vipp_scaler_size {
109 	unsigned int sc_width;
110 	unsigned int sc_height;
111 };
112 
113 struct vipp_osd_config {
114 	unsigned char osd_ov_en;
115 	unsigned char osd_cv_en;
116 	unsigned char osd_orl_en;
117 	enum vipp_osd_argb osd_argb_mode;
118 	unsigned char osd_stat_en;
119 	unsigned int osd_orl_width;
120 	short osd_ov_num;
121 	short osd_cv_num;
122 	short osd_orl_num;
123 };
124 
125 struct vipp_rgb2yuv_factor {
126 	unsigned int jc0;
127 	unsigned int jc1;
128 	unsigned int jc2;
129 	unsigned int jc3;
130 	unsigned int jc4;
131 	unsigned int jc5;
132 	unsigned int jc6;
133 	unsigned int jc7;
134 	unsigned int jc8;
135 	unsigned int jc9;
136 	unsigned int jc10;
137 	unsigned int jc11;
138 };
139 
140 struct vipp_crop {
141 	unsigned int hor;
142 	unsigned int ver;
143 	unsigned int width;
144 	unsigned int height;
145 };
146 
147 struct vipp_osd_overlay_cfg {
148 	unsigned int h_start;
149 	unsigned int h_end;
150 	unsigned int v_start;
151 	unsigned int v_end;
152 	unsigned int alpha;
153 	unsigned int inv_en;
154 	unsigned int inv_th;
155 	unsigned int inv_w_rgn;
156 	unsigned int inv_h_rgn;
157 };
158 
159 struct vipp_osd_cover_cfg {
160 	unsigned int h_start;
161 	unsigned int h_end;
162 	unsigned int v_start;
163 	unsigned int v_end;
164 };
165 
166 struct vipp_osd_cover_data {
167 	unsigned int y;
168 	unsigned int u;
169 	unsigned int v;
170 };
171 
172 struct vipp_osd_para_config {
173 	struct vipp_osd_overlay_cfg overlay_cfg[MAX_OVERLAY_NUM];
174 	struct vipp_osd_cover_cfg cover_cfg[MAX_COVER_NUM];
175 	struct vipp_osd_cover_data cover_data[MAX_COVER_NUM];
176 	struct vipp_osd_cover_cfg orl_cfg[MAX_ORL_NUM];
177 	struct vipp_osd_cover_data orl_data[MAX_ORL_NUM];
178 };
179 
180 int vipp_set_base_addr(unsigned int id, unsigned long addr);
181 void vipp_top_clk_en(unsigned int id, unsigned int en);
182 void vipp_enable(unsigned int id);
183 void vipp_disable(unsigned int id);
184 void vipp_ver_en(unsigned int id, unsigned int en);
185 void vipp_version_get(unsigned int id, struct vipp_version *v);
186 void vipp_feature_list_get(unsigned int id, struct vipp_feature_list *fl);
187 
188 void vipp_set_para_ready(unsigned int id, enum vipp_ready_flag flag);
189 void vipp_set_osd_ov_update(unsigned int id, enum vipp_update_flag flag);
190 void vipp_set_osd_cv_update(unsigned int id, enum vipp_update_flag flag);
191 void vipp_set_osd_para_load_addr(unsigned int id, unsigned long dma_addr);
192 int vipp_map_osd_para_load_addr(unsigned int id, unsigned long vaddr);
193 void vipp_set_osd_stat_load_addr(unsigned int id, unsigned long dma_addr);
194 void vipp_set_osd_bm_load_addr(unsigned int id, unsigned long dma_addr);
195 void vipp_set_reg_load_addr(unsigned int id, unsigned long dma_addr);
196 int vipp_map_reg_load_addr(unsigned int id, unsigned long vaddr);
197 void vipp_get_status(unsigned int id, struct vipp_status *status);
198 void vipp_clr_status(unsigned int id, enum vipp_status_sel sel);
199 
200 void vipp_scaler_en(unsigned int id, unsigned int en);
201 void vipp_osd_en(unsigned int id, unsigned int en);
202 void vipp_chroma_ds_en(unsigned int id, unsigned int en);
203 void vipp_scaler_cfg(unsigned int id, struct vipp_scaler_config *cfg);
204 void vipp_scaler_output_fmt(unsigned int id, enum vipp_format);
205 void vipp_scaler_output_size(unsigned int id, struct vipp_scaler_size *size);
206 
207 void vipp_output_fmt_cfg(unsigned int id, enum vipp_format fmt);
208 void vipp_osd_cfg(unsigned int id, struct vipp_osd_config *cfg);
209 void vipp_osd_rgb2yuv(unsigned int id, struct vipp_rgb2yuv_factor *factor);
210 void vipp_set_crop(unsigned int id, struct vipp_crop *crop);
211 void vipp_osd_hvflip(unsigned int id, int hflip, int vflip);
212 void vipp_osd_inverse(unsigned int id, int *inverse, int cnt);
213 void vipp_osd_para_cfg(unsigned int id, struct vipp_osd_para_config *para,
214 				struct vipp_osd_config *cfg);
215 
216 #endif /* __VIPP__REG__H__ */
217