]>
Commit | Line | Data |
---|---|---|
6eee8726 RB |
1 | /* |
2 | * skl-sst-utils.c - SKL sst utils functions | |
3 | * | |
4 | * Copyright (C) 2016 Intel Corp | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as version 2, as | |
8 | * published by the Free Software Foundation. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, but | |
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * General Public License for more details. | |
14 | */ | |
15 | ||
16 | #include <linux/firmware.h> | |
17 | #include "skl-sst-dsp.h" | |
18 | ||
19 | /* FW Extended Manifest Header id = $AE1 */ | |
20 | #define SKL_EXT_MANIFEST_HEADER_MAGIC 0x31454124 | |
21 | ||
22 | struct skl_ext_manifest_hdr { | |
23 | u32 id; | |
24 | u32 len; | |
25 | u16 version_major; | |
26 | u16 version_minor; | |
27 | u32 entries; | |
28 | }; | |
29 | ||
30 | /* | |
31 | * some firmware binary contains some extended manifest. This needs | |
32 | * to be stripped in that case before we load and use that image. | |
33 | * | |
34 | * So check for magic header, if found strip the header | |
35 | */ | |
36 | int skl_dsp_strip_extended_manifest(struct firmware *fw) | |
37 | { | |
38 | struct skl_ext_manifest_hdr *hdr; | |
39 | ||
40 | /* check if fw file is greater than header we are looking */ | |
41 | if (fw->size < sizeof(hdr)) { | |
42 | pr_err("%s: Firmware file small, no hdr\n", __func__); | |
43 | return -EINVAL; | |
44 | } | |
45 | ||
46 | hdr = (struct skl_ext_manifest_hdr *)fw->data; | |
47 | ||
48 | if (hdr->id == SKL_EXT_MANIFEST_HEADER_MAGIC) { | |
49 | fw->size -= hdr->len; | |
50 | fw->data += hdr->len; | |
51 | } | |
52 | ||
53 | return 0; | |
54 | } |