SRC: Bug fix for handling a deleted conversion

This patch fixes a regression that caused SRC to try to initialize
for a mode that has been disabled from in/out rates matrix. The feature
exist to save tables RAM with modes those are not required. The bug
caused a divide by zero to happen in src_buffer_lengths() function.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This commit is contained in:
Seppo Ingalsuo 2017-12-05 15:54:56 +02:00 committed by Liam Girdwood
parent eaf0c0669f
commit 3805427244
1 changed files with 13 additions and 7 deletions

View File

@ -133,7 +133,6 @@ int src_buffer_lengths(struct src_param *a, int fs_in, int fs_out, int nch,
{
struct src_stage *stage1;
struct src_stage *stage2;
int k;
int q;
int den;
int num;
@ -149,18 +148,25 @@ int src_buffer_lengths(struct src_param *a, int fs_in, int fs_out, int nch,
a->idx_in = src_find_fs(src_in_fs, NUM_IN_FS, fs_in);
a->idx_out = src_find_fs(src_out_fs, NUM_OUT_FS, fs_out);
/* Set blk_in, blk_out so that the muted fallback SRC keeps
* just source & sink in sync in pipeline without drift.
*/
/* Check that both in and out rates are supported */
if ((a->idx_in < 0) || (a->idx_out < 0)) {
k = gcd(fs_in, fs_out);
a->blk_in = fs_in / k;
a->blk_out = fs_out / k;
trace_src_error("us1");
tracev_value(fs_in);
tracev_value(fs_out);
return -EINVAL;
}
stage1 = src_table1[a->idx_out][a->idx_in];
stage2 = src_table2[a->idx_out][a->idx_in];
/* Check from stage1 parameter for a deleted in/out rate combination.*/
if (stage1->filter_length < 1) {
trace_src_error("us2");
tracev_value(fs_in);
tracev_value(fs_out);
return -EINVAL;
}
a->fir_s1 = nch * src_fir_delay_length(stage1);
a->out_s1 = nch * src_out_delay_length(stage1);