Skip to content

Commit 66534d3

Browse files
singalsukv2019i
authored andcommitted
Math: Rename square root function sqrt_int16() to sofm_sqrt_int16()
The rename is done to avoid possible conflict with other math libraries. The change is done to prepare add of 32 bit square root function. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
1 parent 6aeb834 commit 66534d3

5 files changed

Lines changed: 15 additions & 10 deletions

File tree

src/audio/tdfb/tdfb_direction.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ static inline int16_t tdfb_mic_distance_sqrt(int32_t x)
108108

109109
xs = Q_SHIFT_RND(x, 24, 12);
110110
xs = MIN(xs, UINT16_MAX);
111-
return sqrt_int16((uint16_t)xs);
111+
return sofm_sqrt_int16((uint16_t)xs);
112112
}
113113

114114
static int16_t max_mic_distance(struct tdfb_comp_data *cd)

src/include/sof/math/sqrt.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
/* SPDX-License-Identifier: BSD-3-Clause
22
*
3-
* Copyright(c) 2021 Intel Corporation. All rights reserved.
3+
* Copyright(c) 2021-2026 Intel Corporation.
44
*
55
* Author: Shriram Shastry <malladi.sastry@linux.intel.com>
66
*
77
*/
88

9-
#ifndef __SOF_MATH__SQRTLOOKUP__H
10-
#define __SOF_MATH__SQRTLOOKUP__H
9+
#ifndef __SOF_MATH_SQRT_H__
10+
#define __SOF_MATH_SQRT_H__
1111

1212
#include <stdint.h>
1313

14-
uint16_t sqrt_int16(uint16_t u);
15-
#endif
14+
/**
15+
* sofm_sqrt_int16() - Calculate 16-bit fractional square root function.
16+
* @param u Input value in Q4.12 format, from 0 to 16.0.
17+
* @return Calculated square root of n in Q4.12 format, from 0 to 4.0.
18+
*/
19+
uint16_t sofm_sqrt_int16(uint16_t u);
20+
#endif /* __SOF_MATH_SQRT_H__ */

src/math/dct.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ int mod_dct_initialize_16(struct processing_module *mod, struct dct_plan_16 *dct
5858

5959
c1 = PI_Q29 / dct->num_in;
6060
arg = Q_SHIFT_RND(TWO_Q29 / dct->num_in, 29, 12);
61-
c2 = sqrt_int16(arg); /* Q4.12 */
61+
c2 = sofm_sqrt_int16(arg); /* Q4.12 */
6262
for (n = 0; n < dct->num_in; n++) {
6363
for (k = 0; k < dct->num_out; k++) {
6464
/* Note: Current int16_t nk works up to DCT_MATRIX_SIZE_MAX = 91 */

src/math/sqrt_int16.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* Arguments : uint16_t u
3030
* Return Type : int32_t
3131
*/
32-
uint16_t sqrt_int16(uint16_t u)
32+
uint16_t sofm_sqrt_int16(uint16_t u)
3333
{
3434
static const int32_t iv1[193] = {
3535
46341, 46702, 47059, 47415, 47767, 48117, 48465, 48809, 49152, 49492, 49830, 50166,
@@ -146,4 +146,4 @@ uint16_t sqrt_int16(uint16_t u)
146146

147147
return y;
148148
}
149-
EXPORT_SYMBOL(sqrt_int16);
149+
EXPORT_SYMBOL(sofm_sqrt_int16);

test/cmocka/src/math/arithmetic/square_root.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ static void test_math_arithmetic_sqrt_fixed(void **state)
139139

140140
memcpy_s((void *)&u[0], sizeof(u), (void *)&uv[0], 252U * sizeof(uint32_t));
141141
for (i = 0; i < ARRAY_SIZE(sqrt_ref_table); i++) {
142-
y = Q_CONVERT_QTOF(sqrt_int16(u[i]), 12);
142+
y = Q_CONVERT_QTOF(sofm_sqrt_int16(u[i]), 12);
143143
diff = fabs(sqrt_ref_table[i] - y);
144144

145145
if (diff > CMP_TOLERANCE) {

0 commit comments

Comments
 (0)