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