Commit 9e72f13e authored by Karol Trzcinski's avatar Karol Trzcinski Committed by Mark Brown

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: default avatarKarol Trzcinski <karolx.trzcinski@linux.intel.com>
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: default avatarKai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20200415202816.934-7-pierre-louis.bossart@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 37109141
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#define __SOF_FIRMWARE_EXT_MANIFEST_H__ #define __SOF_FIRMWARE_EXT_MANIFEST_H__
#include <linux/const.h> #include <linux/const.h>
#include <sound/sof/info.h>
/* In ASCII `XMan` */ /* In ASCII `XMan` */
#define SOF_EXT_MAN_MAGIC_NUMBER 0x6e614d58 #define SOF_EXT_MAN_MAGIC_NUMBER 0x6e614d58
...@@ -54,6 +55,7 @@ struct sof_ext_man_header { ...@@ -54,6 +55,7 @@ struct sof_ext_man_header {
/* Extended manifest elements types */ /* Extended manifest elements types */
enum sof_ext_man_elem_type { enum sof_ext_man_elem_type {
SOF_EXT_MAN_ELEM_FW_VERSION = 0, SOF_EXT_MAN_ELEM_FW_VERSION = 0,
SOF_EXT_MAN_ELEM_WINDOW = SOF_IPC_EXT_WINDOW,
}; };
/* extended manifest element header */ /* extended manifest element header */
...@@ -71,4 +73,11 @@ struct sof_ext_man_fw_version { ...@@ -71,4 +73,11 @@ struct sof_ext_man_fw_version {
uint32_t flags; uint32_t flags;
} __packed; } __packed;
/* extended data memory windows for IPC, trace and debug */
struct sof_ext_man_window {
struct sof_ext_man_elem_header hdr;
/* use sof_ipc struct because of code re-use */
struct sof_ipc_window ipc_window;
} __packed;
#endif /* __SOF_FIRMWARE_EXT_MANIFEST_H__ */ #endif /* __SOF_FIRMWARE_EXT_MANIFEST_H__ */
...@@ -20,13 +20,21 @@ static int get_ext_windows(struct snd_sof_dev *sdev, ...@@ -20,13 +20,21 @@ static int get_ext_windows(struct snd_sof_dev *sdev,
{ {
const struct sof_ipc_window *w = const struct sof_ipc_window *w =
container_of(ext_hdr, struct sof_ipc_window, ext_hdr); container_of(ext_hdr, struct sof_ipc_window, ext_hdr);
size_t w_size = struct_size(w, window, w->num_windows);
if (sdev->info_window) {
if (memcmp(sdev->info_window, w, w_size)) {
dev_err(sdev->dev, "error: mistmatch between window descriptor from extended manifest and mailbox");
return -EINVAL;
}
return 0;
}
if (w->num_windows == 0 || w->num_windows > SOF_IPC_MAX_ELEMS) if (w->num_windows == 0 || w->num_windows > SOF_IPC_MAX_ELEMS)
return -EINVAL; return -EINVAL;
/* keep a local copy of the data */ /* keep a local copy of the data */
sdev->info_window = kmemdup(w, struct_size(w, window, w->num_windows), sdev->info_window = kmemdup(w, w_size, GFP_KERNEL);
GFP_KERNEL);
if (!sdev->info_window) if (!sdev->info_window)
return -ENOMEM; return -ENOMEM;
...@@ -141,6 +149,18 @@ static int ext_man_get_fw_version(struct snd_sof_dev *sdev, ...@@ -141,6 +149,18 @@ static int ext_man_get_fw_version(struct snd_sof_dev *sdev,
return snd_sof_ipc_valid(sdev); return snd_sof_ipc_valid(sdev);
} }
static int ext_man_get_windows(struct snd_sof_dev *sdev,
const struct sof_ext_man_elem_header *hdr)
{
const struct sof_ipc_ext_data_hdr *w_ipc;
const struct sof_ext_man_window *w;
w = container_of(hdr, struct sof_ext_man_window, hdr);
w_ipc = (const struct sof_ipc_ext_data_hdr *)&w->ipc_window;
return get_ext_windows(sdev, w_ipc);
}
static ssize_t snd_sof_ext_man_size(const struct firmware *fw) static ssize_t snd_sof_ext_man_size(const struct firmware *fw)
{ {
const struct sof_ext_man_header *head = (void *)fw->data; 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, ...@@ -218,6 +238,9 @@ static int snd_sof_fw_ext_man_parse(struct snd_sof_dev *sdev,
case SOF_EXT_MAN_ELEM_FW_VERSION: case SOF_EXT_MAN_ELEM_FW_VERSION:
ret = ext_man_get_fw_version(sdev, elem_hdr); ret = ext_man_get_fw_version(sdev, elem_hdr);
break; break;
case SOF_EXT_MAN_ELEM_WINDOW:
ret = ext_man_get_windows(sdev, elem_hdr);
break;
default: default:
dev_warn(sdev->dev, "warning: unknown sof_ext_man header type %d size 0x%X\n", dev_warn(sdev->dev, "warning: unknown sof_ext_man header type %d size 0x%X\n",
elem_hdr->type, elem_hdr->size); elem_hdr->type, elem_hdr->size);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment