aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/staging/media/atomisp/pci/ia_css_pipe.h
blob: 91653952f1a76f9de2c09a4ccf6868b182a6ec50 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/*
 * Support for Intel Camera Imaging ISP subsystem.
 * Copyright (c) 2015, Intel Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 */

#ifndef __IA_CSS_PIPE_H__
#define __IA_CSS_PIPE_H__

#include <type_support.h>
#include "ia_css_stream.h"
#include "ia_css_frame.h"
#include "ia_css_pipeline.h"
#include "ia_css_binary.h"
#include "sh_css_legacy.h"

#define PIPE_ENTRY_EMPTY_TOKEN                (~0U)
#define PIPE_ENTRY_RESERVED_TOKEN             (0x1)

struct ia_css_preview_settings {
	struct ia_css_binary copy_binary;
	struct ia_css_binary preview_binary;
	struct ia_css_binary vf_pp_binary;

	/* 2401 only for these two - do we in fact use them for anything real */
	struct ia_css_frame *delay_frames[MAX_NUM_DELAY_FRAMES];
	struct ia_css_frame *tnr_frames[NUM_TNR_FRAMES];

	struct ia_css_pipe *copy_pipe;
	struct ia_css_pipe *capture_pipe;
	struct ia_css_pipe *acc_pipe;
};

#define IA_CSS_DEFAULT_PREVIEW_SETTINGS \
(struct ia_css_preview_settings) { \
	.copy_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
	.preview_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
	.vf_pp_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
}

struct ia_css_capture_settings {
	struct ia_css_binary copy_binary;
	/* we extend primary binary to multiple stages because in ISP2.6.1
	 * the computation load is too high to fit in one single binary. */
	struct ia_css_binary primary_binary[MAX_NUM_PRIMARY_STAGES];
	unsigned int num_primary_stage;
	struct ia_css_binary pre_isp_binary;
	struct ia_css_binary anr_gdc_binary;
	struct ia_css_binary post_isp_binary;
	struct ia_css_binary capture_pp_binary;
	struct ia_css_binary vf_pp_binary;
	struct ia_css_binary capture_ldc_binary;
	struct ia_css_binary *yuv_scaler_binary;
	struct ia_css_frame *delay_frames[MAX_NUM_VIDEO_DELAY_FRAMES];
	bool *is_output_stage;
	unsigned int num_yuv_scaler;
};

#define IA_CSS_DEFAULT_CAPTURE_SETTINGS \
(struct ia_css_capture_settings) { \
	.copy_binary		= IA_CSS_BINARY_DEFAULT_SETTINGS, \
	.primary_binary		= {IA_CSS_BINARY_DEFAULT_SETTINGS}, \
	.pre_isp_binary		= IA_CSS_BINARY_DEFAULT_SETTINGS, \
	.anr_gdc_binary		= IA_CSS_BINARY_DEFAULT_SETTINGS, \
	.post_isp_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
	.capture_pp_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
	.vf_pp_binary		= IA_CSS_BINARY_DEFAULT_SETTINGS, \
	.capture_ldc_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
}

struct ia_css_video_settings {
	struct ia_css_binary copy_binary;
	struct ia_css_binary video_binary;
	struct ia_css_binary vf_pp_binary;
	struct ia_css_binary *yuv_scaler_binary;
	struct ia_css_frame *delay_frames[MAX_NUM_VIDEO_DELAY_FRAMES];
	struct ia_css_frame *tnr_frames[NUM_TNR_FRAMES];
	struct ia_css_frame *vf_pp_in_frame;
	struct ia_css_pipe *copy_pipe;
	struct ia_css_pipe *capture_pipe;
	bool *is_output_stage;
	unsigned int num_yuv_scaler;
};

#define IA_CSS_DEFAULT_VIDEO_SETTINGS \
(struct ia_css_video_settings) { \
	.copy_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
	.video_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
	.vf_pp_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
}

struct ia_css_yuvpp_settings {
	struct ia_css_binary copy_binary;
	struct ia_css_binary *yuv_scaler_binary;
	struct ia_css_binary *vf_pp_binary;
	bool *is_output_stage;
	unsigned int num_yuv_scaler;
	unsigned int num_vf_pp;
	unsigned int num_output;
};

#define IA_CSS_DEFAULT_YUVPP_SETTINGS \
(struct ia_css_yuvpp_settings) { \
	.copy_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
}

struct osys_object;

struct ia_css_pipe {
	/* TODO: Remove stop_requested and use stop_requested in the pipeline */
	bool                            stop_requested;
	struct ia_css_pipe_config       config;
	struct ia_css_pipe_extra_config extra_config;
	struct ia_css_pipe_info         info;
	enum ia_css_pipe_id		mode;
	struct ia_css_shading_table	*shading_table;
	struct ia_css_pipeline		pipeline;
	struct ia_css_frame_info	output_info[IA_CSS_PIPE_MAX_OUTPUT_STAGE];
	struct ia_css_frame_info	bds_output_info;
	struct ia_css_frame_info	vf_output_info[IA_CSS_PIPE_MAX_OUTPUT_STAGE];
	struct ia_css_frame_info	out_yuv_ds_input_info;
	struct ia_css_frame_info	vf_yuv_ds_input_info;
	struct ia_css_fw_info		*output_stage;	/* extra output stage */
	struct ia_css_fw_info		*vf_stage;	/* extra vf_stage */
	unsigned int			required_bds_factor;
	unsigned int			dvs_frame_delay;
	int				num_invalid_frames;
	bool				enable_viewfinder[IA_CSS_PIPE_MAX_OUTPUT_STAGE];
	struct ia_css_stream		*stream;
	struct ia_css_frame		in_frame_struct;
	struct ia_css_frame		out_frame_struct;
	struct ia_css_frame		vf_frame_struct;
	struct ia_css_frame		*continuous_frames[NUM_CONTINUOUS_FRAMES];
	struct ia_css_metadata	*cont_md_buffers[NUM_CONTINUOUS_FRAMES];
	union {
		struct ia_css_preview_settings preview;
		struct ia_css_video_settings   video;
		struct ia_css_capture_settings capture;
		struct ia_css_yuvpp_settings yuvpp;
	} pipe_settings;
	hrt_vaddress scaler_pp_lut;
	struct osys_object *osys_obj;

	/* This number is unique per pipe each instance of css. This number is
	 * reused as pipeline number also. There is a 1-1 mapping between pipe_num
	 * and sp thread id. Current logic limits pipe_num to
	 * SH_CSS_MAX_SP_THREADS */
	unsigned int pipe_num;
};

#define IA_CSS_DEFAULT_PIPE \
(struct ia_css_pipe) { \
	.config			= DEFAULT_PIPE_CONFIG, \
	.info			= DEFAULT_PIPE_INFO, \
	.mode			= IA_CSS_PIPE_ID_ACC, /* (pipe_id) */ \
	.pipeline		= DEFAULT_PIPELINE, \
	.output_info		= {IA_CSS_BINARY_DEFAULT_FRAME_INFO}, \
	.bds_output_info	= IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
	.vf_output_info		= {IA_CSS_BINARY_DEFAULT_FRAME_INFO}, \
	.out_yuv_ds_input_info	= IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
	.vf_yuv_ds_input_info	= IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
	.required_bds_factor	= SH_CSS_BDS_FACTOR_1_00, \
	.dvs_frame_delay	= 1, \
	.enable_viewfinder	= {true}, \
	.in_frame_struct	= DEFAULT_FRAME, \
	.out_frame_struct	= DEFAULT_FRAME, \
	.vf_frame_struct	= DEFAULT_FRAME, \
	.pipe_settings		= { \
		.preview = IA_CSS_DEFAULT_PREVIEW_SETTINGS \
	}, \
	.pipe_num		= PIPE_ENTRY_EMPTY_TOKEN, \
}

void ia_css_pipe_map_queue(struct ia_css_pipe *pipe, bool map);

enum ia_css_err
sh_css_param_update_isp_params(struct ia_css_pipe *curr_pipe,
			       struct ia_css_isp_parameters *params,
			       bool commit, struct ia_css_pipe *pipe);

#endif /* __IA_CSS_PIPE_H__ */