Loading asoc/msm-pcm-routing-v2.c +21 −6 Original line number Diff line number Diff line Loading @@ -903,6 +903,9 @@ static struct cal_block_data *msm_routing_find_topology_by_path(int path, cal_block = list_entry(ptr, struct cal_block_data, list); if (cal_utils_is_cal_stale(cal_block)) continue; if (((struct audio_cal_info_adm_top *)cal_block ->cal_info)->path == path) { return cal_block; Loading @@ -929,6 +932,9 @@ static struct cal_block_data *msm_routing_find_topology(int path, cal_block = list_entry(ptr, struct cal_block_data, list); if (cal_utils_is_cal_stale(cal_block)) continue; cal_info = (struct audio_cal_info_adm_top *) cal_block->cal_info; if ((cal_info->path == path) && Loading @@ -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", __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, int be_id) { Loading @@ -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, acdb_dev_id, ADM_TOPOLOGY_CAL_TYPE_IDX); if (cal_block != NULL) if (cal_block != NULL) { topology = ((struct audio_cal_info_adm_top *) cal_block->cal_info)->topology; 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__); mutex_lock(&cal_data[ADM_LSM_TOPOLOGY_CAL_TYPE_IDX]->lock); cal_block = msm_routing_find_topology(session_type, app_type, acdb_dev_id, ADM_LSM_TOPOLOGY_CAL_TYPE_IDX); if (cal_block != NULL) if (cal_block != NULL) { topology = ((struct audio_cal_info_adm_top *) cal_block->cal_info)->topology; cal_utils_mark_cal_used(cal_block); } mutex_unlock(&cal_data[ADM_LSM_TOPOLOGY_CAL_TYPE_IDX]->lock); } Loading dsp/audio_cal_utils.c +31 −0 Original line number Diff line number Diff line Loading @@ -1033,9 +1033,40 @@ int cal_utils_set_cal(size_t data_size, void *data, ((uint8_t *)data + sizeof(struct audio_cal_type_basic)), data_size - sizeof(struct audio_cal_type_basic)); /* reset buffer stale flag */ cal_block->cal_stale = false; err: mutex_unlock(&cal_type->lock); done: return ret; } 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); dsp/q6adm.c +14 −4 Original line number Diff line number Diff line Loading @@ -1856,7 +1856,7 @@ static void send_adm_custom_topology(void) this_adm.set_custom_topology = 0; 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; pr_debug("%s: Sending cal_index %d\n", __func__, cal_index); Loading Loading @@ -1996,6 +1996,9 @@ static struct cal_block_data *adm_find_cal_by_path(int cal_index, int path) cal_block = list_entry(ptr, struct cal_block_data, list); if (cal_utils_is_cal_stale(cal_block)) continue; if (cal_index == ADM_AUDPROC_CAL || cal_index == ADM_LSM_AUDPROC_CAL) { audproc_cal_info = cal_block->cal_info; Loading Loading @@ -2030,6 +2033,9 @@ static struct cal_block_data *adm_find_cal_by_app_type(int cal_index, int path, cal_block = list_entry(ptr, struct cal_block_data, list); if (cal_utils_is_cal_stale(cal_block)) continue; if (cal_index == ADM_AUDPROC_CAL || cal_index == ADM_LSM_AUDPROC_CAL) { audproc_cal_info = cal_block->cal_info; Loading Loading @@ -2067,6 +2073,8 @@ static struct cal_block_data *adm_find_cal(int cal_index, int path, cal_block = list_entry(ptr, struct cal_block_data, list); if (cal_utils_is_cal_stale(cal_block)) continue; if (cal_index == ADM_AUDPROC_CAL || cal_index == ADM_LSM_AUDPROC_CAL) { Loading Loading @@ -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, cal_block, perf_mode, app_type, acdb_id, sample_rate); cal_utils_mark_cal_used(cal_block); unlock: mutex_unlock(&this_adm.cal_data[cal_index]->lock); done: Loading Loading @@ -3111,7 +3121,7 @@ int send_rtac_audvol_cal(void) cal_block = cal_utils_get_only_cal_block( 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__); goto unlock; } Loading dsp/q6afe.c +25 −8 Original line number Diff line number Diff line Loading @@ -1344,7 +1344,7 @@ static void afe_send_custom_topology(void) goto unlock; this_afe.set_custom_topology = 0; 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__); goto unlock; } Loading Loading @@ -1709,7 +1709,9 @@ static struct cal_block_data *afe_find_cal_topo_id_by_port( &cal_type->cal_blocks) { cal_block = list_entry(ptr, 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) == MSM_AFE_PORT_TYPE_TX)?(TX_DEVICE):(RX_DEVICE)); afe_top = Loading Loading @@ -1737,6 +1739,11 @@ static struct cal_block_data *afe_find_cal_topo_id_by_port( 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, int cal_type_index) { Loading @@ -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; 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; } if (topology_id == NULL) { Loading @@ -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( this_afe.cal_data[cal_type_index], port_id); if (cal_block == NULL) { pr_err("%s: [AFE_TOPOLOGY_CAL] not initialized for this port %d\n", __func__, port_id); pr_err("%s: cal_type %d not initialized for this port %d\n", __func__, cal_type_index, port_id); ret = -EINVAL; goto unlock; } Loading @@ -1774,6 +1782,7 @@ static int afe_get_cal_topology_id(u16 port_id, u32 *topology_id, goto unlock; } *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", __func__, port_id, afe_top_info->acdb_id, Loading Loading @@ -1940,7 +1949,7 @@ static int send_afe_cal_type(int cal_index, int port_id) 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__); ret = -EINVAL; goto unlock; Loading @@ -1959,6 +1968,9 @@ static int send_afe_cal_type(int cal_index, int port_id) if (ret < 0) pr_debug("%s: No cal sent for cal_index %d, port_id = 0x%x! ret %d\n", __func__, cal_index, port_id, ret); cal_utils_mark_cal_used(cal_block); unlock: mutex_unlock(&this_afe.cal_data[cal_index]->lock); done: Loading Loading @@ -5272,7 +5284,7 @@ static int afe_sidetone_iir(u16 tx_port_id) } mutex_lock(&this_afe.cal_data[cal_index]->lock); 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__); mutex_unlock(&this_afe.cal_data[cal_index]->lock); ret = -EINVAL; Loading Loading @@ -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); 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__); mutex_unlock(&this_afe.cal_data[cal_index]->lock); ret = -EINVAL; Loading Loading @@ -6533,6 +6545,9 @@ static struct cal_block_data *afe_find_hw_delay_by_path( cal_block = list_entry(ptr, 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) ->path == path) { return cal_block; Loading Loading @@ -6596,6 +6611,8 @@ static int afe_get_cal_hw_delay(int32_t path, ret = -EFAULT; goto unlock; } cal_utils_mark_cal_used(cal_block); pr_debug("%s: Path = %d samplerate = %u usec = %u status %d\n", __func__, path, entry->sample_rate, entry->delay_usec, ret); unlock: Loading dsp/q6asm.c +55 −48 Original line number Diff line number Diff line Loading @@ -125,8 +125,7 @@ static int q6asm_map_channels(u8 *channel_mapping, uint32_t channels, void *q6asm_mmap_apr_reg(void); 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_app_type_cal(void); static int q6asm_get_asm_topology_apptype(struct q6asm_cal_info *cal_info); /* for ASM custom topology */ static struct cal_type_data *cal_data[ASM_MAX_CAL_TYPES]; Loading Loading @@ -759,7 +758,7 @@ int send_asm_custom_topology(struct audio_client *ac) set_custom_topology = 0; 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; if (cal_block->cal_data.size == 0) { Loading Loading @@ -2800,6 +2799,7 @@ static int __q6asm_open_read(struct audio_client *ac, { int rc = 0x00; struct asm_stream_cmd_open_read_v3 open; struct q6asm_cal_info cal_info; config_debug_fs_reset_index(); Loading @@ -2819,12 +2819,15 @@ static int __q6asm_open_read(struct audio_client *ac, /* Stream prio : High, provide meta info with encoded frames */ 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.mode_flags = 0x0; 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) { open.mode_flags |= ASM_LOW_LATENCY_TX_STREAM_SESSION << ASM_SHIFT_STREAM_PERF_MODE_FLAG_IN_OPEN_READ; Loading Loading @@ -3086,6 +3089,7 @@ static int __q6asm_open_write(struct audio_client *ac, uint32_t format, { int rc = 0x00; struct asm_stream_cmd_open_write_v3 open; struct q6asm_cal_info cal_info; if (ac == NULL) { pr_err("%s: APR handle NULL\n", __func__); Loading Loading @@ -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.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) open.postprocopo_id = ASM_STREAM_POSTPROCOPO_ID_NONE; Loading @@ -3147,7 +3153,7 @@ static int __q6asm_open_write(struct audio_client *ac, uint32_t format, */ if (!ac->topology) { ac->topology = open.postprocopo_id; ac->app_type = q6asm_get_asm_app_type_cal(); ac->app_type = cal_info.app_type; } switch (format) { case FORMAT_LINEAR_PCM: Loading Loading @@ -3334,6 +3340,7 @@ static int __q6asm_open_read_write(struct audio_client *ac, uint32_t rd_format, { int rc = 0x00; struct asm_stream_cmd_open_readwrite_v2 open; struct q6asm_cal_info cal_info; if (ac == NULL) { pr_err("%s: APR handle NULL\n", __func__); Loading @@ -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.bits_per_sample = bits_per_sample; /* 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 ? 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) { Loading Loading @@ -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 rc = 0x00; struct q6asm_cal_info cal_info; if (ac == NULL) { pr_err("%s: APR handle NULL\n", __func__); Loading @@ -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.sink_format_id = ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V2; /* 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) open.mode_flags |= ASM_LOW_LATENCY_STREAM_SESSION; else Loading Loading @@ -3608,9 +3618,10 @@ int q6asm_open_loopback_v2(struct audio_client *ac, uint16_t bits_per_sample) open.src_endpointype = 0; open.sink_endpointype = 0; /* 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; open.bits_per_sample = bits_per_sample; open.reserved = 0; Loading Loading @@ -3665,6 +3676,7 @@ int q6asm_open_transcode_loopback(struct audio_client *ac, { int rc = 0x00; struct asm_stream_cmd_open_transcode_loopback_t open; struct q6asm_cal_info cal_info; if (ac == NULL) { pr_err("%s: APR handle NULL\n", __func__); Loading Loading @@ -3712,9 +3724,11 @@ int q6asm_open_transcode_loopback(struct audio_client *ac, } /* 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) open.mode_flags |= ASM_LOW_LATENCY_STREAM_SESSION; else Loading Loading @@ -3884,6 +3898,7 @@ int q6asm_open_shared_io(struct audio_client *ac, struct asm_stream_cmd_open_shared_io *open; u8 *channel_mapping; int i, size_of_open, num_watermarks, bufsz, bufcnt, rc, flags = 0; struct q6asm_cal_info cal_info; if (!ac || !config) return -EINVAL; Loading Loading @@ -3950,7 +3965,8 @@ int q6asm_open_shared_io(struct audio_client *ac, open->endpoint_type = ASM_END_POINT_DEVICE_MATRIX; 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) open->fmt_id = ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V3; Loading Loading @@ -9766,51 +9782,39 @@ int q6asm_get_asm_app_type(int session_id) 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; 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; topology = ((struct audio_cal_info_asm_top *) cal_block->cal_info)->topology; unlock: 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; cal_info->topology_id = DEFAULT_POPP_TOPOLOGY; cal_info->app_type = DEFAULT_APP_TYPE; 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) if (cal_block == NULL || cal_utils_is_cal_stale(cal_block)) goto unlock; app_type = ((struct audio_cal_info_asm_top *) cal_info->topology_id = ((struct audio_cal_info_asm_top *) cal_block->cal_info)->topology; cal_info->app_type = ((struct audio_cal_info_asm_top *) cal_block->cal_info)->app_type; if (app_type == 0) app_type = DEFAULT_APP_TYPE; cal_utils_mark_cal_used(cal_block); unlock: mutex_unlock(&cal_data[ASM_TOPOLOGY_CAL]->lock); done: pr_debug("%s: Using app_type %d\n", __func__, app_type); return app_type; pr_debug("%s: Using topology %d app_type %d\n", __func__, cal_info->topology_id, cal_info->app_type); return 0; } /** Loading Loading @@ -9849,8 +9853,9 @@ int q6asm_send_cal(struct audio_client *ac) memset(&mem_hdr, 0, sizeof(mem_hdr)); mutex_lock(&cal_data[ASM_AUDSTRM_CAL]->lock); cal_block = cal_utils_get_only_cal_block(cal_data[ASM_AUDSTRM_CAL]); if (cal_block == NULL) { pr_err("%s: cal_block is NULL\n", if (cal_block == NULL || cal_utils_is_cal_stale(cal_block)) { rc = 0; /* not error case */ pr_err("%s: cal_block is NULL or stale\n", __func__); goto unlock; } Loading Loading @@ -9887,6 +9892,8 @@ int q6asm_send_cal(struct audio_client *ac) goto unlock; } if (cal_block) cal_utils_mark_cal_used(cal_block); rc = 0; unlock: Loading Loading
asoc/msm-pcm-routing-v2.c +21 −6 Original line number Diff line number Diff line Loading @@ -903,6 +903,9 @@ static struct cal_block_data *msm_routing_find_topology_by_path(int path, cal_block = list_entry(ptr, struct cal_block_data, list); if (cal_utils_is_cal_stale(cal_block)) continue; if (((struct audio_cal_info_adm_top *)cal_block ->cal_info)->path == path) { return cal_block; Loading @@ -929,6 +932,9 @@ static struct cal_block_data *msm_routing_find_topology(int path, cal_block = list_entry(ptr, struct cal_block_data, list); if (cal_utils_is_cal_stale(cal_block)) continue; cal_info = (struct audio_cal_info_adm_top *) cal_block->cal_info; if ((cal_info->path == path) && Loading @@ -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", __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, int be_id) { Loading @@ -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, acdb_dev_id, ADM_TOPOLOGY_CAL_TYPE_IDX); if (cal_block != NULL) if (cal_block != NULL) { topology = ((struct audio_cal_info_adm_top *) cal_block->cal_info)->topology; 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__); mutex_lock(&cal_data[ADM_LSM_TOPOLOGY_CAL_TYPE_IDX]->lock); cal_block = msm_routing_find_topology(session_type, app_type, acdb_dev_id, ADM_LSM_TOPOLOGY_CAL_TYPE_IDX); if (cal_block != NULL) if (cal_block != NULL) { topology = ((struct audio_cal_info_adm_top *) cal_block->cal_info)->topology; cal_utils_mark_cal_used(cal_block); } mutex_unlock(&cal_data[ADM_LSM_TOPOLOGY_CAL_TYPE_IDX]->lock); } Loading
dsp/audio_cal_utils.c +31 −0 Original line number Diff line number Diff line Loading @@ -1033,9 +1033,40 @@ int cal_utils_set_cal(size_t data_size, void *data, ((uint8_t *)data + sizeof(struct audio_cal_type_basic)), data_size - sizeof(struct audio_cal_type_basic)); /* reset buffer stale flag */ cal_block->cal_stale = false; err: mutex_unlock(&cal_type->lock); done: return ret; } 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);
dsp/q6adm.c +14 −4 Original line number Diff line number Diff line Loading @@ -1856,7 +1856,7 @@ static void send_adm_custom_topology(void) this_adm.set_custom_topology = 0; 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; pr_debug("%s: Sending cal_index %d\n", __func__, cal_index); Loading Loading @@ -1996,6 +1996,9 @@ static struct cal_block_data *adm_find_cal_by_path(int cal_index, int path) cal_block = list_entry(ptr, struct cal_block_data, list); if (cal_utils_is_cal_stale(cal_block)) continue; if (cal_index == ADM_AUDPROC_CAL || cal_index == ADM_LSM_AUDPROC_CAL) { audproc_cal_info = cal_block->cal_info; Loading Loading @@ -2030,6 +2033,9 @@ static struct cal_block_data *adm_find_cal_by_app_type(int cal_index, int path, cal_block = list_entry(ptr, struct cal_block_data, list); if (cal_utils_is_cal_stale(cal_block)) continue; if (cal_index == ADM_AUDPROC_CAL || cal_index == ADM_LSM_AUDPROC_CAL) { audproc_cal_info = cal_block->cal_info; Loading Loading @@ -2067,6 +2073,8 @@ static struct cal_block_data *adm_find_cal(int cal_index, int path, cal_block = list_entry(ptr, struct cal_block_data, list); if (cal_utils_is_cal_stale(cal_block)) continue; if (cal_index == ADM_AUDPROC_CAL || cal_index == ADM_LSM_AUDPROC_CAL) { Loading Loading @@ -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, cal_block, perf_mode, app_type, acdb_id, sample_rate); cal_utils_mark_cal_used(cal_block); unlock: mutex_unlock(&this_adm.cal_data[cal_index]->lock); done: Loading Loading @@ -3111,7 +3121,7 @@ int send_rtac_audvol_cal(void) cal_block = cal_utils_get_only_cal_block( 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__); goto unlock; } Loading
dsp/q6afe.c +25 −8 Original line number Diff line number Diff line Loading @@ -1344,7 +1344,7 @@ static void afe_send_custom_topology(void) goto unlock; this_afe.set_custom_topology = 0; 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__); goto unlock; } Loading Loading @@ -1709,7 +1709,9 @@ static struct cal_block_data *afe_find_cal_topo_id_by_port( &cal_type->cal_blocks) { cal_block = list_entry(ptr, 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) == MSM_AFE_PORT_TYPE_TX)?(TX_DEVICE):(RX_DEVICE)); afe_top = Loading Loading @@ -1737,6 +1739,11 @@ static struct cal_block_data *afe_find_cal_topo_id_by_port( 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, int cal_type_index) { Loading @@ -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; 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; } if (topology_id == NULL) { Loading @@ -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( this_afe.cal_data[cal_type_index], port_id); if (cal_block == NULL) { pr_err("%s: [AFE_TOPOLOGY_CAL] not initialized for this port %d\n", __func__, port_id); pr_err("%s: cal_type %d not initialized for this port %d\n", __func__, cal_type_index, port_id); ret = -EINVAL; goto unlock; } Loading @@ -1774,6 +1782,7 @@ static int afe_get_cal_topology_id(u16 port_id, u32 *topology_id, goto unlock; } *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", __func__, port_id, afe_top_info->acdb_id, Loading Loading @@ -1940,7 +1949,7 @@ static int send_afe_cal_type(int cal_index, int port_id) 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__); ret = -EINVAL; goto unlock; Loading @@ -1959,6 +1968,9 @@ static int send_afe_cal_type(int cal_index, int port_id) if (ret < 0) pr_debug("%s: No cal sent for cal_index %d, port_id = 0x%x! ret %d\n", __func__, cal_index, port_id, ret); cal_utils_mark_cal_used(cal_block); unlock: mutex_unlock(&this_afe.cal_data[cal_index]->lock); done: Loading Loading @@ -5272,7 +5284,7 @@ static int afe_sidetone_iir(u16 tx_port_id) } mutex_lock(&this_afe.cal_data[cal_index]->lock); 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__); mutex_unlock(&this_afe.cal_data[cal_index]->lock); ret = -EINVAL; Loading Loading @@ -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); 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__); mutex_unlock(&this_afe.cal_data[cal_index]->lock); ret = -EINVAL; Loading Loading @@ -6533,6 +6545,9 @@ static struct cal_block_data *afe_find_hw_delay_by_path( cal_block = list_entry(ptr, 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) ->path == path) { return cal_block; Loading Loading @@ -6596,6 +6611,8 @@ static int afe_get_cal_hw_delay(int32_t path, ret = -EFAULT; goto unlock; } cal_utils_mark_cal_used(cal_block); pr_debug("%s: Path = %d samplerate = %u usec = %u status %d\n", __func__, path, entry->sample_rate, entry->delay_usec, ret); unlock: Loading
dsp/q6asm.c +55 −48 Original line number Diff line number Diff line Loading @@ -125,8 +125,7 @@ static int q6asm_map_channels(u8 *channel_mapping, uint32_t channels, void *q6asm_mmap_apr_reg(void); 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_app_type_cal(void); static int q6asm_get_asm_topology_apptype(struct q6asm_cal_info *cal_info); /* for ASM custom topology */ static struct cal_type_data *cal_data[ASM_MAX_CAL_TYPES]; Loading Loading @@ -759,7 +758,7 @@ int send_asm_custom_topology(struct audio_client *ac) set_custom_topology = 0; 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; if (cal_block->cal_data.size == 0) { Loading Loading @@ -2800,6 +2799,7 @@ static int __q6asm_open_read(struct audio_client *ac, { int rc = 0x00; struct asm_stream_cmd_open_read_v3 open; struct q6asm_cal_info cal_info; config_debug_fs_reset_index(); Loading @@ -2819,12 +2819,15 @@ static int __q6asm_open_read(struct audio_client *ac, /* Stream prio : High, provide meta info with encoded frames */ 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.mode_flags = 0x0; 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) { open.mode_flags |= ASM_LOW_LATENCY_TX_STREAM_SESSION << ASM_SHIFT_STREAM_PERF_MODE_FLAG_IN_OPEN_READ; Loading Loading @@ -3086,6 +3089,7 @@ static int __q6asm_open_write(struct audio_client *ac, uint32_t format, { int rc = 0x00; struct asm_stream_cmd_open_write_v3 open; struct q6asm_cal_info cal_info; if (ac == NULL) { pr_err("%s: APR handle NULL\n", __func__); Loading Loading @@ -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.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) open.postprocopo_id = ASM_STREAM_POSTPROCOPO_ID_NONE; Loading @@ -3147,7 +3153,7 @@ static int __q6asm_open_write(struct audio_client *ac, uint32_t format, */ if (!ac->topology) { ac->topology = open.postprocopo_id; ac->app_type = q6asm_get_asm_app_type_cal(); ac->app_type = cal_info.app_type; } switch (format) { case FORMAT_LINEAR_PCM: Loading Loading @@ -3334,6 +3340,7 @@ static int __q6asm_open_read_write(struct audio_client *ac, uint32_t rd_format, { int rc = 0x00; struct asm_stream_cmd_open_readwrite_v2 open; struct q6asm_cal_info cal_info; if (ac == NULL) { pr_err("%s: APR handle NULL\n", __func__); Loading @@ -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.bits_per_sample = bits_per_sample; /* 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 ? 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) { Loading Loading @@ -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 rc = 0x00; struct q6asm_cal_info cal_info; if (ac == NULL) { pr_err("%s: APR handle NULL\n", __func__); Loading @@ -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.sink_format_id = ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V2; /* 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) open.mode_flags |= ASM_LOW_LATENCY_STREAM_SESSION; else Loading Loading @@ -3608,9 +3618,10 @@ int q6asm_open_loopback_v2(struct audio_client *ac, uint16_t bits_per_sample) open.src_endpointype = 0; open.sink_endpointype = 0; /* 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; open.bits_per_sample = bits_per_sample; open.reserved = 0; Loading Loading @@ -3665,6 +3676,7 @@ int q6asm_open_transcode_loopback(struct audio_client *ac, { int rc = 0x00; struct asm_stream_cmd_open_transcode_loopback_t open; struct q6asm_cal_info cal_info; if (ac == NULL) { pr_err("%s: APR handle NULL\n", __func__); Loading Loading @@ -3712,9 +3724,11 @@ int q6asm_open_transcode_loopback(struct audio_client *ac, } /* 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) open.mode_flags |= ASM_LOW_LATENCY_STREAM_SESSION; else Loading Loading @@ -3884,6 +3898,7 @@ int q6asm_open_shared_io(struct audio_client *ac, struct asm_stream_cmd_open_shared_io *open; u8 *channel_mapping; int i, size_of_open, num_watermarks, bufsz, bufcnt, rc, flags = 0; struct q6asm_cal_info cal_info; if (!ac || !config) return -EINVAL; Loading Loading @@ -3950,7 +3965,8 @@ int q6asm_open_shared_io(struct audio_client *ac, open->endpoint_type = ASM_END_POINT_DEVICE_MATRIX; 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) open->fmt_id = ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V3; Loading Loading @@ -9766,51 +9782,39 @@ int q6asm_get_asm_app_type(int session_id) 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; 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; topology = ((struct audio_cal_info_asm_top *) cal_block->cal_info)->topology; unlock: 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; cal_info->topology_id = DEFAULT_POPP_TOPOLOGY; cal_info->app_type = DEFAULT_APP_TYPE; 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) if (cal_block == NULL || cal_utils_is_cal_stale(cal_block)) goto unlock; app_type = ((struct audio_cal_info_asm_top *) cal_info->topology_id = ((struct audio_cal_info_asm_top *) cal_block->cal_info)->topology; cal_info->app_type = ((struct audio_cal_info_asm_top *) cal_block->cal_info)->app_type; if (app_type == 0) app_type = DEFAULT_APP_TYPE; cal_utils_mark_cal_used(cal_block); unlock: mutex_unlock(&cal_data[ASM_TOPOLOGY_CAL]->lock); done: pr_debug("%s: Using app_type %d\n", __func__, app_type); return app_type; pr_debug("%s: Using topology %d app_type %d\n", __func__, cal_info->topology_id, cal_info->app_type); return 0; } /** Loading Loading @@ -9849,8 +9853,9 @@ int q6asm_send_cal(struct audio_client *ac) memset(&mem_hdr, 0, sizeof(mem_hdr)); mutex_lock(&cal_data[ASM_AUDSTRM_CAL]->lock); cal_block = cal_utils_get_only_cal_block(cal_data[ASM_AUDSTRM_CAL]); if (cal_block == NULL) { pr_err("%s: cal_block is NULL\n", if (cal_block == NULL || cal_utils_is_cal_stale(cal_block)) { rc = 0; /* not error case */ pr_err("%s: cal_block is NULL or stale\n", __func__); goto unlock; } Loading Loading @@ -9887,6 +9892,8 @@ int q6asm_send_cal(struct audio_client *ac) goto unlock; } if (cal_block) cal_utils_mark_cal_used(cal_block); rc = 0; unlock: Loading