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