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 struct atomisp_metadata_buf {
33 struct ia_css_metadata *metadata;
35 struct list_head list;
38 void atomisp_css2_hw_store_32(hrt_address addr, uint32_t data);
39 void atomisp_load_uint32(hrt_address addr, uint32_t *data);
41 int atomisp_css_init(struct atomisp_device *isp);
43 void atomisp_css_uninit(struct atomisp_device *isp);
45 void atomisp_css_suspend(struct atomisp_device *isp);
47 int atomisp_css_resume(struct atomisp_device *isp);
49 void atomisp_css_init_struct(struct atomisp_sub_device *asd);
51 int atomisp_css_irq_translate(struct atomisp_device *isp,
54 void atomisp_css_rx_get_irq_info(enum mipi_port_id port,
57 void atomisp_css_rx_clear_irq_info(enum mipi_port_id port,
60 int atomisp_css_irq_enable(struct atomisp_device *isp,
61 enum ia_css_irq_info info, bool enable);
63 int atomisp_q_video_buffer_to_css(struct atomisp_sub_device *asd,
64 struct videobuf_vmalloc_memory *vm_mem,
65 enum atomisp_input_stream_id stream_id,
66 enum ia_css_buffer_type css_buf_type,
67 enum ia_css_pipe_id css_pipe_id);
69 int atomisp_q_s3a_buffer_to_css(struct atomisp_sub_device *asd,
70 struct atomisp_s3a_buf *s3a_buf,
71 enum atomisp_input_stream_id stream_id,
72 enum ia_css_pipe_id css_pipe_id);
74 int atomisp_q_metadata_buffer_to_css(struct atomisp_sub_device *asd,
75 struct atomisp_metadata_buf *metadata_buf,
76 enum atomisp_input_stream_id stream_id,
77 enum ia_css_pipe_id css_pipe_id);
79 int atomisp_q_dis_buffer_to_css(struct atomisp_sub_device *asd,
80 struct atomisp_dis_buf *dis_buf,
81 enum atomisp_input_stream_id stream_id,
82 enum ia_css_pipe_id css_pipe_id);
84 void ia_css_mmu_invalidate_cache(void);
86 int atomisp_css_start(struct atomisp_sub_device *asd,
87 enum ia_css_pipe_id pipe_id, bool in_reset);
89 void atomisp_css_update_isp_params(struct atomisp_sub_device *asd);
90 void atomisp_css_update_isp_params_on_pipe(struct atomisp_sub_device *asd,
91 struct ia_css_pipe *pipe);
93 int atomisp_css_queue_buffer(struct atomisp_sub_device *asd,
94 enum atomisp_input_stream_id stream_id,
95 enum ia_css_pipe_id pipe_id,
96 enum ia_css_buffer_type buf_type,
97 struct atomisp_css_buffer *isp_css_buffer);
99 int atomisp_css_dequeue_buffer(struct atomisp_sub_device *asd,
100 enum atomisp_input_stream_id stream_id,
101 enum ia_css_pipe_id pipe_id,
102 enum ia_css_buffer_type buf_type,
103 struct atomisp_css_buffer *isp_css_buffer);
105 int atomisp_css_allocate_stat_buffers(struct atomisp_sub_device *asd,
107 struct atomisp_s3a_buf *s3a_buf,
108 struct atomisp_dis_buf *dis_buf,
109 struct atomisp_metadata_buf *md_buf);
111 void atomisp_css_free_stat_buffers(struct atomisp_sub_device *asd);
113 void atomisp_css_free_3a_buffer(struct atomisp_s3a_buf *s3a_buf);
115 void atomisp_css_free_dis_buffer(struct atomisp_dis_buf *dis_buf);
117 void atomisp_css_free_metadata_buffer(struct atomisp_metadata_buf
120 int atomisp_css_get_grid_info(struct atomisp_sub_device *asd,
121 enum ia_css_pipe_id pipe_id,
124 int atomisp_alloc_3a_output_buf(struct atomisp_sub_device *asd);
126 int atomisp_alloc_dis_coef_buf(struct atomisp_sub_device *asd);
128 int atomisp_alloc_metadata_output_buf(struct atomisp_sub_device *asd);
130 void atomisp_free_metadata_output_buf(struct atomisp_sub_device *asd);
132 void atomisp_css_get_dis_statistics(struct atomisp_sub_device *asd,
133 struct atomisp_css_buffer *isp_css_buffer,
134 struct ia_css_isp_dvs_statistics_map *dvs_map);
136 void atomisp_css_temp_pipe_to_pipe_id(struct atomisp_sub_device *asd,
137 struct atomisp_css_event *current_event);
139 int atomisp_css_isys_set_resolution(struct atomisp_sub_device *asd,
140 enum atomisp_input_stream_id stream_id,
141 struct v4l2_mbus_framefmt *ffmt,
144 void atomisp_css_isys_set_link(struct atomisp_sub_device *asd,
145 enum atomisp_input_stream_id stream_id,
149 void atomisp_css_isys_set_valid(struct atomisp_sub_device *asd,
150 enum atomisp_input_stream_id stream_id,
154 void atomisp_css_isys_set_format(struct atomisp_sub_device *asd,
155 enum atomisp_input_stream_id stream_id,
156 enum atomisp_input_format format,
159 int atomisp_css_set_default_isys_config(struct atomisp_sub_device *asd,
160 enum atomisp_input_stream_id stream_id,
161 struct v4l2_mbus_framefmt *ffmt);
163 int atomisp_css_isys_two_stream_cfg(struct atomisp_sub_device *asd,
164 enum atomisp_input_stream_id stream_id,
165 enum atomisp_input_format input_format);
167 void atomisp_css_isys_two_stream_cfg_update_stream1(
168 struct atomisp_sub_device *asd,
169 enum atomisp_input_stream_id stream_id,
170 enum atomisp_input_format input_format,
171 unsigned int width, unsigned int height);
173 void atomisp_css_isys_two_stream_cfg_update_stream2(
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 int atomisp_css_input_set_resolution(struct atomisp_sub_device *asd,
180 enum atomisp_input_stream_id stream_id,
181 struct v4l2_mbus_framefmt *ffmt);
183 void atomisp_css_input_set_binning_factor(struct atomisp_sub_device *asd,
184 enum atomisp_input_stream_id stream_id,
185 unsigned int bin_factor);
187 void atomisp_css_input_set_bayer_order(struct atomisp_sub_device *asd,
188 enum atomisp_input_stream_id stream_id,
189 enum ia_css_bayer_order bayer_order);
191 void atomisp_css_input_set_format(struct atomisp_sub_device *asd,
192 enum atomisp_input_stream_id stream_id,
193 enum atomisp_input_format format);
195 int atomisp_css_input_set_effective_resolution(
196 struct atomisp_sub_device *asd,
197 enum atomisp_input_stream_id stream_id,
199 unsigned int height);
201 void atomisp_css_video_set_dis_envelope(struct atomisp_sub_device *asd,
202 unsigned int dvs_w, unsigned int dvs_h);
204 void atomisp_css_input_set_two_pixels_per_clock(
205 struct atomisp_sub_device *asd,
208 void atomisp_css_enable_raw_binning(struct atomisp_sub_device *asd,
211 void atomisp_css_enable_dz(struct atomisp_sub_device *asd, bool enable);
213 void atomisp_css_capture_set_mode(struct atomisp_sub_device *asd,
214 enum ia_css_capture_mode mode);
216 void atomisp_css_input_set_mode(struct atomisp_sub_device *asd,
217 enum ia_css_input_mode mode);
219 void atomisp_css_capture_enable_online(struct atomisp_sub_device *asd,
220 unsigned short stream_index, bool enable);
222 void atomisp_css_preview_enable_online(struct atomisp_sub_device *asd,
223 unsigned short stream_index, bool enable);
225 void atomisp_css_video_enable_online(struct atomisp_sub_device *asd,
228 void atomisp_css_enable_continuous(struct atomisp_sub_device *asd,
231 void atomisp_css_enable_cvf(struct atomisp_sub_device *asd,
234 int atomisp_css_input_configure_port(struct atomisp_sub_device *asd,
235 enum mipi_port_id port,
236 unsigned int num_lanes,
237 unsigned int timeout,
238 unsigned int mipi_freq,
239 enum atomisp_input_format metadata_format,
240 unsigned int metadata_width,
241 unsigned int metadata_height);
243 void atomisp_create_pipes_stream(struct atomisp_sub_device *asd);
244 void atomisp_destroy_pipes_stream_force(struct atomisp_sub_device *asd);
246 void atomisp_css_stop(struct atomisp_sub_device *asd,
247 enum ia_css_pipe_id pipe_id, bool in_reset);
249 void atomisp_css_continuous_set_num_raw_frames(
250 struct atomisp_sub_device *asd,
253 int atomisp_css_copy_configure_output(struct atomisp_sub_device *asd,
254 unsigned int stream_index,
255 unsigned int width, unsigned int height,
256 unsigned int padded_width,
257 enum ia_css_frame_format format);
259 int atomisp_css_yuvpp_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_viewfinder(
266 struct atomisp_sub_device *asd,
267 unsigned int stream_index,
268 unsigned int width, unsigned int height,
269 unsigned int min_width,
270 enum ia_css_frame_format format);
272 int atomisp_css_yuvpp_get_output_frame_info(
273 struct atomisp_sub_device *asd,
274 unsigned int stream_index,
275 struct ia_css_frame_info *info);
277 int atomisp_css_yuvpp_get_viewfinder_frame_info(
278 struct atomisp_sub_device *asd,
279 unsigned int stream_index,
280 struct ia_css_frame_info *info);
282 int atomisp_css_preview_configure_output(struct atomisp_sub_device *asd,
283 unsigned int width, unsigned int height,
284 unsigned int min_width,
285 enum ia_css_frame_format format);
287 int atomisp_css_capture_configure_output(struct atomisp_sub_device *asd,
288 unsigned int width, unsigned int height,
289 unsigned int min_width,
290 enum ia_css_frame_format format);
292 int atomisp_css_video_configure_output(struct atomisp_sub_device *asd,
293 unsigned int width, unsigned int height,
294 unsigned int min_width,
295 enum ia_css_frame_format format);
297 int atomisp_get_css_frame_info(struct atomisp_sub_device *asd,
299 struct ia_css_frame_info *frame_info);
301 int atomisp_css_video_configure_viewfinder(struct atomisp_sub_device *asd,
302 unsigned int width, unsigned int height,
303 unsigned int min_width,
304 enum ia_css_frame_format format);
306 int atomisp_css_capture_configure_viewfinder(
307 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_video_get_viewfinder_frame_info(
313 struct atomisp_sub_device *asd,
314 struct ia_css_frame_info *info);
316 int atomisp_css_capture_get_viewfinder_frame_info(
317 struct atomisp_sub_device *asd,
318 struct ia_css_frame_info *info);
320 int atomisp_css_copy_get_output_frame_info(
321 struct atomisp_sub_device *asd,
322 unsigned int stream_index,
323 struct ia_css_frame_info *info);
325 int atomisp_css_capture_get_output_raw_frame_info(
326 struct atomisp_sub_device *asd,
327 struct ia_css_frame_info *info);
329 int atomisp_css_preview_get_output_frame_info(
330 struct atomisp_sub_device *asd,
331 struct ia_css_frame_info *info);
333 int atomisp_css_capture_get_output_frame_info(
334 struct atomisp_sub_device *asd,
335 struct ia_css_frame_info *info);
337 int atomisp_css_video_get_output_frame_info(
338 struct atomisp_sub_device *asd,
339 struct ia_css_frame_info *info);
341 int atomisp_css_preview_configure_pp_input(
342 struct atomisp_sub_device *asd,
343 unsigned int width, unsigned int height);
345 int atomisp_css_capture_configure_pp_input(
346 struct atomisp_sub_device *asd,
347 unsigned int width, unsigned int height);
349 int atomisp_css_video_configure_pp_input(
350 struct atomisp_sub_device *asd,
351 unsigned int width, unsigned int height);
353 int atomisp_css_offline_capture_configure(struct atomisp_sub_device *asd,
354 int num_captures, unsigned int skip, int offset);
355 int atomisp_css_exp_id_capture(struct atomisp_sub_device *asd, int exp_id);
356 int atomisp_css_exp_id_unlock(struct atomisp_sub_device *asd, int exp_id);
358 int atomisp_css_capture_enable_xnr(struct atomisp_sub_device *asd,
361 void atomisp_css_set_ctc_table(struct atomisp_sub_device *asd,
362 struct ia_css_ctc_table *ctc_table);
364 void atomisp_css_video_set_dis_vector(struct atomisp_sub_device *asd,
365 struct atomisp_dis_vector *vector);
367 void atomisp_css_set_dvs2_coefs(struct atomisp_sub_device *asd,
368 struct ia_css_dvs2_coefficients *coefs);
370 int atomisp_css_set_dis_coefs(struct atomisp_sub_device *asd,
371 struct atomisp_dis_coefficients *coefs);
373 void atomisp_css_set_zoom_factor(struct atomisp_sub_device *asd,
376 int atomisp_css_get_wb_config(struct atomisp_sub_device *asd,
377 struct atomisp_wb_config *config);
379 int atomisp_css_get_ob_config(struct atomisp_sub_device *asd,
380 struct atomisp_ob_config *config);
382 int atomisp_css_get_dp_config(struct atomisp_sub_device *asd,
383 struct atomisp_dp_config *config);
385 int atomisp_css_get_de_config(struct atomisp_sub_device *asd,
386 struct atomisp_de_config *config);
388 int atomisp_css_get_nr_config(struct atomisp_sub_device *asd,
389 struct atomisp_nr_config *config);
391 int atomisp_css_get_ee_config(struct atomisp_sub_device *asd,
392 struct atomisp_ee_config *config);
394 int atomisp_css_get_tnr_config(struct atomisp_sub_device *asd,
395 struct atomisp_tnr_config *config);
397 int atomisp_css_get_ctc_table(struct atomisp_sub_device *asd,
398 struct atomisp_ctc_table *config);
400 int atomisp_css_get_gamma_table(struct atomisp_sub_device *asd,
401 struct atomisp_gamma_table *config);
403 int atomisp_css_get_gc_config(struct atomisp_sub_device *asd,
404 struct atomisp_gc_config *config);
406 int atomisp_css_get_3a_config(struct atomisp_sub_device *asd,
407 struct atomisp_3a_config *config);
409 int atomisp_css_get_formats_config(struct atomisp_sub_device *asd,
410 struct atomisp_formats_config *formats_config);
412 void atomisp_css_set_formats_config(struct atomisp_sub_device *asd,
413 struct ia_css_formats_config *formats_config);
415 int atomisp_css_get_zoom_factor(struct atomisp_sub_device *asd,
418 struct ia_css_shading_table *atomisp_css_shading_table_alloc(
419 unsigned int width, unsigned int height);
421 void atomisp_css_set_shading_table(struct atomisp_sub_device *asd,
422 struct ia_css_shading_table *table);
424 void atomisp_css_shading_table_free(struct ia_css_shading_table *table);
426 struct ia_css_morph_table *atomisp_css_morph_table_allocate(
427 unsigned int width, unsigned int height);
429 void atomisp_css_set_morph_table(struct atomisp_sub_device *asd,
430 struct ia_css_morph_table *table);
432 void atomisp_css_get_morph_table(struct atomisp_sub_device *asd,
433 struct ia_css_morph_table *table);
435 void atomisp_css_morph_table_free(struct ia_css_morph_table *table);
437 void atomisp_css_set_cont_prev_start_time(struct atomisp_device *isp,
438 unsigned int overlap);
440 int atomisp_css_get_dis_stat(struct atomisp_sub_device *asd,
441 struct atomisp_dis_statistics *stats);
443 int atomisp_css_update_stream(struct atomisp_sub_device *asd);
445 int atomisp_css_create_acc_pipe(struct atomisp_sub_device *asd);
447 int atomisp_css_start_acc_pipe(struct atomisp_sub_device *asd);
449 int atomisp_css_stop_acc_pipe(struct atomisp_sub_device *asd);
451 void atomisp_css_destroy_acc_pipe(struct atomisp_sub_device *asd);
453 int atomisp_css_load_acc_extension(struct atomisp_sub_device *asd,
454 struct ia_css_fw_info *fw,
455 enum ia_css_pipe_id pipe_id,
458 void atomisp_css_unload_acc_extension(struct atomisp_sub_device *asd,
459 struct ia_css_fw_info *fw,
460 enum ia_css_pipe_id pipe_id);
462 int atomisp_css_wait_acc_finish(struct atomisp_sub_device *asd);
464 void atomisp_css_acc_done(struct atomisp_sub_device *asd);
466 int atomisp_css_load_acc_binary(struct atomisp_sub_device *asd,
467 struct ia_css_fw_info *fw,
470 void atomisp_css_unload_acc_binary(struct atomisp_sub_device *asd);
472 struct atomisp_acc_fw;
473 int atomisp_css_set_acc_parameters(struct atomisp_acc_fw *acc_fw);
475 int atomisp_css_isr_thread(struct atomisp_device *isp,
476 bool *frame_done_found,
477 bool *css_pipe_done);
479 bool atomisp_css_valid_sof(struct atomisp_device *isp);
481 void atomisp_en_dz_capt_pipe(struct atomisp_sub_device *asd, bool enable);