summaryrefslogtreecommitdiff
path: root/drivers/misc/tfa9887.c
diff options
context:
space:
mode:
authorVinod Subbarayalu <vsubbarayalu@nvidia.com>2013-08-01 16:03:53 -0700
committerRiham Haidar <rhaidar@nvidia.com>2013-08-14 18:57:26 -0700
commitc594b04883ec9528114188c70bacdbcf4df23380 (patch)
tree8a337eba62d339b63a07e09bf92c0c9b230e3254 /drivers/misc/tfa9887.c
parent6d41daab2b4d6ede2e16a0b0354631e8a6648d8b (diff)
audio:Support Tfa9887 at different samplerate
Configure Tfa9887 at 16k for voip+nvoice usecase. Add missing copyright info. Change-Id: I080e874510255f1b2a4bf7d8045ef8fa6e2faadc Signed-off-by: Vinod Subbarayalu <vsubbarayalu@nvidia.com> Reviewed-on: http://git-master/r/257042 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Scott Peterson <speterson@nvidia.com>
Diffstat (limited to 'drivers/misc/tfa9887.c')
-rw-r--r--drivers/misc/tfa9887.c86
1 files changed, 86 insertions, 0 deletions
diff --git a/drivers/misc/tfa9887.c b/drivers/misc/tfa9887.c
index 38538afc08d3..d8c1b8c59b22 100644
--- a/drivers/misc/tfa9887.c
+++ b/drivers/misc/tfa9887.c
@@ -1,3 +1,19 @@
+/*
+ * drivers/misc/tfa9887.c
+ *
+ * Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/err.h>
@@ -893,6 +909,72 @@ int Tfa9887_SetVolume(unsigned int index)
return error;
}
+int Tfa9887_setSampleRate(int sRate)
+{
+ if (tfa9887R) {
+ mutex_lock(&tfa9887R->lock);
+ if (tfa9887R->deviceInit)
+ setSampleRate(tfa9887R, sRate);
+ mutex_unlock(&tfa9887R->lock);
+ }
+ if (tfa9887L) {
+ mutex_lock(&tfa9887L->lock);
+ if (tfa9887L->deviceInit)
+ setSampleRate(tfa9887L, sRate);
+ mutex_unlock(&tfa9887L->lock);
+ }
+}
+
+int setSampleRate(struct tfa9887_priv *tfa9887, int sRate)
+{
+
+ int error;
+ unsigned int value;
+
+ /*Set Sampling Frequency*/
+
+ error = Tfa9887_ReadRegister(tfa9887, TFA9887_I2S_CONTROL, &value);
+ if (error == Tfa9887_Error_Ok) {
+ /* clear the 4 bits first*/
+ value &= (~(0xF<<TFA9887_I2SCTRL_RATE_SHIFT));
+ switch (sRate) {
+ case 48000:
+ value |= TFA9887_I2SCTRL_RATE_48000;
+ break;
+ case 44100:
+ value |= TFA9887_I2SCTRL_RATE_44100;
+ break;
+ case 32000:
+ value |= TFA9887_I2SCTRL_RATE_32000;
+ break;
+ case 24000:
+ value |= TFA9887_I2SCTRL_RATE_24000;
+ break;
+ case 22050:
+ value |= TFA9887_I2SCTRL_RATE_22050;
+ break;
+ case 16000:
+ value |= TFA9887_I2SCTRL_RATE_16000;
+ break;
+ case 12000:
+ value |= TFA9887_I2SCTRL_RATE_12000;
+ break;
+ case 11025:
+ value |= TFA9887_I2SCTRL_RATE_11025;
+ break;
+ case 8000:
+ value |= TFA9887_I2SCTRL_RATE_08000;
+ break;
+ default:
+ pr_info("unsupported samplerate\n");
+ error = -1;
+ return error;
+ }
+ error = Tfa9887_WriteRegister(tfa9887,
+ TFA9887_I2S_CONTROL, value);
+ }
+}
+
int coldStartup(struct tfa9887_priv *tfa9887, struct tfa9887_priv *tfa9887_byte, int sRate)
{
int error,volume_value;
@@ -1665,3 +1747,7 @@ static void __exit tfa9887_exit(void)
}
module_exit(tfa9887_exit);
+MODULE_AUTHOR("Vinod Subbarayalu <vsubbarayalu@nvidia.com>, Scott Peterson <speterson@nvidia.com>");
+MODULE_DESCRIPTION("TFA9887 Audio Codec driver");
+MODULE_LICENSE("GPL");
+