1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Support for Clovertrail PNW Camera Imaging ISP subsystem.
5 * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License version
9 * 2 as published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
19 #ifndef __ATOMISP_COMPAT_H__
20 #define __ATOMISP_COMPAT_H__
22 #include "atomisp_compat_css20.h"
24 #include "../../include/linux/atomisp.h"
25 #include <media/videobuf-vmalloc.h>
27 struct atomisp_device;
28 struct atomisp_sub_device;
30 enum atomisp_input_stream_id;
32 extern void __iomem *atomisp_io_base;
34 struct atomisp_metadata_buf {
35 struct ia_css_metadata *metadata;
37 struct list_head list;
40 void atomisp_css2_hw_store_32(hrt_address addr, uint32_t data);
41 void atomisp_load_uint32(hrt_address addr, uint32_t *data);
43 int atomisp_css_init(struct atomisp_device *isp);
45 void atomisp_css_uninit(struct atomisp_device *isp);
47 void atomisp_css_suspend(struct atomisp_device *isp);
49 int atomisp_css_resume(struct atomisp_device *isp);
51 void atomisp_css_init_struct(struct atomisp_sub_device *asd);
53 int atomisp_css_irq_translate(struct atomisp_device *isp,
56 void atomisp_css_rx_get_irq_info(enum mipi_port_id port,
59 void atomisp_css_rx_clear_irq_info(enum mipi_port_id port,
62 int atomisp_css_irq_enable(struct atomisp_device *isp,
63 enum ia_css_irq_info info, bool enable);
65 int atomisp_q_video_buffer_to_css(struct atomisp_sub_device *asd,
66 struct videobuf_vmalloc_memory *vm_mem,
67 enum atomisp_input_stream_id stream_id,
68 enum ia_css_buffer_type css_buf_type,
69 enum ia_css_pipe_id css_pipe_id);
71 int atomisp_q_s3a_buffer_to_css(struct atomisp_sub_device *asd,
72 struct atomisp_s3a_buf *s3a_buf,
73 enum atomisp_input_stream_id stream_id,
74 enum ia_css_pipe_id css_pipe_id);
76 int atomisp_q_metadata_buffer_to_css(struct atomisp_sub_device *asd,
77 struct atomisp_metadata_buf *metadata_buf,
78 enum atomisp_input_stream_id stream_id,
79 enum ia_css_pipe_id css_pipe_id);
81 int atomisp_q_dis_buffer_to_css(struct atomisp_sub_device *asd,
82 struct atomisp_dis_buf *dis_buf,
83 enum atomisp_input_stream_id stream_id,
84 enum ia_css_pipe_id css_pipe_id);
86 void ia_css_mmu_invalidate_cache(void);
88 void ia_css_mmu_invalidate_cache(void);
90 int atomisp_css_start(struct atomisp_sub_device *asd,
91 enum ia_css_pipe_id pipe_id, bool in_reset);
93 void atomisp_css_update_isp_params(struct atomisp_sub_device *asd);
94 void atomisp_css_update_isp_params_on_pipe(struct atomisp_sub_device *asd,
95 struct ia_css_pipe *pipe);
97 int atomisp_css_queue_buffer(struct atomisp_sub_device *asd,
98 enum atomisp_input_stream_id stream_id,
99 enum ia_css_pipe_id pipe_id,
100 enum ia_css_buffer_type buf_type,
101 struct atomisp_css_buffer *isp_css_buffer);
103 int atomisp_css_dequeue_buffer(struct atomisp_sub_device *asd,
104 enum atomisp_input_stream_id stream_id,
105 enum ia_css_pipe_id pipe_id,
106 enum ia_css_buffer_type buf_type,
107 struct atomisp_css_buffer *isp_css_buffer);
109 int atomisp_css_allocate_stat_buffers(struct atomisp_sub_device *asd,
111 struct atomisp_s3a_buf *s3a_buf,
112 struct atomisp_dis_buf *dis_buf,
113 struct atomisp_metadata_buf *md_buf);
115 void atomisp_css_free_stat_buffers(struct atomisp_sub_device *asd);
117 void atomisp_css_free_3a_buffer(struct atomisp_s3a_buf *s3a_buf);
119 void atomisp_css_free_dis_buffer(struct atomisp_dis_buf *dis_buf);
121 void atomisp_css_free_metadata_buffer(struct atomisp_metadata_buf
124 int atomisp_css_get_grid_info(struct atomisp_sub_device *asd,
125 enum ia_css_pipe_id pipe_id,
128 int atomisp_alloc_3a_output_buf(struct atomisp_sub_device *asd);
130 int atomisp_alloc_dis_coef_buf(struct atomisp_sub_device *asd);
132 int atomisp_alloc_metadata_output_buf(struct atomisp_sub_device *asd);
134 void atomisp_free_metadata_output_buf(struct atomisp_sub_device *asd);
136 void atomisp_css_get_dis_statistics(struct atomisp_sub_device *asd,
137 struct atomisp_css_buffer *isp_css_buffer,
138 struct ia_css_isp_dvs_statistics_map *dvs_map);
140 int atomisp_css_dequeue_event(struct atomisp_css_event *current_event);
142 void atomisp_css_temp_pipe_to_pipe_id(struct atomisp_sub_device *asd,
143 struct atomisp_css_event *current_event);
145 int atomisp_css_isys_set_resolution(struct atomisp_sub_device *asd,
146 enum atomisp_input_stream_id stream_id,
147 struct v4l2_mbus_framefmt *ffmt,
150 void atomisp_css_isys_set_link(struct atomisp_sub_device *asd,
151 enum atomisp_input_stream_id stream_id,
155 void atomisp_css_isys_set_valid(struct atomisp_sub_device *asd,
156 enum atomisp_input_stream_id stream_id,
160 void atomisp_css_isys_set_format(struct atomisp_sub_device *asd,
161 enum atomisp_input_stream_id stream_id,
162 enum atomisp_input_format format,
165 int atomisp_css_set_default_isys_config(struct atomisp_sub_device *asd,
166 enum atomisp_input_stream_id stream_id,
167 struct v4l2_mbus_framefmt *ffmt);
169 int atomisp_css_isys_two_stream_cfg(struct atomisp_sub_device *asd,
170 enum atomisp_input_stream_id stream_id,
171 enum atomisp_input_format input_format);
173 void atomisp_css_isys_two_stream_cfg_update_stream1(
174 struct atomisp_sub_device *asd,
175 enum atomisp_input_stream_id stream_id,
176 enum atomisp_input_format input_format,
177 unsigned int width, unsigned int height);
179 void atomisp_css_isys_two_stream_cfg_update_stream2(
180 struct atomisp_sub_device *asd,
181 enum atomisp_input_stream_id stream_id,
182 enum atomisp_input_format input_format,
183 unsigned int width, unsigned int height);
185 int atomisp_css_input_set_resolution(struct atomisp_sub_device *asd,
186 enum atomisp_input_stream_id stream_id,
187 struct v4l2_mbus_framefmt *ffmt);
189 void atomisp_css_input_set_binning_factor(struct atomisp_sub_device *asd,
190 enum atomisp_input_stream_id stream_id,
191 unsigned int bin_factor);
193 void atomisp_css_input_set_bayer_order(struct atomisp_sub_device *asd,
194 enum atomisp_input_stream_id stream_id,
195 enum ia_css_bayer_order bayer_order);
197 void atomisp_css_input_set_format(struct atomisp_sub_device *asd,
198 enum atomisp_input_stream_id stream_id,
199 enum atomisp_input_format format);
201 int atomisp_css_input_set_effective_resolution(
202 struct atomisp_sub_device *asd,
203 enum atomisp_input_stream_id stream_id,
205 unsigned int height);
207 void atomisp_css_video_set_dis_envelope(struct atomisp_sub_device *asd,
208 unsigned int dvs_w, unsigned int dvs_h);
210 void atomisp_css_input_set_two_pixels_per_clock(
211 struct atomisp_sub_device *asd,
214 void atomisp_css_enable_raw_binning(struct atomisp_sub_device *asd,
217 void atomisp_css_enable_dz(struct atomisp_sub_device *asd, bool enable);
219 void atomisp_css_capture_set_mode(struct atomisp_sub_device *asd,
220 enum ia_css_capture_mode mode);
222 void atomisp_css_input_set_mode(struct atomisp_sub_device *asd,
223 enum ia_css_input_mode mode);
225 void atomisp_css_capture_enable_online(struct atomisp_sub_device *asd,
226 unsigned short stream_index, bool enable);
228 void atomisp_css_preview_enable_online(struct atomisp_sub_device *asd,
229 unsigned short stream_index, bool enable);
231 void atomisp_css_video_enable_online(struct atomisp_sub_device *asd,
234 void atomisp_css_enable_continuous(struct atomisp_sub_device *asd,
237 void atomisp_css_enable_cvf(struct atomisp_sub_device *asd,
240 int atomisp_css_input_configure_port(struct atomisp_sub_device *asd,
241 enum mipi_port_id port,
242 unsigned int num_lanes,
243 unsigned int timeout,
244 unsigned int mipi_freq,
245 enum atomisp_input_format metadata_format,
246 unsigned int metadata_width,
247 unsigned int metadata_height);
249 void atomisp_create_pipes_stream(struct atomisp_sub_device *asd);
250 void atomisp_destroy_pipes_stream_force(struct atomisp_sub_device *asd);
252 int atomisp_css_stop(struct atomisp_sub_device *asd,
253 enum ia_css_pipe_id pipe_id, bool in_reset);
255 int atomisp_css_continuous_set_num_raw_frames(
256 struct atomisp_sub_device *asd,
259 int atomisp_css_copy_configure_output(struct atomisp_sub_device *asd,
260 unsigned int stream_index,
261 unsigned int width, unsigned int height,
262 unsigned int padded_width,
263 enum ia_css_frame_format format);
265 int atomisp_css_yuvpp_configure_output(struct atomisp_sub_device *asd,
266 unsigned int stream_index,
267 unsigned int width, unsigned int height,
268 unsigned int padded_width,
269 enum ia_css_frame_format format);
271 int atomisp_css_yuvpp_configure_viewfinder(
272 struct atomisp_sub_device *asd,
273 unsigned int stream_index,
274 unsigned int width, unsigned int height,
275 unsigned int min_width,
276 enum ia_css_frame_format format);
278 int atomisp_css_yuvpp_get_output_frame_info(
279 struct atomisp_sub_device *asd,
280 unsigned int stream_index,
281 struct ia_css_frame_info *info);
283 int atomisp_css_yuvpp_get_viewfinder_frame_info(
284 struct atomisp_sub_device *asd,
285 unsigned int stream_index,
286 struct ia_css_frame_info *info);
288 int atomisp_css_preview_configure_output(struct atomisp_sub_device *asd,
289 unsigned int width, unsigned int height,
290 unsigned int min_width,
291 enum ia_css_frame_format format);
293 int atomisp_css_capture_configure_output(struct atomisp_sub_device *asd,
294 unsigned int width, unsigned int height,
295 unsigned int min_width,
296 enum ia_css_frame_format format);
298 int atomisp_css_video_configure_output(struct atomisp_sub_device *asd,
299 unsigned int width, unsigned int height,
300 unsigned int min_width,
301 enum ia_css_frame_format format);
303 int atomisp_get_css_frame_info(struct atomisp_sub_device *asd,
305 struct ia_css_frame_info *frame_info);
307 int atomisp_css_video_configure_viewfinder(struct atomisp_sub_device *asd,
308 unsigned int width, unsigned int height,
309 unsigned int min_width,
310 enum ia_css_frame_format format);
312 int atomisp_css_capture_configure_viewfinder(
313 struct atomisp_sub_device *asd,
314 unsigned int width, unsigned int height,
315 unsigned int min_width,
316 enum ia_css_frame_format format);
318 int atomisp_css_video_get_viewfinder_frame_info(
319 struct atomisp_sub_device *asd,
320 struct ia_css_frame_info *info);
322 int atomisp_css_capture_get_viewfinder_frame_info(
323 struct atomisp_sub_device *asd,
324 struct ia_css_frame_info *info);
326 int atomisp_css_copy_get_output_frame_info(
327 struct atomisp_sub_device *asd,
328 unsigned int stream_index,
329 struct ia_css_frame_info *info);
331 int atomisp_css_capture_get_output_raw_frame_info(
332 struct atomisp_sub_device *asd,
333 struct ia_css_frame_info *info);
335 int atomisp_css_preview_get_output_frame_info(
336 struct atomisp_sub_device *asd,
337 struct ia_css_frame_info *info);
339 int atomisp_css_capture_get_output_frame_info(
340 struct atomisp_sub_device *asd,
341 struct ia_css_frame_info *info);
343 int atomisp_css_video_get_output_frame_info(
344 struct atomisp_sub_device *asd,
345 struct ia_css_frame_info *info);
347 int atomisp_css_preview_configure_pp_input(
348 struct atomisp_sub_device *asd,
349 unsigned int width, unsigned int height);
351 int atomisp_css_capture_configure_pp_input(
352 struct atomisp_sub_device *asd,
353 unsigned int width, unsigned int height);
355 int atomisp_css_video_configure_pp_input(
356 struct atomisp_sub_device *asd,
357 unsigned int width, unsigned int height);
359 int atomisp_css_offline_capture_configure(struct atomisp_sub_device *asd,
360 int num_captures, unsigned int skip, int offset);
361 int atomisp_css_exp_id_capture(struct atomisp_sub_device *asd, int exp_id);
362 int atomisp_css_exp_id_unlock(struct atomisp_sub_device *asd, int exp_id);
364 int atomisp_css_capture_enable_xnr(struct atomisp_sub_device *asd,
367 void atomisp_css_set_ctc_table(struct atomisp_sub_device *asd,
368 struct ia_css_ctc_table *ctc_table);
370 void atomisp_css_video_set_dis_vector(struct atomisp_sub_device *asd,
371 struct atomisp_dis_vector *vector);
373 void atomisp_css_set_dvs2_coefs(struct atomisp_sub_device *asd,
374 struct ia_css_dvs2_coefficients *coefs);
376 int atomisp_css_set_dis_coefs(struct atomisp_sub_device *asd,
377 struct atomisp_dis_coefficients *coefs);
379 void atomisp_css_set_zoom_factor(struct atomisp_sub_device *asd,
382 int atomisp_css_get_wb_config(struct atomisp_sub_device *asd,
383 struct atomisp_wb_config *config);
385 int atomisp_css_get_ob_config(struct atomisp_sub_device *asd,
386 struct atomisp_ob_config *config);
388 int atomisp_css_get_dp_config(struct atomisp_sub_device *asd,
389 struct atomisp_dp_config *config);
391 int atomisp_css_get_de_config(struct atomisp_sub_device *asd,
392 struct atomisp_de_config *config);
394 int atomisp_css_get_nr_config(struct atomisp_sub_device *asd,
395 struct atomisp_nr_config *config);
397 int atomisp_css_get_ee_config(struct atomisp_sub_device *asd,
398 struct atomisp_ee_config *config);
400 int atomisp_css_get_tnr_config(struct atomisp_sub_device *asd,
401 struct atomisp_tnr_config *config);
403 int atomisp_css_get_ctc_table(struct atomisp_sub_device *asd,
404 struct atomisp_ctc_table *config);
406 int atomisp_css_get_gamma_table(struct atomisp_sub_device *asd,
407 struct atomisp_gamma_table *config);
409 int atomisp_css_get_gc_config(struct atomisp_sub_device *asd,
410 struct atomisp_gc_config *config);
412 int atomisp_css_get_3a_config(struct atomisp_sub_device *asd,
413 struct atomisp_3a_config *config);
415 int atomisp_css_get_formats_config(struct atomisp_sub_device *asd,
416 struct atomisp_formats_config *formats_config);
418 void atomisp_css_set_formats_config(struct atomisp_sub_device *asd,
419 struct ia_css_formats_config *formats_config);
421 int atomisp_css_get_zoom_factor(struct atomisp_sub_device *asd,
424 struct ia_css_shading_table *atomisp_css_shading_table_alloc(
425 unsigned int width, unsigned int height);
427 void atomisp_css_set_shading_table(struct atomisp_sub_device *asd,
428 struct ia_css_shading_table *table);
430 void atomisp_css_shading_table_free(struct ia_css_shading_table *table);
432 struct ia_css_morph_table *atomisp_css_morph_table_allocate(
433 unsigned int width, unsigned int height);
435 void atomisp_css_set_morph_table(struct atomisp_sub_device *asd,
436 struct ia_css_morph_table *table);
438 void atomisp_css_get_morph_table(struct atomisp_sub_device *asd,
439 struct ia_css_morph_table *table);
441 void atomisp_css_morph_table_free(struct ia_css_morph_table *table);
443 void atomisp_css_set_cont_prev_start_time(struct atomisp_device *isp,
444 unsigned int overlap);
446 int atomisp_css_get_dis_stat(struct atomisp_sub_device *asd,
447 struct atomisp_dis_statistics *stats);
449 int atomisp_css_update_stream(struct atomisp_sub_device *asd);
451 int atomisp_css_create_acc_pipe(struct atomisp_sub_device *asd);
453 int atomisp_css_start_acc_pipe(struct atomisp_sub_device *asd);
455 int atomisp_css_stop_acc_pipe(struct atomisp_sub_device *asd);
457 void atomisp_css_destroy_acc_pipe(struct atomisp_sub_device *asd);
459 int atomisp_css_load_acc_extension(struct atomisp_sub_device *asd,
460 struct ia_css_fw_info *fw,
461 enum ia_css_pipe_id pipe_id,
464 void atomisp_css_unload_acc_extension(struct atomisp_sub_device *asd,
465 struct ia_css_fw_info *fw,
466 enum ia_css_pipe_id pipe_id);
468 int atomisp_css_wait_acc_finish(struct atomisp_sub_device *asd);
470 void atomisp_css_acc_done(struct atomisp_sub_device *asd);
472 int atomisp_css_load_acc_binary(struct atomisp_sub_device *asd,
473 struct ia_css_fw_info *fw,
476 void atomisp_css_unload_acc_binary(struct atomisp_sub_device *asd);
478 struct atomisp_acc_fw;
479 int atomisp_css_set_acc_parameters(struct atomisp_acc_fw *acc_fw);
481 int atomisp_css_isr_thread(struct atomisp_device *isp,
482 bool *frame_done_found,
483 bool *css_pipe_done);
485 bool atomisp_css_valid_sof(struct atomisp_device *isp);
487 void atomisp_en_dz_capt_pipe(struct atomisp_sub_device *asd, bool enable);