Skip to content

Commit 609d8a4

Browse files
committed
eq: update frame fmt and period bytes based on source fmt
update frame fmt and period bytes based on source format during prepare to be able to handle all three PCM formats. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
1 parent 4c57e2b commit 609d8a4

2 files changed

Lines changed: 47 additions & 6 deletions

File tree

src/audio/eq_fir.c

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,8 @@ static inline void set_s32_fir(struct comp_data *cd)
139139
static inline int set_fir_func(struct comp_dev *dev)
140140
{
141141
struct comp_data *cd = comp_get_drvdata(dev);
142-
struct sof_ipc_comp_config *config = COMP_GET_CONFIG(dev);
143142

144-
switch (config->frame_fmt) {
143+
switch (dev->params.frame_fmt) {
145144
case SOF_IPC_FRAME_S16_LE:
146145
trace_eq("f16");
147146
set_s16_fir(cd);
@@ -194,9 +193,8 @@ static void eq_fir_s32_passthrough(struct fir_state_32x16 fir[],
194193
static inline int set_pass_func(struct comp_dev *dev)
195194
{
196195
struct comp_data *cd = comp_get_drvdata(dev);
197-
struct sof_ipc_comp_config *config = COMP_GET_CONFIG(dev);
198196

199-
switch (config->frame_fmt) {
197+
switch (dev->params.frame_fmt) {
200198
case SOF_IPC_FRAME_S16_LE:
201199
trace_eq("p16");
202200
cd->eq_fir_func_even = eq_fir_s16_passthrough;
@@ -671,6 +669,8 @@ static int eq_fir_copy(struct comp_dev *dev)
671669
static int eq_fir_prepare(struct comp_dev *dev)
672670
{
673671
struct comp_data *cd = comp_get_drvdata(dev);
672+
struct sof_ipc_comp_config *config = COMP_GET_CONFIG(dev);
673+
struct comp_buffer *sourceb, *sinkb;
674674
int ret;
675675

676676
trace_eq("pre");
@@ -679,6 +679,26 @@ static int eq_fir_prepare(struct comp_dev *dev)
679679
if (ret < 0)
680680
return ret;
681681

682+
/* EQ components will only ever have 1 source and 1 sink buffer */
683+
sourceb = list_first_item(&dev->bsource_list,
684+
struct comp_buffer, sink_list);
685+
sinkb = list_first_item(&dev->bsink_list,
686+
struct comp_buffer, source_list);
687+
688+
/* set period bytes and frame format */
689+
comp_set_period_bytes(sourceb->source, dev->frames,
690+
&dev->params.frame_fmt, &cd->period_bytes);
691+
692+
/* rewrite frame_bytes for all downstream */
693+
dev->frame_bytes = cd->period_bytes / dev->frames;
694+
695+
/* set downstream buffer size */
696+
ret = buffer_set_size(sinkb, cd->period_bytes * config->periods_sink);
697+
if (ret < 0) {
698+
trace_eq_error("ef0");
699+
return ret;
700+
}
701+
682702
/* Initialize EQ */
683703
if (cd->config) {
684704
ret = eq_fir_setup(cd, dev->params.channels);

src/audio/eq_iir.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,7 @@ static int eq_iir_prepare(struct comp_dev *dev)
635635
{
636636
struct comp_data *cd = comp_get_drvdata(dev);
637637
struct sof_ipc_comp_config *config = COMP_GET_CONFIG(dev);
638+
struct comp_buffer *sourceb, *sinkb;
638639
int ret;
639640

640641
trace_eq("pre");
@@ -643,14 +644,34 @@ static int eq_iir_prepare(struct comp_dev *dev)
643644
if (ret < 0)
644645
return ret;
645646

647+
/* EQ components will only ever have 1 source and 1 sink buffer */
648+
sourceb = list_first_item(&dev->bsource_list,
649+
struct comp_buffer, sink_list);
650+
sinkb = list_first_item(&dev->bsink_list,
651+
struct comp_buffer, source_list);
652+
653+
/* set period bytes and frame format */
654+
comp_set_period_bytes(sourceb->source, dev->frames,
655+
&dev->params.frame_fmt, &cd->period_bytes);
656+
657+
/* rewrite frame_bytes for all downstream */
658+
dev->frame_bytes = cd->period_bytes / dev->frames;
659+
660+
/* set downstream buffer size */
661+
ret = buffer_set_size(sinkb, cd->period_bytes * config->periods_sink);
662+
if (ret < 0) {
663+
trace_eq_error("ef0");
664+
return ret;
665+
}
666+
646667
/* Initialize EQ */
647668
if (cd->config) {
648669
ret = eq_iir_setup(cd, dev->params.channels);
649670
if (ret < 0) {
650671
comp_set_state(dev, COMP_TRIGGER_RESET);
651672
return ret;
652673
}
653-
switch (config->frame_fmt) {
674+
switch (dev->params.frame_fmt) {
654675
case SOF_IPC_FRAME_S16_LE:
655676
trace_eq("i16");
656677
cd->eq_iir_func = eq_iir_s16_default;
@@ -668,7 +689,7 @@ static int eq_iir_prepare(struct comp_dev *dev)
668689
return -EINVAL;
669690
}
670691
} else {
671-
switch (config->frame_fmt) {
692+
switch (dev->params.frame_fmt) {
672693
case SOF_IPC_FRAME_S16_LE:
673694
trace_eq("p16");
674695
cd->eq_iir_func = eq_iir_s16_passthrough;

0 commit comments

Comments
 (0)