• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * wmfw.h - Wolfson firmware format information
4  *
5  * Copyright 2012 Wolfson Microelectronics plc
6  *
7  * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
8  */
9 
10 #ifndef __WMFW_H
11 #define __WMFW_H
12 
13 #include <linux/types.h>
14 
15 #define WMFW_MAX_ALG_NAME         256
16 #define WMFW_MAX_ALG_DESCR_NAME   256
17 
18 #define WMFW_MAX_COEFF_NAME       256
19 #define WMFW_MAX_COEFF_DESCR_NAME 256
20 
21 #define WMFW_CTL_FLAG_SYS         0x8000
22 #define WMFW_CTL_FLAG_VOLATILE    0x0004
23 #define WMFW_CTL_FLAG_WRITEABLE   0x0002
24 #define WMFW_CTL_FLAG_READABLE    0x0001
25 
26 /* Non-ALSA coefficient types start at 0x1000 */
27 #define WMFW_CTL_TYPE_ACKED       0x1000 /* acked control */
28 #define WMFW_CTL_TYPE_HOSTEVENT   0x1001 /* event control */
29 #define WMFW_CTL_TYPE_HOST_BUFFER 0x1002 /* host buffer pointer */
30 
31 struct wmfw_header {
32 	char magic[4];
33 	__le32 len;
34 	__le16 rev;
35 	u8 core;
36 	u8 ver;
37 } __packed;
38 
39 struct wmfw_footer {
40 	__le64 timestamp;
41 	__le32 checksum;
42 } __packed;
43 
44 struct wmfw_adsp1_sizes {
45 	__le32 dm;
46 	__le32 pm;
47 	__le32 zm;
48 } __packed;
49 
50 struct wmfw_adsp2_sizes {
51 	__le32 xm;
52 	__le32 ym;
53 	__le32 pm;
54 	__le32 zm;
55 } __packed;
56 
57 struct wmfw_region {
58 	union {
59 		__be32 type;
60 		__le32 offset;
61 	};
62 	__le32 len;
63 	u8 data[];
64 } __packed;
65 
66 struct wmfw_id_hdr {
67 	__be32 core_id;
68 	__be32 core_rev;
69 	__be32 id;
70 	__be32 ver;
71 } __packed;
72 
73 struct wmfw_v3_id_hdr {
74 	__be32 core_id;
75 	__be32 block_rev;
76 	__be32 vendor_id;
77 	__be32 id;
78 	__be32 ver;
79 } __packed;
80 
81 struct wmfw_adsp1_id_hdr {
82 	struct wmfw_id_hdr fw;
83 	__be32 zm;
84 	__be32 dm;
85 	__be32 n_algs;
86 } __packed;
87 
88 struct wmfw_adsp2_id_hdr {
89 	struct wmfw_id_hdr fw;
90 	__be32 zm;
91 	__be32 xm;
92 	__be32 ym;
93 	__be32 n_algs;
94 } __packed;
95 
96 struct wmfw_halo_id_hdr {
97 	struct wmfw_v3_id_hdr fw;
98 	__be32 xm_base;
99 	__be32 xm_size;
100 	__be32 ym_base;
101 	__be32 ym_size;
102 	__be32 n_algs;
103 } __packed;
104 
105 struct wmfw_alg_hdr {
106 	__be32 id;
107 	__be32 ver;
108 } __packed;
109 
110 struct wmfw_adsp1_alg_hdr {
111 	struct wmfw_alg_hdr alg;
112 	__be32 zm;
113 	__be32 dm;
114 } __packed;
115 
116 struct wmfw_adsp2_alg_hdr {
117 	struct wmfw_alg_hdr alg;
118 	__be32 zm;
119 	__be32 xm;
120 	__be32 ym;
121 } __packed;
122 
123 struct wmfw_halo_alg_hdr {
124 	struct wmfw_alg_hdr alg;
125 	__be32 xm_base;
126 	__be32 xm_size;
127 	__be32 ym_base;
128 	__be32 ym_size;
129 } __packed;
130 
131 struct wmfw_adsp_alg_data {
132 	__le32 id;
133 	u8 name[WMFW_MAX_ALG_NAME];
134 	u8 descr[WMFW_MAX_ALG_DESCR_NAME];
135 	__le32 ncoeff;
136 	u8 data[];
137 } __packed;
138 
139 struct wmfw_adsp_coeff_data {
140 	struct {
141 		__le16 offset;
142 		__le16 type;
143 		__le32 size;
144 	} hdr;
145 	u8 name[WMFW_MAX_COEFF_NAME];
146 	u8 descr[WMFW_MAX_COEFF_DESCR_NAME];
147 	__le16 ctl_type;
148 	__le16 flags;
149 	__le32 len;
150 	u8 data[];
151 } __packed;
152 
153 struct wmfw_coeff_hdr {
154 	u8 magic[4];
155 	__le32 len;
156 	union {
157 		__be32 rev;
158 		__le32 ver;
159 	};
160 	union {
161 		__be32 core;
162 		__le32 core_ver;
163 	};
164 	u8 data[];
165 } __packed;
166 
167 struct wmfw_coeff_item {
168 	__le16 offset;
169 	__le16 type;
170 	__le32 id;
171 	__le32 ver;
172 	__le32 sr;
173 	__le32 len;
174 	u8 data[];
175 } __packed;
176 
177 #define WMFW_ADSP1 1
178 #define WMFW_ADSP2 2
179 #define WMFW_HALO 4
180 
181 #define WMFW_ABSOLUTE         0xf0
182 #define WMFW_ALGORITHM_DATA   0xf2
183 #define WMFW_METADATA         0xfc
184 #define WMFW_NAME_TEXT        0xfe
185 #define WMFW_INFO_TEXT        0xff
186 
187 #define WMFW_ADSP1_PM 2
188 #define WMFW_ADSP1_DM 3
189 #define WMFW_ADSP1_ZM 4
190 
191 #define WMFW_ADSP2_PM 2
192 #define WMFW_ADSP2_ZM 4
193 #define WMFW_ADSP2_XM 5
194 #define WMFW_ADSP2_YM 6
195 
196 #define WMFW_HALO_PM_PACKED 0x10
197 #define WMFW_HALO_XM_PACKED 0x11
198 #define WMFW_HALO_YM_PACKED 0x12
199 
200 #endif
201