msm: 7x27a: audio: Enable SRS Post processing.
Code to configure QDSP5 based SRS Post Proc.
Change-Id: Ie137853a90a2780265c419c3b070811ea06abc83
Signed-off-by: Sidipotu Ashok <sashok@codeaurora.org>
diff --git a/arch/arm/mach-msm/qdsp5/audio_out.c b/arch/arm/mach-msm/qdsp5/audio_out.c
index 7d33e05..8fe8cf66 100644
--- a/arch/arm/mach-msm/qdsp5/audio_out.c
+++ b/arch/arm/mach-msm/qdsp5/audio_out.c
@@ -4,6 +4,7 @@
*
* Copyright (C) 2008 Google, Inc.
* Copyright (C) 2008 HTC Corporation
+ * Copyright (c) 2012 Code Aurora Forum. 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
@@ -21,6 +22,7 @@
#include <linux/miscdevice.h>
#include <linux/uaccess.h>
#include <linux/kthread.h>
+#include <linux/slab.h>
#include <linux/wait.h>
#include <linux/dma-mapping.h>
#include <linux/debugfs.h>
@@ -46,6 +48,21 @@
#define LOG_AUDIO_EVENTS 1
#define LOG_AUDIO_FAULTS 0
+#define SRS_ID_GLOBAL 0x00000001
+#define SRS_ID_WOWHD 0x00000002
+#define SRS_ID_CSHP 0x00000003
+#define SRS_ID_HPF 0x00000004
+#define SRS_ID_PEQ 0x00000005
+#define SRS_ID_HL 0x00000006
+
+#define SRS_MASK_G 1
+#define SRS_MASK_W 2
+#define SRS_MASK_C 4
+#define SRS_MASK_HP 8
+#define SRS_MASK_P 16
+#define SRS_MASK_HL 32
+
+
enum {
EV_NULL,
EV_OPEN,
@@ -163,6 +180,10 @@
int qconcert_plus_enable;
int qconcert_plus_needs_commit;
+
+ int srs_enable;
+ int srs_needs_commit;
+ int srs_feature_mask;
audpp_cmd_cfg_object_params_qconcert qconcert_plus;
int status;
@@ -170,6 +191,13 @@
struct mutex lock;
struct audpp_event_callback ecb;
+
+ struct audpp_cmd_cfg_object_params_srstm_g g;
+ struct audpp_cmd_cfg_object_params_srstm_w w;
+ struct audpp_cmd_cfg_object_params_srstm_c c;
+ struct audpp_cmd_cfg_object_params_srstm_h h;
+ struct audpp_cmd_cfg_object_params_srstm_p p;
+ struct audpp_cmd_cfg_object_params_srstm_l l;
} the_audio_copp;
static void audio_prevent_sleep(struct audio *audio)
@@ -190,7 +218,7 @@
static int audio_dsp_send_buffer(struct audio *audio, unsigned id, unsigned len);
static void audio_dsp_event(void *private, unsigned id, uint16_t *msg);
-
+static int audio_enable_srs_trumedia(struct audio_copp *audio_copp, int enable);
/* must be called with audio->lock held */
static int audio_enable(struct audio *audio)
{
@@ -279,6 +307,7 @@
audpp_dsp_set_qconcert_plus(COMMON_OBJ_ID,
audio_copp->qconcert_plus_enable,
&audio_copp->qconcert_plus);
+ audio_enable_srs_trumedia(audio_copp, true);
}
EXPORT_SYMBOL(audio_commit_pending_pp_params);
@@ -448,6 +477,37 @@
return 0;
}
+static int audio_enable_srs_trumedia(struct audio_copp *audio_copp, int enable)
+{
+
+ if (!audio_copp->srs_needs_commit)
+ return 0;
+
+ audio_copp->srs_enable = enable;
+
+ MM_DBG("Enable SRS flags 0x%x enable %d\n",
+ audio_copp->srs_feature_mask, enable);
+ if (is_audpp_enable()) {
+ MM_DBG("Updating audpp for srs\n");
+ if (audio_copp->srs_feature_mask & SRS_MASK_W)
+ audpp_dsp_set_rx_srs_trumedia_w(&audio_copp->w);
+ if (audio_copp->srs_feature_mask & SRS_MASK_C)
+ audpp_dsp_set_rx_srs_trumedia_c(&audio_copp->c);
+ if (audio_copp->srs_feature_mask & SRS_MASK_HP)
+ audpp_dsp_set_rx_srs_trumedia_h(&audio_copp->h);
+ if (audio_copp->srs_feature_mask & SRS_MASK_P)
+ audpp_dsp_set_rx_srs_trumedia_p(&audio_copp->p);
+ if (audio_copp->srs_feature_mask & SRS_MASK_HL)
+ audpp_dsp_set_rx_srs_trumedia_l(&audio_copp->l);
+ if (audio_copp->srs_feature_mask & SRS_MASK_G)
+ audpp_dsp_set_rx_srs_trumedia_g(&audio_copp->g);
+
+ audio_copp->srs_needs_commit = 0;
+ audio_copp->srs_feature_mask = 0;
+ }
+ return 0;
+}
+
static int audio_enable_vol_pan(struct audio_copp *audio_copp)
{
if (is_audpp_enable())
@@ -785,6 +845,8 @@
int rc = 0, enable;
uint16_t enable_mask;
int prev_state;
+ uint32_t to_set, size = 0;
+ void *tmpbuf, *srs_params = NULL;
mutex_lock(&audio_copp->lock);
switch (cmd) {
@@ -804,6 +866,8 @@
audio_enable_rx_iir(audio_copp, enable);
enable = (enable_mask & QCONCERT_PLUS_ENABLE) ? 1 : 0;
audio_enable_qconcert_plus(audio_copp, enable);
+ enable = (enable_mask & SRS_ENABLE) ? 1 : 0;
+ audio_enable_srs_trumedia(audio_copp, enable);
break;
case AUDIO_SET_MBADRC: {
@@ -916,6 +980,75 @@
audio_copp->qconcert_plus_needs_commit = 1;
break;
+ case AUDIO_SET_SRS_TRUMEDIA_PARAM: {
+ prev_state = audio_copp->srs_enable;
+ audio_copp->srs_enable = 0;
+
+ if (copy_from_user(&to_set, (void *)arg, sizeof(uint32_t))) {
+ rc = -EFAULT;
+ break;
+ }
+ switch (to_set) {
+ case SRS_ID_GLOBAL:
+ srs_params = (void *)audio_copp->g.v;
+ size = sizeof(audio_copp->g.v);
+ audio_copp->srs_feature_mask |= SRS_MASK_G;
+ break;
+ case SRS_ID_WOWHD:
+ srs_params = (void *)audio_copp->w.v;
+ size = sizeof(audio_copp->w.v);
+ audio_copp->srs_feature_mask |= SRS_MASK_W;
+ break;
+ case SRS_ID_CSHP:
+ srs_params = (void *)audio_copp->c.v;
+ size = sizeof(audio_copp->c.v);
+ audio_copp->srs_feature_mask |= SRS_MASK_C;
+ break;
+ case SRS_ID_HPF:
+ srs_params = (void *)audio_copp->h.v;
+ size = sizeof(audio_copp->h.v);
+ audio_copp->srs_feature_mask |= SRS_MASK_HP;
+ break;
+ case SRS_ID_PEQ:
+ srs_params = (void *)audio_copp->p.v;
+ size = sizeof(audio_copp->p.v);
+ audio_copp->srs_feature_mask |= SRS_MASK_P;
+ break;
+ case SRS_ID_HL:
+ srs_params = (void *)audio_copp->l.v;
+ size = sizeof(audio_copp->l.v);
+ audio_copp->srs_feature_mask |= SRS_MASK_HL;
+ break;
+ default:
+ MM_ERR("SRS TruMedia error: invalid ioctl\n");
+ rc = -EINVAL;
+ }
+
+ if (rc >= 0) {
+ tmpbuf = kzalloc(sizeof(uint32_t) + size , GFP_KERNEL);
+ if (!tmpbuf) {
+ MM_ERR("SRS TruMedia error: no kernel mem\n");
+ rc = -ENOMEM;
+ } else {
+ if (copy_from_user(tmpbuf, (void *)arg,
+ sizeof(uint32_t) + size))
+ rc = -EFAULT;
+ memcpy(srs_params,
+ &(((uint32_t *)tmpbuf)[1]), size);
+ kfree(tmpbuf);
+ }
+ }
+
+ MM_DBG("Ioctl SRS flags=0x%x\n", audio_copp->srs_feature_mask);
+ if (rc < 0)
+ MM_ERR("SRS TruMedia error setting params failed.\n");
+ else{
+ audio_copp->srs_needs_commit = 1;
+ audio_copp->srs_enable = prev_state;
+ }
+ break;
+ }
+
default:
rc = -EINVAL;
}
diff --git a/arch/arm/mach-msm/qdsp5/audmgr.h b/arch/arm/mach-msm/qdsp5/audmgr.h
index 225beef..34c8488 100644
--- a/arch/arm/mach-msm/qdsp5/audmgr.h
+++ b/arch/arm/mach-msm/qdsp5/audmgr.h
@@ -1,7 +1,7 @@
/* arch/arm/mach-msm/qdsp5/audmgr.h
*
* Copyright (C) 2008 Google, Inc.
- * Copyright (c) 2008-2009, Code Aurora Forum. All rights reserved.
+ * Copyright (c) 2008-2009, 2012 Code Aurora Forum. 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
@@ -253,6 +253,20 @@
audpp_cmd_cfg_object_params_eqalizer *eq);
int audpp_dsp_set_rx_iir(unsigned id, unsigned enable,
audpp_cmd_cfg_object_params_pcm *iir);
+
+int audpp_dsp_set_rx_srs_trumedia_g
+ (struct audpp_cmd_cfg_object_params_srstm_g *srstm);
+int audpp_dsp_set_rx_srs_trumedia_w
+ (struct audpp_cmd_cfg_object_params_srstm_w *srstm);
+int audpp_dsp_set_rx_srs_trumedia_c
+ (struct audpp_cmd_cfg_object_params_srstm_c *srstm);
+int audpp_dsp_set_rx_srs_trumedia_h
+ (struct audpp_cmd_cfg_object_params_srstm_h *srstm);
+int audpp_dsp_set_rx_srs_trumedia_p
+ (struct audpp_cmd_cfg_object_params_srstm_p *srstm);
+int audpp_dsp_set_rx_srs_trumedia_l
+ (struct audpp_cmd_cfg_object_params_srstm_l *srstm);
+
int audpp_dsp_set_vol_pan(unsigned id,
audpp_cmd_cfg_object_params_volume *vol_pan);
int audpp_dsp_set_qconcert_plus(unsigned id, unsigned enable,
diff --git a/arch/arm/mach-msm/qdsp5/audpp.c b/arch/arm/mach-msm/qdsp5/audpp.c
index 2dbb5dc..1616ad0 100644
--- a/arch/arm/mach-msm/qdsp5/audpp.c
+++ b/arch/arm/mach-msm/qdsp5/audpp.c
@@ -71,6 +71,14 @@
#define AUDPP_CLNT_MAX_COUNT 6
#define AUDPP_AVSYNC_INFO_SIZE 7
+#define AUDPP_SRS_PARAMS 2
+#define AUDPP_SRS_PARAMS_G 0
+#define AUDPP_SRS_PARAMS_W 1
+#define AUDPP_SRS_PARAMS_C 2
+#define AUDPP_SRS_PARAMS_H 3
+#define AUDPP_SRS_PARAMS_P 4
+#define AUDPP_SRS_PARAMS_L 5
+
#define AUDPP_CMD_CFG_OBJ_UPDATE 0x8000
#define AUDPP_CMD_EQ_FLAG_DIS 0x0000
#define AUDPP_CMD_EQ_FLAG_ENA -1
@@ -604,6 +612,108 @@
}
EXPORT_SYMBOL(audpp_dsp_set_rx_iir);
+int audpp_dsp_set_rx_srs_trumedia_g(
+ struct audpp_cmd_cfg_object_params_srstm_g *srstm)
+{
+ struct audpp_cmd_cfg_object_params_srstm_g cmd;
+
+ MM_DBG("%s\n", __func__);
+ memset(&cmd, 0, sizeof(cmd));
+ cmd.common.cmd_id = AUDPP_SRS_PARAMS;
+ cmd.common.comman_cfg = AUDPP_CMD_CFG_OBJ_UPDATE;
+ cmd.common.command_type = AUDPP_SRS_PARAMS_G;
+
+ memcpy(cmd.v, srstm->v, sizeof(srstm->v));
+
+ return audpp_send_queue3(&cmd, sizeof(cmd));
+}
+EXPORT_SYMBOL(audpp_dsp_set_rx_srs_trumedia_g);
+
+int audpp_dsp_set_rx_srs_trumedia_w(
+ struct audpp_cmd_cfg_object_params_srstm_w *srstm)
+{
+ struct audpp_cmd_cfg_object_params_srstm_w cmd;
+
+ MM_DBG("%s\n", __func__);
+ memset(&cmd, 0, sizeof(cmd));
+ cmd.common.cmd_id = AUDPP_SRS_PARAMS;
+ cmd.common.comman_cfg = AUDPP_CMD_CFG_OBJ_UPDATE;
+ cmd.common.command_type = AUDPP_SRS_PARAMS_W;
+
+ memcpy(cmd.v, srstm->v, sizeof(srstm->v));
+
+ return audpp_send_queue3(&cmd, sizeof(cmd));
+}
+EXPORT_SYMBOL(audpp_dsp_set_rx_srs_trumedia_w);
+
+int audpp_dsp_set_rx_srs_trumedia_c(
+ struct audpp_cmd_cfg_object_params_srstm_c *srstm)
+{
+ struct audpp_cmd_cfg_object_params_srstm_c cmd;
+
+ MM_DBG("%s\n", __func__);
+ memset(&cmd, 0, sizeof(cmd));
+ cmd.common.cmd_id = AUDPP_SRS_PARAMS;
+ cmd.common.comman_cfg = AUDPP_CMD_CFG_OBJ_UPDATE;
+ cmd.common.command_type = AUDPP_SRS_PARAMS_C;
+
+ memcpy(cmd.v, srstm->v, sizeof(srstm->v));
+
+ return audpp_send_queue3(&cmd, sizeof(cmd));
+}
+EXPORT_SYMBOL(audpp_dsp_set_rx_srs_trumedia_c);
+
+int audpp_dsp_set_rx_srs_trumedia_h(
+ struct audpp_cmd_cfg_object_params_srstm_h *srstm)
+{
+ struct audpp_cmd_cfg_object_params_srstm_h cmd;
+
+ MM_DBG("%s\n", __func__);
+ memset(&cmd, 0, sizeof(cmd));
+ cmd.common.cmd_id = AUDPP_SRS_PARAMS;
+ cmd.common.comman_cfg = AUDPP_CMD_CFG_OBJ_UPDATE;
+ cmd.common.command_type = AUDPP_SRS_PARAMS_H;
+
+ memcpy(cmd.v, srstm->v, sizeof(srstm->v));
+
+ return audpp_send_queue3(&cmd, sizeof(cmd));
+}
+EXPORT_SYMBOL(audpp_dsp_set_rx_srs_trumedia_h);
+
+int audpp_dsp_set_rx_srs_trumedia_p(
+ struct audpp_cmd_cfg_object_params_srstm_p *srstm)
+{
+ struct audpp_cmd_cfg_object_params_srstm_p cmd;
+
+ MM_DBG("%s\n", __func__);
+ memset(&cmd, 0, sizeof(cmd));
+ cmd.common.cmd_id = AUDPP_SRS_PARAMS;
+ cmd.common.comman_cfg = AUDPP_CMD_CFG_OBJ_UPDATE;
+ cmd.common.command_type = AUDPP_SRS_PARAMS_P;
+
+ memcpy(cmd.v, srstm->v, sizeof(srstm->v));
+
+ return audpp_send_queue3(&cmd, sizeof(cmd));
+}
+EXPORT_SYMBOL(audpp_dsp_set_rx_srs_trumedia_p);
+
+int audpp_dsp_set_rx_srs_trumedia_l(
+ struct audpp_cmd_cfg_object_params_srstm_l *srstm)
+{
+ struct audpp_cmd_cfg_object_params_srstm_l cmd;
+
+ MM_DBG("%s\n", __func__);
+ memset(&cmd, 0, sizeof(cmd));
+ cmd.common.cmd_id = AUDPP_SRS_PARAMS;
+ cmd.common.comman_cfg = AUDPP_CMD_CFG_OBJ_UPDATE;
+ cmd.common.command_type = AUDPP_SRS_PARAMS_L;
+
+ memcpy(cmd.v, srstm->v, sizeof(srstm->v));
+
+ return audpp_send_queue3(&cmd, sizeof(cmd));
+}
+EXPORT_SYMBOL(audpp_dsp_set_rx_srs_trumedia_l);
+
/* Implementation Of COPP + POPP */
int audpp_dsp_set_eq(unsigned id, unsigned enable,
audpp_cmd_cfg_object_params_eqalizer *eq)