Skip to content

Commit 3e2a89d

Browse files
ktrzcinxbroonie
authored andcommitted
ASoC: SOF: ext_manifest: parse firmware version
The firmware version 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: Kai Vehmanen <kai.vehmanen@linux.intel.com> Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Link: https://lore.kernel.org/r/20200520165911.21696-4-kai.vehmanen@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent a80cf19 commit 3e2a89d

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

‎include/sound/sof/ext_manifest.h‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/bits.h>
2020
#include <linux/compiler.h>
2121
#include <linux/types.h>
22+
#include <sound/sof/info.h>
2223

2324
/* In ASCII `XMan` */
2425
#define SOF_EXT_MAN_MAGIC_NUMBER 0x6e614d58
@@ -54,6 +55,11 @@ struct sof_ext_man_header {
5455

5556
/* Now define extended manifest elements */
5657

58+
/* Extended manifest elements types */
59+
enum sof_ext_man_elem_type {
60+
SOF_EXT_MAN_ELEM_FW_VERSION = 0,
61+
};
62+
5763
/* extended manifest element header */
5864
struct sof_ext_man_elem_header {
5965
uint32_t type; /*< SOF_EXT_MAN_ELEM_ */
@@ -62,4 +68,12 @@ struct sof_ext_man_elem_header {
6268
/* just after this header should be type dependent content */
6369
} __packed;
6470

71+
/* FW version */
72+
struct sof_ext_man_fw_version {
73+
struct sof_ext_man_elem_header hdr;
74+
/* use sof_ipc struct because of code re-use */
75+
struct sof_ipc_fw_version version;
76+
uint32_t flags;
77+
} __packed;
78+
6579
#endif /* __SOF_FIRMWARE_EXT_MANIFEST_H__ */

‎sound/soc/sof/loader.c‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,19 @@ int snd_sof_fw_parse_ext_data(struct snd_sof_dev *sdev, u32 bar, u32 offset)
127127
}
128128
EXPORT_SYMBOL(snd_sof_fw_parse_ext_data);
129129

130+
static int ext_man_get_fw_version(struct snd_sof_dev *sdev,
131+
const struct sof_ext_man_elem_header *hdr)
132+
{
133+
const struct sof_ext_man_fw_version *v =
134+
container_of(hdr, struct sof_ext_man_fw_version, hdr);
135+
136+
memcpy(&sdev->fw_ready.version, &v->version, sizeof(v->version));
137+
sdev->fw_ready.flags = v->flags;
138+
139+
/* log ABI versions and check FW compatibility */
140+
return snd_sof_ipc_valid(sdev);
141+
}
142+
130143
static ssize_t snd_sof_ext_man_size(const struct firmware *fw)
131144
{
132145
const struct sof_ext_man_header *head;
@@ -197,6 +210,9 @@ static int snd_sof_fw_ext_man_parse(struct snd_sof_dev *sdev,
197210

198211
/* process structure data */
199212
switch (elem_hdr->type) {
213+
case SOF_EXT_MAN_ELEM_FW_VERSION:
214+
ret = ext_man_get_fw_version(sdev, elem_hdr);
215+
break;
200216
default:
201217
dev_warn(sdev->dev, "warning: unknown sof_ext_man header type %d size 0x%X\n",
202218
elem_hdr->type, elem_hdr->size);

0 commit comments

Comments
 (0)