]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
ASoC: SOF: ext_manifest: parse firmware version
authorKarol Trzcinski <karolx.trzcinski@linux.intel.com>
Wed, 15 Apr 2020 20:27:57 +0000 (15:27 -0500)
committerMark Brown <broonie@kernel.org>
Wed, 15 Apr 2020 23:23:02 +0000 (00:23 +0100)
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: 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-6-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/uapi/sound/sof/ext_manifest.h
sound/soc/sof/loader.c

index fc4d1bec0cb32608f6027b352761a5c36cab109d..163d32210ad83de71aa027980d11eb6dedadb2ec 100644 (file)
@@ -51,6 +51,11 @@ struct sof_ext_man_header {
 
 /* Now define extended manifest elements */
 
+/* Extended manifest elements types */
+enum sof_ext_man_elem_type {
+       SOF_EXT_MAN_ELEM_FW_VERSION             = 0,
+};
+
 /* extended manifest element header */
 struct sof_ext_man_elem_header {
        uint32_t type;          /*< SOF_EXT_MAN_ELEM_ */
@@ -58,4 +63,12 @@ struct sof_ext_man_elem_header {
        uint8_t blob[];         /*< type dependent content */
 } __packed;
 
+/* FW version */
+struct sof_ext_man_fw_version {
+       struct sof_ext_man_elem_header hdr;
+       /* use sof_ipc struct because of code re-use */
+       struct sof_ipc_fw_version version;
+       uint32_t flags;
+} __packed;
+
 #endif /* __SOF_FIRMWARE_EXT_MANIFEST_H__ */
index 6b354b6fb83a1c701a1bcb6ef39978a0c03deb86..01077c1ce235ef7a0e6e19e97025d0e8b7208e27 100644 (file)
@@ -127,6 +127,20 @@ int snd_sof_fw_parse_ext_data(struct snd_sof_dev *sdev, u32 bar, u32 offset)
 }
 EXPORT_SYMBOL(snd_sof_fw_parse_ext_data);
 
+static int ext_man_get_fw_version(struct snd_sof_dev *sdev,
+                                 const struct sof_ext_man_elem_header *hdr)
+{
+       const struct sof_ext_man_fw_version *v;
+
+       v = container_of(hdr, struct sof_ext_man_fw_version, hdr);
+
+       memcpy(&sdev->fw_ready.version, &v->version, sizeof(v->version));
+       sdev->fw_ready.flags = v->flags;
+
+       /* log ABI versions and check FW compatibility */
+       return snd_sof_ipc_valid(sdev);
+}
+
 static ssize_t snd_sof_ext_man_size(const struct firmware *fw)
 {
        const struct sof_ext_man_header *head = (void *)fw->data;
@@ -201,6 +215,9 @@ static int snd_sof_fw_ext_man_parse(struct snd_sof_dev *sdev,
 
                /* process structure data */
                switch (elem_hdr->type) {
+               case SOF_EXT_MAN_ELEM_FW_VERSION:
+                       ret = ext_man_get_fw_version(sdev, elem_hdr);
+                       break;
                default:
                        dev_warn(sdev->dev, "warning: unknown sof_ext_man header type %d size 0x%X\n",
                                 elem_hdr->type, elem_hdr->size);