Skip to content

Commit

Permalink
aria: change to S24_LE format processing
Browse files Browse the repository at this point in the history
After the following change:
"copier: add support for windows driver
(383d17a)"
aria stopped working properly.
It is necessary to adapt the module
S24_LE format processing

Signed-off-by: Fabiola Kwasowiec <fabiola.kwasowiec@intel.com>
  • Loading branch information
fkwasowi authored and mwasko committed Jan 10, 2024
1 parent 5059614 commit 1cc7a4c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
6 changes: 6 additions & 0 deletions src/audio/aria/aria.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ static int aria_prepare(struct processing_module *mod,
sink = list_first_item(&dev->bsink_list, struct comp_buffer, source_list);
aria_set_stream_params(sink, mod);

if (audio_stream_get_valid_fmt(&source->stream) != SOF_IPC_FRAME_S24_4LE ||
audio_stream_get_valid_fmt(&sink->stream) != SOF_IPC_FRAME_S24_4LE) {
comp_err(dev, "aria_prepare(): format is not supported");
return -EINVAL;
}

if (dev->state == COMP_STATE_ACTIVE) {
comp_info(dev, "aria_prepare(): Component is in active state.");
return 0;
Expand Down
7 changes: 3 additions & 4 deletions src/audio/aria/aria_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ inline void aria_algo_calc_gain(struct aria_data *cd, size_t gain_idx,
src = audio_stream_wrap(source, src + n);
samples -= n;
}

/*zero check for maxis not needed since att is in range <0;3>*/
if (max_data > (0x7fffffff >> att))
gain = (0x7fffffffULL << 32) / max_data;
if (max_data > (0x007fffff >> att))
gain = (0x007fffffULL << 32) / max_data;

cd->gains[gain_idx] = (int32_t)(gain >> (att + 1));
}
Expand Down Expand Up @@ -83,7 +82,7 @@ void aria_algo_get_data(struct processing_module *mod,
for (i = 0; i < n; i += ch_n) {
for (ch = 0; ch < ch_n; ch++) {
in_sample = *in++;
out[ch] = q_multsr_sat_32x32(in_sample, gain, shift);
out[ch] = q_multsr_sat_32x32_24(in_sample, gain, shift);
}
gain += step;
out += ch_n;
Expand Down
24 changes: 14 additions & 10 deletions src/audio/aria/aria_hifi3.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ inline void aria_algo_calc_gain(struct aria_data *cd, size_t gain_idx,
samples -= n;
}
/*zero check for maxis not needed since att is in range <0;3>*/
if (max > (0x7fffffff >> att))
gain = (0x7fffffffULL << 32) / max;
if (max > (0x007fffff >> att))
gain = (0x007fffffULL << 32) / max;

/* normalization by attenuation factor to obtain fractional range <1 / (2 pow att), 1> */
cd->gains[gain_idx] = (int32_t)(gain >> (att + 1));
Expand All @@ -74,14 +74,15 @@ void aria_algo_get_data_odd_channel(struct processing_module *mod,
int32_t gain_end = cd->gains[INDEX_TAB[gain_state_add_3]];
size_t samples = frames * audio_stream_get_channels(sink);
ae_int32x2 *out = audio_stream_get_wptr(sink);
int32_t att = cd->att;
ae_int32x2 *in = (ae_int32x2 *)cd->data_ptr;
ae_valign inu = AE_ZALIGN64();
ae_valign outu = AE_ZALIGN64();
ae_int32x2 in_sample, out_sample;
const int inc = sizeof(ae_int32);
ae_int32x2 gain;
const int ch_n = cd->chan_cnt;
const int shift_bits = 31 - cd->att - 24;
ae_int64 out1;

for (i = 1; i < ARIA_MAX_GAIN_STATES - 1; i++) {
if (cd->gains[INDEX_TAB[gain_state_add_2 + i]] < gain_begin)
Expand All @@ -102,9 +103,9 @@ 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);
out_sample = AE_MULFP32X2RS(in_sample, gain);

out_sample = AE_SLAA32S(out_sample, att);
out1 = AE_MUL32_HH(in_sample, gain);
out1 = AE_SRAA64(out1, shift_bits);
out_sample = AE_ROUND24X2F48SSYM(out1, out1);
AE_S32_L_XP(out_sample, (ae_int32 *)out, inc);
}
gain = AE_ADD32S(gain, step);
Expand All @@ -131,13 +132,14 @@ void aria_algo_get_data_even_channel(struct processing_module *mod,
int32_t gain_end = cd->gains[INDEX_TAB[gain_state_add_3]];
size_t samples = frames * audio_stream_get_channels(sink);
ae_int32x2 *out = audio_stream_get_wptr(sink);
int32_t att = cd->att;
ae_int32x2 *in = (ae_int32x2 *)cd->data_ptr;
ae_valign inu = AE_ZALIGN64();
ae_valign outu = AE_ZALIGN64();
ae_int32x2 in_sample, out_sample;
ae_int32x2 gain;
const int ch_n = cd->chan_cnt;
const int shift_bits = 31 - cd->att - 24;
ae_int64 out1, out2;

for (i = 1; i < ARIA_MAX_GAIN_STATES - 1; i++) {
if (cd->gains[INDEX_TAB[gain_state_add_2 + i]] < gain_begin)
Expand All @@ -158,9 +160,11 @@ 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);
out_sample = AE_MULFP32X2RS(in_sample, gain);

out_sample = AE_SLAA32S(out_sample, att);
out1 = AE_MUL32_HH(in_sample, gain);
out1 = AE_SRAA64(out1, shift_bits);
out2 = AE_MUL32_LL(in_sample, gain);
out2 = AE_SRAA64(out2, shift_bits);
out_sample = AE_ROUND24X2F48SSYM(out1, out2);
AE_SA32X2_IP(out_sample, outu, out);
}
gain = AE_ADD32S(gain, step);
Expand Down

0 comments on commit 1cc7a4c

Please sign in to comment.