Skip to content

Commit 1615d73

Browse files
wjablon1lgirdwood
authored andcommitted
dai-zephyr: fix config nuances
If a DAI config is passed as a blob (IPC4 case) to dai_set_config, it cannot be cast to sof_ipc_dai_config because the blob format might differ. This commit fixes this by using the format field of ipc_config_dai instead. Field options is set to 0 for the blob case. Additionally, this commit trims the size of a bespoke config for non-blob case after removing the common header. Signed-off-by: Wojciech Jablonski <wojciech.jablonski@intel.com>
1 parent 7fd5fd6 commit 1615d73

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/audio/dai-zephyr.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,15 @@ __cold int dai_set_config(struct dai *dai, struct ipc_config_dai *common_config,
146146
const struct sof_ipc_dai_config *sof_cfg = spec_config;
147147
struct dai_config cfg = {0};
148148
const void *cfg_params;
149+
size_t dai_cfg_size = size;
149150
bool is_blob;
150151

151152
assert_can_be_cold();
152153

153154
cfg.dai_index = common_config->dai_index;
154155
is_blob = common_config->is_config_blob;
155-
cfg.format = sof_cfg->format;
156-
cfg.options = sof_cfg->flags;
156+
cfg.format = common_config->format;
157+
cfg.options = is_blob ? 0 : sof_cfg->flags;
157158
cfg.rate = common_config->sampling_frequency;
158159

159160
switch (common_config->type) {
@@ -195,7 +196,14 @@ __cold int dai_set_config(struct dai *dai, struct ipc_config_dai *common_config,
195196
return -EINVAL;
196197
}
197198

198-
return dai_config_set(dev, &cfg, cfg_params, size);
199+
if (!is_blob) {
200+
if (size < SOF_DAI_CONFIG_HW_SPEC_OFFSET)
201+
return -EINVAL;
202+
203+
dai_cfg_size -= SOF_DAI_CONFIG_HW_SPEC_OFFSET;
204+
}
205+
206+
return dai_config_set(dev, &cfg, cfg_params, dai_cfg_size);
199207
}
200208

201209
/* called from ipc/ipc3/dai.c */

src/include/ipc/dai.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <ipc/dai-mediatek.h>
2222
#include <ipc/dai-amd.h>
2323
#include <ipc/header.h>
24+
#include <stddef.h>
2425
#include <stdint.h>
2526

2627
/*
@@ -97,6 +98,8 @@ enum sof_ipc_dai_type {
9798
SOF_DAI_AMD_SW_AUDIO /**<Amd SW AUDIO */
9899
};
99100

101+
#define SOF_DAI_CONFIG_HW_SPEC_OFFSET offsetof(struct sof_ipc_dai_config, ssp)
102+
100103
/* general purpose DAI configuration */
101104
struct sof_ipc_dai_config {
102105
struct sof_ipc_cmd_hdr hdr;

0 commit comments

Comments
 (0)