ASoC: msm: ensure ADM is only opened/closed for multimedia purpose

It was found that upon initation of voice call, ADM COPP is opened
even though there is no audio playback or capture. This behavior
forces QDSP6 to scale up clock frequency because it is expected that
, with ADM COPP opened, post/pre processing will be exercised hence
require more MIPs in QDSP6 to process the request. Unecessary power
consumption is wasted as result. Update pcm routing driver not to
start ADM COPP unnecessarily.

CRs-fixed: 316604
Change-Id: I90b33ae1582fb76c74d9e4ec13962db34374c60d
Signed-off-by: Patrick Lai <plai@codeaurora.org>
This commit is contained in:
Patrick Lai
2011-12-12 13:44:54 -08:00
parent f6cfb8ef4a
commit 770ca3e432
2 changed files with 35 additions and 3 deletions

View File

@@ -118,7 +118,7 @@ static struct msm_pcm_routing_bdai_data msm_bedais[MSM_BACKEND_DAI_MAX] = {
/* Track ASM playback & capture sessions of DAI */
static int fe_dai_map[MSM_FRONTEND_DAI_MAX][2] = {
static int fe_dai_map[MSM_FRONTEND_DAI_MM_SIZE][2] = {
/* MULTIMEDIA1 */
{INVALID_SESSION, INVALID_SESSION},
/* MULTIMEDIA2 */
@@ -158,6 +158,12 @@ void msm_pcm_routing_reg_phy_stream(int fedai_id, int dspst_id, int stream_type)
int i, session_type, path_type, port_type;
struct route_payload payload;
if (fedai_id > MSM_FRONTEND_DAI_MM_MAX_ID) {
/* bad ID assigned in machine driver */
pr_err("%s: bad MM ID\n", __func__);
return;
}
if (stream_type == SNDRV_PCM_STREAM_PLAYBACK) {
session_type = SESSION_TYPE_RX;
path_type = ADM_PATH_PLAYBACK;
@@ -200,6 +206,12 @@ void msm_pcm_routing_dereg_phy_stream(int fedai_id, int stream_type)
{
int i, port_type, session_type;
if (fedai_id > MSM_FRONTEND_DAI_MM_MAX_ID) {
/* bad ID assigned in machine driver */
pr_err("%s: bad MM ID\n", __func__);
return;
}
if (stream_type == SNDRV_PCM_STREAM_PLAYBACK) {
port_type = MSM_AFE_PORT_TYPE_RX;
session_type = SESSION_TYPE_RX;
@@ -229,6 +241,12 @@ static void msm_pcm_routing_process_audio(u16 reg, u16 val, int set)
pr_debug("%s: reg %x val %x set %x\n", __func__, reg, val, set);
if (val > MSM_FRONTEND_DAI_MM_MAX_ID) {
/* recheck FE ID in the mixer control defined in this file */
pr_err("%s: bad MM ID\n", __func__);
return;
}
if (afe_get_port_type(msm_bedais[reg].port_id) ==
MSM_AFE_PORT_TYPE_RX) {
session_type = SESSION_TYPE_RX;
@@ -1253,6 +1271,11 @@ static int msm_pcm_routing_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_pcm_runtime *rtd = substream->private_data;
unsigned int be_id = rtd->dai_link->be_id;
if (be_id >= MSM_BACKEND_DAI_MAX) {
pr_err("%s: unexpected be_id %d\n", __func__, be_id);
return -EINVAL;
}
mutex_lock(&routing_lock);
msm_bedais[be_id].hw_params = params;
mutex_unlock(&routing_lock);
@@ -1278,7 +1301,7 @@ static int msm_pcm_routing_close(struct snd_pcm_substream *substream)
mutex_lock(&routing_lock);
for_each_set_bit(i, &bedai->fe_sessions, MSM_FRONTEND_DAI_MAX) {
for_each_set_bit(i, &bedai->fe_sessions, MSM_FRONTEND_DAI_MM_MAX_ID) {
if (fe_dai_map[i][session_type] != INVALID_SESSION)
adm_close(bedai->port_id);
}
@@ -1332,7 +1355,7 @@ static int msm_pcm_routing_prepare(struct snd_pcm_substream *substream)
*/
bedai->active = 1;
for_each_set_bit(i, &bedai->fe_sessions, MSM_FRONTEND_DAI_MAX) {
for_each_set_bit(i, &bedai->fe_sessions, MSM_FRONTEND_DAI_MM_MAX_ID) {
if (fe_dai_map[i][session_type] != INVALID_SESSION) {
adm_open(bedai->port_id, path_type,
params_rate(bedai->hw_params),

View File

@@ -27,6 +27,12 @@
#define LPASS_BE_AUXPCM_RX "(Backend) AUX_PCM_RX"
#define LPASS_BE_AUXPCM_TX "(Backend) AUX_PCM_TX"
/* For multimedia front-ends, asm session is allocated dynamically.
* Hence, asm session/multimedia front-end mapping has to be maintained.
* Due to this reason, additional multimedia front-end must be placed before
* non-multimedia front-ends.
*/
enum {
MSM_FRONTEND_DAI_MULTIMEDIA1 = 0,
MSM_FRONTEND_DAI_MULTIMEDIA2,
@@ -39,6 +45,9 @@ enum {
MSM_FRONTEND_DAI_MAX,
};
#define MSM_FRONTEND_DAI_MM_SIZE (MSM_FRONTEND_DAI_MULTIMEDIA4 + 1)
#define MSM_FRONTEND_DAI_MM_MAX_ID MSM_FRONTEND_DAI_MULTIMEDIA4
enum {
MSM_BACKEND_DAI_PRI_I2S_RX = 0,
MSM_BACKEND_DAI_PRI_I2S_TX,