Commit dc57a3ea authored by Alexander Beregalov's avatar Alexander Beregalov Committed by Greg Kroah-Hartman

Staging: echo cleanup

before:
			errors	lines of code	errors/KLOC
drivers/staging/echo/	213		1701	125.2

after:
			errors	lines of code	errors/KLOC
drivers/staging/echo/	8		1685	4.7

Compile tested.
Signed-off-by: default avatarAlexander Beregalov <a.beregalov@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 2961f24f
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id: bit_operations.h,v 1.11 2006/11/28 15:37:03 steveu Exp $
*/ */
/*! \file */ /*! \file */
...@@ -34,7 +32,7 @@ ...@@ -34,7 +32,7 @@
/*! \brief Find the bit position of the highest set bit in a word /*! \brief Find the bit position of the highest set bit in a word
\param bits The word to be searched \param bits The word to be searched
\return The bit number of the highest set bit, or -1 if the word is zero. */ \return The bit number of the highest set bit, or -1 if the word is zero. */
static __inline__ int top_bit(unsigned int bits) static inline int top_bit(unsigned int bits)
{ {
int res; int res;
...@@ -50,7 +48,7 @@ static __inline__ int top_bit(unsigned int bits) ...@@ -50,7 +48,7 @@ static __inline__ int top_bit(unsigned int bits)
/*! \brief Find the bit position of the lowest set bit in a word /*! \brief Find the bit position of the lowest set bit in a word
\param bits The word to be searched \param bits The word to be searched
\return The bit number of the lowest set bit, or -1 if the word is zero. */ \return The bit number of the lowest set bit, or -1 if the word is zero. */
static __inline__ int bottom_bit(unsigned int bits) static inline int bottom_bit(unsigned int bits)
{ {
int res; int res;
...@@ -63,7 +61,7 @@ static __inline__ int bottom_bit(unsigned int bits) ...@@ -63,7 +61,7 @@ static __inline__ int bottom_bit(unsigned int bits)
return res; return res;
} }
#else #else
static __inline__ int top_bit(unsigned int bits) static inline int top_bit(unsigned int bits)
{ {
int i; int i;
...@@ -93,7 +91,7 @@ static __inline__ int top_bit(unsigned int bits) ...@@ -93,7 +91,7 @@ static __inline__ int top_bit(unsigned int bits)
return i; return i;
} }
static __inline__ int bottom_bit(unsigned int bits) static inline int bottom_bit(unsigned int bits)
{ {
int i; int i;
...@@ -127,7 +125,7 @@ static __inline__ int bottom_bit(unsigned int bits) ...@@ -127,7 +125,7 @@ static __inline__ int bottom_bit(unsigned int bits)
/*! \brief Bit reverse a byte. /*! \brief Bit reverse a byte.
\param data The byte to be reversed. \param data The byte to be reversed.
\return The bit reversed version of data. */ \return The bit reversed version of data. */
static __inline__ uint8_t bit_reverse8(uint8_t x) static inline uint8_t bit_reverse8(uint8_t x)
{ {
#if defined(__i386__) || defined(__x86_64__) #if defined(__i386__) || defined(__x86_64__)
/* If multiply is fast */ /* If multiply is fast */
...@@ -175,29 +173,29 @@ uint16_t make_mask16(uint16_t x); ...@@ -175,29 +173,29 @@ uint16_t make_mask16(uint16_t x);
with just that bit set. with just that bit set.
\param x The word to be searched. \param x The word to be searched.
\return The word with the single set bit. */ \return The word with the single set bit. */
static __inline__ uint32_t least_significant_one32(uint32_t x) static inline uint32_t least_significant_one32(uint32_t x)
{ {
return (x & (-(int32_t) x)); return x & (-(int32_t) x);
} }
/*! \brief Find the most significant one in a word, and return a word /*! \brief Find the most significant one in a word, and return a word
with just that bit set. with just that bit set.
\param x The word to be searched. \param x The word to be searched.
\return The word with the single set bit. */ \return The word with the single set bit. */
static __inline__ uint32_t most_significant_one32(uint32_t x) static inline uint32_t most_significant_one32(uint32_t x)
{ {
#if defined(__i386__) || defined(__x86_64__) #if defined(__i386__) || defined(__x86_64__)
return 1 << top_bit(x); return 1 << top_bit(x);
#else #else
x = make_mask32(x); x = make_mask32(x);
return (x ^ (x >> 1)); return x ^ (x >> 1);
#endif #endif
} }
/*! \brief Find the parity of a byte. /*! \brief Find the parity of a byte.
\param x The byte to be checked. \param x The byte to be checked.
\return 1 for odd, or 0 for even. */ \return 1 for odd, or 0 for even. */
static __inline__ int parity8(uint8_t x) static inline int parity8(uint8_t x)
{ {
x = (x ^ (x >> 4)) & 0x0F; x = (x ^ (x >> 4)) & 0x0F;
return (0x6996 >> x) & 1; return (0x6996 >> x) & 1;
...@@ -206,7 +204,7 @@ static __inline__ int parity8(uint8_t x) ...@@ -206,7 +204,7 @@ static __inline__ int parity8(uint8_t x)
/*! \brief Find the parity of a 16 bit word. /*! \brief Find the parity of a 16 bit word.
\param x The word to be checked. \param x The word to be checked.
\return 1 for odd, or 0 for even. */ \return 1 for odd, or 0 for even. */
static __inline__ int parity16(uint16_t x) static inline int parity16(uint16_t x)
{ {
x ^= (x >> 8); x ^= (x >> 8);
x = (x ^ (x >> 4)) & 0x0F; x = (x ^ (x >> 4)) & 0x0F;
...@@ -216,7 +214,7 @@ static __inline__ int parity16(uint16_t x) ...@@ -216,7 +214,7 @@ static __inline__ int parity16(uint16_t x)
/*! \brief Find the parity of a 32 bit word. /*! \brief Find the parity of a 32 bit word.
\param x The word to be checked. \param x The word to be checked.
\return 1 for odd, or 0 for even. */ \return 1 for odd, or 0 for even. */
static __inline__ int parity32(uint32_t x) static inline int parity32(uint32_t x)
{ {
x ^= (x >> 16); x ^= (x >> 16);
x ^= (x >> 8); x ^= (x >> 8);
......
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id: echo.c,v 1.20 2006/12/01 18:00:48 steveu Exp $
*/ */
/*! \file */ /*! \file */
...@@ -123,7 +121,7 @@ ...@@ -123,7 +121,7 @@
/* adapting coeffs using the traditional stochastic descent (N)LMS algorithm */ /* adapting coeffs using the traditional stochastic descent (N)LMS algorithm */
#ifdef __bfin__ #ifdef __bfin__
static void __inline__ lms_adapt_bg(struct oslec_state *ec, int clean, static inline void lms_adapt_bg(struct oslec_state *ec, int clean,
int shift) int shift)
{ {
int i, j; int i, j;
...@@ -147,13 +145,13 @@ static void __inline__ lms_adapt_bg(struct oslec_state *ec, int clean, ...@@ -147,13 +145,13 @@ static void __inline__ lms_adapt_bg(struct oslec_state *ec, int clean,
/* st: and en: help us locate the assembler in echo.s */ /* st: and en: help us locate the assembler in echo.s */
//asm("st:"); /* asm("st:"); */
n = ec->taps; n = ec->taps;
for (i = 0, j = offset2; i < n; i++, j++) { for (i = 0, j = offset2; i < n; i++, j++) {
exp = *phist++ * factor; exp = *phist++ * factor;
ec->fir_taps16[1][i] += (int16_t) ((exp + (1 << 14)) >> 15); ec->fir_taps16[1][i] += (int16_t) ((exp + (1 << 14)) >> 15);
} }
//asm("en:"); /* asm("en:"); */
/* Note the asm for the inner loop above generated by Blackfin gcc /* Note the asm for the inner loop above generated by Blackfin gcc
4.1.1 is pretty good (note even parallel instructions used): 4.1.1 is pretty good (note even parallel instructions used):
...@@ -195,7 +193,7 @@ static void __inline__ lms_adapt_bg(struct oslec_state *ec, int clean, ...@@ -195,7 +193,7 @@ static void __inline__ lms_adapt_bg(struct oslec_state *ec, int clean,
*/ */
#else #else
static __inline__ void lms_adapt_bg(struct oslec_state *ec, int clean, static inline void lms_adapt_bg(struct oslec_state *ec, int clean,
int shift) int shift)
{ {
int i; int i;
...@@ -249,9 +247,8 @@ struct oslec_state *oslec_create(int len, int adaption_mode) ...@@ -249,9 +247,8 @@ struct oslec_state *oslec_create(int len, int adaption_mode)
fir16_create(&ec->fir_state, ec->fir_taps16[0], ec->taps); fir16_create(&ec->fir_state, ec->fir_taps16[0], ec->taps);
fir16_create(&ec->fir_state_bg, ec->fir_taps16[1], ec->taps); fir16_create(&ec->fir_state_bg, ec->fir_taps16[1], ec->taps);
for (i = 0; i < 5; i++) { for (i = 0; i < 5; i++)
ec->xvtx[i] = ec->yvtx[i] = ec->xvrx[i] = ec->yvrx[i] = 0; ec->xvtx[i] = ec->yvtx[i] = ec->xvrx[i] = ec->yvrx[i] = 0;
}
ec->cng_level = 1000; ec->cng_level = 1000;
oslec_adaption_mode(ec, adaption_mode); oslec_adaption_mode(ec, adaption_mode);
...@@ -271,14 +268,13 @@ struct oslec_state *oslec_create(int len, int adaption_mode) ...@@ -271,14 +268,13 @@ struct oslec_state *oslec_create(int len, int adaption_mode)
return ec; return ec;
error_oom: error_oom:
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
kfree(ec->fir_taps16[i]); kfree(ec->fir_taps16[i]);
kfree(ec); kfree(ec);
return NULL; return NULL;
} }
EXPORT_SYMBOL_GPL(oslec_create); EXPORT_SYMBOL_GPL(oslec_create);
void oslec_free(struct oslec_state *ec) void oslec_free(struct oslec_state *ec)
...@@ -292,14 +288,12 @@ void oslec_free(struct oslec_state *ec) ...@@ -292,14 +288,12 @@ void oslec_free(struct oslec_state *ec)
kfree(ec->snapshot); kfree(ec->snapshot);
kfree(ec); kfree(ec);
} }
EXPORT_SYMBOL_GPL(oslec_free); EXPORT_SYMBOL_GPL(oslec_free);
void oslec_adaption_mode(struct oslec_state *ec, int adaption_mode) void oslec_adaption_mode(struct oslec_state *ec, int adaption_mode)
{ {
ec->adaption_mode = adaption_mode; ec->adaption_mode = adaption_mode;
} }
EXPORT_SYMBOL_GPL(oslec_adaption_mode); EXPORT_SYMBOL_GPL(oslec_adaption_mode);
void oslec_flush(struct oslec_state *ec) void oslec_flush(struct oslec_state *ec)
...@@ -326,14 +320,12 @@ void oslec_flush(struct oslec_state *ec) ...@@ -326,14 +320,12 @@ void oslec_flush(struct oslec_state *ec)
ec->curr_pos = ec->taps - 1; ec->curr_pos = ec->taps - 1;
ec->Pstates = 0; ec->Pstates = 0;
} }
EXPORT_SYMBOL_GPL(oslec_flush); EXPORT_SYMBOL_GPL(oslec_flush);
void oslec_snapshot(struct oslec_state *ec) void oslec_snapshot(struct oslec_state *ec)
{ {
memcpy(ec->snapshot, ec->fir_taps16[0], ec->taps * sizeof(int16_t)); memcpy(ec->snapshot, ec->fir_taps16[0], ec->taps * sizeof(int16_t));
} }
EXPORT_SYMBOL_GPL(oslec_snapshot); EXPORT_SYMBOL_GPL(oslec_snapshot);
/* Dual Path Echo Canceller ------------------------------------------------*/ /* Dual Path Echo Canceller ------------------------------------------------*/
...@@ -399,7 +391,7 @@ int16_t oslec_update(struct oslec_state *ec, int16_t tx, int16_t rx) ...@@ -399,7 +391,7 @@ int16_t oslec_update(struct oslec_state *ec, int16_t tx, int16_t rx)
/* efficient "out with the old and in with the new" algorithm so /* efficient "out with the old and in with the new" algorithm so
we don't have to recalculate over the whole block of we don't have to recalculate over the whole block of
samples. */ samples. */
new = (int)tx *(int)tx; new = (int)tx * (int)tx;
old = (int)ec->fir_state.history[ec->fir_state.curr_pos] * old = (int)ec->fir_state.history[ec->fir_state.curr_pos] *
(int)ec->fir_state.history[ec->fir_state.curr_pos]; (int)ec->fir_state.history[ec->fir_state.curr_pos];
ec->Pstates += ec->Pstates +=
...@@ -498,10 +490,10 @@ int16_t oslec_update(struct oslec_state *ec, int16_t tx, int16_t rx) ...@@ -498,10 +490,10 @@ int16_t oslec_update(struct oslec_state *ec, int16_t tx, int16_t rx)
if ((ec->adaption_mode & ECHO_CAN_USE_ADAPTION) && if ((ec->adaption_mode & ECHO_CAN_USE_ADAPTION) &&
(ec->nonupdate_dwell == 0) && (ec->nonupdate_dwell == 0) &&
(8 * ec->Lclean_bg < /* (ec->Lclean_bg < 0.875*ec->Lclean) */
7 * ec->Lclean) /* (ec->Lclean_bg < 0.875*ec->Lclean) */ && (8 * ec->Lclean_bg < 7 * ec->Lclean) &&
(8 * ec->Lclean_bg < /* (ec->Lclean_bg < 0.125*ec->Ltx) */
ec->Ltx) /* (ec->Lclean_bg < 0.125*ec->Ltx) */ ) { (8 * ec->Lclean_bg < ec->Ltx)) {
if (ec->cond_met == 6) { if (ec->cond_met == 6) {
/* BG filter has had better results for 6 consecutive samples */ /* BG filter has had better results for 6 consecutive samples */
ec->adapt = 1; ec->adapt = 1;
...@@ -580,7 +572,6 @@ int16_t oslec_update(struct oslec_state *ec, int16_t tx, int16_t rx) ...@@ -580,7 +572,6 @@ int16_t oslec_update(struct oslec_state *ec, int16_t tx, int16_t rx)
return (int16_t) ec->clean_nlp << 1; return (int16_t) ec->clean_nlp << 1;
} }
EXPORT_SYMBOL_GPL(oslec_update); EXPORT_SYMBOL_GPL(oslec_update);
/* This function is seperated from the echo canceller is it is usually called /* This function is seperated from the echo canceller is it is usually called
...@@ -604,7 +595,7 @@ EXPORT_SYMBOL_GPL(oslec_update); ...@@ -604,7 +595,7 @@ EXPORT_SYMBOL_GPL(oslec_update);
precision, which noise shapes things, giving very clean DC removal. precision, which noise shapes things, giving very clean DC removal.
*/ */
int16_t oslec_hpf_tx(struct oslec_state * ec, int16_t tx) int16_t oslec_hpf_tx(struct oslec_state *ec, int16_t tx)
{ {
int tmp, tmp1; int tmp, tmp1;
...@@ -629,7 +620,6 @@ int16_t oslec_hpf_tx(struct oslec_state * ec, int16_t tx) ...@@ -629,7 +620,6 @@ int16_t oslec_hpf_tx(struct oslec_state * ec, int16_t tx)
return tx; return tx;
} }
EXPORT_SYMBOL_GPL(oslec_hpf_tx); EXPORT_SYMBOL_GPL(oslec_hpf_tx);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
......
...@@ -23,8 +23,6 @@ ...@@ -23,8 +23,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id: echo.h,v 1.9 2006/10/24 13:45:28 steveu Exp $
*/ */
#ifndef __ECHO_H #ifndef __ECHO_H
......
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id: fir.h,v 1.8 2006/10/24 13:45:28 steveu Exp $
*/ */
/*! \page fir_page FIR filtering /*! \page fir_page FIR filtering
...@@ -102,8 +100,8 @@ struct fir_float_state_t { ...@@ -102,8 +100,8 @@ struct fir_float_state_t {
float *history; float *history;
}; };
static __inline__ const int16_t *fir16_create(struct fir16_state_t *fir, static inline const int16_t *fir16_create(struct fir16_state_t *fir,
const int16_t * coeffs, int taps) const int16_t *coeffs, int taps)
{ {
fir->taps = taps; fir->taps = taps;
fir->curr_pos = taps - 1; fir->curr_pos = taps - 1;
...@@ -116,7 +114,7 @@ static __inline__ const int16_t *fir16_create(struct fir16_state_t *fir, ...@@ -116,7 +114,7 @@ static __inline__ const int16_t *fir16_create(struct fir16_state_t *fir,
return fir->history; return fir->history;
} }
static __inline__ void fir16_flush(struct fir16_state_t *fir) static inline void fir16_flush(struct fir16_state_t *fir)
{ {
#if defined(USE_MMX) || defined(USE_SSE2) || defined(__bfin__) #if defined(USE_MMX) || defined(USE_SSE2) || defined(__bfin__)
memset(fir->history, 0, 2 * fir->taps * sizeof(int16_t)); memset(fir->history, 0, 2 * fir->taps * sizeof(int16_t));
...@@ -125,7 +123,7 @@ static __inline__ void fir16_flush(struct fir16_state_t *fir) ...@@ -125,7 +123,7 @@ static __inline__ void fir16_flush(struct fir16_state_t *fir)
#endif #endif
} }
static __inline__ void fir16_free(struct fir16_state_t *fir) static inline void fir16_free(struct fir16_state_t *fir)
{ {
kfree(fir->history); kfree(fir->history);
} }
...@@ -148,16 +146,16 @@ static inline int32_t dot_asm(short *x, short *y, int len) ...@@ -148,16 +146,16 @@ static inline int32_t dot_asm(short *x, short *y, int len)
"A0 += R0.L*R1.L (IS);\n\t" "A0 += R0.L*R1.L (IS);\n\t"
"R0 = A0;\n\t" "R0 = A0;\n\t"
"%0 = R0;\n\t" "%0 = R0;\n\t"
:"=&d"(dot) : "=&d"(dot)
:"a"(x), "a"(y), "a"(len) : "a"(x), "a"(y), "a"(len)
:"I0", "I1", "A1", "A0", "R0", "R1" : "I0", "I1", "A1", "A0", "R0", "R1"
); );
return dot; return dot;
} }
#endif #endif
static __inline__ int16_t fir16(struct fir16_state_t *fir, int16_t sample) static inline int16_t fir16(struct fir16_state_t *fir, int16_t sample)
{ {
int32_t y; int32_t y;
#if defined(USE_MMX) #if defined(USE_MMX)
...@@ -250,8 +248,8 @@ static __inline__ int16_t fir16(struct fir16_state_t *fir, int16_t sample) ...@@ -250,8 +248,8 @@ static __inline__ int16_t fir16(struct fir16_state_t *fir, int16_t sample)
return (int16_t) (y >> 15); return (int16_t) (y >> 15);
} }
static __inline__ const int16_t *fir32_create(struct fir32_state_t *fir, static inline const int16_t *fir32_create(struct fir32_state_t *fir,
const int32_t * coeffs, int taps) const int32_t *coeffs, int taps)
{ {
fir->taps = taps; fir->taps = taps;
fir->curr_pos = taps - 1; fir->curr_pos = taps - 1;
...@@ -260,17 +258,17 @@ static __inline__ const int16_t *fir32_create(struct fir32_state_t *fir, ...@@ -260,17 +258,17 @@ static __inline__ const int16_t *fir32_create(struct fir32_state_t *fir,
return fir->history; return fir->history;
} }
static __inline__ void fir32_flush(struct fir32_state_t *fir) static inline void fir32_flush(struct fir32_state_t *fir)
{ {
memset(fir->history, 0, fir->taps * sizeof(int16_t)); memset(fir->history, 0, fir->taps * sizeof(int16_t));
} }
static __inline__ void fir32_free(struct fir32_state_t *fir) static inline void fir32_free(struct fir32_state_t *fir)
{ {
kfree(fir->history); kfree(fir->history);
} }
static __inline__ int16_t fir32(struct fir32_state_t *fir, int16_t sample) static inline int16_t fir32(struct fir32_state_t *fir, int16_t sample)
{ {
int i; int i;
int32_t y; int32_t y;
......
This diff is collapsed.
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