Merge branch 'for-4.15-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj...
[linux-2.6-block.git] / drivers / staging / media / atomisp / pci / atomisp2 / atomisp_compat_css20.h
CommitLineData
a49d2536
AC
1/*
2 * Support for Clovertrail PNW Camera Imaging ISP subsystem.
3 *
4 * Copyright (c) 2013 Intel Corporation. All Rights Reserved.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
a49d2536
AC
15 *
16 */
17
18#ifndef __ATOMISP_COMPAT_CSS20_H__
19#define __ATOMISP_COMPAT_CSS20_H__
20
21#include <media/v4l2-mediabus.h>
22
23#include "ia_css.h"
24#include "ia_css_types.h"
25#include "ia_css_acc_types.h"
26#include "sh_css_legacy.h"
27
28#define ATOMISP_CSS2_PIPE_MAX 2
29#define ATOMISP_CSS2_NUM_OFFLINE_INIT_CONTINUOUS_FRAMES 3
30#define ATOMISP_CSS2_NUM_OFFLINE_INIT_CONTINUOUS_FRAMES_LOCK_EN 4
31#define ATOMISP_CSS2_NUM_DVS_FRAME_DELAY 2
32
33#define atomisp_css_pipe_id ia_css_pipe_id
34#define atomisp_css_pipeline ia_css_pipe
35#define atomisp_css_buffer_type ia_css_buffer_type
36#define atomisp_css_dis_data ia_css_isp_dvs_statistics
37#define atomisp_css_irq_info ia_css_irq_info
38#define atomisp_css_isp_config ia_css_isp_config
39#define atomisp_css_bayer_order ia_css_bayer_order
40#define atomisp_css_stream_format ia_css_stream_format
41#define atomisp_css_capture_mode ia_css_capture_mode
42#define atomisp_css_input_mode ia_css_input_mode
43#define atomisp_css_frame ia_css_frame
44#define atomisp_css_frame_format ia_css_frame_format
45#define atomisp_css_frame_info ia_css_frame_info
46#define atomisp_css_dp_config ia_css_dp_config
47#define atomisp_css_wb_config ia_css_wb_config
48#define atomisp_css_cc_config ia_css_cc_config
49#define atomisp_css_nr_config ia_css_nr_config
50#define atomisp_css_ee_config ia_css_ee_config
51#define atomisp_css_ob_config ia_css_ob_config
52#define atomisp_css_de_config ia_css_de_config
53#define atomisp_css_dz_config ia_css_dz_config
54#define atomisp_css_ce_config ia_css_ce_config
55#define atomisp_css_gc_config ia_css_gc_config
56#define atomisp_css_tnr_config ia_css_tnr_config
57#define atomisp_css_cnr_config ia_css_cnr_config
58#define atomisp_css_ctc_config ia_css_ctc_config
59#define atomisp_css_3a_config ia_css_3a_config
60#define atomisp_css_ecd_config ia_css_ecd_config
61#define atomisp_css_ynr_config ia_css_ynr_config
62#define atomisp_css_fc_config ia_css_fc_config
63#define atomisp_css_aa_config ia_css_aa_config
64#define atomisp_css_baa_config ia_css_aa_config
65#define atomisp_css_anr_config ia_css_anr_config
66#define atomisp_css_xnr_config ia_css_xnr_config
67#define atomisp_css_macc_config ia_css_macc_config
68#define atomisp_css_gamma_table ia_css_gamma_table
69#define atomisp_css_ctc_table ia_css_ctc_table
70#define atomisp_css_macc_table ia_css_macc_table
71#define atomisp_css_xnr_table ia_css_xnr_table
72#define atomisp_css_rgb_gamma_table ia_css_rgb_gamma_table
73#define atomisp_css_anr_thres ia_css_anr_thres
74#define atomisp_css_dvs_6axis ia_css_dvs_6axis_config
75#define atomisp_css_grid_info ia_css_grid_info
76#define atomisp_css_3a_grid_info ia_css_3a_grid_info
77#define atomisp_css_dvs_grid_info ia_css_dvs_grid_info
78#define atomisp_css_shading_table ia_css_shading_table
79#define atomisp_css_morph_table ia_css_morph_table
80#define atomisp_css_dvs_6axis_config ia_css_dvs_6axis_config
81#define atomisp_css_fw_info ia_css_fw_info
82#define atomisp_css_formats_config ia_css_formats_config
83
84#define CSS_PIPE_ID_PREVIEW IA_CSS_PIPE_ID_PREVIEW
85#define CSS_PIPE_ID_COPY IA_CSS_PIPE_ID_COPY
86#define CSS_PIPE_ID_VIDEO IA_CSS_PIPE_ID_VIDEO
87#define CSS_PIPE_ID_CAPTURE IA_CSS_PIPE_ID_CAPTURE
88#define CSS_PIPE_ID_ACC IA_CSS_PIPE_ID_ACC
89#define CSS_PIPE_ID_YUVPP IA_CSS_PIPE_ID_YUVPP
90#define CSS_PIPE_ID_NUM IA_CSS_PIPE_ID_NUM
91
92#define CSS_INPUT_MODE_SENSOR IA_CSS_INPUT_MODE_BUFFERED_SENSOR
93#define CSS_INPUT_MODE_FIFO IA_CSS_INPUT_MODE_FIFO
94#define CSS_INPUT_MODE_TPG IA_CSS_INPUT_MODE_TPG
95#define CSS_INPUT_MODE_PRBS IA_CSS_INPUT_MODE_PRBS
96#define CSS_INPUT_MODE_MEMORY IA_CSS_INPUT_MODE_MEMORY
97
98#define CSS_IRQ_INFO_CSS_RECEIVER_ERROR IA_CSS_IRQ_INFO_CSS_RECEIVER_ERROR
99#define CSS_IRQ_INFO_EVENTS_READY IA_CSS_IRQ_INFO_EVENTS_READY
100#define CSS_IRQ_INFO_INPUT_SYSTEM_ERROR \
101 IA_CSS_IRQ_INFO_INPUT_SYSTEM_ERROR
102#define CSS_IRQ_INFO_IF_ERROR IA_CSS_IRQ_INFO_IF_ERROR
103
104#define CSS_BUFFER_TYPE_NUM IA_CSS_BUFFER_TYPE_NUM
105
106#define CSS_FRAME_FLASH_STATE_NONE IA_CSS_FRAME_FLASH_STATE_NONE
107#define CSS_FRAME_FLASH_STATE_PARTIAL IA_CSS_FRAME_FLASH_STATE_PARTIAL
108#define CSS_FRAME_FLASH_STATE_FULL IA_CSS_FRAME_FLASH_STATE_FULL
109
110#define CSS_BAYER_ORDER_GRBG IA_CSS_BAYER_ORDER_GRBG
111#define CSS_BAYER_ORDER_RGGB IA_CSS_BAYER_ORDER_RGGB
112#define CSS_BAYER_ORDER_BGGR IA_CSS_BAYER_ORDER_BGGR
113#define CSS_BAYER_ORDER_GBRG IA_CSS_BAYER_ORDER_GBRG
114
115/*
116 * Hide IA_ naming difference in otherwise common CSS macros.
117 */
118#define CSS_ID(val) (IA_ ## val)
119#define CSS_EVENT(val) (IA_CSS_EVENT_TYPE_ ## val)
120#define CSS_FORMAT(val) (IA_CSS_STREAM_FORMAT_ ## val)
121
122#define CSS_EVENT_PORT_EOF CSS_EVENT(PORT_EOF)
123#define CSS_EVENT_FRAME_TAGGED CSS_EVENT(FRAME_TAGGED)
124
125#define CSS_MIPI_FRAME_BUFFER_SIZE_1 0x60000
126#define CSS_MIPI_FRAME_BUFFER_SIZE_2 0x80000
127
128struct atomisp_device;
129struct atomisp_sub_device;
130
131#define MAX_STREAMS_PER_CHANNEL 2
132
133/*
134 * These are used to indicate the css stream state, corresponding
135 * stream handling can be done via judging the different state.
136 */
137enum atomisp_css_stream_state {
138 CSS_STREAM_UNINIT,
139 CSS_STREAM_CREATED,
140 CSS_STREAM_STARTED,
141 CSS_STREAM_STOPPED,
142};
143
144/*
145 * Sensor of external ISP can send multiple steams with different mipi data
146 * type in the same virtual channel. This information needs to come from the
147 * sensor or external ISP
148 */
149struct atomisp_css_isys_config_info {
150 unsigned int input_format;
151 unsigned int width;
152 unsigned int height;
153};
154
155struct atomisp_stream_env {
156 struct ia_css_stream *stream;
157 struct ia_css_stream_config stream_config;
158 struct ia_css_stream_info stream_info;
159 struct ia_css_pipe *pipes[IA_CSS_PIPE_ID_NUM];
160 struct ia_css_pipe *multi_pipes[IA_CSS_PIPE_ID_NUM];
161 struct ia_css_pipe_config pipe_configs[IA_CSS_PIPE_ID_NUM];
162 struct ia_css_pipe_extra_config pipe_extra_configs[IA_CSS_PIPE_ID_NUM];
163 bool update_pipe[IA_CSS_PIPE_ID_NUM];
164 enum atomisp_css_stream_state stream_state;
165 struct ia_css_stream *acc_stream;
166 enum atomisp_css_stream_state acc_stream_state;
167 struct ia_css_stream_config acc_stream_config;
168 unsigned int ch_id; /* virtual channel ID */
169 unsigned int isys_configs;
170 struct atomisp_css_isys_config_info isys_info[MAX_STREAMS_PER_CHANNEL];
171};
172
173struct atomisp_css_env {
174 struct ia_css_env isp_css_env;
175 struct ia_css_fw isp_css_fw;
176};
177
178struct atomisp_s3a_buf {
179 struct ia_css_isp_3a_statistics *s3a_data;
180 struct ia_css_isp_3a_statistics_map *s3a_map;
181 struct list_head list;
182};
183
184struct atomisp_dis_buf {
185 struct atomisp_css_dis_data *dis_data;
186 struct ia_css_isp_dvs_statistics_map *dvs_map;
187 struct list_head list;
188};
189
190struct atomisp_css_buffer {
191 struct ia_css_buffer css_buffer;
192};
193
194struct atomisp_css_event {
195 enum atomisp_css_pipe_id pipe;
196 struct ia_css_event event;
197};
198
199void atomisp_css_set_macc_config(struct atomisp_sub_device *asd,
200 struct atomisp_css_macc_config *macc_config);
201
202void atomisp_css_set_ecd_config(struct atomisp_sub_device *asd,
203 struct atomisp_css_ecd_config *ecd_config);
204
205void atomisp_css_set_ynr_config(struct atomisp_sub_device *asd,
206 struct atomisp_css_ynr_config *ynr_config);
207
208void atomisp_css_set_fc_config(struct atomisp_sub_device *asd,
209 struct atomisp_css_fc_config *fc_config);
210
211void atomisp_css_set_aa_config(struct atomisp_sub_device *asd,
212 struct atomisp_css_aa_config *aa_config);
213
214void atomisp_css_set_baa_config(struct atomisp_sub_device *asd,
215 struct atomisp_css_baa_config *baa_config);
216
217void atomisp_css_set_anr_config(struct atomisp_sub_device *asd,
218 struct atomisp_css_anr_config *anr_config);
219
220void atomisp_css_set_xnr_config(struct atomisp_sub_device *asd,
221 struct atomisp_css_xnr_config *xnr_config);
222
223void atomisp_css_set_cnr_config(struct atomisp_sub_device *asd,
224 struct atomisp_css_cnr_config *cnr_config);
225
226void atomisp_css_set_ctc_config(struct atomisp_sub_device *asd,
227 struct atomisp_css_ctc_config *ctc_config);
228
229void atomisp_css_set_yuv2rgb_cc_config(struct atomisp_sub_device *asd,
230 struct atomisp_css_cc_config *yuv2rgb_cc_config);
231
232void atomisp_css_set_rgb2yuv_cc_config(struct atomisp_sub_device *asd,
233 struct atomisp_css_cc_config *rgb2yuv_cc_config);
234
235void atomisp_css_set_xnr_table(struct atomisp_sub_device *asd,
236 struct atomisp_css_xnr_table *xnr_table);
237
238void atomisp_css_set_r_gamma_table(struct atomisp_sub_device *asd,
239 struct atomisp_css_rgb_gamma_table *r_gamma_table);
240
241void atomisp_css_set_g_gamma_table(struct atomisp_sub_device *asd,
242 struct atomisp_css_rgb_gamma_table *g_gamma_table);
243
244void atomisp_css_set_b_gamma_table(struct atomisp_sub_device *asd,
245 struct atomisp_css_rgb_gamma_table *b_gamma_table);
246
247void atomisp_css_set_anr_thres(struct atomisp_sub_device *asd,
248 struct atomisp_css_anr_thres *anr_thres);
249
250int atomisp_css_check_firmware_version(struct atomisp_device *isp);
251
252int atomisp_css_load_firmware(struct atomisp_device *isp);
253
254void atomisp_css_unload_firmware(struct atomisp_device *isp);
255
256void atomisp_css_set_dvs_6axis(struct atomisp_sub_device *asd,
257 struct atomisp_css_dvs_6axis *dvs_6axis);
258
259unsigned int atomisp_css_debug_get_dtrace_level(void);
260
261int atomisp_css_debug_dump_isp_binary(void);
262
263int atomisp_css_dump_sp_raw_copy_linecount(bool reduced);
264
265int atomisp_css_dump_blob_infor(void);
266
267void atomisp_css_set_isp_config_id(struct atomisp_sub_device *asd,
268 uint32_t isp_config_id);
269
270void atomisp_css_set_isp_config_applied_frame(struct atomisp_sub_device *asd,
271 struct atomisp_css_frame *output_frame);
272
273int atomisp_get_css_dbgfunc(void);
274
275int atomisp_set_css_dbgfunc(struct atomisp_device *isp, int opt);
276struct atomisp_css_dvs_grid_info *atomisp_css_get_dvs_grid_info(
277 struct atomisp_css_grid_info *grid_info);
278#endif