1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Support for Medifield PNW Camera Imaging ISP subsystem.
5 * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
7 * Copyright (c) 2010 Silicon Hive www.siliconhive.com.
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License version
11 * 2 as published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
21 #ifndef __ATOMISP_CMD_H__
22 #define __ATOMISP_CMD_H__
24 #include "../../include/linux/atomisp.h"
25 #include <linux/interrupt.h>
26 #include <linux/videodev2.h>
28 #include <media/v4l2-subdev.h>
30 #include "atomisp_internal.h"
32 #include "ia_css_types.h"
35 struct atomisp_device;
38 #define MSI_ENABLE_BIT 16
39 #define INTR_DISABLE_BIT 10
40 #define BUS_MASTER_ENABLE 2
41 #define MEMORY_SPACE_ENABLE 1
46 #define RUNMODE_MASK (ATOMISP_RUN_MODE_VIDEO | ATOMISP_RUN_MODE_STILL_CAPTURE \
47 | ATOMISP_RUN_MODE_PREVIEW)
49 /* FIXME: check if can go */
50 extern int atomisp_punit_hpll_freq;
55 void dump_sp_dmem(struct atomisp_device *isp, unsigned int addr,
57 struct camera_mipi_info *atomisp_to_sensor_mipi_info(struct v4l2_subdev *sd);
58 struct atomisp_video_pipe *atomisp_to_video_pipe(struct video_device *dev);
59 struct atomisp_acc_pipe *atomisp_to_acc_pipe(struct video_device *dev);
60 int atomisp_reset(struct atomisp_device *isp);
61 void atomisp_flush_bufs_and_wakeup(struct atomisp_sub_device *asd);
62 void atomisp_clear_css_buffer_counters(struct atomisp_sub_device *asd);
64 bool atomisp_buffers_queued(struct atomisp_sub_device *asd);
66 bool atomisp_buffers_queued_pipe(struct atomisp_video_pipe *pipe);
68 /* TODO:should be here instead of atomisp_helper.h
69 extern void __iomem *atomisp_io_base;
71 static inline void __iomem *atomisp_get_io_virt_addr(unsigned int address)
73 void __iomem *ret = atomisp_io_base + (address & 0x003FFFFF);
81 void atomisp_msi_irq_init(struct atomisp_device *isp, struct pci_dev *dev);
82 void atomisp_msi_irq_uninit(struct atomisp_device *isp, struct pci_dev *dev);
83 void atomisp_wdt_work(struct work_struct *work);
84 void atomisp_wdt(struct timer_list *t);
85 void atomisp_setup_flash(struct atomisp_sub_device *asd);
86 irqreturn_t atomisp_isr(int irq, void *dev);
87 irqreturn_t atomisp_isr_thread(int irq, void *isp_ptr);
88 const struct atomisp_format_bridge *get_atomisp_format_bridge_from_mbus(
90 bool atomisp_is_mbuscode_raw(uint32_t code);
91 int atomisp_get_frame_pgnr(struct atomisp_device *isp,
92 const struct ia_css_frame *frame, u32 *p_pgnr);
93 void atomisp_delayed_init_work(struct work_struct *work);
96 * Get internal fmt according to V4L2 fmt
99 bool atomisp_is_viewfinder_support(struct atomisp_device *isp);
102 * ISP features control function
106 * Function to set sensor runmode by user when
107 * ATOMISP_IOC_S_SENSOR_RUNMODE ioctl was called
109 int atomisp_set_sensor_runmode(struct atomisp_sub_device *asd,
110 struct atomisp_s_runmode *runmode);
112 * Function to enable/disable lens geometry distortion correction (GDC) and
113 * chromatic aberration correction (CAC)
115 int atomisp_gdc_cac(struct atomisp_sub_device *asd, int flag,
119 * Function to enable/disable low light mode (including ANR)
121 int atomisp_low_light(struct atomisp_sub_device *asd, int flag,
125 * Function to enable/disable extra noise reduction (XNR) in low light
128 int atomisp_xnr(struct atomisp_sub_device *asd, int flag, int *arg);
130 int atomisp_formats(struct atomisp_sub_device *asd, int flag,
131 struct atomisp_formats_config *config);
134 * Function to configure noise reduction
136 int atomisp_nr(struct atomisp_sub_device *asd, int flag,
137 struct atomisp_nr_config *config);
140 * Function to configure temporal noise reduction (TNR)
142 int atomisp_tnr(struct atomisp_sub_device *asd, int flag,
143 struct atomisp_tnr_config *config);
146 * Function to configure black level compensation
148 int atomisp_black_level(struct atomisp_sub_device *asd, int flag,
149 struct atomisp_ob_config *config);
152 * Function to configure edge enhancement
154 int atomisp_ee(struct atomisp_sub_device *asd, int flag,
155 struct atomisp_ee_config *config);
158 * Function to update Gamma table for gamma, brightness and contrast config
160 int atomisp_gamma(struct atomisp_sub_device *asd, int flag,
161 struct atomisp_gamma_table *config);
163 * Function to update Ctc table for Chroma Enhancement
165 int atomisp_ctc(struct atomisp_sub_device *asd, int flag,
166 struct atomisp_ctc_table *config);
169 * Function to update gamma correction parameters
171 int atomisp_gamma_correction(struct atomisp_sub_device *asd, int flag,
172 struct atomisp_gc_config *config);
175 * Function to update Gdc table for gdc
177 int atomisp_gdc_cac_table(struct atomisp_sub_device *asd, int flag,
178 struct atomisp_morph_table *config);
181 * Function to update table for macc
183 int atomisp_macc_table(struct atomisp_sub_device *asd, int flag,
184 struct atomisp_macc_config *config);
186 * Function to get DIS statistics.
188 int atomisp_get_dis_stat(struct atomisp_sub_device *asd,
189 struct atomisp_dis_statistics *stats);
192 * Function to get DVS2 BQ resolution settings
194 int atomisp_get_dvs2_bq_resolutions(struct atomisp_sub_device *asd,
195 struct atomisp_dvs2_bq_resolutions *bq_res);
198 * Function to set the DIS coefficients.
200 int atomisp_set_dis_coefs(struct atomisp_sub_device *asd,
201 struct atomisp_dis_coefficients *coefs);
204 * Function to set the DIS motion vector.
206 int atomisp_set_dis_vector(struct atomisp_sub_device *asd,
207 struct atomisp_dis_vector *vector);
210 * Function to set/get 3A stat from isp
212 int atomisp_3a_stat(struct atomisp_sub_device *asd, int flag,
213 struct atomisp_3a_statistics *config);
216 * Function to get metadata from isp
218 int atomisp_get_metadata(struct atomisp_sub_device *asd, int flag,
219 struct atomisp_metadata *config);
221 int atomisp_get_metadata_by_type(struct atomisp_sub_device *asd, int flag,
222 struct atomisp_metadata_with_type *config);
224 int atomisp_set_parameters(struct video_device *vdev,
225 struct atomisp_parameters *arg);
227 * Function to set/get isp parameters to isp
229 int atomisp_param(struct atomisp_sub_device *asd, int flag,
230 struct atomisp_parm *config);
233 * Function to configure color effect of the image
235 int atomisp_color_effect(struct atomisp_sub_device *asd, int flag,
239 * Function to configure bad pixel correction
241 int atomisp_bad_pixel(struct atomisp_sub_device *asd, int flag,
245 * Function to configure bad pixel correction params
247 int atomisp_bad_pixel_param(struct atomisp_sub_device *asd, int flag,
248 struct atomisp_dp_config *config);
251 * Function to enable/disable video image stablization
253 int atomisp_video_stable(struct atomisp_sub_device *asd, int flag,
257 * Function to configure fixed pattern noise
259 int atomisp_fixed_pattern(struct atomisp_sub_device *asd, int flag,
263 * Function to configure fixed pattern noise table
265 int atomisp_fixed_pattern_table(struct atomisp_sub_device *asd,
266 struct v4l2_framebuffer *config);
269 * Function to configure false color correction
271 int atomisp_false_color(struct atomisp_sub_device *asd, int flag,
275 * Function to configure false color correction params
277 int atomisp_false_color_param(struct atomisp_sub_device *asd, int flag,
278 struct atomisp_de_config *config);
281 * Function to configure white balance params
283 int atomisp_white_balance_param(struct atomisp_sub_device *asd, int flag,
284 struct atomisp_wb_config *config);
286 int atomisp_3a_config_param(struct atomisp_sub_device *asd, int flag,
287 struct atomisp_3a_config *config);
290 * Function to setup digital zoom
292 int atomisp_digital_zoom(struct atomisp_sub_device *asd, int flag,
296 * Function set camera_prefiles.xml current sensor pixel array size
298 int atomisp_set_array_res(struct atomisp_sub_device *asd,
299 struct atomisp_resolution *config);
302 * Function to calculate real zoom region for every pipe
304 int atomisp_calculate_real_zoom_region(struct atomisp_sub_device *asd,
305 struct ia_css_dz_config *dz_config,
306 enum ia_css_pipe_id css_pipe_id);
308 int atomisp_cp_general_isp_parameters(struct atomisp_sub_device *asd,
309 struct atomisp_parameters *arg,
310 struct atomisp_css_params *css_param,
313 int atomisp_cp_lsc_table(struct atomisp_sub_device *asd,
314 struct atomisp_shading_table *source_st,
315 struct atomisp_css_params *css_param,
318 int atomisp_css_cp_dvs2_coefs(struct atomisp_sub_device *asd,
319 struct ia_css_dvs2_coefficients *coefs,
320 struct atomisp_css_params *css_param,
323 int atomisp_cp_morph_table(struct atomisp_sub_device *asd,
324 struct atomisp_morph_table *source_morph_table,
325 struct atomisp_css_params *css_param,
328 int atomisp_cp_dvs_6axis_config(struct atomisp_sub_device *asd,
329 struct atomisp_dvs_6axis_config *user_6axis_config,
330 struct atomisp_css_params *css_param,
333 int atomisp_makeup_css_parameters(struct atomisp_sub_device *asd,
334 struct atomisp_parameters *arg,
335 struct atomisp_css_params *css_param);
337 int atomisp_compare_grid(struct atomisp_sub_device *asd,
338 struct atomisp_grid_info *atomgrid);
340 int atomisp_get_sensor_mode_data(struct atomisp_sub_device *asd,
341 struct atomisp_sensor_mode_data *config);
343 int atomisp_get_fmt(struct video_device *vdev, struct v4l2_format *f);
345 /* This function looks up the closest available resolution. */
346 int atomisp_try_fmt(struct video_device *vdev, struct v4l2_format *f,
349 int atomisp_set_fmt(struct video_device *vdev, struct v4l2_format *f);
350 int atomisp_set_fmt_file(struct video_device *vdev, struct v4l2_format *f);
352 int atomisp_set_shading_table(struct atomisp_sub_device *asd,
353 struct atomisp_shading_table *shading_table);
355 int atomisp_offline_capture_configure(struct atomisp_sub_device *asd,
356 struct atomisp_cont_capture_conf *cvf_config);
358 int atomisp_ospm_dphy_down(struct atomisp_device *isp);
359 int atomisp_ospm_dphy_up(struct atomisp_device *isp);
360 int atomisp_exif_makernote(struct atomisp_sub_device *asd,
361 struct atomisp_makernote_info *config);
363 void atomisp_free_internal_buffers(struct atomisp_sub_device *asd);
365 int atomisp_s_ae_window(struct atomisp_sub_device *asd,
366 struct atomisp_ae_window *arg);
368 int atomisp_flash_enable(struct atomisp_sub_device *asd,
371 int atomisp_freq_scaling(struct atomisp_device *vdev,
372 enum atomisp_dfs_mode mode,
375 void atomisp_buf_done(struct atomisp_sub_device *asd, int error,
376 enum ia_css_buffer_type buf_type,
377 enum ia_css_pipe_id css_pipe_id,
378 bool q_buffers, enum atomisp_input_stream_id stream_id);
380 void atomisp_css_flush(struct atomisp_device *isp);
381 int atomisp_source_pad_to_stream_id(struct atomisp_sub_device *asd,
382 uint16_t source_pad);
385 * Events. Only one event has to be exported for now.
387 void atomisp_eof_event(struct atomisp_sub_device *asd, uint8_t exp_id);
389 enum mipi_port_id __get_mipi_port(struct atomisp_device *isp,
390 enum atomisp_camera_port port);
392 bool atomisp_is_vf_pipe(struct atomisp_video_pipe *pipe);
394 void atomisp_apply_css_parameters(
395 struct atomisp_sub_device *asd,
396 struct atomisp_css_params *css_param);
397 void atomisp_free_css_parameters(struct atomisp_css_params *css_param);
399 void atomisp_handle_parameter_and_buffer(struct atomisp_video_pipe *pipe);
401 void atomisp_flush_params_queue(struct atomisp_video_pipe *asd);
403 * Function to do Raw Buffer related operation, after enable Lock Unlock Raw Buffer
405 int atomisp_exp_id_unlock(struct atomisp_sub_device *asd, int *exp_id);
406 int atomisp_exp_id_capture(struct atomisp_sub_device *asd, int *exp_id);
409 * Function to update Raw Buffer bitmap
411 int atomisp_set_raw_buffer_bitmap(struct atomisp_sub_device *asd, int exp_id);
412 void atomisp_init_raw_buffer_bitmap(struct atomisp_sub_device *asd);
415 * Function to enable/disable zoom for capture pipe
417 int atomisp_enable_dz_capt_pipe(struct atomisp_sub_device *asd,
418 unsigned int *enable);
421 * Function to get metadata type bu pipe id
423 enum atomisp_metadata_type
424 atomisp_get_metadata_type(struct atomisp_sub_device *asd,
425 enum ia_css_pipe_id pipe_id);
428 * Function for HAL to inject a fake event to wake up poll thread
430 int atomisp_inject_a_fake_event(struct atomisp_sub_device *asd, int *event);
433 * Function for HAL to query how many invalid frames at the beginning of ISP
436 int atomisp_get_invalid_frame_num(struct video_device *vdev,
437 int *invalid_frame_num);
439 int atomisp_mrfld_power_up(struct atomisp_device *isp);
440 int atomisp_mrfld_power_down(struct atomisp_device *isp);
441 int atomisp_runtime_suspend(struct device *dev);
442 int atomisp_runtime_resume(struct device *dev);
443 #endif /* __ATOMISP_CMD_H__ */