1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Support for Clovertrail PNW Camera Imaging ISP subsystem.
4 *
5 * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License version
9 * 2 as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 *
16 *
17 */
18
19#ifndef __ATOMISP_COMPAT_H__
20#define __ATOMISP_COMPAT_H__
21
22#include "atomisp_compat_css20.h"
23
24#include "../../include/linux/atomisp.h"
25
26struct atomisp_device;
27struct atomisp_sub_device;
28struct video_device;
29enum atomisp_input_stream_id;
30
31struct atomisp_metadata_buf {
32	struct ia_css_metadata *metadata;
33	void *md_vptr;
34	struct list_head list;
35};
36
37void atomisp_css2_hw_store_32(hrt_address addr, uint32_t data);
38void atomisp_load_uint32(hrt_address addr, uint32_t *data);
39
40int atomisp_css_init(struct atomisp_device *isp);
41
42void atomisp_css_uninit(struct atomisp_device *isp);
43
44void atomisp_css_init_struct(struct atomisp_sub_device *asd);
45
46int atomisp_css_irq_translate(struct atomisp_device *isp,
47			      unsigned int *infos);
48
49void atomisp_css_rx_get_irq_info(enum mipi_port_id port,
50				 unsigned int *infos);
51
52void atomisp_css_rx_clear_irq_info(enum mipi_port_id port,
53				   unsigned int infos);
54
55int atomisp_css_irq_enable(struct atomisp_device *isp,
56			   enum ia_css_irq_info info, bool enable);
57
58int atomisp_q_video_buffer_to_css(struct atomisp_sub_device *asd,
59				  struct ia_css_frame *frame,
60				  enum atomisp_input_stream_id stream_id,
61				  enum ia_css_buffer_type css_buf_type,
62				  enum ia_css_pipe_id css_pipe_id);
63
64int atomisp_q_s3a_buffer_to_css(struct atomisp_sub_device *asd,
65				struct atomisp_s3a_buf *s3a_buf,
66				enum atomisp_input_stream_id stream_id,
67				enum ia_css_pipe_id css_pipe_id);
68
69int atomisp_q_metadata_buffer_to_css(struct atomisp_sub_device *asd,
70				     struct atomisp_metadata_buf *metadata_buf,
71				     enum atomisp_input_stream_id stream_id,
72				     enum ia_css_pipe_id css_pipe_id);
73
74int atomisp_q_dis_buffer_to_css(struct atomisp_sub_device *asd,
75				struct atomisp_dis_buf *dis_buf,
76				enum atomisp_input_stream_id stream_id,
77				enum ia_css_pipe_id css_pipe_id);
78
79void ia_css_mmu_invalidate_cache(void);
80
81int atomisp_css_start(struct atomisp_sub_device *asd);
82
83void atomisp_css_update_isp_params(struct atomisp_sub_device *asd);
84void atomisp_css_update_isp_params_on_pipe(struct atomisp_sub_device *asd,
85	struct ia_css_pipe *pipe);
86
87int atomisp_css_queue_buffer(struct atomisp_sub_device *asd,
88			     enum atomisp_input_stream_id stream_id,
89			     enum ia_css_pipe_id pipe_id,
90			     enum ia_css_buffer_type buf_type,
91			     struct atomisp_css_buffer *isp_css_buffer);
92
93int atomisp_css_dequeue_buffer(struct atomisp_sub_device *asd,
94			       enum atomisp_input_stream_id stream_id,
95			       enum ia_css_pipe_id pipe_id,
96			       enum ia_css_buffer_type buf_type,
97			       struct atomisp_css_buffer *isp_css_buffer);
98
99int atomisp_css_allocate_stat_buffers(struct atomisp_sub_device *asd,
100				      u16 stream_id,
101				      struct atomisp_s3a_buf *s3a_buf,
102				      struct atomisp_dis_buf *dis_buf,
103				      struct atomisp_metadata_buf *md_buf);
104
105void atomisp_css_free_stat_buffers(struct atomisp_sub_device *asd);
106
107void atomisp_css_free_3a_buffer(struct atomisp_s3a_buf *s3a_buf);
108
109void atomisp_css_free_dis_buffer(struct atomisp_dis_buf *dis_buf);
110
111void atomisp_css_free_metadata_buffer(struct atomisp_metadata_buf
112				      *metadata_buf);
113
114int atomisp_css_get_grid_info(struct atomisp_sub_device *asd,
115			      enum ia_css_pipe_id pipe_id);
116
117int atomisp_alloc_3a_output_buf(struct atomisp_sub_device *asd);
118
119int atomisp_alloc_dis_coef_buf(struct atomisp_sub_device *asd);
120
121int atomisp_alloc_metadata_output_buf(struct atomisp_sub_device *asd);
122
123void atomisp_free_metadata_output_buf(struct atomisp_sub_device *asd);
124
125void atomisp_css_temp_pipe_to_pipe_id(struct atomisp_sub_device *asd,
126				      struct atomisp_css_event *current_event);
127
128int atomisp_css_isys_set_resolution(struct atomisp_sub_device *asd,
129				    enum atomisp_input_stream_id stream_id,
130				    struct v4l2_mbus_framefmt *ffmt,
131				    int isys_stream);
132
133void atomisp_css_isys_set_link(struct atomisp_sub_device *asd,
134			       enum atomisp_input_stream_id stream_id,
135			       int link,
136			       int isys_stream);
137
138void atomisp_css_isys_set_valid(struct atomisp_sub_device *asd,
139				enum atomisp_input_stream_id stream_id,
140				bool valid,
141				int isys_stream);
142
143void atomisp_css_isys_set_format(struct atomisp_sub_device *asd,
144				 enum atomisp_input_stream_id stream_id,
145				 enum atomisp_input_format format,
146				 int isys_stream);
147
148int atomisp_css_set_default_isys_config(struct atomisp_sub_device *asd,
149					enum atomisp_input_stream_id stream_id,
150					struct v4l2_mbus_framefmt *ffmt);
151
152void atomisp_css_isys_two_stream_cfg_update_stream1(
153    struct atomisp_sub_device *asd,
154    enum atomisp_input_stream_id stream_id,
155    enum atomisp_input_format input_format,
156    unsigned int width, unsigned int height);
157
158void atomisp_css_isys_two_stream_cfg_update_stream2(
159    struct atomisp_sub_device *asd,
160    enum atomisp_input_stream_id stream_id,
161    enum atomisp_input_format input_format,
162    unsigned int width, unsigned int height);
163
164int atomisp_css_input_set_resolution(struct atomisp_sub_device *asd,
165				     enum atomisp_input_stream_id stream_id,
166				     struct v4l2_mbus_framefmt *ffmt);
167
168void atomisp_css_input_set_binning_factor(struct atomisp_sub_device *asd,
169	enum atomisp_input_stream_id stream_id,
170	unsigned int bin_factor);
171
172void atomisp_css_input_set_bayer_order(struct atomisp_sub_device *asd,
173				       enum atomisp_input_stream_id stream_id,
174				       enum ia_css_bayer_order bayer_order);
175
176void atomisp_css_input_set_format(struct atomisp_sub_device *asd,
177				  enum atomisp_input_stream_id stream_id,
178				  enum atomisp_input_format format);
179
180int atomisp_css_input_set_effective_resolution(
181    struct atomisp_sub_device *asd,
182    enum atomisp_input_stream_id stream_id,
183    unsigned int width,
184    unsigned int height);
185
186void atomisp_css_video_set_dis_envelope(struct atomisp_sub_device *asd,
187					unsigned int dvs_w, unsigned int dvs_h);
188
189void atomisp_css_input_set_two_pixels_per_clock(
190    struct atomisp_sub_device *asd,
191    bool two_ppc);
192
193void atomisp_css_enable_dz(struct atomisp_sub_device *asd, bool enable);
194
195void atomisp_css_capture_set_mode(struct atomisp_sub_device *asd,
196				  enum ia_css_capture_mode mode);
197
198void atomisp_css_input_set_mode(struct atomisp_sub_device *asd,
199				enum ia_css_input_mode mode);
200
201void atomisp_css_capture_enable_online(struct atomisp_sub_device *asd,
202				       unsigned short stream_index, bool enable);
203
204void atomisp_css_preview_enable_online(struct atomisp_sub_device *asd,
205				       unsigned short stream_index, bool enable);
206
207int atomisp_css_input_configure_port(struct atomisp_sub_device *asd,
208				     enum mipi_port_id port,
209				     unsigned int num_lanes,
210				     unsigned int timeout,
211				     unsigned int mipi_freq,
212				     enum atomisp_input_format metadata_format,
213				     unsigned int metadata_width,
214				     unsigned int metadata_height);
215
216int atomisp_create_pipes_stream(struct atomisp_sub_device *asd);
217void atomisp_destroy_pipes_stream(struct atomisp_sub_device *asd);
218
219void atomisp_css_stop(struct atomisp_sub_device *asd, bool in_reset);
220
221void atomisp_css_continuous_set_num_raw_frames(
222     struct atomisp_sub_device *asd,
223     int num_frames);
224
225int atomisp_css_copy_configure_output(struct atomisp_sub_device *asd,
226				      unsigned int stream_index,
227				      unsigned int width, unsigned int height,
228				      unsigned int padded_width,
229				      enum ia_css_frame_format format);
230
231int atomisp_css_preview_configure_output(struct atomisp_sub_device *asd,
232	unsigned int width, unsigned int height,
233	unsigned int min_width,
234	enum ia_css_frame_format format);
235
236int atomisp_css_capture_configure_output(struct atomisp_sub_device *asd,
237	unsigned int width, unsigned int height,
238	unsigned int min_width,
239	enum ia_css_frame_format format);
240
241int atomisp_css_video_configure_output(struct atomisp_sub_device *asd,
242				       unsigned int width, unsigned int height,
243				       unsigned int min_width,
244				       enum ia_css_frame_format format);
245
246int atomisp_get_css_frame_info(struct atomisp_sub_device *asd,
247			       struct ia_css_frame_info *frame_info);
248
249int atomisp_css_video_configure_viewfinder(struct atomisp_sub_device *asd,
250	unsigned int width, unsigned int height,
251	unsigned int min_width,
252	enum ia_css_frame_format format);
253
254int atomisp_css_capture_configure_viewfinder(
255    struct atomisp_sub_device *asd,
256    unsigned int width, unsigned int height,
257    unsigned int min_width,
258    enum ia_css_frame_format format);
259
260int atomisp_css_video_get_viewfinder_frame_info(
261    struct atomisp_sub_device *asd,
262    struct ia_css_frame_info *info);
263
264int atomisp_css_capture_get_viewfinder_frame_info(
265    struct atomisp_sub_device *asd,
266    struct ia_css_frame_info *info);
267
268int atomisp_css_copy_get_output_frame_info(
269    struct atomisp_sub_device *asd,
270    unsigned int stream_index,
271    struct ia_css_frame_info *info);
272
273int atomisp_css_preview_get_output_frame_info(
274    struct atomisp_sub_device *asd,
275    struct ia_css_frame_info *info);
276
277int atomisp_css_capture_get_output_frame_info(
278    struct atomisp_sub_device *asd,
279    struct ia_css_frame_info *info);
280
281int atomisp_css_video_get_output_frame_info(
282    struct atomisp_sub_device *asd,
283    struct ia_css_frame_info *info);
284
285int atomisp_css_preview_configure_pp_input(
286    struct atomisp_sub_device *asd,
287    unsigned int width, unsigned int height);
288
289int atomisp_css_capture_configure_pp_input(
290    struct atomisp_sub_device *asd,
291    unsigned int width, unsigned int height);
292
293int atomisp_css_video_configure_pp_input(
294    struct atomisp_sub_device *asd,
295    unsigned int width, unsigned int height);
296
297int atomisp_css_offline_capture_configure(struct atomisp_sub_device *asd,
298	int num_captures, unsigned int skip, int offset);
299int atomisp_css_exp_id_capture(struct atomisp_sub_device *asd, int exp_id);
300int atomisp_css_exp_id_unlock(struct atomisp_sub_device *asd, int exp_id);
301
302int atomisp_css_capture_enable_xnr(struct atomisp_sub_device *asd,
303				   bool enable);
304
305void atomisp_css_set_ctc_table(struct atomisp_sub_device *asd,
306			       struct ia_css_ctc_table *ctc_table);
307
308void atomisp_css_video_set_dis_vector(struct atomisp_sub_device *asd,
309				      struct atomisp_dis_vector *vector);
310
311void atomisp_css_set_dvs2_coefs(struct atomisp_sub_device *asd,
312				struct ia_css_dvs2_coefficients *coefs);
313
314int atomisp_css_set_dis_coefs(struct atomisp_sub_device *asd,
315			      struct atomisp_dis_coefficients *coefs);
316
317void atomisp_css_set_zoom_factor(struct atomisp_sub_device *asd,
318				 unsigned int zoom);
319
320int atomisp_css_get_wb_config(struct atomisp_sub_device *asd,
321			      struct atomisp_wb_config *config);
322
323int atomisp_css_get_ob_config(struct atomisp_sub_device *asd,
324			      struct atomisp_ob_config *config);
325
326int atomisp_css_get_dp_config(struct atomisp_sub_device *asd,
327			      struct atomisp_dp_config *config);
328
329int atomisp_css_get_de_config(struct atomisp_sub_device *asd,
330			      struct atomisp_de_config *config);
331
332int atomisp_css_get_nr_config(struct atomisp_sub_device *asd,
333			      struct atomisp_nr_config *config);
334
335int atomisp_css_get_ee_config(struct atomisp_sub_device *asd,
336			      struct atomisp_ee_config *config);
337
338int atomisp_css_get_tnr_config(struct atomisp_sub_device *asd,
339			       struct atomisp_tnr_config *config);
340
341int atomisp_css_get_ctc_table(struct atomisp_sub_device *asd,
342			      struct atomisp_ctc_table *config);
343
344int atomisp_css_get_gamma_table(struct atomisp_sub_device *asd,
345				struct atomisp_gamma_table *config);
346
347int atomisp_css_get_gc_config(struct atomisp_sub_device *asd,
348			      struct atomisp_gc_config *config);
349
350int atomisp_css_get_3a_config(struct atomisp_sub_device *asd,
351			      struct atomisp_3a_config *config);
352
353int atomisp_css_get_formats_config(struct atomisp_sub_device *asd,
354				   struct atomisp_formats_config *formats_config);
355
356void atomisp_css_set_formats_config(struct atomisp_sub_device *asd,
357				    struct ia_css_formats_config *formats_config);
358
359int atomisp_css_get_zoom_factor(struct atomisp_sub_device *asd,
360				unsigned int *zoom);
361
362struct ia_css_shading_table *atomisp_css_shading_table_alloc(
363    unsigned int width, unsigned int height);
364
365void atomisp_css_set_shading_table(struct atomisp_sub_device *asd,
366				   struct ia_css_shading_table *table);
367
368void atomisp_css_shading_table_free(struct ia_css_shading_table *table);
369
370struct ia_css_morph_table *atomisp_css_morph_table_allocate(
371    unsigned int width, unsigned int height);
372
373void atomisp_css_set_morph_table(struct atomisp_sub_device *asd,
374				 struct ia_css_morph_table *table);
375
376void atomisp_css_get_morph_table(struct atomisp_sub_device *asd,
377				 struct ia_css_morph_table *table);
378
379void atomisp_css_morph_table_free(struct ia_css_morph_table *table);
380
381int atomisp_css_get_dis_stat(struct atomisp_sub_device *asd,
382			     struct atomisp_dis_statistics *stats);
383
384int atomisp_css_update_stream(struct atomisp_sub_device *asd);
385
386int atomisp_css_isr_thread(struct atomisp_device *isp);
387
388bool atomisp_css_valid_sof(struct atomisp_device *isp);
389
390void atomisp_en_dz_capt_pipe(struct atomisp_sub_device *asd, bool enable);
391
392#endif
393