]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
ASoC: Intel: Skylake: Add strip extended manifest utility
authorRamesh Babu <ramesh.babu@intel.com>
Mon, 30 May 2016 12:12:55 +0000 (17:42 +0530)
committerMark Brown <broonie@kernel.org>
Mon, 30 May 2016 17:24:41 +0000 (18:24 +0100)
Some upcoming platforms like broxton etc have extended manifest
in firmware binary. This is not required to be downloaded to DSP.
So driver needs to strip this before downloading.

Add a utility function to check if a header exists, and remove it
in that case

Signed-off-by: Ramesh Babu <ramesh.babu@intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/intel/skylake/Makefile
sound/soc/intel/skylake/skl-sst-dsp.h
sound/soc/intel/skylake/skl-sst-utils.c [new file with mode: 0644]

index c28f5d0e1d99fee2d254d65c595638c4c0cb71bb..60fbc9bbe47330c720fd286e1c57606d34b0312d 100644 (file)
@@ -5,6 +5,6 @@ obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE) += snd-soc-skl.o
 
 # Skylake IPC Support
 snd-soc-skl-ipc-objs := skl-sst-ipc.o skl-sst-dsp.o skl-sst-cldma.o \
-               skl-sst.o bxt-sst.o
+               skl-sst.o bxt-sst.o skl-sst-utils.o
 
 obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE) += snd-soc-skl-ipc.o
index deabe7308d3bc779389982b15bc3cea10d4d32b0..94878fac2269f8a47d69a38056768a6de01122b3 100644 (file)
@@ -175,4 +175,6 @@ int bxt_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq,
 void skl_sst_dsp_cleanup(struct device *dev, struct skl_sst *ctx);
 void bxt_sst_dsp_cleanup(struct device *dev, struct skl_sst *ctx);
 
+int skl_dsp_strip_extended_manifest(struct firmware *fw);
+
 #endif /*__SKL_SST_DSP_H__*/
diff --git a/sound/soc/intel/skylake/skl-sst-utils.c b/sound/soc/intel/skylake/skl-sst-utils.c
new file mode 100644 (file)
index 0000000..c00567d
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ *  skl-sst-utils.c - SKL sst utils functions
+ *
+ *  Copyright (C) 2016 Intel Corp
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ */
+
+#include <linux/firmware.h>
+#include "skl-sst-dsp.h"
+
+/* FW Extended Manifest Header id = $AE1 */
+#define SKL_EXT_MANIFEST_HEADER_MAGIC   0x31454124
+
+struct skl_ext_manifest_hdr {
+       u32 id;
+       u32 len;
+       u16 version_major;
+       u16 version_minor;
+       u32 entries;
+};
+
+/*
+ * some firmware binary contains some extended manifest. This needs
+ * to be stripped in that case before we load and use that image.
+ *
+ * So check for magic header, if found strip the header
+ */
+int skl_dsp_strip_extended_manifest(struct firmware *fw)
+{
+       struct skl_ext_manifest_hdr *hdr;
+
+       /* check if fw file is greater than header we are looking */
+       if (fw->size < sizeof(hdr)) {
+               pr_err("%s: Firmware file small, no hdr\n", __func__);
+               return -EINVAL;
+       }
+
+       hdr = (struct skl_ext_manifest_hdr *)fw->data;
+
+       if (hdr->id == SKL_EXT_MANIFEST_HEADER_MAGIC) {
+               fw->size -= hdr->len;
+               fw->data += hdr->len;
+       }
+
+       return 0;
+}