dsp: Mark cal block after use
After applying calibration on DSP, cal block is marked stale to ensure same calibration is not reused for future usecase. Change-Id: I9f446c0602f4ab34ca71b9d2611319624fb19cd2 Signed-off-by: Vikram Panduranga <vpandura@codeaurora.org>
This commit is contained in:

committed by
Gerrit - the friendly Code Review server

parent
dd3e130abe
commit
770b8383d2
@@ -903,6 +903,9 @@ static struct cal_block_data *msm_routing_find_topology_by_path(int path,
|
|||||||
cal_block = list_entry(ptr,
|
cal_block = list_entry(ptr,
|
||||||
struct cal_block_data, list);
|
struct cal_block_data, list);
|
||||||
|
|
||||||
|
if (cal_utils_is_cal_stale(cal_block))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (((struct audio_cal_info_adm_top *)cal_block
|
if (((struct audio_cal_info_adm_top *)cal_block
|
||||||
->cal_info)->path == path) {
|
->cal_info)->path == path) {
|
||||||
return cal_block;
|
return cal_block;
|
||||||
@@ -929,6 +932,9 @@ static struct cal_block_data *msm_routing_find_topology(int path,
|
|||||||
cal_block = list_entry(ptr,
|
cal_block = list_entry(ptr,
|
||||||
struct cal_block_data, list);
|
struct cal_block_data, list);
|
||||||
|
|
||||||
|
if (cal_utils_is_cal_stale(cal_block))
|
||||||
|
continue;
|
||||||
|
|
||||||
cal_info = (struct audio_cal_info_adm_top *)
|
cal_info = (struct audio_cal_info_adm_top *)
|
||||||
cal_block->cal_info;
|
cal_block->cal_info;
|
||||||
if ((cal_info->path == path) &&
|
if ((cal_info->path == path) &&
|
||||||
@@ -939,9 +945,14 @@ static struct cal_block_data *msm_routing_find_topology(int path,
|
|||||||
}
|
}
|
||||||
pr_debug("%s: Can't find topology for path %d, app %d, acdb_id %d defaulting to search by path\n",
|
pr_debug("%s: Can't find topology for path %d, app %d, acdb_id %d defaulting to search by path\n",
|
||||||
__func__, path, app_type, acdb_id);
|
__func__, path, app_type, acdb_id);
|
||||||
return msm_routing_find_topology_by_path(cal_index, path);
|
return msm_routing_find_topology_by_path(path, cal_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieving cal_block will mark cal_block as stale.
|
||||||
|
* Hence it cannot be reused or resent unless the flag
|
||||||
|
* is reset.
|
||||||
|
*/
|
||||||
static int msm_routing_get_adm_topology(int fedai_id, int session_type,
|
static int msm_routing_get_adm_topology(int fedai_id, int session_type,
|
||||||
int be_id)
|
int be_id)
|
||||||
{
|
{
|
||||||
@@ -963,20 +974,24 @@ static int msm_routing_get_adm_topology(int fedai_id, int session_type,
|
|||||||
cal_block = msm_routing_find_topology(session_type, app_type,
|
cal_block = msm_routing_find_topology(session_type, app_type,
|
||||||
acdb_dev_id,
|
acdb_dev_id,
|
||||||
ADM_TOPOLOGY_CAL_TYPE_IDX);
|
ADM_TOPOLOGY_CAL_TYPE_IDX);
|
||||||
if (cal_block != NULL)
|
if (cal_block != NULL) {
|
||||||
topology = ((struct audio_cal_info_adm_top *)
|
topology = ((struct audio_cal_info_adm_top *)
|
||||||
cal_block->cal_info)->topology;
|
cal_block->cal_info)->topology;
|
||||||
mutex_unlock(&cal_data[ADM_TOPOLOGY_CAL_TYPE_IDX]->lock);
|
cal_utils_mark_cal_used(cal_block);
|
||||||
|
mutex_unlock(&cal_data[ADM_TOPOLOGY_CAL_TYPE_IDX]->lock);
|
||||||
|
} else {
|
||||||
|
mutex_unlock(&cal_data[ADM_TOPOLOGY_CAL_TYPE_IDX]->lock);
|
||||||
|
|
||||||
if (cal_block == NULL) {
|
|
||||||
pr_debug("%s: Check for LSM topology\n", __func__);
|
pr_debug("%s: Check for LSM topology\n", __func__);
|
||||||
mutex_lock(&cal_data[ADM_LSM_TOPOLOGY_CAL_TYPE_IDX]->lock);
|
mutex_lock(&cal_data[ADM_LSM_TOPOLOGY_CAL_TYPE_IDX]->lock);
|
||||||
cal_block = msm_routing_find_topology(session_type, app_type,
|
cal_block = msm_routing_find_topology(session_type, app_type,
|
||||||
acdb_dev_id,
|
acdb_dev_id,
|
||||||
ADM_LSM_TOPOLOGY_CAL_TYPE_IDX);
|
ADM_LSM_TOPOLOGY_CAL_TYPE_IDX);
|
||||||
if (cal_block != NULL)
|
if (cal_block != NULL) {
|
||||||
topology = ((struct audio_cal_info_adm_top *)
|
topology = ((struct audio_cal_info_adm_top *)
|
||||||
cal_block->cal_info)->topology;
|
cal_block->cal_info)->topology;
|
||||||
|
cal_utils_mark_cal_used(cal_block);
|
||||||
|
}
|
||||||
mutex_unlock(&cal_data[ADM_LSM_TOPOLOGY_CAL_TYPE_IDX]->lock);
|
mutex_unlock(&cal_data[ADM_LSM_TOPOLOGY_CAL_TYPE_IDX]->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1434,7 +1449,7 @@ int msm_pcm_routing_reg_phy_stream(int fedai_id, int perf_mode,
|
|||||||
if ((copp_idx < 0) ||
|
if ((copp_idx < 0) ||
|
||||||
(copp_idx >= MAX_COPPS_PER_PORT)) {
|
(copp_idx >= MAX_COPPS_PER_PORT)) {
|
||||||
pr_err("%s: adm open failed copp_idx:%d\n",
|
pr_err("%s: adm open failed copp_idx:%d\n",
|
||||||
__func__, copp_idx);
|
__func__, copp_idx);
|
||||||
mutex_unlock(&routing_lock);
|
mutex_unlock(&routing_lock);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
@@ -1033,9 +1033,40 @@ int cal_utils_set_cal(size_t data_size, void *data,
|
|||||||
((uint8_t *)data + sizeof(struct audio_cal_type_basic)),
|
((uint8_t *)data + sizeof(struct audio_cal_type_basic)),
|
||||||
data_size - sizeof(struct audio_cal_type_basic));
|
data_size - sizeof(struct audio_cal_type_basic));
|
||||||
|
|
||||||
|
/* reset buffer stale flag */
|
||||||
|
cal_block->cal_stale = false;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
mutex_unlock(&cal_type->lock);
|
mutex_unlock(&cal_type->lock);
|
||||||
done:
|
done:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(cal_utils_set_cal);
|
EXPORT_SYMBOL(cal_utils_set_cal);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cal_utils_mark_cal_used
|
||||||
|
*
|
||||||
|
* @cal_block: pointer to cal block
|
||||||
|
*/
|
||||||
|
void cal_utils_mark_cal_used(struct cal_block_data *cal_block)
|
||||||
|
{
|
||||||
|
if (cal_block)
|
||||||
|
cal_block->cal_stale = true;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(cal_utils_mark_cal_used);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cal_utils_is_cal_stale
|
||||||
|
*
|
||||||
|
* @cal_block: pointer to cal block
|
||||||
|
*
|
||||||
|
* Returns true if cal block is stale, false otherwise
|
||||||
|
*/
|
||||||
|
bool cal_utils_is_cal_stale(struct cal_block_data *cal_block)
|
||||||
|
{
|
||||||
|
if ((cal_block) && (cal_block->cal_stale))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(cal_utils_is_cal_stale);
|
||||||
|
18
dsp/q6adm.c
18
dsp/q6adm.c
@@ -1856,7 +1856,7 @@ static void send_adm_custom_topology(void)
|
|||||||
this_adm.set_custom_topology = 0;
|
this_adm.set_custom_topology = 0;
|
||||||
|
|
||||||
cal_block = cal_utils_get_only_cal_block(this_adm.cal_data[cal_index]);
|
cal_block = cal_utils_get_only_cal_block(this_adm.cal_data[cal_index]);
|
||||||
if (cal_block == NULL)
|
if (cal_block == NULL || cal_utils_is_cal_stale(cal_block))
|
||||||
goto unlock;
|
goto unlock;
|
||||||
|
|
||||||
pr_debug("%s: Sending cal_index %d\n", __func__, cal_index);
|
pr_debug("%s: Sending cal_index %d\n", __func__, cal_index);
|
||||||
@@ -1996,8 +1996,11 @@ static struct cal_block_data *adm_find_cal_by_path(int cal_index, int path)
|
|||||||
cal_block = list_entry(ptr,
|
cal_block = list_entry(ptr,
|
||||||
struct cal_block_data, list);
|
struct cal_block_data, list);
|
||||||
|
|
||||||
|
if (cal_utils_is_cal_stale(cal_block))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (cal_index == ADM_AUDPROC_CAL ||
|
if (cal_index == ADM_AUDPROC_CAL ||
|
||||||
cal_index == ADM_LSM_AUDPROC_CAL) {
|
cal_index == ADM_LSM_AUDPROC_CAL) {
|
||||||
audproc_cal_info = cal_block->cal_info;
|
audproc_cal_info = cal_block->cal_info;
|
||||||
if ((audproc_cal_info->path == path) &&
|
if ((audproc_cal_info->path == path) &&
|
||||||
(cal_block->cal_data.size > 0))
|
(cal_block->cal_data.size > 0))
|
||||||
@@ -2030,8 +2033,11 @@ static struct cal_block_data *adm_find_cal_by_app_type(int cal_index, int path,
|
|||||||
cal_block = list_entry(ptr,
|
cal_block = list_entry(ptr,
|
||||||
struct cal_block_data, list);
|
struct cal_block_data, list);
|
||||||
|
|
||||||
|
if (cal_utils_is_cal_stale(cal_block))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (cal_index == ADM_AUDPROC_CAL ||
|
if (cal_index == ADM_AUDPROC_CAL ||
|
||||||
cal_index == ADM_LSM_AUDPROC_CAL) {
|
cal_index == ADM_LSM_AUDPROC_CAL) {
|
||||||
audproc_cal_info = cal_block->cal_info;
|
audproc_cal_info = cal_block->cal_info;
|
||||||
if ((audproc_cal_info->path == path) &&
|
if ((audproc_cal_info->path == path) &&
|
||||||
(audproc_cal_info->app_type == app_type) &&
|
(audproc_cal_info->app_type == app_type) &&
|
||||||
@@ -2067,6 +2073,8 @@ static struct cal_block_data *adm_find_cal(int cal_index, int path,
|
|||||||
|
|
||||||
cal_block = list_entry(ptr,
|
cal_block = list_entry(ptr,
|
||||||
struct cal_block_data, list);
|
struct cal_block_data, list);
|
||||||
|
if (cal_utils_is_cal_stale(cal_block))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (cal_index == ADM_AUDPROC_CAL ||
|
if (cal_index == ADM_AUDPROC_CAL ||
|
||||||
cal_index == ADM_LSM_AUDPROC_CAL) {
|
cal_index == ADM_LSM_AUDPROC_CAL) {
|
||||||
@@ -2135,6 +2143,8 @@ static void send_adm_cal_type(int cal_index, int path, int port_id,
|
|||||||
|
|
||||||
ret = adm_remap_and_send_cal_block(cal_index, port_id, copp_idx,
|
ret = adm_remap_and_send_cal_block(cal_index, port_id, copp_idx,
|
||||||
cal_block, perf_mode, app_type, acdb_id, sample_rate);
|
cal_block, perf_mode, app_type, acdb_id, sample_rate);
|
||||||
|
|
||||||
|
cal_utils_mark_cal_used(cal_block);
|
||||||
unlock:
|
unlock:
|
||||||
mutex_unlock(&this_adm.cal_data[cal_index]->lock);
|
mutex_unlock(&this_adm.cal_data[cal_index]->lock);
|
||||||
done:
|
done:
|
||||||
@@ -3111,7 +3121,7 @@ int send_rtac_audvol_cal(void)
|
|||||||
|
|
||||||
cal_block = cal_utils_get_only_cal_block(
|
cal_block = cal_utils_get_only_cal_block(
|
||||||
this_adm.cal_data[ADM_RTAC_AUDVOL_CAL]);
|
this_adm.cal_data[ADM_RTAC_AUDVOL_CAL]);
|
||||||
if (cal_block == NULL) {
|
if (cal_block == NULL || cal_utils_is_cal_stale(cal_block)) {
|
||||||
pr_err("%s: can't find cal block!\n", __func__);
|
pr_err("%s: can't find cal block!\n", __func__);
|
||||||
goto unlock;
|
goto unlock;
|
||||||
}
|
}
|
||||||
|
33
dsp/q6afe.c
33
dsp/q6afe.c
@@ -1344,7 +1344,7 @@ static void afe_send_custom_topology(void)
|
|||||||
goto unlock;
|
goto unlock;
|
||||||
this_afe.set_custom_topology = 0;
|
this_afe.set_custom_topology = 0;
|
||||||
cal_block = cal_utils_get_only_cal_block(this_afe.cal_data[cal_index]);
|
cal_block = cal_utils_get_only_cal_block(this_afe.cal_data[cal_index]);
|
||||||
if (cal_block == NULL) {
|
if (cal_block == NULL || cal_utils_is_cal_stale(cal_block)) {
|
||||||
pr_err("%s cal_block not found!!\n", __func__);
|
pr_err("%s cal_block not found!!\n", __func__);
|
||||||
goto unlock;
|
goto unlock;
|
||||||
}
|
}
|
||||||
@@ -1709,7 +1709,9 @@ static struct cal_block_data *afe_find_cal_topo_id_by_port(
|
|||||||
&cal_type->cal_blocks) {
|
&cal_type->cal_blocks) {
|
||||||
cal_block = list_entry(ptr,
|
cal_block = list_entry(ptr,
|
||||||
struct cal_block_data, list);
|
struct cal_block_data, list);
|
||||||
|
/* Skip cal_block if it is already marked stale */
|
||||||
|
if (cal_utils_is_cal_stale(cal_block))
|
||||||
|
continue;
|
||||||
path = ((afe_get_port_type(port_id) ==
|
path = ((afe_get_port_type(port_id) ==
|
||||||
MSM_AFE_PORT_TYPE_TX)?(TX_DEVICE):(RX_DEVICE));
|
MSM_AFE_PORT_TYPE_TX)?(TX_DEVICE):(RX_DEVICE));
|
||||||
afe_top =
|
afe_top =
|
||||||
@@ -1737,6 +1739,11 @@ err_exit:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieving cal_block will mark cal_block as stale.
|
||||||
|
* Hence it cannot be reused or resent unless the flag
|
||||||
|
* is reset.
|
||||||
|
*/
|
||||||
static int afe_get_cal_topology_id(u16 port_id, u32 *topology_id,
|
static int afe_get_cal_topology_id(u16 port_id, u32 *topology_id,
|
||||||
int cal_type_index)
|
int cal_type_index)
|
||||||
{
|
{
|
||||||
@@ -1746,7 +1753,8 @@ static int afe_get_cal_topology_id(u16 port_id, u32 *topology_id,
|
|||||||
struct audio_cal_info_afe_top *afe_top_info = NULL;
|
struct audio_cal_info_afe_top *afe_top_info = NULL;
|
||||||
|
|
||||||
if (this_afe.cal_data[cal_type_index] == NULL) {
|
if (this_afe.cal_data[cal_type_index] == NULL) {
|
||||||
pr_err("%s: [AFE_TOPOLOGY_CAL] not initialized\n", __func__);
|
pr_err("%s: cal_type %d not initialized\n", __func__,
|
||||||
|
cal_type_index);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
if (topology_id == NULL) {
|
if (topology_id == NULL) {
|
||||||
@@ -1759,8 +1767,8 @@ static int afe_get_cal_topology_id(u16 port_id, u32 *topology_id,
|
|||||||
cal_block = afe_find_cal_topo_id_by_port(
|
cal_block = afe_find_cal_topo_id_by_port(
|
||||||
this_afe.cal_data[cal_type_index], port_id);
|
this_afe.cal_data[cal_type_index], port_id);
|
||||||
if (cal_block == NULL) {
|
if (cal_block == NULL) {
|
||||||
pr_err("%s: [AFE_TOPOLOGY_CAL] not initialized for this port %d\n",
|
pr_err("%s: cal_type %d not initialized for this port %d\n",
|
||||||
__func__, port_id);
|
__func__, cal_type_index, port_id);
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto unlock;
|
goto unlock;
|
||||||
}
|
}
|
||||||
@@ -1774,6 +1782,7 @@ static int afe_get_cal_topology_id(u16 port_id, u32 *topology_id,
|
|||||||
goto unlock;
|
goto unlock;
|
||||||
}
|
}
|
||||||
*topology_id = (u32)afe_top_info->topology;
|
*topology_id = (u32)afe_top_info->topology;
|
||||||
|
cal_utils_mark_cal_used(cal_block);
|
||||||
|
|
||||||
pr_debug("%s: port_id = %u acdb_id = %d topology_id = %u ret=%d\n",
|
pr_debug("%s: port_id = %u acdb_id = %d topology_id = %u ret=%d\n",
|
||||||
__func__, port_id, afe_top_info->acdb_id,
|
__func__, port_id, afe_top_info->acdb_id,
|
||||||
@@ -1940,7 +1949,7 @@ static int send_afe_cal_type(int cal_index, int port_id)
|
|||||||
cal_block = cal_utils_get_only_cal_block(
|
cal_block = cal_utils_get_only_cal_block(
|
||||||
this_afe.cal_data[cal_index]);
|
this_afe.cal_data[cal_index]);
|
||||||
|
|
||||||
if (cal_block == NULL) {
|
if (cal_block == NULL || cal_utils_is_cal_stale(cal_block)) {
|
||||||
pr_err("%s cal_block not found!!\n", __func__);
|
pr_err("%s cal_block not found!!\n", __func__);
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto unlock;
|
goto unlock;
|
||||||
@@ -1959,6 +1968,9 @@ static int send_afe_cal_type(int cal_index, int port_id)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
pr_debug("%s: No cal sent for cal_index %d, port_id = 0x%x! ret %d\n",
|
pr_debug("%s: No cal sent for cal_index %d, port_id = 0x%x! ret %d\n",
|
||||||
__func__, cal_index, port_id, ret);
|
__func__, cal_index, port_id, ret);
|
||||||
|
|
||||||
|
cal_utils_mark_cal_used(cal_block);
|
||||||
|
|
||||||
unlock:
|
unlock:
|
||||||
mutex_unlock(&this_afe.cal_data[cal_index]->lock);
|
mutex_unlock(&this_afe.cal_data[cal_index]->lock);
|
||||||
done:
|
done:
|
||||||
@@ -5272,7 +5284,7 @@ static int afe_sidetone_iir(u16 tx_port_id)
|
|||||||
}
|
}
|
||||||
mutex_lock(&this_afe.cal_data[cal_index]->lock);
|
mutex_lock(&this_afe.cal_data[cal_index]->lock);
|
||||||
cal_block = cal_utils_get_only_cal_block(this_afe.cal_data[cal_index]);
|
cal_block = cal_utils_get_only_cal_block(this_afe.cal_data[cal_index]);
|
||||||
if (cal_block == NULL) {
|
if (cal_block == NULL || cal_utils_is_cal_stale(cal_block)) {
|
||||||
pr_err("%s: cal_block not found\n ", __func__);
|
pr_err("%s: cal_block not found\n ", __func__);
|
||||||
mutex_unlock(&this_afe.cal_data[cal_index]->lock);
|
mutex_unlock(&this_afe.cal_data[cal_index]->lock);
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
@@ -5399,7 +5411,7 @@ static int afe_sidetone(u16 tx_port_id, u16 rx_port_id, bool enable)
|
|||||||
|
|
||||||
mutex_lock(&this_afe.cal_data[cal_index]->lock);
|
mutex_lock(&this_afe.cal_data[cal_index]->lock);
|
||||||
cal_block = cal_utils_get_only_cal_block(this_afe.cal_data[cal_index]);
|
cal_block = cal_utils_get_only_cal_block(this_afe.cal_data[cal_index]);
|
||||||
if (cal_block == NULL) {
|
if (cal_block == NULL || cal_utils_is_cal_stale(cal_block)) {
|
||||||
pr_err("%s: cal_block not found\n", __func__);
|
pr_err("%s: cal_block not found\n", __func__);
|
||||||
mutex_unlock(&this_afe.cal_data[cal_index]->lock);
|
mutex_unlock(&this_afe.cal_data[cal_index]->lock);
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
@@ -6533,6 +6545,9 @@ static struct cal_block_data *afe_find_hw_delay_by_path(
|
|||||||
cal_block = list_entry(ptr,
|
cal_block = list_entry(ptr,
|
||||||
struct cal_block_data, list);
|
struct cal_block_data, list);
|
||||||
|
|
||||||
|
if (cal_utils_is_cal_stale(cal_block))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (((struct audio_cal_info_hw_delay *)cal_block->cal_info)
|
if (((struct audio_cal_info_hw_delay *)cal_block->cal_info)
|
||||||
->path == path) {
|
->path == path) {
|
||||||
return cal_block;
|
return cal_block;
|
||||||
@@ -6596,6 +6611,8 @@ static int afe_get_cal_hw_delay(int32_t path,
|
|||||||
ret = -EFAULT;
|
ret = -EFAULT;
|
||||||
goto unlock;
|
goto unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cal_utils_mark_cal_used(cal_block);
|
||||||
pr_debug("%s: Path = %d samplerate = %u usec = %u status %d\n",
|
pr_debug("%s: Path = %d samplerate = %u usec = %u status %d\n",
|
||||||
__func__, path, entry->sample_rate, entry->delay_usec, ret);
|
__func__, path, entry->sample_rate, entry->delay_usec, ret);
|
||||||
unlock:
|
unlock:
|
||||||
|
103
dsp/q6asm.c
103
dsp/q6asm.c
@@ -125,8 +125,7 @@ static int q6asm_map_channels(u8 *channel_mapping, uint32_t channels,
|
|||||||
void *q6asm_mmap_apr_reg(void);
|
void *q6asm_mmap_apr_reg(void);
|
||||||
|
|
||||||
static int q6asm_is_valid_session(struct apr_client_data *data, void *priv);
|
static int q6asm_is_valid_session(struct apr_client_data *data, void *priv);
|
||||||
static int q6asm_get_asm_topology_cal(void);
|
static int q6asm_get_asm_topology_apptype(struct q6asm_cal_info *cal_info);
|
||||||
static int q6asm_get_asm_app_type_cal(void);
|
|
||||||
|
|
||||||
/* for ASM custom topology */
|
/* for ASM custom topology */
|
||||||
static struct cal_type_data *cal_data[ASM_MAX_CAL_TYPES];
|
static struct cal_type_data *cal_data[ASM_MAX_CAL_TYPES];
|
||||||
@@ -759,7 +758,7 @@ int send_asm_custom_topology(struct audio_client *ac)
|
|||||||
set_custom_topology = 0;
|
set_custom_topology = 0;
|
||||||
|
|
||||||
cal_block = cal_utils_get_only_cal_block(cal_data[ASM_CUSTOM_TOP_CAL]);
|
cal_block = cal_utils_get_only_cal_block(cal_data[ASM_CUSTOM_TOP_CAL]);
|
||||||
if (cal_block == NULL)
|
if (cal_block == NULL || cal_utils_is_cal_stale(cal_block))
|
||||||
goto unlock;
|
goto unlock;
|
||||||
|
|
||||||
if (cal_block->cal_data.size == 0) {
|
if (cal_block->cal_data.size == 0) {
|
||||||
@@ -2800,6 +2799,7 @@ static int __q6asm_open_read(struct audio_client *ac,
|
|||||||
{
|
{
|
||||||
int rc = 0x00;
|
int rc = 0x00;
|
||||||
struct asm_stream_cmd_open_read_v3 open;
|
struct asm_stream_cmd_open_read_v3 open;
|
||||||
|
struct q6asm_cal_info cal_info;
|
||||||
|
|
||||||
config_debug_fs_reset_index();
|
config_debug_fs_reset_index();
|
||||||
|
|
||||||
@@ -2819,12 +2819,15 @@ static int __q6asm_open_read(struct audio_client *ac,
|
|||||||
/* Stream prio : High, provide meta info with encoded frames */
|
/* Stream prio : High, provide meta info with encoded frames */
|
||||||
open.src_endpointype = ASM_END_POINT_DEVICE_MATRIX;
|
open.src_endpointype = ASM_END_POINT_DEVICE_MATRIX;
|
||||||
|
|
||||||
open.preprocopo_id = q6asm_get_asm_topology_cal();
|
rc = q6asm_get_asm_topology_apptype(&cal_info);
|
||||||
|
open.preprocopo_id = cal_info.topology_id;
|
||||||
|
|
||||||
|
|
||||||
open.bits_per_sample = bits_per_sample;
|
open.bits_per_sample = bits_per_sample;
|
||||||
open.mode_flags = 0x0;
|
open.mode_flags = 0x0;
|
||||||
|
|
||||||
ac->topology = open.preprocopo_id;
|
ac->topology = open.preprocopo_id;
|
||||||
ac->app_type = q6asm_get_asm_app_type_cal();
|
ac->app_type = cal_info.app_type;
|
||||||
if (ac->perf_mode == LOW_LATENCY_PCM_MODE) {
|
if (ac->perf_mode == LOW_LATENCY_PCM_MODE) {
|
||||||
open.mode_flags |= ASM_LOW_LATENCY_TX_STREAM_SESSION <<
|
open.mode_flags |= ASM_LOW_LATENCY_TX_STREAM_SESSION <<
|
||||||
ASM_SHIFT_STREAM_PERF_MODE_FLAG_IN_OPEN_READ;
|
ASM_SHIFT_STREAM_PERF_MODE_FLAG_IN_OPEN_READ;
|
||||||
@@ -3086,6 +3089,7 @@ static int __q6asm_open_write(struct audio_client *ac, uint32_t format,
|
|||||||
{
|
{
|
||||||
int rc = 0x00;
|
int rc = 0x00;
|
||||||
struct asm_stream_cmd_open_write_v3 open;
|
struct asm_stream_cmd_open_write_v3 open;
|
||||||
|
struct q6asm_cal_info cal_info;
|
||||||
|
|
||||||
if (ac == NULL) {
|
if (ac == NULL) {
|
||||||
pr_err("%s: APR handle NULL\n", __func__);
|
pr_err("%s: APR handle NULL\n", __func__);
|
||||||
@@ -3134,7 +3138,9 @@ static int __q6asm_open_write(struct audio_client *ac, uint32_t format,
|
|||||||
open.sink_endpointype = ASM_END_POINT_DEVICE_MATRIX;
|
open.sink_endpointype = ASM_END_POINT_DEVICE_MATRIX;
|
||||||
open.bits_per_sample = bits_per_sample;
|
open.bits_per_sample = bits_per_sample;
|
||||||
|
|
||||||
open.postprocopo_id = q6asm_get_asm_topology_cal();
|
rc = q6asm_get_asm_topology_apptype(&cal_info);
|
||||||
|
open.postprocopo_id = cal_info.topology_id;
|
||||||
|
|
||||||
if (ac->perf_mode != LEGACY_PCM_MODE)
|
if (ac->perf_mode != LEGACY_PCM_MODE)
|
||||||
open.postprocopo_id = ASM_STREAM_POSTPROCOPO_ID_NONE;
|
open.postprocopo_id = ASM_STREAM_POSTPROCOPO_ID_NONE;
|
||||||
|
|
||||||
@@ -3147,7 +3153,7 @@ static int __q6asm_open_write(struct audio_client *ac, uint32_t format,
|
|||||||
*/
|
*/
|
||||||
if (!ac->topology) {
|
if (!ac->topology) {
|
||||||
ac->topology = open.postprocopo_id;
|
ac->topology = open.postprocopo_id;
|
||||||
ac->app_type = q6asm_get_asm_app_type_cal();
|
ac->app_type = cal_info.app_type;
|
||||||
}
|
}
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case FORMAT_LINEAR_PCM:
|
case FORMAT_LINEAR_PCM:
|
||||||
@@ -3334,6 +3340,7 @@ static int __q6asm_open_read_write(struct audio_client *ac, uint32_t rd_format,
|
|||||||
{
|
{
|
||||||
int rc = 0x00;
|
int rc = 0x00;
|
||||||
struct asm_stream_cmd_open_readwrite_v2 open;
|
struct asm_stream_cmd_open_readwrite_v2 open;
|
||||||
|
struct q6asm_cal_info cal_info;
|
||||||
|
|
||||||
if (ac == NULL) {
|
if (ac == NULL) {
|
||||||
pr_err("%s: APR handle NULL\n", __func__);
|
pr_err("%s: APR handle NULL\n", __func__);
|
||||||
@@ -3355,12 +3362,13 @@ static int __q6asm_open_read_write(struct audio_client *ac, uint32_t rd_format,
|
|||||||
open.mode_flags = is_meta_data_mode ? BUFFER_META_ENABLE : 0;
|
open.mode_flags = is_meta_data_mode ? BUFFER_META_ENABLE : 0;
|
||||||
open.bits_per_sample = bits_per_sample;
|
open.bits_per_sample = bits_per_sample;
|
||||||
/* source endpoint : matrix */
|
/* source endpoint : matrix */
|
||||||
open.postprocopo_id = q6asm_get_asm_topology_cal();
|
rc = q6asm_get_asm_topology_apptype(&cal_info);
|
||||||
|
open.postprocopo_id = cal_info.topology_id;
|
||||||
|
|
||||||
open.postprocopo_id = overwrite_topology ?
|
open.postprocopo_id = overwrite_topology ?
|
||||||
topology : open.postprocopo_id;
|
topology : open.postprocopo_id;
|
||||||
ac->topology = open.postprocopo_id;
|
ac->topology = open.postprocopo_id;
|
||||||
ac->app_type = q6asm_get_asm_app_type_cal();
|
ac->app_type = cal_info.app_type;
|
||||||
|
|
||||||
|
|
||||||
switch (wr_format) {
|
switch (wr_format) {
|
||||||
@@ -3553,6 +3561,7 @@ EXPORT_SYMBOL(q6asm_open_read_write_v2);
|
|||||||
int q6asm_open_loopback_v2(struct audio_client *ac, uint16_t bits_per_sample)
|
int q6asm_open_loopback_v2(struct audio_client *ac, uint16_t bits_per_sample)
|
||||||
{
|
{
|
||||||
int rc = 0x00;
|
int rc = 0x00;
|
||||||
|
struct q6asm_cal_info cal_info;
|
||||||
|
|
||||||
if (ac == NULL) {
|
if (ac == NULL) {
|
||||||
pr_err("%s: APR handle NULL\n", __func__);
|
pr_err("%s: APR handle NULL\n", __func__);
|
||||||
@@ -3577,9 +3586,10 @@ int q6asm_open_loopback_v2(struct audio_client *ac, uint16_t bits_per_sample)
|
|||||||
open.src_format_id = ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V2;
|
open.src_format_id = ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V2;
|
||||||
open.sink_format_id = ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V2;
|
open.sink_format_id = ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V2;
|
||||||
/* source endpoint : matrix */
|
/* source endpoint : matrix */
|
||||||
open.audproc_topo_id = q6asm_get_asm_topology_cal();
|
rc = q6asm_get_asm_topology_apptype(&cal_info);
|
||||||
|
open.audproc_topo_id = cal_info.topology_id;
|
||||||
|
|
||||||
ac->app_type = q6asm_get_asm_app_type_cal();
|
ac->app_type = cal_info.app_type;
|
||||||
if (ac->perf_mode == LOW_LATENCY_PCM_MODE)
|
if (ac->perf_mode == LOW_LATENCY_PCM_MODE)
|
||||||
open.mode_flags |= ASM_LOW_LATENCY_STREAM_SESSION;
|
open.mode_flags |= ASM_LOW_LATENCY_STREAM_SESSION;
|
||||||
else
|
else
|
||||||
@@ -3608,9 +3618,10 @@ int q6asm_open_loopback_v2(struct audio_client *ac, uint16_t bits_per_sample)
|
|||||||
open.src_endpointype = 0;
|
open.src_endpointype = 0;
|
||||||
open.sink_endpointype = 0;
|
open.sink_endpointype = 0;
|
||||||
/* source endpoint : matrix */
|
/* source endpoint : matrix */
|
||||||
open.postprocopo_id = q6asm_get_asm_topology_cal();
|
rc = q6asm_get_asm_topology_apptype(&cal_info);
|
||||||
|
open.postprocopo_id = cal_info.topology_id;
|
||||||
|
|
||||||
ac->app_type = q6asm_get_asm_app_type_cal();
|
ac->app_type = cal_info.app_type;
|
||||||
ac->topology = open.postprocopo_id;
|
ac->topology = open.postprocopo_id;
|
||||||
open.bits_per_sample = bits_per_sample;
|
open.bits_per_sample = bits_per_sample;
|
||||||
open.reserved = 0;
|
open.reserved = 0;
|
||||||
@@ -3665,6 +3676,7 @@ int q6asm_open_transcode_loopback(struct audio_client *ac,
|
|||||||
{
|
{
|
||||||
int rc = 0x00;
|
int rc = 0x00;
|
||||||
struct asm_stream_cmd_open_transcode_loopback_t open;
|
struct asm_stream_cmd_open_transcode_loopback_t open;
|
||||||
|
struct q6asm_cal_info cal_info;
|
||||||
|
|
||||||
if (ac == NULL) {
|
if (ac == NULL) {
|
||||||
pr_err("%s: APR handle NULL\n", __func__);
|
pr_err("%s: APR handle NULL\n", __func__);
|
||||||
@@ -3712,9 +3724,11 @@ int q6asm_open_transcode_loopback(struct audio_client *ac,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* source endpoint : matrix */
|
/* source endpoint : matrix */
|
||||||
open.audproc_topo_id = q6asm_get_asm_topology_cal();
|
rc = q6asm_get_asm_topology_apptype(&cal_info);
|
||||||
|
open.audproc_topo_id = cal_info.topology_id;
|
||||||
|
|
||||||
ac->app_type = q6asm_get_asm_app_type_cal();
|
|
||||||
|
ac->app_type = cal_info.app_type;
|
||||||
if (ac->perf_mode == LOW_LATENCY_PCM_MODE)
|
if (ac->perf_mode == LOW_LATENCY_PCM_MODE)
|
||||||
open.mode_flags |= ASM_LOW_LATENCY_STREAM_SESSION;
|
open.mode_flags |= ASM_LOW_LATENCY_STREAM_SESSION;
|
||||||
else
|
else
|
||||||
@@ -3884,6 +3898,7 @@ int q6asm_open_shared_io(struct audio_client *ac,
|
|||||||
struct asm_stream_cmd_open_shared_io *open;
|
struct asm_stream_cmd_open_shared_io *open;
|
||||||
u8 *channel_mapping;
|
u8 *channel_mapping;
|
||||||
int i, size_of_open, num_watermarks, bufsz, bufcnt, rc, flags = 0;
|
int i, size_of_open, num_watermarks, bufsz, bufcnt, rc, flags = 0;
|
||||||
|
struct q6asm_cal_info cal_info;
|
||||||
|
|
||||||
if (!ac || !config)
|
if (!ac || !config)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@@ -3950,7 +3965,8 @@ int q6asm_open_shared_io(struct audio_client *ac,
|
|||||||
open->endpoint_type = ASM_END_POINT_DEVICE_MATRIX;
|
open->endpoint_type = ASM_END_POINT_DEVICE_MATRIX;
|
||||||
open->topo_bits_per_sample = config->bits_per_sample;
|
open->topo_bits_per_sample = config->bits_per_sample;
|
||||||
|
|
||||||
open->topo_id = q6asm_get_asm_topology_cal();
|
rc = q6asm_get_asm_topology_apptype(&cal_info);
|
||||||
|
open->topo_id = cal_info.topology_id;
|
||||||
|
|
||||||
if (config->format == FORMAT_LINEAR_PCM)
|
if (config->format == FORMAT_LINEAR_PCM)
|
||||||
open->fmt_id = ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V3;
|
open->fmt_id = ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V3;
|
||||||
@@ -9766,51 +9782,39 @@ done:
|
|||||||
return app_type;
|
return app_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int q6asm_get_asm_topology_cal(void)
|
/*
|
||||||
|
* Retrieving cal_block will mark cal_block as stale.
|
||||||
|
* Hence it cannot be reused or resent unless the flag
|
||||||
|
* is reset.
|
||||||
|
*/
|
||||||
|
static int q6asm_get_asm_topology_apptype(struct q6asm_cal_info *cal_info)
|
||||||
{
|
{
|
||||||
int topology = DEFAULT_POPP_TOPOLOGY;
|
|
||||||
struct cal_block_data *cal_block = NULL;
|
struct cal_block_data *cal_block = NULL;
|
||||||
|
|
||||||
|
cal_info->topology_id = DEFAULT_POPP_TOPOLOGY;
|
||||||
|
cal_info->app_type = DEFAULT_APP_TYPE;
|
||||||
|
|
||||||
if (cal_data[ASM_TOPOLOGY_CAL] == NULL)
|
if (cal_data[ASM_TOPOLOGY_CAL] == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
mutex_lock(&cal_data[ASM_TOPOLOGY_CAL]->lock);
|
mutex_lock(&cal_data[ASM_TOPOLOGY_CAL]->lock);
|
||||||
cal_block = cal_utils_get_only_cal_block(cal_data[ASM_TOPOLOGY_CAL]);
|
cal_block = cal_utils_get_only_cal_block(cal_data[ASM_TOPOLOGY_CAL]);
|
||||||
if (cal_block == NULL)
|
if (cal_block == NULL || cal_utils_is_cal_stale(cal_block))
|
||||||
goto unlock;
|
goto unlock;
|
||||||
|
cal_info->topology_id = ((struct audio_cal_info_asm_top *)
|
||||||
topology = ((struct audio_cal_info_asm_top *)
|
|
||||||
cal_block->cal_info)->topology;
|
cal_block->cal_info)->topology;
|
||||||
unlock:
|
cal_info->app_type = ((struct audio_cal_info_asm_top *)
|
||||||
mutex_unlock(&cal_data[ASM_TOPOLOGY_CAL]->lock);
|
|
||||||
done:
|
|
||||||
pr_debug("%s: Using topology %d\n", __func__, topology);
|
|
||||||
return topology;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int q6asm_get_asm_app_type_cal(void)
|
|
||||||
{
|
|
||||||
int app_type = DEFAULT_APP_TYPE;
|
|
||||||
struct cal_block_data *cal_block = NULL;
|
|
||||||
|
|
||||||
if (cal_data[ASM_TOPOLOGY_CAL] == NULL)
|
|
||||||
goto done;
|
|
||||||
|
|
||||||
mutex_lock(&cal_data[ASM_TOPOLOGY_CAL]->lock);
|
|
||||||
cal_block = cal_utils_get_only_cal_block(cal_data[ASM_TOPOLOGY_CAL]);
|
|
||||||
if (cal_block == NULL)
|
|
||||||
goto unlock;
|
|
||||||
|
|
||||||
app_type = ((struct audio_cal_info_asm_top *)
|
|
||||||
cal_block->cal_info)->app_type;
|
cal_block->cal_info)->app_type;
|
||||||
|
|
||||||
if (app_type == 0)
|
cal_utils_mark_cal_used(cal_block);
|
||||||
app_type = DEFAULT_APP_TYPE;
|
|
||||||
unlock:
|
unlock:
|
||||||
mutex_unlock(&cal_data[ASM_TOPOLOGY_CAL]->lock);
|
mutex_unlock(&cal_data[ASM_TOPOLOGY_CAL]->lock);
|
||||||
done:
|
done:
|
||||||
pr_debug("%s: Using app_type %d\n", __func__, app_type);
|
pr_debug("%s: Using topology %d app_type %d\n", __func__,
|
||||||
return app_type;
|
cal_info->topology_id, cal_info->app_type);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -9849,8 +9853,9 @@ int q6asm_send_cal(struct audio_client *ac)
|
|||||||
memset(&mem_hdr, 0, sizeof(mem_hdr));
|
memset(&mem_hdr, 0, sizeof(mem_hdr));
|
||||||
mutex_lock(&cal_data[ASM_AUDSTRM_CAL]->lock);
|
mutex_lock(&cal_data[ASM_AUDSTRM_CAL]->lock);
|
||||||
cal_block = cal_utils_get_only_cal_block(cal_data[ASM_AUDSTRM_CAL]);
|
cal_block = cal_utils_get_only_cal_block(cal_data[ASM_AUDSTRM_CAL]);
|
||||||
if (cal_block == NULL) {
|
if (cal_block == NULL || cal_utils_is_cal_stale(cal_block)) {
|
||||||
pr_err("%s: cal_block is NULL\n",
|
rc = 0; /* not error case */
|
||||||
|
pr_err("%s: cal_block is NULL or stale\n",
|
||||||
__func__);
|
__func__);
|
||||||
goto unlock;
|
goto unlock;
|
||||||
}
|
}
|
||||||
@@ -9887,6 +9892,8 @@ int q6asm_send_cal(struct audio_client *ac)
|
|||||||
goto unlock;
|
goto unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cal_block)
|
||||||
|
cal_utils_mark_cal_used(cal_block);
|
||||||
rc = 0;
|
rc = 0;
|
||||||
|
|
||||||
unlock:
|
unlock:
|
||||||
|
@@ -37,6 +37,7 @@ struct cal_block_data {
|
|||||||
void *cal_info;
|
void *cal_info;
|
||||||
struct list_head list;
|
struct list_head list;
|
||||||
struct cal_data cal_data;
|
struct cal_data cal_data;
|
||||||
|
bool cal_stale;
|
||||||
struct mem_map_data map_data;
|
struct mem_map_data map_data;
|
||||||
int32_t buffer_number;
|
int32_t buffer_number;
|
||||||
};
|
};
|
||||||
@@ -98,4 +99,8 @@ size_t get_user_cal_type_size(int32_t cal_type);
|
|||||||
|
|
||||||
/* Version of the cal type*/
|
/* Version of the cal type*/
|
||||||
int32_t cal_utils_get_cal_type_version(void *cal_type_data);
|
int32_t cal_utils_get_cal_type_version(void *cal_type_data);
|
||||||
|
|
||||||
|
void cal_utils_mark_cal_used(struct cal_block_data *cal_block);
|
||||||
|
|
||||||
|
bool cal_utils_is_cal_stale(struct cal_block_data *cal_block);
|
||||||
#endif
|
#endif
|
||||||
|
@@ -245,6 +245,11 @@ struct audio_client {
|
|||||||
struct shared_io_config config;
|
struct shared_io_config config;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct q6asm_cal_info {
|
||||||
|
int topology_id;
|
||||||
|
int app_type;
|
||||||
|
};
|
||||||
|
|
||||||
void q6asm_audio_client_free(struct audio_client *ac);
|
void q6asm_audio_client_free(struct audio_client *ac);
|
||||||
|
|
||||||
struct audio_client *q6asm_audio_client_alloc(app_cb cb, void *priv);
|
struct audio_client *q6asm_audio_client_alloc(app_cb cb, void *priv);
|
||||||
|
Reference in New Issue
Block a user