hpi_internal.h 41 KB

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