xref: /openbmc/linux/drivers/misc/echo/oslec.h (revision 6e2055a9)
16e2055a9SGreg Kroah-Hartman /*
26e2055a9SGreg Kroah-Hartman  *  OSLEC - A line echo canceller.  This code is being developed
36e2055a9SGreg Kroah-Hartman  *          against and partially complies with G168. Using code from SpanDSP
46e2055a9SGreg Kroah-Hartman  *
56e2055a9SGreg Kroah-Hartman  * Written by Steve Underwood <steveu@coppice.org>
66e2055a9SGreg Kroah-Hartman  *         and David Rowe <david_at_rowetel_dot_com>
76e2055a9SGreg Kroah-Hartman  *
86e2055a9SGreg Kroah-Hartman  * Copyright (C) 2001 Steve Underwood and 2007-2008 David Rowe
96e2055a9SGreg Kroah-Hartman  *
106e2055a9SGreg Kroah-Hartman  * All rights reserved.
116e2055a9SGreg Kroah-Hartman  *
126e2055a9SGreg Kroah-Hartman  * This program is free software; you can redistribute it and/or modify
136e2055a9SGreg Kroah-Hartman  * it under the terms of the GNU General Public License version 2, as
146e2055a9SGreg Kroah-Hartman  * published by the Free Software Foundation.
156e2055a9SGreg Kroah-Hartman  *
166e2055a9SGreg Kroah-Hartman  * This program is distributed in the hope that it will be useful,
176e2055a9SGreg Kroah-Hartman  * but WITHOUT ANY WARRANTY; without even the implied warranty of
186e2055a9SGreg Kroah-Hartman  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
196e2055a9SGreg Kroah-Hartman  * GNU General Public License for more details.
206e2055a9SGreg Kroah-Hartman  *
216e2055a9SGreg Kroah-Hartman  * You should have received a copy of the GNU General Public License
226e2055a9SGreg Kroah-Hartman  * along with this program; if not, write to the Free Software
236e2055a9SGreg Kroah-Hartman  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
246e2055a9SGreg Kroah-Hartman  *
256e2055a9SGreg Kroah-Hartman  */
266e2055a9SGreg Kroah-Hartman 
276e2055a9SGreg Kroah-Hartman #ifndef __OSLEC_H
286e2055a9SGreg Kroah-Hartman #define __OSLEC_H
296e2055a9SGreg Kroah-Hartman 
306e2055a9SGreg Kroah-Hartman /* Mask bits for the adaption mode */
316e2055a9SGreg Kroah-Hartman #define ECHO_CAN_USE_ADAPTION	0x01
326e2055a9SGreg Kroah-Hartman #define ECHO_CAN_USE_NLP	0x02
336e2055a9SGreg Kroah-Hartman #define ECHO_CAN_USE_CNG	0x04
346e2055a9SGreg Kroah-Hartman #define ECHO_CAN_USE_CLIP	0x08
356e2055a9SGreg Kroah-Hartman #define ECHO_CAN_USE_TX_HPF	0x10
366e2055a9SGreg Kroah-Hartman #define ECHO_CAN_USE_RX_HPF	0x20
376e2055a9SGreg Kroah-Hartman #define ECHO_CAN_DISABLE	0x40
386e2055a9SGreg Kroah-Hartman 
396e2055a9SGreg Kroah-Hartman /**
406e2055a9SGreg Kroah-Hartman  * oslec_state: G.168 echo canceller descriptor.
416e2055a9SGreg Kroah-Hartman  *
426e2055a9SGreg Kroah-Hartman  * This defines the working state for a line echo canceller.
436e2055a9SGreg Kroah-Hartman  */
446e2055a9SGreg Kroah-Hartman struct oslec_state;
456e2055a9SGreg Kroah-Hartman 
466e2055a9SGreg Kroah-Hartman /**
476e2055a9SGreg Kroah-Hartman  * oslec_create - Create a voice echo canceller context.
486e2055a9SGreg Kroah-Hartman  * @len: The length of the canceller, in samples.
496e2055a9SGreg Kroah-Hartman  * @return: The new canceller context, or NULL if the canceller could not be
506e2055a9SGreg Kroah-Hartman  * created.
516e2055a9SGreg Kroah-Hartman  */
526e2055a9SGreg Kroah-Hartman struct oslec_state *oslec_create(int len, int adaption_mode);
536e2055a9SGreg Kroah-Hartman 
546e2055a9SGreg Kroah-Hartman /**
556e2055a9SGreg Kroah-Hartman  * oslec_free - Free a voice echo canceller context.
566e2055a9SGreg Kroah-Hartman  * @ec: The echo canceller context.
576e2055a9SGreg Kroah-Hartman  */
586e2055a9SGreg Kroah-Hartman void oslec_free(struct oslec_state *ec);
596e2055a9SGreg Kroah-Hartman 
606e2055a9SGreg Kroah-Hartman /**
616e2055a9SGreg Kroah-Hartman  * oslec_flush - Flush (reinitialise) a voice echo canceller context.
626e2055a9SGreg Kroah-Hartman  * @ec: The echo canceller context.
636e2055a9SGreg Kroah-Hartman  */
646e2055a9SGreg Kroah-Hartman void oslec_flush(struct oslec_state *ec);
656e2055a9SGreg Kroah-Hartman 
666e2055a9SGreg Kroah-Hartman /**
676e2055a9SGreg Kroah-Hartman  * oslec_adaption_mode - set the adaption mode of a voice echo canceller context.
686e2055a9SGreg Kroah-Hartman  * @ec The echo canceller context.
696e2055a9SGreg Kroah-Hartman  * @adaption_mode: The mode.
706e2055a9SGreg Kroah-Hartman  */
716e2055a9SGreg Kroah-Hartman void oslec_adaption_mode(struct oslec_state *ec, int adaption_mode);
726e2055a9SGreg Kroah-Hartman 
736e2055a9SGreg Kroah-Hartman void oslec_snapshot(struct oslec_state *ec);
746e2055a9SGreg Kroah-Hartman 
756e2055a9SGreg Kroah-Hartman /**
766e2055a9SGreg Kroah-Hartman  * oslec_update: Process a sample through a voice echo canceller.
776e2055a9SGreg Kroah-Hartman  * @ec: The echo canceller context.
786e2055a9SGreg Kroah-Hartman  * @tx: The transmitted audio sample.
796e2055a9SGreg Kroah-Hartman  * @rx: The received audio sample.
806e2055a9SGreg Kroah-Hartman  *
816e2055a9SGreg Kroah-Hartman  * The return value is the clean (echo cancelled) received sample.
826e2055a9SGreg Kroah-Hartman  */
836e2055a9SGreg Kroah-Hartman int16_t oslec_update(struct oslec_state *ec, int16_t tx, int16_t rx);
846e2055a9SGreg Kroah-Hartman 
856e2055a9SGreg Kroah-Hartman /**
866e2055a9SGreg Kroah-Hartman  * oslec_hpf_tx: Process to high pass filter the tx signal.
876e2055a9SGreg Kroah-Hartman  * @ec: The echo canceller context.
886e2055a9SGreg Kroah-Hartman  * @tx: The transmitted auio sample.
896e2055a9SGreg Kroah-Hartman  *
906e2055a9SGreg Kroah-Hartman  * The return value is the HP filtered transmit sample, send this to your D/A.
916e2055a9SGreg Kroah-Hartman  */
926e2055a9SGreg Kroah-Hartman int16_t oslec_hpf_tx(struct oslec_state *ec, int16_t tx);
936e2055a9SGreg Kroah-Hartman 
946e2055a9SGreg Kroah-Hartman #endif /* __OSLEC_H */
95