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 #include "ia_css_pipe_stagedesc.h"
17 #include "assert_support.h"
18 #include "ia_css_debug.h"
19 
20 void ia_css_pipe_get_generic_stage_desc(
21     struct ia_css_pipeline_stage_desc *stage_desc,
22     struct ia_css_binary *binary,
23     struct ia_css_frame *out_frame[],
24     struct ia_css_frame *in_frame,
25     struct ia_css_frame *vf_frame)
26 {
27 	unsigned int i;
28 
29 	IA_CSS_ENTER_PRIVATE("stage_desc = %p, binary = %p, out_frame = %p, in_frame = %p, vf_frame = %p",
30 			     stage_desc, binary, out_frame, in_frame, vf_frame);
31 
32 	assert(stage_desc && binary && binary->info);
33 	if (!stage_desc || !binary || !binary->info) {
34 		IA_CSS_ERROR("invalid arguments");
35 		goto ERR;
36 	}
37 
38 	stage_desc->binary = binary;
39 	stage_desc->firmware = NULL;
40 	stage_desc->sp_func = IA_CSS_PIPELINE_NO_FUNC;
41 	stage_desc->max_input_width = 0;
42 	stage_desc->mode = binary->info->sp.pipeline.mode;
43 	stage_desc->in_frame = in_frame;
44 	for (i = 0; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++) {
45 		stage_desc->out_frame[i] = out_frame[i];
46 	}
47 	stage_desc->vf_frame = vf_frame;
48 ERR:
49 	IA_CSS_LEAVE_PRIVATE("");
50 }
51 
52 void ia_css_pipe_get_firmwares_stage_desc(
53     struct ia_css_pipeline_stage_desc *stage_desc,
54     struct ia_css_binary *binary,
55     struct ia_css_frame *out_frame[],
56     struct ia_css_frame *in_frame,
57     struct ia_css_frame *vf_frame,
58     const struct ia_css_fw_info *fw,
59     unsigned int mode)
60 {
61 	unsigned int i;
62 
63 	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE,
64 			    "ia_css_pipe_get_firmwares_stage_desc() enter:\n");
65 	stage_desc->binary = binary;
66 	stage_desc->firmware = fw;
67 	stage_desc->sp_func = IA_CSS_PIPELINE_NO_FUNC;
68 	stage_desc->max_input_width = 0;
69 	stage_desc->mode = mode;
70 	stage_desc->in_frame = in_frame;
71 	for (i = 0; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++) {
72 		stage_desc->out_frame[i] = out_frame[i];
73 	}
74 	stage_desc->vf_frame = vf_frame;
75 }
76 
77 void ia_css_pipe_get_sp_func_stage_desc(
78     struct ia_css_pipeline_stage_desc *stage_desc,
79     struct ia_css_frame *out_frame,
80     enum ia_css_pipeline_stage_sp_func sp_func,
81     unsigned int max_input_width)
82 {
83 	unsigned int i;
84 
85 	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE,
86 			    "ia_css_pipe_get_sp_func_stage_desc() enter:\n");
87 	stage_desc->binary = NULL;
88 	stage_desc->firmware = NULL;
89 	stage_desc->sp_func = sp_func;
90 	stage_desc->max_input_width = max_input_width;
91 	stage_desc->mode = (unsigned int)-1;
92 	stage_desc->in_frame = NULL;
93 	stage_desc->out_frame[0] = out_frame;
94 	for (i = 1; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++) {
95 		stage_desc->out_frame[i] = NULL;
96 	}
97 	stage_desc->vf_frame = NULL;
98 }
99