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