1 #ifndef __UAPI_CAM_ISP_H__
2 #define __UAPI_CAM_ISP_H__
3 
4 #include "cam_defs.h"
5 #include "cam_isp_vfe.h"
6 #include "cam_isp_ife.h"
7 #ifdef CONFIG_BOARD_SUNFISH
8 #include "cam_cpas.h"
9 #endif /*CONFIG_BOARD_SUNFISH*/
10 
11 #define CAM_ISP_DEV_NAME                        "cam-isp"
12 
13 #define CAM_ISP_HW_BASE                         0
14 #define CAM_ISP_HW_CSID                         1
15 #define CAM_ISP_HW_VFE                          2
16 #define CAM_ISP_HW_IFE                          3
17 #define CAM_ISP_HW_ISPIF                        4
18 #define CAM_ISP_HW_MAX                          5
19 
20 #define CAM_ISP_PATTERN_BAYER_RGRGRG            0
21 #define CAM_ISP_PATTERN_BAYER_GRGRGR            1
22 #define CAM_ISP_PATTERN_BAYER_BGBGBG            2
23 #define CAM_ISP_PATTERN_BAYER_GBGBGB            3
24 #define CAM_ISP_PATTERN_YUV_YCBYCR              4
25 #define CAM_ISP_PATTERN_YUV_YCRYCB              5
26 #define CAM_ISP_PATTERN_YUV_CBYCRY              6
27 #define CAM_ISP_PATTERN_YUV_CRYCBY              7
28 #define CAM_ISP_PATTERN_MAX                     8
29 
30 #define CAM_ISP_RES_USAGE_SINGLE                0
31 #define CAM_ISP_RES_USAGE_DUAL                  1
32 #define CAM_ISP_RES_USAGE_MAX                   2
33 
34 #define CAM_ISP_RES_ID_PORT                     0
35 #define CAM_ISP_RES_ID_CLK                      1
36 #define CAM_ISP_RES_ID_MAX                      2
37 
38 
39 #define CAM_ISP_LANE_TYPE_DPHY                  0
40 #define CAM_ISP_LANE_TYPE_CPHY                  1
41 #define CAM_ISP_LANE_TYPE_MAX                   2
42 
43 #define CAM_ISP_RES_COMP_GROUP_NONE             0
44 #define CAM_ISP_RES_COMP_GROUP_ID_0             1
45 #define CAM_ISP_RES_COMP_GROUP_ID_1             2
46 #define CAM_ISP_RES_COMP_GROUP_ID_2             3
47 #define CAM_ISP_RES_COMP_GROUP_ID_3             4
48 #define CAM_ISP_RES_COMP_GROUP_ID_4             5
49 #define CAM_ISP_RES_COMP_GROUP_ID_5             6
50 #define CAM_ISP_RES_COMP_GROUP_ID_MAX           6
51 
52 #define CAM_ISP_PACKET_OP_BASE                  0
53 #define CAM_ISP_PACKET_INIT_DEV                 1
54 #define CAM_ISP_PACKET_UPDATE_DEV               2
55 #define CAM_ISP_PACKET_OP_MAX                   3
56 
57 #define CAM_ISP_PACKET_META_BASE                0
58 #define CAM_ISP_PACKET_META_LEFT                1
59 #define CAM_ISP_PACKET_META_RIGHT               2
60 #define CAM_ISP_PACKET_META_COMMON              3
61 #define CAM_ISP_PACKET_META_DMI_LEFT            4
62 #define CAM_ISP_PACKET_META_DMI_RIGHT           5
63 #define CAM_ISP_PACKET_META_DMI_COMMON          6
64 #define CAM_ISP_PACKET_META_CLOCK               7
65 #define CAM_ISP_PACKET_META_CSID                8
66 #define CAM_ISP_PACKET_META_DUAL_CONFIG         9
67 #define CAM_ISP_PACKET_META_GENERIC_BLOB_LEFT   10
68 #define CAM_ISP_PACKET_META_GENERIC_BLOB_RIGHT  11
69 #define CAM_ISP_PACKET_META_GENERIC_BLOB_COMMON 12
70 
71 #define CAM_ISP_DSP_MODE_NONE                   0
72 #define CAM_ISP_DSP_MODE_ONE_WAY                1
73 #define CAM_ISP_DSP_MODE_ROUND                  2
74 
75 #define CAM_ISP_GENERIC_BLOB_TYPE_HFR_CONFIG          0
76 #define CAM_ISP_GENERIC_BLOB_TYPE_CLOCK_CONFIG        1
77 #define CAM_ISP_GENERIC_BLOB_TYPE_BW_CONFIG           2
78 #define CAM_ISP_GENERIC_BLOB_TYPE_UBWC_CONFIG         3
79 #define CAM_ISP_GENERIC_BLOB_TYPE_CSID_CLOCK_CONFIG   4
80 #define CAM_ISP_GENERIC_BLOB_TYPE_FE_CONFIG           5
81 #define CAM_ISP_GENERIC_BLOB_TYPE_BW_CONFIG_V2        6
82 
83 
84 #ifdef CONFIG_BOARD_SUNFISH
85 
86  /* ISP Generic Cmd Buffer Blob types */
87 #define CAM_ISP_GENERIC_BLOB_TYPE_INIT_FRAME_DROP           10
88 #define CAM_ISP_GENERIC_BLOB_TYPE_SENSOR_DIMENSION_CONFIG   11
89 #define CAM_ISP_GENERIC_BLOB_TYPE_FPS_CONFIG                12
90 
91 #define CAM_ISP_USAGE_INVALID     0
92 #define CAM_ISP_USAGE_LEFT_PX     1
93 #define CAM_ISP_USAGE_RIGHT_PX    2
94 #define CAM_ISP_USAGE_RDI         3
95 
96 struct cam_isp_bw_config_v2 {
97        uint32_t                             usage_type;
98        uint32_t                             num_paths;
99        struct cam_axi_per_path_bw_vote      axi_path[1];
100 } __attribute__((packed));
101 
102 struct cam_isp_sensor_dimension {
103        uint32_t width;
104        uint32_t height;
105        uint32_t measure_enabled;
106 } __attribute__((packed));
107 
108 struct cam_isp_sensor_config {
109        struct cam_isp_sensor_dimension  ppp_path;
110        struct cam_isp_sensor_dimension  ipp_path;
111        struct cam_isp_sensor_dimension  rdi_path[4];
112        uint32_t                   hbi;
113        uint32_t                   vbi;
114 } __attribute__((packed));
115 
116 
117 struct cam_isp_init_frame_drop_config {
118        uint32_t                       init_frame_drop;
119 } __attribute__((packed));
120 
121 struct cam_fps_config {
122        uint32_t        fps;
123 } __attribute__((packed));
124 
125 #endif /*CONFIG_BOARD_SUNFISH*/
126 
127 struct cam_isp_dev_cap_info {
128 	uint32_t              hw_type;
129 	uint32_t              reserved;
130 	struct cam_hw_version hw_version;
131 };
132 
133 struct cam_isp_query_cap_cmd {
134 	struct cam_iommu_handle       device_iommu;
135 	struct cam_iommu_handle       cdm_iommu;
136 	int32_t                       num_dev;
137 	uint32_t                      reserved;
138 	struct cam_isp_dev_cap_info   dev_caps[CAM_ISP_HW_MAX];
139 };
140 
141 struct cam_isp_out_port_info {
142 	uint32_t                res_type;
143 	uint32_t                format;
144 	uint32_t                width;
145 	uint32_t                height;
146 	uint32_t                comp_grp_id;
147 	uint32_t                split_point;
148 	uint32_t                secure_mode;
149 	uint32_t                reserved;
150 };
151 
152 struct cam_isp_in_port_info {
153 	uint32_t                        res_type;
154 	uint32_t                        lane_type;
155 	uint32_t                        lane_num;
156 	uint32_t                        lane_cfg;
157 	uint32_t                        vc;
158 	uint32_t                        dt;
159 	uint32_t                        format;
160 	uint32_t                        test_pattern;
161 	uint32_t                        usage_type;
162 	uint32_t                        left_start;
163 	uint32_t                        left_stop;
164 	uint32_t                        left_width;
165 	uint32_t                        right_start;
166 	uint32_t                        right_stop;
167 	uint32_t                        right_width;
168 	uint32_t                        line_start;
169 	uint32_t                        line_stop;
170 	uint32_t                        height;
171 	uint32_t                        pixel_clk;
172 	uint32_t                        batch_size;
173 	uint32_t                        dsp_mode;
174 	uint32_t                        hbi_cnt;
175 	uint32_t                        reserved;
176 	uint32_t                        num_out_res;
177 	struct cam_isp_out_port_info    data[1];
178 };
179 
180 struct cam_isp_resource {
181 	uint32_t                       resource_id;
182 	uint32_t                       length;
183 	uint32_t                       handle_type;
184 	uint32_t                       reserved;
185 	uint64_t                       res_hdl;
186 };
187 
188 struct cam_isp_port_hfr_config {
189 	uint32_t                       resource_type;
190 	uint32_t                       subsample_pattern;
191 	uint32_t                       subsample_period;
192 	uint32_t                       framedrop_pattern;
193 	uint32_t                       framedrop_period;
194 	uint32_t                       reserved;
195 } __attribute__((packed));
196 
197 struct cam_isp_resource_hfr_config {
198 	uint32_t                       num_ports;
199 	uint32_t                       reserved;
200 	struct cam_isp_port_hfr_config port_hfr_config[1];
201 } __attribute__((packed));
202 
203 struct cam_isp_dual_split_params {
204 	uint32_t                       split_point;
205 	uint32_t                       right_padding;
206 	uint32_t                       left_padding;
207 	uint32_t                       reserved;
208 };
209 
210 struct cam_isp_dual_stripe_config {
211 	uint32_t                       offset;
212 	uint32_t                       width;
213 	uint32_t                       tileconfig;
214 	uint32_t                       port_id;
215 };
216 
217 struct cam_isp_dual_config {
218 	uint32_t                           num_ports;
219 	uint32_t                           reserved;
220 	struct cam_isp_dual_split_params   split_params;
221 	struct cam_isp_dual_stripe_config  stripes[1];
222 } __attribute__((packed));
223 
224 struct cam_isp_clock_config {
225 	uint32_t                       usage_type;
226 	uint32_t                       num_rdi;
227 	uint64_t                       left_pix_hz;
228 	uint64_t                       right_pix_hz;
229 	uint64_t                       rdi_hz[1];
230 } __attribute__((packed));
231 
232 struct cam_isp_csid_clock_config {
233 	uint64_t                       csid_clock;
234 } __attribute__((packed));
235 
236 
237 struct cam_isp_bw_vote {
238 	uint32_t                       resource_id;
239 	uint32_t                       reserved;
240 	uint64_t                       cam_bw_bps;
241 	uint64_t                       ext_bw_bps;
242 } __attribute__((packed));
243 
244 
245 struct cam_isp_bw_config {
246 	uint32_t                       usage_type;
247 	uint32_t                       num_rdi;
248 	struct cam_isp_bw_vote         left_pix_vote;
249 	struct cam_isp_bw_vote         right_pix_vote;
250 	struct cam_isp_bw_vote         rdi_vote[1];
251 } __attribute__((packed));
252 
253 
254 
255 struct cam_isp_bw_config_ab {
256 	uint32_t    usage_type;
257 	uint32_t    num_rdi;
258 	uint64_t    left_pix_vote_ab;
259 	uint64_t    right_pix_vote_ab;
260 	uint64_t    rdi_vote_ab[1];
261 } __attribute__((packed));
262 
263 struct cam_fe_config {
264 	uint64_t    version;
265 	uint32_t    min_vbi;
266 	uint32_t    fs_mode;
267 	uint32_t    fs_line_sync_en;
268 	uint32_t    hbi_count;
269 	uint32_t    fs_sync_enable;
270 	uint32_t    go_cmd_sel;
271 	uint32_t    client_enable;
272 	uint32_t    source_addr;
273 	uint32_t    width;
274 	uint32_t    height;
275 	uint32_t    stride;
276 	uint32_t    format;
277 	uint32_t    unpacker_cfg;
278 	uint32_t    latency_buf_size;
279 } __attribute__((packed));
280 
281 
282 struct cam_isp_acquire_hw_info {
283 	uint16_t                common_info_version;
284 	uint16_t                common_info_size;
285 	uint32_t                common_info_offset;
286 	uint32_t                num_inputs;
287 	uint32_t                input_info_version;
288 	uint32_t                input_info_size;
289 	uint32_t                input_info_offset;
290 	uint64_t                data;
291 };
292 
293 #define CAM_ISP_ACQUIRE_COMMON_VER0         0x1000
294 
295 #define CAM_ISP_ACQUIRE_COMMON_SIZE_VER0    0x0
296 
297 #define CAM_ISP_ACQUIRE_INPUT_VER0          0x2000
298 
299 #define CAM_ISP_ACQUIRE_INPUT_SIZE_VER0     sizeof(struct cam_isp_in_port_info)
300 
301 #define CAM_ISP_ACQUIRE_OUT_VER0            0x3000
302 
303 #define CAM_ISP_ACQUIRE_OUT_SIZE_VER0       sizeof(struct cam_isp_out_port_info)
304 
305 #endif /* __UAPI_CAM_ISP_H__ */
306