GNU Linux-libre 4.14.332-gnu1
[releases.git] / drivers / staging / media / atomisp / pci / atomisp2 / css2400 / sh_css_sp.h
1 /*
2  * Support for Intel Camera Imaging ISP subsystem.
3  * Copyright (c) 2015, Intel Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms and conditions of the GNU General Public License,
7  * version 2, as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12  * more details.
13  */
14
15 #ifndef _SH_CSS_SP_H_
16 #define _SH_CSS_SP_H_
17
18 #include <system_global.h>
19 #include <type_support.h>
20 #if !defined(HAS_NO_INPUT_FORMATTER)
21 #include "input_formatter.h"
22 #endif
23
24 #include "ia_css_binary.h"
25 #include "ia_css_types.h"
26 #include "ia_css_pipeline.h"
27
28 /* Function to initialize the data and bss section descr of the binary */
29 void
30 sh_css_sp_store_init_dmem(const struct ia_css_fw_info *fw);
31
32 void
33 store_sp_stage_data(enum ia_css_pipe_id id, unsigned int pipe_num, unsigned stage);
34
35 void
36 sh_css_stage_write_binary_info(struct ia_css_binary_info *info);
37
38 void
39 store_sp_group_data(void);
40
41 /* Start binary (jpeg) copy on the SP */
42 void
43 sh_css_sp_start_binary_copy(unsigned int pipe_num, struct ia_css_frame *out_frame,
44                             unsigned two_ppc);
45
46 unsigned int
47 sh_css_sp_get_binary_copy_size(void);
48
49 /* Return the value of a SW interrupt */
50 unsigned int
51 sh_css_sp_get_sw_interrupt_value(unsigned int irq);
52
53 void
54 sh_css_sp_init_pipeline(struct ia_css_pipeline *me,
55                         enum ia_css_pipe_id id,
56                         uint8_t pipe_num,
57                         bool xnr,
58                         bool two_ppc,
59                         bool continuous,
60                         bool offline,
61                         unsigned int required_bds_factor,
62                         enum sh_css_pipe_config_override copy_ovrd,
63                         enum ia_css_input_mode input_mode,
64                         const struct ia_css_metadata_config *md_config,
65                         const struct ia_css_metadata_info *md_info,
66 #if !defined(HAS_NO_INPUT_SYSTEM)
67                         const mipi_port_ID_t port_id
68 #endif
69 #ifdef ISP2401
70                         ,
71                         const struct ia_css_coordinate *internal_frame_origin_bqs_on_sctbl, /* Origin of internal frame
72                                                         positioned on shading table at shading correction in ISP. */
73                         const struct ia_css_isp_parameters *params
74 #endif
75                         );
76
77 void
78 sh_css_sp_uninit_pipeline(unsigned int pipe_num);
79
80 bool sh_css_write_host2sp_command(enum host2sp_commands host2sp_command);
81
82 enum host2sp_commands
83 sh_css_read_host2sp_command(void);
84
85 void
86 sh_css_init_host2sp_frame_data(void);
87
88 /**
89  * @brief Update the offline frame information in host_sp_communication.
90  *
91  * @param[in] frame_num The offline frame number.
92  * @param[in] frame The pointer to the offline frame.
93  */
94 void
95 sh_css_update_host2sp_offline_frame(
96                                 unsigned frame_num,
97                                 struct ia_css_frame *frame,
98                                 struct ia_css_metadata *metadata);
99
100 #if defined(USE_INPUT_SYSTEM_VERSION_2) || defined(USE_INPUT_SYSTEM_VERSION_2401)
101 /**
102  * @brief Update the mipi frame information in host_sp_communication.
103  *
104  * @param[in] frame_num The mipi frame number.
105  * @param[in] frame The pointer to the mipi frame.
106  */
107 void
108 sh_css_update_host2sp_mipi_frame(
109                                 unsigned frame_num,
110                                 struct ia_css_frame *frame);
111
112 /**
113  * @brief Update the mipi metadata information in host_sp_communication.
114  *
115  * @param[in] frame_num The mipi frame number.
116  * @param[in] metadata The pointer to the mipi metadata.
117  */
118 void
119 sh_css_update_host2sp_mipi_metadata(
120                                 unsigned frame_num,
121                                 struct ia_css_metadata *metadata);
122
123 /**
124  * @brief Update the nr of mipi frames to use in host_sp_communication.
125  *
126  * @param[in] num_frames The number of mipi frames to use.
127  */
128 void
129 sh_css_update_host2sp_num_mipi_frames(unsigned num_frames);
130 #endif
131
132 /**
133  * @brief Update the nr of offline frames to use in host_sp_communication.
134  *
135  * @param[in] num_frames The number of raw frames to use.
136  */
137 void
138 sh_css_update_host2sp_cont_num_raw_frames(unsigned num_frames, bool set_avail);
139
140 void
141 sh_css_event_init_irq_mask(void);
142
143 void
144 sh_css_sp_start_isp(void);
145
146 void
147 sh_css_sp_set_sp_running(bool flag);
148
149 bool
150 sh_css_sp_is_running(void);
151
152 #if SP_DEBUG != SP_DEBUG_NONE
153
154 void
155 sh_css_sp_get_debug_state(struct sh_css_sp_debug_state *state);
156
157 #endif
158
159 #if !defined(HAS_NO_INPUT_FORMATTER)
160 void
161 sh_css_sp_set_if_configs(
162         const input_formatter_cfg_t     *config_a,
163         const input_formatter_cfg_t     *config_b,
164         const uint8_t           if_config_index);
165 #endif
166
167 void
168 sh_css_sp_program_input_circuit(int fmt_type,
169                                 int ch_id,
170                                 enum ia_css_input_mode input_mode);
171
172 void
173 sh_css_sp_configure_sync_gen(int width,
174                              int height,
175                              int hblank_cycles,
176                              int vblank_cycles);
177
178 void
179 sh_css_sp_configure_tpg(int x_mask,
180                         int y_mask,
181                         int x_delta,
182                         int y_delta,
183                         int xy_mask);
184
185 void
186 sh_css_sp_configure_prbs(int seed);
187
188 void
189 sh_css_sp_configure_enable_raw_pool_locking(bool lock_all);
190
191 void
192 sh_css_sp_enable_isys_event_queue(bool enable);
193
194 void
195 sh_css_sp_set_disable_continuous_viewfinder(bool flag);
196
197 void
198 sh_css_sp_reset_global_vars(void);
199
200 /**
201  * @brief Initialize the DMA software-mask in the debug mode.
202  * This API should be ONLY called in the debugging mode.
203  * And it should be always called before the first call of
204  * "sh_css_set_dma_sw_reg(...)".
205  *
206  * @param[in]   dma_id          The ID of the target DMA.
207  *
208  * @return
209  *      - true, if it is successful.
210  *      - false, otherwise.
211  */
212 bool
213 sh_css_sp_init_dma_sw_reg(int dma_id);
214
215 /**
216  * @brief Set the DMA software-mask in the debug mode.
217  * This API should be ONLYL called in the debugging mode. Must
218  * call "sh_css_set_dma_sw_reg(...)" before this
219  * API is called for the first time.
220  *
221  * @param[in]   dma_id          The ID of the target DMA.
222  * @param[in]   channel_id      The ID of the target DMA channel.
223  * @param[in]   request_type    The type of the DMA request.
224  *                              For example:
225  *                              - "0" indicates the writing request.
226  *                              - "1" indicates the reading request.
227  *
228  * @param[in]   enable          If it is "true", the target DMA
229  *                              channel is enabled in the software.
230  *                              Otherwise, the target DMA channel
231  *                              is disabled in the software.
232  *
233  * @return
234  *      - true, if it is successful.
235  *      - false, otherwise.
236  */
237 bool
238 sh_css_sp_set_dma_sw_reg(int dma_id,
239                 int channel_id,
240                 int request_type,
241                 bool enable);
242
243
244 extern struct sh_css_sp_group sh_css_sp_group;
245 extern struct sh_css_sp_stage sh_css_sp_stage;
246 extern struct sh_css_isp_stage sh_css_isp_stage;
247
248 #endif /* _SH_CSS_SP_H_ */