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