msm: audio: qdsp6v2: Change RTAC to use topology
This changes real-time audio calibration (RTAC) to use
topology ID's instead of device ID's.
Signed-off-by: Ben Romberger <bromberg@codeaurora.org>
diff --git a/arch/arm/mach-msm/include/mach/qdsp6v2/audio_dev_ctl.h b/arch/arm/mach-msm/include/mach/qdsp6v2/audio_dev_ctl.h
index f1e707a..71f2bd9 100644
--- a/arch/arm/mach-msm/include/mach/qdsp6v2/audio_dev_ctl.h
+++ b/arch/arm/mach-msm/include/mach/qdsp6v2/audio_dev_ctl.h
@@ -31,11 +31,6 @@
per clients, MAX_BIT_PER_CLIENT >= MAX_SESSIONS */
#define MAX_BIT_PER_CLIENT 16
-/* Path ID used by dev ctrl & Q6 */
-#define PLAYBACK 0x1
-#define LIVE_RECORDING 0x2
-#define NON_LIVE_RECORDING 0x3
-
#define VOICE_STATE_INVALID 0x0
#define VOICE_STATE_INCALL 0x1
#define VOICE_STATE_OFFCALL 0x2
diff --git a/arch/arm/mach-msm/include/mach/qdsp6v2/rtac.h b/arch/arm/mach-msm/include/mach/qdsp6v2/rtac.h
index 23fb679..863fe97 100644
--- a/arch/arm/mach-msm/include/mach/qdsp6v2/rtac.h
+++ b/arch/arm/mach-msm/include/mach/qdsp6v2/rtac.h
@@ -16,7 +16,6 @@
#ifdef CONFIG_MSM8X60_RTAC
-#include <mach/qdsp6v2/audio_dev_ctl.h>
#include <mach/qdsp6v2/q6voice.h>
/* Voice Modes */
@@ -24,8 +23,7 @@
#define RTAC_CVS 1
#define RTAC_VOICE_MODES 2
-void update_rtac(u32 evt_id, u32 dev_id, struct msm_snddev_info *dev_info);
-void rtac_add_adm_device(u32 port_id, u32 popp_id);
+void rtac_add_adm_device(u32 port_id, u32 copp_id, u32 path_id, u32 popp_id);
void rtac_remove_adm_device(u32 port_id, u32 popp_id);
void rtac_add_voice(struct voice_data *v);
void rtac_remove_voice(struct voice_data *v);
diff --git a/arch/arm/mach-msm/qdsp6v2/audio_dev_ctl.c b/arch/arm/mach-msm/qdsp6v2/audio_dev_ctl.c
index 41729c9..0a5acce 100644
--- a/arch/arm/mach-msm/qdsp6v2/audio_dev_ctl.c
+++ b/arch/arm/mach-msm/qdsp6v2/audio_dev_ctl.c
@@ -22,7 +22,6 @@
#include <mach/qdsp6v2/audio_dev_ctl.h>
#include <mach/debug_mm.h>
#include <mach/qdsp6v2/q6voice.h>
-#include <mach/qdsp6v2/rtac.h>
#include <sound/apr_audio.h>
#include <sound/q6adm.h>
@@ -45,8 +44,6 @@
static struct audio_dev_ctrl_state audio_dev_ctrl;
struct event_listner event;
-#define MAX_COPP_DEVICES 4
-
struct session_freq {
int freq;
int evt;
@@ -366,7 +363,7 @@
mutex_lock(&routing_info.adm_mutex);
if (set) {
- rc = adm_open(copp_id, PLAYBACK, rate, mode,
+ rc = adm_open(copp_id, ADM_PATH_PLAYBACK, rate, mode,
DEFAULT_COPP_TOPOLOGY);
if (rc < 0) {
pr_err("%s: adm open fail rc[%d]\n", __func__, rc);
@@ -381,7 +378,7 @@
(sizeof(unsigned int) * AFE_MAX_PORTS));
num_copps = msm_check_multicopp_per_stream(popp_id, &payload);
/* Multiple streams per copp is handled, one stream at a time */
- rc = adm_matrix_map(popp_id, PLAYBACK, num_copps,
+ rc = adm_matrix_map(popp_id, ADM_PATH_PLAYBACK, num_copps,
payload.copp_ids, copp_id);
if (rc < 0) {
pr_err("%s: matrix map failed rc[%d]\n",
@@ -518,14 +515,14 @@
rate = 16000;
}
mutex_unlock(&adm_tx_topology_tbl.lock);
- rc = adm_open(copp_id, LIVE_RECORDING, rate, mode, topology);
+ rc = adm_open(copp_id, ADM_PATH_LIVE_REC, rate, mode, topology);
if (rc < 0) {
pr_err("%s: adm open fail rc[%d]\n", __func__, rc);
rc = -EINVAL;
goto fail_cmd;
}
- rc = adm_matrix_map(popp_id, LIVE_RECORDING, 1,
+ rc = adm_matrix_map(popp_id, ADM_PATH_LIVE_REC, 1,
(unsigned int *)&copp_id, copp_id);
if (rc < 0) {
pr_err("%s: matrix map failed rc[%d]\n", __func__, rc);
@@ -998,7 +995,7 @@
goto fail_cmd;
}
- rc = adm_open(port_id[0], LIVE_RECORDING, rate, channel_mode,
+ rc = adm_open(port_id[0], ADM_PATH_LIVE_REC, rate, channel_mode,
DEFAULT_COPP_TOPOLOGY);
if (rc < 0) {
pr_err("%s: Error %d in ADM open %d\n",
@@ -1007,7 +1004,7 @@
goto fail_cmd;
}
- rc = adm_matrix_map(popp_id, LIVE_RECORDING, 1,
+ rc = adm_matrix_map(popp_id, ADM_PATH_LIVE_REC, 1,
&port_id[0], port_id[0]);
if (rc < 0) {
pr_err("%s: Error %d in ADM matrix map %d\n",
@@ -1027,7 +1024,7 @@
goto fail_cmd;
}
- rc = adm_open(port_id[1], LIVE_RECORDING, rate, channel_mode,
+ rc = adm_open(port_id[1], ADM_PATH_LIVE_REC, rate, channel_mode,
DEFAULT_COPP_TOPOLOGY);
if (rc < 0) {
pr_err("%s: Error %d in ADM open %d\n",
@@ -1036,7 +1033,7 @@
goto fail_cmd;
}
- rc = adm_matrix_map(popp_id, LIVE_RECORDING, 1,
+ rc = adm_matrix_map(popp_id, ADM_PATH_LIVE_REC, 1,
&port_id[1], port_id[1]);
if (rc < 0) {
pr_err("%s: Error %d in ADM matrix map %d\n",
@@ -1056,7 +1053,7 @@
goto fail_cmd;
}
- rc = adm_open(port_id[0], LIVE_RECORDING, rate, channel_mode,
+ rc = adm_open(port_id[0], ADM_PATH_LIVE_REC, rate, channel_mode,
DEFAULT_COPP_TOPOLOGY);
if (rc < 0) {
pr_err("%s: Error %d in ADM open %d\n",
@@ -1075,7 +1072,7 @@
goto fail_cmd;
}
- rc = adm_open(port_id[1], LIVE_RECORDING, rate, channel_mode,
+ rc = adm_open(port_id[1], ADM_PATH_LIVE_REC, rate, channel_mode,
DEFAULT_COPP_TOPOLOGY);
if (rc < 0) {
pr_err("%s: Error %d in ADM open %d\n",
@@ -1084,7 +1081,7 @@
goto fail_cmd;
}
- rc = adm_matrix_map(popp_id, LIVE_RECORDING, 2,
+ rc = adm_matrix_map(popp_id, ADM_PATH_LIVE_REC, 2,
&port_id[0], port_id[1]);
if (rc < 0) {
pr_err("%s: Error %d in ADM matrix map\n",
@@ -1363,10 +1360,6 @@
}
}
-#ifdef CONFIG_MSM8X60_RTAC
- update_rtac(evt_id, dev_id, dev_info);
-#endif
-
if (event.cb != NULL)
callback = event.cb;
else
diff --git a/arch/arm/mach-msm/qdsp6v2/rtac.c b/arch/arm/mach-msm/qdsp6v2/rtac.c
index 5e2339e..372ff3f 100644
--- a/arch/arm/mach-msm/qdsp6v2/rtac.c
+++ b/arch/arm/mach-msm/qdsp6v2/rtac.c
@@ -20,10 +20,9 @@
#include <linux/sched.h>
#include <linux/msm_audio_acdb.h>
#include <asm/atomic.h>
-#include <mach/qdsp6v2/apr_audio.h>
-#include <mach/qdsp6v2/q6asm.h>
-#include <mach/qdsp6v2/q6afe.h>
+#include <mach/qdsp6v2/audio_acdb.h>
#include <mach/qdsp6v2/rtac.h>
+#include <sound/q6asm.h>
#include <sound/q6adm.h>
@@ -48,22 +47,9 @@
static struct rtac_apr_data rtac_voice_apr_data[RTAC_VOICE_MODES];
-/* Dev ctrl info */
-struct rtac_dev_ctrl_data {
- uint32_t dev_id;
- uint32_t afe_port;
-};
-
-struct rtac_dev_ctrl {
- uint32_t num_of_dev;
- struct rtac_dev_ctrl_data device[RTAC_MAX_ACTIVE_DEVICES];
-};
-
-static struct rtac_dev_ctrl rtac_dev_ctl_data;
-
-
/* ADM info & APR */
struct rtac_adm_data {
+ uint32_t topology_id;
uint32_t afe_port;
uint32_t copp;
uint32_t num_of_popp;
@@ -88,8 +74,8 @@
/* Voice info & APR */
struct rtac_voice_data {
- uint32_t tx_dev_id;
- uint32_t rx_dev_id;
+ uint32_t tx_topology_id;
+ uint32_t rx_topology_id;
uint32_t tx_afe_port;
uint32_t rx_afe_port;
uint16_t cvs_handle;
@@ -108,7 +94,6 @@
-struct mutex rtac_dev_ctrl_mutex;
struct mutex rtac_adm_mutex;
struct mutex rtac_adm_apr_mutex;
struct mutex rtac_asm_apr_mutex;
@@ -127,99 +112,6 @@
return 0;
}
-
-/* Dev ctrl info */
-void rtac_add_dev_ctrl_device(u32 dev_id, struct msm_snddev_info *dev_info)
-{
- s32 i = 0;
- pr_debug("%s: dev_id = %d\n", __func__, dev_id);
-
- mutex_lock(&rtac_dev_ctrl_mutex);
- if (rtac_dev_ctl_data.num_of_dev == RTAC_MAX_ACTIVE_DEVICES) {
- pr_err("%s, Can't add anymore RTAC devices!\n", __func__);
- goto done;
- }
-
- /* Check if device already added */
- if (rtac_dev_ctl_data.num_of_dev != 0) {
- for (; i < rtac_dev_ctl_data.num_of_dev; i++) {
- if (rtac_dev_ctl_data.device[i].dev_id == dev_id) {
- pr_debug("%s, Device = %d already present"
- "in list\n", __func__, dev_id);
- goto done;
- }
- }
- }
-
- /* Add device */
- rtac_dev_ctl_data.num_of_dev++;
- rtac_dev_ctl_data.device[i].dev_id = dev_id;
- rtac_dev_ctl_data.device[i].afe_port = dev_info->copp_id;
-done:
- mutex_unlock(&rtac_dev_ctrl_mutex);
- return;
-}
-
-void shift_dev_ctrl_devices(u32 dev_idx)
-{
- for (; dev_idx < rtac_dev_ctl_data.num_of_dev; dev_idx++) {
- rtac_dev_ctl_data.device[dev_idx].dev_id =
- rtac_dev_ctl_data.device[dev_idx + 1].dev_id;
- rtac_dev_ctl_data.device[dev_idx].afe_port =
- rtac_dev_ctl_data.device[dev_idx + 1].afe_port;
- }
-}
-
-void rtac_remove_dev_ctrl_device(u32 dev_id)
-{
- s32 i;
- pr_debug("%s: dev_id = %d\n", __func__, dev_id);
-
- mutex_lock(&rtac_dev_ctrl_mutex);
- if (rtac_dev_ctl_data.num_of_dev == 0)
- goto done;
-
- /* look for device */
- for (i = 0; i < rtac_dev_ctl_data.num_of_dev; i++) {
- if (rtac_dev_ctl_data.device[i].dev_id == dev_id) {
- if (rtac_dev_ctl_data.device[i].afe_port ==
- rtac_adm_data.device[i].afe_port) {
- if (rtac_adm_data.device[i].num_of_popp == 0) {
- shift_dev_ctrl_devices(i);
- rtac_dev_ctl_data.device[i+1].dev_id
- = 0;
- rtac_dev_ctl_data.device[i+1].afe_port
- = 0;
- rtac_dev_ctl_data.num_of_dev--;
- break;
- } else
- pr_debug("%s:Device has atleast one"
- " POPP associated with it\n",
- __func__);
- }
- }
- }
-done:
- mutex_unlock(&rtac_dev_ctrl_mutex);
- return;
-}
-
-void update_rtac(u32 evt_id, u32 dev_id, struct msm_snddev_info *dev_info)
-{
- pr_debug("%s, evt_id = %d, dev_id = %d\n", __func__, evt_id, dev_id);
- switch (evt_id) {
- case AUDDEV_EVT_DEV_RDY:
- rtac_add_dev_ctrl_device(dev_id, dev_info);
- break;
- case AUDDEV_EVT_DEV_RLS:
- rtac_remove_dev_ctrl_device(dev_id);
- break;
- default:
- break;
- }
-}
-
-
/* ADM Info */
void add_popp(u32 dev_idx, u32 port_id, u32 popp_id)
{
@@ -240,7 +132,7 @@
return;
}
-void rtac_add_adm_device(u32 port_id, u32 popp_id)
+void rtac_add_adm_device(u32 port_id, u32 copp_id, u32 path_id, u32 popp_id)
{
u32 i = 0;
pr_debug("%s: port_id = %d, popp_id = %d\n", __func__, port_id,
@@ -269,8 +161,15 @@
/* Add device */
rtac_adm_data.num_of_dev++;
+
+ if (path_id == ADM_PATH_PLAYBACK)
+ rtac_adm_data.device[i].topology_id =
+ get_adm_rx_topology();
+ else
+ rtac_adm_data.device[i].topology_id =
+ get_adm_tx_topology();
rtac_adm_data.device[i].afe_port = port_id;
- rtac_adm_data.device[i].copp = adm_get_copp_id(port_id);
+ rtac_adm_data.device[i].copp = copp_id;
rtac_adm_data.device[i].popp[
rtac_adm_data.device[i].num_of_popp++] = popp_id;
done:
@@ -278,7 +177,7 @@
return;
}
-void shift_adm_devices(u32 dev_idx)
+static void shift_adm_devices(u32 dev_idx)
{
for (; dev_idx < rtac_adm_data.num_of_dev; dev_idx++) {
memcpy(&rtac_adm_data.device[dev_idx],
@@ -289,7 +188,7 @@
}
}
-void shift_popp(u32 copp_idx, u32 popp_idx)
+static void shift_popp(u32 copp_idx, u32 popp_idx)
{
for (; popp_idx < rtac_adm_data.device[copp_idx].num_of_popp;
popp_idx++) {
@@ -328,12 +227,6 @@
}
}
}
- if (rtac_adm_data.device[i].num_of_popp == 0) {
- shift_dev_ctrl_devices(i);
- rtac_dev_ctl_data.device[i+1].dev_id = 0;
- rtac_dev_ctl_data.device[i+1].afe_port = 0;
- rtac_dev_ctl_data.num_of_dev--;
- }
if (rtac_adm_data.num_of_dev >= 1) {
shift_adm_devices(i);
break;
@@ -347,10 +240,10 @@
/* Voice Info */
-void set_rtac_voice_data(int idx, struct voice_data *v)
+static void set_rtac_voice_data(int idx, struct voice_data *v)
{
- rtac_voice_data.voice[idx].tx_dev_id = v->dev_tx.dev_id;
- rtac_voice_data.voice[idx].rx_dev_id = v->dev_rx.dev_id;
+ rtac_voice_data.voice[idx].tx_topology_id = get_voice_tx_topology();
+ rtac_voice_data.voice[idx].rx_topology_id = get_voice_rx_topology();
rtac_voice_data.voice[idx].tx_afe_port = v->dev_tx.dev_port_id;
rtac_voice_data.voice[idx].rx_afe_port = v->dev_rx.dev_port_id;
rtac_voice_data.voice[idx].cvs_handle = v->cvs_handle;
@@ -389,7 +282,7 @@
return;
}
-void shift_voice_devices(u32 idx)
+static void shift_voice_devices(u32 idx)
{
for (; idx < rtac_voice_data.num_of_voice_combos - 1; idx++) {
memcpy(&rtac_voice_data.voice[idx],
@@ -471,7 +364,7 @@
s32 result;
u32 count = 0;
u32 bytes_returned = 0;
- u32 port_id = 0;
+ u32 port_index = 0;
u32 copp_id;
u32 payload_size;
struct apr_hdr adm_params;
@@ -510,12 +403,13 @@
goto done;
}
- for (port_id = 0; port_id < AFE_MAX_PORTS; port_id++) {
- if (adm_get_copp_id(port_id) == copp_id)
+ for (port_index = 0; port_index < AFE_MAX_PORTS; port_index++) {
+ if (adm_get_copp_id(port_index) == copp_id)
break;
}
- if (port_id >= AFE_MAX_PORTS) {
- pr_err("%s: Invalid Port ID = %d\n", __func__, port_id);
+ if (port_index >= AFE_MAX_PORTS) {
+ pr_err("%s: Could not find port index for copp = %d\n",
+ __func__, copp_id);
goto done;
}
@@ -542,11 +436,11 @@
payload_size);
adm_params.src_svc = APR_SVC_ADM;
adm_params.src_domain = APR_DOMAIN_APPS;
- adm_params.src_port = port_id;
+ adm_params.src_port = port_index;
adm_params.dest_svc = APR_SVC_ADM;
adm_params.dest_domain = APR_DOMAIN_ADSP;
- adm_params.dest_port = adm_get_copp_id(port_id);
- adm_params.token = port_id;
+ adm_params.dest_port = copp_id;
+ adm_params.token = port_index;
adm_params.opcode = opcode;
memcpy(rtac_adm_buffer, &adm_params, sizeof(adm_params));
@@ -558,8 +452,8 @@
result = apr_send_pkt(rtac_adm_apr_data.apr_handle,
(uint32_t *)rtac_adm_buffer);
if (result < 0) {
- pr_err("%s: Set params failed port = %d\n",
- __func__, port_id);
+ pr_err("%s: Set params failed port = %d, copp = %d\n",
+ __func__, port_index, copp_id);
goto err;
}
/* Wait for the callback */
@@ -568,8 +462,8 @@
msecs_to_jiffies(TIMEOUT_MS));
mutex_unlock(&rtac_adm_apr_mutex);
if (!result) {
- pr_err("%s: Set params timed out port = %d\n",
- __func__, port_id);
+ pr_err("%s: Set params timed out port = %d, copp = %d\n",
+ __func__, port_index, copp_id);
goto done;
}
@@ -933,7 +827,7 @@
-static int rtac_ioctl(struct inode *inode, struct file *f,
+static long rtac_ioctl(struct file *f,
unsigned int cmd, unsigned long arg)
{
s32 result = 0;
@@ -946,13 +840,6 @@
}
switch (cmd) {
- case AUDIO_GET_RTAC_DEV_CTRL_INFO:
- if (copy_to_user((void *)arg, &rtac_dev_ctl_data,
- sizeof(rtac_dev_ctl_data)))
- pr_err("%s: Could not copy to userspace!\n", __func__);
- else
- result = sizeof(rtac_dev_ctl_data);
- break;
case AUDIO_GET_RTAC_ADM_INFO:
if (copy_to_user((void *)arg, &rtac_adm_data,
sizeof(rtac_adm_data)))
@@ -1010,7 +897,7 @@
.owner = THIS_MODULE,
.open = rtac_open,
.release = rtac_release,
- .ioctl = rtac_ioctl,
+ .unlocked_ioctl = rtac_ioctl,
};
struct miscdevice rtac_misc = {
@@ -1024,10 +911,6 @@
int i = 0;
pr_debug("%s\n", __func__);
- /* Dev ctrl */
- memset(&rtac_dev_ctl_data, 0, sizeof(rtac_dev_ctl_data));
- mutex_init(&rtac_dev_ctrl_mutex);
-
/* ADM */
memset(&rtac_adm_data, 0, sizeof(rtac_adm_data));
rtac_adm_apr_data.apr_handle = NULL;