Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /******************************************************************************
0003 
0004     AudioScience HPI driver
0005     Copyright (C) 1997-2012  AudioScience Inc. <support@audioscience.com>
0006 
0007 
0008 HPI internal definitions
0009 
0010 (C) Copyright AudioScience Inc. 1996-2009
0011 ******************************************************************************/
0012 
0013 #ifndef _HPI_INTERNAL_H_
0014 #define _HPI_INTERNAL_H_
0015 
0016 #include "hpi.h"
0017 
0018 /** maximum number of memory regions mapped to an adapter */
0019 #define HPI_MAX_ADAPTER_MEM_SPACES (2)
0020 
0021 /* Each OS needs its own hpios.h */
0022 #include "hpios.h"
0023 
0024 /* physical memory allocation */
0025 
0026 /** Allocate and map an area of locked memory for bus master DMA operations.
0027 
0028 On success, *pLockedMemeHandle is a valid handle, and 0 is returned
0029 On error *pLockedMemHandle marked invalid, non-zero returned.
0030 
0031 If this function succeeds, then HpiOs_LockedMem_GetVirtAddr() and
0032 HpiOs_LockedMem_GetPyhsAddr() will always succed on the returned handle.
0033 */
0034 u16 hpios_locked_mem_alloc(struct consistent_dma_area *p_locked_mem_handle,
0035                                /**< memory handle */
0036     u32 size, /**< Size in bytes to allocate */
0037     struct pci_dev *p_os_reference
0038     /**< OS specific data required for memory allocation */
0039     );
0040 
0041 /** Free mapping and memory represented by LockedMemHandle
0042 
0043 Frees any resources, then invalidates the handle.
0044 Returns 0 on success, 1 if handle is invalid.
0045 
0046 */
0047 u16 hpios_locked_mem_free(struct consistent_dma_area *locked_mem_handle);
0048 
0049 /** Get the physical PCI address of memory represented by LockedMemHandle.
0050 
0051 If handle is invalid *pPhysicalAddr is set to zero and return 1
0052 */
0053 u16 hpios_locked_mem_get_phys_addr(struct consistent_dma_area
0054     *locked_mem_handle, u32 *p_physical_addr);
0055 
0056 /** Get the CPU address of memory represented by LockedMemHandle.
0057 
0058 If handle is NULL *ppvVirtualAddr is set to NULL and return 1
0059 */
0060 u16 hpios_locked_mem_get_virt_addr(struct consistent_dma_area
0061     *locked_mem_handle, void **ppv_virtual_addr);
0062 
0063 /** Check that handle is valid
0064 i.e it represents a valid memory area
0065 */
0066 u16 hpios_locked_mem_valid(struct consistent_dma_area *locked_mem_handle);
0067 
0068 /* timing/delay */
0069 void hpios_delay_micro_seconds(u32 num_micro_sec);
0070 
0071 struct hpi_message;
0072 struct hpi_response;
0073 
0074 typedef void hpi_handler_func(struct hpi_message *, struct hpi_response *);
0075 
0076 /* If the assert fails, compiler complains
0077    something like size of array `msg' is negative.
0078    Unlike linux BUILD_BUG_ON, this works outside function scope.
0079 */
0080 #define compile_time_assert(cond, msg) \
0081     typedef char ASSERT_##msg[(cond) ? 1 : -1]
0082 
0083 /******************************************* bus types */
0084 enum HPI_BUSES {
0085     HPI_BUS_ISAPNP = 1,
0086     HPI_BUS_PCI = 2,
0087     HPI_BUS_USB = 3,
0088     HPI_BUS_NET = 4
0089 };
0090 
0091 enum HPI_SUBSYS_OPTIONS {
0092     /* 0, 256 are invalid, 1..255 reserved for global options */
0093     HPI_SUBSYS_OPT_NET_ENABLE = 257,
0094     HPI_SUBSYS_OPT_NET_BROADCAST = 258,
0095     HPI_SUBSYS_OPT_NET_UNICAST = 259,
0096     HPI_SUBSYS_OPT_NET_ADDR = 260,
0097     HPI_SUBSYS_OPT_NET_MASK = 261,
0098     HPI_SUBSYS_OPT_NET_ADAPTER_ADDRESS_ADD = 262
0099 };
0100 
0101 /** Volume flags
0102 */
0103 enum HPI_VOLUME_FLAGS {
0104     /** Set if the volume control is muted */
0105     HPI_VOLUME_FLAG_MUTED = (1 << 0),
0106     /** Set if the volume control has a mute function */
0107     HPI_VOLUME_FLAG_HAS_MUTE = (1 << 1),
0108     /** Set if volume control can do autofading */
0109     HPI_VOLUME_FLAG_HAS_AUTOFADE = (1 << 2)
0110         /* Note Flags >= (1<<8) are for DSP internal use only */
0111 };
0112 
0113 /******************************************* CONTROL ATTRIBUTES ****/
0114 /* (in order of control type ID */
0115 
0116 /* This allows for 255 control types, 256 unique attributes each */
0117 #define HPI_CTL_ATTR(ctl, ai) ((HPI_CONTROL_##ctl << 8) + ai)
0118 
0119 /* Get the sub-index of the attribute for a control type */
0120 #define HPI_CTL_ATTR_INDEX(i) (i & 0xff)
0121 
0122 /* Extract the control from the control attribute */
0123 #define HPI_CTL_ATTR_CONTROL(i) (i >> 8)
0124 
0125 /** Enable event generation for a control.
0126 0=disable, 1=enable
0127 \note generic to all controls that can generate events
0128 */
0129 
0130 /** Unique identifiers for every control attribute
0131 */
0132 enum HPI_CONTROL_ATTRIBUTES {
0133     HPI_GENERIC_ENABLE = HPI_CTL_ATTR(GENERIC, 1),
0134     HPI_GENERIC_EVENT_ENABLE = HPI_CTL_ATTR(GENERIC, 2),
0135 
0136     HPI_VOLUME_GAIN = HPI_CTL_ATTR(VOLUME, 1),
0137     HPI_VOLUME_AUTOFADE = HPI_CTL_ATTR(VOLUME, 2),
0138     HPI_VOLUME_MUTE = HPI_CTL_ATTR(VOLUME, 3),
0139     HPI_VOLUME_GAIN_AND_FLAGS = HPI_CTL_ATTR(VOLUME, 4),
0140     HPI_VOLUME_NUM_CHANNELS = HPI_CTL_ATTR(VOLUME, 6),
0141     HPI_VOLUME_RANGE = HPI_CTL_ATTR(VOLUME, 10),
0142 
0143     HPI_METER_RMS = HPI_CTL_ATTR(METER, 1),
0144     HPI_METER_PEAK = HPI_CTL_ATTR(METER, 2),
0145     HPI_METER_RMS_BALLISTICS = HPI_CTL_ATTR(METER, 3),
0146     HPI_METER_PEAK_BALLISTICS = HPI_CTL_ATTR(METER, 4),
0147     HPI_METER_NUM_CHANNELS = HPI_CTL_ATTR(METER, 5),
0148 
0149     HPI_MULTIPLEXER_SOURCE = HPI_CTL_ATTR(MULTIPLEXER, 1),
0150     HPI_MULTIPLEXER_QUERYSOURCE = HPI_CTL_ATTR(MULTIPLEXER, 2),
0151 
0152     HPI_AESEBUTX_FORMAT = HPI_CTL_ATTR(AESEBUTX, 1),
0153     HPI_AESEBUTX_SAMPLERATE = HPI_CTL_ATTR(AESEBUTX, 3),
0154     HPI_AESEBUTX_CHANNELSTATUS = HPI_CTL_ATTR(AESEBUTX, 4),
0155     HPI_AESEBUTX_USERDATA = HPI_CTL_ATTR(AESEBUTX, 5),
0156 
0157     HPI_AESEBURX_FORMAT = HPI_CTL_ATTR(AESEBURX, 1),
0158     HPI_AESEBURX_ERRORSTATUS = HPI_CTL_ATTR(AESEBURX, 2),
0159     HPI_AESEBURX_SAMPLERATE = HPI_CTL_ATTR(AESEBURX, 3),
0160     HPI_AESEBURX_CHANNELSTATUS = HPI_CTL_ATTR(AESEBURX, 4),
0161     HPI_AESEBURX_USERDATA = HPI_CTL_ATTR(AESEBURX, 5),
0162 
0163     HPI_LEVEL_GAIN = HPI_CTL_ATTR(LEVEL, 1),
0164     HPI_LEVEL_RANGE = HPI_CTL_ATTR(LEVEL, 10),
0165 
0166     HPI_TUNER_BAND = HPI_CTL_ATTR(TUNER, 1),
0167     HPI_TUNER_FREQ = HPI_CTL_ATTR(TUNER, 2),
0168     HPI_TUNER_LEVEL_AVG = HPI_CTL_ATTR(TUNER, 3),
0169     HPI_TUNER_LEVEL_RAW = HPI_CTL_ATTR(TUNER, 4),
0170     HPI_TUNER_SNR = HPI_CTL_ATTR(TUNER, 5),
0171     HPI_TUNER_GAIN = HPI_CTL_ATTR(TUNER, 6),
0172     HPI_TUNER_STATUS = HPI_CTL_ATTR(TUNER, 7),
0173     HPI_TUNER_MODE = HPI_CTL_ATTR(TUNER, 8),
0174     HPI_TUNER_RDS = HPI_CTL_ATTR(TUNER, 9),
0175     HPI_TUNER_DEEMPHASIS = HPI_CTL_ATTR(TUNER, 10),
0176     HPI_TUNER_PROGRAM = HPI_CTL_ATTR(TUNER, 11),
0177     HPI_TUNER_HDRADIO_SIGNAL_QUALITY = HPI_CTL_ATTR(TUNER, 12),
0178     HPI_TUNER_HDRADIO_SDK_VERSION = HPI_CTL_ATTR(TUNER, 13),
0179     HPI_TUNER_HDRADIO_DSP_VERSION = HPI_CTL_ATTR(TUNER, 14),
0180     HPI_TUNER_HDRADIO_BLEND = HPI_CTL_ATTR(TUNER, 15),
0181 
0182     HPI_VOX_THRESHOLD = HPI_CTL_ATTR(VOX, 1),
0183 
0184     HPI_CHANNEL_MODE_MODE = HPI_CTL_ATTR(CHANNEL_MODE, 1),
0185 
0186     HPI_BITSTREAM_DATA_POLARITY = HPI_CTL_ATTR(BITSTREAM, 1),
0187     HPI_BITSTREAM_CLOCK_EDGE = HPI_CTL_ATTR(BITSTREAM, 2),
0188     HPI_BITSTREAM_CLOCK_SOURCE = HPI_CTL_ATTR(BITSTREAM, 3),
0189     HPI_BITSTREAM_ACTIVITY = HPI_CTL_ATTR(BITSTREAM, 4),
0190 
0191     HPI_SAMPLECLOCK_SOURCE = HPI_CTL_ATTR(SAMPLECLOCK, 1),
0192     HPI_SAMPLECLOCK_SAMPLERATE = HPI_CTL_ATTR(SAMPLECLOCK, 2),
0193     HPI_SAMPLECLOCK_SOURCE_INDEX = HPI_CTL_ATTR(SAMPLECLOCK, 3),
0194     HPI_SAMPLECLOCK_LOCAL_SAMPLERATE = HPI_CTL_ATTR(SAMPLECLOCK, 4),
0195     HPI_SAMPLECLOCK_AUTO = HPI_CTL_ATTR(SAMPLECLOCK, 5),
0196     HPI_SAMPLECLOCK_LOCAL_LOCK = HPI_CTL_ATTR(SAMPLECLOCK, 6),
0197 
0198     HPI_MICROPHONE_PHANTOM_POWER = HPI_CTL_ATTR(MICROPHONE, 1),
0199 
0200     HPI_EQUALIZER_NUM_FILTERS = HPI_CTL_ATTR(EQUALIZER, 1),
0201     HPI_EQUALIZER_FILTER = HPI_CTL_ATTR(EQUALIZER, 2),
0202     HPI_EQUALIZER_COEFFICIENTS = HPI_CTL_ATTR(EQUALIZER, 3),
0203 
0204     HPI_COMPANDER_PARAMS = HPI_CTL_ATTR(COMPANDER, 1),
0205     HPI_COMPANDER_MAKEUPGAIN = HPI_CTL_ATTR(COMPANDER, 2),
0206     HPI_COMPANDER_THRESHOLD = HPI_CTL_ATTR(COMPANDER, 3),
0207     HPI_COMPANDER_RATIO = HPI_CTL_ATTR(COMPANDER, 4),
0208     HPI_COMPANDER_ATTACK = HPI_CTL_ATTR(COMPANDER, 5),
0209     HPI_COMPANDER_DECAY = HPI_CTL_ATTR(COMPANDER, 6),
0210 
0211     HPI_COBRANET_SET = HPI_CTL_ATTR(COBRANET, 1),
0212     HPI_COBRANET_GET = HPI_CTL_ATTR(COBRANET, 2),
0213     HPI_COBRANET_GET_STATUS = HPI_CTL_ATTR(COBRANET, 5),
0214     HPI_COBRANET_SEND_PACKET = HPI_CTL_ATTR(COBRANET, 6),
0215     HPI_COBRANET_GET_PACKET = HPI_CTL_ATTR(COBRANET, 7),
0216 
0217     HPI_TONEDETECTOR_THRESHOLD = HPI_CTL_ATTR(TONEDETECTOR, 1),
0218     HPI_TONEDETECTOR_STATE = HPI_CTL_ATTR(TONEDETECTOR, 2),
0219     HPI_TONEDETECTOR_FREQUENCY = HPI_CTL_ATTR(TONEDETECTOR, 3),
0220 
0221     HPI_SILENCEDETECTOR_THRESHOLD = HPI_CTL_ATTR(SILENCEDETECTOR, 1),
0222     HPI_SILENCEDETECTOR_STATE = HPI_CTL_ATTR(SILENCEDETECTOR, 2),
0223     HPI_SILENCEDETECTOR_DELAY = HPI_CTL_ATTR(SILENCEDETECTOR, 3),
0224 
0225     HPI_PAD_CHANNEL_NAME = HPI_CTL_ATTR(PAD, 1),
0226     HPI_PAD_ARTIST = HPI_CTL_ATTR(PAD, 2),
0227     HPI_PAD_TITLE = HPI_CTL_ATTR(PAD, 3),
0228     HPI_PAD_COMMENT = HPI_CTL_ATTR(PAD, 4),
0229     HPI_PAD_PROGRAM_TYPE = HPI_CTL_ATTR(PAD, 5),
0230     HPI_PAD_PROGRAM_ID = HPI_CTL_ATTR(PAD, 6),
0231     HPI_PAD_TA_SUPPORT = HPI_CTL_ATTR(PAD, 7),
0232     HPI_PAD_TA_ACTIVE = HPI_CTL_ATTR(PAD, 8),
0233 
0234     HPI_UNIVERSAL_ENTITY = HPI_CTL_ATTR(UNIVERSAL, 1)
0235 };
0236 
0237 #define HPI_POLARITY_POSITIVE           0
0238 #define HPI_POLARITY_NEGATIVE           1
0239 
0240 /*------------------------------------------------------------
0241  Cobranet Chip Bridge - copied from HMI.H
0242 ------------------------------------------------------------*/
0243 #define  HPI_COBRANET_HMI_cobra_bridge           0x20000
0244 #define  HPI_COBRANET_HMI_cobra_bridge_tx_pkt_buf \
0245     (HPI_COBRANET_HMI_cobra_bridge + 0x1000)
0246 #define  HPI_COBRANET_HMI_cobra_bridge_rx_pkt_buf \
0247     (HPI_COBRANET_HMI_cobra_bridge + 0x2000)
0248 #define  HPI_COBRANET_HMI_cobra_if_table1         0x110000
0249 #define  HPI_COBRANET_HMI_cobra_if_phy_address \
0250     (HPI_COBRANET_HMI_cobra_if_table1 + 0xd)
0251 #define  HPI_COBRANET_HMI_cobra_protocolIP       0x72000
0252 #define  HPI_COBRANET_HMI_cobra_ip_mon_currentIP \
0253     (HPI_COBRANET_HMI_cobra_protocolIP + 0x0)
0254 #define  HPI_COBRANET_HMI_cobra_ip_mon_staticIP \
0255     (HPI_COBRANET_HMI_cobra_protocolIP + 0x2)
0256 #define  HPI_COBRANET_HMI_cobra_sys              0x100000
0257 #define  HPI_COBRANET_HMI_cobra_sys_desc \
0258         (HPI_COBRANET_HMI_cobra_sys + 0x0)
0259 #define  HPI_COBRANET_HMI_cobra_sys_objectID \
0260     (HPI_COBRANET_HMI_cobra_sys + 0x100)
0261 #define  HPI_COBRANET_HMI_cobra_sys_contact \
0262     (HPI_COBRANET_HMI_cobra_sys + 0x200)
0263 #define  HPI_COBRANET_HMI_cobra_sys_name \
0264         (HPI_COBRANET_HMI_cobra_sys + 0x300)
0265 #define  HPI_COBRANET_HMI_cobra_sys_location \
0266     (HPI_COBRANET_HMI_cobra_sys + 0x400)
0267 
0268 /*------------------------------------------------------------
0269  Cobranet Chip Status bits
0270 ------------------------------------------------------------*/
0271 #define HPI_COBRANET_HMI_STATUS_RXPACKET 2
0272 #define HPI_COBRANET_HMI_STATUS_TXPACKET 3
0273 
0274 /*------------------------------------------------------------
0275  Ethernet header size
0276 ------------------------------------------------------------*/
0277 #define HPI_ETHERNET_HEADER_SIZE (16)
0278 
0279 /* These defines are used to fill in protocol information for an Ethernet packet
0280     sent using HMI on CS18102 */
0281 /** ID supplied by Cirrus for ASI packets. */
0282 #define HPI_ETHERNET_PACKET_ID                  0x85
0283 /** Simple packet - no special routing required */
0284 #define HPI_ETHERNET_PACKET_V1                  0x01
0285 /** This packet must make its way to the host across the HPI interface */
0286 #define HPI_ETHERNET_PACKET_HOSTED_VIA_HMI      0x20
0287 /** This packet must make its way to the host across the HPI interface */
0288 #define HPI_ETHERNET_PACKET_HOSTED_VIA_HMI_V1   0x21
0289 /** This packet must make its way to the host across the HPI interface */
0290 #define HPI_ETHERNET_PACKET_HOSTED_VIA_HPI      0x40
0291 /** This packet must make its way to the host across the HPI interface */
0292 #define HPI_ETHERNET_PACKET_HOSTED_VIA_HPI_V1   0x41
0293 
0294 #define HPI_ETHERNET_UDP_PORT 44600 /**< HPI UDP service */
0295 
0296 /** Default network timeout in milli-seconds. */
0297 #define HPI_ETHERNET_TIMEOUT_MS 500
0298 
0299 /** Locked memory buffer alloc/free phases */
0300 enum HPI_BUFFER_CMDS {
0301     /** use one message to allocate or free physical memory */
0302     HPI_BUFFER_CMD_EXTERNAL = 0,
0303     /** alloc physical memory */
0304     HPI_BUFFER_CMD_INTERNAL_ALLOC = 1,
0305     /** send physical memory address to adapter */
0306     HPI_BUFFER_CMD_INTERNAL_GRANTADAPTER = 2,
0307     /** notify adapter to stop using physical buffer */
0308     HPI_BUFFER_CMD_INTERNAL_REVOKEADAPTER = 3,
0309     /** free physical buffer */
0310     HPI_BUFFER_CMD_INTERNAL_FREE = 4
0311 };
0312 
0313 /*****************************************************************************/
0314 /*****************************************************************************/
0315 /********               HPI LOW LEVEL MESSAGES                  *******/
0316 /*****************************************************************************/
0317 /*****************************************************************************/
0318 /** Pnp ids */
0319 /** "ASI"  - actual is "ASX" - need to change */
0320 #define HPI_ID_ISAPNP_AUDIOSCIENCE      0x0669
0321 /** PCI vendor ID that AudioScience uses */
0322 #define HPI_PCI_VENDOR_ID_AUDIOSCIENCE  0x175C
0323 /** PCI vendor ID that the DSP56301 has */
0324 #define HPI_PCI_VENDOR_ID_MOTOROLA      0x1057
0325 /** PCI vendor ID that TI uses */
0326 #define HPI_PCI_VENDOR_ID_TI            0x104C
0327 
0328 #define HPI_PCI_DEV_ID_PCI2040          0xAC60
0329 /** TI's C6205 PCI interface has this ID */
0330 #define HPI_PCI_DEV_ID_DSP6205          0xA106
0331 
0332 #define HPI_USB_VENDOR_ID_AUDIOSCIENCE  0x1257
0333 #define HPI_USB_W2K_TAG                 0x57495341  /* "ASIW"       */
0334 #define HPI_USB_LINUX_TAG               0x4C495341  /* "ASIL"       */
0335 
0336 /** Invalid Adapter index
0337 Used in HPI messages that are not addressed to a specific adapter
0338 Used in DLL to indicate device not present
0339 */
0340 #define HPI_ADAPTER_INDEX_INVALID 0xFFFF
0341 
0342 /** First 2 hex digits define the adapter family */
0343 #define HPI_ADAPTER_FAMILY_MASK         0xff00
0344 #define HPI_MODULE_FAMILY_MASK          0xfff0
0345 
0346 #define HPI_ADAPTER_FAMILY_ASI(f)   (f & HPI_ADAPTER_FAMILY_MASK)
0347 #define HPI_MODULE_FAMILY_ASI(f)   (f & HPI_MODULE_FAMILY_MASK)
0348 #define HPI_ADAPTER_ASI(f)   (f)
0349 
0350 enum HPI_MESSAGE_TYPES {
0351     HPI_TYPE_REQUEST = 1,
0352     HPI_TYPE_RESPONSE = 2,
0353     HPI_TYPE_DATA = 3,
0354     HPI_TYPE_SSX2BYPASS_MESSAGE = 4,
0355     HPI_TYPE_COMMAND = 5,
0356     HPI_TYPE_NOTIFICATION = 6
0357 };
0358 
0359 enum HPI_OBJECT_TYPES {
0360     HPI_OBJ_SUBSYSTEM = 1,
0361     HPI_OBJ_ADAPTER = 2,
0362     HPI_OBJ_OSTREAM = 3,
0363     HPI_OBJ_ISTREAM = 4,
0364     HPI_OBJ_MIXER = 5,
0365     HPI_OBJ_NODE = 6,
0366     HPI_OBJ_CONTROL = 7,
0367     HPI_OBJ_NVMEMORY = 8,
0368     HPI_OBJ_GPIO = 9,
0369     HPI_OBJ_WATCHDOG = 10,
0370     HPI_OBJ_CLOCK = 11,
0371     HPI_OBJ_PROFILE = 12,
0372     /* HPI_ OBJ_ CONTROLEX  = 13, */
0373     HPI_OBJ_ASYNCEVENT = 14
0374 #define HPI_OBJ_MAXINDEX 14
0375 };
0376 
0377 #define HPI_OBJ_FUNCTION_SPACING 0x100
0378 #define HPI_FUNC_ID(obj, i) (HPI_OBJ_##obj * HPI_OBJ_FUNCTION_SPACING + i)
0379 
0380 #define HPI_EXTRACT_INDEX(fn) (fn & 0xff)
0381 
0382 enum HPI_FUNCTION_IDS {
0383     HPI_SUBSYS_OPEN = HPI_FUNC_ID(SUBSYSTEM, 1),
0384     HPI_SUBSYS_GET_VERSION = HPI_FUNC_ID(SUBSYSTEM, 2),
0385     HPI_SUBSYS_GET_INFO = HPI_FUNC_ID(SUBSYSTEM, 3),
0386     HPI_SUBSYS_CREATE_ADAPTER = HPI_FUNC_ID(SUBSYSTEM, 5),
0387     HPI_SUBSYS_CLOSE = HPI_FUNC_ID(SUBSYSTEM, 6),
0388     HPI_SUBSYS_DRIVER_LOAD = HPI_FUNC_ID(SUBSYSTEM, 8),
0389     HPI_SUBSYS_DRIVER_UNLOAD = HPI_FUNC_ID(SUBSYSTEM, 9),
0390     HPI_SUBSYS_GET_NUM_ADAPTERS = HPI_FUNC_ID(SUBSYSTEM, 12),
0391     HPI_SUBSYS_GET_ADAPTER = HPI_FUNC_ID(SUBSYSTEM, 13),
0392     HPI_SUBSYS_SET_NETWORK_INTERFACE = HPI_FUNC_ID(SUBSYSTEM, 14),
0393     HPI_SUBSYS_OPTION_INFO = HPI_FUNC_ID(SUBSYSTEM, 15),
0394     HPI_SUBSYS_OPTION_GET = HPI_FUNC_ID(SUBSYSTEM, 16),
0395     HPI_SUBSYS_OPTION_SET = HPI_FUNC_ID(SUBSYSTEM, 17),
0396 #define HPI_SUBSYS_FUNCTION_COUNT 17
0397 
0398     HPI_ADAPTER_OPEN = HPI_FUNC_ID(ADAPTER, 1),
0399     HPI_ADAPTER_CLOSE = HPI_FUNC_ID(ADAPTER, 2),
0400     HPI_ADAPTER_GET_INFO = HPI_FUNC_ID(ADAPTER, 3),
0401     HPI_ADAPTER_GET_ASSERT = HPI_FUNC_ID(ADAPTER, 4),
0402     HPI_ADAPTER_TEST_ASSERT = HPI_FUNC_ID(ADAPTER, 5),
0403     HPI_ADAPTER_SET_MODE = HPI_FUNC_ID(ADAPTER, 6),
0404     HPI_ADAPTER_GET_MODE = HPI_FUNC_ID(ADAPTER, 7),
0405     HPI_ADAPTER_ENABLE_CAPABILITY = HPI_FUNC_ID(ADAPTER, 8),
0406     HPI_ADAPTER_SELFTEST = HPI_FUNC_ID(ADAPTER, 9),
0407     HPI_ADAPTER_FIND_OBJECT = HPI_FUNC_ID(ADAPTER, 10),
0408     HPI_ADAPTER_QUERY_FLASH = HPI_FUNC_ID(ADAPTER, 11),
0409     HPI_ADAPTER_START_FLASH = HPI_FUNC_ID(ADAPTER, 12),
0410     HPI_ADAPTER_PROGRAM_FLASH = HPI_FUNC_ID(ADAPTER, 13),
0411     HPI_ADAPTER_SET_PROPERTY = HPI_FUNC_ID(ADAPTER, 14),
0412     HPI_ADAPTER_GET_PROPERTY = HPI_FUNC_ID(ADAPTER, 15),
0413     HPI_ADAPTER_ENUM_PROPERTY = HPI_FUNC_ID(ADAPTER, 16),
0414     HPI_ADAPTER_MODULE_INFO = HPI_FUNC_ID(ADAPTER, 17),
0415     HPI_ADAPTER_DEBUG_READ = HPI_FUNC_ID(ADAPTER, 18),
0416     HPI_ADAPTER_IRQ_QUERY_AND_CLEAR = HPI_FUNC_ID(ADAPTER, 19),
0417     HPI_ADAPTER_IRQ_CALLBACK = HPI_FUNC_ID(ADAPTER, 20),
0418     HPI_ADAPTER_DELETE = HPI_FUNC_ID(ADAPTER, 21),
0419     HPI_ADAPTER_READ_FLASH = HPI_FUNC_ID(ADAPTER, 22),
0420     HPI_ADAPTER_END_FLASH = HPI_FUNC_ID(ADAPTER, 23),
0421     HPI_ADAPTER_FILESTORE_DELETE_ALL = HPI_FUNC_ID(ADAPTER, 24),
0422 #define HPI_ADAPTER_FUNCTION_COUNT 24
0423 
0424     HPI_OSTREAM_OPEN = HPI_FUNC_ID(OSTREAM, 1),
0425     HPI_OSTREAM_CLOSE = HPI_FUNC_ID(OSTREAM, 2),
0426     HPI_OSTREAM_WRITE = HPI_FUNC_ID(OSTREAM, 3),
0427     HPI_OSTREAM_START = HPI_FUNC_ID(OSTREAM, 4),
0428     HPI_OSTREAM_STOP = HPI_FUNC_ID(OSTREAM, 5),
0429     HPI_OSTREAM_RESET = HPI_FUNC_ID(OSTREAM, 6),
0430     HPI_OSTREAM_GET_INFO = HPI_FUNC_ID(OSTREAM, 7),
0431     HPI_OSTREAM_QUERY_FORMAT = HPI_FUNC_ID(OSTREAM, 8),
0432     HPI_OSTREAM_DATA = HPI_FUNC_ID(OSTREAM, 9),
0433     HPI_OSTREAM_SET_VELOCITY = HPI_FUNC_ID(OSTREAM, 10),
0434     HPI_OSTREAM_SET_PUNCHINOUT = HPI_FUNC_ID(OSTREAM, 11),
0435     HPI_OSTREAM_SINEGEN = HPI_FUNC_ID(OSTREAM, 12),
0436     HPI_OSTREAM_ANC_RESET = HPI_FUNC_ID(OSTREAM, 13),
0437     HPI_OSTREAM_ANC_GET_INFO = HPI_FUNC_ID(OSTREAM, 14),
0438     HPI_OSTREAM_ANC_READ = HPI_FUNC_ID(OSTREAM, 15),
0439     HPI_OSTREAM_SET_TIMESCALE = HPI_FUNC_ID(OSTREAM, 16),
0440     HPI_OSTREAM_SET_FORMAT = HPI_FUNC_ID(OSTREAM, 17),
0441     HPI_OSTREAM_HOSTBUFFER_ALLOC = HPI_FUNC_ID(OSTREAM, 18),
0442     HPI_OSTREAM_HOSTBUFFER_FREE = HPI_FUNC_ID(OSTREAM, 19),
0443     HPI_OSTREAM_GROUP_ADD = HPI_FUNC_ID(OSTREAM, 20),
0444     HPI_OSTREAM_GROUP_GETMAP = HPI_FUNC_ID(OSTREAM, 21),
0445     HPI_OSTREAM_GROUP_RESET = HPI_FUNC_ID(OSTREAM, 22),
0446     HPI_OSTREAM_HOSTBUFFER_GET_INFO = HPI_FUNC_ID(OSTREAM, 23),
0447     HPI_OSTREAM_WAIT_START = HPI_FUNC_ID(OSTREAM, 24),
0448     HPI_OSTREAM_WAIT = HPI_FUNC_ID(OSTREAM, 25),
0449 #define HPI_OSTREAM_FUNCTION_COUNT 25
0450 
0451     HPI_ISTREAM_OPEN = HPI_FUNC_ID(ISTREAM, 1),
0452     HPI_ISTREAM_CLOSE = HPI_FUNC_ID(ISTREAM, 2),
0453     HPI_ISTREAM_SET_FORMAT = HPI_FUNC_ID(ISTREAM, 3),
0454     HPI_ISTREAM_READ = HPI_FUNC_ID(ISTREAM, 4),
0455     HPI_ISTREAM_START = HPI_FUNC_ID(ISTREAM, 5),
0456     HPI_ISTREAM_STOP = HPI_FUNC_ID(ISTREAM, 6),
0457     HPI_ISTREAM_RESET = HPI_FUNC_ID(ISTREAM, 7),
0458     HPI_ISTREAM_GET_INFO = HPI_FUNC_ID(ISTREAM, 8),
0459     HPI_ISTREAM_QUERY_FORMAT = HPI_FUNC_ID(ISTREAM, 9),
0460     HPI_ISTREAM_ANC_RESET = HPI_FUNC_ID(ISTREAM, 10),
0461     HPI_ISTREAM_ANC_GET_INFO = HPI_FUNC_ID(ISTREAM, 11),
0462     HPI_ISTREAM_ANC_WRITE = HPI_FUNC_ID(ISTREAM, 12),
0463     HPI_ISTREAM_HOSTBUFFER_ALLOC = HPI_FUNC_ID(ISTREAM, 13),
0464     HPI_ISTREAM_HOSTBUFFER_FREE = HPI_FUNC_ID(ISTREAM, 14),
0465     HPI_ISTREAM_GROUP_ADD = HPI_FUNC_ID(ISTREAM, 15),
0466     HPI_ISTREAM_GROUP_GETMAP = HPI_FUNC_ID(ISTREAM, 16),
0467     HPI_ISTREAM_GROUP_RESET = HPI_FUNC_ID(ISTREAM, 17),
0468     HPI_ISTREAM_HOSTBUFFER_GET_INFO = HPI_FUNC_ID(ISTREAM, 18),
0469     HPI_ISTREAM_WAIT_START = HPI_FUNC_ID(ISTREAM, 19),
0470     HPI_ISTREAM_WAIT = HPI_FUNC_ID(ISTREAM, 20),
0471 #define HPI_ISTREAM_FUNCTION_COUNT 20
0472 
0473 /* NOTE:
0474    GET_NODE_INFO, SET_CONNECTION, GET_CONNECTIONS are not currently used */
0475     HPI_MIXER_OPEN = HPI_FUNC_ID(MIXER, 1),
0476     HPI_MIXER_CLOSE = HPI_FUNC_ID(MIXER, 2),
0477     HPI_MIXER_GET_INFO = HPI_FUNC_ID(MIXER, 3),
0478     HPI_MIXER_GET_NODE_INFO = HPI_FUNC_ID(MIXER, 4),
0479     HPI_MIXER_GET_CONTROL = HPI_FUNC_ID(MIXER, 5),
0480     HPI_MIXER_SET_CONNECTION = HPI_FUNC_ID(MIXER, 6),
0481     HPI_MIXER_GET_CONNECTIONS = HPI_FUNC_ID(MIXER, 7),
0482     HPI_MIXER_GET_CONTROL_BY_INDEX = HPI_FUNC_ID(MIXER, 8),
0483     HPI_MIXER_GET_CONTROL_ARRAY_BY_INDEX = HPI_FUNC_ID(MIXER, 9),
0484     HPI_MIXER_GET_CONTROL_MULTIPLE_VALUES = HPI_FUNC_ID(MIXER, 10),
0485     HPI_MIXER_STORE = HPI_FUNC_ID(MIXER, 11),
0486     HPI_MIXER_GET_CACHE_INFO = HPI_FUNC_ID(MIXER, 12),
0487     HPI_MIXER_GET_BLOCK_HANDLE = HPI_FUNC_ID(MIXER, 13),
0488     HPI_MIXER_GET_PARAMETER_HANDLE = HPI_FUNC_ID(MIXER, 14),
0489 #define HPI_MIXER_FUNCTION_COUNT 14
0490 
0491     HPI_CONTROL_GET_INFO = HPI_FUNC_ID(CONTROL, 1),
0492     HPI_CONTROL_GET_STATE = HPI_FUNC_ID(CONTROL, 2),
0493     HPI_CONTROL_SET_STATE = HPI_FUNC_ID(CONTROL, 3),
0494 #define HPI_CONTROL_FUNCTION_COUNT 3
0495 
0496     HPI_NVMEMORY_OPEN = HPI_FUNC_ID(NVMEMORY, 1),
0497     HPI_NVMEMORY_READ_BYTE = HPI_FUNC_ID(NVMEMORY, 2),
0498     HPI_NVMEMORY_WRITE_BYTE = HPI_FUNC_ID(NVMEMORY, 3),
0499 #define HPI_NVMEMORY_FUNCTION_COUNT 3
0500 
0501     HPI_GPIO_OPEN = HPI_FUNC_ID(GPIO, 1),
0502     HPI_GPIO_READ_BIT = HPI_FUNC_ID(GPIO, 2),
0503     HPI_GPIO_WRITE_BIT = HPI_FUNC_ID(GPIO, 3),
0504     HPI_GPIO_READ_ALL = HPI_FUNC_ID(GPIO, 4),
0505     HPI_GPIO_WRITE_STATUS = HPI_FUNC_ID(GPIO, 5),
0506 #define HPI_GPIO_FUNCTION_COUNT 5
0507 
0508     HPI_ASYNCEVENT_OPEN = HPI_FUNC_ID(ASYNCEVENT, 1),
0509     HPI_ASYNCEVENT_CLOSE = HPI_FUNC_ID(ASYNCEVENT, 2),
0510     HPI_ASYNCEVENT_WAIT = HPI_FUNC_ID(ASYNCEVENT, 3),
0511     HPI_ASYNCEVENT_GETCOUNT = HPI_FUNC_ID(ASYNCEVENT, 4),
0512     HPI_ASYNCEVENT_GET = HPI_FUNC_ID(ASYNCEVENT, 5),
0513     HPI_ASYNCEVENT_SENDEVENTS = HPI_FUNC_ID(ASYNCEVENT, 6),
0514 #define HPI_ASYNCEVENT_FUNCTION_COUNT 6
0515 
0516     HPI_WATCHDOG_OPEN = HPI_FUNC_ID(WATCHDOG, 1),
0517     HPI_WATCHDOG_SET_TIME = HPI_FUNC_ID(WATCHDOG, 2),
0518     HPI_WATCHDOG_PING = HPI_FUNC_ID(WATCHDOG, 3),
0519 
0520     HPI_CLOCK_OPEN = HPI_FUNC_ID(CLOCK, 1),
0521     HPI_CLOCK_SET_TIME = HPI_FUNC_ID(CLOCK, 2),
0522     HPI_CLOCK_GET_TIME = HPI_FUNC_ID(CLOCK, 3),
0523 
0524     HPI_PROFILE_OPEN_ALL = HPI_FUNC_ID(PROFILE, 1),
0525     HPI_PROFILE_START_ALL = HPI_FUNC_ID(PROFILE, 2),
0526     HPI_PROFILE_STOP_ALL = HPI_FUNC_ID(PROFILE, 3),
0527     HPI_PROFILE_GET = HPI_FUNC_ID(PROFILE, 4),
0528     HPI_PROFILE_GET_IDLECOUNT = HPI_FUNC_ID(PROFILE, 5),
0529     HPI_PROFILE_GET_NAME = HPI_FUNC_ID(PROFILE, 6),
0530     HPI_PROFILE_GET_UTILIZATION = HPI_FUNC_ID(PROFILE, 7)
0531 #define HPI_PROFILE_FUNCTION_COUNT 7
0532 };
0533 
0534 /* ////////////////////////////////////////////////////////////////////// */
0535 /* STRUCTURES */
0536 #ifndef DISABLE_PRAGMA_PACK1
0537 #pragma pack(push, 1)
0538 #endif
0539 
0540 /** PCI bus resource */
0541 struct hpi_pci {
0542     u32 __iomem *ap_mem_base[HPI_MAX_ADAPTER_MEM_SPACES];
0543     struct pci_dev *pci_dev;
0544 };
0545 
0546 /** Adapter specification resource */
0547 struct hpi_adapter_specification {
0548     u32 type;
0549     u8 modules[4];
0550 };
0551 
0552 struct hpi_resource {
0553     union {
0554         const struct hpi_pci *pci;
0555         const char *net_if;
0556         struct hpi_adapter_specification adapter_spec;
0557         const void *sw_if;
0558     } r;
0559     u16 bus_type;       /* HPI_BUS_PNPISA, _PCI, _USB etc */
0560     u16 padding;
0561 };
0562 
0563 /** Format info used inside struct hpi_message
0564     Not the same as public API struct hpi_format */
0565 struct hpi_msg_format {
0566     u32 sample_rate; /**< 11025, 32000, 44100 etc. */
0567     u32 bit_rate; /**< for MPEG */
0568     u32 attributes; /**< stereo/joint_stereo/mono */
0569     u16 channels; /**< 1,2..., (or ancillary mode or idle bit */
0570     u16 format; /**< HPI_FORMAT_PCM16, _MPEG etc. see \ref HPI_FORMATS. */
0571 };
0572 
0573 /**  Buffer+format structure.
0574      Must be kept 7 * 32 bits to match public struct hpi_datastruct */
0575 struct hpi_msg_data {
0576     struct hpi_msg_format format;
0577     u8 *pb_data;
0578 #ifndef CONFIG_64BIT
0579     u32 padding;
0580 #endif
0581     u32 data_size;
0582 };
0583 
0584 /** struct hpi_datastructure used up to 3.04 driver */
0585 struct hpi_data_legacy32 {
0586     struct hpi_format format;
0587     u32 pb_data;
0588     u32 data_size;
0589 };
0590 
0591 #ifdef CONFIG_64BIT
0592 /* Compatibility version of struct hpi_data*/
0593 struct hpi_data_compat32 {
0594     struct hpi_msg_format format;
0595     u32 pb_data;
0596     u32 padding;
0597     u32 data_size;
0598 };
0599 #endif
0600 
0601 struct hpi_buffer {
0602   /** placeholder for backward compatibility (see dwBufferSize) */
0603     struct hpi_msg_format reserved;
0604     u32 command; /**< HPI_BUFFER_CMD_xxx*/
0605     u32 pci_address; /**< PCI physical address of buffer for DSP DMA */
0606     u32 buffer_size; /**< must line up with data_size of HPI_DATA*/
0607 };
0608 
0609 /*/////////////////////////////////////////////////////////////////////////// */
0610 /* This is used for background buffer bus mastering stream buffers.           */
0611 struct hpi_hostbuffer_status {
0612     u32 samples_processed;
0613     u32 auxiliary_data_available;
0614     u32 stream_state;
0615     /* DSP index in to the host bus master buffer. */
0616     u32 dsp_index;
0617     /* Host index in to the host bus master buffer. */
0618     u32 host_index;
0619     u32 size_in_bytes;
0620 };
0621 
0622 struct hpi_streamid {
0623     u16 object_type;
0624             /**< Type of object, HPI_OBJ_OSTREAM or HPI_OBJ_ISTREAM. */
0625     u16 stream_index; /**< outstream or instream index. */
0626 };
0627 
0628 struct hpi_punchinout {
0629     u32 punch_in_sample;
0630     u32 punch_out_sample;
0631 };
0632 
0633 struct hpi_subsys_msg {
0634     struct hpi_resource resource;
0635 };
0636 
0637 struct hpi_subsys_res {
0638     u32 version;
0639     u32 data;       /* extended version */
0640     u16 num_adapters;
0641     u16 adapter_index;
0642     u16 adapter_type;
0643     u16 pad16;
0644 };
0645 
0646 union hpi_adapterx_msg {
0647     struct {
0648         u32 dsp_address;
0649         u32 count_bytes;
0650     } debug_read;
0651     struct {
0652         u32 adapter_mode;
0653         u16 query_or_set;
0654     } mode;
0655     struct {
0656         u16 index;
0657     } module_info;
0658     struct {
0659         u16 index;
0660         u16 what;
0661         u16 property_index;
0662     } property_enum;
0663     struct {
0664         u16 property;
0665         u16 parameter1;
0666         u16 parameter2;
0667     } property_set;
0668     struct {
0669         u32 pad32;
0670         u16 key1;
0671         u16 key2;
0672     } restart;
0673     struct {
0674         u32 pad32;
0675         u16 value;
0676     } test_assert;
0677     struct {
0678         u32 message;
0679     } irq;
0680     u32 pad[3];
0681 };
0682 
0683 struct hpi_adapter_res {
0684     u32 serial_number;
0685     u16 adapter_type;
0686     u16 adapter_index;
0687     u16 num_instreams;
0688     u16 num_outstreams;
0689     u16 num_mixers;
0690     u16 version;
0691     u8 sz_adapter_assert[HPI_STRING_LEN];
0692 };
0693 
0694 union hpi_adapterx_res {
0695     struct hpi_adapter_res info;
0696     struct {
0697         u32 p1;
0698         u16 count;
0699         u16 dsp_index;
0700         u32 p2;
0701         u32 dsp_msg_addr;
0702         char sz_message[HPI_STRING_LEN];
0703     } assert;
0704     struct {
0705         u32 adapter_mode;
0706     } mode;
0707     struct {
0708         u16 parameter1;
0709         u16 parameter2;
0710     } property_get;
0711     struct {
0712         u32 yes;
0713     } irq_query;
0714 };
0715 
0716 struct hpi_stream_msg {
0717     union {
0718         struct hpi_msg_data data;
0719         struct hpi_data_legacy32 data32;
0720         u16 velocity;
0721         struct hpi_punchinout pio;
0722         u32 time_scale;
0723         struct hpi_buffer buffer;
0724         struct hpi_streamid stream;
0725         u32 threshold_bytes;
0726     } u;
0727 };
0728 
0729 struct hpi_stream_res {
0730     union {
0731         struct {
0732             /* size of hardware buffer */
0733             u32 buffer_size;
0734             /* OutStream - data to play,
0735                InStream - data recorded */
0736             u32 data_available;
0737             /* OutStream - samples played,
0738                InStream - samples recorded */
0739             u32 samples_transferred;
0740             /* Adapter - OutStream - data to play,
0741                InStream - data recorded */
0742             u32 auxiliary_data_available;
0743             u16 state;  /* HPI_STATE_PLAYING, _STATE_STOPPED */
0744             u16 padding;
0745         } stream_info;
0746         struct {
0747             u32 buffer_size;
0748             u32 data_available;
0749             u32 samples_transfered;
0750             u16 state;
0751             u16 outstream_index;
0752             u16 instream_index;
0753             u16 padding;
0754             u32 auxiliary_data_available;
0755         } legacy_stream_info;
0756         struct {
0757             /* bitmap of grouped OutStreams */
0758             u32 outstream_group_map;
0759             /* bitmap of grouped InStreams */
0760             u32 instream_group_map;
0761         } group_info;
0762         struct {
0763             /* pointer to the buffer */
0764             u8 *p_buffer;
0765             /* pointer to the hostbuffer status */
0766             struct hpi_hostbuffer_status *p_status;
0767         } hostbuffer_info;
0768     } u;
0769 };
0770 
0771 struct hpi_mixer_msg {
0772     u16 control_index;
0773     u16 control_type;   /* = HPI_CONTROL_METER _VOLUME etc */
0774     u16 padding1;       /* Maintain alignment of subsequent fields */
0775     u16 node_type1;     /* = HPI_SOURCENODE_LINEIN etc */
0776     u16 node_index1;    /* = 0..N */
0777     u16 node_type2;
0778     u16 node_index2;
0779     u16 padding2;       /* round to 4 bytes */
0780 };
0781 
0782 struct hpi_mixer_res {
0783     u16 src_node_type;  /* = HPI_SOURCENODE_LINEIN etc */
0784     u16 src_node_index; /* = 0..N */
0785     u16 dst_node_type;
0786     u16 dst_node_index;
0787     /* Also controlType for MixerGetControlByIndex */
0788     u16 control_index;
0789     /* may indicate which DSP the control is located on */
0790     u16 dsp_index;
0791 };
0792 
0793 union hpi_mixerx_msg {
0794     struct {
0795         u16 starting_index;
0796         u16 flags;
0797         u32 length_in_bytes;    /* length in bytes of p_data */
0798         u32 p_data; /* pointer to a data array */
0799     } gcabi;
0800     struct {
0801         u16 command;
0802         u16 index;
0803     } store;        /* for HPI_MIXER_STORE message */
0804 };
0805 
0806 union hpi_mixerx_res {
0807     struct {
0808         u32 bytes_returned; /* size of items returned */
0809         u32 p_data; /* pointer to data array */
0810         u16 more_to_do; /* indicates if there is more to do */
0811     } gcabi;
0812     struct {
0813         u32 total_controls; /* count of controls in the mixer */
0814         u32 cache_controls; /* count of controls in the cac */
0815         u32 cache_bytes;    /* size of cache */
0816     } cache_info;
0817 };
0818 
0819 struct hpi_control_msg {
0820     u16 attribute;      /* control attribute or property */
0821     u16 saved_index;
0822     u32 param1;     /* generic parameter 1 */
0823     u32 param2;     /* generic parameter 2 */
0824     short an_log_value[HPI_MAX_CHANNELS];
0825 };
0826 
0827 struct hpi_control_union_msg {
0828     u16 attribute;      /* control attribute or property */
0829     u16 saved_index;    /* only used in ctrl save/restore */
0830     union {
0831         struct {
0832             u32 param1; /* generic parameter 1 */
0833             u32 param2; /* generic parameter 2 */
0834             short an_log_value[HPI_MAX_CHANNELS];
0835         } old;
0836         union {
0837             u32 frequency;
0838             u32 gain;
0839             u32 band;
0840             u32 deemphasis;
0841             u32 program;
0842             struct {
0843                 u32 mode;
0844                 u32 value;
0845             } mode;
0846             u32 blend;
0847         } tuner;
0848     } u;
0849 };
0850 
0851 struct hpi_control_res {
0852     /* Could make union. dwParam, anLogValue never used in same response */
0853     u32 param1;
0854     u32 param2;
0855     short an_log_value[HPI_MAX_CHANNELS];
0856 };
0857 
0858 union hpi_control_union_res {
0859     struct {
0860         u32 param1;
0861         u32 param2;
0862         short an_log_value[HPI_MAX_CHANNELS];
0863     } old;
0864     union {
0865         u32 band;
0866         u32 frequency;
0867         u32 gain;
0868         u32 deemphasis;
0869         struct {
0870             u32 data[2];
0871             u32 bLER;
0872         } rds;
0873         short s_level;
0874         struct {
0875             u16 value;
0876             u16 mask;
0877         } status;
0878     } tuner;
0879     struct {
0880         char sz_data[8];
0881         u32 remaining_chars;
0882     } chars8;
0883     char c_data12[12];
0884     union {
0885         struct {
0886             u32 status;
0887             u32 readable_size;
0888             u32 writeable_size;
0889         } status;
0890     } cobranet;
0891 };
0892 
0893 struct hpi_nvmemory_msg {
0894     u16 address;
0895     u16 data;
0896 };
0897 
0898 struct hpi_nvmemory_res {
0899     u16 size_in_bytes;
0900     u16 data;
0901 };
0902 
0903 struct hpi_gpio_msg {
0904     u16 bit_index;
0905     u16 bit_data;
0906 };
0907 
0908 struct hpi_gpio_res {
0909     u16 number_input_bits;
0910     u16 number_output_bits;
0911     u16 bit_data[4];
0912 };
0913 
0914 struct hpi_async_msg {
0915     u32 events;
0916     u16 maximum_events;
0917     u16 padding;
0918 };
0919 
0920 struct hpi_async_res {
0921     union {
0922         struct {
0923             u16 count;
0924         } count;
0925         struct {
0926             u32 events;
0927             u16 number_returned;
0928             u16 padding;
0929         } get;
0930         struct hpi_async_event event;
0931     } u;
0932 };
0933 
0934 struct hpi_watchdog_msg {
0935     u32 time_ms;
0936 };
0937 
0938 struct hpi_watchdog_res {
0939     u32 time_ms;
0940 };
0941 
0942 struct hpi_clock_msg {
0943     u16 hours;
0944     u16 minutes;
0945     u16 seconds;
0946     u16 milli_seconds;
0947 };
0948 
0949 struct hpi_clock_res {
0950     u16 size_in_bytes;
0951     u16 hours;
0952     u16 minutes;
0953     u16 seconds;
0954     u16 milli_seconds;
0955     u16 padding;
0956 };
0957 
0958 struct hpi_profile_msg {
0959     u16 bin_index;
0960     u16 padding;
0961 };
0962 
0963 struct hpi_profile_res_open {
0964     u16 max_profiles;
0965 };
0966 
0967 struct hpi_profile_res_time {
0968     u32 total_tick_count;
0969     u32 call_count;
0970     u32 max_tick_count;
0971     u32 ticks_per_millisecond;
0972     u16 profile_interval;
0973 };
0974 
0975 struct hpi_profile_res_name {
0976     u8 sz_name[32];
0977 };
0978 
0979 struct hpi_profile_res {
0980     union {
0981         struct hpi_profile_res_open o;
0982         struct hpi_profile_res_time t;
0983         struct hpi_profile_res_name n;
0984     } u;
0985 };
0986 
0987 struct hpi_message_header {
0988     u16 size;       /* total size in bytes */
0989     u8 type;        /* HPI_TYPE_MESSAGE  */
0990     u8 version;     /* message version */
0991     u16 object;     /* HPI_OBJ_* */
0992     u16 function;       /* HPI_SUBSYS_xxx, HPI_ADAPTER_xxx */
0993     u16 adapter_index;  /* the adapter index */
0994     u16 obj_index;      /* */
0995 };
0996 
0997 struct hpi_message {
0998     /* following fields must match HPI_MESSAGE_HEADER */
0999     u16 size;       /* total size in bytes */
1000     u8 type;        /* HPI_TYPE_MESSAGE  */
1001     u8 version;     /* message version */
1002     u16 object;     /* HPI_OBJ_* */
1003     u16 function;       /* HPI_SUBSYS_xxx, HPI_ADAPTER_xxx */
1004     u16 adapter_index;  /* the adapter index */
1005     u16 obj_index;      /*  */
1006     union {
1007         struct hpi_subsys_msg s;
1008         union hpi_adapterx_msg ax;
1009         struct hpi_stream_msg d;
1010         struct hpi_mixer_msg m;
1011         union hpi_mixerx_msg mx;    /* extended mixer; */
1012         struct hpi_control_msg c;   /* mixer control; */
1013         /* identical to struct hpi_control_msg,
1014            but field naming is improved */
1015         struct hpi_control_union_msg cu;
1016         struct hpi_nvmemory_msg n;
1017         struct hpi_gpio_msg l;  /* digital i/o */
1018         struct hpi_watchdog_msg w;
1019         struct hpi_clock_msg t; /* dsp time */
1020         struct hpi_profile_msg p;
1021         struct hpi_async_msg as;
1022         char fixed_size[32];
1023     } u;
1024 };
1025 
1026 #define HPI_MESSAGE_SIZE_BY_OBJECT { \
1027     sizeof(struct hpi_message_header) ,   /* Default, no object type 0 */ \
1028     sizeof(struct hpi_message_header) + sizeof(struct hpi_subsys_msg),\
1029     sizeof(struct hpi_message_header) + sizeof(union hpi_adapterx_msg),\
1030     sizeof(struct hpi_message_header) + sizeof(struct hpi_stream_msg),\
1031     sizeof(struct hpi_message_header) + sizeof(struct hpi_stream_msg),\
1032     sizeof(struct hpi_message_header) + sizeof(struct hpi_mixer_msg),\
1033     sizeof(struct hpi_message_header) ,   /* no node message */ \
1034     sizeof(struct hpi_message_header) + sizeof(struct hpi_control_msg),\
1035     sizeof(struct hpi_message_header) + sizeof(struct hpi_nvmemory_msg),\
1036     sizeof(struct hpi_message_header) + sizeof(struct hpi_gpio_msg),\
1037     sizeof(struct hpi_message_header) + sizeof(struct hpi_watchdog_msg),\
1038     sizeof(struct hpi_message_header) + sizeof(struct hpi_clock_msg),\
1039     sizeof(struct hpi_message_header) + sizeof(struct hpi_profile_msg),\
1040     sizeof(struct hpi_message_header), /* controlx obj removed */ \
1041     sizeof(struct hpi_message_header) + sizeof(struct hpi_async_msg) \
1042 }
1043 
1044 /*
1045 Note that the wSpecificError error field should be inspected and potentially
1046 reported whenever HPI_ERROR_DSP_COMMUNICATION or HPI_ERROR_DSP_BOOTLOAD is
1047 returned in wError.
1048 */
1049 struct hpi_response_header {
1050     u16 size;
1051     u8 type;        /* HPI_TYPE_RESPONSE  */
1052     u8 version;     /* response version */
1053     u16 object;     /* HPI_OBJ_* */
1054     u16 function;       /* HPI_SUBSYS_xxx, HPI_ADAPTER_xxx */
1055     u16 error;      /* HPI_ERROR_xxx */
1056     u16 specific_error; /* adapter specific error */
1057 };
1058 
1059 struct hpi_response {
1060 /* following fields must match HPI_RESPONSE_HEADER */
1061     u16 size;
1062     u8 type;        /* HPI_TYPE_RESPONSE  */
1063     u8 version;     /* response version */
1064     u16 object;     /* HPI_OBJ_* */
1065     u16 function;       /* HPI_SUBSYS_xxx, HPI_ADAPTER_xxx */
1066     u16 error;      /* HPI_ERROR_xxx */
1067     u16 specific_error; /* adapter specific error */
1068     union {
1069         struct hpi_subsys_res s;
1070         union hpi_adapterx_res ax;
1071         struct hpi_stream_res d;
1072         struct hpi_mixer_res m;
1073         union hpi_mixerx_res mx;    /* extended mixer; */
1074         struct hpi_control_res c;   /* mixer control; */
1075         /* identical to hpi_control_res, but field naming is improved */
1076         union hpi_control_union_res cu;
1077         struct hpi_nvmemory_res n;
1078         struct hpi_gpio_res l;  /* digital i/o */
1079         struct hpi_watchdog_res w;
1080         struct hpi_clock_res t; /* dsp time */
1081         struct hpi_profile_res p;
1082         struct hpi_async_res as;
1083         u8 bytes[52];
1084     } u;
1085 };
1086 
1087 #define HPI_RESPONSE_SIZE_BY_OBJECT { \
1088     sizeof(struct hpi_response_header) ,/* Default, no object type 0 */ \
1089     sizeof(struct hpi_response_header) + sizeof(struct hpi_subsys_res),\
1090     sizeof(struct hpi_response_header) + sizeof(union  hpi_adapterx_res),\
1091     sizeof(struct hpi_response_header) + sizeof(struct hpi_stream_res),\
1092     sizeof(struct hpi_response_header) + sizeof(struct hpi_stream_res),\
1093     sizeof(struct hpi_response_header) + sizeof(struct hpi_mixer_res),\
1094     sizeof(struct hpi_response_header) , /* no node response */ \
1095     sizeof(struct hpi_response_header) + sizeof(struct hpi_control_res),\
1096     sizeof(struct hpi_response_header) + sizeof(struct hpi_nvmemory_res),\
1097     sizeof(struct hpi_response_header) + sizeof(struct hpi_gpio_res),\
1098     sizeof(struct hpi_response_header) + sizeof(struct hpi_watchdog_res),\
1099     sizeof(struct hpi_response_header) + sizeof(struct hpi_clock_res),\
1100     sizeof(struct hpi_response_header) + sizeof(struct hpi_profile_res),\
1101     sizeof(struct hpi_response_header), /* controlx obj removed */ \
1102     sizeof(struct hpi_response_header) + sizeof(struct hpi_async_res) \
1103 }
1104 
1105 /*********************** version 1 message/response **************************/
1106 #define HPINET_ETHERNET_DATA_SIZE (1500)
1107 #define HPINET_IP_HDR_SIZE (20)
1108 #define HPINET_IP_DATA_SIZE (HPINET_ETHERNET_DATA_SIZE - HPINET_IP_HDR_SIZE)
1109 #define HPINET_UDP_HDR_SIZE (8)
1110 #define HPINET_UDP_DATA_SIZE (HPINET_IP_DATA_SIZE - HPINET_UDP_HDR_SIZE)
1111 #define HPINET_ASI_HDR_SIZE (2)
1112 #define HPINET_ASI_DATA_SIZE (HPINET_UDP_DATA_SIZE - HPINET_ASI_HDR_SIZE)
1113 
1114 #define HPI_MAX_PAYLOAD_SIZE (HPINET_ASI_DATA_SIZE - 2)
1115 
1116 /* New style message/response, but still V0 compatible */
1117 struct hpi_msg_adapter_get_info {
1118     struct hpi_message_header h;
1119 };
1120 
1121 struct hpi_res_adapter_get_info {
1122     struct hpi_response_header h;   /*v0 */
1123     struct hpi_adapter_res p;
1124 };
1125 
1126 struct hpi_res_adapter_debug_read {
1127     struct hpi_response_header h;
1128     u8 bytes[1024];
1129 };
1130 
1131 struct hpi_msg_cobranet_hmi {
1132     u16 attribute;
1133     u16 padding;
1134     u32 hmi_address;
1135     u32 byte_count;
1136 };
1137 
1138 struct hpi_msg_cobranet_hmiwrite {
1139     struct hpi_message_header h;
1140     struct hpi_msg_cobranet_hmi p;
1141     u8 bytes[256];
1142 };
1143 
1144 struct hpi_msg_cobranet_hmiread {
1145     struct hpi_message_header h;
1146     struct hpi_msg_cobranet_hmi p;
1147 };
1148 
1149 struct hpi_res_cobranet_hmiread {
1150     struct hpi_response_header h;
1151     u32 byte_count;
1152     u8 bytes[256];
1153 };
1154 
1155 #if 1
1156 #define hpi_message_header_v1 hpi_message_header
1157 #define hpi_response_header_v1 hpi_response_header
1158 #else
1159 /* V1 headers in Addition to v0 headers */
1160 struct hpi_message_header_v1 {
1161     struct hpi_message_header h0;
1162 /* struct {
1163 } h1; */
1164 };
1165 
1166 struct hpi_response_header_v1 {
1167     struct hpi_response_header h0;
1168     struct {
1169         u16 adapter_index;  /* the adapter index */
1170         u16 obj_index;  /* object index */
1171     } h1;
1172 };
1173 #endif
1174 
1175 struct hpi_msg_payload_v0 {
1176     struct hpi_message_header h;
1177     union {
1178         struct hpi_subsys_msg s;
1179         union hpi_adapterx_msg ax;
1180         struct hpi_stream_msg d;
1181         struct hpi_mixer_msg m;
1182         union hpi_mixerx_msg mx;
1183         struct hpi_control_msg c;
1184         struct hpi_control_union_msg cu;
1185         struct hpi_nvmemory_msg n;
1186         struct hpi_gpio_msg l;
1187         struct hpi_watchdog_msg w;
1188         struct hpi_clock_msg t;
1189         struct hpi_profile_msg p;
1190         struct hpi_async_msg as;
1191     } u;
1192 };
1193 
1194 struct hpi_res_payload_v0 {
1195     struct hpi_response_header h;
1196     union {
1197         struct hpi_subsys_res s;
1198         union hpi_adapterx_res ax;
1199         struct hpi_stream_res d;
1200         struct hpi_mixer_res m;
1201         union hpi_mixerx_res mx;
1202         struct hpi_control_res c;
1203         union hpi_control_union_res cu;
1204         struct hpi_nvmemory_res n;
1205         struct hpi_gpio_res l;
1206         struct hpi_watchdog_res w;
1207         struct hpi_clock_res t;
1208         struct hpi_profile_res p;
1209         struct hpi_async_res as;
1210     } u;
1211 };
1212 
1213 union hpi_message_buffer_v1 {
1214     struct hpi_message m0;  /* version 0 */
1215     struct hpi_message_header_v1 h;
1216     u8 buf[HPI_MAX_PAYLOAD_SIZE];
1217 };
1218 
1219 union hpi_response_buffer_v1 {
1220     struct hpi_response r0; /* version 0 */
1221     struct hpi_response_header_v1 h;
1222     u8 buf[HPI_MAX_PAYLOAD_SIZE];
1223 };
1224 
1225 compile_time_assert((sizeof(union hpi_message_buffer_v1) <=
1226         HPI_MAX_PAYLOAD_SIZE), message_buffer_ok);
1227 compile_time_assert((sizeof(union hpi_response_buffer_v1) <=
1228         HPI_MAX_PAYLOAD_SIZE), response_buffer_ok);
1229 
1230 /*////////////////////////////////////////////////////////////////////////// */
1231 /* declarations for compact control calls  */
1232 struct hpi_control_defn {
1233     u8 type;
1234     u8 channels;
1235     u8 src_node_type;
1236     u8 src_node_index;
1237     u8 dest_node_type;
1238     u8 dest_node_index;
1239 };
1240 
1241 /*////////////////////////////////////////////////////////////////////////// */
1242 /* declarations for control caching (internal to HPI<->DSP interaction)      */
1243 
1244 /** indicates a cached u16 value is invalid. */
1245 #define HPI_CACHE_INVALID_UINT16 0xFFFF
1246 /** indicates a cached short value is invalid. */
1247 #define HPI_CACHE_INVALID_SHORT -32768
1248 
1249 /** A compact representation of (part of) a controls state.
1250 Used for efficient transfer of the control state
1251 between DSP and host or across a network
1252 */
1253 struct hpi_control_cache_info {
1254     /** one of HPI_CONTROL_* */
1255     u8 control_type;
1256     /** The total size of cached information in 32-bit words. */
1257     u8 size_in32bit_words;
1258     /** The original index of the control on the DSP */
1259     u16 control_index;
1260 };
1261 
1262 struct hpi_control_cache_vol {
1263     struct hpi_control_cache_info i;
1264     short an_log[2];
1265     unsigned short flags;
1266     char padding[2];
1267 };
1268 
1269 struct hpi_control_cache_meter {
1270     struct hpi_control_cache_info i;
1271     short an_log_peak[2];
1272     short an_logRMS[2];
1273 };
1274 
1275 struct hpi_control_cache_channelmode {
1276     struct hpi_control_cache_info i;
1277     u16 mode;
1278     char temp_padding[6];
1279 };
1280 
1281 struct hpi_control_cache_mux {
1282     struct hpi_control_cache_info i;
1283     u16 source_node_type;
1284     u16 source_node_index;
1285     char temp_padding[4];
1286 };
1287 
1288 struct hpi_control_cache_level {
1289     struct hpi_control_cache_info i;
1290     short an_log[2];
1291     char temp_padding[4];
1292 };
1293 
1294 struct hpi_control_cache_tuner {
1295     struct hpi_control_cache_info i;
1296     u32 freq_ink_hz;
1297     u16 band;
1298     short s_level_avg;
1299 };
1300 
1301 struct hpi_control_cache_aes3rx {
1302     struct hpi_control_cache_info i;
1303     u32 error_status;
1304     u32 format;
1305 };
1306 
1307 struct hpi_control_cache_aes3tx {
1308     struct hpi_control_cache_info i;
1309     u32 format;
1310     char temp_padding[4];
1311 };
1312 
1313 struct hpi_control_cache_tonedetector {
1314     struct hpi_control_cache_info i;
1315     u16 state;
1316     char temp_padding[6];
1317 };
1318 
1319 struct hpi_control_cache_silencedetector {
1320     struct hpi_control_cache_info i;
1321     u32 state;
1322     char temp_padding[4];
1323 };
1324 
1325 struct hpi_control_cache_sampleclock {
1326     struct hpi_control_cache_info i;
1327     u16 source;
1328     u16 source_index;
1329     u32 sample_rate;
1330 };
1331 
1332 struct hpi_control_cache_microphone {
1333     struct hpi_control_cache_info i;
1334     u16 phantom_state;
1335     char temp_padding[6];
1336 };
1337 
1338 struct hpi_control_cache_single {
1339     union {
1340         struct hpi_control_cache_info i;
1341         struct hpi_control_cache_vol vol;
1342         struct hpi_control_cache_meter meter;
1343         struct hpi_control_cache_channelmode mode;
1344         struct hpi_control_cache_mux mux;
1345         struct hpi_control_cache_level level;
1346         struct hpi_control_cache_tuner tuner;
1347         struct hpi_control_cache_aes3rx aes3rx;
1348         struct hpi_control_cache_aes3tx aes3tx;
1349         struct hpi_control_cache_tonedetector tone;
1350         struct hpi_control_cache_silencedetector silence;
1351         struct hpi_control_cache_sampleclock clk;
1352         struct hpi_control_cache_microphone microphone;
1353     } u;
1354 };
1355 
1356 struct hpi_control_cache_pad {
1357     struct hpi_control_cache_info i;
1358     u32 field_valid_flags;
1359     u8 c_channel[40];
1360     u8 c_artist[100];
1361     u8 c_title[100];
1362     u8 c_comment[200];
1363     u32 pTY;
1364     u32 pI;
1365     u32 traffic_supported;
1366     u32 traffic_anouncement;
1367 };
1368 
1369 /* 2^N sized FIFO buffer (internal to HPI<->DSP interaction) */
1370 struct hpi_fifo_buffer {
1371     u32 size;
1372     u32 dsp_index;
1373     u32 host_index;
1374 };
1375 
1376 #ifndef DISABLE_PRAGMA_PACK1
1377 #pragma pack(pop)
1378 #endif
1379 
1380 /* skip host side function declarations for DSP
1381    compile and documentation extraction */
1382 
1383 char hpi_handle_object(const u32 handle);
1384 
1385 void hpi_handle_to_indexes(const u32 handle, u16 *pw_adapter_index,
1386     u16 *pw_object_index);
1387 
1388 u32 hpi_indexes_to_handle(const char c_object, const u16 adapter_index,
1389     const u16 object_index);
1390 
1391 /*////////////////////////////////////////////////////////////////////////// */
1392 
1393 /* main HPI entry point */
1394 void hpi_send_recv(struct hpi_message *phm, struct hpi_response *phr);
1395 
1396 /* used in PnP OS/driver */
1397 u16 hpi_subsys_create_adapter(const struct hpi_resource *p_resource,
1398     u16 *pw_adapter_index);
1399 
1400 u16 hpi_outstream_host_buffer_get_info(u32 h_outstream, u8 **pp_buffer,
1401     struct hpi_hostbuffer_status **pp_status);
1402 
1403 u16 hpi_instream_host_buffer_get_info(u32 h_instream, u8 **pp_buffer,
1404     struct hpi_hostbuffer_status **pp_status);
1405 
1406 u16 hpi_adapter_restart(u16 adapter_index);
1407 
1408 /*
1409 The following 3 functions were last declared in header files for
1410 driver 3.10. HPI_ControlQuery() used to be the recommended way
1411 of getting a volume range. Declared here for binary asihpi32.dll
1412 compatibility.
1413 */
1414 
1415 void hpi_format_to_msg(struct hpi_msg_format *pMF,
1416     const struct hpi_format *pF);
1417 void hpi_stream_response_to_legacy(struct hpi_stream_res *pSR);
1418 
1419 /*////////////////////////////////////////////////////////////////////////// */
1420 /* declarations for individual HPI entry points */
1421 hpi_handler_func HPI_6000;
1422 hpi_handler_func HPI_6205;
1423 
1424 #endif              /* _HPI_INTERNAL_H_ */