Skip to content

Commit a6a651c

Browse files
committed
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. Filed options is set to 0 for the blob case. Additionally, this commit trims the size of bespoke config for non-blob case after removing the common header. Signed-off-by: Wojciech Jablonski <wojciech.jablonski@intel.com>
1 parent 112425c commit a6a651c

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ enum sof_ipc_dai_type {
9797
SOF_DAI_AMD_SW_AUDIO /**<Amd SW AUDIO */
9898
};
9999

100+
#define SOF_DAI_CONFIG_HW_SPEC_OFFSET offsetof(struct sof_ipc_dai_config, ssp)
101+
100102
/* general purpose DAI configuration */
101103
struct sof_ipc_dai_config {
102104
struct sof_ipc_cmd_hdr hdr;

0 commit comments

Comments
 (0)