]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_include/host/isp_op1w.h
Merge back PM core material for v4.16.
[mirror_ubuntu-jammy-kernel.git] / drivers / staging / media / atomisp / pci / atomisp2 / css2400 / hive_isp_css_include / host / isp_op1w.h
CommitLineData
a49d2536
AC
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 __ISP_OP1W_H_INCLUDED__
16#define __ISP_OP1W_H_INCLUDED__
17
18/*
19 * This file is part of the Multi-precision vector operations exstension package.
20 */
21
22/*
23 * Single-precision vector operations
24 */
25
26/*
27 * Prerequisites:
28 *
29 */
a49d2536
AC
30
31#ifdef INLINE_ISP_OP1W
4c5133f5
MCC
32#define STORAGE_CLASS_ISP_OP1W_FUNC_H static inline
33#define STORAGE_CLASS_ISP_OP1W_DATA_H static inline_DATA
a49d2536 34#else /* INLINE_ISP_OP1W */
4c5133f5
MCC
35#define STORAGE_CLASS_ISP_OP1W_FUNC_H extern
36#define STORAGE_CLASS_ISP_OP1W_DATA_H extern_DATA
a49d2536
AC
37#endif /* INLINE_ISP_OP1W */
38
39/*
40 * Single-precision data type specification
41 */
42
43#include "isp_op1w_types.h"
44#include "isp_op2w_types.h" // for doubling operations.
45
46/*
47 * Single-precision prototype specification
48 */
49
50/* Arithmetic */
51
d929fb4e 52/* @brief bitwise AND
a49d2536
AC
53 *
54 * @param[in] _a first argument
55 * @param[in] _b second argument
56 *
57 * @return bitwise and of both input arguments
58 *
59 * This function will calculate the bitwise and.
60 * result = _a & _b
61 */
62STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_and(
63 const tvector1w _a,
64 const tvector1w _b);
65
d929fb4e 66/* @brief bitwise OR
a49d2536
AC
67 *
68 * @param[in] _a first argument
69 * @param[in] _b second argument
70 *
71 * @return bitwise or of both input arguments
72 *
73 * This function will calculate the bitwise or.
74 * result = _a | _b
75 */
76STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_or(
77 const tvector1w _a,
78 const tvector1w _b);
79
d929fb4e 80/* @brief bitwise XOR
a49d2536
AC
81 *
82 * @param[in] _a first argument
83 * @param[in] _b second argument
84 *
85 * @return bitwise xor of both input arguments
86 *
87 * This function will calculate the bitwise xor.
88 * result = _a ^ _b
89 */
90STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_xor(
91 const tvector1w _a,
92 const tvector1w _b);
93
d929fb4e 94/* @brief bitwise inverse
a49d2536
AC
95 *
96 * @param[in] _a first argument
97 *
98 * @return bitwise inverse of both input arguments
99 *
100 * This function will calculate the bitwise inverse.
101 * result = ~_a
102 */
103STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_inv(
104 const tvector1w _a);
105
106/* Additive */
107
d929fb4e 108/* @brief addition
a49d2536
AC
109 *
110 * @param[in] _a first argument
111 * @param[in] _b second argument
112 *
113 * @return sum of both input arguments
114 *
115 * This function will calculate the sum of the input arguments.
116 * in case of overflow it will wrap around.
117 * result = _a + _b
118 */
119STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_add(
120 const tvector1w _a,
121 const tvector1w _b);
122
d929fb4e 123/* @brief subtraction
a49d2536
AC
124 *
125 * @param[in] _a first argument
126 * @param[in] _b second argument
127 *
128 * @return _b subtracted from _a.
129 *
130 * This function will subtract _b from _a.
131 * in case of overflow it will wrap around.
132 * result = _a - _b
133 */
134STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_sub(
135 const tvector1w _a,
136 const tvector1w _b);
137
d929fb4e 138/* @brief saturated addition
a49d2536
AC
139 *
140 * @param[in] _a first argument
141 * @param[in] _b second argument
142 *
143 * @return saturated sum of both input arguments
144 *
145 * This function will calculate the sum of the input arguments.
146 * in case of overflow it will saturate.
147 * result = CLIP(_a + _b, MIN_RANGE, MAX_RANGE);
148 */
149STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_addsat(
150 const tvector1w _a,
151 const tvector1w _b);
152
d929fb4e 153/* @brief saturated subtraction
a49d2536
AC
154 *
155 * @param[in] _a first argument
156 * @param[in] _b second argument
157 *
158 * @return saturated subtraction of both input arguments
159 *
160 * This function will subtract _b from _a.
161 * in case of overflow it will saturate.
162 * result = CLIP(_a - _b, MIN_RANGE, MAX_RANGE);
163 */
164STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_subsat(
165 const tvector1w _a,
166 const tvector1w _b);
167
168#ifdef ISP2401
d929fb4e 169/* @brief Unsigned saturated subtraction
a49d2536
AC
170 *
171 * @param[in] _a first argument
172 * @param[in] _b second argument
173 *
174 * @return saturated subtraction of both input arguments
175 *
176 * This function will subtract _b from _a.
177 * in case of overflow it will saturate.
178 * result = CLIP(_a - _b, 0, MAX_RANGE);
179 */
180STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w_unsigned OP_1w_subsat_u(
181 const tvector1w_unsigned _a,
182 const tvector1w_unsigned _b);
183
184#endif
d929fb4e 185/* @brief subtraction with shift right and rounding
a49d2536
AC
186 *
187 * @param[in] _a first argument
188 * @param[in] _b second argument
189 *
190 * @return (a - b) >> 1
191 *
192 * This function subtracts _b from _a and right shifts
193 * the result by 1 bit with rounding.
194 * No overflow can occur.
195 * result = (_a - _b) >> 1
196 *
197 * Note: This function will be deprecated due to
198 * the naming confusion and it will be replaced
199 * by "OP_1w_subhalfrnd".
200 */
201STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_subasr1(
202 const tvector1w _a,
203 const tvector1w _b);
204
d929fb4e 205/* @brief Subtraction with shift right and rounding
a49d2536
AC
206 *
207 * @param[in] _a first operand
208 * @param[in] _b second operand
209 *
210 * @return (_a - _b) >> 1
211 *
212 * This function subtracts _b from _a and right shifts
213 * the result by 1 bit with rounding.
214 * No overflow can occur.
215 */
216STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_subhalfrnd(
217 const tvector1w _a,
218 const tvector1w _b);
219
d929fb4e 220/* @brief Subtraction with shift right and no rounding
a49d2536
AC
221 *
222 * @param[in] _a first operand
223 * @param[in] _b second operand
224 *
225 * @return (_a - _b) >> 1
226 *
227 * This function subtracts _b from _a and right shifts
228 * the result by 1 bit without rounding (i.e. truncation).
229 * No overflow can occur.
230 */
231STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_subhalf(
232 const tvector1w _a,
233 const tvector1w _b);
234
235
d929fb4e 236/* @brief saturated absolute value
a49d2536
AC
237 *
238 * @param[in] _a input
239 *
240 * @return saturated absolute value of the input
241 *
242 * This function will calculate the saturated absolute value of the input.
243 * in case of overflow it will saturate.
244 * if (_a > 0) return _a;<br>
245 * else return CLIP(-_a, MIN_RANGE, MAX_RANGE);<br>
246 */
247STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_abs(
248 const tvector1w _a);
249
d929fb4e 250/* @brief saturated absolute difference
a49d2536
AC
251 *
252 * @param[in] _a first argument
253 * @param[in] _b second argument
254 *
255 * @return sat(abs(a-b));
256 *
257 * This function will calculate the saturated absolute value
258 * of the saturated difference of both inputs.
259 * result = sat(abs(sat(_a - _b)));
260 */
261STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_subabssat(
262 const tvector1w _a,
263 const tvector1w _b);
264
265/* Multiplicative */
266
d929fb4e 267/* @brief doubling multiply
a49d2536
AC
268 *
269 * @param[in] _a first argument
270 * @param[in] _b second argument
271 *
272 * @return product of _a and _b
273 *
274 * This function will calculate the product
275 * of the input arguments and returns a double
276 * precision result.
277 * No overflow can occur.
278 * result = _a * _b;
279 */
280STORAGE_CLASS_ISP_OP1W_FUNC_H tvector2w OP_1w_muld(
281 const tvector1w _a,
282 const tvector1w _b);
283
d929fb4e 284/* @brief integer multiply
a49d2536
AC
285 *
286 * @param[in] _a first argument
287 * @param[in] _b second argument
288 *
289 * @return product of _a and _b
290 *
291 * This function will calculate the product
292 * of the input arguments and returns the LSB
293 * aligned single precision result.
294 * In case of overflow it will wrap around.
295 * result = _a * _b;
296 */
297STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_mul(
298 const tvector1w _a,
299 const tvector1w _b);
300
d929fb4e 301/* @brief fractional saturating multiply
a49d2536
AC
302 *
303 * @param[in] _a first argument
304 * @param[in] _b second argument
305 *
306 * @return saturated product of _a and _b
307 *
308 * This function will calculate the fixed point
309 * product of the input arguments
310 * and returns a single precision result.
311 * In case of overflow it will saturate.
312 * FP_UNITY * FP_UNITY => FP_UNITY.
313 * result = CLIP(_a * _b >> (NUM_BITS-1), MIN_RANGE, MAX_RANGE);
314 */
315STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_qmul(
316 const tvector1w _a,
317 const tvector1w _b);
318
d929fb4e 319/* @brief fractional saturating multiply with rounding
a49d2536
AC
320 *
321 * @param[in] _a first argument
322 * @param[in] _b second argument
323 *
324 * @return product of _a and _b
325 *
326 * This function will calculate the fixed point
327 * product of the input arguments
328 * and returns a single precision result.
329 * FP_UNITY * FP_UNITY => FP_UNITY.
330 * Depending on the rounding mode of the core
331 * it will round to nearest or to nearest even.
332 * result = CLIP(_a * _b >> (NUM_BITS-1), MIN_RANGE, MAX_RANGE);
333 */
334STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_qrmul(
335 const tvector1w _a,
336 const tvector1w _b);
337
338/* Comparative */
339
d929fb4e 340/* @brief equal
a49d2536
AC
341 *
342 * @param[in] _a first argument
343 * @param[in] _b second argument
344 *
345 * @return _a == _b
346 *
347 * This function will return true if both inputs
348 * are equal, and false if not equal.
349 */
350STORAGE_CLASS_ISP_OP1W_FUNC_H tflags OP_1w_eq(
351 const tvector1w _a,
352 const tvector1w _b);
353
d929fb4e 354/* @brief not equal
a49d2536
AC
355 *
356 * @param[in] _a first argument
357 * @param[in] _b second argument
358 *
359 * @return _a != _b
360 *
361 * This function will return false if both inputs
362 * are equal, and true if not equal.
363 */
364STORAGE_CLASS_ISP_OP1W_FUNC_H tflags OP_1w_ne(
365 const tvector1w _a,
366 const tvector1w _b);
367
d929fb4e 368/* @brief less or equal
a49d2536
AC
369 *
370 * @param[in] _a first argument
371 * @param[in] _b second argument
372 *
373 * @return _a <= _b
374 *
375 * This function will return true if _a is smaller
376 * or equal than _b.
377 */
378STORAGE_CLASS_ISP_OP1W_FUNC_H tflags OP_1w_le(
379 const tvector1w _a,
380 const tvector1w _b);
381
d929fb4e 382/* @brief less then
a49d2536
AC
383 *
384 * @param[in] _a first argument
385 * @param[in] _b second argument
386 *
387 * @return _a < _b
388 *
389 * This function will return true if _a is smaller
390 * than _b.
391 */
392STORAGE_CLASS_ISP_OP1W_FUNC_H tflags OP_1w_lt(
393 const tvector1w _a,
394 const tvector1w _b);
395
d929fb4e 396/* @brief greater or equal
a49d2536
AC
397 *
398 * @param[in] _a first argument
399 * @param[in] _b second argument
400 *
401 * @return _a >= _b
402 *
403 * This function will return true if _a is greater
404 * or equal than _b.
405 */
406STORAGE_CLASS_ISP_OP1W_FUNC_H tflags OP_1w_ge(
407 const tvector1w _a,
408 const tvector1w _b);
409
d929fb4e 410/* @brief greater than
a49d2536
AC
411 *
412 * @param[in] _a first argument
413 * @param[in] _b second argument
414 *
415 * @return _a > _b
416 *
417 * This function will return true if _a is greater
418 * than _b.
419 */
420STORAGE_CLASS_ISP_OP1W_FUNC_H tflags OP_1w_gt(
421 const tvector1w _a,
422 const tvector1w _b);
423
424/* Shift */
425
d929fb4e 426/* @brief aritmetic shift right
a49d2536
AC
427 *
428 * @param[in] _a input
429 * @param[in] _b shift amount
430 *
431 * @return _a >> _b
432 *
433 * This function will shift _a with _b bits to the right,
434 * preserving the sign bit.
435 * It asserts 0 <= _b <= MAX_SHIFT_1W.
436 *
437 * The operation count for this function assumes that
438 * the shift amount is a cloned scalar input.
439 */
440STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_asr(
441 const tvector1w _a,
442 const tvector1w _b);
443
d929fb4e 444/* @brief aritmetic shift right with rounding
a49d2536
AC
445 *
446 * @param[in] _a input
447 * @param[in] _b shift amount
448 *
449 * @return _a >> _b
450 *
451 * If _b < NUM_BITS, this function will shift _a with _b bits to the right,
452 * preserving the sign bit, and depending on the rounding mode of the core
453 * it will round to nearest or to nearest even.
454 * If _b >= NUM_BITS, this function will return 0.
455 * It asserts 0 <= _b <= MAX_SHIFT_1W.
456 * The operation count for this function assumes that
457 * the shift amount is a cloned scalar input.
458 */
459STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_asrrnd(
460 const tvector1w _a,
461 const tvector1w _b);
462
d929fb4e 463/* @brief saturating arithmetic shift left
a49d2536
AC
464 *
465 * @param[in] _a input
466 * @param[in] _b shift amount
467 *
468 * @return _a << _b
469 *
470 * If _b < MAX_BITDEPTH, this function will shift _a with _b bits to the left,
471 * saturating at MIN_RANGE/MAX_RANGE in case of overflow.
472 * If _b >= MAX_BITDEPTH, this function will return MIN_RANGE if _a < 0,
473 * MAX_RANGE if _a > 0, 0 if _a == 0.
474 * (with MAX_BITDEPTH=64)
475 * It asserts 0 <= _b <= MAX_SHIFT_1W.
476 * The operation count for this function assumes that
477 * the shift amount is a cloned scalar input.
478 */
479STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_asl(
480 const tvector1w _a,
481 const tvector1w _b);
482
d929fb4e 483/* @brief saturating aritmetic shift left
a49d2536
AC
484 *
485 * @param[in] _a input
486 * @param[in] _b shift amount
487 *
488 * @return _a << _b
489 *
490 * This function is identical to OP_1w_asl( )
491 */
492STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_aslsat(
493 const tvector1w _a,
494 const tvector1w _b);
495
d929fb4e 496/* @brief logical shift left
a49d2536
AC
497 *
498 * @param[in] _a input
499 * @param[in] _b shift amount
500 *
501 * @return _a << _b
502 *
503 * This function will shift _a with _b bits to the left.
504 * It will insert zeroes on the right.
505 * It asserts 0 <= _b <= MAX_SHIFT_1W.
506 * The operation count for this function assumes that
507 * the shift amount is a cloned scalar input.
508 */
509STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_lsl(
510 const tvector1w _a,
511 const tvector1w _b);
512
d929fb4e 513/* @brief logical shift right
a49d2536
AC
514 *
515 * @param[in] _a input
516 * @param[in] _b shift amount
517 *
518 * @return _a >> _b
519 *
520 * This function will shift _a with _b bits to the right.
521 * It will insert zeroes on the left.
522 * It asserts 0 <= _b <= MAX_SHIFT_1W.
523 * The operation count for this function assumes that
524 * the shift amount is a cloned scalar input.
525 */
526STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_lsr(
527 const tvector1w _a,
528 const tvector1w _b);
529
530#ifdef ISP2401
d929fb4e 531/* @brief bidirectional saturating arithmetic shift
a49d2536
AC
532 *
533 * @param[in] _a input
534 * @param[in] _b shift amount
535 *
536 * @return _a << |_b| if _b is positive
537 * _a >> |_b| if _b is negative
538 *
539 * If _b > 0, this function will shift _a with _b bits to the left,
540 * saturating at MIN_RANGE/MAX_RANGE in case of overflow.
541 * if _b < 0, this function will shift _a with _b bits to the right.
542 * It asserts -MAX_SHIFT_1W <= _b <= MAX_SHIFT_1W.
543 * If _b = 0, it returns _a.
544 */
545STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_ashift_sat(
546 const tvector1w _a,
547 const tvector1w _b);
548
d929fb4e 549/* @brief bidirectional non-saturating arithmetic shift
a49d2536
AC
550 *
551 * @param[in] _a input
552 * @param[in] _b shift amount
553 *
554 * @return _a << |_b| if _b is positive
555 * _a >> |_b| if _b is negative
556 *
557 * If _b > 0, this function will shift _a with _b bits to the left,
558 * no saturation is performed in case of overflow.
559 * if _b < 0, this function will shift _a with _b bits to the right.
560 * It asserts -MAX_SHIFT_1W <= _b <= MAX_SHIFT_1W.
561 * If _b = 0, it returns _a.
562 */
563STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_ashift(
564 const tvector1w _a,
565 const tvector1w _b);
566
567
d929fb4e 568/* @brief bidirectional logical shift
a49d2536
AC
569 *
570 * @param[in] _a input
571 * @param[in] _b shift amount
572 *
573 * @return _a << |_b| if _b is positive
574 * _a >> |_b| if _b is negative
575 *
576 * This function will shift _a with _b bits to the left if _b is positive.
577 * This function will shift _a with _b bits to the right if _b is negative.
578 * It asserts -MAX_SHIFT_1W <= _b <= MAX_SHIFT_1W.
579 * It inserts zeros on the left or right depending on the shift direction:
580 * right or left.
581 * The operation count for this function assumes that
582 * the shift amount is a cloned scalar input.
583 */
584STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_lshift(
585 const tvector1w _a,
586 const tvector1w _b);
587
588#endif
589/* Cast */
590
d929fb4e 591/* @brief Cast from int to 1w
a49d2536
AC
592 *
593 * @param[in] _a input
594 *
595 * @return _a
596 *
597 * This function casts the input from integer type to
598 * single precision. It asserts there is no overflow.
599 *
600 */
601STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_int_cast_to_1w(
602 const int _a);
603
d929fb4e 604/* @brief Cast from 1w to int
a49d2536
AC
605 *
606 * @param[in] _a input
607 *
608 * @return _a
609 *
610 * This function casts the input from single precision type to
611 * integer, preserving value and sign.
612 *
613 */
614STORAGE_CLASS_ISP_OP1W_FUNC_H int OP_1w_cast_to_int(
615 const tvector1w _a);
616
d929fb4e 617/* @brief Cast from 1w to 2w
a49d2536
AC
618 *
619 * @param[in] _a input
620 *
621 * @return _a
622 *
623 * This function casts the input from single precision type to
624 * double precision, preserving value and sign.
625 *
626 */
627STORAGE_CLASS_ISP_OP1W_FUNC_H tvector2w OP_1w_cast_to_2w(
628 const tvector1w _a);
629
d929fb4e 630/* @brief Cast from 2w to 1w
a49d2536
AC
631 *
632 * @param[in] _a input
633 *
634 * @return _a
635 *
636 * This function casts the input from double precision type to
637 * single precision. In case of overflow it will wrap around.
638 *
639 */
640STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_2w_cast_to_1w(
641 const tvector2w _a);
642
643
d929fb4e 644/* @brief Cast from 2w to 1w with saturation
a49d2536
AC
645 *
646 * @param[in] _a input
647 *
648 * @return _a
649 *
650 * This function casts the input from double precision type to
651 * single precision after saturating it to the range of single
652 * precision.
653 *
654 */
655STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_2w_sat_cast_to_1w(
656 const tvector2w _a);
657
658/* clipping */
659
d929fb4e 660/* @brief Clip asymmetrical
a49d2536
AC
661 *
662 * @param[in] _a first argument
663 * @param[in] _b second argument
664 *
665 * @return _a clipped between ~_b and b
666 *
667 * This function will clip the first argument between
668 * (-_b - 1) and _b.
669 * It asserts _b >= 0.
670 *
671 */
672STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_clip_asym(
673 const tvector1w _a,
674 const tvector1w _b);
675
d929fb4e 676/* @brief Clip zero
a49d2536
AC
677 *
678 * @param[in] _a first argument
679 * @param[in] _b second argument
680 *
681 * @return _a clipped beteween 0 and _b
682 *
683 * This function will clip the first argument between
684 * zero and _b.
685 * It asserts _b >= 0.
686 *
687 */
688STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_clipz(
689 const tvector1w _a,
690 const tvector1w _b);
691
692/* division */
693
d929fb4e 694/* @brief Truncated division
a49d2536
AC
695 *
696 * @param[in] _a first argument
697 * @param[in] _b second argument
698 *
699 * @return trunc( _a / _b )
700 *
701 * This function will divide the first argument by
702 * the second argument, with rounding toward 0.
703 * If _b == 0 and _a < 0, the function will return MIN_RANGE.
704 * If _b == 0 and _a == 0, the function will return 0.
705 * If _b == 0 and _a > 0, the function will return MAX_RANGE.
706 */
707STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_div(
708 const tvector1w _a,
709 const tvector1w _b);
710
d929fb4e 711/* @brief Fractional saturating divide
a49d2536
AC
712 *
713 * @param[in] _a first argument
714 * @param[in] _b second argument
715 *
716 * @return _a / _b
717 *
718 * This function will perform fixed point division of
719 * the first argument by the second argument, with rounding toward 0.
720 * In case of overflow it will saturate.
721 * If _b == 0 and _a < 0, the function will return MIN_RANGE.
722 * If _b == 0 and _a == 0, the function will return 0.
723 * If _b == 0 and _a > 0, the function will return MAX_RANGE.
724 */
725STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_qdiv(
726 const tvector1w _a,
727 const tvector1w _b);
728
d929fb4e 729/* @brief Modulo
a49d2536
AC
730 *
731 * @param[in] _a first argument
732 * @param[in] _b second argument
733 *
734 * @return _a % _b
735 *
736 * This function will return the remainder r = _a - _b * trunc( _a / _b ),
737 * Note that the sign of the remainder is always equal to the sign of _a.
738 * If _b == 0 the function will return _a.
739 */
740STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_mod(
741 const tvector1w _a,
742 const tvector1w _b);
743
d929fb4e 744/* @brief Unsigned integer Square root
a49d2536
AC
745 *
746 * @param[in] _a input
747 *
748 * @return Integer square root of _a
749 *
750 * This function will calculate the Integer square root of _a
751 */
752STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w_unsigned OP_1w_sqrt_u(
753 const tvector1w_unsigned _a);
754
755/* Miscellaneous */
756
d929fb4e 757/* @brief Multiplexer
a49d2536
AC
758 *
759 * @param[in] _a first argument
760 * @param[in] _b second argument
761 * @param[in] _c condition
762 *
763 * @return _c ? _a : _b
764 *
765 * This function will return _a if the condition _c
766 * is true and _b otherwise.
767 */
768STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_mux(
769 const tvector1w _a,
770 const tvector1w _b,
771 const tflags _c);
772
d929fb4e 773/* @brief Average without rounding
a49d2536
AC
774 *
775 * @param[in] _a first operand
776 * @param[in] _b second operand
777 *
778 * @return (_a + _b) >> 1
779 *
780 * This function will add _a and _b, and right shift
781 * the result by one without rounding. No overflow
782 * will occur because addition is performed in the
783 * proper precision.
784 */
785STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_avg(
786 const tvector1w _a,
787 const tvector1w _b);
788
d929fb4e 789/* @brief Average with rounding
a49d2536
AC
790 *
791 * @param[in] _a first argument
792 * @param[in] _b second argument
793 *
794 * @return (_a + _b) >> 1
795 *
796 * This function will add _a and _b at full precision,
797 * and right shift with rounding the result with 1 bit.
798 * Depending on the rounding mode of the core
799 * it will round to nearest or to nearest even.
800 */
801STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_avgrnd(
802 const tvector1w _a,
803 const tvector1w _b);
804
d929fb4e 805/* @brief Minimum
a49d2536
AC
806 *
807 * @param[in] _a first argument
808 * @param[in] _b second argument
809 *
810 * @return (_a < _b) ? _a : _b;
811 *
812 * This function will return the smallest of both
813 * input arguments.
814 */
815STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_min(
816 const tvector1w _a,
817 const tvector1w _b);
818
d929fb4e 819/* @brief Maximum
a49d2536
AC
820 *
821 * @param[in] _a first argument
822 * @param[in] _b second argument
823 *
824 * @return (_a > _b) ? _a : _b;
825 *
826 * This function will return the largest of both
827 * input arguments.
828 */
829STORAGE_CLASS_ISP_OP1W_FUNC_H tvector1w OP_1w_max(
830 const tvector1w _a,
831 const tvector1w _b);
832
833#ifndef INLINE_ISP_OP1W
834#define STORAGE_CLASS_ISP_OP1W_FUNC_C
835#define STORAGE_CLASS_ISP_OP1W_DATA_C const
836#else /* INLINE_ISP_OP1W */
837#define STORAGE_CLASS_ISP_OP1W_FUNC_C STORAGE_CLASS_ISP_OP1W_FUNC_H
838#define STORAGE_CLASS_ISP_OP1W_DATA_C STORAGE_CLASS_ISP_OP1W_DATA_H
839#include "isp_op1w.c"
840#define ISP_OP1W_INLINED
841#endif /* INLINE_ISP_OP1W */
842
843#endif /* __ISP_OP1W_H_INCLUDED__ */
844