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