Skip to content

Commit

Permalink
aria: change to LSB 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
to LSB processing

Signed-off-by: Fabiola Kwasowiec <fabiola.kwasowiec@intel.com>
  • Loading branch information
fkwasowi committed Jan 9, 2024
1 parent 0698fa3 commit ecb6847
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
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 ecb6847

Please sign in to comment.