]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - drivers/staging/media/atomisp/pci/atomisp2/css2400/ia_css_dvs.h
PM / core: Use dev_pm_skip_next_resume_phases() internally
[mirror_ubuntu-jammy-kernel.git] / drivers / staging / media / atomisp / pci / atomisp2 / css2400 / ia_css_dvs.h
1 /*
2 * Support for Intel Camera Imaging ISP subsystem.
3 * Copyright (c) 2015, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 */
14
15 #ifndef __IA_CSS_DVS_H
16 #define __IA_CSS_DVS_H
17
18 /** @file
19 * This file contains types for DVS statistics
20 */
21
22 #include <type_support.h>
23 #include "ia_css_types.h"
24 #include "ia_css_err.h"
25 #include "ia_css_stream_public.h"
26
27 enum dvs_statistics_type {
28 DVS_STATISTICS,
29 DVS2_STATISTICS,
30 SKC_DVS_STATISTICS
31 };
32
33
34 /** Structure that holds DVS statistics in the ISP internal
35 * format. Use ia_css_get_dvs_statistics() to translate
36 * this to the format used on the host (DVS engine).
37 * */
38 struct ia_css_isp_dvs_statistics {
39 ia_css_ptr hor_proj;
40 ia_css_ptr ver_proj;
41 uint32_t hor_size;
42 uint32_t ver_size;
43 uint32_t exp_id; /**< see ia_css_event_public.h for more detail */
44 ia_css_ptr data_ptr; /* base pointer containing all memory */
45 uint32_t size; /* size of allocated memory in data_ptr */
46 };
47
48 /** Structure that holds SKC DVS statistics in the ISP internal
49 * format. Use ia_css_dvs_statistics_get() to translate this to
50 * the format used on the host.
51 * */
52 struct ia_css_isp_skc_dvs_statistics;
53
54
55 #define SIZE_OF_IA_CSS_ISP_DVS_STATISTICS_STRUCT \
56 ((3 * SIZE_OF_IA_CSS_PTR) + \
57 (4 * sizeof(uint32_t)))
58
59 /* Map with host-side pointers to ISP-format statistics.
60 * These pointers can either be copies of ISP data or memory mapped
61 * ISP pointers.
62 * All of the data behind these pointers is allocatd contiguously, the
63 * allocated pointer is stored in the data_ptr field. The other fields
64 * point into this one block of data.
65 */
66 struct ia_css_isp_dvs_statistics_map {
67 void *data_ptr;
68 int32_t *hor_proj;
69 int32_t *ver_proj;
70 uint32_t size; /* total size in bytes */
71 uint32_t data_allocated; /* indicate whether data was allocated */
72 };
73
74 union ia_css_dvs_statistics_isp {
75 struct ia_css_isp_dvs_statistics *p_dvs_statistics_isp;
76 struct ia_css_isp_skc_dvs_statistics *p_skc_dvs_statistics_isp;
77 };
78
79 union ia_css_dvs_statistics_host {
80 struct ia_css_dvs_statistics *p_dvs_statistics_host;
81 struct ia_css_dvs2_statistics *p_dvs2_statistics_host;
82 struct ia_css_skc_dvs_statistics *p_skc_dvs_statistics_host;
83 };
84
85 /** @brief Copy DVS statistics from an ISP buffer to a host buffer.
86 * @param[in] host_stats Host buffer
87 * @param[in] isp_stats ISP buffer
88 * @return error value if temporary memory cannot be allocated
89 *
90 * This may include a translation step as well depending
91 * on the ISP version.
92 * Always use this function, never copy the buffer directly.
93 * Note that this function uses the mem_load function from the CSS
94 * environment struct.
95 * In certain environments this may be slow. In those cases it is
96 * advised to map the ISP memory into a host-side pointer and use
97 * the ia_css_translate_dvs_statistics() function instead.
98 */
99 enum ia_css_err
100 ia_css_get_dvs_statistics(struct ia_css_dvs_statistics *host_stats,
101 const struct ia_css_isp_dvs_statistics *isp_stats);
102
103 /** @brief Translate DVS statistics from ISP format to host format
104 * @param[in] host_stats Host buffer
105 * @param[in] isp_stats ISP buffer
106 * @return None
107 *
108 * This function translates the dvs statistics from the ISP-internal
109 * format to the format used by the DVS library on the CPU.
110 * This function takes a host-side pointer as input. This can either
111 * point to a copy of the data or be a memory mapped pointer to the
112 * ISP memory pages.
113 */
114 void
115 ia_css_translate_dvs_statistics(
116 struct ia_css_dvs_statistics *host_stats,
117 const struct ia_css_isp_dvs_statistics_map *isp_stats);
118
119 /** @brief Copy DVS 2.0 statistics from an ISP buffer to a host buffer.
120 * @param[in] host_stats Host buffer
121 * @param[in] isp_stats ISP buffer
122 * @return error value if temporary memory cannot be allocated
123 *
124 * This may include a translation step as well depending
125 * on the ISP version.
126 * Always use this function, never copy the buffer directly.
127 * Note that this function uses the mem_load function from the CSS
128 * environment struct.
129 * In certain environments this may be slow. In those cases it is
130 * advised to map the ISP memory into a host-side pointer and use
131 * the ia_css_translate_dvs2_statistics() function instead.
132 */
133 enum ia_css_err
134 ia_css_get_dvs2_statistics(struct ia_css_dvs2_statistics *host_stats,
135 const struct ia_css_isp_dvs_statistics *isp_stats);
136
137 /** @brief Translate DVS2 statistics from ISP format to host format
138 * @param[in] host_stats Host buffer
139 * @param[in] isp_stats ISP buffer
140 * @return None
141 *
142 * This function translates the dvs2 statistics from the ISP-internal
143 * format to the format used by the DVS2 library on the CPU.
144 * This function takes a host-side pointer as input. This can either
145 * point to a copy of the data or be a memory mapped pointer to the
146 * ISP memory pages.
147 */
148 void
149 ia_css_translate_dvs2_statistics(
150 struct ia_css_dvs2_statistics *host_stats,
151 const struct ia_css_isp_dvs_statistics_map *isp_stats);
152
153 /** @brief Copy DVS statistics from an ISP buffer to a host buffer.
154 * @param[in] type - DVS statistics type
155 * @param[in] host_stats Host buffer
156 * @param[in] isp_stats ISP buffer
157 * @return None
158 */
159 void
160 ia_css_dvs_statistics_get(enum dvs_statistics_type type,
161 union ia_css_dvs_statistics_host *host_stats,
162 const union ia_css_dvs_statistics_isp *isp_stats);
163
164 /** @brief Allocate the DVS statistics memory on the ISP
165 * @param[in] grid The grid.
166 * @return Pointer to the allocated DVS statistics buffer on the ISP
167 */
168 struct ia_css_isp_dvs_statistics *
169 ia_css_isp_dvs_statistics_allocate(const struct ia_css_dvs_grid_info *grid);
170
171 /** @brief Free the DVS statistics memory on the ISP
172 * @param[in] me Pointer to the DVS statistics buffer on the ISP.
173 * @return None
174 */
175 void
176 ia_css_isp_dvs_statistics_free(struct ia_css_isp_dvs_statistics *me);
177
178 /** @brief Allocate the DVS 2.0 statistics memory
179 * @param[in] grid The grid.
180 * @return Pointer to the allocated DVS statistics buffer on the ISP
181 */
182 struct ia_css_isp_dvs_statistics *
183 ia_css_isp_dvs2_statistics_allocate(const struct ia_css_dvs_grid_info *grid);
184
185 /** @brief Free the DVS 2.0 statistics memory
186 * @param[in] me Pointer to the DVS statistics buffer on the ISP.
187 * @return None
188 */
189 void
190 ia_css_isp_dvs2_statistics_free(struct ia_css_isp_dvs_statistics *me);
191
192 /** @brief Allocate the DVS statistics memory on the host
193 * @param[in] grid The grid.
194 * @return Pointer to the allocated DVS statistics buffer on the host
195 */
196 struct ia_css_dvs_statistics *
197 ia_css_dvs_statistics_allocate(const struct ia_css_dvs_grid_info *grid);
198
199 /** @brief Free the DVS statistics memory on the host
200 * @param[in] me Pointer to the DVS statistics buffer on the host.
201 * @return None
202 */
203 void
204 ia_css_dvs_statistics_free(struct ia_css_dvs_statistics *me);
205
206 /** @brief Allocate the DVS coefficients memory
207 * @param[in] grid The grid.
208 * @return Pointer to the allocated DVS coefficients buffer
209 */
210 struct ia_css_dvs_coefficients *
211 ia_css_dvs_coefficients_allocate(const struct ia_css_dvs_grid_info *grid);
212
213 /** @brief Free the DVS coefficients memory
214 * @param[in] me Pointer to the DVS coefficients buffer.
215 * @return None
216 */
217 void
218 ia_css_dvs_coefficients_free(struct ia_css_dvs_coefficients *me);
219
220 /** @brief Allocate the DVS 2.0 statistics memory on the host
221 * @param[in] grid The grid.
222 * @return Pointer to the allocated DVS 2.0 statistics buffer on the host
223 */
224 struct ia_css_dvs2_statistics *
225 ia_css_dvs2_statistics_allocate(const struct ia_css_dvs_grid_info *grid);
226
227 /** @brief Free the DVS 2.0 statistics memory
228 * @param[in] me Pointer to the DVS 2.0 statistics buffer on the host.
229 * @return None
230 */
231 void
232 ia_css_dvs2_statistics_free(struct ia_css_dvs2_statistics *me);
233
234 /** @brief Allocate the DVS 2.0 coefficients memory
235 * @param[in] grid The grid.
236 * @return Pointer to the allocated DVS 2.0 coefficients buffer
237 */
238 struct ia_css_dvs2_coefficients *
239 ia_css_dvs2_coefficients_allocate(const struct ia_css_dvs_grid_info *grid);
240
241 /** @brief Free the DVS 2.0 coefficients memory
242 * @param[in] me Pointer to the DVS 2.0 coefficients buffer.
243 * @return None
244 */
245 void
246 ia_css_dvs2_coefficients_free(struct ia_css_dvs2_coefficients *me);
247
248 /** @brief Allocate the DVS 2.0 6-axis config memory
249 * @param[in] stream The stream.
250 * @return Pointer to the allocated DVS 6axis configuration buffer
251 */
252 struct ia_css_dvs_6axis_config *
253 ia_css_dvs2_6axis_config_allocate(const struct ia_css_stream *stream);
254
255 /** @brief Free the DVS 2.0 6-axis config memory
256 * @param[in] dvs_6axis_config Pointer to the DVS 6axis configuration buffer
257 * @return None
258 */
259 void
260 ia_css_dvs2_6axis_config_free(struct ia_css_dvs_6axis_config *dvs_6axis_config);
261
262 /** @brief Allocate a dvs statistics map structure
263 * @param[in] isp_stats pointer to ISP dvs statistis struct
264 * @param[in] data_ptr host-side pointer to ISP dvs statistics.
265 * @return Pointer to the allocated dvs statistics map
266 *
267 * This function allocates the ISP dvs statistics map structure
268 * and uses the data_ptr as base pointer to set the appropriate
269 * pointers to all relevant subsets of the dvs statistics (dmem,
270 * vmem, hmem).
271 * If the data_ptr is NULL, this function will allocate the host-side
272 * memory. This information is stored in the struct and used in the
273 * ia_css_isp_dvs_statistics_map_free() function to determine whether
274 * the memory should be freed or not.
275 * Note that this function does not allocate or map any ISP
276 * memory.
277 */
278 struct ia_css_isp_dvs_statistics_map *
279 ia_css_isp_dvs_statistics_map_allocate(
280 const struct ia_css_isp_dvs_statistics *isp_stats,
281 void *data_ptr);
282
283 /** @brief Free the dvs statistics map
284 * @param[in] me Pointer to the dvs statistics map
285 * @return None
286 *
287 * This function frees the map struct. If the data_ptr inside it
288 * was allocated inside ia_css_isp_dvs_statistics_map_allocate(), it
289 * will be freed in this function. Otherwise it will not be freed.
290 */
291 void
292 ia_css_isp_dvs_statistics_map_free(struct ia_css_isp_dvs_statistics_map *me);
293
294 /** @brief Allocate memory for the SKC DVS statistics on the ISP
295 * @return Pointer to the allocated ACC DVS statistics buffer on the ISP
296 */
297 struct ia_css_isp_skc_dvs_statistics *ia_css_skc_dvs_statistics_allocate(void);
298
299 #endif /* __IA_CSS_DVS_H */