1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Support for Intel Camera Imaging ISP subsystem. 4 * Copyright (c) 2010 - 2015, Intel Corporation. 5 */ 6 7 #ifndef __IA_CSS_PIPELINE_H__ 8 #define __IA_CSS_PIPELINE_H__ 9 10 #include "sh_css_internal.h" 11 #include "ia_css_pipe_public.h" 12 #include "ia_css_pipeline_common.h" 13 14 #define IA_CSS_PIPELINE_NUM_MAX (20) 15 16 /* Pipeline stage to be executed on SP/ISP */ 17 struct ia_css_pipeline_stage { 18 unsigned int stage_num; 19 struct ia_css_binary *binary; /* built-in binary */ 20 struct ia_css_binary_info *binary_info; 21 const struct ia_css_fw_info *firmware; /* acceleration binary */ 22 /* SP function for SP stage */ 23 enum ia_css_pipeline_stage_sp_func sp_func; 24 unsigned int max_input_width; /* For SP raw copy */ 25 struct sh_css_binary_args args; 26 int mode; 27 bool out_frame_allocated[IA_CSS_BINARY_MAX_OUTPUT_PORTS]; 28 bool vf_frame_allocated; 29 struct ia_css_pipeline_stage *next; 30 bool enable_zoom; 31 }; 32 33 /* Pipeline of n stages to be executed on SP/ISP per stage */ 34 struct ia_css_pipeline { 35 enum ia_css_pipe_id pipe_id; 36 u8 pipe_num; 37 bool stop_requested; 38 struct ia_css_pipeline_stage *stages; 39 struct ia_css_pipeline_stage *current_stage; 40 unsigned int num_stages; 41 struct ia_css_frame in_frame; 42 struct ia_css_frame out_frame[IA_CSS_PIPE_MAX_OUTPUT_STAGE]; 43 struct ia_css_frame vf_frame[IA_CSS_PIPE_MAX_OUTPUT_STAGE]; 44 unsigned int dvs_frame_delay; 45 unsigned int inout_port_config; 46 int num_execs; 47 bool acquire_isp_each_stage; 48 }; 49 50 #define DEFAULT_PIPELINE { \ 51 .pipe_id = IA_CSS_PIPE_ID_PREVIEW, \ 52 .in_frame = DEFAULT_FRAME, \ 53 .out_frame = {DEFAULT_FRAME}, \ 54 .vf_frame = {DEFAULT_FRAME}, \ 55 .dvs_frame_delay = IA_CSS_FRAME_DELAY_1, \ 56 .num_execs = -1, \ 57 .acquire_isp_each_stage = true, \ 58 } 59 60 /* Stage descriptor used to create a new stage in the pipeline */ 61 struct ia_css_pipeline_stage_desc { 62 struct ia_css_binary *binary; 63 const struct ia_css_fw_info *firmware; 64 enum ia_css_pipeline_stage_sp_func sp_func; 65 unsigned int max_input_width; 66 unsigned int mode; 67 struct ia_css_frame *in_frame; 68 struct ia_css_frame *out_frame[IA_CSS_BINARY_MAX_OUTPUT_PORTS]; 69 struct ia_css_frame *vf_frame; 70 }; 71 72 /* @brief initialize the pipeline module 73 * 74 * @return None 75 * 76 * Initializes the pipeline module. This API has to be called 77 * before any operation on the pipeline module is done 78 */ 79 void ia_css_pipeline_init(void); 80 81 /* @brief initialize the pipeline structure with default values 82 * 83 * @param[out] pipeline structure to be initialized with defaults 84 * @param[in] pipe_id 85 * @param[in] pipe_num Number that uniquely identifies a pipeline. 86 * @return 0 or error code upon error. 87 * 88 * Initializes the pipeline structure with a set of default values. 89 * This API is expected to be used when a pipeline structure is allocated 90 * externally and needs sane defaults 91 */ 92 int ia_css_pipeline_create( 93 struct ia_css_pipeline *pipeline, 94 enum ia_css_pipe_id pipe_id, 95 unsigned int pipe_num, 96 unsigned int dvs_frame_delay); 97 98 /* @brief destroy a pipeline 99 * 100 * @param[in] pipeline 101 * @return None 102 * 103 */ 104 void ia_css_pipeline_destroy(struct ia_css_pipeline *pipeline); 105 106 /* @brief Starts a pipeline 107 * 108 * @param[in] pipe_id 109 * @param[in] pipeline 110 * @return None 111 * 112 */ 113 void ia_css_pipeline_start(enum ia_css_pipe_id pipe_id, 114 struct ia_css_pipeline *pipeline); 115 116 /* @brief Request to stop a pipeline 117 * 118 * @param[in] pipeline 119 * @return 0 or error code upon error. 120 * 121 */ 122 int ia_css_pipeline_request_stop(struct ia_css_pipeline *pipeline); 123 124 /* @brief Check whether pipeline has stopped 125 * 126 * @param[in] pipeline 127 * @return true if the pipeline has stopped 128 * 129 */ 130 bool ia_css_pipeline_has_stopped(struct ia_css_pipeline *pipe); 131 132 /* @brief clean all the stages pipeline and make it as new 133 * 134 * @param[in] pipeline 135 * @return None 136 * 137 */ 138 void ia_css_pipeline_clean(struct ia_css_pipeline *pipeline); 139 140 /* @brief Add a stage to pipeline. 141 * 142 * @param pipeline Pointer to the pipeline to be added to. 143 * @param[in] stage_desc The description of the stage 144 * @param[out] stage The successor of the stage. 145 * @return 0 or error code upon error. 146 * 147 * Add a new stage to a non-NULL pipeline. 148 * The stage consists of an ISP binary or firmware and input and output 149 * arguments. 150 */ 151 int ia_css_pipeline_create_and_add_stage( 152 struct ia_css_pipeline *pipeline, 153 struct ia_css_pipeline_stage_desc *stage_desc, 154 struct ia_css_pipeline_stage **stage); 155 156 /* @brief Finalize the stages in a pipeline 157 * 158 * @param pipeline Pointer to the pipeline to be added to. 159 * @return None 160 * 161 * This API is expected to be called after adding all stages 162 */ 163 void ia_css_pipeline_finalize_stages(struct ia_css_pipeline *pipeline, 164 bool continuous); 165 166 /* @brief gets a stage from the pipeline 167 * 168 * @param[in] pipeline 169 * @return 0 or error code upon error. 170 * 171 */ 172 int ia_css_pipeline_get_stage(struct ia_css_pipeline *pipeline, 173 int mode, 174 struct ia_css_pipeline_stage **stage); 175 176 /* @brief Gets a pipeline stage corresponding Firmware handle from the pipeline 177 * 178 * @param[in] pipeline 179 * @param[in] fw_handle 180 * @param[out] stage Pointer to Stage 181 * 182 * @return 0 or error code upon error. 183 * 184 */ 185 int ia_css_pipeline_get_stage_from_fw(struct ia_css_pipeline 186 *pipeline, 187 u32 fw_handle, 188 struct ia_css_pipeline_stage **stage); 189 190 /* @brief Gets the Firmware handle corresponding the stage num from the pipeline 191 * 192 * @param[in] pipeline 193 * @param[in] stage_num 194 * @param[out] fw_handle 195 * 196 * @return 0 or error code upon error. 197 * 198 */ 199 int ia_css_pipeline_get_fw_from_stage(struct ia_css_pipeline 200 *pipeline, 201 u32 stage_num, 202 uint32_t *fw_handle); 203 204 /* @brief gets the output stage from the pipeline 205 * 206 * @param[in] pipeline 207 * @return 0 or error code upon error. 208 * 209 */ 210 int ia_css_pipeline_get_output_stage( 211 struct ia_css_pipeline *pipeline, 212 int mode, 213 struct ia_css_pipeline_stage **stage); 214 215 /* @brief Checks whether the pipeline uses params 216 * 217 * @param[in] pipeline 218 * @return true if the pipeline uses params 219 * 220 */ 221 bool ia_css_pipeline_uses_params(struct ia_css_pipeline *pipeline); 222 223 /** 224 * @brief get the SP thread ID. 225 * 226 * @param[in] key The query key, typical use is pipe_num. 227 * @param[out] val The query value. 228 * 229 * @return 230 * true, if the query succeeds; 231 * false, if the query fails. 232 */ 233 bool ia_css_pipeline_get_sp_thread_id(unsigned int key, unsigned int *val); 234 235 /** 236 * @brief Get the pipeline io status 237 * 238 * @param[in] None 239 * @return 240 * Pointer to pipe_io_status 241 */ 242 struct sh_css_sp_pipeline_io_status *ia_css_pipeline_get_pipe_io_status(void); 243 244 /** 245 * @brief Map an SP thread to this pipeline 246 * 247 * @param[in] pipe_num 248 * @param[in] map true for mapping and false for unmapping sp threads. 249 * 250 */ 251 void ia_css_pipeline_map(unsigned int pipe_num, bool map); 252 253 /** 254 * @brief Checks whether the pipeline is mapped to SP threads 255 * 256 * @param[in] Query key, typical use is pipe_num 257 * 258 * return 259 * true, pipeline is mapped to SP threads 260 * false, pipeline is not mapped to SP threads 261 */ 262 bool ia_css_pipeline_is_mapped(unsigned int key); 263 264 /** 265 * @brief Print pipeline thread mapping 266 * 267 * @param[in] none 268 * 269 * return none 270 */ 271 void ia_css_pipeline_dump_thread_map_info(void); 272 273 #endif /*__IA_CSS_PIPELINE_H__*/ 274