Commit 196e76e8 authored by David Rowe's avatar David Rowe Committed by Greg Kroah-Hartman

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: default avatarDavid Rowe <david@rowetel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent a3c0f0aa
TODO: 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 Please send patches to Greg Kroah-Hartman <greg@kroah.com> and Cc: Steve
Underwood <steveu@coppice.org> and David Rowe <david@rowetel.com> Underwood <steveu@coppice.org> and David Rowe <david@rowetel.com>
...@@ -106,7 +106,6 @@ ...@@ -106,7 +106,6 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/slab.h> #include <linux/slab.h>
#include "bit_operations.h"
#include "echo.h" #include "echo.h"
#define MIN_TX_POWER_FOR_ADAPTION 64 #define MIN_TX_POWER_FOR_ADAPTION 64
...@@ -221,6 +220,14 @@ static inline void lms_adapt_bg(struct oslec_state *ec, int clean, ...@@ -221,6 +220,14 @@ static inline void lms_adapt_bg(struct oslec_state *ec, int clean,
} }
#endif #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 *oslec_create(int len, int adaption_mode)
{ {
struct oslec_state *ec; struct oslec_state *ec;
...@@ -347,7 +354,7 @@ int16_t oslec_update(struct oslec_state *ec, int16_t tx, int16_t rx) ...@@ -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 * 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 * 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 * need this, but something like a $10 X100P card does. Any DC really
* slows down convergence. * slows down convergence.
* *
...@@ -361,7 +368,7 @@ int16_t oslec_update(struct oslec_state *ec, int16_t tx, int16_t rx) ...@@ -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) { if (ec->adaption_mode & ECHO_CAN_USE_RX_HPF) {
tmp = rx << 15; tmp = rx << 15;
#if 1
/* /*
* Make sure the gain of the HPF is 1.0. This can still * Make sure the gain of the HPF is 1.0. This can still
* saturate a little under impulse conditions, and it might * 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) ...@@ -371,7 +378,7 @@ int16_t oslec_update(struct oslec_state *ec, int16_t tx, int16_t rx)
* the downstream processing. * the downstream processing.
*/ */
tmp -= (tmp >> 4); tmp -= (tmp >> 4);
#endif
ec->rx_1 += -(ec->rx_1 >> DC_LOG2BETA) + tmp - ec->rx_2; ec->rx_1 += -(ec->rx_1 >> DC_LOG2BETA) + tmp - ec->rx_2;
/* /*
...@@ -624,7 +631,7 @@ int16_t oslec_hpf_tx(struct oslec_state *ec, int16_t tx) ...@@ -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) { if (ec->adaption_mode & ECHO_CAN_USE_TX_HPF) {
tmp = tx << 15; tmp = tx << 15;
#if 1
/* /*
* Make sure the gain of the HPF is 1.0. The first can still * Make sure the gain of the HPF is 1.0. The first can still
* saturate a little under impulse conditions, and it might * 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) ...@@ -634,7 +641,7 @@ int16_t oslec_hpf_tx(struct oslec_state *ec, int16_t tx)
* the downstream processing. * the downstream processing.
*/ */
tmp -= (tmp >> 4); tmp -= (tmp >> 4);
#endif
ec->tx_1 += -(ec->tx_1 >> DC_LOG2BETA) + tmp - ec->tx_2; ec->tx_1 += -(ec->tx_1 >> DC_LOG2BETA) + tmp - ec->tx_2;
tmp1 = ec->tx_1 >> 15; tmp1 = ec->tx_1 >> 15;
if (tmp1 > 32767) if (tmp1 > 32767)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment