dsp: fix shared buffer format mixer control

Due to SVA5 supports multiple sound models in a
signle SVA session, shared buffer format mixer
control will be called several time to set the
afe data format within one session. This behavior
can exhaust all available afe data format sessions
without freeing them at the end of a SVA session.
Fix this issue by using fe_id to find the matching
SVA session when set afe data format.

Change-Id: I3332b9ff88df2b14eb3e59036164f11ad3342e14
Signed-off-by: Xiaoyu Ye <benyxy@codeaurora.org>
This commit is contained in:
Xiaoyu Ye 2020-12-11 01:55:31 -08:00
commit 3c2489dfbf

View file

@ -1252,7 +1252,7 @@ int get_lsm_port(void)
*/
int q6lsm_set_afe_data_format(uint64_t fe_id, uint16_t afe_data_format)
{
int n = 0;
int n = 0, free_session = LSM_INVALID_SESSION_ID;
if (0 != afe_data_format && 1 != afe_data_format)
goto done;
@ -1261,8 +1261,13 @@ int q6lsm_set_afe_data_format(uint64_t fe_id, uint16_t afe_data_format)
afe_data_format ? "unprocessed" : "processed");
for (n = LSM_MIN_SESSION_ID; n <= LSM_MAX_SESSION_ID; n++) {
if (0 == lsm_client_afe_data[n].fe_id) {
lsm_client_afe_data[n].fe_id = fe_id;
/* Save ID of the first available free session */
if (LSM_INVALID_SESSION_ID == free_session &&
0 == lsm_client_afe_data[n].fe_id)
free_session = n;
/* Find the matching session with fe_id */
if (fe_id == lsm_client_afe_data[n].fe_id) {
lsm_client_afe_data[n].unprocessed_data =
afe_data_format;
pr_debug("%s: session ID is %d, fe_id is %d\n",
@ -1270,6 +1275,18 @@ int q6lsm_set_afe_data_format(uint64_t fe_id, uint16_t afe_data_format)
return 0;
}
}
/*
* When no matching session is found, allocate
* a new one if a free session is available.
*/
if (free_session != LSM_INVALID_SESSION_ID) {
lsm_client_afe_data[free_session].fe_id = fe_id;
lsm_client_afe_data[free_session].unprocessed_data =
afe_data_format;
pr_debug("%s: session ID is %d, fe_id is %d\n",
__func__, free_session, fe_id);
return 0;
}
pr_err("%s: all lsm sessions are taken\n", __func__);
done: