···220220}221221#endif222222223223-static __inline__ int top_bit(unsigned int bits)223223+static inline int top_bit(unsigned int bits)224224{225225 if (bits == 0)226226- return -1;227227- else228228- return (int)fls((int32_t)bits)-1;226226+ return -1;227227+ else228228+ return (int)fls((int32_t)bits)-1;229229}230230231231struct oslec_state *oslec_create(int len, int adaption_mode)···466466467467 factor = (2^30) * (2^-2) * clean_bg_rx/P468468469469- (30 - 2 - log2(P))469469+ (30 - 2 - log2(P))470470 factor = clean_bg_rx 2 ----- (3)471471472472 To avoid a divide we approximate log2(P) as top_bit(P),
+10-5
drivers/staging/echo/echo.h
···2828#ifndef __ECHO_H2929#define __ECHO_H30303131-/*! \page echo_can_page Line echo cancellation for voice3131+/*3232+Line echo cancellation for voice32333333-\section echo_can_page_sec_1 What does it do?3434+What does it do?3535+3436This module aims to provide G.168-2002 compliant echo cancellation, to remove3537electrical echoes (e.g. from 2-4 wire hybrids) from voice calls.36383737-\section echo_can_page_sec_2 How does it work?3939+4040+How does it work?4141+3842The heart of the echo cancellor is FIR filter. This is adapted to match the3943echo impulse response of the telephone line. It must be long enough to4044adequately cover the duration of that impulse response. The signal transmitted···112108needed which produces a fairly accurate result from a very short burst of far113109end energy.114110115115-\section echo_can_page_sec_3 How do I use it?111111+How do I use it?112112+116113The echo cancellor processes both the transmit and receive streams sample by117114sample. The processing function is not declared inline. Unfortunately,118115cancellation requires many operations per sample, so the call overhead is only···123118#include "fir.h"124119#include "oslec.h"125120126126-/*!121121+/*127122 G.168 echo canceller descriptor. This defines the working state for a line128123 echo canceller.129124*/
+13-22
drivers/staging/echo/fir.h
···2323 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.2424 */25252626-/*! \page fir_page FIR filtering2727-\section fir_page_sec_1 What does it do?2828-???.2929-3030-\section fir_page_sec_2 How does it work?3131-???.3232-*/3333-3426#if !defined(_FIR_H_)3527#define _FIR_H_3628···5462 can.5563*/56645757-/*!5858- 16 bit integer FIR descriptor. This defines the working state for a single5959- instance of an FIR filter using 16 bit integer coefficients.6060-*/6565+/*6666+ * 16 bit integer FIR descriptor. This defines the working state for a single6767+ * instance of an FIR filter using 16 bit integer coefficients.6868+ */6169struct fir16_state_t {6270 int taps;6371 int curr_pos;···6573 int16_t *history;6674};67756868-/*!6969- 32 bit integer FIR descriptor. This defines the working state for a single7070- instance of an FIR filter using 32 bit integer coefficients, and filtering7171- 16 bit integer data.7272-*/7676+/*7777+ * 32 bit integer FIR descriptor. This defines the working state for a single7878+ * instance of an FIR filter using 32 bit integer coefficients, and filtering7979+ * 16 bit integer data.8080+ */7381struct fir32_state_t {7482 int taps;7583 int curr_pos;···7785 int16_t *history;7886};79878080-/*!8181- Floating point FIR descriptor. This defines the working state for a single8282- instance of an FIR filter using floating point coefficients and data.8383-*/8888+/*8989+ * Floating point FIR descriptor. This defines the working state for a single9090+ * instance of an FIR filter using floating point coefficients and data.9191+ */8492struct fir_float_state_t {8593 int taps;8694 int curr_pos;···214222}215223216224#endif217217-/*- End of file ------------------------------------------------------------*/
+39-31
drivers/staging/echo/oslec.h
···2727#ifndef __OSLEC_H2828#define __OSLEC_H29293030-/* TODO: document interface */3131-3230/* Mask bits for the adaption mode */3331#define ECHO_CAN_USE_ADAPTION 0x013432#define ECHO_CAN_USE_NLP 0x02···3638#define ECHO_CAN_USE_RX_HPF 0x203739#define ECHO_CAN_DISABLE 0x4038403939-/*!4040- G.168 echo canceller descriptor. This defines the working state for a line4141- echo canceller.4242-*/4141+/**4242+ * oslec_state: G.168 echo canceller descriptor.4343+ *4444+ * This defines the working state for a line echo canceller.4545+ */4346struct oslec_state;44474545-/*! Create a voice echo canceller context.4646- \param len The length of the canceller, in samples.4747- \return The new canceller context, or NULL if the canceller could not be created.4848-*/4848+/**4949+ * oslec_create - Create a voice echo canceller context.5050+ * @len: The length of the canceller, in samples.5151+ * @return: The new canceller context, or NULL if the canceller could not be5252+ * created.5353+ */4954struct oslec_state *oslec_create(int len, int adaption_mode);50555151-/*! Free a voice echo canceller context.5252- \param ec The echo canceller context.5353-*/5656+/**5757+ * oslec_free - Free a voice echo canceller context.5858+ * @ec: The echo canceller context.5959+ */5460void oslec_free(struct oslec_state *ec);55615656-/*! Flush (reinitialise) a voice echo canceller context.5757- \param ec The echo canceller context.5858-*/6262+/**6363+ * oslec_flush - Flush (reinitialise) a voice echo canceller context.6464+ * @ec: The echo canceller context.6565+ */5966void oslec_flush(struct oslec_state *ec);60676161-/*! Set the adaption mode of a voice echo canceller context.6262- \param ec The echo canceller context.6363- \param adapt The mode.6464-*/6868+/**6969+ * oslec_adaption_mode - set the adaption mode of a voice echo canceller context.7070+ * @ec The echo canceller context.7171+ * @adaption_mode: The mode.7272+ */6573void oslec_adaption_mode(struct oslec_state *ec, int adaption_mode);66746775void oslec_snapshot(struct oslec_state *ec);68766969-/*! Process a sample through a voice echo canceller.7070- \param ec The echo canceller context.7171- \param tx The transmitted audio sample.7272- \param rx The received audio sample.7373- \return The clean (echo cancelled) received sample.7474-*/7777+/**7878+ * oslec_update: Process a sample through a voice echo canceller.7979+ * @ec: The echo canceller context.8080+ * @tx: The transmitted audio sample.8181+ * @rx: The received audio sample.8282+ *8383+ * The return value is the clean (echo cancelled) received sample.8484+ */7585int16_t oslec_update(struct oslec_state *ec, int16_t tx, int16_t rx);76867777-/*! Process to high pass filter the tx signal.7878- \param ec The echo canceller context.7979- \param tx The transmitted auio sample.8080- \return The HP filtered transmit sample, send this to your D/A.8181-*/8787+/**8888+ * oslec_hpf_tx: Process to high pass filter the tx signal.8989+ * @ec: The echo canceller context.9090+ * @tx: The transmitted auio sample.9191+ *9292+ * The return value is the HP filtered transmit sample, send this to your D/A.9393+ */8294int16_t oslec_hpf_tx(struct oslec_state *ec, int16_t tx);83958496#endif /* __OSLEC_H */