diff options
author | David Rowe <david@rowetel.com> | 2009-08-23 10:57:53 +0930 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-09-15 12:02:16 -0700 |
commit | 196e76e86a3a909125daff3d62f0a38761f79c66 (patch) | |
tree | f63d60199d90135583304635ad2f4559d352915f /drivers | |
parent | a3c0f0aa4f206297ea84f91ffb61c8687e23e1a4 (diff) |
Staging: echo: top bit patch
This patch removes the need for the bit_operations.h include file which
can now be deleted. It also contains some minor corrections to comments
(typos and alignment of ASCII formulas). I have also removed some #if
lines that were not necessary.
I have tested the patch using a unit test module that runs in kernel
mode and have verified that the patched code gives identical results to
the previous version using a 8000 sample input sequence. Let me know if
you want this unit test, it runs automatically when the module is
insmod-ed and outputs a go/no go result:
# insmod oslec.ko
# dmesg
[17191803.480000] oslec_test installed
[17191803.480000] Testing OSLEC with 128 taps (16 ms tail)
[17191803.496000] Oslec Unit Test PASSED! pass: 8000 fail: 0
Signed-off-by: David Rowe <david@rowetel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/echo/TODO | 2 | ||||
-rw-r--r-- | drivers/staging/echo/echo.c | 27 |
2 files changed, 18 insertions, 11 deletions
diff --git a/drivers/staging/echo/TODO b/drivers/staging/echo/TODO index 2208f342b4c..72a311a5a9c 100644 --- a/drivers/staging/echo/TODO +++ b/drivers/staging/echo/TODO @@ -1,5 +1,5 @@ TODO: - - handle bit_operations.h (merge in or make part of common code?) + - send to lkml for review Please send patches to Greg Kroah-Hartman <greg@kroah.com> and Cc: Steve Underwood <steveu@coppice.org> and David Rowe <david@rowetel.com> diff --git a/drivers/staging/echo/echo.c b/drivers/staging/echo/echo.c index d05642eec54..548365cd0a4 100644 --- a/drivers/staging/echo/echo.c +++ b/drivers/staging/echo/echo.c @@ -106,7 +106,6 @@ #include <linux/module.h> #include <linux/slab.h> -#include "bit_operations.h" #include "echo.h" #define MIN_TX_POWER_FOR_ADAPTION 64 @@ -221,6 +220,14 @@ static inline void lms_adapt_bg(struct oslec_state *ec, int clean, } #endif +static __inline__ int top_bit(unsigned int bits) +{ + if (bits == 0) + return -1; + else + return (int)fls((int32_t)bits)-1; +} + struct oslec_state *oslec_create(int len, int adaption_mode) { struct oslec_state *ec; @@ -347,7 +354,7 @@ int16_t oslec_update(struct oslec_state *ec, int16_t tx, int16_t rx) /* * Filter DC, 3dB point is 160Hz (I think), note 32 bit precision * required otherwise values do not track down to 0. Zero at DC, Pole - * at (1-Beta) only real axis. Some chip sets (like Si labs) don't + * at (1-Beta) on real axis. Some chip sets (like Si labs) don't * need this, but something like a $10 X100P card does. Any DC really * slows down convergence. * @@ -361,7 +368,7 @@ int16_t oslec_update(struct oslec_state *ec, int16_t tx, int16_t rx) if (ec->adaption_mode & ECHO_CAN_USE_RX_HPF) { tmp = rx << 15; -#if 1 + /* * Make sure the gain of the HPF is 1.0. This can still * saturate a little under impulse conditions, and it might @@ -371,7 +378,7 @@ int16_t oslec_update(struct oslec_state *ec, int16_t tx, int16_t rx) * the downstream processing. */ tmp -= (tmp >> 4); -#endif + ec->rx_1 += -(ec->rx_1 >> DC_LOG2BETA) + tmp - ec->rx_2; /* @@ -453,14 +460,14 @@ int16_t oslec_update(struct oslec_state *ec, int16_t tx, int16_t rx) therefore the scaled version of (1) is: (2^30) * f = (2^30) * Beta * clean_bg_rx/P - factor = (2^30) * Beta * clean_bg_rx/P ----- (2) + factor = (2^30) * Beta * clean_bg_rx/P ----- (2) We have chosen Beta = 0.25 by experiment, so: - factor = (2^30) * (2^-2) * clean_bg_rx/P + factor = (2^30) * (2^-2) * clean_bg_rx/P - (30 - 2 - log2(P)) - factor = clean_bg_rx 2 ----- (3) + (30 - 2 - log2(P)) + factor = clean_bg_rx 2 ----- (3) To avoid a divide we approximate log2(P) as top_bit(P), which returns the position of the highest non-zero bit in @@ -624,7 +631,7 @@ int16_t oslec_hpf_tx(struct oslec_state *ec, int16_t tx) if (ec->adaption_mode & ECHO_CAN_USE_TX_HPF) { tmp = tx << 15; -#if 1 + /* * Make sure the gain of the HPF is 1.0. The first can still * saturate a little under impulse conditions, and it might @@ -634,7 +641,7 @@ int16_t oslec_hpf_tx(struct oslec_state *ec, int16_t tx) * the downstream processing. */ tmp -= (tmp >> 4); -#endif + ec->tx_1 += -(ec->tx_1 >> DC_LOG2BETA) + tmp - ec->tx_2; tmp1 = ec->tx_1 >> 15; if (tmp1 > 32767) |