From 6cd1cb7964eec7cb65c0acab47a6f5664cc5939e Mon Sep 17 00:00:00 2001 From: Vidyakumar Athota Date: Thu, 2 Feb 2017 17:29:19 -0800 Subject: [PATCH] ASoC: qdsp6v2: update afe topology to RTAC driver In device switch scenarios, AFE topology is stored in Real Time Audio Calibration(RTAC) driver before afe ports are open, which is invalid. Update AFE topology in RTAC driver after topology ID is obtained during AFE port open. Change-Id: I034321126fb0ffc9a2871f3c64f29f8aaedb21e7 Signed-off-by: Vidyakumar Athota --- include/linux/qdsp6v2/rtac.h | 4 +++- sound/soc/msm/qdsp6v2/q6afe.c | 1 + sound/soc/msm/qdsp6v2/rtac.c | 20 +++++++++++++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/include/linux/qdsp6v2/rtac.h b/include/linux/qdsp6v2/rtac.h index 3e5433b23a51..eeea0eb0a837 100644 --- a/include/linux/qdsp6v2/rtac.h +++ b/include/linux/qdsp6v2/rtac.h @@ -1,4 +1,5 @@ -/* Copyright (c) 2011, 2013-2015, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011, 2013-2015, 2017, The Linux Foundation. All rights + * reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -95,4 +96,5 @@ int rtac_clear_mapping(uint32_t cal_type); bool rtac_make_afe_callback(uint32_t *payload, u32 payload_size); void rtac_set_afe_handle(void *handle); void get_rtac_adm_data(struct rtac_adm *adm_data); +void rtac_update_afe_topology(u32 port_id); #endif diff --git a/sound/soc/msm/qdsp6v2/q6afe.c b/sound/soc/msm/qdsp6v2/q6afe.c index f1607b8e5d66..c1757fcdd598 100644 --- a/sound/soc/msm/qdsp6v2/q6afe.c +++ b/sound/soc/msm/qdsp6v2/q6afe.c @@ -1364,6 +1364,7 @@ static int afe_send_port_topology_id(u16 port_id) } this_afe.topology[index] = topology_id; + rtac_update_afe_topology(port_id); done: pr_debug("%s: AFE set topology id 0x%x enable for port 0x%x ret %d\n", __func__, topology_id, port_id, ret); diff --git a/sound/soc/msm/qdsp6v2/rtac.c b/sound/soc/msm/qdsp6v2/rtac.c index 82551fb8ed71..83628b8d62d9 100644 --- a/sound/soc/msm/qdsp6v2/rtac.c +++ b/sound/soc/msm/qdsp6v2/rtac.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -393,6 +393,24 @@ done: return; } +void rtac_update_afe_topology(u32 port_id) +{ + u32 i = 0; + + mutex_lock(&rtac_adm_mutex); + for (i = 0; i < rtac_adm_data.num_of_dev; i++) { + if (rtac_adm_data.device[i].afe_port == port_id) { + rtac_adm_data.device[i].afe_topology = + afe_get_topology(port_id); + pr_debug("%s: port_id = 0x%x topology_id = 0x%x copp_id = %d\n", + __func__, port_id, + rtac_adm_data.device[i].afe_topology, + rtac_adm_data.device[i].copp); + } + } + mutex_unlock(&rtac_adm_mutex); +} + void rtac_add_adm_device(u32 port_id, u32 copp_id, u32 path_id, u32 popp_id, u32 app_type, u32 acdb_id) {