2 * Support for Intel Camera Imaging ISP subsystem.
3 * Copyright (c) 2015, Intel Corporation.
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.
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
15 #ifndef __MPMATH_H_INCLUDED__
16 #define __MPMATH_H_INCLUDED__
18 #include "storage_class.h"
21 #define STORAGE_CLASS_MPMATH_FUNC_H STORAGE_CLASS_INLINE
22 #define STORAGE_CLASS_MPMATH_DATA_H STORAGE_CLASS_INLINE_DATA
23 #else /* INLINE_MPMATH */
24 #define STORAGE_CLASS_MPMATH_FUNC_H STORAGE_CLASS_EXTERN
25 #define STORAGE_CLASS_MPMATH_DATA_H STORAGE_CLASS_EXTERN_DATA
26 #endif /* INLINE_MPMATH */
28 #include <type_support.h>
31 * Implementation limits
33 #define MIN_BITDEPTH 1
34 #define MAX_BITDEPTH 64
36 #define ROUND_NEAREST_EVEN 0
37 #define ROUND_NEAREST 1
42 * "vector lane data" is scalar. With "scalar data" for limited range shift and address values
44 typedef unsigned long long mpudata_t; /* Type of reference MP scalar / vector lane data; unsigned */
45 typedef long long mpsdata_t; /* Type of reference MP scalar / vector lane data; signed */
46 typedef unsigned short spudata_t; /* Type of reference SP scalar / vector lane data; unsigned */
47 typedef short spsdata_t; /* Type of reference SP scalar / vector lane data; signed */
48 typedef unsigned short bitdepth_t;
62 /* _isValidMpudata is for internal use by mpmath and bbb's.
63 * isValidMpudata is for external use by functions on top.
65 #ifndef ENABLE_VALID_MP_DATA_CHECK
66 #define _isValidMpsdata(data,bitdepth) (1)
67 #define _isValidMpudata(data,bitdepth) (1)
69 #define _isValidMpsdata(data,bitdepth) isValidMpsdata(data,bitdepth)
70 #define _isValidMpudata(data,bitdepth) isValidMpsdata(data,bitdepth)
74 STORAGE_CLASS_MPMATH_FUNC_H bool isValidMpsdata(
76 const bitdepth_t bitdepth);
78 STORAGE_CLASS_MPMATH_FUNC_H bool isValidMpudata(
80 const bitdepth_t bitdepth);
82 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_castd (
84 const bitdepth_t bitdepth);
86 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_casth (
88 const bitdepth_t bitdepth);
90 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_scasth (
92 const bitdepth_t bitdepth);
94 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_qcastd (
96 const bitdepth_t bitdepth);
98 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_qcasth (
100 const bitdepth_t bitdepth);
102 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_qrcasth (
104 const bitdepth_t bitdepth);
106 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_abs (
108 const bitdepth_t bitdepth);
110 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_limit (
111 const mpsdata_t bnd_low,
113 const mpsdata_t bnd_high,
114 const bitdepth_t bitdepth);
116 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_max (
119 const bitdepth_t bitdepth);
121 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_min (
124 const bitdepth_t bitdepth);
126 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_mux (
130 const bitdepth_t bitdepth);
132 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_rmux (
136 const bitdepth_t bitdepth);
138 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_add (
141 const bitdepth_t bitdepth);
143 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_sadd (
146 const bitdepth_t bitdepth);
148 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_sub (
151 const bitdepth_t bitdepth);
153 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_ssub (
156 const bitdepth_t bitdepth);
158 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_addasr1 (
161 const bitdepth_t bitdepth);
163 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_subasr1 (
166 const bitdepth_t bitdepth);
168 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_lsr (
170 const spsdata_t shft,
171 const bitdepth_t bitdepth);
173 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_asr (
175 const spsdata_t shft,
176 const bitdepth_t bitdepth);
178 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_rasr (
180 const spsdata_t shft,
181 const bitdepth_t bitdepth);
183 /* "mp_rasr_u()" is implemented by "mp_rasr()" */
184 STORAGE_CLASS_MPMATH_FUNC_H mpudata_t mp_rasr_u (
186 const spsdata_t shft,
187 const bitdepth_t bitdepth);
189 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_lsl (
191 const spsdata_t shft,
192 const bitdepth_t bitdepth);
194 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_asl (
196 const spsdata_t shft,
197 const bitdepth_t bitdepth);
199 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_muld (
202 const bitdepth_t bitdepth);
204 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_mul (
207 const bitdepth_t bitdepth);
209 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_qmul (
212 const bitdepth_t bitdepth);
214 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_qrmul (
217 const bitdepth_t bitdepth);
219 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_qdiv (
222 const bitdepth_t bitdepth);
224 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_qdivh (
227 const bitdepth_t bitdepth);
229 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_div (
232 const bitdepth_t bitdepth);
234 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_divh (
237 const bitdepth_t bitdepth);
239 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_and (
242 const bitdepth_t bitdepth);
244 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_compl (
246 const bitdepth_t bitdepth);
248 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_or (
251 const bitdepth_t bitdepth);
253 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_xor (
256 const bitdepth_t bitdepth);
258 STORAGE_CLASS_MPMATH_FUNC_H spudata_t mp_isEQ (
261 const bitdepth_t bitdepth);
263 STORAGE_CLASS_MPMATH_FUNC_H spudata_t mp_isNE (
266 const bitdepth_t bitdepth);
268 STORAGE_CLASS_MPMATH_FUNC_H spudata_t mp_isGT (
271 const bitdepth_t bitdepth);
273 STORAGE_CLASS_MPMATH_FUNC_H spudata_t mp_isGE (
276 const bitdepth_t bitdepth);
278 STORAGE_CLASS_MPMATH_FUNC_H spudata_t mp_isLT (
281 const bitdepth_t bitdepth);
283 STORAGE_CLASS_MPMATH_FUNC_H spudata_t mp_isLE (
286 const bitdepth_t bitdepth);
288 STORAGE_CLASS_MPMATH_FUNC_H spudata_t mp_isEQZ (
290 const bitdepth_t bitdepth);
292 STORAGE_CLASS_MPMATH_FUNC_H spudata_t mp_isNEZ (
294 const bitdepth_t bitdepth);
296 STORAGE_CLASS_MPMATH_FUNC_H spudata_t mp_isGTZ (
298 const bitdepth_t bitdepth);
300 STORAGE_CLASS_MPMATH_FUNC_H spudata_t mp_isGEZ (
302 const bitdepth_t bitdepth);
304 STORAGE_CLASS_MPMATH_FUNC_H spudata_t mp_isLTZ (
306 const bitdepth_t bitdepth);
308 STORAGE_CLASS_MPMATH_FUNC_H spudata_t mp_isLEZ (
310 const bitdepth_t bitdepth);
312 STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_const (
313 const mp_const_ID_t ID,
314 const bitdepth_t bitdepth);
316 STORAGE_CLASS_MPMATH_FUNC_H mpudata_t mp_sqrt_u(
318 const bitdepth_t bitdepth);
320 #ifndef INLINE_MPMATH
321 #define STORAGE_CLASS_MPMATH_FUNC_C
322 #define STORAGE_CLASS_MPMATH_DATA_C const
323 #else /* INLINE_MPMATH */
324 #define STORAGE_CLASS_MPMATH_FUNC_C STORAGE_CLASS_MPMATH_FUNC_H
325 #define STORAGE_CLASS_MPMATH_DATA_C STORAGE_CLASS_MPMATH_DATA_H
327 #define MPMATH_INLINED
328 #endif /* INLINE_MPMATH */
330 #endif /* __MPMATH_H_INCLUDED__ */