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