aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_include/mpmath.h
blob: 565983aafa4d51d410364d0231d87937503078d3 (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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
/*
 * 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 __MPMATH_H_INCLUDED__
#define __MPMATH_H_INCLUDED__

#include "storage_class.h"

#ifdef INLINE_MPMATH
#define STORAGE_CLASS_MPMATH_FUNC_H STORAGE_CLASS_INLINE
#define STORAGE_CLASS_MPMATH_DATA_H STORAGE_CLASS_INLINE_DATA
#else /* INLINE_MPMATH */
#define STORAGE_CLASS_MPMATH_FUNC_H STORAGE_CLASS_EXTERN
#define STORAGE_CLASS_MPMATH_DATA_H STORAGE_CLASS_EXTERN_DATA
#endif  /* INLINE_MPMATH */

#include <type_support.h>

/*
 * Implementation limits
 */
#define MIN_BITDEPTH            1
#define MAX_BITDEPTH            64

#define ROUND_NEAREST_EVEN  0
#define ROUND_NEAREST       1

/*
 * The MP types
 *
 * "vector lane data" is scalar. With "scalar data" for limited range shift and address values
 */
typedef unsigned long long      mpudata_t;   /* Type of reference MP scalar / vector lane data; unsigned */
typedef long long               mpsdata_t;   /* Type of reference MP scalar / vector lane data; signed */
typedef unsigned short          spudata_t;   /* Type of reference SP scalar / vector lane data; unsigned */
typedef short                   spsdata_t;   /* Type of reference SP scalar / vector lane data; signed */
typedef unsigned short          bitdepth_t;

typedef enum {
    mp_zero_ID,
    mp_one_ID,
    mp_mone_ID,
    mp_smin_ID,
    mp_smax_ID,
    mp_umin_ID,
    mp_umax_ID,
    N_mp_const_ID
} mp_const_ID_t;

#ifdef ISP2401
/* _isValidMpudata is for internal use by mpmath and bbb's.
 * isValidMpudata is for external use by functions on top.
 */
#ifndef ENABLE_VALID_MP_DATA_CHECK
#define _isValidMpsdata(data,bitdepth) (1)
#define _isValidMpudata(data,bitdepth) (1)
#else
#define _isValidMpsdata(data,bitdepth) isValidMpsdata(data,bitdepth)
#define _isValidMpudata(data,bitdepth) isValidMpsdata(data,bitdepth)

#endif
#endif
STORAGE_CLASS_MPMATH_FUNC_H bool isValidMpsdata(
    const mpsdata_t             data,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H bool isValidMpudata(
    const mpudata_t             data,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_castd (
    const mpsdata_t             in0,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_casth (
    const mpsdata_t             in0,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_scasth (
    const mpsdata_t             in0,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_qcastd (
    const mpsdata_t             in0,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_qcasth (
    const mpsdata_t             in0,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_qrcasth (
    const mpsdata_t             in0,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_abs (
    const mpsdata_t             in0,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_limit (
    const mpsdata_t             bnd_low,
    const mpsdata_t             in0,
    const mpsdata_t             bnd_high,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_max (
    const mpsdata_t             in0,
    const mpsdata_t             in1,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_min (
    const mpsdata_t             in0,
    const mpsdata_t             in1,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_mux (
    const spudata_t             sel,
    const mpsdata_t             in0,
    const mpsdata_t             in1,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_rmux (
    const spudata_t             sel,
    const mpsdata_t             in0,
    const mpsdata_t             in1,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_add (
    const mpsdata_t             in0,
    const mpsdata_t             in1,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_sadd (
    const mpsdata_t             in0,
    const mpsdata_t             in1,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_sub (
    const mpsdata_t             in0,
    const mpsdata_t             in1,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_ssub (
    const mpsdata_t             in0,
    const mpsdata_t             in1,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_addasr1 (
    const mpsdata_t             in0,
    const mpsdata_t             in1,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_subasr1 (
    const mpsdata_t             in0,
    const mpsdata_t             in1,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_lsr (
    const mpsdata_t             in0,
    const spsdata_t             shft,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_asr (
    const mpsdata_t             in0,
    const spsdata_t             shft,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_rasr (
    const mpsdata_t             in0,
    const spsdata_t             shft,
    const bitdepth_t            bitdepth);

/* "mp_rasr_u()" is implemented by "mp_rasr()" */
STORAGE_CLASS_MPMATH_FUNC_H mpudata_t mp_rasr_u (
    const mpudata_t             in0,
    const spsdata_t             shft,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_lsl (
    const mpsdata_t             in0,
    const spsdata_t             shft,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_asl (
    const mpsdata_t             in0,
    const spsdata_t             shft,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_muld (
    const mpsdata_t             in0,
    const mpsdata_t             in1,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_mul (
    const mpsdata_t             in0,
    const mpsdata_t             in1,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_qmul (
    const mpsdata_t             in0,
    const mpsdata_t             in1,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_qrmul (
    const mpsdata_t             in0,
    const mpsdata_t             in1,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_qdiv (
    const mpsdata_t             in0,
    const mpsdata_t             in1,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_qdivh (
    const mpsdata_t             in0,
    const mpsdata_t             in1,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_div (
    const mpsdata_t             in0,
    const mpsdata_t             in1,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_divh (
    const mpsdata_t             in0,
    const mpsdata_t             in1,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_and (
    const mpsdata_t             in0,
    const mpsdata_t             in1,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_compl (
    const mpsdata_t             in0,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_or (
    const mpsdata_t             in0,
    const mpsdata_t             in1,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_xor (
    const mpsdata_t             in0,
    const mpsdata_t             in1,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H spudata_t mp_isEQ (
    const mpsdata_t             in0,
    const mpsdata_t             in1,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H spudata_t mp_isNE (
    const mpsdata_t             in0,
    const mpsdata_t             in1,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H spudata_t mp_isGT (
    const mpsdata_t             in0,
    const mpsdata_t             in1,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H spudata_t mp_isGE (
    const mpsdata_t             in0,
    const mpsdata_t             in1,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H spudata_t mp_isLT (
    const mpsdata_t             in0,
    const mpsdata_t             in1,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H spudata_t mp_isLE (
    const mpsdata_t             in0,
    const mpsdata_t             in1,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H spudata_t mp_isEQZ (
    const mpsdata_t             in0,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H spudata_t mp_isNEZ (
    const mpsdata_t             in0,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H spudata_t mp_isGTZ (
    const mpsdata_t             in0,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H spudata_t mp_isGEZ (
    const mpsdata_t             in0,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H spudata_t mp_isLTZ (
    const mpsdata_t             in0,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H spudata_t mp_isLEZ (
    const mpsdata_t             in0,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpsdata_t mp_const (
    const mp_const_ID_t         ID,
    const bitdepth_t            bitdepth);

STORAGE_CLASS_MPMATH_FUNC_H mpudata_t mp_sqrt_u(
	const mpudata_t     in0,
	const bitdepth_t    bitdepth);

#ifndef INLINE_MPMATH
#define STORAGE_CLASS_MPMATH_FUNC_C 
#define STORAGE_CLASS_MPMATH_DATA_C const
#else /* INLINE_MPMATH */
#define STORAGE_CLASS_MPMATH_FUNC_C STORAGE_CLASS_MPMATH_FUNC_H
#define STORAGE_CLASS_MPMATH_DATA_C STORAGE_CLASS_MPMATH_DATA_H
#include "mpmath.c"
#define MPMATH_INLINED
#endif  /* INLINE_MPMATH */

#endif /* __MPMATH_H_INCLUDED__ */