Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audio: Aria: Fix handling of S24_LE format, update blob ABI headers in topologies #9614

Merged
merged 6 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/audio/aria/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ config COMP_ARIA
depends on IPC_MAJOR_4
help
Select for Automatic Regressive Input Amplifier Module component
ARIA applies variable gain into incoming signal.
Applied gain is in range <1, 2 power attenuation>
Currently ARIA introduces gain transition and algorithmic
latency equal to 1 ms.
ARIA applies variable gain into incoming signal. Target gain is
0, 6, 12, 18 dB with allowed configuration parameter values
0, 1, 2, 3. Gain is reduced from target with high level signals
to avoid clipping. Currently ARIA introduces gain transition and
algorithmic latency equal to 1 ms.

choice
prompt "ARIA HIFI level"
Expand Down
12 changes: 10 additions & 2 deletions src/audio/aria/aria.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,16 +276,24 @@ static int aria_set_config(struct processing_module *mod, uint32_t param_id,
size_t response_size)
{
struct aria_data *cd = module_get_private_data(mod);
struct comp_dev *dev = mod->dev;

comp_info(dev, "aria_set_config()");
if (param_id == ARIA_SET_ATTENUATION) {
if (fragment_size != sizeof(uint32_t)) {
comp_err(mod->dev, "Illegal fragment_size = %d", fragment_size);
comp_err(dev, "Illegal fragment_size = %d", fragment_size);
return -EINVAL;
}
memcpy_s(&cd->att, sizeof(uint32_t), fragment, sizeof(uint32_t));
if (cd->att > ARIA_MAX_ATT) {
comp_warn(dev,
"aria_set_config(): Attenuation parameter %d is limited to %d",
cd->att, ARIA_MAX_ATT);
cd->att = ARIA_MAX_ATT;
}
aria_set_gains(cd);
} else {
comp_err(mod->dev, "Illegal param_id = %d", param_id);
comp_err(dev, "Illegal param_id = %d", param_id);
return -EINVAL;
}

Expand Down
2 changes: 1 addition & 1 deletion src/audio/aria/aria.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ struct aria_data {
/* current data position in circular buffer */
size_t buff_pos;
/* Attenuation parameter */
size_t att;
uint32_t att;
/* Gain states */
int32_t gains[ARIA_MAX_GAIN_STATES];
/* cyclic buffer pointer data */
Expand Down
4 changes: 2 additions & 2 deletions src/audio/aria/aria_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ inline void aria_algo_calc_gain(struct aria_data *cd, size_t gain_idx,
n = audio_stream_samples_without_wrap_s32(source, src);
n = MIN(samples, n);
for (i = 0; i < n; i++) {
sample_abs = ABS(src[i]);
sample_abs = ABS(sign_extend_s24(src[i]));
max_data = MAX(max_data, sample_abs);
}

Expand Down Expand Up @@ -71,7 +71,7 @@ static void aria_algo_get_data(struct processing_module *mod,
n = MIN(m, n);
for (i = 0; i < n; i += ch_n) {
for (ch = 0; ch < ch_n; ch++) {
in_sample = *in++;
in_sample = sign_extend_s24(*in++);
out[ch] = q_multsr_sat_32x32_24(in_sample, gain, shift);
}
gain += step;
Expand Down
10 changes: 7 additions & 3 deletions src/audio/aria/aria_hifi3.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,18 @@ inline void aria_algo_calc_gain(struct aria_data *cd, size_t gain_idx,
inu = AE_LA64_PP(in);
for (i = 0; i < m; i++) {
AE_LA32X2_IP(in_sample, inu, in);
max_data = AE_MAXABS32S(max_data, in_sample);
max_data = AE_MAXABS32S(max_data, AE_SLAI32(in_sample, 8));
}
if (n & 1) {
AE_L32_IP(in_sample, (ae_int32 *)in, sizeof(ae_int32));
max_data = AE_MAXABS32S(max_data, in_sample);
max_data = AE_MAXABS32S(max_data, AE_SLAI32(in_sample, 8));
}
max = MAX(max_ptr[0], max_ptr[1]);
in = audio_stream_wrap(source, in);
samples -= n;
}

max = MAX(max_ptr[0], max_ptr[1]) >> 8;

/*zero check for maxis not needed since att is in range <0;3>*/
if (max > (0x007fffff >> att))
gain = (0x007fffffULL << 32) / max;
Expand Down Expand Up @@ -93,6 +95,7 @@ static void aria_algo_get_data_odd_channel(struct processing_module *mod,
/*process data one by one if ch_n is odd*/
for (ch = 0; ch < ch_n; ch++) {
AE_L32_XP(in_sample, (ae_int32 *)in, inc);
in_sample = AE_SRAI32(AE_SLAI32(in_sample, 8), 8);
out1 = AE_MUL32_HH(in_sample, gain);
out1 = AE_SRAA64(out1, shift_bits);
out_sample = AE_ROUND24X2F48SSYM(out1, out1);
Expand Down Expand Up @@ -150,6 +153,7 @@ static void aria_algo_get_data_even_channel(struct processing_module *mod,
/*process 2 samples per time if ch_n is even*/
for (ch = 0; ch < ch_n; ch += 2) {
AE_LA32X2_IP(in_sample, inu, in);
in_sample = AE_SRAI32(AE_SLAI32(in_sample, 8), 8);
out1 = AE_MUL32_HH(in_sample, gain);
out1 = AE_SRAA64(out1, shift_bits);
out2 = AE_MUL32_LL(in_sample, gain);
Expand Down
12 changes: 8 additions & 4 deletions src/audio/aria/aria_hifi5.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,19 @@ inline void aria_algo_calc_gain(struct aria_data *cd, size_t gain_idx,
inu = AE_LA128_PP(in);
for (i = 0; i < n; i += 4) {
AE_LA32X2X2_IP(in_sample, in_sample1, inu, in);
in_sample = AE_MAXABS32S(in_sample, in_sample1);
max_data = AE_MAXABS32S(max_data, in_sample);
max_data = AE_MAXABS32S(max_data, AE_SLAI32(in_sample1, 8));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this intentional? So in_sample below is used as set in line 59 above?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's intentional. I think this is more clear, and no need to have left shift for both first AE_MAXABS32S input arguments.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, now all (generic, hifi3/4, hifi5) versions of Aria are bit exact with the input that I use.

max_data = AE_MAXABS32S(max_data, AE_SLAI32(in_sample, 8));
}
for (i = 0; i < left; i++) {
AE_L32_IP(in_sample, (ae_int32 *)in, sizeof(ae_int32));
max_data = AE_MAXABS32S(max_data, in_sample);
max_data = AE_MAXABS32S(max_data, AE_SLAI32(in_sample, 8));
}
max = MAX(max_ptr[0], max_ptr[1]);
in = audio_stream_wrap(source, in);
samples -= n;
}

max = MAX(max_ptr[0], max_ptr[1]) >> 8;

/*zero check for maxis not needed since att is in range <0;3>*/
if (max > (0x007fffff >> att))
gain = (0x007fffffULL << 32) / max;
Expand Down Expand Up @@ -104,6 +106,7 @@ static void aria_algo_get_data_odd_channel(struct processing_module *mod,
/*process data one by one if ch_n is odd*/
for (ch = 0; ch < ch_n; ch++) {
AE_L32_XC(in_sample, in, inc);
in_sample = AE_SRAI32(AE_SLAI32(in_sample, 8), 8);
out1 = AE_MUL32_HH(in_sample, gain);
out1 = AE_SRAA64(out1, shift_bits);
out_sample = AE_ROUND24X2F48SSYM(out1, out1);
Expand Down Expand Up @@ -153,6 +156,7 @@ static void aria_algo_get_data_even_channel(struct processing_module *mod,
/*process 2 samples per time if ch_n is even*/
for (ch = 0; ch < ch_n; ch += 2) {
AE_L32X2_XC(in_sample, in, inc);
in_sample = AE_SRAI32(AE_SLAI32(in_sample, 8), 8);
out1 = AE_MUL32_HH(in_sample, gain);
out1 = AE_SRAA64(out1, shift_bits);
out2 = AE_MUL32_LL(in_sample, gain);
Expand Down
6 changes: 6 additions & 0 deletions tools/topology/topology2/cavs-benchmark-hda.conf
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ IncludeByKey.BENCH_CONFIG {
]
Object.Control.bytes."1" {
name '$ANALOG_PLAYBACK_PCM ARIA bytes'
IncludeByKey.BENCH_ARIA_PARAMS {
"passthrough" "include/components/aria/passthrough.conf"
"param_1" "include/components/aria/param_1.conf"
"param_2" "include/components/aria/param_2.conf"
"param_3" "include/components/aria/param_3.conf"
}
}
}
Object.Widget.mixout.1 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ set(components_s24
)

set(component_parameters_s24
"BENCH_ARIA_PARAMS=default"
"BENCH_ARIA_PARAMS=param_2"
)

# Add components with all sample formats
Expand Down
2 changes: 1 addition & 1 deletion tools/topology/topology2/development/tplg-targets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ PREPROCESS_PLUGINS=nhlt,NHLT_BIN=nhlt-sof-nocodec-bt-mtl-lbm.bin"

# CAVS HDA topology for benchmarking performance
# Copier - peak volume - mixin - mixout - aria - peak volume - mixin - mixout - copier
"sof-hda-generic\;sof-hda-benchmark-generic\;HDA_CONFIG=benchmark,BENCH_CONFIG=benchmark"
"sof-hda-generic\;sof-hda-benchmark-generic\;HDA_CONFIG=benchmark,BENCH_CONFIG=benchmark,BENCH_ARIA_PARAMS=param_1"

# Topology to test IPC4 Crossover
"development/cavs-nocodec-crossover\;sof-tgl-nocodec-crossover-2way\;PLATFORM=tgl,\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
Object.Control {
bytes."1" {
name '$ANALOG_CAPTURE_PCM ARIA bytes'
IncludeByKey.BENCH_ARIA_PARAMS {
"passthrough" "include/components/aria/passthrough.conf"
"param_1" "include/components/aria/param_1.conf"
"param_2" "include/components/aria/param_2.conf"
"param_3" "include/components/aria/param_3.conf"
}
}
#mixer."1" {
# name '$ANALOG_CAPTURE_PCM ARIA switch or volume'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
Object.Control {
bytes."1" {
name '$ANALOG_PLAYBACK_PCM ARIA bytes'
IncludeByKey.BENCH_ARIA_PARAMS {
"passthrough" "include/components/aria/passthrough.conf"
"param_1" "include/components/aria/param_1.conf"
"param_2" "include/components/aria/param_2.conf"
"param_3" "include/components/aria/param_3.conf"
}
}
#mixer."1" {
# name '$ANALOG_PLAYBACK_PCM ARIA switch or volume'
Expand Down
8 changes: 0 additions & 8 deletions tools/topology/topology2/include/components/aria.conf
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@ Class.Widget."aria" {
put 0
}
max 4096
Object.Base.data. 1 {
# attenuation for the aria module
bytes "0x53, 0x4f, 0x46, 0x34, 0x01, 0x00, 0x00, 0x00,
0x4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00"
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When looking at the quite similar hex values of the blob it might be that this would have worked if I had first done the size_t vs. uint32_t fix to code that failed on 64 bit build. I think I should rewrite the commit message to say it's a blob ABI update and blobs added for all allowed configurations of Aria.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

# Attribute categories
Expand Down
10 changes: 10 additions & 0 deletions tools/topology/topology2/include/components/aria/param_1.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Exported with script sof_aria_blobs.m 24-Oct-2024
# cd tools/tune/aria; octave sof_aria_blobs.m
Object.Base.data."aria_config" {
bytes "
0x53,0x4f,0x46,0x34,0x01,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x00,0xa0,0x01,0x03,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x00,0x00,0x00"
}
10 changes: 10 additions & 0 deletions tools/topology/topology2/include/components/aria/param_2.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Exported with script sof_aria_blobs.m 24-Oct-2024
# cd tools/tune/aria; octave sof_aria_blobs.m
Object.Base.data."aria_config" {
bytes "
0x53,0x4f,0x46,0x34,0x01,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x00,0xa0,0x01,0x03,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x02,0x00,0x00,0x00"
}
10 changes: 10 additions & 0 deletions tools/topology/topology2/include/components/aria/param_3.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Exported with script sof_aria_blobs.m 24-Oct-2024
# cd tools/tune/aria; octave sof_aria_blobs.m
Object.Base.data."aria_config" {
bytes "
0x53,0x4f,0x46,0x34,0x01,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x00,0xa0,0x01,0x03,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x03,0x00,0x00,0x00"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Exported with script sof_aria_blobs.m 24-Oct-2024
# cd tools/tune/aria; octave sof_aria_blobs.m
Object.Base.data."aria_config" {
bytes "
0x53,0x4f,0x46,0x34,0x01,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x00,0xa0,0x01,0x03,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00"
}
Loading