Merge "ASoC: msm: ensure ADM is only opened/closed for multimedia purpose" into msm-3.0

This commit is contained in:
Linux Build Service Account
2011-12-14 14:18:39 -08:00
committed by QuIC Gerrit Code Review
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 */ /* 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 */ /* MULTIMEDIA1 */
{INVALID_SESSION, INVALID_SESSION}, {INVALID_SESSION, INVALID_SESSION},
/* MULTIMEDIA2 */ /* 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; int i, session_type, path_type, port_type;
struct route_payload payload; 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) { if (stream_type == SNDRV_PCM_STREAM_PLAYBACK) {
session_type = SESSION_TYPE_RX; session_type = SESSION_TYPE_RX;
path_type = ADM_PATH_PLAYBACK; 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; 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) { if (stream_type == SNDRV_PCM_STREAM_PLAYBACK) {
port_type = MSM_AFE_PORT_TYPE_RX; port_type = MSM_AFE_PORT_TYPE_RX;
session_type = SESSION_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); 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) == if (afe_get_port_type(msm_bedais[reg].port_id) ==
MSM_AFE_PORT_TYPE_RX) { MSM_AFE_PORT_TYPE_RX) {
session_type = SESSION_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; struct snd_soc_pcm_runtime *rtd = substream->private_data;
unsigned int be_id = rtd->dai_link->be_id; 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); mutex_lock(&routing_lock);
msm_bedais[be_id].hw_params = params; msm_bedais[be_id].hw_params = params;
mutex_unlock(&routing_lock); mutex_unlock(&routing_lock);
@@ -1278,7 +1301,7 @@ static int msm_pcm_routing_close(struct snd_pcm_substream *substream)
mutex_lock(&routing_lock); 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) if (fe_dai_map[i][session_type] != INVALID_SESSION)
adm_close(bedai->port_id); adm_close(bedai->port_id);
} }
@@ -1332,7 +1355,7 @@ static int msm_pcm_routing_prepare(struct snd_pcm_substream *substream)
*/ */
bedai->active = 1; 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) { if (fe_dai_map[i][session_type] != INVALID_SESSION) {
adm_open(bedai->port_id, path_type, adm_open(bedai->port_id, path_type,
params_rate(bedai->hw_params), params_rate(bedai->hw_params),

View File

@@ -27,6 +27,12 @@
#define LPASS_BE_AUXPCM_RX "(Backend) AUX_PCM_RX" #define LPASS_BE_AUXPCM_RX "(Backend) AUX_PCM_RX"
#define LPASS_BE_AUXPCM_TX "(Backend) AUX_PCM_TX" #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 { enum {
MSM_FRONTEND_DAI_MULTIMEDIA1 = 0, MSM_FRONTEND_DAI_MULTIMEDIA1 = 0,
MSM_FRONTEND_DAI_MULTIMEDIA2, MSM_FRONTEND_DAI_MULTIMEDIA2,
@@ -39,6 +45,9 @@ enum {
MSM_FRONTEND_DAI_MAX, 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 { enum {
MSM_BACKEND_DAI_PRI_I2S_RX = 0, MSM_BACKEND_DAI_PRI_I2S_RX = 0,
MSM_BACKEND_DAI_PRI_I2S_TX, MSM_BACKEND_DAI_PRI_I2S_TX,