1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Support for Clovertrail PNW Camera Imaging ISP subsystem. 4 * 5 * Copyright (c) 2012 Intel Corporation. All Rights Reserved. 6 * 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. 10 * 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. 15 * 16 * 17 */ 18 19 #ifndef __ATOMISP_COMPAT_H__ 20 #define __ATOMISP_COMPAT_H__ 21 22 #include "atomisp_compat_css20.h" 23 24 #include "../../include/linux/atomisp.h" 25 26 struct atomisp_device; 27 struct atomisp_sub_device; 28 struct video_device; 29 enum atomisp_input_stream_id; 30 31 struct atomisp_metadata_buf { 32 struct ia_css_metadata *metadata; 33 void *md_vptr; 34 struct list_head list; 35 }; 36 37 void atomisp_css2_hw_store_32(hrt_address addr, uint32_t data); 38 void atomisp_load_uint32(hrt_address addr, uint32_t *data); 39 40 int atomisp_css_init(struct atomisp_device *isp); 41 42 void atomisp_css_uninit(struct atomisp_device *isp); 43 44 void atomisp_css_init_struct(struct atomisp_sub_device *asd); 45 46 int atomisp_css_irq_translate(struct atomisp_device *isp, 47 unsigned int *infos); 48 49 void atomisp_css_rx_get_irq_info(enum mipi_port_id port, 50 unsigned int *infos); 51 52 void atomisp_css_rx_clear_irq_info(enum mipi_port_id port, 53 unsigned int infos); 54 55 int atomisp_css_irq_enable(struct atomisp_device *isp, 56 enum ia_css_irq_info info, bool enable); 57 58 int atomisp_q_video_buffer_to_css(struct atomisp_sub_device *asd, 59 struct ia_css_frame *frame, 60 enum atomisp_input_stream_id stream_id, 61 enum ia_css_buffer_type css_buf_type, 62 enum ia_css_pipe_id css_pipe_id); 63 64 int atomisp_q_s3a_buffer_to_css(struct atomisp_sub_device *asd, 65 struct atomisp_s3a_buf *s3a_buf, 66 enum atomisp_input_stream_id stream_id, 67 enum ia_css_pipe_id css_pipe_id); 68 69 int atomisp_q_metadata_buffer_to_css(struct atomisp_sub_device *asd, 70 struct atomisp_metadata_buf *metadata_buf, 71 enum atomisp_input_stream_id stream_id, 72 enum ia_css_pipe_id css_pipe_id); 73 74 int atomisp_q_dis_buffer_to_css(struct atomisp_sub_device *asd, 75 struct atomisp_dis_buf *dis_buf, 76 enum atomisp_input_stream_id stream_id, 77 enum ia_css_pipe_id css_pipe_id); 78 79 void ia_css_mmu_invalidate_cache(void); 80 81 int atomisp_css_start(struct atomisp_sub_device *asd, 82 enum ia_css_pipe_id pipe_id, bool in_reset); 83 84 void atomisp_css_update_isp_params(struct atomisp_sub_device *asd); 85 void atomisp_css_update_isp_params_on_pipe(struct atomisp_sub_device *asd, 86 struct ia_css_pipe *pipe); 87 88 int atomisp_css_queue_buffer(struct atomisp_sub_device *asd, 89 enum atomisp_input_stream_id stream_id, 90 enum ia_css_pipe_id pipe_id, 91 enum ia_css_buffer_type buf_type, 92 struct atomisp_css_buffer *isp_css_buffer); 93 94 int atomisp_css_dequeue_buffer(struct atomisp_sub_device *asd, 95 enum atomisp_input_stream_id stream_id, 96 enum ia_css_pipe_id pipe_id, 97 enum ia_css_buffer_type buf_type, 98 struct atomisp_css_buffer *isp_css_buffer); 99 100 int atomisp_css_allocate_stat_buffers(struct atomisp_sub_device *asd, 101 u16 stream_id, 102 struct atomisp_s3a_buf *s3a_buf, 103 struct atomisp_dis_buf *dis_buf, 104 struct atomisp_metadata_buf *md_buf); 105 106 void atomisp_css_free_stat_buffers(struct atomisp_sub_device *asd); 107 108 void atomisp_css_free_3a_buffer(struct atomisp_s3a_buf *s3a_buf); 109 110 void atomisp_css_free_dis_buffer(struct atomisp_dis_buf *dis_buf); 111 112 void atomisp_css_free_metadata_buffer(struct atomisp_metadata_buf 113 *metadata_buf); 114 115 int atomisp_css_get_grid_info(struct atomisp_sub_device *asd, 116 enum ia_css_pipe_id pipe_id, 117 int source_pad); 118 119 int atomisp_alloc_3a_output_buf(struct atomisp_sub_device *asd); 120 121 int atomisp_alloc_dis_coef_buf(struct atomisp_sub_device *asd); 122 123 int atomisp_alloc_metadata_output_buf(struct atomisp_sub_device *asd); 124 125 void atomisp_free_metadata_output_buf(struct atomisp_sub_device *asd); 126 127 void atomisp_css_temp_pipe_to_pipe_id(struct atomisp_sub_device *asd, 128 struct atomisp_css_event *current_event); 129 130 int atomisp_css_isys_set_resolution(struct atomisp_sub_device *asd, 131 enum atomisp_input_stream_id stream_id, 132 struct v4l2_mbus_framefmt *ffmt, 133 int isys_stream); 134 135 void atomisp_css_isys_set_link(struct atomisp_sub_device *asd, 136 enum atomisp_input_stream_id stream_id, 137 int link, 138 int isys_stream); 139 140 void atomisp_css_isys_set_valid(struct atomisp_sub_device *asd, 141 enum atomisp_input_stream_id stream_id, 142 bool valid, 143 int isys_stream); 144 145 void atomisp_css_isys_set_format(struct atomisp_sub_device *asd, 146 enum atomisp_input_stream_id stream_id, 147 enum atomisp_input_format format, 148 int isys_stream); 149 150 int atomisp_css_set_default_isys_config(struct atomisp_sub_device *asd, 151 enum atomisp_input_stream_id stream_id, 152 struct v4l2_mbus_framefmt *ffmt); 153 154 int atomisp_css_isys_two_stream_cfg(struct atomisp_sub_device *asd, 155 enum atomisp_input_stream_id stream_id, 156 enum atomisp_input_format input_format); 157 158 void atomisp_css_isys_two_stream_cfg_update_stream1( 159 struct atomisp_sub_device *asd, 160 enum atomisp_input_stream_id stream_id, 161 enum atomisp_input_format input_format, 162 unsigned int width, unsigned int height); 163 164 void atomisp_css_isys_two_stream_cfg_update_stream2( 165 struct atomisp_sub_device *asd, 166 enum atomisp_input_stream_id stream_id, 167 enum atomisp_input_format input_format, 168 unsigned int width, unsigned int height); 169 170 int atomisp_css_input_set_resolution(struct atomisp_sub_device *asd, 171 enum atomisp_input_stream_id stream_id, 172 struct v4l2_mbus_framefmt *ffmt); 173 174 void atomisp_css_input_set_binning_factor(struct atomisp_sub_device *asd, 175 enum atomisp_input_stream_id stream_id, 176 unsigned int bin_factor); 177 178 void atomisp_css_input_set_bayer_order(struct atomisp_sub_device *asd, 179 enum atomisp_input_stream_id stream_id, 180 enum ia_css_bayer_order bayer_order); 181 182 void atomisp_css_input_set_format(struct atomisp_sub_device *asd, 183 enum atomisp_input_stream_id stream_id, 184 enum atomisp_input_format format); 185 186 int atomisp_css_input_set_effective_resolution( 187 struct atomisp_sub_device *asd, 188 enum atomisp_input_stream_id stream_id, 189 unsigned int width, 190 unsigned int height); 191 192 void atomisp_css_video_set_dis_envelope(struct atomisp_sub_device *asd, 193 unsigned int dvs_w, unsigned int dvs_h); 194 195 void atomisp_css_input_set_two_pixels_per_clock( 196 struct atomisp_sub_device *asd, 197 bool two_ppc); 198 199 void atomisp_css_enable_raw_binning(struct atomisp_sub_device *asd, 200 bool enable); 201 202 void atomisp_css_enable_dz(struct atomisp_sub_device *asd, bool enable); 203 204 void atomisp_css_capture_set_mode(struct atomisp_sub_device *asd, 205 enum ia_css_capture_mode mode); 206 207 void atomisp_css_input_set_mode(struct atomisp_sub_device *asd, 208 enum ia_css_input_mode mode); 209 210 void atomisp_css_capture_enable_online(struct atomisp_sub_device *asd, 211 unsigned short stream_index, bool enable); 212 213 void atomisp_css_preview_enable_online(struct atomisp_sub_device *asd, 214 unsigned short stream_index, bool enable); 215 216 void atomisp_css_video_enable_online(struct atomisp_sub_device *asd, 217 bool enable); 218 219 void atomisp_css_enable_continuous(struct atomisp_sub_device *asd, 220 bool enable); 221 222 void atomisp_css_enable_cvf(struct atomisp_sub_device *asd, 223 bool enable); 224 225 int atomisp_css_input_configure_port(struct atomisp_sub_device *asd, 226 enum mipi_port_id port, 227 unsigned int num_lanes, 228 unsigned int timeout, 229 unsigned int mipi_freq, 230 enum atomisp_input_format metadata_format, 231 unsigned int metadata_width, 232 unsigned int metadata_height); 233 234 int atomisp_create_pipes_stream(struct atomisp_sub_device *asd); 235 void atomisp_destroy_pipes_stream_force(struct atomisp_sub_device *asd); 236 237 void atomisp_css_stop(struct atomisp_sub_device *asd, 238 enum ia_css_pipe_id pipe_id, bool in_reset); 239 240 void atomisp_css_continuous_set_num_raw_frames( 241 struct atomisp_sub_device *asd, 242 int num_frames); 243 244 int atomisp_css_copy_configure_output(struct atomisp_sub_device *asd, 245 unsigned int stream_index, 246 unsigned int width, unsigned int height, 247 unsigned int padded_width, 248 enum ia_css_frame_format format); 249 250 int atomisp_css_yuvpp_configure_output(struct atomisp_sub_device *asd, 251 unsigned int stream_index, 252 unsigned int width, unsigned int height, 253 unsigned int padded_width, 254 enum ia_css_frame_format format); 255 256 int atomisp_css_yuvpp_get_output_frame_info( 257 struct atomisp_sub_device *asd, 258 unsigned int stream_index, 259 struct ia_css_frame_info *info); 260 261 int atomisp_css_yuvpp_get_viewfinder_frame_info( 262 struct atomisp_sub_device *asd, 263 unsigned int stream_index, 264 struct ia_css_frame_info *info); 265 266 int atomisp_css_preview_configure_output(struct atomisp_sub_device *asd, 267 unsigned int width, unsigned int height, 268 unsigned int min_width, 269 enum ia_css_frame_format format); 270 271 int atomisp_css_capture_configure_output(struct atomisp_sub_device *asd, 272 unsigned int width, unsigned int height, 273 unsigned int min_width, 274 enum ia_css_frame_format format); 275 276 int atomisp_css_video_configure_output(struct atomisp_sub_device *asd, 277 unsigned int width, unsigned int height, 278 unsigned int min_width, 279 enum ia_css_frame_format format); 280 281 int atomisp_get_css_frame_info(struct atomisp_sub_device *asd, 282 u16 source_pad, 283 struct ia_css_frame_info *frame_info); 284 285 int atomisp_css_video_configure_viewfinder(struct atomisp_sub_device *asd, 286 unsigned int width, unsigned int height, 287 unsigned int min_width, 288 enum ia_css_frame_format format); 289 290 int atomisp_css_capture_configure_viewfinder( 291 struct atomisp_sub_device *asd, 292 unsigned int width, unsigned int height, 293 unsigned int min_width, 294 enum ia_css_frame_format format); 295 296 int atomisp_css_video_get_viewfinder_frame_info( 297 struct atomisp_sub_device *asd, 298 struct ia_css_frame_info *info); 299 300 int atomisp_css_capture_get_viewfinder_frame_info( 301 struct atomisp_sub_device *asd, 302 struct ia_css_frame_info *info); 303 304 int atomisp_css_copy_get_output_frame_info( 305 struct atomisp_sub_device *asd, 306 unsigned int stream_index, 307 struct ia_css_frame_info *info); 308 309 int atomisp_css_capture_get_output_raw_frame_info( 310 struct atomisp_sub_device *asd, 311 struct ia_css_frame_info *info); 312 313 int atomisp_css_preview_get_output_frame_info( 314 struct atomisp_sub_device *asd, 315 struct ia_css_frame_info *info); 316 317 int atomisp_css_capture_get_output_frame_info( 318 struct atomisp_sub_device *asd, 319 struct ia_css_frame_info *info); 320 321 int atomisp_css_video_get_output_frame_info( 322 struct atomisp_sub_device *asd, 323 struct ia_css_frame_info *info); 324 325 int atomisp_css_preview_configure_pp_input( 326 struct atomisp_sub_device *asd, 327 unsigned int width, unsigned int height); 328 329 int atomisp_css_capture_configure_pp_input( 330 struct atomisp_sub_device *asd, 331 unsigned int width, unsigned int height); 332 333 int atomisp_css_video_configure_pp_input( 334 struct atomisp_sub_device *asd, 335 unsigned int width, unsigned int height); 336 337 int atomisp_css_offline_capture_configure(struct atomisp_sub_device *asd, 338 int num_captures, unsigned int skip, int offset); 339 int atomisp_css_exp_id_capture(struct atomisp_sub_device *asd, int exp_id); 340 int atomisp_css_exp_id_unlock(struct atomisp_sub_device *asd, int exp_id); 341 342 int atomisp_css_capture_enable_xnr(struct atomisp_sub_device *asd, 343 bool enable); 344 345 void atomisp_css_set_ctc_table(struct atomisp_sub_device *asd, 346 struct ia_css_ctc_table *ctc_table); 347 348 void atomisp_css_video_set_dis_vector(struct atomisp_sub_device *asd, 349 struct atomisp_dis_vector *vector); 350 351 void atomisp_css_set_dvs2_coefs(struct atomisp_sub_device *asd, 352 struct ia_css_dvs2_coefficients *coefs); 353 354 int atomisp_css_set_dis_coefs(struct atomisp_sub_device *asd, 355 struct atomisp_dis_coefficients *coefs); 356 357 void atomisp_css_set_zoom_factor(struct atomisp_sub_device *asd, 358 unsigned int zoom); 359 360 int atomisp_css_get_wb_config(struct atomisp_sub_device *asd, 361 struct atomisp_wb_config *config); 362 363 int atomisp_css_get_ob_config(struct atomisp_sub_device *asd, 364 struct atomisp_ob_config *config); 365 366 int atomisp_css_get_dp_config(struct atomisp_sub_device *asd, 367 struct atomisp_dp_config *config); 368 369 int atomisp_css_get_de_config(struct atomisp_sub_device *asd, 370 struct atomisp_de_config *config); 371 372 int atomisp_css_get_nr_config(struct atomisp_sub_device *asd, 373 struct atomisp_nr_config *config); 374 375 int atomisp_css_get_ee_config(struct atomisp_sub_device *asd, 376 struct atomisp_ee_config *config); 377 378 int atomisp_css_get_tnr_config(struct atomisp_sub_device *asd, 379 struct atomisp_tnr_config *config); 380 381 int atomisp_css_get_ctc_table(struct atomisp_sub_device *asd, 382 struct atomisp_ctc_table *config); 383 384 int atomisp_css_get_gamma_table(struct atomisp_sub_device *asd, 385 struct atomisp_gamma_table *config); 386 387 int atomisp_css_get_gc_config(struct atomisp_sub_device *asd, 388 struct atomisp_gc_config *config); 389 390 int atomisp_css_get_3a_config(struct atomisp_sub_device *asd, 391 struct atomisp_3a_config *config); 392 393 int atomisp_css_get_formats_config(struct atomisp_sub_device *asd, 394 struct atomisp_formats_config *formats_config); 395 396 void atomisp_css_set_formats_config(struct atomisp_sub_device *asd, 397 struct ia_css_formats_config *formats_config); 398 399 int atomisp_css_get_zoom_factor(struct atomisp_sub_device *asd, 400 unsigned int *zoom); 401 402 struct ia_css_shading_table *atomisp_css_shading_table_alloc( 403 unsigned int width, unsigned int height); 404 405 void atomisp_css_set_shading_table(struct atomisp_sub_device *asd, 406 struct ia_css_shading_table *table); 407 408 void atomisp_css_shading_table_free(struct ia_css_shading_table *table); 409 410 struct ia_css_morph_table *atomisp_css_morph_table_allocate( 411 unsigned int width, unsigned int height); 412 413 void atomisp_css_set_morph_table(struct atomisp_sub_device *asd, 414 struct ia_css_morph_table *table); 415 416 void atomisp_css_get_morph_table(struct atomisp_sub_device *asd, 417 struct ia_css_morph_table *table); 418 419 void atomisp_css_morph_table_free(struct ia_css_morph_table *table); 420 421 int atomisp_css_get_dis_stat(struct atomisp_sub_device *asd, 422 struct atomisp_dis_statistics *stats); 423 424 int atomisp_css_update_stream(struct atomisp_sub_device *asd); 425 426 int atomisp_css_isr_thread(struct atomisp_device *isp, 427 bool *frame_done_found, 428 bool *css_pipe_done); 429 430 bool atomisp_css_valid_sof(struct atomisp_device *isp); 431 432 void atomisp_en_dz_capt_pipe(struct atomisp_sub_device *asd, bool enable); 433 434 #endif 435