• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 __IA_CSS_PIPE_H__
17 #define __IA_CSS_PIPE_H__
18 
19 #include <type_support.h>
20 #include "ia_css_stream.h"
21 #include "ia_css_frame.h"
22 #include "ia_css_pipeline.h"
23 #include "ia_css_binary.h"
24 #include "sh_css_legacy.h"
25 
26 #define PIPE_ENTRY_EMPTY_TOKEN                (~0U)
27 #define PIPE_ENTRY_RESERVED_TOKEN             (0x1)
28 
29 struct ia_css_preview_settings {
30 	struct ia_css_binary copy_binary;
31 	struct ia_css_binary preview_binary;
32 	struct ia_css_binary vf_pp_binary;
33 
34 	/* 2401 only for these two - do we in fact use them for anything real */
35 	struct ia_css_frame *delay_frames[MAX_NUM_VIDEO_DELAY_FRAMES];
36 	struct ia_css_frame *tnr_frames[NUM_TNR_FRAMES];
37 
38 	struct ia_css_pipe *copy_pipe;
39 	struct ia_css_pipe *capture_pipe;
40 	struct ia_css_pipe *acc_pipe;
41 };
42 
43 #define IA_CSS_DEFAULT_PREVIEW_SETTINGS { \
44 	.copy_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
45 	.preview_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
46 	.vf_pp_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
47 }
48 
49 struct ia_css_capture_settings {
50 	struct ia_css_binary copy_binary;
51 	/* we extend primary binary to multiple stages because in ISP2.6.1
52 	 * the computation load is too high to fit in one single binary. */
53 	struct ia_css_binary primary_binary[MAX_NUM_PRIMARY_STAGES];
54 	unsigned int num_primary_stage;
55 	struct ia_css_binary pre_isp_binary;
56 	struct ia_css_binary anr_gdc_binary;
57 	struct ia_css_binary post_isp_binary;
58 	struct ia_css_binary capture_pp_binary;
59 	struct ia_css_binary vf_pp_binary;
60 	struct ia_css_binary capture_ldc_binary;
61 	struct ia_css_binary *yuv_scaler_binary;
62 	struct ia_css_frame *delay_frames[MAX_NUM_VIDEO_DELAY_FRAMES];
63 	bool *is_output_stage;
64 	unsigned int num_yuv_scaler;
65 };
66 
67 #define IA_CSS_DEFAULT_CAPTURE_SETTINGS { \
68 	.copy_binary		= IA_CSS_BINARY_DEFAULT_SETTINGS, \
69 	.primary_binary		= {IA_CSS_BINARY_DEFAULT_SETTINGS}, \
70 	.pre_isp_binary		= IA_CSS_BINARY_DEFAULT_SETTINGS, \
71 	.anr_gdc_binary		= IA_CSS_BINARY_DEFAULT_SETTINGS, \
72 	.post_isp_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
73 	.capture_pp_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
74 	.vf_pp_binary		= IA_CSS_BINARY_DEFAULT_SETTINGS, \
75 	.capture_ldc_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
76 }
77 
78 struct ia_css_video_settings {
79 	struct ia_css_binary copy_binary;
80 	struct ia_css_binary video_binary;
81 	struct ia_css_binary vf_pp_binary;
82 	struct ia_css_binary *yuv_scaler_binary;
83 	struct ia_css_frame *delay_frames[MAX_NUM_VIDEO_DELAY_FRAMES];
84 	struct ia_css_frame *tnr_frames[NUM_TNR_FRAMES];
85 	struct ia_css_frame *vf_pp_in_frame;
86 	struct ia_css_pipe *copy_pipe;
87 	struct ia_css_pipe *capture_pipe;
88 	bool *is_output_stage;
89 	unsigned int num_yuv_scaler;
90 };
91 
92 #define IA_CSS_DEFAULT_VIDEO_SETTINGS { \
93 	.copy_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
94 	.video_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
95 	.vf_pp_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
96 }
97 
98 struct ia_css_yuvpp_settings {
99 	struct ia_css_binary copy_binary;
100 	struct ia_css_binary *yuv_scaler_binary;
101 	struct ia_css_binary *vf_pp_binary;
102 	bool *is_output_stage;
103 	unsigned int num_yuv_scaler;
104 	unsigned int num_vf_pp;
105 	unsigned int num_output;
106 };
107 
108 #define IA_CSS_DEFAULT_YUVPP_SETTINGS { \
109 	.copy_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
110 }
111 
112 struct osys_object;
113 
114 struct ia_css_pipe {
115 	/* TODO: Remove stop_requested and use stop_requested in the pipeline */
116 	bool                            stop_requested;
117 	struct ia_css_pipe_config       config;
118 	struct ia_css_pipe_extra_config extra_config;
119 	struct ia_css_pipe_info         info;
120 	enum ia_css_pipe_id		mode;
121 	struct ia_css_shading_table	*shading_table;
122 	struct ia_css_pipeline		pipeline;
123 	struct ia_css_frame_info	output_info[IA_CSS_PIPE_MAX_OUTPUT_STAGE];
124 	struct ia_css_frame_info	bds_output_info;
125 	struct ia_css_frame_info	vf_output_info[IA_CSS_PIPE_MAX_OUTPUT_STAGE];
126 	struct ia_css_frame_info	out_yuv_ds_input_info;
127 	struct ia_css_frame_info	vf_yuv_ds_input_info;
128 	struct ia_css_fw_info		*output_stage;	/* extra output stage */
129 	struct ia_css_fw_info		*vf_stage;	/* extra vf_stage */
130 	unsigned int			required_bds_factor;
131 	unsigned int			dvs_frame_delay;
132 	int				num_invalid_frames;
133 	bool				enable_viewfinder[IA_CSS_PIPE_MAX_OUTPUT_STAGE];
134 	struct ia_css_stream		*stream;
135 	struct ia_css_frame		in_frame_struct;
136 	struct ia_css_frame		out_frame_struct;
137 	struct ia_css_frame		vf_frame_struct;
138 	struct ia_css_frame		*continuous_frames[NUM_CONTINUOUS_FRAMES];
139 	struct ia_css_metadata	*cont_md_buffers[NUM_CONTINUOUS_FRAMES];
140 	union {
141 		struct ia_css_preview_settings preview;
142 		struct ia_css_video_settings   video;
143 		struct ia_css_capture_settings capture;
144 		struct ia_css_yuvpp_settings yuvpp;
145 	} pipe_settings;
146 	ia_css_ptr scaler_pp_lut;
147 	struct osys_object *osys_obj;
148 
149 	/* This number is unique per pipe each instance of css. This number is
150 	 * reused as pipeline number also. There is a 1-1 mapping between pipe_num
151 	 * and sp thread id. Current logic limits pipe_num to
152 	 * SH_CSS_MAX_SP_THREADS */
153 	unsigned int pipe_num;
154 };
155 
156 #define IA_CSS_DEFAULT_PIPE { \
157 	.config			= DEFAULT_PIPE_CONFIG, \
158 	.info			= DEFAULT_PIPE_INFO, \
159 	.mode			= IA_CSS_PIPE_ID_ACC, /* (pipe_id) */ \
160 	.pipeline		= DEFAULT_PIPELINE, \
161 	.output_info		= {IA_CSS_BINARY_DEFAULT_FRAME_INFO}, \
162 	.bds_output_info	= IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
163 	.vf_output_info		= {IA_CSS_BINARY_DEFAULT_FRAME_INFO}, \
164 	.out_yuv_ds_input_info	= IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
165 	.vf_yuv_ds_input_info	= IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
166 	.required_bds_factor	= SH_CSS_BDS_FACTOR_1_00, \
167 	.dvs_frame_delay	= 1, \
168 	.enable_viewfinder	= {true}, \
169 	.in_frame_struct	= DEFAULT_FRAME, \
170 	.out_frame_struct	= DEFAULT_FRAME, \
171 	.vf_frame_struct	= DEFAULT_FRAME, \
172 	.pipe_settings		= { \
173 		.preview = IA_CSS_DEFAULT_PREVIEW_SETTINGS \
174 	}, \
175 	.pipe_num		= PIPE_ENTRY_EMPTY_TOKEN, \
176 }
177 
178 void ia_css_pipe_map_queue(struct ia_css_pipe *pipe, bool map);
179 
180 int
181 sh_css_param_update_isp_params(struct ia_css_pipe *curr_pipe,
182 			       struct ia_css_isp_parameters *params,
183 			       bool commit, struct ia_css_pipe *pipe);
184 
185 #endif /* __IA_CSS_PIPE_H__ */
186