linux/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_qmath.c

// SPDX-License-Identifier: ISC
/*
 * Copyright (c) 2010 Broadcom Corporation
 */

#include "phy_qmath.h"

/*
 * Description: This function make 16 bit unsigned multiplication.
 * To fit the output into 16 bits the 32 bit multiplication result is right
 * shifted by 16 bits.
 */
u16 qm_mulu16(u16 op1, u16 op2)
{}

/*
 * Description: This function make 16 bit multiplication and return the result
 * in 16 bits. To fit the multiplication result into 16 bits the multiplication
 * result is right shifted by 15 bits. Right shifting 15 bits instead of 16 bits
 * is done to remove the extra sign bit formed due to the multiplication.
 * When both the 16bit inputs are 0x8000 then the output is saturated to
 * 0x7fffffff.
 */
s16 qm_muls16(s16 op1, s16 op2)
{}

/*
 * Description: This function add two 32 bit numbers and return the 32bit
 * result. If the result overflow 32 bits, the output will be saturated to
 * 32bits.
 */
s32 qm_add32(s32 op1, s32 op2)
{}

/*
 * Description: This function add two 16 bit numbers and return the 16bit
 * result. If the result overflow 16 bits, the output will be saturated to
 * 16bits.
 */
s16 qm_add16(s16 op1, s16 op2)
{}

/*
 * Description: This function make 16 bit subtraction and return the 16bit
 * result. If the result overflow 16 bits, the output will be saturated to
 * 16bits.
 */
s16 qm_sub16(s16 op1, s16 op2)
{}

/*
 * Description: This function make a 32 bit saturated left shift when the
 * specified shift is +ve. This function will make a 32 bit right shift when
 * the specified shift is -ve. This function return the result after shifting
 * operation.
 */
s32 qm_shl32(s32 op, int shift)
{}

/*
 * Description: This function make a 16 bit saturated left shift when the
 * specified shift is +ve. This function will make a 16 bit right shift when
 * the specified shift is -ve. This function return the result after shifting
 * operation.
 */
s16 qm_shl16(s16 op, int shift)
{}

/*
 * Description: This function make a 16 bit right shift when shift is +ve.
 * This function make a 16 bit saturated left shift when shift is -ve. This
 * function return the result of the shift operation.
 */
s16 qm_shr16(s16 op, int shift)
{}

/*
 * Description: This function return the number of redundant sign bits in a
 * 32 bit number. Example: qm_norm32(0x00000080) = 23
 */
s16 qm_norm32(s32 op)
{}

/* This table is log2(1+(i/32)) where i=[0:1:32], in q.15 format */
static const s16 log_table[] =;

#define LOG_TABLE_SIZE
#define LOG2_LOG_TABLE_SIZE
#define Q_LOG_TABLE
#define LOG10_2

/*
 * Description:
 * This routine takes the input number N and its q format qN and compute
 * the log10(N). This routine first normalizes the input no N.	Then N is in
 * mag*(2^x) format. mag is any number in the range 2^30-(2^31 - 1).
 * Then log2(mag * 2^x) = log2(mag) + x is computed. From that
 * log10(mag * 2^x) = log2(mag * 2^x) * log10(2) is computed.
 * This routine looks the log2 value in the table considering
 * LOG2_LOG_TABLE_SIZE+1 MSBs. As the MSB is always 1, only next
 * LOG2_OF_LOG_TABLE_SIZE MSBs are used for table lookup. Next 16 MSBs are used
 * for interpolation.
 * Inputs:
 * N - number to which log10 has to be found.
 * qN - q format of N
 * log10N - address where log10(N) will be written.
 * qLog10N - address where log10N qformat will be written.
 * Note/Problem:
 * For accurate results input should be in normalized or near normalized form.
 */
void qm_log10(s32 N, s16 qN, s16 *log10N, s16 *qLog10N)
{}