Skip to content

Commit 9e72f13

Browse files
ktrzcinxbroonie
authored andcommitted
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> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Link: https://lore.kernel.org/r/20200415202816.934-7-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 3710914 commit 9e72f13

2 files changed

Lines changed: 34 additions & 2 deletions

File tree

‎include/uapi/sound/sof/ext_manifest.h‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#define __SOF_FIRMWARE_EXT_MANIFEST_H__
1818

1919
#include <linux/const.h>
20+
#include <sound/sof/info.h>
2021

2122
/* In ASCII `XMan` */
2223
#define SOF_EXT_MAN_MAGIC_NUMBER 0x6e614d58
@@ -54,6 +55,7 @@ struct sof_ext_man_header {
5455
/* Extended manifest elements types */
5556
enum sof_ext_man_elem_type {
5657
SOF_EXT_MAN_ELEM_FW_VERSION = 0,
58+
SOF_EXT_MAN_ELEM_WINDOW = SOF_IPC_EXT_WINDOW,
5759
};
5860

5961
/* extended manifest element header */
@@ -71,4 +73,11 @@ struct sof_ext_man_fw_version {
7173
uint32_t flags;
7274
} __packed;
7375

76+
/* extended data memory windows for IPC, trace and debug */
77+
struct sof_ext_man_window {
78+
struct sof_ext_man_elem_header hdr;
79+
/* use sof_ipc struct because of code re-use */
80+
struct sof_ipc_window ipc_window;
81+
} __packed;
82+
7483
#endif /* __SOF_FIRMWARE_EXT_MANIFEST_H__ */

‎sound/soc/sof/loader.c‎

Lines changed: 25 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);
24+
25+
if (sdev->info_window) {
26+
if (memcmp(sdev->info_window, w, w_size)) {
27+
dev_err(sdev->dev, "error: mistmatch between window descriptor from extended manifest and mailbox");
28+
return -EINVAL;
29+
}
30+
return 0;
31+
}
2332

2433
if (w->num_windows == 0 || w->num_windows > SOF_IPC_MAX_ELEMS)
2534
return -EINVAL;
2635

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

@@ -141,6 +149,18 @@ static int ext_man_get_fw_version(struct snd_sof_dev *sdev,
141149
return snd_sof_ipc_valid(sdev);
142150
}
143151

152+
static int ext_man_get_windows(struct snd_sof_dev *sdev,
153+
const struct sof_ext_man_elem_header *hdr)
154+
{
155+
const struct sof_ipc_ext_data_hdr *w_ipc;
156+
const struct sof_ext_man_window *w;
157+
158+
w = container_of(hdr, struct sof_ext_man_window, hdr);
159+
w_ipc = (const struct sof_ipc_ext_data_hdr *)&w->ipc_window;
160+
161+
return get_ext_windows(sdev, w_ipc);
162+
}
163+
144164
static ssize_t snd_sof_ext_man_size(const struct firmware *fw)
145165
{
146166
const struct sof_ext_man_header *head = (void *)fw->data;
@@ -218,6 +238,9 @@ static int snd_sof_fw_ext_man_parse(struct snd_sof_dev *sdev,
218238
case SOF_EXT_MAN_ELEM_FW_VERSION:
219239
ret = ext_man_get_fw_version(sdev, elem_hdr);
220240
break;
241+
case SOF_EXT_MAN_ELEM_WINDOW:
242+
ret = ext_man_get_windows(sdev, elem_hdr);
243+
break;
221244
default:
222245
dev_warn(sdev->dev, "warning: unknown sof_ext_man header type %d size 0x%X\n",
223246
elem_hdr->type, elem_hdr->size);

0 commit comments

Comments
 (0)