Skip to content

Commit

Permalink
Merge tag 'LA.UM.9.3.r1-01600-sdm845.0' of https://source.codeaurora.…
Browse files Browse the repository at this point in the history
…org/quic/la/platform/vendor/opensource/audio-kernel into HEAD

"LA.UM.9.3.r1-01600-sdm845.0"

Change-Id: Iafcfc0112a955761a5ff6be375340a0f8b1873e5
  • Loading branch information
YumeMichi committed Apr 21, 2021
2 parents 0fe1999 + 91eacf3 commit ec81eaa
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 15 deletions.
28 changes: 24 additions & 4 deletions techpack/audio/dsp/audio_cal_utils.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2018, 2020, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
Expand All @@ -18,6 +18,8 @@
#include <linux/mutex.h>
#include <dsp/audio_cal_utils.h>

struct mutex cal_lock;

static int unmap_memory(struct cal_type_data *cal_type,
struct cal_block_data *cal_block);

Expand Down Expand Up @@ -63,6 +65,7 @@ size_t get_cal_info_size(int32_t cal_type)
break;
case ADM_AUDPROC_CAL_TYPE:
case ADM_LSM_AUDPROC_CAL_TYPE:
case ADM_LSM_AUDPROC_PERSISTENT_CAL_TYPE:
size = sizeof(struct audio_cal_info_audproc);
break;
case ADM_AUDVOL_CAL_TYPE:
Expand Down Expand Up @@ -213,6 +216,7 @@ size_t get_user_cal_type_size(int32_t cal_type)
break;
case ADM_AUDPROC_CAL_TYPE:
case ADM_LSM_AUDPROC_CAL_TYPE:
case ADM_LSM_AUDPROC_PERSISTENT_CAL_TYPE:
size = sizeof(struct audio_cal_type_audproc);
break;
case ADM_AUDVOL_CAL_TYPE:
Expand Down Expand Up @@ -937,7 +941,9 @@ int cal_utils_dealloc_cal(size_t data_size, void *data,
if (ret < 0)
goto err;

mutex_lock(&cal_lock);
delete_cal_block(cal_block);
mutex_unlock(&cal_lock);
err:
mutex_unlock(&cal_type->lock);
done:
Expand Down Expand Up @@ -1052,6 +1058,11 @@ void cal_utils_mark_cal_used(struct cal_block_data *cal_block)
}
EXPORT_SYMBOL(cal_utils_mark_cal_used);

int __init cal_utils_init(void)
{
mutex_init(&cal_lock);
return 0;
}
/**
* cal_utils_is_cal_stale
*
Expand All @@ -1061,9 +1072,18 @@ EXPORT_SYMBOL(cal_utils_mark_cal_used);
*/
bool cal_utils_is_cal_stale(struct cal_block_data *cal_block)
{
if ((cal_block) && (cal_block->cal_stale))
return true;
bool ret = false;

return false;
mutex_lock(&cal_lock);
if (!cal_block) {
pr_err("%s: cal_block is Null", __func__);
goto unlock;
}
if (cal_block->cal_stale)
ret = true;

unlock:
mutex_unlock(&cal_lock);
return ret;
}
EXPORT_SYMBOL(cal_utils_is_cal_stale);
3 changes: 2 additions & 1 deletion techpack/audio/dsp/audio_calibration.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2014, 2016-2017 The Linux Foundation. All rights reserved.
/* Copyright (c) 2014, 2016-2017, 2020, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
Expand Down Expand Up @@ -599,6 +599,7 @@ static int __init audio_cal_init(void)

pr_debug("%s\n", __func__);

cal_utils_init();
memset(&audio_cal, 0, sizeof(audio_cal));
mutex_init(&audio_cal.common_lock);
for (; i < MAX_CAL_TYPES; i++) {
Expand Down
37 changes: 31 additions & 6 deletions techpack/audio/dsp/q6adm.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2019, 2020, The Linux Foundation. All rights reserved.
* Copyright (C) 2019 XiaoMi, Inc.
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -2039,7 +2039,8 @@ static struct cal_block_data *adm_find_cal_by_path(int cal_index, int path)
continue;

if (cal_index == ADM_AUDPROC_CAL ||
cal_index == ADM_LSM_AUDPROC_CAL) {
cal_index == ADM_LSM_AUDPROC_CAL ||
cal_index == ADM_LSM_AUDPROC_PERSISTENT_CAL) {
audproc_cal_info = cal_block->cal_info;
if ((audproc_cal_info->path == path) &&
(cal_block->cal_data.size > 0))
Expand Down Expand Up @@ -2076,7 +2077,8 @@ static struct cal_block_data *adm_find_cal_by_app_type(int cal_index, int path,
continue;

if (cal_index == ADM_AUDPROC_CAL ||
cal_index == ADM_LSM_AUDPROC_CAL) {
cal_index == ADM_LSM_AUDPROC_CAL ||
cal_index == ADM_LSM_AUDPROC_PERSISTENT_CAL) {
audproc_cal_info = cal_block->cal_info;
if ((audproc_cal_info->path == path) &&
(audproc_cal_info->app_type == app_type) &&
Expand Down Expand Up @@ -2116,7 +2118,8 @@ static struct cal_block_data *adm_find_cal(int cal_index, int path,
continue;

if (cal_index == ADM_AUDPROC_CAL ||
cal_index == ADM_LSM_AUDPROC_CAL) {
cal_index == ADM_LSM_AUDPROC_CAL ||
cal_index == ADM_LSM_AUDPROC_PERSISTENT_CAL) {
audproc_cal_info = cal_block->cal_info;
if ((audproc_cal_info->path == path) &&
(audproc_cal_info->app_type == app_type) &&
Expand Down Expand Up @@ -2205,12 +2208,18 @@ static void send_adm_cal(int port_id, int copp_idx, int path, int perf_mode,
{
pr_debug("%s: port id 0x%x copp_idx %d\n", __func__, port_id, copp_idx);

if (passthr_mode != LISTEN)
if (passthr_mode != LISTEN) {
send_adm_cal_type(ADM_AUDPROC_CAL, path, port_id, copp_idx,
perf_mode, app_type, acdb_id, sample_rate);
else
} else {
send_adm_cal_type(ADM_LSM_AUDPROC_CAL, path, port_id, copp_idx,
perf_mode, app_type, acdb_id, sample_rate);

send_adm_cal_type(ADM_LSM_AUDPROC_PERSISTENT_CAL, path,
port_id, copp_idx, perf_mode, app_type,
acdb_id, sample_rate);
}

send_adm_cal_type(ADM_AUDVOL_CAL, path, port_id, copp_idx, perf_mode,
app_type, acdb_id, sample_rate);
}
Expand Down Expand Up @@ -3290,6 +3299,9 @@ static int get_cal_type_index(int32_t cal_type)
case ADM_RTAC_AUDVOL_CAL_TYPE:
ret = ADM_RTAC_AUDVOL_CAL;
break;
case ADM_LSM_AUDPROC_PERSISTENT_CAL_TYPE:
ret = ADM_LSM_AUDPROC_PERSISTENT_CAL;
break;
default:
pr_err("%s: invalid cal type %d!\n", __func__, cal_type);
}
Expand Down Expand Up @@ -3511,6 +3523,12 @@ static int adm_init_cal_data(void)
adm_set_cal, NULL, NULL} },
{adm_map_cal_data, adm_unmap_cal_data,
cal_utils_match_buf_num} },

{{ADM_LSM_AUDPROC_PERSISTENT_CAL_TYPE,
{adm_alloc_cal, adm_dealloc_cal, NULL,
adm_set_cal, NULL, NULL} },
{adm_map_cal_data, adm_unmap_cal_data,
cal_utils_match_buf_num} },
};
pr_debug("%s:\n", __func__);

Expand Down Expand Up @@ -4194,6 +4212,13 @@ int adm_store_cal_data(int port_id, int copp_idx, int path, int perf_mode,
rc = -ENOMEM;
goto unlock;
}
} else if (cal_index == ADM_LSM_AUDPROC_PERSISTENT_CAL) {
if (cal_block->cal_data.size > AUD_PROC_PERSIST_BLOCK_SIZE) {
pr_err("%s:persist invalid size exp/actual[%zd, %d]\n",
__func__, cal_block->cal_data.size, *size);
rc = -ENOMEM;
goto unlock;
}
} else if (cal_index == ADM_AUDVOL_CAL) {
if (cal_block->cal_data.size > AUD_VOL_BLOCK_SIZE) {
pr_err("%s:aud_vol:invalid size exp/actual[%zd, %d]\n",
Expand Down
10 changes: 8 additions & 2 deletions techpack/audio/dsp/q6asm.c
Original file line number Diff line number Diff line change
Expand Up @@ -9530,9 +9530,15 @@ int q6asm_send_cal(struct audio_client *ac)

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 || cal_utils_is_cal_stale(cal_block)) {
if (cal_block == NULL) {
pr_err("%s: cal_block is NULL\n",
__func__);
goto unlock;
}

if (cal_utils_is_cal_stale(cal_block)) {
rc = 0; /* not error case */
pr_err("%s: cal_block is NULL or stale\n",
pr_err("%s: cal_block is stale\n",
__func__);
goto unlock;
}
Expand Down
4 changes: 3 additions & 1 deletion techpack/audio/include/dsp/audio_cal_utils.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2014, 2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014, 2018, 2020, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
Expand Down Expand Up @@ -104,4 +104,6 @@ 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);

int cal_utils_init(void);
#endif
4 changes: 3 additions & 1 deletion techpack/audio/include/dsp/q6adm-v2.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2018, 2020, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
Expand Down Expand Up @@ -27,6 +27,7 @@
((MAX_MODULES_IN_TOPO + 1) * sizeof(uint32_t))
#define AUD_PROC_BLOCK_SIZE 4096
#define AUD_VOL_BLOCK_SIZE 4096
#define AUD_PROC_PERSIST_BLOCK_SIZE (2 * 1024 * 1020)
#define AUDIO_RX_CALIBRATION_SIZE (AUD_PROC_BLOCK_SIZE + \
AUD_VOL_BLOCK_SIZE)
enum {
Expand All @@ -38,6 +39,7 @@ enum {
ADM_RTAC_APR_CAL,
ADM_SRS_TRUMEDIA,
ADM_RTAC_AUDVOL_CAL,
ADM_LSM_AUDPROC_PERSISTENT_CAL,
ADM_MAX_CAL_TYPES
};

Expand Down
2 changes: 2 additions & 0 deletions techpack/audio/include/uapi/linux/msm_audio_calibration.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ enum {
AFE_LSM_TX_CAL_TYPE,
ADM_LSM_TOPOLOGY_CAL_TYPE,
ADM_LSM_AUDPROC_CAL_TYPE,
ADM_LSM_AUDPROC_PERSISTENT_CAL_TYPE,
MAX_CAL_TYPES,
};

Expand All @@ -115,6 +116,7 @@ enum {
#define AFE_LSM_TX_CAL_TYPE AFE_LSM_TX_CAL_TYPE
#define ADM_LSM_TOPOLOGY_CAL_TYPE ADM_LSM_TOPOLOGY_CAL_TYPE
#define ADM_LSM_AUDPROC_CAL_TYPE ADM_LSM_AUDPROC_CAL_TYPE
#define ADM_LSM_AUDPROC_PERSISTENT_CAL_TYPE ADM_LSM_AUDPROC_PERSISTENT_CAL_TYPE
#define LSM_CAL_TYPES

#define TOPOLOGY_SPECIFIC_CHANNEL_INFO
Expand Down

0 comments on commit ec81eaa

Please sign in to comment.