3 * Support for Intel Camera Imaging ISP subsystem.
4 * Copyright (c) 2015, Intel Corporation.
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.
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
17 Support for Intel Camera Imaging ISP subsystem.
18 Copyright (c) 2010 - 2015, Intel Corporation.
20 This program is free software; you can redistribute it and/or modify it
21 under the terms and conditions of the GNU General Public License,
22 version 2, as published by the Free Software Foundation.
24 This program is distributed in the hope it will be useful, but WITHOUT
25 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
26 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
31 #ifndef __IA_CSS_PIPELINE_H__
32 #define __IA_CSS_PIPELINE_H__
34 #include "sh_css_internal.h"
35 #include "ia_css_pipe_public.h"
36 #include "ia_css_pipeline_common.h"
38 #define IA_CSS_PIPELINE_NUM_MAX (20)
41 /* Pipeline stage to be executed on SP/ISP */
42 struct ia_css_pipeline_stage {
43 unsigned int stage_num;
44 struct ia_css_binary *binary; /* built-in binary */
45 struct ia_css_binary_info *binary_info;
46 const struct ia_css_fw_info *firmware; /* acceleration binary */
47 /* SP function for SP stage */
48 enum ia_css_pipeline_stage_sp_func sp_func;
49 unsigned max_input_width; /* For SP raw copy */
50 struct sh_css_binary_args args;
52 bool out_frame_allocated[IA_CSS_BINARY_MAX_OUTPUT_PORTS];
53 bool vf_frame_allocated;
54 struct ia_css_pipeline_stage *next;
58 /* Pipeline of n stages to be executed on SP/ISP per stage */
59 struct ia_css_pipeline {
60 enum ia_css_pipe_id pipe_id;
63 struct ia_css_pipeline_stage *stages;
64 struct ia_css_pipeline_stage *current_stage;
66 struct ia_css_frame in_frame;
67 struct ia_css_frame out_frame[IA_CSS_PIPE_MAX_OUTPUT_STAGE];
68 struct ia_css_frame vf_frame[IA_CSS_PIPE_MAX_OUTPUT_STAGE];
69 unsigned int dvs_frame_delay;
70 unsigned inout_port_config;
72 bool acquire_isp_each_stage;
73 uint32_t pipe_qos_config;
76 #define DEFAULT_PIPELINE \
78 IA_CSS_PIPE_ID_PREVIEW, /* pipe_id */ \
80 false, /* stop_requested */ \
82 NULL, /* current_stage */ \
84 DEFAULT_FRAME, /* in_frame */ \
85 {DEFAULT_FRAME}, /* out_frame */ \
86 {DEFAULT_FRAME}, /* vf_frame */ \
87 IA_CSS_FRAME_DELAY_1, /* frame_delay */ \
88 0, /* inout_port_config */ \
90 true, /* acquire_isp_each_stage */\
91 QOS_INVALID /* pipe_qos_config */\
94 /* Stage descriptor used to create a new stage in the pipeline */
95 struct ia_css_pipeline_stage_desc {
96 struct ia_css_binary *binary;
97 const struct ia_css_fw_info *firmware;
98 enum ia_css_pipeline_stage_sp_func sp_func;
99 unsigned max_input_width;
101 struct ia_css_frame *in_frame;
102 struct ia_css_frame *out_frame[IA_CSS_BINARY_MAX_OUTPUT_PORTS];
103 struct ia_css_frame *vf_frame;
106 /** @brief initialize the pipeline module
110 * Initializes the pipeline module. This API has to be called
111 * before any operation on the pipeline module is done
113 void ia_css_pipeline_init(void);
115 /** @brief initialize the pipeline structure with default values
117 * @param[out] pipeline structure to be initialized with defaults
119 * @param[in] pipe_num Number that uniquely identifies a pipeline.
120 * @return IA_CSS_SUCCESS or error code upon error.
122 * Initializes the pipeline structure with a set of default values.
123 * This API is expected to be used when a pipeline structure is allocated
124 * externally and needs sane defaults
126 enum ia_css_err ia_css_pipeline_create(
127 struct ia_css_pipeline *pipeline,
128 enum ia_css_pipe_id pipe_id,
129 unsigned int pipe_num,
130 unsigned int dvs_frame_delay);
132 /** @brief destroy a pipeline
134 * @param[in] pipeline
138 void ia_css_pipeline_destroy(struct ia_css_pipeline *pipeline);
141 /** @brief Starts a pipeline
144 * @param[in] pipeline
148 void ia_css_pipeline_start(enum ia_css_pipe_id pipe_id,
149 struct ia_css_pipeline *pipeline);
151 /** @brief Request to stop a pipeline
153 * @param[in] pipeline
154 * @return IA_CSS_SUCCESS or error code upon error.
157 enum ia_css_err ia_css_pipeline_request_stop(struct ia_css_pipeline *pipeline);
159 /** @brief Check whether pipeline has stopped
161 * @param[in] pipeline
162 * @return true if the pipeline has stopped
165 bool ia_css_pipeline_has_stopped(struct ia_css_pipeline *pipe);
167 /** @brief clean all the stages pipeline and make it as new
169 * @param[in] pipeline
173 void ia_css_pipeline_clean(struct ia_css_pipeline *pipeline);
175 /** @brief Add a stage to pipeline.
177 * @param pipeline Pointer to the pipeline to be added to.
178 * @param[in] stage_desc The description of the stage
179 * @param[out] stage The successor of the stage.
180 * @return IA_CSS_SUCCESS or error code upon error.
182 * Add a new stage to a non-NULL pipeline.
183 * The stage consists of an ISP binary or firmware and input and output
186 enum ia_css_err ia_css_pipeline_create_and_add_stage(
187 struct ia_css_pipeline *pipeline,
188 struct ia_css_pipeline_stage_desc *stage_desc,
189 struct ia_css_pipeline_stage **stage);
191 /** @brief Finalize the stages in a pipeline
193 * @param pipeline Pointer to the pipeline to be added to.
196 * This API is expected to be called after adding all stages
198 void ia_css_pipeline_finalize_stages(struct ia_css_pipeline *pipeline,
201 /** @brief gets a stage from the pipeline
203 * @param[in] pipeline
204 * @return IA_CSS_SUCCESS or error code upon error.
207 enum ia_css_err ia_css_pipeline_get_stage(struct ia_css_pipeline *pipeline,
209 struct ia_css_pipeline_stage **stage);
211 /** @brief Gets a pipeline stage corresponding Firmware handle from the pipeline
213 * @param[in] pipeline
214 * @param[in] fw_handle
215 * @param[out] stage Pointer to Stage
217 * @return IA_CSS_SUCCESS or error code upon error.
220 enum ia_css_err ia_css_pipeline_get_stage_from_fw(struct ia_css_pipeline *pipeline,
222 struct ia_css_pipeline_stage **stage);
224 /** @brief Gets the Firmware handle correponding the stage num from the pipeline
226 * @param[in] pipeline
227 * @param[in] stage_num
228 * @param[out] fw_handle
230 * @return IA_CSS_SUCCESS or error code upon error.
233 enum ia_css_err ia_css_pipeline_get_fw_from_stage(struct ia_css_pipeline *pipeline,
235 uint32_t *fw_handle);
237 /** @brief gets the output stage from the pipeline
239 * @param[in] pipeline
240 * @return IA_CSS_SUCCESS or error code upon error.
243 enum ia_css_err ia_css_pipeline_get_output_stage(
244 struct ia_css_pipeline *pipeline,
246 struct ia_css_pipeline_stage **stage);
248 /** @brief Checks whether the pipeline uses params
250 * @param[in] pipeline
251 * @return true if the pipeline uses params
254 bool ia_css_pipeline_uses_params(struct ia_css_pipeline *pipeline);
257 * @brief get the SP thread ID.
259 * @param[in] key The query key, typical use is pipe_num.
260 * @param[out] val The query value.
263 * true, if the query succeeds;
264 * false, if the query fails.
266 bool ia_css_pipeline_get_sp_thread_id(unsigned int key, unsigned int *val);
268 #if defined(USE_INPUT_SYSTEM_VERSION_2401)
270 * @brief Get the pipeline io status
274 * Pointer to pipe_io_status
276 struct sh_css_sp_pipeline_io_status *ia_css_pipeline_get_pipe_io_status(void);
280 * @brief Map an SP thread to this pipeline
282 * @param[in] pipe_num
283 * @param[in] map true for mapping and false for unmapping sp threads.
286 void ia_css_pipeline_map(unsigned int pipe_num, bool map);
289 * @brief Checks whether the pipeline is mapped to SP threads
291 * @param[in] Query key, typical use is pipe_num
294 * true, pipeline is mapped to SP threads
295 * false, pipeline is not mapped to SP threads
297 bool ia_css_pipeline_is_mapped(unsigned int key);
300 * @brief Print pipeline thread mapping
306 void ia_css_pipeline_dump_thread_map_info(void);
308 #endif /*__IA_CSS_PIPELINE_H__*/