Skip to content

Commit 589d9d9

Browse files
committed
ASoC: SOF: ext_manifest: parse windows
The window description can be extracted from the extended manifest content. This information known at build time does not need to be provided in a mailbox. Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
1 parent cd98918 commit 589d9d9

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

include/sound/sof/ext_manifest.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ struct sof_ext_man_header {
5858
/* Extended manifest elements types */
5959
enum sof_ext_man_elem_type {
6060
SOF_EXT_MAN_ELEM_FW_VERSION = 0,
61+
SOF_EXT_MAN_ELEM_WINDOW = SOF_IPC_EXT_WINDOW,
6162
};
6263

6364
/* extended manifest element header */
@@ -76,4 +77,11 @@ struct sof_ext_man_fw_version {
7677
uint32_t flags;
7778
} __packed;
7879

80+
/* extended data memory windows for IPC, trace and debug */
81+
struct sof_ext_man_window {
82+
struct sof_ext_man_elem_header hdr;
83+
/* use sof_ipc struct because of code re-use */
84+
struct sof_ipc_window ipc_window;
85+
} __packed;
86+
7987
#endif /* __SOF_FIRMWARE_EXT_MANIFEST_H__ */

sound/soc/sof/loader.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,21 @@ static int get_ext_windows(struct snd_sof_dev *sdev,
2020
{
2121
const struct sof_ipc_window *w =
2222
container_of(ext_hdr, struct sof_ipc_window, ext_hdr);
23+
size_t w_size = struct_size(w, window, w->num_windows);
2324

2425
if (w->num_windows == 0 || w->num_windows > SOF_IPC_MAX_ELEMS)
2526
return -EINVAL;
2627

28+
if (sdev->info_window) {
29+
if (memcmp(sdev->info_window, w, w_size)) {
30+
dev_err(sdev->dev, "error: mismatch between window descriptor from extended manifest and mailbox");
31+
return -EINVAL;
32+
}
33+
return 0;
34+
}
35+
2736
/* keep a local copy of the data */
28-
sdev->info_window = kmemdup(w, struct_size(w, window, w->num_windows),
29-
GFP_KERNEL);
37+
sdev->info_window = kmemdup(w, w_size, GFP_KERNEL);
3038
if (!sdev->info_window)
3139
return -ENOMEM;
3240

@@ -140,6 +148,16 @@ static int ext_man_get_fw_version(struct snd_sof_dev *sdev,
140148
return snd_sof_ipc_valid(sdev);
141149
}
142150

151+
static int ext_man_get_windows(struct snd_sof_dev *sdev,
152+
const struct sof_ext_man_elem_header *hdr)
153+
{
154+
const struct sof_ext_man_window *w;
155+
156+
w = container_of(hdr, struct sof_ext_man_window, hdr);
157+
158+
return get_ext_windows(sdev, &w->ipc_window.ext_hdr);
159+
}
160+
143161
static ssize_t snd_sof_ext_man_size(const struct firmware *fw)
144162
{
145163
const struct sof_ext_man_header *head;
@@ -213,6 +231,9 @@ static int snd_sof_fw_ext_man_parse(struct snd_sof_dev *sdev,
213231
case SOF_EXT_MAN_ELEM_FW_VERSION:
214232
ret = ext_man_get_fw_version(sdev, elem_hdr);
215233
break;
234+
case SOF_EXT_MAN_ELEM_WINDOW:
235+
ret = ext_man_get_windows(sdev, elem_hdr);
236+
break;
216237
default:
217238
dev_warn(sdev->dev, "warning: unknown sof_ext_man header type %d size 0x%X\n",
218239
elem_hdr->type, elem_hdr->size);

0 commit comments

Comments
 (0)