]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.h
Merge tag 'media/v4.12-2' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab...
[karo-tx-linux.git] / drivers / staging / media / atomisp / pci / atomisp2 / atomisp_cmd.h
1 /*
2  * Support for Medifield PNW Camera Imaging ISP subsystem.
3  *
4  * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
5  *
6  * Copyright (c) 2010 Silicon Hive www.siliconhive.com.
7  *
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.
11  *
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.
16  *
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
20  * 02110-1301, USA.
21  *
22  */
23
24 #ifndef __ATOMISP_CMD_H__
25 #define __ATOMISP_CMD_H__
26
27 #include "../../include/linux/atomisp.h"
28 #include <linux/interrupt.h>
29 #include <linux/videodev2.h>
30
31 #include <media/v4l2-subdev.h>
32
33 #include "atomisp_internal.h"
34
35 #include "ia_css_types.h"
36 #include "ia_css.h"
37
38 struct atomisp_device;
39 struct atomisp_css_frame;
40
41 #define MSI_ENABLE_BIT          16
42 #define INTR_DISABLE_BIT        10
43 #define BUS_MASTER_ENABLE       2
44 #define MEMORY_SPACE_ENABLE     1
45 #define INTR_IER                24
46 #define INTR_IIR                16
47 #ifdef ISP2401
48 #define RUNMODE_MASK (ATOMISP_RUN_MODE_VIDEO | ATOMISP_RUN_MODE_STILL_CAPTURE \
49                         | ATOMISP_RUN_MODE_PREVIEW)
50
51 /* FIXME: check if can go */
52 extern int atomisp_punit_hpll_freq;
53 #endif
54
55 /*
56  * Helper function
57  */
58 void dump_sp_dmem(struct atomisp_device *isp, unsigned int addr,
59                   unsigned int size);
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);
66 #ifndef ISP2401
67 bool atomisp_buffers_queued(struct atomisp_sub_device *asd);
68 #else
69 bool atomisp_buffers_queued_pipe(struct atomisp_video_pipe *pipe);
70 #endif
71
72 /* TODO:should be here instead of atomisp_helper.h
73 extern void __iomem *atomisp_io_base;
74
75 static inline void __iomem *atomisp_get_io_virt_addr(unsigned int address)
76 {
77         void __iomem *ret = atomisp_io_base + (address & 0x003FFFFF);
78         return ret;
79 }
80 */
81 void *atomisp_kernel_malloc(size_t bytes);
82 void *atomisp_kernel_zalloc(size_t bytes, bool zero_mem);
83 void atomisp_kernel_free(void *ptr);
84
85 /*
86  * Interrupt functions
87  */
88 void atomisp_msi_irq_init(struct atomisp_device *isp, struct pci_dev *dev);
89 void atomisp_msi_irq_uninit(struct atomisp_device *isp, struct pci_dev *dev);
90 void atomisp_wdt_work(struct work_struct *work);
91 #ifndef ISP2401
92 void atomisp_wdt(unsigned long isp_addr);
93 #else
94 void atomisp_wdt(unsigned long pipe_addr);
95 #endif
96 void atomisp_setup_flash(struct atomisp_sub_device *asd);
97 irqreturn_t atomisp_isr(int irq, void *dev);
98 irqreturn_t atomisp_isr_thread(int irq, void *isp_ptr);
99 const struct atomisp_format_bridge *get_atomisp_format_bridge_from_mbus(
100         u32 mbus_code);
101 bool atomisp_is_mbuscode_raw(uint32_t code);
102 int atomisp_get_frame_pgnr(struct atomisp_device *isp,
103                            const struct atomisp_css_frame *frame, u32 *p_pgnr);
104 void atomisp_delayed_init_work(struct work_struct *work);
105
106 /*
107  * Get internal fmt according to V4L2 fmt
108  */
109
110 bool atomisp_is_viewfinder_support(struct atomisp_device *isp);
111
112 /*
113  * ISP features control function
114  */
115
116 /*
117 #ifdef ISP2401
118  * Function to set sensor runmode by user when
119  * ATOMISP_IOC_S_SENSOR_RUNMODE ioctl was called
120  */
121 int atomisp_set_sensor_runmode(struct atomisp_sub_device *asd,
122                 struct atomisp_s_runmode *runmode);
123 /*
124 #endif
125  * Function to enable/disable lens geometry distortion correction (GDC) and
126  * chromatic aberration correction (CAC)
127  */
128 int atomisp_gdc_cac(struct atomisp_sub_device *asd, int flag,
129                     __s32 *value);
130
131 /*
132  * Function to enable/disable low light mode (including ANR)
133  */
134 int atomisp_low_light(struct atomisp_sub_device *asd, int flag,
135                       __s32 *value);
136
137 /*
138  * Function to enable/disable extra noise reduction (XNR) in low light
139  * condition
140  */
141 int atomisp_xnr(struct atomisp_sub_device *asd, int flag, int *arg);
142
143 int atomisp_formats(struct atomisp_sub_device *asd, int flag,
144                 struct atomisp_formats_config *config);
145
146 /*
147  * Function to configure noise reduction
148  */
149 int atomisp_nr(struct atomisp_sub_device *asd, int flag,
150                struct atomisp_nr_config *config);
151
152 /*
153  * Function to configure temporal noise reduction (TNR)
154  */
155 int atomisp_tnr(struct atomisp_sub_device *asd, int flag,
156                 struct atomisp_tnr_config *config);
157
158 /*
159  * Function to configure black level compensation
160  */
161 int atomisp_black_level(struct atomisp_sub_device *asd, int flag,
162                         struct atomisp_ob_config *config);
163
164 /*
165  * Function to configure edge enhancement
166  */
167 int atomisp_ee(struct atomisp_sub_device *asd, int flag,
168                struct atomisp_ee_config *config);
169
170 /*
171  * Function to update Gamma table for gamma, brightness and contrast config
172  */
173 int atomisp_gamma(struct atomisp_sub_device *asd, int flag,
174                   struct atomisp_gamma_table *config);
175 /*
176  * Function to update Ctc table for Chroma Enhancement
177  */
178 int atomisp_ctc(struct atomisp_sub_device *asd, int flag,
179                 struct atomisp_ctc_table *config);
180
181 /*
182  * Function to update gamma correction parameters
183  */
184 int atomisp_gamma_correction(struct atomisp_sub_device *asd, int flag,
185         struct atomisp_gc_config *config);
186
187 /*
188  * Function to update Gdc table for gdc
189  */
190 int atomisp_gdc_cac_table(struct atomisp_sub_device *asd, int flag,
191                           struct atomisp_morph_table *config);
192
193 /*
194  * Function to update table for macc
195  */
196 int atomisp_macc_table(struct atomisp_sub_device *asd, int flag,
197                        struct atomisp_macc_config *config);
198 /*
199  * Function to get DIS statistics.
200  */
201 int atomisp_get_dis_stat(struct atomisp_sub_device *asd,
202                          struct atomisp_dis_statistics *stats);
203
204 /*
205  * Function to get DVS2 BQ resolution settings
206  */
207 int atomisp_get_dvs2_bq_resolutions(struct atomisp_sub_device *asd,
208                          struct atomisp_dvs2_bq_resolutions *bq_res);
209
210 /*
211  * Function to set the DIS coefficients.
212  */
213 int atomisp_set_dis_coefs(struct atomisp_sub_device *asd,
214                           struct atomisp_dis_coefficients *coefs);
215
216 /*
217  * Function to set the DIS motion vector.
218  */
219 int atomisp_set_dis_vector(struct atomisp_sub_device *asd,
220                            struct atomisp_dis_vector *vector);
221
222 /*
223  * Function to set/get 3A stat from isp
224  */
225 int atomisp_3a_stat(struct atomisp_sub_device *asd, int flag,
226                     struct atomisp_3a_statistics *config);
227
228 /*
229  * Function to get metadata from isp
230  */
231 int atomisp_get_metadata(struct atomisp_sub_device *asd, int flag,
232                          struct atomisp_metadata *config);
233
234 int atomisp_get_metadata_by_type(struct atomisp_sub_device *asd, int flag,
235                          struct atomisp_metadata_with_type *config);
236
237 int atomisp_set_parameters(struct video_device *vdev,
238                         struct atomisp_parameters *arg);
239 /*
240  * Function to set/get isp parameters to isp
241  */
242 int atomisp_param(struct atomisp_sub_device *asd, int flag,
243                   struct atomisp_parm *config);
244
245 /*
246  * Function to configure color effect of the image
247  */
248 int atomisp_color_effect(struct atomisp_sub_device *asd, int flag,
249                          __s32 *effect);
250
251 /*
252  * Function to configure bad pixel correction
253  */
254 int atomisp_bad_pixel(struct atomisp_sub_device *asd, int flag,
255                       __s32 *value);
256
257 /*
258  * Function to configure bad pixel correction params
259  */
260 int atomisp_bad_pixel_param(struct atomisp_sub_device *asd, int flag,
261                             struct atomisp_dp_config *config);
262
263 /*
264  * Function to enable/disable video image stablization
265  */
266 int atomisp_video_stable(struct atomisp_sub_device *asd, int flag,
267                          __s32 *value);
268
269 /*
270  * Function to configure fixed pattern noise
271  */
272 int atomisp_fixed_pattern(struct atomisp_sub_device *asd, int flag,
273                           __s32 *value);
274
275 /*
276  * Function to configure fixed pattern noise table
277  */
278 int atomisp_fixed_pattern_table(struct atomisp_sub_device *asd,
279                                 struct v4l2_framebuffer *config);
280
281 /*
282  * Function to configure false color correction
283  */
284 int atomisp_false_color(struct atomisp_sub_device *asd, int flag,
285                         __s32 *value);
286
287 /*
288  * Function to configure false color correction params
289  */
290 int atomisp_false_color_param(struct atomisp_sub_device *asd, int flag,
291                               struct atomisp_de_config *config);
292
293 /*
294  * Function to configure white balance params
295  */
296 int atomisp_white_balance_param(struct atomisp_sub_device *asd, int flag,
297                                 struct atomisp_wb_config *config);
298
299 int atomisp_3a_config_param(struct atomisp_sub_device *asd, int flag,
300                             struct atomisp_3a_config *config);
301
302 /*
303  * Function to setup digital zoom
304  */
305 int atomisp_digital_zoom(struct atomisp_sub_device *asd, int flag,
306                          __s32 *value);
307
308 /*
309  * Function  set camera_prefiles.xml current sensor pixel array size
310  */
311 int atomisp_set_array_res(struct atomisp_sub_device *asd,
312                         struct atomisp_resolution  *config);
313
314 /*
315  * Function to calculate real zoom region for every pipe
316  */
317 int atomisp_calculate_real_zoom_region(struct atomisp_sub_device *asd,
318                         struct atomisp_css_dz_config   *dz_config,
319                         enum atomisp_css_pipe_id css_pipe_id);
320
321 int atomisp_cp_general_isp_parameters(struct atomisp_sub_device *asd,
322                                       struct atomisp_parameters *arg,
323                                       struct atomisp_css_params *css_param,
324                                       bool from_user);
325
326 int atomisp_cp_lsc_table(struct atomisp_sub_device *asd,
327                          struct atomisp_shading_table *source_st,
328                          struct atomisp_css_params *css_param,
329                          bool from_user);
330
331 int atomisp_css_cp_dvs2_coefs(struct atomisp_sub_device *asd,
332                               struct ia_css_dvs2_coefficients *coefs,
333                               struct atomisp_css_params *css_param,
334                               bool from_user);
335
336 int atomisp_cp_morph_table(struct atomisp_sub_device *asd,
337                            struct atomisp_morph_table *source_morph_table,
338                            struct atomisp_css_params *css_param,
339                            bool from_user);
340
341 int atomisp_cp_dvs_6axis_config(struct atomisp_sub_device *asd,
342                         struct atomisp_dvs_6axis_config *user_6axis_config,
343                         struct atomisp_css_params *css_param,
344                         bool from_user);
345
346 int atomisp_makeup_css_parameters(struct atomisp_sub_device *asd,
347                                   struct atomisp_parameters *arg,
348                                   struct atomisp_css_params *css_param);
349
350 int atomisp_compare_grid(struct atomisp_sub_device *asd,
351                                 struct atomisp_grid_info *atomgrid);
352
353 int atomisp_get_sensor_mode_data(struct atomisp_sub_device *asd,
354                                  struct atomisp_sensor_mode_data *config);
355
356 int atomisp_get_fmt(struct video_device *vdev, struct v4l2_format *f);
357
358
359 /* This function looks up the closest available resolution. */
360 int atomisp_try_fmt(struct video_device *vdev, struct v4l2_format *f,
361                                                 bool *res_overflow);
362
363 int atomisp_set_fmt(struct video_device *vdev, struct v4l2_format *f);
364 int atomisp_set_fmt_file(struct video_device *vdev, struct v4l2_format *f);
365
366 int atomisp_set_shading_table(struct atomisp_sub_device *asd,
367                               struct atomisp_shading_table *shading_table);
368
369 int atomisp_offline_capture_configure(struct atomisp_sub_device *asd,
370                                 struct atomisp_cont_capture_conf *cvf_config);
371
372 int atomisp_ospm_dphy_down(struct atomisp_device *isp);
373 int atomisp_ospm_dphy_up(struct atomisp_device *isp);
374 int atomisp_exif_makernote(struct atomisp_sub_device *asd,
375                            struct atomisp_makernote_info *config);
376
377 void atomisp_free_internal_buffers(struct atomisp_sub_device *asd);
378
379 int atomisp_s_ae_window(struct atomisp_sub_device *asd,
380                         struct atomisp_ae_window *arg);
381
382 int  atomisp_flash_enable(struct atomisp_sub_device *asd,
383                           int num_frames);
384
385 int atomisp_freq_scaling(struct atomisp_device *vdev,
386                          enum atomisp_dfs_mode mode,
387                          bool force);
388
389 void atomisp_buf_done(struct atomisp_sub_device *asd, int error,
390                       enum atomisp_css_buffer_type buf_type,
391                       enum atomisp_css_pipe_id css_pipe_id,
392                       bool q_buffers, enum atomisp_input_stream_id stream_id);
393
394 void atomisp_css_flush(struct atomisp_device *isp);
395 int atomisp_source_pad_to_stream_id(struct atomisp_sub_device *asd,
396                                            uint16_t source_pad);
397
398 /*
399  * Events. Only one event has to be exported for now.
400  */
401 void atomisp_eof_event(struct atomisp_sub_device *asd, uint8_t exp_id);
402
403 mipi_port_ID_t __get_mipi_port(struct atomisp_device *isp,
404                                 enum atomisp_camera_port port);
405
406 bool atomisp_is_vf_pipe(struct atomisp_video_pipe *pipe);
407
408 void atomisp_apply_css_parameters(
409                                 struct atomisp_sub_device *asd,
410                                 struct atomisp_css_params *css_param);
411 void atomisp_free_css_parameters(struct atomisp_css_params *css_param);
412
413 void atomisp_handle_parameter_and_buffer(struct atomisp_video_pipe *pipe);
414
415 void atomisp_flush_params_queue(struct atomisp_video_pipe *asd);
416 /*
417  * Function to do Raw Buffer related operation, after enable Lock Unlock Raw Buffer
418  */
419 int atomisp_exp_id_unlock(struct atomisp_sub_device *asd, int *exp_id);
420 int atomisp_exp_id_capture(struct atomisp_sub_device *asd, int *exp_id);
421
422 /*
423  * Function to update Raw Buffer bitmap
424  */
425 int atomisp_set_raw_buffer_bitmap(struct atomisp_sub_device *asd, int exp_id);
426 void atomisp_init_raw_buffer_bitmap(struct atomisp_sub_device *asd);
427
428 /*
429  * Function to enable/disable zoom for capture pipe
430  */
431 int atomisp_enable_dz_capt_pipe(struct atomisp_sub_device *asd,
432                                            unsigned int *enable);
433
434 /*
435  * Function to get metadata type bu pipe id
436  */
437 enum atomisp_metadata_type
438 atomisp_get_metadata_type(struct atomisp_sub_device *asd,
439                           enum ia_css_pipe_id pipe_id);
440
441 /*
442  * Function for HAL to inject a fake event to wake up poll thread
443  */
444 int atomisp_inject_a_fake_event(struct atomisp_sub_device *asd, int *event);
445
446 /*
447  * Function for HAL to query how many invalid frames at the beginning of ISP
448  * pipeline output
449  */
450 int atomisp_get_invalid_frame_num(struct video_device *vdev,
451                         int *invalid_frame_num);
452
453 int atomisp_mrfld_power_up(struct atomisp_device *isp);
454 int atomisp_mrfld_power_down(struct atomisp_device *isp);
455 int atomisp_runtime_suspend(struct device *dev);
456 int atomisp_runtime_resume(struct device *dev);
457 #endif /* __ATOMISP_CMD_H__ */