From 265ed1ab8b29adb2ae5b827df11191f37fc816cf Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Marco=20Trevisan=20(Trevi=C3=B1o)?= <mail@3v1n0.net>
Date: Wed, 15 Oct 2008 02:04:41 +0200
Subject: [PATCH] Enable echo suppression on Dialing and on Accepting
 This patch replaces the first echo cancellation implementation using the TI Calypso
 "hidden" AT commands as suggested by Micheal Lauer on voice dialout and when accepting
 a call. According to some tests, in fact, it seems that the echo suppression is enabled
 only after the first AT query.

---
 .../phonevendors/ficgta01/vendor_ficgta01.cpp      |   25 ++++++++++++++++---
 .../phonevendors/ficgta01/vendor_ficgta01_p.h      |    3 ++
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/devices/ficgta01/src/plugins/phonevendors/ficgta01/vendor_ficgta01.cpp b/devices/ficgta01/src/plugins/phonevendors/ficgta01/vendor_ficgta01.cpp
index ae96eb4..afd5d37 100644
--- a/devices/ficgta01/src/plugins/phonevendors/ficgta01/vendor_ficgta01.cpp
+++ b/devices/ficgta01/src/plugins/phonevendors/ficgta01/vendor_ficgta01.cpp
@@ -186,6 +186,20 @@ QString Ficgta01CallProvider::dialServiceCommand(const QDialOptions& options) co
     return cmd.arg(QAtUtils::quote(options.number(), codec));
 }
 
+// Use the enable the echo suppression for TI Calypso before dialing
+QString Ficgta01CallProvider::dialVoiceCommand(const QDialOptions& options) const
+{
+	Ficgta01ModemService::echoCancellation(atchat());
+	return QModemCallProvider::dialVoiceCommand(options);
+}
+
+// Use the enable the echo suppression for TI Calypso before accepting calls
+QString Ficgta01CallProvider::acceptCallCommand( bool otherActiveCalls ) const
+{
+	Ficgta01ModemService::echoCancellation(atchat());
+	return QModemCallProvider::acceptCallCommand(otherActiveCalls);
+}
+
 Ficgta01PhoneBook::Ficgta01PhoneBook( QModemService *service )
     : QModemPhoneBook( service )
     , m_phoneBookWasReady(false)
@@ -453,10 +467,6 @@ Ficgta01ModemService::Ficgta01ModemService
     // Enable %CPRI for ciphering indications.
 //    chat( "AT%CPRI=1" );
 
-    // Set the side to the minimum value, enable echo/noise reduction
-    chat("AT@ST=\"-26\"" );
-    chat("AT%N0187" );
-
     // Make the modem send unsolicited reports at any time
     // the "user is not typing".  i.e. don't intersperse unsolicited
     // notifications and command echo as it will confuse QAtChat.
@@ -759,6 +769,13 @@ void Ficgta01ModemService::modemDied()
         m_vibratorService->setVibrateNow(false);
 }
 
+void Ficgta01ModemService::echoCancellation(QAtChat * atChat)
+{
+        atChat->chat( "AT@ST=\"-26\"" ); // audio side tone: set to minimum
+        atChat->chat( "AT%N028B" );      // Long Echo Cancellation: active, -6db
+        atChat->chat( "AT%N0125" );      // Noise reduction: active, -6db
+}
+
  Ficgta01VibrateAccessory::Ficgta01VibrateAccessory
         ( QModemService *service )
     : QVibrateAccessoryProvider( service->service(), service )
diff --git a/devices/ficgta01/src/plugins/phonevendors/ficgta01/vendor_ficgta01_p.h b/devices/ficgta01/src/plugins/phonevendors/ficgta01/vendor_ficgta01_p.h
index 6426a93..b5cc651 100644
--- a/devices/ficgta01/src/plugins/phonevendors/ficgta01/vendor_ficgta01_p.h
+++ b/devices/ficgta01/src/plugins/phonevendors/ficgta01/vendor_ficgta01_p.h
@@ -53,6 +53,8 @@ protected:
     QModemCallProvider::AtdBehavior atdBehavior() const;
     void abortDial( uint modemIdentifier, QPhoneCall::Scope scope );
     QString dialServiceCommand(const QDialOptions&) const;
+    QString dialVoiceCommand(const QDialOptions&) const;
+    QString acceptCallCommand( bool otherActiveCalls ) const;
 
     // reimplementation
     void resetModem();
@@ -126,6 +128,7 @@ public:
     ~Ficgta01ModemService();
 
     void initialize();
+    static void echoCancellation( QAtChat* );
 
 private slots:
     void csq( const QString& msg );
-- 
1.5.4.3

