set_attenuation: adding checker based on config data

Adding attenuation checking based on the frame_fmt
from the config of the module instead of calling
sink->stream.frame_fmt, because sending IPC_SET_ATTENUATION
before calling module_prepare results in an error,
because at this stage the sink values are not yet set
(sink->stream.frame_fmt is zero)

Signed-off-by: Kwasowiec, Fabiola <fabiola.kwasowiec@intel.com>
This commit is contained in:
Kwasowiec, Fabiola 2023-03-27 12:23:47 +02:00 committed by Kai Vehmanen
parent 4e605c888b
commit 17b539f1c8
2 changed files with 22 additions and 18 deletions

View File

@ -1576,9 +1576,8 @@ static int copier_set_sink_fmt(struct comp_dev *dev, const void *data,
static int set_attenuation(struct comp_dev *dev, uint32_t data_offset, const char *data)
{
struct copier_data *cd = comp_get_drvdata(dev);
struct comp_buffer *sink;
struct list_item *sink_list;
uint32_t attenuation;
uint32_t __sparse_cache valid_fmt, frame_fmt;
/* only support attenuation in format of 32bit */
if (data_offset > sizeof(uint32_t)) {
@ -1592,13 +1591,16 @@ static int set_attenuation(struct comp_dev *dev, uint32_t data_offset, const cha
return -EINVAL;
}
list_for_item(sink_list, &dev->bsink_list) {
sink = container_of(sink_list, struct comp_buffer, source_list);
if (sink->stream.frame_fmt < SOF_IPC_FRAME_S24_4LE) {
comp_err(dev, "sink %d in format %d isn't supported by attenuation",
sink->id, sink->buffer_fmt);
return -EINVAL;
}
audio_stream_fmt_conversion(cd->config.base.audio_fmt.depth,
cd->config.base.audio_fmt.valid_bit_depth,
&frame_fmt,
&valid_fmt,
cd->config.base.audio_fmt.s_type);
if (frame_fmt < SOF_IPC_FRAME_S24_4LE) {
comp_err(dev, "frame_fmt %d isn't supported by attenuation",
frame_fmt);
return -EINVAL;
}
cd->attenuation = attenuation;

View File

@ -983,9 +983,9 @@ static int volume_set_attenuation(struct processing_module *mod, const uint8_t *
{
struct vol_data *cd = module_get_private_data(mod);
struct comp_dev *dev = mod->dev;
struct list_item *sink_list;
struct comp_buffer *sink;
uint32_t attenuation;
uint32_t __sparse_cache valid_fmt, frame_fmt;
/* only support attenuation in format of 32bit */
if (data_size > sizeof(uint32_t)) {
@ -999,13 +999,15 @@ static int volume_set_attenuation(struct processing_module *mod, const uint8_t *
return -EINVAL;
}
list_for_item(sink_list, &dev->bsink_list) {
sink = container_of(sink_list, struct comp_buffer, source_list);
if (sink->stream.frame_fmt < SOF_IPC_FRAME_S24_4LE) {
comp_err(dev, "sink %d in format %d isn't supported by attenuation",
sink->id, sink->stream.frame_fmt);
return -EINVAL;
}
audio_stream_fmt_conversion(mod->priv.cfg.base_cfg.audio_fmt.depth,
mod->priv.cfg.base_cfg.audio_fmt.valid_bit_depth,
&frame_fmt, &valid_fmt,
mod->priv.cfg.base_cfg.audio_fmt.s_type);
if (frame_fmt < SOF_IPC_FRAME_S24_4LE) {
comp_err(dev, "frame_fmt %d isn't supported by attenuation",
frame_fmt);
return -EINVAL;
}
cd->attenuation = attenuation;