xref: /openbmc/linux/drivers/misc/echo/oslec.h (revision 82c29810)
182c29810SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
26e2055a9SGreg Kroah-Hartman /*
36e2055a9SGreg Kroah-Hartman  *  OSLEC - A line echo canceller.  This code is being developed
46e2055a9SGreg Kroah-Hartman  *          against and partially complies with G168. Using code from SpanDSP
56e2055a9SGreg Kroah-Hartman  *
66e2055a9SGreg Kroah-Hartman  * Written by Steve Underwood <steveu@coppice.org>
76e2055a9SGreg Kroah-Hartman  *         and David Rowe <david_at_rowetel_dot_com>
86e2055a9SGreg Kroah-Hartman  *
96e2055a9SGreg Kroah-Hartman  * Copyright (C) 2001 Steve Underwood and 2007-2008 David Rowe
106e2055a9SGreg Kroah-Hartman  *
116e2055a9SGreg Kroah-Hartman  * All rights reserved.
126e2055a9SGreg Kroah-Hartman  */
136e2055a9SGreg Kroah-Hartman 
146e2055a9SGreg Kroah-Hartman #ifndef __OSLEC_H
156e2055a9SGreg Kroah-Hartman #define __OSLEC_H
166e2055a9SGreg Kroah-Hartman 
176e2055a9SGreg Kroah-Hartman /* Mask bits for the adaption mode */
186e2055a9SGreg Kroah-Hartman #define ECHO_CAN_USE_ADAPTION	0x01
196e2055a9SGreg Kroah-Hartman #define ECHO_CAN_USE_NLP	0x02
206e2055a9SGreg Kroah-Hartman #define ECHO_CAN_USE_CNG	0x04
216e2055a9SGreg Kroah-Hartman #define ECHO_CAN_USE_CLIP	0x08
226e2055a9SGreg Kroah-Hartman #define ECHO_CAN_USE_TX_HPF	0x10
236e2055a9SGreg Kroah-Hartman #define ECHO_CAN_USE_RX_HPF	0x20
246e2055a9SGreg Kroah-Hartman #define ECHO_CAN_DISABLE	0x40
256e2055a9SGreg Kroah-Hartman 
266e2055a9SGreg Kroah-Hartman /**
276e2055a9SGreg Kroah-Hartman  * oslec_state: G.168 echo canceller descriptor.
286e2055a9SGreg Kroah-Hartman  *
296e2055a9SGreg Kroah-Hartman  * This defines the working state for a line echo canceller.
306e2055a9SGreg Kroah-Hartman  */
316e2055a9SGreg Kroah-Hartman struct oslec_state;
326e2055a9SGreg Kroah-Hartman 
336e2055a9SGreg Kroah-Hartman /**
346e2055a9SGreg Kroah-Hartman  * oslec_create - Create a voice echo canceller context.
356e2055a9SGreg Kroah-Hartman  * @len: The length of the canceller, in samples.
366e2055a9SGreg Kroah-Hartman  * @return: The new canceller context, or NULL if the canceller could not be
376e2055a9SGreg Kroah-Hartman  * created.
386e2055a9SGreg Kroah-Hartman  */
396e2055a9SGreg Kroah-Hartman struct oslec_state *oslec_create(int len, int adaption_mode);
406e2055a9SGreg Kroah-Hartman 
416e2055a9SGreg Kroah-Hartman /**
426e2055a9SGreg Kroah-Hartman  * oslec_free - Free a voice echo canceller context.
436e2055a9SGreg Kroah-Hartman  * @ec: The echo canceller context.
446e2055a9SGreg Kroah-Hartman  */
456e2055a9SGreg Kroah-Hartman void oslec_free(struct oslec_state *ec);
466e2055a9SGreg Kroah-Hartman 
476e2055a9SGreg Kroah-Hartman /**
486e2055a9SGreg Kroah-Hartman  * oslec_flush - Flush (reinitialise) a voice echo canceller context.
496e2055a9SGreg Kroah-Hartman  * @ec: The echo canceller context.
506e2055a9SGreg Kroah-Hartman  */
516e2055a9SGreg Kroah-Hartman void oslec_flush(struct oslec_state *ec);
526e2055a9SGreg Kroah-Hartman 
536e2055a9SGreg Kroah-Hartman /**
546e2055a9SGreg Kroah-Hartman  * oslec_adaption_mode - set the adaption mode of a voice echo canceller context.
556e2055a9SGreg Kroah-Hartman  * @ec The echo canceller context.
566e2055a9SGreg Kroah-Hartman  * @adaption_mode: The mode.
576e2055a9SGreg Kroah-Hartman  */
586e2055a9SGreg Kroah-Hartman void oslec_adaption_mode(struct oslec_state *ec, int adaption_mode);
596e2055a9SGreg Kroah-Hartman 
606e2055a9SGreg Kroah-Hartman void oslec_snapshot(struct oslec_state *ec);
616e2055a9SGreg Kroah-Hartman 
626e2055a9SGreg Kroah-Hartman /**
636e2055a9SGreg Kroah-Hartman  * oslec_update: Process a sample through a voice echo canceller.
646e2055a9SGreg Kroah-Hartman  * @ec: The echo canceller context.
656e2055a9SGreg Kroah-Hartman  * @tx: The transmitted audio sample.
666e2055a9SGreg Kroah-Hartman  * @rx: The received audio sample.
676e2055a9SGreg Kroah-Hartman  *
686e2055a9SGreg Kroah-Hartman  * The return value is the clean (echo cancelled) received sample.
696e2055a9SGreg Kroah-Hartman  */
706e2055a9SGreg Kroah-Hartman int16_t oslec_update(struct oslec_state *ec, int16_t tx, int16_t rx);
716e2055a9SGreg Kroah-Hartman 
726e2055a9SGreg Kroah-Hartman /**
736e2055a9SGreg Kroah-Hartman  * oslec_hpf_tx: Process to high pass filter the tx signal.
746e2055a9SGreg Kroah-Hartman  * @ec: The echo canceller context.
756e2055a9SGreg Kroah-Hartman  * @tx: The transmitted auio sample.
766e2055a9SGreg Kroah-Hartman  *
776e2055a9SGreg Kroah-Hartman  * The return value is the HP filtered transmit sample, send this to your D/A.
786e2055a9SGreg Kroah-Hartman  */
796e2055a9SGreg Kroah-Hartman int16_t oslec_hpf_tx(struct oslec_state *ec, int16_t tx);
806e2055a9SGreg Kroah-Hartman 
816e2055a9SGreg Kroah-Hartman #endif /* __OSLEC_H */
82