2 * Support for Medifield PNW Camera Imaging ISP subsystem.
4 * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
6 * Copyright (c) 2010 Silicon Hive www.siliconhive.com.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version
10 * 2 as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 #ifndef __ATOMISP_CMD_H__
25 #define __ATOMISP_CMD_H__
27 #include "../../include/linux/atomisp.h"
28 #include <linux/interrupt.h>
29 #include <linux/videodev2.h>
31 #include <media/v4l2-subdev.h>
33 #include "atomisp_internal.h"
35 #include "ia_css_types.h"
38 struct atomisp_device;
39 struct atomisp_css_frame;
41 #define MSI_ENABLE_BIT 16
42 #define INTR_DISABLE_BIT 10
43 #define BUS_MASTER_ENABLE 2
44 #define MEMORY_SPACE_ENABLE 1
48 #define RUNMODE_MASK (ATOMISP_RUN_MODE_VIDEO | ATOMISP_RUN_MODE_STILL_CAPTURE \
49 | ATOMISP_RUN_MODE_PREVIEW)
51 /* FIXME: check if can go */
52 extern int atomisp_punit_hpll_freq;
58 void dump_sp_dmem(struct atomisp_device *isp, unsigned int addr,
60 struct camera_mipi_info *atomisp_to_sensor_mipi_info(struct v4l2_subdev *sd);
61 struct atomisp_video_pipe *atomisp_to_video_pipe(struct video_device *dev);
62 struct atomisp_acc_pipe *atomisp_to_acc_pipe(struct video_device *dev);
63 int atomisp_reset(struct atomisp_device *isp);
64 void atomisp_flush_bufs_and_wakeup(struct atomisp_sub_device *asd);
65 void atomisp_clear_css_buffer_counters(struct atomisp_sub_device *asd);
67 bool atomisp_buffers_queued(struct atomisp_sub_device *asd);
69 bool atomisp_buffers_queued_pipe(struct atomisp_video_pipe *pipe);
72 /* TODO:should be here instead of atomisp_helper.h
73 extern void __iomem *atomisp_io_base;
75 static inline void __iomem *atomisp_get_io_virt_addr(unsigned int address)
77 void __iomem *ret = atomisp_io_base + (address & 0x003FFFFF);
85 void atomisp_msi_irq_init(struct atomisp_device *isp, struct pci_dev *dev);
86 void atomisp_msi_irq_uninit(struct atomisp_device *isp, struct pci_dev *dev);
87 void atomisp_wdt_work(struct work_struct *work);
89 void atomisp_wdt(unsigned long isp_addr);
91 void atomisp_wdt(unsigned long pipe_addr);
93 void atomisp_setup_flash(struct atomisp_sub_device *asd);
94 irqreturn_t atomisp_isr(int irq, void *dev);
95 irqreturn_t atomisp_isr_thread(int irq, void *isp_ptr);
96 const struct atomisp_format_bridge *get_atomisp_format_bridge_from_mbus(
98 bool atomisp_is_mbuscode_raw(uint32_t code);
99 int atomisp_get_frame_pgnr(struct atomisp_device *isp,
100 const struct atomisp_css_frame *frame, u32 *p_pgnr);
101 void atomisp_delayed_init_work(struct work_struct *work);
104 * Get internal fmt according to V4L2 fmt
107 bool atomisp_is_viewfinder_support(struct atomisp_device *isp);
110 * ISP features control function
115 * Function to set sensor runmode by user when
116 * ATOMISP_IOC_S_SENSOR_RUNMODE ioctl was called
118 int atomisp_set_sensor_runmode(struct atomisp_sub_device *asd,
119 struct atomisp_s_runmode *runmode);
122 * Function to enable/disable lens geometry distortion correction (GDC) and
123 * chromatic aberration correction (CAC)
125 int atomisp_gdc_cac(struct atomisp_sub_device *asd, int flag,
129 * Function to enable/disable low light mode (including ANR)
131 int atomisp_low_light(struct atomisp_sub_device *asd, int flag,
135 * Function to enable/disable extra noise reduction (XNR) in low light
138 int atomisp_xnr(struct atomisp_sub_device *asd, int flag, int *arg);
140 int atomisp_formats(struct atomisp_sub_device *asd, int flag,
141 struct atomisp_formats_config *config);
144 * Function to configure noise reduction
146 int atomisp_nr(struct atomisp_sub_device *asd, int flag,
147 struct atomisp_nr_config *config);
150 * Function to configure temporal noise reduction (TNR)
152 int atomisp_tnr(struct atomisp_sub_device *asd, int flag,
153 struct atomisp_tnr_config *config);
156 * Function to configure black level compensation
158 int atomisp_black_level(struct atomisp_sub_device *asd, int flag,
159 struct atomisp_ob_config *config);
162 * Function to configure edge enhancement
164 int atomisp_ee(struct atomisp_sub_device *asd, int flag,
165 struct atomisp_ee_config *config);
168 * Function to update Gamma table for gamma, brightness and contrast config
170 int atomisp_gamma(struct atomisp_sub_device *asd, int flag,
171 struct atomisp_gamma_table *config);
173 * Function to update Ctc table for Chroma Enhancement
175 int atomisp_ctc(struct atomisp_sub_device *asd, int flag,
176 struct atomisp_ctc_table *config);
179 * Function to update gamma correction parameters
181 int atomisp_gamma_correction(struct atomisp_sub_device *asd, int flag,
182 struct atomisp_gc_config *config);
185 * Function to update Gdc table for gdc
187 int atomisp_gdc_cac_table(struct atomisp_sub_device *asd, int flag,
188 struct atomisp_morph_table *config);
191 * Function to update table for macc
193 int atomisp_macc_table(struct atomisp_sub_device *asd, int flag,
194 struct atomisp_macc_config *config);
196 * Function to get DIS statistics.
198 int atomisp_get_dis_stat(struct atomisp_sub_device *asd,
199 struct atomisp_dis_statistics *stats);
202 * Function to get DVS2 BQ resolution settings
204 int atomisp_get_dvs2_bq_resolutions(struct atomisp_sub_device *asd,
205 struct atomisp_dvs2_bq_resolutions *bq_res);
208 * Function to set the DIS coefficients.
210 int atomisp_set_dis_coefs(struct atomisp_sub_device *asd,
211 struct atomisp_dis_coefficients *coefs);
214 * Function to set the DIS motion vector.
216 int atomisp_set_dis_vector(struct atomisp_sub_device *asd,
217 struct atomisp_dis_vector *vector);
220 * Function to set/get 3A stat from isp
222 int atomisp_3a_stat(struct atomisp_sub_device *asd, int flag,
223 struct atomisp_3a_statistics *config);
226 * Function to get metadata from isp
228 int atomisp_get_metadata(struct atomisp_sub_device *asd, int flag,
229 struct atomisp_metadata *config);
231 int atomisp_get_metadata_by_type(struct atomisp_sub_device *asd, int flag,
232 struct atomisp_metadata_with_type *config);
234 int atomisp_set_parameters(struct video_device *vdev,
235 struct atomisp_parameters *arg);
237 * Function to set/get isp parameters to isp
239 int atomisp_param(struct atomisp_sub_device *asd, int flag,
240 struct atomisp_parm *config);
243 * Function to configure color effect of the image
245 int atomisp_color_effect(struct atomisp_sub_device *asd, int flag,
249 * Function to configure bad pixel correction
251 int atomisp_bad_pixel(struct atomisp_sub_device *asd, int flag,
255 * Function to configure bad pixel correction params
257 int atomisp_bad_pixel_param(struct atomisp_sub_device *asd, int flag,
258 struct atomisp_dp_config *config);
261 * Function to enable/disable video image stablization
263 int atomisp_video_stable(struct atomisp_sub_device *asd, int flag,
267 * Function to configure fixed pattern noise
269 int atomisp_fixed_pattern(struct atomisp_sub_device *asd, int flag,
273 * Function to configure fixed pattern noise table
275 int atomisp_fixed_pattern_table(struct atomisp_sub_device *asd,
276 struct v4l2_framebuffer *config);
279 * Function to configure false color correction
281 int atomisp_false_color(struct atomisp_sub_device *asd, int flag,
285 * Function to configure false color correction params
287 int atomisp_false_color_param(struct atomisp_sub_device *asd, int flag,
288 struct atomisp_de_config *config);
291 * Function to configure white balance params
293 int atomisp_white_balance_param(struct atomisp_sub_device *asd, int flag,
294 struct atomisp_wb_config *config);
296 int atomisp_3a_config_param(struct atomisp_sub_device *asd, int flag,
297 struct atomisp_3a_config *config);
300 * Function to setup digital zoom
302 int atomisp_digital_zoom(struct atomisp_sub_device *asd, int flag,
306 * Function set camera_prefiles.xml current sensor pixel array size
308 int atomisp_set_array_res(struct atomisp_sub_device *asd,
309 struct atomisp_resolution *config);
312 * Function to calculate real zoom region for every pipe
314 int atomisp_calculate_real_zoom_region(struct atomisp_sub_device *asd,
315 struct atomisp_css_dz_config *dz_config,
316 enum atomisp_css_pipe_id css_pipe_id);
318 int atomisp_cp_general_isp_parameters(struct atomisp_sub_device *asd,
319 struct atomisp_parameters *arg,
320 struct atomisp_css_params *css_param,
323 int atomisp_cp_lsc_table(struct atomisp_sub_device *asd,
324 struct atomisp_shading_table *source_st,
325 struct atomisp_css_params *css_param,
328 int atomisp_css_cp_dvs2_coefs(struct atomisp_sub_device *asd,
329 struct ia_css_dvs2_coefficients *coefs,
330 struct atomisp_css_params *css_param,
333 int atomisp_cp_morph_table(struct atomisp_sub_device *asd,
334 struct atomisp_morph_table *source_morph_table,
335 struct atomisp_css_params *css_param,
338 int atomisp_cp_dvs_6axis_config(struct atomisp_sub_device *asd,
339 struct atomisp_dvs_6axis_config *user_6axis_config,
340 struct atomisp_css_params *css_param,
343 int atomisp_makeup_css_parameters(struct atomisp_sub_device *asd,
344 struct atomisp_parameters *arg,
345 struct atomisp_css_params *css_param);
347 int atomisp_compare_grid(struct atomisp_sub_device *asd,
348 struct atomisp_grid_info *atomgrid);
350 int atomisp_get_sensor_mode_data(struct atomisp_sub_device *asd,
351 struct atomisp_sensor_mode_data *config);
353 int atomisp_get_fmt(struct video_device *vdev, struct v4l2_format *f);
356 /* This function looks up the closest available resolution. */
357 int atomisp_try_fmt(struct video_device *vdev, struct v4l2_format *f,
360 int atomisp_set_fmt(struct video_device *vdev, struct v4l2_format *f);
361 int atomisp_set_fmt_file(struct video_device *vdev, struct v4l2_format *f);
363 int atomisp_set_shading_table(struct atomisp_sub_device *asd,
364 struct atomisp_shading_table *shading_table);
366 int atomisp_offline_capture_configure(struct atomisp_sub_device *asd,
367 struct atomisp_cont_capture_conf *cvf_config);
369 int atomisp_ospm_dphy_down(struct atomisp_device *isp);
370 int atomisp_ospm_dphy_up(struct atomisp_device *isp);
371 int atomisp_exif_makernote(struct atomisp_sub_device *asd,
372 struct atomisp_makernote_info *config);
374 void atomisp_free_internal_buffers(struct atomisp_sub_device *asd);
376 int atomisp_s_ae_window(struct atomisp_sub_device *asd,
377 struct atomisp_ae_window *arg);
379 int atomisp_flash_enable(struct atomisp_sub_device *asd,
382 int atomisp_freq_scaling(struct atomisp_device *vdev,
383 enum atomisp_dfs_mode mode,
386 void atomisp_buf_done(struct atomisp_sub_device *asd, int error,
387 enum atomisp_css_buffer_type buf_type,
388 enum atomisp_css_pipe_id css_pipe_id,
389 bool q_buffers, enum atomisp_input_stream_id stream_id);
391 void atomisp_css_flush(struct atomisp_device *isp);
392 int atomisp_source_pad_to_stream_id(struct atomisp_sub_device *asd,
393 uint16_t source_pad);
396 * Events. Only one event has to be exported for now.
398 void atomisp_eof_event(struct atomisp_sub_device *asd, uint8_t exp_id);
400 mipi_port_ID_t __get_mipi_port(struct atomisp_device *isp,
401 enum atomisp_camera_port port);
403 bool atomisp_is_vf_pipe(struct atomisp_video_pipe *pipe);
405 void atomisp_apply_css_parameters(
406 struct atomisp_sub_device *asd,
407 struct atomisp_css_params *css_param);
408 void atomisp_free_css_parameters(struct atomisp_css_params *css_param);
410 void atomisp_handle_parameter_and_buffer(struct atomisp_video_pipe *pipe);
412 void atomisp_flush_params_queue(struct atomisp_video_pipe *asd);
414 * Function to do Raw Buffer related operation, after enable Lock Unlock Raw Buffer
416 int atomisp_exp_id_unlock(struct atomisp_sub_device *asd, int *exp_id);
417 int atomisp_exp_id_capture(struct atomisp_sub_device *asd, int *exp_id);
420 * Function to update Raw Buffer bitmap
422 int atomisp_set_raw_buffer_bitmap(struct atomisp_sub_device *asd, int exp_id);
423 void atomisp_init_raw_buffer_bitmap(struct atomisp_sub_device *asd);
426 * Function to enable/disable zoom for capture pipe
428 int atomisp_enable_dz_capt_pipe(struct atomisp_sub_device *asd,
429 unsigned int *enable);
432 * Function to get metadata type bu pipe id
434 enum atomisp_metadata_type
435 atomisp_get_metadata_type(struct atomisp_sub_device *asd,
436 enum ia_css_pipe_id pipe_id);
439 * Function for HAL to inject a fake event to wake up poll thread
441 int atomisp_inject_a_fake_event(struct atomisp_sub_device *asd, int *event);
444 * Function for HAL to query how many invalid frames at the beginning of ISP
447 int atomisp_get_invalid_frame_num(struct video_device *vdev,
448 int *invalid_frame_num);
450 int atomisp_mrfld_power_up(struct atomisp_device *isp);
451 int atomisp_mrfld_power_down(struct atomisp_device *isp);
452 int atomisp_runtime_suspend(struct device *dev);
453 int atomisp_runtime_resume(struct device *dev);
454 #endif /* __ATOMISP_CMD_H__ */