]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/staging/echo/echo.c
Merge branch 'omap-pool'
[linux-2.6-omap-h63xx.git] / drivers / staging / echo / echo.c
index fd4007e329e7dfe632c5b5ad56d63e1edf17a6e2..6d7217e1bd06e72a8cb721f4eca0c395d70311d6 100644 (file)
@@ -27,8 +27,6 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: echo.c,v 1.20 2006/12/01 18:00:48 steveu Exp $
  */
 
 /*! \file */
 
 #define MIN_TX_POWER_FOR_ADAPTION   64
 #define MIN_RX_POWER_FOR_ADAPTION   64
-#define DTD_HANGOVER               600 /* 600 samples, or 75ms     */
-#define DC_LOG2BETA                  3 /* log2() of DC filter Beta */
+#define DTD_HANGOVER            600    /* 600 samples, or 75ms     */
+#define DC_LOG2BETA                3   /* log2() of DC filter Beta */
 
 /*-----------------------------------------------------------------------*\
-                               FUNCTIONS
+                                  FUNCTIONS
 \*-----------------------------------------------------------------------*/
 
 /* adapting coeffs using the traditional stochastic descent (N)LMS algorithm */
 
 #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 i, j;
@@ -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 */
 
-       //asm("st:");
+       /* asm("st:"); */
        n = ec->taps;
        for (i = 0, j = offset2; i < n; i++, j++) {
                exp = *phist++ * factor;
                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
           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,
 */
 
 #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 i;
@@ -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_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->cng_level = 1000;
        oslec_adaption_mode(ec, adaption_mode);
@@ -271,14 +268,13 @@ struct oslec_state *oslec_create(int len, int adaption_mode)
 
        return ec;
 
-      error_oom:
+error_oom:
        for (i = 0; i < 2; i++)
                kfree(ec->fir_taps16[i]);
 
        kfree(ec);
        return NULL;
 }
-
 EXPORT_SYMBOL_GPL(oslec_create);
 
 void oslec_free(struct oslec_state *ec)
@@ -292,14 +288,12 @@ void oslec_free(struct oslec_state *ec)
        kfree(ec->snapshot);
        kfree(ec);
 }
-
 EXPORT_SYMBOL_GPL(oslec_free);
 
 void oslec_adaption_mode(struct oslec_state *ec, int adaption_mode)
 {
        ec->adaption_mode = adaption_mode;
 }
-
 EXPORT_SYMBOL_GPL(oslec_adaption_mode);
 
 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->Pstates = 0;
 }
-
 EXPORT_SYMBOL_GPL(oslec_flush);
 
 void oslec_snapshot(struct oslec_state *ec)
 {
        memcpy(ec->snapshot, ec->fir_taps16[0], ec->taps * sizeof(int16_t));
 }
-
 EXPORT_SYMBOL_GPL(oslec_snapshot);
 
 /* Dual Path Echo Canceller ------------------------------------------------*/
@@ -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
                   we don't have to recalculate over the whole block of
                   samples. */
-               new = (int)tx *(int)tx;
+               new = (int)tx * (int)tx;
                old = (int)ec->fir_state.history[ec->fir_state.curr_pos] *
                    (int)ec->fir_state.history[ec->fir_state.curr_pos];
                ec->Pstates +=
@@ -498,15 +490,15 @@ int16_t oslec_update(struct oslec_state *ec, int16_t tx, int16_t rx)
 
        if ((ec->adaption_mode & ECHO_CAN_USE_ADAPTION) &&
            (ec->nonupdate_dwell == 0) &&
-           (8 * ec->Lclean_bg <
-            7 * ec->Lclean) /* (ec->Lclean_bg < 0.875*ec->Lclean) */ &&
-           (8 * ec->Lclean_bg <
-            ec->Ltx) /* (ec->Lclean_bg < 0.125*ec->Ltx)    */ ) {
+           /* (ec->Lclean_bg < 0.875*ec->Lclean) */
+           (8 * ec->Lclean_bg < 7 * ec->Lclean) &&
+           /* (ec->Lclean_bg < 0.125*ec->Ltx) */
+           (8 * ec->Lclean_bg < ec->Ltx)) {
                if (ec->cond_met == 6) {
                        /* BG filter has had better results for 6 consecutive samples */
                        ec->adapt = 1;
                        memcpy(ec->fir_taps16[0], ec->fir_taps16[1],
-                              ec->taps * sizeof(int16_t));
+                               ec->taps * sizeof(int16_t));
                } else
                        ec->cond_met++;
        } else
@@ -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;
 }
-
 EXPORT_SYMBOL_GPL(oslec_update);
 
 /* This function is seperated from the echo canceller is it is usually called
@@ -604,7 +595,7 @@ EXPORT_SYMBOL_GPL(oslec_update);
    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;
 
@@ -629,7 +620,6 @@ int16_t oslec_hpf_tx(struct oslec_state * ec, int16_t tx)
 
        return tx;
 }
-
 EXPORT_SYMBOL_GPL(oslec_hpf_tx);
 
 MODULE_LICENSE("GPL");