xref: /linux/sound/pci/asihpi/hpi_internal.h (revision c532de5a67a70f8533d495f8f2aaa9a0491c3ad0)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /******************************************************************************
3 
4     AudioScience HPI driver
5     Copyright (C) 1997-2012  AudioScience Inc. <support@audioscience.com>
6 
7 
8 HPI internal definitions
9 
10 (C) Copyright AudioScience Inc. 1996-2009
11 ******************************************************************************/
12 
13 #ifndef _HPI_INTERNAL_H_
14 #define _HPI_INTERNAL_H_
15 
16 #include "hpi.h"
17 
18 /** maximum number of memory regions mapped to an adapter */
19 #define HPI_MAX_ADAPTER_MEM_SPACES (2)
20 
21 /* Each OS needs its own hpios.h */
22 #include "hpios.h"
23 
24 /* physical memory allocation */
25 
26 /** Allocate and map an area of locked memory for bus master DMA operations.
27 
28 On success, *pLockedMemeHandle is a valid handle, and 0 is returned
29 On error *pLockedMemHandle marked invalid, non-zero returned.
30 
31 If this function succeeds, then HpiOs_LockedMem_GetVirtAddr() and
32 HpiOs_LockedMem_GetPyhsAddr() will always succed on the returned handle.
33 */
34 u16 hpios_locked_mem_alloc(struct consistent_dma_area *p_locked_mem_handle,
35 							   /**< memory handle */
36 	u32 size, /**< Size in bytes to allocate */
37 	struct pci_dev *p_os_reference
38 	/**< OS specific data required for memory allocation */
39 	);
40 
41 /** Free mapping and memory represented by LockedMemHandle
42 
43 Frees any resources, then invalidates the handle.
44 Returns 0 on success, 1 if handle is invalid.
45 
46 */
47 u16 hpios_locked_mem_free(struct consistent_dma_area *locked_mem_handle);
48 
49 /** Get the physical PCI address of memory represented by LockedMemHandle.
50 
51 If handle is invalid *pPhysicalAddr is set to zero and return 1
52 */
53 u16 hpios_locked_mem_get_phys_addr(struct consistent_dma_area
54 	*locked_mem_handle, u32 *p_physical_addr);
55 
56 /** Get the CPU address of memory represented by LockedMemHandle.
57 
58 If handle is NULL *ppvVirtualAddr is set to NULL and return 1
59 */
60 u16 hpios_locked_mem_get_virt_addr(struct consistent_dma_area
61 	*locked_mem_handle, void **ppv_virtual_addr);
62 
63 /** Check that handle is valid
64 i.e it represents a valid memory area
65 */
66 u16 hpios_locked_mem_valid(struct consistent_dma_area *locked_mem_handle);
67 
68 /* timing/delay */
69 void hpios_delay_micro_seconds(u32 num_micro_sec);
70 
71 struct hpi_message;
72 struct hpi_response;
73 
74 typedef void hpi_handler_func(struct hpi_message *, struct hpi_response *);
75 
76 /* If the assert fails, compiler complains
77    something like size of array `msg' is negative.
78    Unlike linux BUILD_BUG_ON, this works outside function scope.
79 */
80 #define compile_time_assert(cond, msg) \
81     typedef char ASSERT_##msg[(cond) ? 1 : -1]
82 
83 /******************************************* bus types */
84 enum HPI_BUSES {
85 	HPI_BUS_ISAPNP = 1,
86 	HPI_BUS_PCI = 2,
87 	HPI_BUS_USB = 3,
88 	HPI_BUS_NET = 4
89 };
90 
91 enum HPI_SUBSYS_OPTIONS {
92 	/* 0, 256 are invalid, 1..255 reserved for global options */
93 	HPI_SUBSYS_OPT_NET_ENABLE = 257,
94 	HPI_SUBSYS_OPT_NET_BROADCAST = 258,
95 	HPI_SUBSYS_OPT_NET_UNICAST = 259,
96 	HPI_SUBSYS_OPT_NET_ADDR = 260,
97 	HPI_SUBSYS_OPT_NET_MASK = 261,
98 	HPI_SUBSYS_OPT_NET_ADAPTER_ADDRESS_ADD = 262
99 };
100 
101 /** Volume flags
102 */
103 enum HPI_VOLUME_FLAGS {
104 	/** Set if the volume control is muted */
105 	HPI_VOLUME_FLAG_MUTED = (1 << 0),
106 	/** Set if the volume control has a mute function */
107 	HPI_VOLUME_FLAG_HAS_MUTE = (1 << 1),
108 	/** Set if volume control can do autofading */
109 	HPI_VOLUME_FLAG_HAS_AUTOFADE = (1 << 2)
110 		/* Note Flags >= (1<<8) are for DSP internal use only */
111 };
112 
113 /******************************************* CONTROL ATTRIBUTES ****/
114 /* (in order of control type ID */
115 
116 /* This allows for 255 control types, 256 unique attributes each */
117 #define HPI_CTL_ATTR(ctl, ai) ((HPI_CONTROL_##ctl << 8) + ai)
118 
119 /* Get the sub-index of the attribute for a control type */
120 #define HPI_CTL_ATTR_INDEX(i) (i & 0xff)
121 
122 /* Extract the control from the control attribute */
123 #define HPI_CTL_ATTR_CONTROL(i) (i >> 8)
124 
125 /** Enable event generation for a control.
126 0=disable, 1=enable
127 \note generic to all controls that can generate events
128 */
129 
130 /** Unique identifiers for every control attribute
131 */
132 enum HPI_CONTROL_ATTRIBUTES {
133 	HPI_GENERIC_ENABLE = HPI_CTL_ATTR(GENERIC, 1),
134 	HPI_GENERIC_EVENT_ENABLE = HPI_CTL_ATTR(GENERIC, 2),
135 
136 	HPI_VOLUME_GAIN = HPI_CTL_ATTR(VOLUME, 1),
137 	HPI_VOLUME_AUTOFADE = HPI_CTL_ATTR(VOLUME, 2),
138 	HPI_VOLUME_MUTE = HPI_CTL_ATTR(VOLUME, 3),
139 	HPI_VOLUME_GAIN_AND_FLAGS = HPI_CTL_ATTR(VOLUME, 4),
140 	HPI_VOLUME_NUM_CHANNELS = HPI_CTL_ATTR(VOLUME, 6),
141 	HPI_VOLUME_RANGE = HPI_CTL_ATTR(VOLUME, 10),
142 
143 	HPI_METER_RMS = HPI_CTL_ATTR(METER, 1),
144 	HPI_METER_PEAK = HPI_CTL_ATTR(METER, 2),
145 	HPI_METER_RMS_BALLISTICS = HPI_CTL_ATTR(METER, 3),
146 	HPI_METER_PEAK_BALLISTICS = HPI_CTL_ATTR(METER, 4),
147 	HPI_METER_NUM_CHANNELS = HPI_CTL_ATTR(METER, 5),
148 
149 	HPI_MULTIPLEXER_SOURCE = HPI_CTL_ATTR(MULTIPLEXER, 1),
150 	HPI_MULTIPLEXER_QUERYSOURCE = HPI_CTL_ATTR(MULTIPLEXER, 2),
151 
152 	HPI_AESEBUTX_FORMAT = HPI_CTL_ATTR(AESEBUTX, 1),
153 	HPI_AESEBUTX_SAMPLERATE = HPI_CTL_ATTR(AESEBUTX, 3),
154 	HPI_AESEBUTX_CHANNELSTATUS = HPI_CTL_ATTR(AESEBUTX, 4),
155 	HPI_AESEBUTX_USERDATA = HPI_CTL_ATTR(AESEBUTX, 5),
156 
157 	HPI_AESEBURX_FORMAT = HPI_CTL_ATTR(AESEBURX, 1),
158 	HPI_AESEBURX_ERRORSTATUS = HPI_CTL_ATTR(AESEBURX, 2),
159 	HPI_AESEBURX_SAMPLERATE = HPI_CTL_ATTR(AESEBURX, 3),
160 	HPI_AESEBURX_CHANNELSTATUS = HPI_CTL_ATTR(AESEBURX, 4),
161 	HPI_AESEBURX_USERDATA = HPI_CTL_ATTR(AESEBURX, 5),
162 
163 	HPI_LEVEL_GAIN = HPI_CTL_ATTR(LEVEL, 1),
164 	HPI_LEVEL_RANGE = HPI_CTL_ATTR(LEVEL, 10),
165 
166 	HPI_TUNER_BAND = HPI_CTL_ATTR(TUNER, 1),
167 	HPI_TUNER_FREQ = HPI_CTL_ATTR(TUNER, 2),
168 	HPI_TUNER_LEVEL_AVG = HPI_CTL_ATTR(TUNER, 3),
169 	HPI_TUNER_LEVEL_RAW = HPI_CTL_ATTR(TUNER, 4),
170 	HPI_TUNER_SNR = HPI_CTL_ATTR(TUNER, 5),
171 	HPI_TUNER_GAIN = HPI_CTL_ATTR(TUNER, 6),
172 	HPI_TUNER_STATUS = HPI_CTL_ATTR(TUNER, 7),
173 	HPI_TUNER_MODE = HPI_CTL_ATTR(TUNER, 8),
174 	HPI_TUNER_RDS = HPI_CTL_ATTR(TUNER, 9),
175 	HPI_TUNER_DEEMPHASIS = HPI_CTL_ATTR(TUNER, 10),
176 	HPI_TUNER_PROGRAM = HPI_CTL_ATTR(TUNER, 11),
177 	HPI_TUNER_HDRADIO_SIGNAL_QUALITY = HPI_CTL_ATTR(TUNER, 12),
178 	HPI_TUNER_HDRADIO_SDK_VERSION = HPI_CTL_ATTR(TUNER, 13),
179 	HPI_TUNER_HDRADIO_DSP_VERSION = HPI_CTL_ATTR(TUNER, 14),
180 	HPI_TUNER_HDRADIO_BLEND = HPI_CTL_ATTR(TUNER, 15),
181 
182 	HPI_VOX_THRESHOLD = HPI_CTL_ATTR(VOX, 1),
183 
184 	HPI_CHANNEL_MODE_MODE = HPI_CTL_ATTR(CHANNEL_MODE, 1),
185 
186 	HPI_BITSTREAM_DATA_POLARITY = HPI_CTL_ATTR(BITSTREAM, 1),
187 	HPI_BITSTREAM_CLOCK_EDGE = HPI_CTL_ATTR(BITSTREAM, 2),
188 	HPI_BITSTREAM_CLOCK_SOURCE = HPI_CTL_ATTR(BITSTREAM, 3),
189 	HPI_BITSTREAM_ACTIVITY = HPI_CTL_ATTR(BITSTREAM, 4),
190 
191 	HPI_SAMPLECLOCK_SOURCE = HPI_CTL_ATTR(SAMPLECLOCK, 1),
192 	HPI_SAMPLECLOCK_SAMPLERATE = HPI_CTL_ATTR(SAMPLECLOCK, 2),
193 	HPI_SAMPLECLOCK_SOURCE_INDEX = HPI_CTL_ATTR(SAMPLECLOCK, 3),
194 	HPI_SAMPLECLOCK_LOCAL_SAMPLERATE = HPI_CTL_ATTR(SAMPLECLOCK, 4),
195 	HPI_SAMPLECLOCK_AUTO = HPI_CTL_ATTR(SAMPLECLOCK, 5),
196 	HPI_SAMPLECLOCK_LOCAL_LOCK = HPI_CTL_ATTR(SAMPLECLOCK, 6),
197 
198 	HPI_MICROPHONE_PHANTOM_POWER = HPI_CTL_ATTR(MICROPHONE, 1),
199 
200 	HPI_EQUALIZER_NUM_FILTERS = HPI_CTL_ATTR(EQUALIZER, 1),
201 	HPI_EQUALIZER_FILTER = HPI_CTL_ATTR(EQUALIZER, 2),
202 	HPI_EQUALIZER_COEFFICIENTS = HPI_CTL_ATTR(EQUALIZER, 3),
203 
204 	HPI_COMPANDER_PARAMS = HPI_CTL_ATTR(COMPANDER, 1),
205 	HPI_COMPANDER_MAKEUPGAIN = HPI_CTL_ATTR(COMPANDER, 2),
206 	HPI_COMPANDER_THRESHOLD = HPI_CTL_ATTR(COMPANDER, 3),
207 	HPI_COMPANDER_RATIO = HPI_CTL_ATTR(COMPANDER, 4),
208 	HPI_COMPANDER_ATTACK = HPI_CTL_ATTR(COMPANDER, 5),
209 	HPI_COMPANDER_DECAY = HPI_CTL_ATTR(COMPANDER, 6),
210 
211 	HPI_COBRANET_SET = HPI_CTL_ATTR(COBRANET, 1),
212 	HPI_COBRANET_GET = HPI_CTL_ATTR(COBRANET, 2),
213 	HPI_COBRANET_GET_STATUS = HPI_CTL_ATTR(COBRANET, 5),
214 	HPI_COBRANET_SEND_PACKET = HPI_CTL_ATTR(COBRANET, 6),
215 	HPI_COBRANET_GET_PACKET = HPI_CTL_ATTR(COBRANET, 7),
216 
217 	HPI_TONEDETECTOR_THRESHOLD = HPI_CTL_ATTR(TONEDETECTOR, 1),
218 	HPI_TONEDETECTOR_STATE = HPI_CTL_ATTR(TONEDETECTOR, 2),
219 	HPI_TONEDETECTOR_FREQUENCY = HPI_CTL_ATTR(TONEDETECTOR, 3),
220 
221 	HPI_SILENCEDETECTOR_THRESHOLD = HPI_CTL_ATTR(SILENCEDETECTOR, 1),
222 	HPI_SILENCEDETECTOR_STATE = HPI_CTL_ATTR(SILENCEDETECTOR, 2),
223 	HPI_SILENCEDETECTOR_DELAY = HPI_CTL_ATTR(SILENCEDETECTOR, 3),
224 
225 	HPI_PAD_CHANNEL_NAME = HPI_CTL_ATTR(PAD, 1),
226 	HPI_PAD_ARTIST = HPI_CTL_ATTR(PAD, 2),
227 	HPI_PAD_TITLE = HPI_CTL_ATTR(PAD, 3),
228 	HPI_PAD_COMMENT = HPI_CTL_ATTR(PAD, 4),
229 	HPI_PAD_PROGRAM_TYPE = HPI_CTL_ATTR(PAD, 5),
230 	HPI_PAD_PROGRAM_ID = HPI_CTL_ATTR(PAD, 6),
231 	HPI_PAD_TA_SUPPORT = HPI_CTL_ATTR(PAD, 7),
232 	HPI_PAD_TA_ACTIVE = HPI_CTL_ATTR(PAD, 8),
233 
234 	HPI_UNIVERSAL_ENTITY = HPI_CTL_ATTR(UNIVERSAL, 1)
235 };
236 
237 #define HPI_POLARITY_POSITIVE           0
238 #define HPI_POLARITY_NEGATIVE           1
239 
240 /*------------------------------------------------------------
241  Cobranet Chip Bridge - copied from HMI.H
242 ------------------------------------------------------------*/
243 #define  HPI_COBRANET_HMI_cobra_bridge           0x20000
244 #define  HPI_COBRANET_HMI_cobra_bridge_tx_pkt_buf \
245 	(HPI_COBRANET_HMI_cobra_bridge + 0x1000)
246 #define  HPI_COBRANET_HMI_cobra_bridge_rx_pkt_buf \
247 	(HPI_COBRANET_HMI_cobra_bridge + 0x2000)
248 #define  HPI_COBRANET_HMI_cobra_if_table1         0x110000
249 #define  HPI_COBRANET_HMI_cobra_if_phy_address \
250 	(HPI_COBRANET_HMI_cobra_if_table1 + 0xd)
251 #define  HPI_COBRANET_HMI_cobra_protocolIP       0x72000
252 #define  HPI_COBRANET_HMI_cobra_ip_mon_currentIP \
253 	(HPI_COBRANET_HMI_cobra_protocolIP + 0x0)
254 #define  HPI_COBRANET_HMI_cobra_ip_mon_staticIP \
255 	(HPI_COBRANET_HMI_cobra_protocolIP + 0x2)
256 #define  HPI_COBRANET_HMI_cobra_sys              0x100000
257 #define  HPI_COBRANET_HMI_cobra_sys_desc \
258 		(HPI_COBRANET_HMI_cobra_sys + 0x0)
259 #define  HPI_COBRANET_HMI_cobra_sys_objectID \
260 	(HPI_COBRANET_HMI_cobra_sys + 0x100)
261 #define  HPI_COBRANET_HMI_cobra_sys_contact \
262 	(HPI_COBRANET_HMI_cobra_sys + 0x200)
263 #define  HPI_COBRANET_HMI_cobra_sys_name \
264 		(HPI_COBRANET_HMI_cobra_sys + 0x300)
265 #define  HPI_COBRANET_HMI_cobra_sys_location \
266 	(HPI_COBRANET_HMI_cobra_sys + 0x400)
267 
268 /*------------------------------------------------------------
269  Cobranet Chip Status bits
270 ------------------------------------------------------------*/
271 #define HPI_COBRANET_HMI_STATUS_RXPACKET 2
272 #define HPI_COBRANET_HMI_STATUS_TXPACKET 3
273 
274 /*------------------------------------------------------------
275  Ethernet header size
276 ------------------------------------------------------------*/
277 #define HPI_ETHERNET_HEADER_SIZE (16)
278 
279 /* These defines are used to fill in protocol information for an Ethernet packet
280     sent using HMI on CS18102 */
281 /** ID supplied by Cirrus for ASI packets. */
282 #define HPI_ETHERNET_PACKET_ID                  0x85
283 /** Simple packet - no special routing required */
284 #define HPI_ETHERNET_PACKET_V1                  0x01
285 /** This packet must make its way to the host across the HPI interface */
286 #define HPI_ETHERNET_PACKET_HOSTED_VIA_HMI      0x20
287 /** This packet must make its way to the host across the HPI interface */
288 #define HPI_ETHERNET_PACKET_HOSTED_VIA_HMI_V1   0x21
289 /** This packet must make its way to the host across the HPI interface */
290 #define HPI_ETHERNET_PACKET_HOSTED_VIA_HPI      0x40
291 /** This packet must make its way to the host across the HPI interface */
292 #define HPI_ETHERNET_PACKET_HOSTED_VIA_HPI_V1   0x41
293 
294 #define HPI_ETHERNET_UDP_PORT 44600 /**< HPI UDP service */
295 
296 /** Default network timeout in milli-seconds. */
297 #define HPI_ETHERNET_TIMEOUT_MS 500
298 
299 /** Locked memory buffer alloc/free phases */
300 enum HPI_BUFFER_CMDS {
301 	/** use one message to allocate or free physical memory */
302 	HPI_BUFFER_CMD_EXTERNAL = 0,
303 	/** alloc physical memory */
304 	HPI_BUFFER_CMD_INTERNAL_ALLOC = 1,
305 	/** send physical memory address to adapter */
306 	HPI_BUFFER_CMD_INTERNAL_GRANTADAPTER = 2,
307 	/** notify adapter to stop using physical buffer */
308 	HPI_BUFFER_CMD_INTERNAL_REVOKEADAPTER = 3,
309 	/** free physical buffer */
310 	HPI_BUFFER_CMD_INTERNAL_FREE = 4
311 };
312 
313 /*****************************************************************************/
314 /*****************************************************************************/
315 /********               HPI LOW LEVEL MESSAGES                  *******/
316 /*****************************************************************************/
317 /*****************************************************************************/
318 /** Pnp ids */
319 /** "ASI"  - actual is "ASX" - need to change */
320 #define HPI_ID_ISAPNP_AUDIOSCIENCE      0x0669
321 /** PCI vendor ID that AudioScience uses */
322 #define HPI_PCI_VENDOR_ID_AUDIOSCIENCE  0x175C
323 /** PCI vendor ID that the DSP56301 has */
324 #define HPI_PCI_VENDOR_ID_MOTOROLA      0x1057
325 /** PCI vendor ID that TI uses */
326 #define HPI_PCI_VENDOR_ID_TI            0x104C
327 
328 #define HPI_PCI_DEV_ID_PCI2040          0xAC60
329 /** TI's C6205 PCI interface has this ID */
330 #define HPI_PCI_DEV_ID_DSP6205          0xA106
331 
332 #define HPI_USB_VENDOR_ID_AUDIOSCIENCE  0x1257
333 #define HPI_USB_W2K_TAG                 0x57495341	/* "ASIW"       */
334 #define HPI_USB_LINUX_TAG               0x4C495341	/* "ASIL"       */
335 
336 /** Invalid Adapter index
337 Used in HPI messages that are not addressed to a specific adapter
338 Used in DLL to indicate device not present
339 */
340 #define HPI_ADAPTER_INDEX_INVALID 0xFFFF
341 
342 /** First 2 hex digits define the adapter family */
343 #define HPI_ADAPTER_FAMILY_MASK         0xff00
344 #define HPI_MODULE_FAMILY_MASK          0xfff0
345 
346 #define HPI_ADAPTER_FAMILY_ASI(f)   (f & HPI_ADAPTER_FAMILY_MASK)
347 #define HPI_MODULE_FAMILY_ASI(f)   (f & HPI_MODULE_FAMILY_MASK)
348 #define HPI_ADAPTER_ASI(f)   (f)
349 
350 enum HPI_MESSAGE_TYPES {
351 	HPI_TYPE_REQUEST = 1,
352 	HPI_TYPE_RESPONSE = 2,
353 	HPI_TYPE_DATA = 3,
354 	HPI_TYPE_SSX2BYPASS_MESSAGE = 4,
355 	HPI_TYPE_COMMAND = 5,
356 	HPI_TYPE_NOTIFICATION = 6
357 };
358 
359 enum HPI_OBJECT_TYPES {
360 	HPI_OBJ_SUBSYSTEM = 1,
361 	HPI_OBJ_ADAPTER = 2,
362 	HPI_OBJ_OSTREAM = 3,
363 	HPI_OBJ_ISTREAM = 4,
364 	HPI_OBJ_MIXER = 5,
365 	HPI_OBJ_NODE = 6,
366 	HPI_OBJ_CONTROL = 7,
367 	HPI_OBJ_NVMEMORY = 8,
368 	HPI_OBJ_GPIO = 9,
369 	HPI_OBJ_WATCHDOG = 10,
370 	HPI_OBJ_CLOCK = 11,
371 	HPI_OBJ_PROFILE = 12,
372 	/* HPI_ OBJ_ CONTROLEX  = 13, */
373 	HPI_OBJ_ASYNCEVENT = 14
374 #define HPI_OBJ_MAXINDEX 14
375 };
376 
377 #define HPI_OBJ_FUNCTION_SPACING 0x100
378 #define HPI_FUNC_ID(obj, i) (HPI_OBJ_##obj * HPI_OBJ_FUNCTION_SPACING + i)
379 
380 #define HPI_EXTRACT_INDEX(fn) (fn & 0xff)
381 
382 enum HPI_FUNCTION_IDS {
383 	HPI_SUBSYS_OPEN = HPI_FUNC_ID(SUBSYSTEM, 1),
384 	HPI_SUBSYS_GET_VERSION = HPI_FUNC_ID(SUBSYSTEM, 2),
385 	HPI_SUBSYS_GET_INFO = HPI_FUNC_ID(SUBSYSTEM, 3),
386 	HPI_SUBSYS_CREATE_ADAPTER = HPI_FUNC_ID(SUBSYSTEM, 5),
387 	HPI_SUBSYS_CLOSE = HPI_FUNC_ID(SUBSYSTEM, 6),
388 	HPI_SUBSYS_DRIVER_LOAD = HPI_FUNC_ID(SUBSYSTEM, 8),
389 	HPI_SUBSYS_DRIVER_UNLOAD = HPI_FUNC_ID(SUBSYSTEM, 9),
390 	HPI_SUBSYS_GET_NUM_ADAPTERS = HPI_FUNC_ID(SUBSYSTEM, 12),
391 	HPI_SUBSYS_GET_ADAPTER = HPI_FUNC_ID(SUBSYSTEM, 13),
392 	HPI_SUBSYS_SET_NETWORK_INTERFACE = HPI_FUNC_ID(SUBSYSTEM, 14),
393 	HPI_SUBSYS_OPTION_INFO = HPI_FUNC_ID(SUBSYSTEM, 15),
394 	HPI_SUBSYS_OPTION_GET = HPI_FUNC_ID(SUBSYSTEM, 16),
395 	HPI_SUBSYS_OPTION_SET = HPI_FUNC_ID(SUBSYSTEM, 17),
396 #define HPI_SUBSYS_FUNCTION_COUNT 17
397 
398 	HPI_ADAPTER_OPEN = HPI_FUNC_ID(ADAPTER, 1),
399 	HPI_ADAPTER_CLOSE = HPI_FUNC_ID(ADAPTER, 2),
400 	HPI_ADAPTER_GET_INFO = HPI_FUNC_ID(ADAPTER, 3),
401 	HPI_ADAPTER_GET_ASSERT = HPI_FUNC_ID(ADAPTER, 4),
402 	HPI_ADAPTER_TEST_ASSERT = HPI_FUNC_ID(ADAPTER, 5),
403 	HPI_ADAPTER_SET_MODE = HPI_FUNC_ID(ADAPTER, 6),
404 	HPI_ADAPTER_GET_MODE = HPI_FUNC_ID(ADAPTER, 7),
405 	HPI_ADAPTER_ENABLE_CAPABILITY = HPI_FUNC_ID(ADAPTER, 8),
406 	HPI_ADAPTER_SELFTEST = HPI_FUNC_ID(ADAPTER, 9),
407 	HPI_ADAPTER_FIND_OBJECT = HPI_FUNC_ID(ADAPTER, 10),
408 	HPI_ADAPTER_QUERY_FLASH = HPI_FUNC_ID(ADAPTER, 11),
409 	HPI_ADAPTER_START_FLASH = HPI_FUNC_ID(ADAPTER, 12),
410 	HPI_ADAPTER_PROGRAM_FLASH = HPI_FUNC_ID(ADAPTER, 13),
411 	HPI_ADAPTER_SET_PROPERTY = HPI_FUNC_ID(ADAPTER, 14),
412 	HPI_ADAPTER_GET_PROPERTY = HPI_FUNC_ID(ADAPTER, 15),
413 	HPI_ADAPTER_ENUM_PROPERTY = HPI_FUNC_ID(ADAPTER, 16),
414 	HPI_ADAPTER_MODULE_INFO = HPI_FUNC_ID(ADAPTER, 17),
415 	HPI_ADAPTER_DEBUG_READ = HPI_FUNC_ID(ADAPTER, 18),
416 	HPI_ADAPTER_IRQ_QUERY_AND_CLEAR = HPI_FUNC_ID(ADAPTER, 19),
417 	HPI_ADAPTER_IRQ_CALLBACK = HPI_FUNC_ID(ADAPTER, 20),
418 	HPI_ADAPTER_DELETE = HPI_FUNC_ID(ADAPTER, 21),
419 	HPI_ADAPTER_READ_FLASH = HPI_FUNC_ID(ADAPTER, 22),
420 	HPI_ADAPTER_END_FLASH = HPI_FUNC_ID(ADAPTER, 23),
421 	HPI_ADAPTER_FILESTORE_DELETE_ALL = HPI_FUNC_ID(ADAPTER, 24),
422 #define HPI_ADAPTER_FUNCTION_COUNT 24
423 
424 	HPI_OSTREAM_OPEN = HPI_FUNC_ID(OSTREAM, 1),
425 	HPI_OSTREAM_CLOSE = HPI_FUNC_ID(OSTREAM, 2),
426 	HPI_OSTREAM_WRITE = HPI_FUNC_ID(OSTREAM, 3),
427 	HPI_OSTREAM_START = HPI_FUNC_ID(OSTREAM, 4),
428 	HPI_OSTREAM_STOP = HPI_FUNC_ID(OSTREAM, 5),
429 	HPI_OSTREAM_RESET = HPI_FUNC_ID(OSTREAM, 6),
430 	HPI_OSTREAM_GET_INFO = HPI_FUNC_ID(OSTREAM, 7),
431 	HPI_OSTREAM_QUERY_FORMAT = HPI_FUNC_ID(OSTREAM, 8),
432 	HPI_OSTREAM_DATA = HPI_FUNC_ID(OSTREAM, 9),
433 	HPI_OSTREAM_SET_VELOCITY = HPI_FUNC_ID(OSTREAM, 10),
434 	HPI_OSTREAM_SET_PUNCHINOUT = HPI_FUNC_ID(OSTREAM, 11),
435 	HPI_OSTREAM_SINEGEN = HPI_FUNC_ID(OSTREAM, 12),
436 	HPI_OSTREAM_ANC_RESET = HPI_FUNC_ID(OSTREAM, 13),
437 	HPI_OSTREAM_ANC_GET_INFO = HPI_FUNC_ID(OSTREAM, 14),
438 	HPI_OSTREAM_ANC_READ = HPI_FUNC_ID(OSTREAM, 15),
439 	HPI_OSTREAM_SET_TIMESCALE = HPI_FUNC_ID(OSTREAM, 16),
440 	HPI_OSTREAM_SET_FORMAT = HPI_FUNC_ID(OSTREAM, 17),
441 	HPI_OSTREAM_HOSTBUFFER_ALLOC = HPI_FUNC_ID(OSTREAM, 18),
442 	HPI_OSTREAM_HOSTBUFFER_FREE = HPI_FUNC_ID(OSTREAM, 19),
443 	HPI_OSTREAM_GROUP_ADD = HPI_FUNC_ID(OSTREAM, 20),
444 	HPI_OSTREAM_GROUP_GETMAP = HPI_FUNC_ID(OSTREAM, 21),
445 	HPI_OSTREAM_GROUP_RESET = HPI_FUNC_ID(OSTREAM, 22),
446 	HPI_OSTREAM_HOSTBUFFER_GET_INFO = HPI_FUNC_ID(OSTREAM, 23),
447 	HPI_OSTREAM_WAIT_START = HPI_FUNC_ID(OSTREAM, 24),
448 	HPI_OSTREAM_WAIT = HPI_FUNC_ID(OSTREAM, 25),
449 #define HPI_OSTREAM_FUNCTION_COUNT 25
450 
451 	HPI_ISTREAM_OPEN = HPI_FUNC_ID(ISTREAM, 1),
452 	HPI_ISTREAM_CLOSE = HPI_FUNC_ID(ISTREAM, 2),
453 	HPI_ISTREAM_SET_FORMAT = HPI_FUNC_ID(ISTREAM, 3),
454 	HPI_ISTREAM_READ = HPI_FUNC_ID(ISTREAM, 4),
455 	HPI_ISTREAM_START = HPI_FUNC_ID(ISTREAM, 5),
456 	HPI_ISTREAM_STOP = HPI_FUNC_ID(ISTREAM, 6),
457 	HPI_ISTREAM_RESET = HPI_FUNC_ID(ISTREAM, 7),
458 	HPI_ISTREAM_GET_INFO = HPI_FUNC_ID(ISTREAM, 8),
459 	HPI_ISTREAM_QUERY_FORMAT = HPI_FUNC_ID(ISTREAM, 9),
460 	HPI_ISTREAM_ANC_RESET = HPI_FUNC_ID(ISTREAM, 10),
461 	HPI_ISTREAM_ANC_GET_INFO = HPI_FUNC_ID(ISTREAM, 11),
462 	HPI_ISTREAM_ANC_WRITE = HPI_FUNC_ID(ISTREAM, 12),
463 	HPI_ISTREAM_HOSTBUFFER_ALLOC = HPI_FUNC_ID(ISTREAM, 13),
464 	HPI_ISTREAM_HOSTBUFFER_FREE = HPI_FUNC_ID(ISTREAM, 14),
465 	HPI_ISTREAM_GROUP_ADD = HPI_FUNC_ID(ISTREAM, 15),
466 	HPI_ISTREAM_GROUP_GETMAP = HPI_FUNC_ID(ISTREAM, 16),
467 	HPI_ISTREAM_GROUP_RESET = HPI_FUNC_ID(ISTREAM, 17),
468 	HPI_ISTREAM_HOSTBUFFER_GET_INFO = HPI_FUNC_ID(ISTREAM, 18),
469 	HPI_ISTREAM_WAIT_START = HPI_FUNC_ID(ISTREAM, 19),
470 	HPI_ISTREAM_WAIT = HPI_FUNC_ID(ISTREAM, 20),
471 #define HPI_ISTREAM_FUNCTION_COUNT 20
472 
473 /* NOTE:
474    GET_NODE_INFO, SET_CONNECTION, GET_CONNECTIONS are not currently used */
475 	HPI_MIXER_OPEN = HPI_FUNC_ID(MIXER, 1),
476 	HPI_MIXER_CLOSE = HPI_FUNC_ID(MIXER, 2),
477 	HPI_MIXER_GET_INFO = HPI_FUNC_ID(MIXER, 3),
478 	HPI_MIXER_GET_NODE_INFO = HPI_FUNC_ID(MIXER, 4),
479 	HPI_MIXER_GET_CONTROL = HPI_FUNC_ID(MIXER, 5),
480 	HPI_MIXER_SET_CONNECTION = HPI_FUNC_ID(MIXER, 6),
481 	HPI_MIXER_GET_CONNECTIONS = HPI_FUNC_ID(MIXER, 7),
482 	HPI_MIXER_GET_CONTROL_BY_INDEX = HPI_FUNC_ID(MIXER, 8),
483 	HPI_MIXER_GET_CONTROL_ARRAY_BY_INDEX = HPI_FUNC_ID(MIXER, 9),
484 	HPI_MIXER_GET_CONTROL_MULTIPLE_VALUES = HPI_FUNC_ID(MIXER, 10),
485 	HPI_MIXER_STORE = HPI_FUNC_ID(MIXER, 11),
486 	HPI_MIXER_GET_CACHE_INFO = HPI_FUNC_ID(MIXER, 12),
487 	HPI_MIXER_GET_BLOCK_HANDLE = HPI_FUNC_ID(MIXER, 13),
488 	HPI_MIXER_GET_PARAMETER_HANDLE = HPI_FUNC_ID(MIXER, 14),
489 #define HPI_MIXER_FUNCTION_COUNT 14
490 
491 	HPI_CONTROL_GET_INFO = HPI_FUNC_ID(CONTROL, 1),
492 	HPI_CONTROL_GET_STATE = HPI_FUNC_ID(CONTROL, 2),
493 	HPI_CONTROL_SET_STATE = HPI_FUNC_ID(CONTROL, 3),
494 #define HPI_CONTROL_FUNCTION_COUNT 3
495 
496 	HPI_NVMEMORY_OPEN = HPI_FUNC_ID(NVMEMORY, 1),
497 	HPI_NVMEMORY_READ_BYTE = HPI_FUNC_ID(NVMEMORY, 2),
498 	HPI_NVMEMORY_WRITE_BYTE = HPI_FUNC_ID(NVMEMORY, 3),
499 #define HPI_NVMEMORY_FUNCTION_COUNT 3
500 
501 	HPI_GPIO_OPEN = HPI_FUNC_ID(GPIO, 1),
502 	HPI_GPIO_READ_BIT = HPI_FUNC_ID(GPIO, 2),
503 	HPI_GPIO_WRITE_BIT = HPI_FUNC_ID(GPIO, 3),
504 	HPI_GPIO_READ_ALL = HPI_FUNC_ID(GPIO, 4),
505 	HPI_GPIO_WRITE_STATUS = HPI_FUNC_ID(GPIO, 5),
506 #define HPI_GPIO_FUNCTION_COUNT 5
507 
508 	HPI_ASYNCEVENT_OPEN = HPI_FUNC_ID(ASYNCEVENT, 1),
509 	HPI_ASYNCEVENT_CLOSE = HPI_FUNC_ID(ASYNCEVENT, 2),
510 	HPI_ASYNCEVENT_WAIT = HPI_FUNC_ID(ASYNCEVENT, 3),
511 	HPI_ASYNCEVENT_GETCOUNT = HPI_FUNC_ID(ASYNCEVENT, 4),
512 	HPI_ASYNCEVENT_GET = HPI_FUNC_ID(ASYNCEVENT, 5),
513 	HPI_ASYNCEVENT_SENDEVENTS = HPI_FUNC_ID(ASYNCEVENT, 6),
514 #define HPI_ASYNCEVENT_FUNCTION_COUNT 6
515 
516 	HPI_WATCHDOG_OPEN = HPI_FUNC_ID(WATCHDOG, 1),
517 	HPI_WATCHDOG_SET_TIME = HPI_FUNC_ID(WATCHDOG, 2),
518 	HPI_WATCHDOG_PING = HPI_FUNC_ID(WATCHDOG, 3),
519 
520 	HPI_CLOCK_OPEN = HPI_FUNC_ID(CLOCK, 1),
521 	HPI_CLOCK_SET_TIME = HPI_FUNC_ID(CLOCK, 2),
522 	HPI_CLOCK_GET_TIME = HPI_FUNC_ID(CLOCK, 3),
523 
524 	HPI_PROFILE_OPEN_ALL = HPI_FUNC_ID(PROFILE, 1),
525 	HPI_PROFILE_START_ALL = HPI_FUNC_ID(PROFILE, 2),
526 	HPI_PROFILE_STOP_ALL = HPI_FUNC_ID(PROFILE, 3),
527 	HPI_PROFILE_GET = HPI_FUNC_ID(PROFILE, 4),
528 	HPI_PROFILE_GET_IDLECOUNT = HPI_FUNC_ID(PROFILE, 5),
529 	HPI_PROFILE_GET_NAME = HPI_FUNC_ID(PROFILE, 6),
530 	HPI_PROFILE_GET_UTILIZATION = HPI_FUNC_ID(PROFILE, 7)
531 #define HPI_PROFILE_FUNCTION_COUNT 7
532 };
533 
534 /* ////////////////////////////////////////////////////////////////////// */
535 /* STRUCTURES */
536 #ifndef DISABLE_PRAGMA_PACK1
537 #pragma pack(push, 1)
538 #endif
539 
540 /** PCI bus resource */
541 struct hpi_pci {
542 	u32 __iomem *ap_mem_base[HPI_MAX_ADAPTER_MEM_SPACES];
543 	struct pci_dev *pci_dev;
544 };
545 
546 /** Adapter specification resource */
547 struct hpi_adapter_specification {
548 	u32 type;
549 	u8 modules[4];
550 };
551 
552 struct hpi_resource {
553 	union {
554 		const struct hpi_pci *pci;
555 		const char *net_if;
556 		struct hpi_adapter_specification adapter_spec;
557 		const void *sw_if;
558 	} r;
559 	u16 bus_type;		/* HPI_BUS_PNPISA, _PCI, _USB etc */
560 	u16 padding;
561 };
562 
563 /** Format info used inside struct hpi_message
564     Not the same as public API struct hpi_format */
565 struct hpi_msg_format {
566 	u32 sample_rate; /**< 11025, 32000, 44100 etc. */
567 	u32 bit_rate; /**< for MPEG */
568 	u32 attributes;	/**< stereo/joint_stereo/mono */
569 	u16 channels; /**< 1,2..., (or ancillary mode or idle bit */
570 	u16 format; /**< HPI_FORMAT_PCM16, _MPEG etc. see \ref HPI_FORMATS. */
571 };
572 
573 /**  Buffer+format structure.
574 	 Must be kept 7 * 32 bits to match public struct hpi_datastruct */
575 struct hpi_msg_data {
576 	struct hpi_msg_format format;
577 	u8 *pb_data;
578 #ifndef CONFIG_64BIT
579 	u32 padding;
580 #endif
581 	u32 data_size;
582 };
583 
584 /** struct hpi_datastructure used up to 3.04 driver */
585 struct hpi_data_legacy32 {
586 	struct hpi_format format;
587 	u32 pb_data;
588 	u32 data_size;
589 };
590 
591 #ifdef CONFIG_64BIT
592 /* Compatibility version of struct hpi_data*/
593 struct hpi_data_compat32 {
594 	struct hpi_msg_format format;
595 	u32 pb_data;
596 	u32 padding;
597 	u32 data_size;
598 };
599 #endif
600 
601 struct hpi_buffer {
602   /** placeholder for backward compatibility (see dwBufferSize) */
603 	struct hpi_msg_format reserved;
604 	u32 command; /**< HPI_BUFFER_CMD_xxx*/
605 	u32 pci_address; /**< PCI physical address of buffer for DSP DMA */
606 	u32 buffer_size; /**< must line up with data_size of HPI_DATA*/
607 };
608 
609 /*/////////////////////////////////////////////////////////////////////////// */
610 /* This is used for background buffer bus mastering stream buffers.           */
611 struct hpi_hostbuffer_status {
612 	u32 samples_processed;
613 	u32 auxiliary_data_available;
614 	u32 stream_state;
615 	/* DSP index in to the host bus master buffer. */
616 	u32 dsp_index;
617 	/* Host index in to the host bus master buffer. */
618 	u32 host_index;
619 	u32 size_in_bytes;
620 };
621 
622 struct hpi_streamid {
623 	u16 object_type;
624 		    /**< Type of object, HPI_OBJ_OSTREAM or HPI_OBJ_ISTREAM. */
625 	u16 stream_index; /**< outstream or instream index. */
626 };
627 
628 struct hpi_punchinout {
629 	u32 punch_in_sample;
630 	u32 punch_out_sample;
631 };
632 
633 struct hpi_subsys_msg {
634 	struct hpi_resource resource;
635 };
636 
637 struct hpi_subsys_res {
638 	u32 version;
639 	u32 data;		/* extended version */
640 	u16 num_adapters;
641 	u16 adapter_index;
642 	u16 adapter_type;
643 	u16 pad16;
644 };
645 
646 union hpi_adapterx_msg {
647 	struct {
648 		u32 dsp_address;
649 		u32 count_bytes;
650 	} debug_read;
651 	struct {
652 		u32 adapter_mode;
653 		u16 query_or_set;
654 	} mode;
655 	struct {
656 		u16 index;
657 	} module_info;
658 	struct {
659 		u16 index;
660 		u16 what;
661 		u16 property_index;
662 	} property_enum;
663 	struct {
664 		u16 property;
665 		u16 parameter1;
666 		u16 parameter2;
667 	} property_set;
668 	struct {
669 		u32 pad32;
670 		u16 key1;
671 		u16 key2;
672 	} restart;
673 	struct {
674 		u32 pad32;
675 		u16 value;
676 	} test_assert;
677 	struct {
678 		u32 message;
679 	} irq;
680 	u32 pad[3];
681 };
682 
683 struct hpi_adapter_res {
684 	u32 serial_number;
685 	u16 adapter_type;
686 	u16 adapter_index;
687 	u16 num_instreams;
688 	u16 num_outstreams;
689 	u16 num_mixers;
690 	u16 version;
691 	u8 sz_adapter_assert[HPI_STRING_LEN];
692 };
693 
694 union hpi_adapterx_res {
695 	struct hpi_adapter_res info;
696 	struct {
697 		u32 p1;
698 		u16 count;
699 		u16 dsp_index;
700 		u32 p2;
701 		u32 dsp_msg_addr;
702 		char sz_message[HPI_STRING_LEN];
703 	} assert;
704 	struct {
705 		u32 adapter_mode;
706 	} mode;
707 	struct {
708 		u16 parameter1;
709 		u16 parameter2;
710 	} property_get;
711 	struct {
712 		u32 yes;
713 	} irq_query;
714 };
715 
716 struct hpi_stream_msg {
717 	union {
718 		struct hpi_msg_data data;
719 		struct hpi_data_legacy32 data32;
720 		u16 velocity;
721 		struct hpi_punchinout pio;
722 		u32 time_scale;
723 		struct hpi_buffer buffer;
724 		struct hpi_streamid stream;
725 		u32 threshold_bytes;
726 	} u;
727 };
728 
729 struct hpi_stream_res {
730 	union {
731 		struct {
732 			/* size of hardware buffer */
733 			u32 buffer_size;
734 			/* OutStream - data to play,
735 			   InStream - data recorded */
736 			u32 data_available;
737 			/* OutStream - samples played,
738 			   InStream - samples recorded */
739 			u32 samples_transferred;
740 			/* Adapter - OutStream - data to play,
741 			   InStream - data recorded */
742 			u32 auxiliary_data_available;
743 			u16 state;	/* HPI_STATE_PLAYING, _STATE_STOPPED */
744 			u16 padding;
745 		} stream_info;
746 		struct {
747 			u32 buffer_size;
748 			u32 data_available;
749 			u32 samples_transfered;
750 			u16 state;
751 			u16 outstream_index;
752 			u16 instream_index;
753 			u16 padding;
754 			u32 auxiliary_data_available;
755 		} legacy_stream_info;
756 		struct {
757 			/* bitmap of grouped OutStreams */
758 			u32 outstream_group_map;
759 			/* bitmap of grouped InStreams */
760 			u32 instream_group_map;
761 		} group_info;
762 		struct {
763 			/* pointer to the buffer */
764 			u8 *p_buffer;
765 			/* pointer to the hostbuffer status */
766 			struct hpi_hostbuffer_status *p_status;
767 		} hostbuffer_info;
768 	} u;
769 };
770 
771 struct hpi_mixer_msg {
772 	u16 control_index;
773 	u16 control_type;	/* = HPI_CONTROL_METER _VOLUME etc */
774 	u16 padding1;		/* Maintain alignment of subsequent fields */
775 	u16 node_type1;		/* = HPI_SOURCENODE_LINEIN etc */
776 	u16 node_index1;	/* = 0..N */
777 	u16 node_type2;
778 	u16 node_index2;
779 	u16 padding2;		/* round to 4 bytes */
780 };
781 
782 struct hpi_mixer_res {
783 	u16 src_node_type;	/* = HPI_SOURCENODE_LINEIN etc */
784 	u16 src_node_index;	/* = 0..N */
785 	u16 dst_node_type;
786 	u16 dst_node_index;
787 	/* Also controlType for MixerGetControlByIndex */
788 	u16 control_index;
789 	/* may indicate which DSP the control is located on */
790 	u16 dsp_index;
791 };
792 
793 union hpi_mixerx_msg {
794 	struct {
795 		u16 starting_index;
796 		u16 flags;
797 		u32 length_in_bytes;	/* length in bytes of p_data */
798 		u32 p_data;	/* pointer to a data array */
799 	} gcabi;
800 	struct {
801 		u16 command;
802 		u16 index;
803 	} store;		/* for HPI_MIXER_STORE message */
804 };
805 
806 union hpi_mixerx_res {
807 	struct {
808 		u32 bytes_returned;	/* size of items returned */
809 		u32 p_data;	/* pointer to data array */
810 		u16 more_to_do;	/* indicates if there is more to do */
811 	} gcabi;
812 	struct {
813 		u32 total_controls;	/* count of controls in the mixer */
814 		u32 cache_controls;	/* count of controls in the cac */
815 		u32 cache_bytes;	/* size of cache */
816 	} cache_info;
817 };
818 
819 struct hpi_control_msg {
820 	u16 attribute;		/* control attribute or property */
821 	u16 saved_index;
822 	u32 param1;		/* generic parameter 1 */
823 	u32 param2;		/* generic parameter 2 */
824 	short an_log_value[HPI_MAX_CHANNELS];
825 };
826 
827 struct hpi_control_union_msg {
828 	u16 attribute;		/* control attribute or property */
829 	u16 saved_index;	/* only used in ctrl save/restore */
830 	union {
831 		struct {
832 			u32 param1;	/* generic parameter 1 */
833 			u32 param2;	/* generic parameter 2 */
834 			short an_log_value[HPI_MAX_CHANNELS];
835 		} old;
836 		union {
837 			u32 frequency;
838 			u32 gain;
839 			u32 band;
840 			u32 deemphasis;
841 			u32 program;
842 			struct {
843 				u32 mode;
844 				u32 value;
845 			} mode;
846 			u32 blend;
847 		} tuner;
848 	} u;
849 };
850 
851 struct hpi_control_res {
852 	/* Could make union. dwParam, anLogValue never used in same response */
853 	u32 param1;
854 	u32 param2;
855 	short an_log_value[HPI_MAX_CHANNELS];
856 };
857 
858 union hpi_control_union_res {
859 	struct {
860 		u32 param1;
861 		u32 param2;
862 		short an_log_value[HPI_MAX_CHANNELS];
863 	} old;
864 	union {
865 		u32 band;
866 		u32 frequency;
867 		u32 gain;
868 		u32 deemphasis;
869 		struct {
870 			u32 data[2];
871 			u32 bLER;
872 		} rds;
873 		short s_level;
874 		struct {
875 			u16 value;
876 			u16 mask;
877 		} status;
878 	} tuner;
879 	struct {
880 		char sz_data[8];
881 		u32 remaining_chars;
882 	} chars8;
883 	char c_data12[12];
884 	union {
885 		struct {
886 			u32 status;
887 			u32 readable_size;
888 			u32 writeable_size;
889 		} status;
890 	} cobranet;
891 };
892 
893 struct hpi_nvmemory_msg {
894 	u16 address;
895 	u16 data;
896 };
897 
898 struct hpi_nvmemory_res {
899 	u16 size_in_bytes;
900 	u16 data;
901 };
902 
903 struct hpi_gpio_msg {
904 	u16 bit_index;
905 	u16 bit_data;
906 };
907 
908 struct hpi_gpio_res {
909 	u16 number_input_bits;
910 	u16 number_output_bits;
911 	u16 bit_data[4];
912 };
913 
914 struct hpi_async_msg {
915 	u32 events;
916 	u16 maximum_events;
917 	u16 padding;
918 };
919 
920 struct hpi_async_res {
921 	union {
922 		struct {
923 			u16 count;
924 		} count;
925 		struct {
926 			u32 events;
927 			u16 number_returned;
928 			u16 padding;
929 		} get;
930 		struct hpi_async_event event;
931 	} u;
932 };
933 
934 struct hpi_watchdog_msg {
935 	u32 time_ms;
936 };
937 
938 struct hpi_watchdog_res {
939 	u32 time_ms;
940 };
941 
942 struct hpi_clock_msg {
943 	u16 hours;
944 	u16 minutes;
945 	u16 seconds;
946 	u16 milli_seconds;
947 };
948 
949 struct hpi_clock_res {
950 	u16 size_in_bytes;
951 	u16 hours;
952 	u16 minutes;
953 	u16 seconds;
954 	u16 milli_seconds;
955 	u16 padding;
956 };
957 
958 struct hpi_profile_msg {
959 	u16 bin_index;
960 	u16 padding;
961 };
962 
963 struct hpi_profile_res_open {
964 	u16 max_profiles;
965 };
966 
967 struct hpi_profile_res_time {
968 	u32 total_tick_count;
969 	u32 call_count;
970 	u32 max_tick_count;
971 	u32 ticks_per_millisecond;
972 	u16 profile_interval;
973 };
974 
975 struct hpi_profile_res_name {
976 	u8 sz_name[32];
977 };
978 
979 struct hpi_profile_res {
980 	union {
981 		struct hpi_profile_res_open o;
982 		struct hpi_profile_res_time t;
983 		struct hpi_profile_res_name n;
984 	} u;
985 };
986 
987 struct hpi_message_header {
988 	u16 size;		/* total size in bytes */
989 	u8 type;		/* HPI_TYPE_MESSAGE  */
990 	u8 version;		/* message version */
991 	u16 object;		/* HPI_OBJ_* */
992 	u16 function;		/* HPI_SUBSYS_xxx, HPI_ADAPTER_xxx */
993 	u16 adapter_index;	/* the adapter index */
994 	u16 obj_index;		/* */
995 };
996 
997 struct hpi_message {
998 	/* following fields must match HPI_MESSAGE_HEADER */
999 	u16 size;		/* total size in bytes */
1000 	u8 type;		/* HPI_TYPE_MESSAGE  */
1001 	u8 version;		/* message version */
1002 	u16 object;		/* HPI_OBJ_* */
1003 	u16 function;		/* HPI_SUBSYS_xxx, HPI_ADAPTER_xxx */
1004 	u16 adapter_index;	/* the adapter index */
1005 	u16 obj_index;		/*  */
1006 	union {
1007 		struct hpi_subsys_msg s;
1008 		union hpi_adapterx_msg ax;
1009 		struct hpi_stream_msg d;
1010 		struct hpi_mixer_msg m;
1011 		union hpi_mixerx_msg mx;	/* extended mixer; */
1012 		struct hpi_control_msg c;	/* mixer control; */
1013 		/* identical to struct hpi_control_msg,
1014 		   but field naming is improved */
1015 		struct hpi_control_union_msg cu;
1016 		struct hpi_nvmemory_msg n;
1017 		struct hpi_gpio_msg l;	/* digital i/o */
1018 		struct hpi_watchdog_msg w;
1019 		struct hpi_clock_msg t;	/* dsp time */
1020 		struct hpi_profile_msg p;
1021 		struct hpi_async_msg as;
1022 		char fixed_size[32];
1023 	} u;
1024 };
1025 
1026 #define HPI_MESSAGE_SIZE_BY_OBJECT { \
1027 	sizeof(struct hpi_message_header) ,   /* Default, no object type 0 */ \
1028 	sizeof(struct hpi_message_header) + sizeof(struct hpi_subsys_msg),\
1029 	sizeof(struct hpi_message_header) + sizeof(union hpi_adapterx_msg),\
1030 	sizeof(struct hpi_message_header) + sizeof(struct hpi_stream_msg),\
1031 	sizeof(struct hpi_message_header) + sizeof(struct hpi_stream_msg),\
1032 	sizeof(struct hpi_message_header) + sizeof(struct hpi_mixer_msg),\
1033 	sizeof(struct hpi_message_header) ,   /* no node message */ \
1034 	sizeof(struct hpi_message_header) + sizeof(struct hpi_control_msg),\
1035 	sizeof(struct hpi_message_header) + sizeof(struct hpi_nvmemory_msg),\
1036 	sizeof(struct hpi_message_header) + sizeof(struct hpi_gpio_msg),\
1037 	sizeof(struct hpi_message_header) + sizeof(struct hpi_watchdog_msg),\
1038 	sizeof(struct hpi_message_header) + sizeof(struct hpi_clock_msg),\
1039 	sizeof(struct hpi_message_header) + sizeof(struct hpi_profile_msg),\
1040 	sizeof(struct hpi_message_header), /* controlx obj removed */ \
1041 	sizeof(struct hpi_message_header) + sizeof(struct hpi_async_msg) \
1042 }
1043 
1044 /*
1045 Note that the wSpecificError error field should be inspected and potentially
1046 reported whenever HPI_ERROR_DSP_COMMUNICATION or HPI_ERROR_DSP_BOOTLOAD is
1047 returned in wError.
1048 */
1049 struct hpi_response_header {
1050 	u16 size;
1051 	u8 type;		/* HPI_TYPE_RESPONSE  */
1052 	u8 version;		/* response version */
1053 	u16 object;		/* HPI_OBJ_* */
1054 	u16 function;		/* HPI_SUBSYS_xxx, HPI_ADAPTER_xxx */
1055 	u16 error;		/* HPI_ERROR_xxx */
1056 	u16 specific_error;	/* adapter specific error */
1057 };
1058 
1059 struct hpi_response {
1060 /* following fields must match HPI_RESPONSE_HEADER */
1061 	u16 size;
1062 	u8 type;		/* HPI_TYPE_RESPONSE  */
1063 	u8 version;		/* response version */
1064 	u16 object;		/* HPI_OBJ_* */
1065 	u16 function;		/* HPI_SUBSYS_xxx, HPI_ADAPTER_xxx */
1066 	u16 error;		/* HPI_ERROR_xxx */
1067 	u16 specific_error;	/* adapter specific error */
1068 	union {
1069 		struct hpi_subsys_res s;
1070 		union hpi_adapterx_res ax;
1071 		struct hpi_stream_res d;
1072 		struct hpi_mixer_res m;
1073 		union hpi_mixerx_res mx;	/* extended mixer; */
1074 		struct hpi_control_res c;	/* mixer control; */
1075 		/* identical to hpi_control_res, but field naming is improved */
1076 		union hpi_control_union_res cu;
1077 		struct hpi_nvmemory_res n;
1078 		struct hpi_gpio_res l;	/* digital i/o */
1079 		struct hpi_watchdog_res w;
1080 		struct hpi_clock_res t;	/* dsp time */
1081 		struct hpi_profile_res p;
1082 		struct hpi_async_res as;
1083 		u8 bytes[52];
1084 	} u;
1085 };
1086 
1087 #define HPI_RESPONSE_SIZE_BY_OBJECT { \
1088 	sizeof(struct hpi_response_header) ,/* Default, no object type 0 */ \
1089 	sizeof(struct hpi_response_header) + sizeof(struct hpi_subsys_res),\
1090 	sizeof(struct hpi_response_header) + sizeof(union  hpi_adapterx_res),\
1091 	sizeof(struct hpi_response_header) + sizeof(struct hpi_stream_res),\
1092 	sizeof(struct hpi_response_header) + sizeof(struct hpi_stream_res),\
1093 	sizeof(struct hpi_response_header) + sizeof(struct hpi_mixer_res),\
1094 	sizeof(struct hpi_response_header) , /* no node response */ \
1095 	sizeof(struct hpi_response_header) + sizeof(struct hpi_control_res),\
1096 	sizeof(struct hpi_response_header) + sizeof(struct hpi_nvmemory_res),\
1097 	sizeof(struct hpi_response_header) + sizeof(struct hpi_gpio_res),\
1098 	sizeof(struct hpi_response_header) + sizeof(struct hpi_watchdog_res),\
1099 	sizeof(struct hpi_response_header) + sizeof(struct hpi_clock_res),\
1100 	sizeof(struct hpi_response_header) + sizeof(struct hpi_profile_res),\
1101 	sizeof(struct hpi_response_header), /* controlx obj removed */ \
1102 	sizeof(struct hpi_response_header) + sizeof(struct hpi_async_res) \
1103 }
1104 
1105 /*********************** version 1 message/response **************************/
1106 #define HPINET_ETHERNET_DATA_SIZE (1500)
1107 #define HPINET_IP_HDR_SIZE (20)
1108 #define HPINET_IP_DATA_SIZE (HPINET_ETHERNET_DATA_SIZE - HPINET_IP_HDR_SIZE)
1109 #define HPINET_UDP_HDR_SIZE (8)
1110 #define HPINET_UDP_DATA_SIZE (HPINET_IP_DATA_SIZE - HPINET_UDP_HDR_SIZE)
1111 #define HPINET_ASI_HDR_SIZE (2)
1112 #define HPINET_ASI_DATA_SIZE (HPINET_UDP_DATA_SIZE - HPINET_ASI_HDR_SIZE)
1113 
1114 #define HPI_MAX_PAYLOAD_SIZE (HPINET_ASI_DATA_SIZE - 2)
1115 
1116 /* New style message/response, but still V0 compatible */
1117 struct hpi_msg_adapter_get_info {
1118 	struct hpi_message_header h;
1119 };
1120 
1121 struct hpi_res_adapter_get_info {
1122 	struct hpi_response_header h;	/*v0 */
1123 	struct hpi_adapter_res p;
1124 };
1125 
1126 struct hpi_res_adapter_debug_read {
1127 	struct hpi_response_header h;
1128 	u8 bytes[1024];
1129 };
1130 
1131 struct hpi_msg_cobranet_hmi {
1132 	u16 attribute;
1133 	u16 padding;
1134 	u32 hmi_address;
1135 	u32 byte_count;
1136 };
1137 
1138 struct hpi_msg_cobranet_hmiwrite {
1139 	struct hpi_message_header h;
1140 	struct hpi_msg_cobranet_hmi p;
1141 	u8 bytes[256];
1142 };
1143 
1144 struct hpi_msg_cobranet_hmiread {
1145 	struct hpi_message_header h;
1146 	struct hpi_msg_cobranet_hmi p;
1147 };
1148 
1149 struct hpi_res_cobranet_hmiread {
1150 	struct hpi_response_header h;
1151 	u32 byte_count;
1152 	u8 bytes[256];
1153 };
1154 
1155 #if 1
1156 #define hpi_message_header_v1 hpi_message_header
1157 #define hpi_response_header_v1 hpi_response_header
1158 #else
1159 /* V1 headers in Addition to v0 headers */
1160 struct hpi_message_header_v1 {
1161 	struct hpi_message_header h0;
1162 /* struct {
1163 } h1; */
1164 };
1165 
1166 struct hpi_response_header_v1 {
1167 	struct hpi_response_header h0;
1168 	struct {
1169 		u16 adapter_index;	/* the adapter index */
1170 		u16 obj_index;	/* object index */
1171 	} h1;
1172 };
1173 #endif
1174 
1175 struct hpi_msg_payload_v0 {
1176 	struct hpi_message_header h;
1177 	union {
1178 		struct hpi_subsys_msg s;
1179 		union hpi_adapterx_msg ax;
1180 		struct hpi_stream_msg d;
1181 		struct hpi_mixer_msg m;
1182 		union hpi_mixerx_msg mx;
1183 		struct hpi_control_msg c;
1184 		struct hpi_control_union_msg cu;
1185 		struct hpi_nvmemory_msg n;
1186 		struct hpi_gpio_msg l;
1187 		struct hpi_watchdog_msg w;
1188 		struct hpi_clock_msg t;
1189 		struct hpi_profile_msg p;
1190 		struct hpi_async_msg as;
1191 	} u;
1192 };
1193 
1194 struct hpi_res_payload_v0 {
1195 	struct hpi_response_header h;
1196 	union {
1197 		struct hpi_subsys_res s;
1198 		union hpi_adapterx_res ax;
1199 		struct hpi_stream_res d;
1200 		struct hpi_mixer_res m;
1201 		union hpi_mixerx_res mx;
1202 		struct hpi_control_res c;
1203 		union hpi_control_union_res cu;
1204 		struct hpi_nvmemory_res n;
1205 		struct hpi_gpio_res l;
1206 		struct hpi_watchdog_res w;
1207 		struct hpi_clock_res t;
1208 		struct hpi_profile_res p;
1209 		struct hpi_async_res as;
1210 	} u;
1211 };
1212 
1213 union hpi_message_buffer_v1 {
1214 	struct hpi_message m0;	/* version 0 */
1215 	struct hpi_message_header_v1 h;
1216 	u8 buf[HPI_MAX_PAYLOAD_SIZE];
1217 };
1218 
1219 union hpi_response_buffer_v1 {
1220 	struct hpi_response r0;	/* version 0 */
1221 	struct hpi_response_header_v1 h;
1222 	u8 buf[HPI_MAX_PAYLOAD_SIZE];
1223 };
1224 
1225 compile_time_assert((sizeof(union hpi_message_buffer_v1) <=
1226 		HPI_MAX_PAYLOAD_SIZE), message_buffer_ok);
1227 compile_time_assert((sizeof(union hpi_response_buffer_v1) <=
1228 		HPI_MAX_PAYLOAD_SIZE), response_buffer_ok);
1229 
1230 /*////////////////////////////////////////////////////////////////////////// */
1231 /* declarations for compact control calls  */
1232 struct hpi_control_defn {
1233 	u8 type;
1234 	u8 channels;
1235 	u8 src_node_type;
1236 	u8 src_node_index;
1237 	u8 dest_node_type;
1238 	u8 dest_node_index;
1239 };
1240 
1241 /*////////////////////////////////////////////////////////////////////////// */
1242 /* declarations for control caching (internal to HPI<->DSP interaction)      */
1243 
1244 /** indicates a cached u16 value is invalid. */
1245 #define HPI_CACHE_INVALID_UINT16 0xFFFF
1246 /** indicates a cached short value is invalid. */
1247 #define HPI_CACHE_INVALID_SHORT -32768
1248 
1249 /** A compact representation of (part of) a controls state.
1250 Used for efficient transfer of the control state
1251 between DSP and host or across a network
1252 */
1253 struct hpi_control_cache_info {
1254 	/** one of HPI_CONTROL_* */
1255 	u8 control_type;
1256 	/** The total size of cached information in 32-bit words. */
1257 	u8 size_in32bit_words;
1258 	/** The original index of the control on the DSP */
1259 	u16 control_index;
1260 };
1261 
1262 struct hpi_control_cache_vol {
1263 	struct hpi_control_cache_info i;
1264 	short an_log[2];
1265 	unsigned short flags;
1266 	char padding[2];
1267 };
1268 
1269 struct hpi_control_cache_meter {
1270 	struct hpi_control_cache_info i;
1271 	short an_log_peak[2];
1272 	short an_logRMS[2];
1273 };
1274 
1275 struct hpi_control_cache_channelmode {
1276 	struct hpi_control_cache_info i;
1277 	u16 mode;
1278 	char temp_padding[6];
1279 };
1280 
1281 struct hpi_control_cache_mux {
1282 	struct hpi_control_cache_info i;
1283 	u16 source_node_type;
1284 	u16 source_node_index;
1285 	char temp_padding[4];
1286 };
1287 
1288 struct hpi_control_cache_level {
1289 	struct hpi_control_cache_info i;
1290 	short an_log[2];
1291 	char temp_padding[4];
1292 };
1293 
1294 struct hpi_control_cache_tuner {
1295 	struct hpi_control_cache_info i;
1296 	u32 freq_ink_hz;
1297 	u16 band;
1298 	short s_level_avg;
1299 };
1300 
1301 struct hpi_control_cache_aes3rx {
1302 	struct hpi_control_cache_info i;
1303 	u32 error_status;
1304 	u32 format;
1305 };
1306 
1307 struct hpi_control_cache_aes3tx {
1308 	struct hpi_control_cache_info i;
1309 	u32 format;
1310 	char temp_padding[4];
1311 };
1312 
1313 struct hpi_control_cache_tonedetector {
1314 	struct hpi_control_cache_info i;
1315 	u16 state;
1316 	char temp_padding[6];
1317 };
1318 
1319 struct hpi_control_cache_silencedetector {
1320 	struct hpi_control_cache_info i;
1321 	u32 state;
1322 	char temp_padding[4];
1323 };
1324 
1325 struct hpi_control_cache_sampleclock {
1326 	struct hpi_control_cache_info i;
1327 	u16 source;
1328 	u16 source_index;
1329 	u32 sample_rate;
1330 };
1331 
1332 struct hpi_control_cache_microphone {
1333 	struct hpi_control_cache_info i;
1334 	u16 phantom_state;
1335 	char temp_padding[6];
1336 };
1337 
1338 struct hpi_control_cache_single {
1339 	union {
1340 		struct hpi_control_cache_info i;
1341 		struct hpi_control_cache_vol vol;
1342 		struct hpi_control_cache_meter meter;
1343 		struct hpi_control_cache_channelmode mode;
1344 		struct hpi_control_cache_mux mux;
1345 		struct hpi_control_cache_level level;
1346 		struct hpi_control_cache_tuner tuner;
1347 		struct hpi_control_cache_aes3rx aes3rx;
1348 		struct hpi_control_cache_aes3tx aes3tx;
1349 		struct hpi_control_cache_tonedetector tone;
1350 		struct hpi_control_cache_silencedetector silence;
1351 		struct hpi_control_cache_sampleclock clk;
1352 		struct hpi_control_cache_microphone microphone;
1353 	} u;
1354 };
1355 
1356 struct hpi_control_cache_pad {
1357 	struct hpi_control_cache_info i;
1358 	u32 field_valid_flags;
1359 	u8 c_channel[40];
1360 	u8 c_artist[100];
1361 	u8 c_title[100];
1362 	u8 c_comment[200];
1363 	u32 pTY;
1364 	u32 pI;
1365 	u32 traffic_supported;
1366 	u32 traffic_anouncement;
1367 };
1368 
1369 /* 2^N sized FIFO buffer (internal to HPI<->DSP interaction) */
1370 struct hpi_fifo_buffer {
1371 	u32 size;
1372 	u32 dsp_index;
1373 	u32 host_index;
1374 };
1375 
1376 #ifndef DISABLE_PRAGMA_PACK1
1377 #pragma pack(pop)
1378 #endif
1379 
1380 /* skip host side function declarations for DSP
1381    compile and documentation extraction */
1382 
1383 char hpi_handle_object(const u32 handle);
1384 
1385 void hpi_handle_to_indexes(const u32 handle, u16 *pw_adapter_index,
1386 	u16 *pw_object_index);
1387 
1388 u32 hpi_indexes_to_handle(const char c_object, const u16 adapter_index,
1389 	const u16 object_index);
1390 
1391 /*////////////////////////////////////////////////////////////////////////// */
1392 
1393 /* main HPI entry point */
1394 void hpi_send_recv(struct hpi_message *phm, struct hpi_response *phr);
1395 
1396 /* used in PnP OS/driver */
1397 u16 hpi_outstream_host_buffer_get_info(u32 h_outstream, u8 **pp_buffer,
1398 	struct hpi_hostbuffer_status **pp_status);
1399 
1400 u16 hpi_instream_host_buffer_get_info(u32 h_instream, u8 **pp_buffer,
1401 	struct hpi_hostbuffer_status **pp_status);
1402 
1403 /*
1404 The following 3 functions were last declared in header files for
1405 driver 3.10. HPI_ControlQuery() used to be the recommended way
1406 of getting a volume range. Declared here for binary asihpi32.dll
1407 compatibility.
1408 */
1409 
1410 void hpi_format_to_msg(struct hpi_msg_format *pMF,
1411 	const struct hpi_format *pF);
1412 void hpi_stream_response_to_legacy(struct hpi_stream_res *pSR);
1413 
1414 /*////////////////////////////////////////////////////////////////////////// */
1415 /* declarations for individual HPI entry points */
1416 hpi_handler_func HPI_6000;
1417 hpi_handler_func HPI_6205;
1418 
1419 #endif				/* _HPI_INTERNAL_H_ */
1420