xref: /openbmc/linux/sound/pci/asihpi/hpi_internal.h (revision 8ac727c1)
1 /******************************************************************************
2 
3     AudioScience HPI driver
4     Copyright (C) 1997-2010  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 /** maximum number of memory regions mapped to an adapter */
29 #define HPI_MAX_ADAPTER_MEM_SPACES (2)
30 
31 /* Each OS needs its own hpios.h, or specific define as above */
32 #include "hpios.h"
33 
34 /* physical memory allocation */
35 void hpios_locked_mem_init(void
36 	);
37 void hpios_locked_mem_free_all(void
38 	);
39 #define hpios_locked_mem_prepare(a, b, c, d);
40 #define hpios_locked_mem_unprepare(a)
41 
42 /** Allocate and map an area of locked memory for bus master DMA operations.
43 
44 On success, *pLockedMemeHandle is a valid handle, and 0 is returned
45 On error *pLockedMemHandle marked invalid, non-zero returned.
46 
47 If this function succeeds, then HpiOs_LockedMem_GetVirtAddr() and
48 HpiOs_LockedMem_GetPyhsAddr() will always succed on the returned handle.
49 */
50 u16 hpios_locked_mem_alloc(struct consistent_dma_area *p_locked_mem_handle,
51 							   /**< memory handle */
52 	u32 size, /**< size in bytes to allocate */
53 	struct pci_dev *p_os_reference
54 	/**< OS specific data required for memory allocation */
55 	);
56 
57 /** Free mapping and memory represented by LockedMemHandle
58 
59 Frees any resources, then invalidates the handle.
60 Returns 0 on success, 1 if handle is invalid.
61 
62 */
63 u16 hpios_locked_mem_free(struct consistent_dma_area *locked_mem_handle);
64 
65 /** Get the physical PCI address of memory represented by LockedMemHandle.
66 
67 If handle is invalid *pPhysicalAddr is set to zero and return 1
68 */
69 u16 hpios_locked_mem_get_phys_addr(struct consistent_dma_area
70 	*locked_mem_handle, u32 *p_physical_addr);
71 
72 /** Get the CPU address of of memory represented by LockedMemHandle.
73 
74 If handle is NULL *ppvVirtualAddr is set to NULL and return 1
75 */
76 u16 hpios_locked_mem_get_virt_addr(struct consistent_dma_area
77 	*locked_mem_handle, void **ppv_virtual_addr);
78 
79 /** Check that handle is valid
80 i.e it represents a valid memory area
81 */
82 u16 hpios_locked_mem_valid(struct consistent_dma_area *locked_mem_handle);
83 
84 /* timing/delay */
85 void hpios_delay_micro_seconds(u32 num_micro_sec);
86 
87 struct hpi_message;
88 struct hpi_response;
89 
90 typedef void hpi_handler_func(struct hpi_message *, struct hpi_response *);
91 
92 /* If the assert fails, compiler complains
93    something like size of array `msg' is negative.
94    Unlike linux BUILD_BUG_ON, this works outside function scope.
95 */
96 #define compile_time_assert(cond, msg) \
97     typedef char ASSERT_##msg[(cond) ? 1 : -1]
98 
99 /*/////////////////////////////////////////////////////////////////////////// */
100 /* Private HPI Entity related definitions                                     */
101 
102 #define STR_SIZE_FIELD_MAX 65535U
103 #define STR_TYPE_FIELD_MAX 255U
104 #define STR_ROLE_FIELD_MAX 255U
105 
106 struct hpi_entity_str {
107 	u16 size;
108 	u8 type;
109 	u8 role;
110 };
111 
112 #if defined(_MSC_VER)
113 #pragma warning(push)
114 #pragma warning(disable : 4200)
115 #endif
116 
117 struct hpi_entity {
118 	struct hpi_entity_str header;
119 #if ! defined(HPI_OS_DSP_C6000) || (defined(HPI_OS_DSP_C6000) && (__TI_COMPILER_VERSION__ > 6000008))
120 	/* DSP C6000 compiler v6.0.8 and lower
121 	   do not support  flexible array member */
122 	u8 value[];
123 #else
124 	/* NOTE! Using sizeof(struct hpi_entity) will give erroneous results */
125 #define HPI_INTERNAL_WARN_ABOUT_ENTITY_VALUE
126 	u8 value[1];
127 #endif
128 };
129 
130 #if defined(_MSC_VER)
131 #pragma warning(pop)
132 #endif
133 
134 /******************************************* bus types */
135 enum HPI_BUSES {
136 	HPI_BUS_ISAPNP = 1,
137 	HPI_BUS_PCI = 2,
138 	HPI_BUS_USB = 3,
139 	HPI_BUS_NET = 4
140 };
141 
142 /******************************************* CONTROL ATTRIBUTES ****/
143 /* (in order of control type ID */
144 
145 /* This allows for 255 control types, 256 unique attributes each */
146 #define HPI_CTL_ATTR(ctl, ai) (HPI_CONTROL_##ctl * 0x100 + ai)
147 
148 /* Get the sub-index of the attribute for a control type */
149 #define HPI_CTL_ATTR_INDEX(i) (i&0xff)
150 
151 /* Extract the control from the control attribute */
152 #define HPI_CTL_ATTR_CONTROL(i) (i>>8)
153 
154 /* Generic control attributes.  */
155 
156 /** Enable a control.
157 0=disable, 1=enable
158 \note generic to all mixer plugins?
159 */
160 #define HPI_GENERIC_ENABLE HPI_CTL_ATTR(GENERIC, 1)
161 
162 /** Enable event generation for a control.
163 0=disable, 1=enable
164 \note generic to all controls that can generate events
165 */
166 #define HPI_GENERIC_EVENT_ENABLE HPI_CTL_ATTR(GENERIC, 2)
167 
168 /* Volume Control attributes */
169 #define HPI_VOLUME_GAIN                 HPI_CTL_ATTR(VOLUME, 1)
170 #define HPI_VOLUME_AUTOFADE             HPI_CTL_ATTR(VOLUME, 2)
171 
172 /** For HPI_ControlQuery() to get the number of channels of a volume control*/
173 #define HPI_VOLUME_NUM_CHANNELS         HPI_CTL_ATTR(VOLUME, 6)
174 #define HPI_VOLUME_RANGE                HPI_CTL_ATTR(VOLUME, 10)
175 
176 /** Level Control attributes */
177 #define HPI_LEVEL_GAIN                  HPI_CTL_ATTR(LEVEL, 1)
178 #define HPI_LEVEL_RANGE                 HPI_CTL_ATTR(LEVEL, 10)
179 
180 /* Meter Control attributes */
181 /** return RMS signal level */
182 #define HPI_METER_RMS                   HPI_CTL_ATTR(METER, 1)
183 /** return peak signal level */
184 #define HPI_METER_PEAK                  HPI_CTL_ATTR(METER, 2)
185 /** ballistics for ALL rms meters on adapter */
186 #define HPI_METER_RMS_BALLISTICS        HPI_CTL_ATTR(METER, 3)
187 /** ballistics for ALL peak meters on adapter */
188 #define HPI_METER_PEAK_BALLISTICS       HPI_CTL_ATTR(METER, 4)
189 
190 /** For HPI_ControlQuery() to get the number of channels of a meter control*/
191 #define HPI_METER_NUM_CHANNELS          HPI_CTL_ATTR(METER, 5)
192 
193 /* Multiplexer control attributes */
194 #define HPI_MULTIPLEXER_SOURCE          HPI_CTL_ATTR(MULTIPLEXER, 1)
195 #define HPI_MULTIPLEXER_QUERYSOURCE     HPI_CTL_ATTR(MULTIPLEXER, 2)
196 
197 /** AES/EBU transmitter control attributes */
198 /** AESEBU or SPDIF */
199 #define HPI_AESEBUTX_FORMAT             HPI_CTL_ATTR(AESEBUTX, 1)
200 #define HPI_AESEBUTX_SAMPLERATE         HPI_CTL_ATTR(AESEBUTX, 3)
201 #define HPI_AESEBUTX_CHANNELSTATUS      HPI_CTL_ATTR(AESEBUTX, 4)
202 #define HPI_AESEBUTX_USERDATA           HPI_CTL_ATTR(AESEBUTX, 5)
203 
204 /** AES/EBU receiver control attributes */
205 #define HPI_AESEBURX_FORMAT             HPI_CTL_ATTR(AESEBURX, 1)
206 #define HPI_AESEBURX_ERRORSTATUS        HPI_CTL_ATTR(AESEBURX, 2)
207 #define HPI_AESEBURX_SAMPLERATE         HPI_CTL_ATTR(AESEBURX, 3)
208 #define HPI_AESEBURX_CHANNELSTATUS      HPI_CTL_ATTR(AESEBURX, 4)
209 #define HPI_AESEBURX_USERDATA           HPI_CTL_ATTR(AESEBURX, 5)
210 
211 /** \defgroup tuner_defs Tuners
212 \{
213 */
214 /** \defgroup tuner_attrs Tuner control attributes
215 \{
216 */
217 #define HPI_TUNER_BAND                  HPI_CTL_ATTR(TUNER, 1)
218 #define HPI_TUNER_FREQ                  HPI_CTL_ATTR(TUNER, 2)
219 #define HPI_TUNER_LEVEL                 HPI_CTL_ATTR(TUNER, 3)
220 #define HPI_TUNER_AUDIOMUTE             HPI_CTL_ATTR(TUNER, 4)
221 /* use TUNER_STATUS instead */
222 #define HPI_TUNER_VIDEO_STATUS          HPI_CTL_ATTR(TUNER, 5)
223 #define HPI_TUNER_GAIN                  HPI_CTL_ATTR(TUNER, 6)
224 #define HPI_TUNER_STATUS                HPI_CTL_ATTR(TUNER, 7)
225 #define HPI_TUNER_MODE                  HPI_CTL_ATTR(TUNER, 8)
226 /** RDS data. */
227 #define HPI_TUNER_RDS                   HPI_CTL_ATTR(TUNER, 9)
228 /** Audio pre-emphasis. */
229 #define HPI_TUNER_DEEMPHASIS            HPI_CTL_ATTR(TUNER, 10)
230 /** HD Radio tuner program control. */
231 #define HPI_TUNER_PROGRAM               HPI_CTL_ATTR(TUNER, 11)
232 /** HD Radio tuner digital signal quality. */
233 #define HPI_TUNER_HDRADIO_SIGNAL_QUALITY        HPI_CTL_ATTR(TUNER, 12)
234 /** HD Radio SDK firmware version. */
235 #define HPI_TUNER_HDRADIO_SDK_VERSION   HPI_CTL_ATTR(TUNER, 13)
236 /** HD Radio DSP firmware version. */
237 #define HPI_TUNER_HDRADIO_DSP_VERSION   HPI_CTL_ATTR(TUNER, 14)
238 /** HD Radio signal blend (force analog, or automatic). */
239 #define HPI_TUNER_HDRADIO_BLEND         HPI_CTL_ATTR(TUNER, 15)
240 
241 /** \} */
242 
243 /** \defgroup pads_attrs Tuner PADs control attributes
244 \{
245 */
246 /** The text string containing the station/channel combination. */
247 #define HPI_PAD_CHANNEL_NAME            HPI_CTL_ATTR(PAD, 1)
248 /** The text string containing the artist. */
249 #define HPI_PAD_ARTIST                  HPI_CTL_ATTR(PAD, 2)
250 /** The text string containing the title. */
251 #define HPI_PAD_TITLE                   HPI_CTL_ATTR(PAD, 3)
252 /** The text string containing the comment. */
253 #define HPI_PAD_COMMENT                 HPI_CTL_ATTR(PAD, 4)
254 /** The integer containing the PTY code. */
255 #define HPI_PAD_PROGRAM_TYPE            HPI_CTL_ATTR(PAD, 5)
256 /** The integer containing the program identification. */
257 #define HPI_PAD_PROGRAM_ID              HPI_CTL_ATTR(PAD, 6)
258 /** The integer containing whether traffic information is supported.
259 Contains either 1 or 0. */
260 #define HPI_PAD_TA_SUPPORT              HPI_CTL_ATTR(PAD, 7)
261 /** The integer containing whether traffic announcement is in progress.
262 Contains either 1 or 0. */
263 #define HPI_PAD_TA_ACTIVE               HPI_CTL_ATTR(PAD, 8)
264 /** \} */
265 /** \} */
266 
267 /* VOX control attributes */
268 #define HPI_VOX_THRESHOLD               HPI_CTL_ATTR(VOX, 1)
269 
270 /*?? channel mode used hpi_multiplexer_source attribute == 1 */
271 #define HPI_CHANNEL_MODE_MODE HPI_CTL_ATTR(CHANNEL_MODE, 1)
272 
273 /** \defgroup channel_modes Channel Modes
274 Used for HPI_ChannelModeSet/Get()
275 \{
276 */
277 /** Left channel out = left channel in, Right channel out = right channel in. */
278 #define HPI_CHANNEL_MODE_NORMAL                 1
279 /** Left channel out = right channel in, Right channel out = left channel in. */
280 #define HPI_CHANNEL_MODE_SWAP                   2
281 /** Left channel out = left channel in, Right channel out = left channel in. */
282 #define HPI_CHANNEL_MODE_LEFT_TO_STEREO         3
283 /** Left channel out = right channel in, Right channel out = right channel in.*/
284 #define HPI_CHANNEL_MODE_RIGHT_TO_STEREO        4
285 /** Left channel out = (left channel in + right channel in)/2,
286     Right channel out = mute. */
287 #define HPI_CHANNEL_MODE_STEREO_TO_LEFT         5
288 /** Left channel out = mute,
289     Right channel out = (right channel in + left channel in)/2. */
290 #define HPI_CHANNEL_MODE_STEREO_TO_RIGHT        6
291 #define HPI_CHANNEL_MODE_LAST                   6
292 /** \} */
293 
294 /* Bitstream control set attributes */
295 #define HPI_BITSTREAM_DATA_POLARITY     HPI_CTL_ATTR(BITSTREAM, 1)
296 #define HPI_BITSTREAM_CLOCK_EDGE        HPI_CTL_ATTR(BITSTREAM, 2)
297 #define HPI_BITSTREAM_CLOCK_SOURCE      HPI_CTL_ATTR(BITSTREAM, 3)
298 
299 #define HPI_POLARITY_POSITIVE           0
300 #define HPI_POLARITY_NEGATIVE           1
301 
302 /* Bitstream control get attributes */
303 #define HPI_BITSTREAM_ACTIVITY          1
304 
305 /* SampleClock control attributes */
306 #define HPI_SAMPLECLOCK_SOURCE                  HPI_CTL_ATTR(SAMPLECLOCK, 1)
307 #define HPI_SAMPLECLOCK_SAMPLERATE              HPI_CTL_ATTR(SAMPLECLOCK, 2)
308 #define HPI_SAMPLECLOCK_SOURCE_INDEX            HPI_CTL_ATTR(SAMPLECLOCK, 3)
309 #define HPI_SAMPLECLOCK_LOCAL_SAMPLERATE\
310 	HPI_CTL_ATTR(SAMPLECLOCK, 4)
311 #define HPI_SAMPLECLOCK_AUTO                    HPI_CTL_ATTR(SAMPLECLOCK, 5)
312 #define HPI_SAMPLECLOCK_LOCAL_LOCK                      HPI_CTL_ATTR(SAMPLECLOCK, 6)
313 
314 /* Microphone control attributes */
315 #define HPI_MICROPHONE_PHANTOM_POWER HPI_CTL_ATTR(MICROPHONE, 1)
316 
317 /** Equalizer control attributes */
318 /** Used to get number of filters in an EQ. (Can't set) */
319 #define HPI_EQUALIZER_NUM_FILTERS HPI_CTL_ATTR(EQUALIZER, 1)
320 /** Set/get the filter by type, freq, Q, gain */
321 #define HPI_EQUALIZER_FILTER HPI_CTL_ATTR(EQUALIZER, 2)
322 /** Get the biquad coefficients */
323 #define HPI_EQUALIZER_COEFFICIENTS HPI_CTL_ATTR(EQUALIZER, 3)
324 
325 /* Note compander also uses HPI_GENERIC_ENABLE */
326 #define HPI_COMPANDER_PARAMS     HPI_CTL_ATTR(COMPANDER, 1)
327 #define HPI_COMPANDER_MAKEUPGAIN HPI_CTL_ATTR(COMPANDER, 2)
328 #define HPI_COMPANDER_THRESHOLD  HPI_CTL_ATTR(COMPANDER, 3)
329 #define HPI_COMPANDER_RATIO      HPI_CTL_ATTR(COMPANDER, 4)
330 #define HPI_COMPANDER_ATTACK     HPI_CTL_ATTR(COMPANDER, 5)
331 #define HPI_COMPANDER_DECAY      HPI_CTL_ATTR(COMPANDER, 6)
332 
333 /* Cobranet control attributes. */
334 #define HPI_COBRANET_SET         HPI_CTL_ATTR(COBRANET, 1)
335 #define HPI_COBRANET_GET         HPI_CTL_ATTR(COBRANET, 2)
336 #define HPI_COBRANET_SET_DATA    HPI_CTL_ATTR(COBRANET, 3)
337 #define HPI_COBRANET_GET_DATA    HPI_CTL_ATTR(COBRANET, 4)
338 #define HPI_COBRANET_GET_STATUS  HPI_CTL_ATTR(COBRANET, 5)
339 #define HPI_COBRANET_SEND_PACKET HPI_CTL_ATTR(COBRANET, 6)
340 #define HPI_COBRANET_GET_PACKET  HPI_CTL_ATTR(COBRANET, 7)
341 
342 /*------------------------------------------------------------
343  Cobranet Chip Bridge - copied from HMI.H
344 ------------------------------------------------------------*/
345 #define  HPI_COBRANET_HMI_cobra_bridge           0x20000
346 #define  HPI_COBRANET_HMI_cobra_bridge_tx_pkt_buf \
347 	(HPI_COBRANET_HMI_cobra_bridge + 0x1000)
348 #define  HPI_COBRANET_HMI_cobra_bridge_rx_pkt_buf \
349 	(HPI_COBRANET_HMI_cobra_bridge + 0x2000)
350 #define  HPI_COBRANET_HMI_cobra_if_table1         0x110000
351 #define  HPI_COBRANET_HMI_cobra_if_phy_address \
352 	(HPI_COBRANET_HMI_cobra_if_table1 + 0xd)
353 #define  HPI_COBRANET_HMI_cobra_protocolIP       0x72000
354 #define  HPI_COBRANET_HMI_cobra_ip_mon_currentIP \
355 	(HPI_COBRANET_HMI_cobra_protocolIP + 0x0)
356 #define  HPI_COBRANET_HMI_cobra_ip_mon_staticIP \
357 	(HPI_COBRANET_HMI_cobra_protocolIP + 0x2)
358 #define  HPI_COBRANET_HMI_cobra_sys              0x100000
359 #define  HPI_COBRANET_HMI_cobra_sys_desc \
360 		(HPI_COBRANET_HMI_cobra_sys + 0x0)
361 #define  HPI_COBRANET_HMI_cobra_sys_objectID \
362 	(HPI_COBRANET_HMI_cobra_sys + 0x100)
363 #define  HPI_COBRANET_HMI_cobra_sys_contact \
364 	(HPI_COBRANET_HMI_cobra_sys + 0x200)
365 #define  HPI_COBRANET_HMI_cobra_sys_name \
366 		(HPI_COBRANET_HMI_cobra_sys + 0x300)
367 #define  HPI_COBRANET_HMI_cobra_sys_location \
368 	(HPI_COBRANET_HMI_cobra_sys + 0x400)
369 
370 /*------------------------------------------------------------
371  Cobranet Chip Status bits
372 ------------------------------------------------------------*/
373 #define HPI_COBRANET_HMI_STATUS_RXPACKET 2
374 #define HPI_COBRANET_HMI_STATUS_TXPACKET 3
375 
376 /*------------------------------------------------------------
377  Ethernet header size
378 ------------------------------------------------------------*/
379 #define HPI_ETHERNET_HEADER_SIZE (16)
380 
381 /* These defines are used to fill in protocol information for an Ethernet packet
382     sent using HMI on CS18102 */
383 /** ID supplied by Cirrius for ASI packets. */
384 #define HPI_ETHERNET_PACKET_ID                  0x85
385 /** Simple packet - no special routing required */
386 #define HPI_ETHERNET_PACKET_V1                  0x01
387 /** This packet must make its way to the host across the HPI interface */
388 #define HPI_ETHERNET_PACKET_HOSTED_VIA_HMI      0x20
389 /** This packet must make its way to the host across the HPI interface */
390 #define HPI_ETHERNET_PACKET_HOSTED_VIA_HMI_V1   0x21
391 /** This packet must make its way to the host across the HPI interface */
392 #define HPI_ETHERNET_PACKET_HOSTED_VIA_HPI      0x40
393 /** This packet must make its way to the host across the HPI interface */
394 #define HPI_ETHERNET_PACKET_HOSTED_VIA_HPI_V1   0x41
395 
396 #define HPI_ETHERNET_UDP_PORT (44600)	/*!< UDP messaging port */
397 
398 /** Base network time out is set to 100 milli-seconds. */
399 #define HPI_ETHERNET_TIMEOUT_MS      (100)
400 
401 /** \defgroup tonedet_attr Tonedetector attributes
402 \{
403 Used by HPI_ToneDetector_Set() and HPI_ToneDetector_Get()
404 */
405 
406 /** Set the threshold level of a tonedetector,
407 Threshold is a -ve number in units of dB/100,
408 */
409 #define HPI_TONEDETECTOR_THRESHOLD HPI_CTL_ATTR(TONEDETECTOR, 1)
410 
411 /** Get the current state of tonedetection
412 The result is a bitmap of detected tones.  pairs of bits represent the left
413 and right channels, with left channel in LSB.
414 The lowest frequency detector state is in the LSB
415 */
416 #define HPI_TONEDETECTOR_STATE HPI_CTL_ATTR(TONEDETECTOR, 2)
417 
418 /** Get the frequency of a tonedetector band.
419 */
420 #define HPI_TONEDETECTOR_FREQUENCY HPI_CTL_ATTR(TONEDETECTOR, 3)
421 
422 /**\}*/
423 
424 /** \defgroup silencedet_attr SilenceDetector attributes
425 \{
426 */
427 
428 /** Get the current state of tonedetection
429 The result is a bitmap with 1s for silent channels. Left channel is in LSB
430 */
431 #define HPI_SILENCEDETECTOR_STATE \
432   HPI_CTL_ATTR(SILENCEDETECTOR, 2)
433 
434 /** Set the threshold level of a SilenceDetector,
435 Threshold is a -ve number in units of dB/100,
436 */
437 #define HPI_SILENCEDETECTOR_THRESHOLD \
438   HPI_CTL_ATTR(SILENCEDETECTOR, 1)
439 
440 /** get/set the silence time before the detector triggers
441 */
442 #define HPI_SILENCEDETECTOR_DELAY \
443        HPI_CTL_ATTR(SILENCEDETECTOR, 3)
444 
445 /**\}*/
446 
447 /* Locked memory buffer alloc/free phases */
448 /** use one message to allocate or free physical memory */
449 #define HPI_BUFFER_CMD_EXTERNAL                 0
450 /** alloc physical memory */
451 #define HPI_BUFFER_CMD_INTERNAL_ALLOC           1
452 /** send physical memory address to adapter */
453 #define HPI_BUFFER_CMD_INTERNAL_GRANTADAPTER    2
454 /** notify adapter to stop using physical buffer */
455 #define HPI_BUFFER_CMD_INTERNAL_REVOKEADAPTER   3
456 /** free physical buffer */
457 #define HPI_BUFFER_CMD_INTERNAL_FREE            4
458 
459 /******************************************* CONTROLX ATTRIBUTES ****/
460 /* NOTE: All controlx attributes must be unique, unlike control attributes */
461 
462 /*****************************************************************************/
463 /*****************************************************************************/
464 /********               HPI LOW LEVEL MESSAGES                  *******/
465 /*****************************************************************************/
466 /*****************************************************************************/
467 /** Pnp ids */
468 /** "ASI"  - actual is "ASX" - need to change */
469 #define HPI_ID_ISAPNP_AUDIOSCIENCE      0x0669
470 /** PCI vendor ID that AudioScience uses */
471 #define HPI_PCI_VENDOR_ID_AUDIOSCIENCE  0x175C
472 /** PCI vendor ID that the DSP56301 has */
473 #define HPI_PCI_VENDOR_ID_MOTOROLA      0x1057
474 /** PCI vendor ID that TI uses */
475 #define HPI_PCI_VENDOR_ID_TI            0x104C
476 
477 #define HPI_PCI_DEV_ID_PCI2040          0xAC60
478 /** TI's C6205 PCI interface has this ID */
479 #define HPI_PCI_DEV_ID_DSP6205          0xA106
480 
481 #define HPI_USB_VENDOR_ID_AUDIOSCIENCE  0x1257
482 #define HPI_USB_W2K_TAG                 0x57495341	/* "ASIW"       */
483 #define HPI_USB_LINUX_TAG               0x4C495341	/* "ASIL"       */
484 
485 /** First 2 hex digits define the adapter family */
486 #define HPI_ADAPTER_FAMILY_MASK         0xff00
487 #define HPI_MODULE_FAMILY_MASK          0xfff0
488 
489 #define HPI_ADAPTER_FAMILY_ASI(f)   (f & HPI_ADAPTER_FAMILY_MASK)
490 #define HPI_MODULE_FAMILY_ASI(f)   (f & HPI_MODULE_FAMILY_MASK)
491 #define HPI_ADAPTER_ASI(f)   (f)
492 
493 /******************************************* message types */
494 #define HPI_TYPE_MESSAGE                        1
495 #define HPI_TYPE_RESPONSE                       2
496 #define HPI_TYPE_DATA                           3
497 #define HPI_TYPE_SSX2BYPASS_MESSAGE             4
498 
499 /******************************************* object types */
500 #define HPI_OBJ_SUBSYSTEM                       1
501 #define HPI_OBJ_ADAPTER                         2
502 #define HPI_OBJ_OSTREAM                         3
503 #define HPI_OBJ_ISTREAM                         4
504 #define HPI_OBJ_MIXER                           5
505 #define HPI_OBJ_NODE                            6
506 #define HPI_OBJ_CONTROL                         7
507 #define HPI_OBJ_NVMEMORY                        8
508 #define HPI_OBJ_GPIO                            9
509 #define HPI_OBJ_WATCHDOG                        10
510 #define HPI_OBJ_CLOCK                           11
511 #define HPI_OBJ_PROFILE                         12
512 #define HPI_OBJ_CONTROLEX                       13
513 #define HPI_OBJ_ASYNCEVENT                      14
514 
515 #define HPI_OBJ_MAXINDEX                        14
516 
517 /******************************************* methods/functions */
518 
519 #define HPI_OBJ_FUNCTION_SPACING        0x100
520 #define HPI_MAKE_INDEX(obj, index) (obj * HPI_OBJ_FUNCTION_SPACING + index)
521 #define HPI_EXTRACT_INDEX(fn) (fn & 0xff)
522 
523 /* SUB-SYSTEM */
524 #define HPI_SUBSYS_OPEN                 HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 1)
525 #define HPI_SUBSYS_GET_VERSION          HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 2)
526 #define HPI_SUBSYS_GET_INFO             HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 3)
527 #define HPI_SUBSYS_FIND_ADAPTERS        HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 4)
528 #define HPI_SUBSYS_CREATE_ADAPTER       HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 5)
529 #define HPI_SUBSYS_CLOSE                HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 6)
530 #define HPI_SUBSYS_DELETE_ADAPTER       HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 7)
531 #define HPI_SUBSYS_DRIVER_LOAD          HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 8)
532 #define HPI_SUBSYS_DRIVER_UNLOAD        HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 9)
533 #define HPI_SUBSYS_READ_PORT_8          HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 10)
534 #define HPI_SUBSYS_WRITE_PORT_8         HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 11)
535 #define HPI_SUBSYS_GET_NUM_ADAPTERS     HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 12)
536 #define HPI_SUBSYS_GET_ADAPTER          HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 13)
537 #define HPI_SUBSYS_SET_NETWORK_INTERFACE HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 14)
538 #define HPI_SUBSYS_FUNCTION_COUNT 14
539 /* ADAPTER */
540 #define HPI_ADAPTER_OPEN                HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 1)
541 #define HPI_ADAPTER_CLOSE               HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 2)
542 #define HPI_ADAPTER_GET_INFO            HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 3)
543 #define HPI_ADAPTER_GET_ASSERT          HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 4)
544 #define HPI_ADAPTER_TEST_ASSERT         HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 5)
545 #define HPI_ADAPTER_SET_MODE            HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 6)
546 #define HPI_ADAPTER_GET_MODE            HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 7)
547 #define HPI_ADAPTER_ENABLE_CAPABILITY   HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 8)
548 #define HPI_ADAPTER_SELFTEST            HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 9)
549 #define HPI_ADAPTER_FIND_OBJECT         HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 10)
550 #define HPI_ADAPTER_QUERY_FLASH         HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 11)
551 #define HPI_ADAPTER_START_FLASH         HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 12)
552 #define HPI_ADAPTER_PROGRAM_FLASH       HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 13)
553 #define HPI_ADAPTER_SET_PROPERTY        HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 14)
554 #define HPI_ADAPTER_GET_PROPERTY        HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 15)
555 #define HPI_ADAPTER_ENUM_PROPERTY       HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 16)
556 #define HPI_ADAPTER_MODULE_INFO         HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 17)
557 #define HPI_ADAPTER_DEBUG_READ          HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 18)
558 #define HPI_ADAPTER_FUNCTION_COUNT 18
559 /* OUTPUT STREAM */
560 #define HPI_OSTREAM_OPEN                HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 1)
561 #define HPI_OSTREAM_CLOSE               HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 2)
562 #define HPI_OSTREAM_WRITE               HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 3)
563 #define HPI_OSTREAM_START               HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 4)
564 #define HPI_OSTREAM_STOP                HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 5)
565 #define HPI_OSTREAM_RESET               HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 6)
566 #define HPI_OSTREAM_GET_INFO            HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 7)
567 #define HPI_OSTREAM_QUERY_FORMAT        HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 8)
568 #define HPI_OSTREAM_DATA                HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 9)
569 #define HPI_OSTREAM_SET_VELOCITY        HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 10)
570 #define HPI_OSTREAM_SET_PUNCHINOUT      HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 11)
571 #define HPI_OSTREAM_SINEGEN             HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 12)
572 #define HPI_OSTREAM_ANC_RESET           HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 13)
573 #define HPI_OSTREAM_ANC_GET_INFO        HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 14)
574 #define HPI_OSTREAM_ANC_READ            HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 15)
575 #define HPI_OSTREAM_SET_TIMESCALE       HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 16)
576 #define HPI_OSTREAM_SET_FORMAT          HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 17)
577 #define HPI_OSTREAM_HOSTBUFFER_ALLOC    HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 18)
578 #define HPI_OSTREAM_HOSTBUFFER_FREE     HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 19)
579 #define HPI_OSTREAM_GROUP_ADD           HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 20)
580 #define HPI_OSTREAM_GROUP_GETMAP        HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 21)
581 #define HPI_OSTREAM_GROUP_RESET         HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 22)
582 #define HPI_OSTREAM_HOSTBUFFER_GET_INFO HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 23)
583 #define HPI_OSTREAM_WAIT_START          HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 24)
584 #define HPI_OSTREAM_FUNCTION_COUNT              24
585 /* INPUT STREAM */
586 #define HPI_ISTREAM_OPEN                HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 1)
587 #define HPI_ISTREAM_CLOSE               HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 2)
588 #define HPI_ISTREAM_SET_FORMAT          HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 3)
589 #define HPI_ISTREAM_READ                HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 4)
590 #define HPI_ISTREAM_START               HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 5)
591 #define HPI_ISTREAM_STOP                HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 6)
592 #define HPI_ISTREAM_RESET               HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 7)
593 #define HPI_ISTREAM_GET_INFO            HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 8)
594 #define HPI_ISTREAM_QUERY_FORMAT        HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 9)
595 #define HPI_ISTREAM_ANC_RESET           HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 10)
596 #define HPI_ISTREAM_ANC_GET_INFO        HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 11)
597 #define HPI_ISTREAM_ANC_WRITE           HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 12)
598 #define HPI_ISTREAM_HOSTBUFFER_ALLOC    HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 13)
599 #define HPI_ISTREAM_HOSTBUFFER_FREE     HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 14)
600 #define HPI_ISTREAM_GROUP_ADD           HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 15)
601 #define HPI_ISTREAM_GROUP_GETMAP        HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 16)
602 #define HPI_ISTREAM_GROUP_RESET         HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 17)
603 #define HPI_ISTREAM_HOSTBUFFER_GET_INFO HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 18)
604 #define HPI_ISTREAM_WAIT_START          HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 19)
605 #define HPI_ISTREAM_FUNCTION_COUNT              19
606 /* MIXER */
607 /* NOTE:
608    GET_NODE_INFO, SET_CONNECTION, GET_CONNECTIONS are not currently used */
609 #define HPI_MIXER_OPEN                  HPI_MAKE_INDEX(HPI_OBJ_MIXER, 1)
610 #define HPI_MIXER_CLOSE                 HPI_MAKE_INDEX(HPI_OBJ_MIXER, 2)
611 #define HPI_MIXER_GET_INFO              HPI_MAKE_INDEX(HPI_OBJ_MIXER, 3)
612 #define HPI_MIXER_GET_NODE_INFO         HPI_MAKE_INDEX(HPI_OBJ_MIXER, 4)
613 #define HPI_MIXER_GET_CONTROL           HPI_MAKE_INDEX(HPI_OBJ_MIXER, 5)
614 #define HPI_MIXER_SET_CONNECTION        HPI_MAKE_INDEX(HPI_OBJ_MIXER, 6)
615 #define HPI_MIXER_GET_CONNECTIONS       HPI_MAKE_INDEX(HPI_OBJ_MIXER, 7)
616 #define HPI_MIXER_GET_CONTROL_BY_INDEX  HPI_MAKE_INDEX(HPI_OBJ_MIXER, 8)
617 #define HPI_MIXER_GET_CONTROL_ARRAY_BY_INDEX  HPI_MAKE_INDEX(HPI_OBJ_MIXER, 9)
618 #define HPI_MIXER_GET_CONTROL_MULTIPLE_VALUES HPI_MAKE_INDEX(HPI_OBJ_MIXER, 10)
619 #define HPI_MIXER_STORE                 HPI_MAKE_INDEX(HPI_OBJ_MIXER, 11)
620 #define HPI_MIXER_FUNCTION_COUNT        11
621 /* MIXER CONTROLS */
622 #define HPI_CONTROL_GET_INFO            HPI_MAKE_INDEX(HPI_OBJ_CONTROL, 1)
623 #define HPI_CONTROL_GET_STATE           HPI_MAKE_INDEX(HPI_OBJ_CONTROL, 2)
624 #define HPI_CONTROL_SET_STATE           HPI_MAKE_INDEX(HPI_OBJ_CONTROL, 3)
625 #define HPI_CONTROL_FUNCTION_COUNT 3
626 /* NONVOL MEMORY */
627 #define HPI_NVMEMORY_OPEN               HPI_MAKE_INDEX(HPI_OBJ_NVMEMORY, 1)
628 #define HPI_NVMEMORY_READ_BYTE          HPI_MAKE_INDEX(HPI_OBJ_NVMEMORY, 2)
629 #define HPI_NVMEMORY_WRITE_BYTE         HPI_MAKE_INDEX(HPI_OBJ_NVMEMORY, 3)
630 #define HPI_NVMEMORY_FUNCTION_COUNT 3
631 /* GPIO */
632 #define HPI_GPIO_OPEN                   HPI_MAKE_INDEX(HPI_OBJ_GPIO, 1)
633 #define HPI_GPIO_READ_BIT               HPI_MAKE_INDEX(HPI_OBJ_GPIO, 2)
634 #define HPI_GPIO_WRITE_BIT              HPI_MAKE_INDEX(HPI_OBJ_GPIO, 3)
635 #define HPI_GPIO_READ_ALL               HPI_MAKE_INDEX(HPI_OBJ_GPIO, 4)
636 #define HPI_GPIO_WRITE_STATUS           HPI_MAKE_INDEX(HPI_OBJ_GPIO, 5)
637 #define HPI_GPIO_FUNCTION_COUNT 5
638 /* ASYNC EVENT */
639 #define HPI_ASYNCEVENT_OPEN             HPI_MAKE_INDEX(HPI_OBJ_ASYNCEVENT, 1)
640 #define HPI_ASYNCEVENT_CLOSE            HPI_MAKE_INDEX(HPI_OBJ_ASYNCEVENT, 2)
641 #define HPI_ASYNCEVENT_WAIT             HPI_MAKE_INDEX(HPI_OBJ_ASYNCEVENT, 3)
642 #define HPI_ASYNCEVENT_GETCOUNT         HPI_MAKE_INDEX(HPI_OBJ_ASYNCEVENT, 4)
643 #define HPI_ASYNCEVENT_GET              HPI_MAKE_INDEX(HPI_OBJ_ASYNCEVENT, 5)
644 #define HPI_ASYNCEVENT_SENDEVENTS       HPI_MAKE_INDEX(HPI_OBJ_ASYNCEVENT, 6)
645 #define HPI_ASYNCEVENT_FUNCTION_COUNT 6
646 /* WATCH-DOG */
647 #define HPI_WATCHDOG_OPEN               HPI_MAKE_INDEX(HPI_OBJ_WATCHDOG, 1)
648 #define HPI_WATCHDOG_SET_TIME           HPI_MAKE_INDEX(HPI_OBJ_WATCHDOG, 2)
649 #define HPI_WATCHDOG_PING               HPI_MAKE_INDEX(HPI_OBJ_WATCHDOG, 3)
650 /* CLOCK */
651 #define HPI_CLOCK_OPEN                  HPI_MAKE_INDEX(HPI_OBJ_CLOCK, 1)
652 #define HPI_CLOCK_SET_TIME              HPI_MAKE_INDEX(HPI_OBJ_CLOCK, 2)
653 #define HPI_CLOCK_GET_TIME              HPI_MAKE_INDEX(HPI_OBJ_CLOCK, 3)
654 /* PROFILE */
655 #define HPI_PROFILE_OPEN_ALL            HPI_MAKE_INDEX(HPI_OBJ_PROFILE, 1)
656 #define HPI_PROFILE_START_ALL           HPI_MAKE_INDEX(HPI_OBJ_PROFILE, 2)
657 #define HPI_PROFILE_STOP_ALL            HPI_MAKE_INDEX(HPI_OBJ_PROFILE, 3)
658 #define HPI_PROFILE_GET                 HPI_MAKE_INDEX(HPI_OBJ_PROFILE, 4)
659 #define HPI_PROFILE_GET_IDLECOUNT       HPI_MAKE_INDEX(HPI_OBJ_PROFILE, 5)
660 #define HPI_PROFILE_GET_NAME            HPI_MAKE_INDEX(HPI_OBJ_PROFILE, 6)
661 #define HPI_PROFILE_GET_UTILIZATION     HPI_MAKE_INDEX(HPI_OBJ_PROFILE, 7)
662 #define HPI_PROFILE_FUNCTION_COUNT 7
663 /* ////////////////////////////////////////////////////////////////////// */
664 /* PRIVATE ATTRIBUTES */
665 
666 /* ////////////////////////////////////////////////////////////////////// */
667 /* STRUCTURES */
668 #ifndef DISABLE_PRAGMA_PACK1
669 #pragma pack(push, 1)
670 #endif
671 
672 /** PCI bus resource */
673 struct hpi_pci {
674 	u32 __iomem *ap_mem_base[HPI_MAX_ADAPTER_MEM_SPACES];
675 	struct pci_dev *p_os_data;
676 
677 #ifndef HPI64BIT		/* keep structure size constant */
678 	u32 padding[HPI_MAX_ADAPTER_MEM_SPACES + 1];
679 #endif
680 	u16 vendor_id;
681 	u16 device_id;
682 	u16 subsys_vendor_id;
683 	u16 subsys_device_id;
684 	u16 bus_number;
685 	u16 device_number;
686 	u32 interrupt;
687 };
688 
689 struct hpi_resource {
690 	union {
691 		const struct hpi_pci *pci;
692 		const char *net_if;
693 	} r;
694 #ifndef HPI64BIT		/* keep structure size constant */
695 	u32 pad_to64;
696 #endif
697 	u16 bus_type;		/* HPI_BUS_PNPISA, _PCI, _USB etc */
698 	u16 padding;
699 
700 };
701 
702 /** Format info used inside struct hpi_message
703     Not the same as public API struct hpi_format */
704 struct hpi_msg_format {
705 	u32 sample_rate;
706 				/**< 11025, 32000, 44100 ... */
707 	u32 bit_rate;	      /**< for MPEG */
708 	u32 attributes;
709 				/**< Stereo/JointStereo/Mono */
710 	u16 channels;	      /**< 1,2..., (or ancillary mode or idle bit */
711 	u16 format; /**< HPI_FORMAT_PCM16, _MPEG etc. see \ref HPI_FORMATS. */
712 };
713 
714 /**  Buffer+format structure.
715 	 Must be kept 7 * 32 bits to match public struct hpi_datastruct */
716 struct hpi_msg_data {
717 	struct hpi_msg_format format;
718 	u8 *pb_data;
719 #ifndef HPI64BIT
720 	u32 padding;
721 #endif
722 	u32 data_size;
723 };
724 
725 /** struct hpi_datastructure used up to 3.04 driver */
726 struct hpi_data_legacy32 {
727 	struct hpi_format format;
728 	u32 pb_data;
729 	u32 data_size;
730 };
731 
732 #ifdef HPI64BIT
733 /* Compatibility version of struct hpi_data*/
734 struct hpi_data_compat32 {
735 	struct hpi_msg_format format;
736 	u32 pb_data;
737 	u32 padding;
738 	u32 data_size;
739 };
740 #endif
741 
742 struct hpi_buffer {
743   /** placehoder for backward compatability (see dwBufferSize) */
744 	struct hpi_msg_format reserved;
745 	u32 command;	/**< HPI_BUFFER_CMD_xxx*/
746 	u32 pci_address; /**< PCI physical address of buffer for DSP DMA */
747 	u32 buffer_size; /**< must line up with data_size of HPI_DATA*/
748 };
749 
750 /*/////////////////////////////////////////////////////////////////////////// */
751 /* This is used for background buffer bus mastering stream buffers.           */
752 struct hpi_hostbuffer_status {
753 	u32 samples_processed;
754 	u32 auxiliary_data_available;
755 	u32 stream_state;
756 	/* DSP index in to the host bus master buffer. */
757 	u32 dSP_index;
758 	/* Host index in to the host bus master buffer. */
759 	u32 host_index;
760 	u32 size_in_bytes;
761 };
762 
763 struct hpi_streamid {
764 	u16 object_type;
765 		    /**< Type of object, HPI_OBJ_OSTREAM or HPI_OBJ_ISTREAM. */
766 	u16 stream_index; /**< outstream or instream index. */
767 };
768 
769 struct hpi_punchinout {
770 	u32 punch_in_sample;
771 	u32 punch_out_sample;
772 };
773 
774 struct hpi_subsys_msg {
775 	struct hpi_resource resource;
776 };
777 
778 struct hpi_subsys_res {
779 	u32 version;
780 	u32 data;		/* used to return extended version */
781 	u16 num_adapters;	/* number of adapters */
782 	u16 adapter_index;
783 	u16 aw_adapter_list[HPI_MAX_ADAPTERS];
784 };
785 
786 struct hpi_adapter_msg {
787 	u32 adapter_mode;	/* adapter mode */
788 	u16 assert_id;		/* assert number for "test assert" call
789 				   object_index for find object call
790 				   query_or_set for hpi_adapter_set_mode_ex() */
791 	u16 object_type;	/* for adapter find object call */
792 };
793 
794 union hpi_adapterx_msg {
795 	struct hpi_adapter_msg adapter;
796 	struct {
797 		u32 offset;
798 	} query_flash;
799 	struct {
800 		u32 offset;
801 		u32 length;
802 		u32 key;
803 	} start_flash;
804 	struct {
805 		u32 checksum;
806 		u16 sequence;
807 		u16 length;
808 		u16 offset; /**< offset from start of msg to data */
809 		u16 unused;
810 	} program_flash;
811 	struct {
812 		u16 property;
813 		u16 parameter1;
814 		u16 parameter2;
815 	} property_set;
816 	struct {
817 		u16 index;
818 		u16 what;
819 		u16 property_index;
820 	} property_enum;
821 	struct {
822 		u16 index;
823 	} module_info;
824 	struct {
825 		u32 dsp_address;
826 		u32 count_bytes;
827 	} debug_read;
828 };
829 
830 struct hpi_adapter_res {
831 	u32 serial_number;
832 	u16 adapter_type;
833 	u16 adapter_index;	/* is this needed? also used for dsp_index */
834 	u16 num_instreams;
835 	u16 num_outstreams;
836 	u16 num_mixers;
837 	u16 version;
838 	u8 sz_adapter_assert[HPI_STRING_LEN];
839 };
840 
841 union hpi_adapterx_res {
842 	struct hpi_adapter_res adapter;
843 	struct {
844 		u32 checksum;
845 		u32 length;
846 		u32 version;
847 	} query_flash;
848 	struct {
849 		u16 sequence;
850 	} program_flash;
851 	struct {
852 		u16 parameter1;
853 		u16 parameter2;
854 	} property_get;
855 };
856 
857 struct hpi_stream_msg {
858 	union {
859 		struct hpi_msg_data data;
860 		struct hpi_data_legacy32 data32;
861 		u16 velocity;
862 		struct hpi_punchinout pio;
863 		u32 time_scale;
864 		struct hpi_buffer buffer;
865 		struct hpi_streamid stream;
866 	} u;
867 };
868 
869 struct hpi_stream_res {
870 	union {
871 		struct {
872 			/* size of hardware buffer */
873 			u32 buffer_size;
874 			/* OutStream - data to play,
875 			   InStream - data recorded */
876 			u32 data_available;
877 			/* OutStream - samples played,
878 			   InStream - samples recorded */
879 			u32 samples_transferred;
880 			/* Adapter - OutStream - data to play,
881 			   InStream - data recorded */
882 			u32 auxiliary_data_available;
883 			u16 state;	/* HPI_STATE_PLAYING, _STATE_STOPPED */
884 			u16 padding;
885 		} stream_info;
886 		struct {
887 			u32 buffer_size;
888 			u32 data_available;
889 			u32 samples_transfered;
890 			u16 state;
891 			u16 outstream_index;
892 			u16 instream_index;
893 			u16 padding;
894 			u32 auxiliary_data_available;
895 		} legacy_stream_info;
896 		struct {
897 			/* bitmap of grouped OutStreams */
898 			u32 outstream_group_map;
899 			/* bitmap of grouped InStreams */
900 			u32 instream_group_map;
901 		} group_info;
902 		struct {
903 			/* pointer to the buffer */
904 			u8 *p_buffer;
905 			/* pointer to the hostbuffer status */
906 			struct hpi_hostbuffer_status *p_status;
907 		} hostbuffer_info;
908 	} u;
909 };
910 
911 struct hpi_mixer_msg {
912 	u16 control_index;
913 	u16 control_type;	/* = HPI_CONTROL_METER _VOLUME etc */
914 	u16 padding1;		/* maintain alignment of subsequent fields */
915 	u16 node_type1;		/* = HPI_SOURCENODE_LINEIN etc */
916 	u16 node_index1;	/* = 0..N */
917 	u16 node_type2;
918 	u16 node_index2;
919 	u16 padding2;		/* round to 4 bytes */
920 };
921 
922 struct hpi_mixer_res {
923 	u16 src_node_type;	/* = HPI_SOURCENODE_LINEIN etc */
924 	u16 src_node_index;	/* = 0..N */
925 	u16 dst_node_type;
926 	u16 dst_node_index;
927 	/* Also controlType for MixerGetControlByIndex */
928 	u16 control_index;
929 	/* may indicate which DSP the control is located on */
930 	u16 dsp_index;
931 };
932 
933 union hpi_mixerx_msg {
934 	struct {
935 		u16 starting_index;
936 		u16 flags;
937 		u32 length_in_bytes;	/* length in bytes of p_data */
938 		u32 p_data;	/* pointer to a data array */
939 	} gcabi;
940 	struct {
941 		u16 command;
942 		u16 index;
943 	} store;		/* for HPI_MIXER_STORE message */
944 };
945 
946 union hpi_mixerx_res {
947 	struct {
948 		u32 bytes_returned;	/* size of items returned */
949 		u32 p_data;	/* pointer to data array */
950 		u16 more_to_do;	/* indicates if there is more to do */
951 	} gcabi;
952 };
953 
954 struct hpi_control_msg {
955 	u16 attribute;		/* control attribute or property */
956 	u16 saved_index;
957 	u32 param1;		/* generic parameter 1 */
958 	u32 param2;		/* generic parameter 2 */
959 	short an_log_value[HPI_MAX_CHANNELS];
960 };
961 
962 struct hpi_control_union_msg {
963 	u16 attribute;		/* control attribute or property */
964 	u16 saved_index;	/* only used in ctrl save/restore */
965 	union {
966 		struct {
967 			u32 param1;	/* generic parameter 1 */
968 			u32 param2;	/* generic parameter 2 */
969 			short an_log_value[HPI_MAX_CHANNELS];
970 		} old;
971 		union {
972 			u32 frequency;
973 			u32 gain;
974 			u32 band;
975 			u32 deemphasis;
976 			u32 program;
977 			struct {
978 				u32 mode;
979 				u32 value;
980 			} mode;
981 			u32 blend;
982 		} tuner;
983 	} u;
984 };
985 
986 struct hpi_control_res {
987 	/* Could make union. dwParam, anLogValue never used in same response */
988 	u32 param1;
989 	u32 param2;
990 	short an_log_value[HPI_MAX_CHANNELS];
991 };
992 
993 union hpi_control_union_res {
994 	struct {
995 		u32 param1;
996 		u32 param2;
997 		short an_log_value[HPI_MAX_CHANNELS];
998 	} old;
999 	union {
1000 		u32 band;
1001 		u32 frequency;
1002 		u32 gain;
1003 		u32 level;
1004 		u32 deemphasis;
1005 		struct {
1006 			u32 data[2];
1007 			u32 bLER;
1008 		} rds;
1009 	} tuner;
1010 	struct {
1011 		char sz_data[8];
1012 		u32 remaining_chars;
1013 	} chars8;
1014 	char c_data12[12];
1015 };
1016 
1017 /* HPI_CONTROLX_STRUCTURES */
1018 
1019 /* Message */
1020 
1021 /** Used for all HMI variables where max length <= 8 bytes
1022 */
1023 struct hpi_controlx_msg_cobranet_data {
1024 	u32 hmi_address;
1025 	u32 byte_count;
1026 	u32 data[2];
1027 };
1028 
1029 /** Used for string data, and for packet bridge
1030 */
1031 struct hpi_controlx_msg_cobranet_bigdata {
1032 	u32 hmi_address;
1033 	u32 byte_count;
1034 	u8 *pb_data;
1035 #ifndef HPI64BIT
1036 	u32 padding;
1037 #endif
1038 };
1039 
1040 /** Used for PADS control reading of string fields.
1041 */
1042 struct hpi_controlx_msg_pad_data {
1043 	u32 field;
1044 	u32 byte_count;
1045 	u8 *pb_data;
1046 #ifndef HPI64BIT
1047 	u32 padding;
1048 #endif
1049 };
1050 
1051 /** Used for generic data
1052 */
1053 
1054 struct hpi_controlx_msg_generic {
1055 	u32 param1;
1056 	u32 param2;
1057 };
1058 
1059 struct hpi_controlx_msg {
1060 	u16 attribute;		/* control attribute or property */
1061 	u16 saved_index;
1062 	union {
1063 		struct hpi_controlx_msg_cobranet_data cobranet_data;
1064 		struct hpi_controlx_msg_cobranet_bigdata cobranet_bigdata;
1065 		struct hpi_controlx_msg_generic generic;
1066 		struct hpi_controlx_msg_pad_data pad_data;
1067 		/*struct param_value universal_value; */
1068 		/* nothing extra to send for status read */
1069 	} u;
1070 };
1071 
1072 /* Response */
1073 /**
1074 */
1075 struct hpi_controlx_res_cobranet_data {
1076 	u32 byte_count;
1077 	u32 data[2];
1078 };
1079 
1080 struct hpi_controlx_res_cobranet_bigdata {
1081 	u32 byte_count;
1082 };
1083 
1084 struct hpi_controlx_res_cobranet_status {
1085 	u32 status;
1086 	u32 readable_size;
1087 	u32 writeable_size;
1088 };
1089 
1090 struct hpi_controlx_res_generic {
1091 	u32 param1;
1092 	u32 param2;
1093 };
1094 
1095 struct hpi_controlx_res {
1096 	union {
1097 		struct hpi_controlx_res_cobranet_bigdata cobranet_bigdata;
1098 		struct hpi_controlx_res_cobranet_data cobranet_data;
1099 		struct hpi_controlx_res_cobranet_status cobranet_status;
1100 		struct hpi_controlx_res_generic generic;
1101 		/*struct param_info universal_info; */
1102 		/*struct param_value universal_value; */
1103 	} u;
1104 };
1105 
1106 struct hpi_nvmemory_msg {
1107 	u16 address;
1108 	u16 data;
1109 };
1110 
1111 struct hpi_nvmemory_res {
1112 	u16 size_in_bytes;
1113 	u16 data;
1114 };
1115 
1116 struct hpi_gpio_msg {
1117 	u16 bit_index;
1118 	u16 bit_data;
1119 };
1120 
1121 struct hpi_gpio_res {
1122 	u16 number_input_bits;
1123 	u16 number_output_bits;
1124 	u16 bit_data[4];
1125 };
1126 
1127 struct hpi_async_msg {
1128 	u32 events;
1129 	u16 maximum_events;
1130 	u16 padding;
1131 };
1132 
1133 struct hpi_async_res {
1134 	union {
1135 		struct {
1136 			u16 count;
1137 		} count;
1138 		struct {
1139 			u32 events;
1140 			u16 number_returned;
1141 			u16 padding;
1142 		} get;
1143 		struct hpi_async_event event;
1144 	} u;
1145 };
1146 
1147 struct hpi_watchdog_msg {
1148 	u32 time_ms;
1149 };
1150 
1151 struct hpi_watchdog_res {
1152 	u32 time_ms;
1153 };
1154 
1155 struct hpi_clock_msg {
1156 	u16 hours;
1157 	u16 minutes;
1158 	u16 seconds;
1159 	u16 milli_seconds;
1160 };
1161 
1162 struct hpi_clock_res {
1163 	u16 size_in_bytes;
1164 	u16 hours;
1165 	u16 minutes;
1166 	u16 seconds;
1167 	u16 milli_seconds;
1168 	u16 padding;
1169 };
1170 
1171 struct hpi_profile_msg {
1172 	u16 bin_index;
1173 	u16 padding;
1174 };
1175 
1176 struct hpi_profile_res_open {
1177 	u16 max_profiles;
1178 };
1179 
1180 struct hpi_profile_res_time {
1181 	u32 micro_seconds;
1182 	u32 call_count;
1183 	u32 max_micro_seconds;
1184 	u32 min_micro_seconds;
1185 	u16 seconds;
1186 };
1187 
1188 struct hpi_profile_res_name {
1189 	u8 sz_name[32];
1190 };
1191 
1192 struct hpi_profile_res {
1193 	union {
1194 		struct hpi_profile_res_open o;
1195 		struct hpi_profile_res_time t;
1196 		struct hpi_profile_res_name n;
1197 	} u;
1198 };
1199 
1200 struct hpi_message_header {
1201 	u16 size;		/* total size in bytes */
1202 	u8 type;		/* HPI_TYPE_MESSAGE  */
1203 	u8 version;		/* message version */
1204 	u16 object;		/* HPI_OBJ_* */
1205 	u16 function;		/* HPI_SUBSYS_xxx, HPI_ADAPTER_xxx */
1206 	u16 adapter_index;	/* the adapter index */
1207 	u16 obj_index;		/* */
1208 };
1209 
1210 struct hpi_message {
1211 	/* following fields must match HPI_MESSAGE_HEADER */
1212 	u16 size;		/* total size in bytes */
1213 	u8 type;		/* HPI_TYPE_MESSAGE  */
1214 	u8 version;		/* message version */
1215 	u16 object;		/* HPI_OBJ_* */
1216 	u16 function;		/* HPI_SUBSYS_xxx, HPI_ADAPTER_xxx */
1217 	u16 adapter_index;	/* the adapter index */
1218 	u16 obj_index;		/*  */
1219 	union {
1220 		struct hpi_subsys_msg s;
1221 		struct hpi_adapter_msg a;
1222 		union hpi_adapterx_msg ax;
1223 		struct hpi_stream_msg d;
1224 		struct hpi_mixer_msg m;
1225 		union hpi_mixerx_msg mx;	/* extended mixer; */
1226 		struct hpi_control_msg c;	/* mixer control; */
1227 		/* identical to struct hpi_control_msg,
1228 		   but field naming is improved */
1229 		struct hpi_control_union_msg cu;
1230 		struct hpi_controlx_msg cx;	/* extended mixer control; */
1231 		struct hpi_nvmemory_msg n;
1232 		struct hpi_gpio_msg l;	/* digital i/o */
1233 		struct hpi_watchdog_msg w;
1234 		struct hpi_clock_msg t;	/* dsp time */
1235 		struct hpi_profile_msg p;
1236 		struct hpi_async_msg as;
1237 		char fixed_size[32];
1238 	} u;
1239 };
1240 
1241 #define HPI_MESSAGE_SIZE_BY_OBJECT { \
1242 	sizeof(struct hpi_message_header) ,   /* default, no object type 0 */ \
1243 	sizeof(struct hpi_message_header) + sizeof(struct hpi_subsys_msg),\
1244 	sizeof(struct hpi_message_header) + sizeof(union hpi_adapterx_msg),\
1245 	sizeof(struct hpi_message_header) + sizeof(struct hpi_stream_msg),\
1246 	sizeof(struct hpi_message_header) + sizeof(struct hpi_stream_msg),\
1247 	sizeof(struct hpi_message_header) + sizeof(struct hpi_mixer_msg),\
1248 	sizeof(struct hpi_message_header) ,   /* no node message */ \
1249 	sizeof(struct hpi_message_header) + sizeof(struct hpi_control_msg),\
1250 	sizeof(struct hpi_message_header) + sizeof(struct hpi_nvmemory_msg),\
1251 	sizeof(struct hpi_message_header) + sizeof(struct hpi_gpio_msg),\
1252 	sizeof(struct hpi_message_header) + sizeof(struct hpi_watchdog_msg),\
1253 	sizeof(struct hpi_message_header) + sizeof(struct hpi_clock_msg),\
1254 	sizeof(struct hpi_message_header) + sizeof(struct hpi_profile_msg),\
1255 	sizeof(struct hpi_message_header) + sizeof(struct hpi_controlx_msg),\
1256 	sizeof(struct hpi_message_header) + sizeof(struct hpi_async_msg) \
1257 }
1258 
1259 struct hpi_response_header {
1260 	u16 size;
1261 	u8 type;		/* HPI_TYPE_RESPONSE  */
1262 	u8 version;		/* response version */
1263 	u16 object;		/* HPI_OBJ_* */
1264 	u16 function;		/* HPI_SUBSYS_xxx, HPI_ADAPTER_xxx */
1265 	u16 error;		/* HPI_ERROR_xxx */
1266 	u16 specific_error;	/* adapter specific error */
1267 };
1268 
1269 struct hpi_response {
1270 /* following fields must match HPI_RESPONSE_HEADER */
1271 	u16 size;
1272 	u8 type;		/* HPI_TYPE_RESPONSE  */
1273 	u8 version;		/* response version */
1274 	u16 object;		/* HPI_OBJ_* */
1275 	u16 function;		/* HPI_SUBSYS_xxx, HPI_ADAPTER_xxx */
1276 	u16 error;		/* HPI_ERROR_xxx */
1277 	u16 specific_error;	/* adapter specific error */
1278 	union {
1279 		struct hpi_subsys_res s;
1280 		struct hpi_adapter_res a;
1281 		union hpi_adapterx_res ax;
1282 		struct hpi_stream_res d;
1283 		struct hpi_mixer_res m;
1284 		union hpi_mixerx_res mx;	/* extended mixer; */
1285 		struct hpi_control_res c;	/* mixer control; */
1286 		/* identical to hpi_control_res, but field naming is improved */
1287 		union hpi_control_union_res cu;
1288 		struct hpi_controlx_res cx;	/* extended mixer control; */
1289 		struct hpi_nvmemory_res n;
1290 		struct hpi_gpio_res l;	/* digital i/o */
1291 		struct hpi_watchdog_res w;
1292 		struct hpi_clock_res t;	/* dsp time */
1293 		struct hpi_profile_res p;
1294 		struct hpi_async_res as;
1295 		u8 bytes[52];
1296 	} u;
1297 };
1298 
1299 #define HPI_RESPONSE_SIZE_BY_OBJECT { \
1300 	sizeof(struct hpi_response_header) ,/* default, no object type 0 */ \
1301 	sizeof(struct hpi_response_header) + sizeof(struct hpi_subsys_res),\
1302 	sizeof(struct hpi_response_header) + sizeof(union  hpi_adapterx_res),\
1303 	sizeof(struct hpi_response_header) + sizeof(struct hpi_stream_res),\
1304 	sizeof(struct hpi_response_header) + sizeof(struct hpi_stream_res),\
1305 	sizeof(struct hpi_response_header) + sizeof(struct hpi_mixer_res),\
1306 	sizeof(struct hpi_response_header) , /* no node response */ \
1307 	sizeof(struct hpi_response_header) + sizeof(struct hpi_control_res),\
1308 	sizeof(struct hpi_response_header) + sizeof(struct hpi_nvmemory_res),\
1309 	sizeof(struct hpi_response_header) + sizeof(struct hpi_gpio_res),\
1310 	sizeof(struct hpi_response_header) + sizeof(struct hpi_watchdog_res),\
1311 	sizeof(struct hpi_response_header) + sizeof(struct hpi_clock_res),\
1312 	sizeof(struct hpi_response_header) + sizeof(struct hpi_profile_res),\
1313 	sizeof(struct hpi_response_header) + sizeof(struct hpi_controlx_res),\
1314 	sizeof(struct hpi_response_header) + sizeof(struct hpi_async_res) \
1315 }
1316 
1317 /*********************** version 1 message/response *****************************/
1318 #define HPINET_ETHERNET_DATA_SIZE (1500)
1319 #define HPINET_IP_HDR_SIZE (20)
1320 #define HPINET_IP_DATA_SIZE (HPINET_ETHERNET_DATA_SIZE - HPINET_IP_HDR_SIZE)
1321 #define HPINET_UDP_HDR_SIZE (8)
1322 #define HPINET_UDP_DATA_SIZE (HPINET_IP_DATA_SIZE - HPINET_UDP_HDR_SIZE)
1323 #define HPINET_ASI_HDR_SIZE (2)
1324 #define HPINET_ASI_DATA_SIZE (HPINET_UDP_DATA_SIZE - HPINET_ASI_HDR_SIZE)
1325 
1326 #define HPI_MAX_PAYLOAD_SIZE (HPINET_ASI_DATA_SIZE - 2)
1327 
1328 /* New style message/response, but still V0 compatible */
1329 struct hpi_msg_adapter_get_info {
1330 	struct hpi_message_header h;
1331 };
1332 
1333 struct hpi_res_adapter_get_info {
1334 	struct hpi_response_header h;	/*v0 */
1335 	struct hpi_adapter_res p;
1336 };
1337 
1338 /* padding is so these are same size as v0 hpi_message */
1339 struct hpi_msg_adapter_query_flash {
1340 	struct hpi_message_header h;
1341 	u32 offset;
1342 	u8 pad_to_version0_size[sizeof(struct hpi_message) -	/* V0 res */
1343 		sizeof(struct hpi_message_header) - 1 * sizeof(u32)];
1344 };
1345 
1346 /* padding is so these are same size as v0 hpi_response */
1347 struct hpi_res_adapter_query_flash {
1348 	struct hpi_response_header h;
1349 	u32 checksum;
1350 	u32 length;
1351 	u32 version;
1352 	u8 pad_to_version0_size[sizeof(struct hpi_response) -	/* V0 res */
1353 		sizeof(struct hpi_response_header) - 3 * sizeof(u32)];
1354 };
1355 
1356 struct hpi_msg_adapter_start_flash {
1357 	struct hpi_message_header h;
1358 	u32 offset;
1359 	u32 length;
1360 	u32 key;
1361 	u8 pad_to_version0_size[sizeof(struct hpi_message) -	/* V0 res */
1362 		sizeof(struct hpi_message_header) - 3 * sizeof(u32)];
1363 };
1364 
1365 struct hpi_res_adapter_start_flash {
1366 	struct hpi_response_header h;
1367 	u8 pad_to_version0_size[sizeof(struct hpi_response) -	/* V0 res */
1368 		sizeof(struct hpi_response_header)];
1369 };
1370 
1371 struct hpi_msg_adapter_program_flash_payload {
1372 	u32 checksum;
1373 	u16 sequence;
1374 	u16 length;
1375 	u16 offset; /**< offset from start of msg to data */
1376 	u16 unused;
1377 	/* ensure sizeof(header + payload) == sizeof(hpi_message_V0)
1378 	   because old firmware expects data after message of this size */
1379 	u8 pad_to_version0_size[sizeof(struct hpi_message) -	/* V0 message */
1380 		sizeof(struct hpi_message_header) - sizeof(u32) -
1381 		4 * sizeof(u16)];
1382 };
1383 
1384 struct hpi_msg_adapter_program_flash {
1385 	struct hpi_message_header h;
1386 	struct hpi_msg_adapter_program_flash_payload p;
1387 	u32 data[256];
1388 };
1389 
1390 struct hpi_res_adapter_program_flash {
1391 	struct hpi_response_header h;
1392 	u16 sequence;
1393 	u8 pad_to_version0_size[sizeof(struct hpi_response) -	/* V0 res */
1394 		sizeof(struct hpi_response_header) - sizeof(u16)];
1395 };
1396 
1397 #if 1
1398 #define hpi_message_header_v1 hpi_message_header
1399 #define hpi_response_header_v1 hpi_response_header
1400 #else
1401 /* V1 headers in Addition to v0 headers */
1402 struct hpi_message_header_v1 {
1403 	struct hpi_message_header h0;
1404 /* struct {
1405 } h1; */
1406 };
1407 
1408 struct hpi_response_header_v1 {
1409 	struct hpi_response_header h0;
1410 	struct {
1411 		u16 adapter_index;	/* the adapter index */
1412 		u16 obj_index;	/* object index */
1413 	} h1;
1414 };
1415 #endif
1416 
1417 /* STRV HPI Packet */
1418 struct hpi_msg_strv {
1419 	struct hpi_message_header h;
1420 	struct hpi_entity strv;
1421 };
1422 
1423 struct hpi_res_strv {
1424 	struct hpi_response_header h;
1425 	struct hpi_entity strv;
1426 };
1427 #define MIN_STRV_PACKET_SIZE sizeof(struct hpi_res_strv)
1428 
1429 struct hpi_msg_payload_v0 {
1430 	struct hpi_message_header h;
1431 	union {
1432 		struct hpi_subsys_msg s;
1433 		struct hpi_adapter_msg a;
1434 		union hpi_adapterx_msg ax;
1435 		struct hpi_stream_msg d;
1436 		struct hpi_mixer_msg m;
1437 		union hpi_mixerx_msg mx;
1438 		struct hpi_control_msg c;
1439 		struct hpi_control_union_msg cu;
1440 		struct hpi_controlx_msg cx;
1441 		struct hpi_nvmemory_msg n;
1442 		struct hpi_gpio_msg l;
1443 		struct hpi_watchdog_msg w;
1444 		struct hpi_clock_msg t;
1445 		struct hpi_profile_msg p;
1446 		struct hpi_async_msg as;
1447 	} u;
1448 };
1449 
1450 struct hpi_res_payload_v0 {
1451 	struct hpi_response_header h;
1452 	union {
1453 		struct hpi_subsys_res s;
1454 		struct hpi_adapter_res a;
1455 		union hpi_adapterx_res ax;
1456 		struct hpi_stream_res d;
1457 		struct hpi_mixer_res m;
1458 		union hpi_mixerx_res mx;
1459 		struct hpi_control_res c;
1460 		union hpi_control_union_res cu;
1461 		struct hpi_controlx_res cx;
1462 		struct hpi_nvmemory_res n;
1463 		struct hpi_gpio_res l;
1464 		struct hpi_watchdog_res w;
1465 		struct hpi_clock_res t;
1466 		struct hpi_profile_res p;
1467 		struct hpi_async_res as;
1468 	} u;
1469 };
1470 
1471 union hpi_message_buffer_v1 {
1472 	struct hpi_message m0;	/* version 0 */
1473 	struct hpi_message_header_v1 h;
1474 	unsigned char buf[HPI_MAX_PAYLOAD_SIZE];
1475 };
1476 
1477 union hpi_response_buffer_v1 {
1478 	struct hpi_response r0;	/* version 0 */
1479 	struct hpi_response_header_v1 h;
1480 	unsigned char buf[HPI_MAX_PAYLOAD_SIZE];
1481 };
1482 
1483 compile_time_assert((sizeof(union hpi_message_buffer_v1) <=
1484 		HPI_MAX_PAYLOAD_SIZE), message_buffer_ok);
1485 compile_time_assert((sizeof(union hpi_response_buffer_v1) <=
1486 		HPI_MAX_PAYLOAD_SIZE), response_buffer_ok);
1487 
1488 /*////////////////////////////////////////////////////////////////////////// */
1489 /* declarations for compact control calls  */
1490 struct hpi_control_defn {
1491 	u8 type;
1492 	u8 channels;
1493 	u8 src_node_type;
1494 	u8 src_node_index;
1495 	u8 dest_node_type;
1496 	u8 dest_node_index;
1497 };
1498 
1499 /*////////////////////////////////////////////////////////////////////////// */
1500 /* declarations for control caching (internal to HPI<->DSP interaction)      */
1501 
1502 /** A compact representation of (part of) a controls state.
1503 Used for efficient transfer of the control state
1504 between DSP and host or across a network
1505 */
1506 struct hpi_control_cache_info {
1507 	/** one of HPI_CONTROL_* */
1508 	u8 control_type;
1509 	/** The total size of cached information in 32-bit words. */
1510 	u8 size_in32bit_words;
1511 	/** The original index of the control on the DSP */
1512 	u16 control_index;
1513 };
1514 
1515 struct hpi_control_cache_single {
1516 	struct hpi_control_cache_info i;
1517 	union {
1518 		struct {	/* volume */
1519 			short an_log[2];
1520 		} v;
1521 		struct {	/* peak meter */
1522 			short an_log_peak[2];
1523 			short an_logRMS[2];
1524 		} p;
1525 		struct {	/* channel mode */
1526 			u16 mode;
1527 		} m;
1528 		struct {	/* multiplexer */
1529 			u16 source_node_type;
1530 			u16 source_node_index;
1531 		} x;
1532 		struct {	/* level/trim */
1533 			short an_log[2];
1534 		} l;
1535 		struct {	/* tuner - partial caching.
1536 				   some attributes go to the DSP. */
1537 			u32 freq_ink_hz;
1538 			u16 band;
1539 			u16 level;
1540 		} t;
1541 		struct {	/* AESEBU rx status */
1542 			u32 error_status;
1543 			u32 source;
1544 		} aes3rx;
1545 		struct {	/* AESEBU tx */
1546 			u32 format;
1547 		} aes3tx;
1548 		struct {	/* tone detector */
1549 			u16 state;
1550 		} tone;
1551 		struct {	/* silence detector */
1552 			u32 state;
1553 			u32 count;
1554 		} silence;
1555 		struct {	/* sample clock */
1556 			u16 source;
1557 			u16 source_index;
1558 			u32 sample_rate;
1559 		} clk;
1560 		struct {	/* microphone control */
1561 			u16 state;
1562 		} phantom_power;
1563 		struct {	/* generic control */
1564 			u32 dw1;
1565 			u32 dw2;
1566 		} g;
1567 	} u;
1568 };
1569 
1570 struct hpi_control_cache_pad {
1571 	struct hpi_control_cache_info i;
1572 	u32 field_valid_flags;
1573 	u8 c_channel[8];
1574 	u8 c_artist[40];
1575 	u8 c_title[40];
1576 	u8 c_comment[200];
1577 	u32 pTY;
1578 	u32 pI;
1579 	u32 traffic_supported;
1580 	u32 traffic_anouncement;
1581 };
1582 
1583 /*/////////////////////////////////////////////////////////////////////////// */
1584 /* declarations for 2^N sized FIFO buffer (internal to HPI<->DSP interaction) */
1585 struct hpi_fifo_buffer {
1586 	u32 size;
1587 	u32 dSP_index;
1588 	u32 host_index;
1589 };
1590 
1591 #ifndef DISABLE_PRAGMA_PACK1
1592 #pragma pack(pop)
1593 #endif
1594 
1595 /* skip host side function declarations for DSP
1596    compile and documentation extraction */
1597 
1598 char hpi_handle_object(const u32 handle);
1599 
1600 void hpi_handle_to_indexes(const u32 handle, u16 *pw_adapter_index,
1601 	u16 *pw_object_index);
1602 
1603 u32 hpi_indexes_to_handle(const char c_object, const u16 adapter_index,
1604 	const u16 object_index);
1605 
1606 /*////////////////////////////////////////////////////////////////////////// */
1607 
1608 /* main HPI entry point */
1609 hpi_handler_func hpi_send_recv;
1610 
1611 /* UDP message */
1612 void hpi_send_recvUDP(struct hpi_message *phm, struct hpi_response *phr,
1613 	const unsigned int timeout);
1614 
1615 /* used in PnP OS/driver */
1616 u16 hpi_subsys_create_adapter(const struct hpi_hsubsys *ph_subsys,
1617 	const struct hpi_resource *p_resource, u16 *pw_adapter_index);
1618 
1619 u16 hpi_subsys_delete_adapter(const struct hpi_hsubsys *ph_subsys,
1620 	u16 adapter_index);
1621 
1622 u16 hpi_outstream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys,
1623 	u32 h_outstream, u8 **pp_buffer,
1624 	struct hpi_hostbuffer_status **pp_status);
1625 
1626 u16 hpi_instream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys,
1627 	u32 h_instream, u8 **pp_buffer,
1628 	struct hpi_hostbuffer_status **pp_status);
1629 
1630 u16 hpi_adapter_restart(u16 adapter_index);
1631 
1632 /*
1633 The following 3 functions were last declared in header files for
1634 driver 3.10. HPI_ControlQuery() used to be the recommended way
1635 of getting a volume range. Declared here for binary asihpi32.dll
1636 compatibility.
1637 */
1638 
1639 void hpi_format_to_msg(struct hpi_msg_format *pMF,
1640 	const struct hpi_format *pF);
1641 void hpi_stream_response_to_legacy(struct hpi_stream_res *pSR);
1642 
1643 /*////////////////////////////////////////////////////////////////////////// */
1644 /* declarations for individual HPI entry points */
1645 hpi_handler_func HPI_1000;
1646 hpi_handler_func HPI_6000;
1647 hpi_handler_func HPI_6205;
1648 hpi_handler_func HPI_COMMON;
1649 
1650 #endif				/* _HPI_INTERNAL_H_ */
1651