sndif.h 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064
  1. /* SPDX-License-Identifier: MIT */
  2. /******************************************************************************
  3. * sndif.h
  4. *
  5. * Unified sound-device I/O interface for Xen guest OSes.
  6. *
  7. * Copyright (C) 2013-2015 GlobalLogic Inc.
  8. * Copyright (C) 2016-2017 EPAM Systems Inc.
  9. *
  10. * Authors: Oleksandr Andrushchenko <[email protected]>
  11. * Oleksandr Grytsov <[email protected]>
  12. * Oleksandr Dmytryshyn <[email protected]>
  13. * Iurii Konovalenko <[email protected]>
  14. */
  15. #ifndef __XEN_PUBLIC_IO_SNDIF_H__
  16. #define __XEN_PUBLIC_IO_SNDIF_H__
  17. #include "ring.h"
  18. #include "../grant_table.h"
  19. /*
  20. ******************************************************************************
  21. * Protocol version
  22. ******************************************************************************
  23. */
  24. #define XENSND_PROTOCOL_VERSION 2
  25. /*
  26. ******************************************************************************
  27. * Feature and Parameter Negotiation
  28. ******************************************************************************
  29. *
  30. * Front->back notifications: when enqueuing a new request, sending a
  31. * notification can be made conditional on xensnd_req (i.e., the generic
  32. * hold-off mechanism provided by the ring macros). Backends must set
  33. * xensnd_req appropriately (e.g., using RING_FINAL_CHECK_FOR_REQUESTS()).
  34. *
  35. * Back->front notifications: when enqueuing a new response, sending a
  36. * notification can be made conditional on xensnd_resp (i.e., the generic
  37. * hold-off mechanism provided by the ring macros). Frontends must set
  38. * xensnd_resp appropriately (e.g., using RING_FINAL_CHECK_FOR_RESPONSES()).
  39. *
  40. * The two halves of a para-virtual sound card driver utilize nodes within
  41. * XenStore to communicate capabilities and to negotiate operating parameters.
  42. * This section enumerates these nodes which reside in the respective front and
  43. * backend portions of XenStore, following the XenBus convention.
  44. *
  45. * All data in XenStore is stored as strings. Nodes specifying numeric
  46. * values are encoded in decimal. Integer value ranges listed below are
  47. * expressed as fixed sized integer types capable of storing the conversion
  48. * of a properly formated node string, without loss of information.
  49. *
  50. ******************************************************************************
  51. * Example configuration
  52. ******************************************************************************
  53. *
  54. * Note: depending on the use-case backend can expose more sound cards and
  55. * PCM devices/streams than the underlying HW physically has by employing
  56. * SW mixers, configuring virtual sound streams, channels etc.
  57. *
  58. * This is an example of backend and frontend configuration:
  59. *
  60. *--------------------------------- Backend -----------------------------------
  61. *
  62. * /local/domain/0/backend/vsnd/1/0/frontend-id = "1"
  63. * /local/domain/0/backend/vsnd/1/0/frontend = "/local/domain/1/device/vsnd/0"
  64. * /local/domain/0/backend/vsnd/1/0/state = "4"
  65. * /local/domain/0/backend/vsnd/1/0/versions = "1,2"
  66. *
  67. *--------------------------------- Frontend ----------------------------------
  68. *
  69. * /local/domain/1/device/vsnd/0/backend-id = "0"
  70. * /local/domain/1/device/vsnd/0/backend = "/local/domain/0/backend/vsnd/1/0"
  71. * /local/domain/1/device/vsnd/0/state = "4"
  72. * /local/domain/1/device/vsnd/0/version = "1"
  73. *
  74. *----------------------------- Card configuration ----------------------------
  75. *
  76. * /local/domain/1/device/vsnd/0/short-name = "Card short name"
  77. * /local/domain/1/device/vsnd/0/long-name = "Card long name"
  78. * /local/domain/1/device/vsnd/0/sample-rates = "8000,32000,44100,48000,96000"
  79. * /local/domain/1/device/vsnd/0/sample-formats = "s8,u8,s16_le,s16_be"
  80. * /local/domain/1/device/vsnd/0/buffer-size = "262144"
  81. *
  82. *------------------------------- PCM device 0 --------------------------------
  83. *
  84. * /local/domain/1/device/vsnd/0/0/name = "General analog"
  85. * /local/domain/1/device/vsnd/0/0/channels-max = "5"
  86. *
  87. *----------------------------- Stream 0, playback ----------------------------
  88. *
  89. * /local/domain/1/device/vsnd/0/0/0/type = "p"
  90. * /local/domain/1/device/vsnd/0/0/0/sample-formats = "s8,u8"
  91. * /local/domain/1/device/vsnd/0/0/0/unique-id = "0"
  92. *
  93. * /local/domain/1/device/vsnd/0/0/0/ring-ref = "386"
  94. * /local/domain/1/device/vsnd/0/0/0/event-channel = "15"
  95. * /local/domain/1/device/vsnd/0/0/0/evt-ring-ref = "1386"
  96. * /local/domain/1/device/vsnd/0/0/0/evt-event-channel = "215"
  97. *
  98. *------------------------------ Stream 1, capture ----------------------------
  99. *
  100. * /local/domain/1/device/vsnd/0/0/1/type = "c"
  101. * /local/domain/1/device/vsnd/0/0/1/channels-max = "2"
  102. * /local/domain/1/device/vsnd/0/0/1/unique-id = "1"
  103. *
  104. * /local/domain/1/device/vsnd/0/0/1/ring-ref = "384"
  105. * /local/domain/1/device/vsnd/0/0/1/event-channel = "13"
  106. * /local/domain/1/device/vsnd/0/0/1/evt-ring-ref = "1384"
  107. * /local/domain/1/device/vsnd/0/0/1/evt-event-channel = "213"
  108. *
  109. *------------------------------- PCM device 1 --------------------------------
  110. *
  111. * /local/domain/1/device/vsnd/0/1/name = "HDMI-0"
  112. * /local/domain/1/device/vsnd/0/1/sample-rates = "8000,32000,44100"
  113. *
  114. *------------------------------ Stream 0, capture ----------------------------
  115. *
  116. * /local/domain/1/device/vsnd/0/1/0/type = "c"
  117. * /local/domain/1/device/vsnd/0/1/0/unique-id = "2"
  118. *
  119. * /local/domain/1/device/vsnd/0/1/0/ring-ref = "387"
  120. * /local/domain/1/device/vsnd/0/1/0/event-channel = "151"
  121. * /local/domain/1/device/vsnd/0/1/0/evt-ring-ref = "1387"
  122. * /local/domain/1/device/vsnd/0/1/0/evt-event-channel = "351"
  123. *
  124. *------------------------------- PCM device 2 --------------------------------
  125. *
  126. * /local/domain/1/device/vsnd/0/2/name = "SPDIF"
  127. *
  128. *----------------------------- Stream 0, playback ----------------------------
  129. *
  130. * /local/domain/1/device/vsnd/0/2/0/type = "p"
  131. * /local/domain/1/device/vsnd/0/2/0/unique-id = "3"
  132. *
  133. * /local/domain/1/device/vsnd/0/2/0/ring-ref = "389"
  134. * /local/domain/1/device/vsnd/0/2/0/event-channel = "152"
  135. * /local/domain/1/device/vsnd/0/2/0/evt-ring-ref = "1389"
  136. * /local/domain/1/device/vsnd/0/2/0/evt-event-channel = "452"
  137. *
  138. ******************************************************************************
  139. * Backend XenBus Nodes
  140. ******************************************************************************
  141. *
  142. *----------------------------- Protocol version ------------------------------
  143. *
  144. * versions
  145. * Values: <string>
  146. *
  147. * List of XENSND_LIST_SEPARATOR separated protocol versions supported
  148. * by the backend. For example "1,2,3".
  149. *
  150. ******************************************************************************
  151. * Frontend XenBus Nodes
  152. ******************************************************************************
  153. *
  154. *-------------------------------- Addressing ---------------------------------
  155. *
  156. * dom-id
  157. * Values: <uint16_t>
  158. *
  159. * Domain identifier.
  160. *
  161. * dev-id
  162. * Values: <uint16_t>
  163. *
  164. * Device identifier.
  165. *
  166. * pcm-dev-idx
  167. * Values: <uint8_t>
  168. *
  169. * Zero based contigous index of the PCM device.
  170. *
  171. * stream-idx
  172. * Values: <uint8_t>
  173. *
  174. * Zero based contigous index of the stream of the PCM device.
  175. *
  176. * The following pattern is used for addressing:
  177. * /local/domain/<dom-id>/device/vsnd/<dev-id>/<pcm-dev-idx>/<stream-idx>/...
  178. *
  179. *----------------------------- Protocol version ------------------------------
  180. *
  181. * version
  182. * Values: <string>
  183. *
  184. * Protocol version, chosen among the ones supported by the backend.
  185. *
  186. *------------------------------- PCM settings --------------------------------
  187. *
  188. * Every virtualized sound frontend has a set of PCM devices and streams, each
  189. * could be individually configured. Part of the PCM configuration can be
  190. * defined at higher level of the hierarchy and be fully or partially re-used
  191. * by the underlying layers. These configuration values are:
  192. * o number of channels (min/max)
  193. * o supported sample rates
  194. * o supported sample formats.
  195. * E.g. one can define these values for the whole card, device or stream.
  196. * Every underlying layer in turn can re-define some or all of them to better
  197. * fit its needs. For example, card may define number of channels to be
  198. * in [1; 8] range, and some particular stream may be limited to [1; 2] only.
  199. * The rule is that the underlying layer must be a subset of the upper layer
  200. * range.
  201. *
  202. * channels-min
  203. * Values: <uint8_t>
  204. *
  205. * The minimum amount of channels that is supported, [1; channels-max].
  206. * Optional, if not set or omitted a value of 1 is used.
  207. *
  208. * channels-max
  209. * Values: <uint8_t>
  210. *
  211. * The maximum amount of channels that is supported.
  212. * Must be at least <channels-min>.
  213. *
  214. * sample-rates
  215. * Values: <list of uint32_t>
  216. *
  217. * List of supported sample rates separated by XENSND_LIST_SEPARATOR.
  218. * Sample rates are expressed as a list of decimal values w/o any
  219. * ordering requirement.
  220. *
  221. * sample-formats
  222. * Values: <list of XENSND_PCM_FORMAT_XXX_STR>
  223. *
  224. * List of supported sample formats separated by XENSND_LIST_SEPARATOR.
  225. * Items must not exceed XENSND_SAMPLE_FORMAT_MAX_LEN length.
  226. *
  227. * buffer-size
  228. * Values: <uint32_t>
  229. *
  230. * The maximum size in octets of the buffer to allocate per stream.
  231. *
  232. *----------------------- Virtual sound card settings -------------------------
  233. * short-name
  234. * Values: <char[32]>
  235. *
  236. * Short name of the virtual sound card. Optional.
  237. *
  238. * long-name
  239. * Values: <char[80]>
  240. *
  241. * Long name of the virtual sound card. Optional.
  242. *
  243. *----------------------------- Device settings -------------------------------
  244. * name
  245. * Values: <char[80]>
  246. *
  247. * Name of the sound device within the virtual sound card. Optional.
  248. *
  249. *----------------------------- Stream settings -------------------------------
  250. *
  251. * type
  252. * Values: "p", "c"
  253. *
  254. * Stream type: "p" - playback stream, "c" - capture stream
  255. *
  256. * If both capture and playback are needed then two streams need to be
  257. * defined under the same device.
  258. *
  259. * unique-id
  260. * Values: <string>
  261. *
  262. * After stream initialization it is assigned a unique ID, so every
  263. * stream of the frontend can be identified by the backend by this ID.
  264. * This can be UUID or such.
  265. *
  266. *-------------------- Stream Request Transport Parameters --------------------
  267. *
  268. * event-channel
  269. * Values: <uint32_t>
  270. *
  271. * The identifier of the Xen event channel used to signal activity
  272. * in the ring buffer.
  273. *
  274. * ring-ref
  275. * Values: <uint32_t>
  276. *
  277. * The Xen grant reference granting permission for the backend to map
  278. * a sole page in a single page sized ring buffer.
  279. *
  280. *--------------------- Stream Event Transport Parameters ---------------------
  281. *
  282. * This communication path is used to deliver asynchronous events from backend
  283. * to frontend, set up per stream.
  284. *
  285. * evt-event-channel
  286. * Values: <uint32_t>
  287. *
  288. * The identifier of the Xen event channel used to signal activity
  289. * in the ring buffer.
  290. *
  291. * evt-ring-ref
  292. * Values: <uint32_t>
  293. *
  294. * The Xen grant reference granting permission for the backend to map
  295. * a sole page in a single page sized ring buffer.
  296. *
  297. ******************************************************************************
  298. * STATE DIAGRAMS
  299. ******************************************************************************
  300. *
  301. * Tool stack creates front and back state nodes with initial state
  302. * XenbusStateInitialising.
  303. * Tool stack creates and sets up frontend sound configuration nodes per domain.
  304. *
  305. * Front Back
  306. * ================================= =====================================
  307. * XenbusStateInitialising XenbusStateInitialising
  308. * o Query backend device identification
  309. * data.
  310. * o Open and validate backend device.
  311. * |
  312. * |
  313. * V
  314. * XenbusStateInitWait
  315. *
  316. * o Query frontend configuration
  317. * o Allocate and initialize
  318. * event channels per configured
  319. * playback/capture stream.
  320. * o Publish transport parameters
  321. * that will be in effect during
  322. * this connection.
  323. * |
  324. * |
  325. * V
  326. * XenbusStateInitialised
  327. *
  328. * o Query frontend transport parameters.
  329. * o Connect to the event channels.
  330. * |
  331. * |
  332. * V
  333. * XenbusStateConnected
  334. *
  335. * o Create and initialize OS
  336. * virtual sound device instances
  337. * as per configuration.
  338. * |
  339. * |
  340. * V
  341. * XenbusStateConnected
  342. *
  343. * XenbusStateUnknown
  344. * XenbusStateClosed
  345. * XenbusStateClosing
  346. * o Remove virtual sound device
  347. * o Remove event channels
  348. * |
  349. * |
  350. * V
  351. * XenbusStateClosed
  352. *
  353. *------------------------------- Recovery flow -------------------------------
  354. *
  355. * In case of frontend unrecoverable errors backend handles that as
  356. * if frontend goes into the XenbusStateClosed state.
  357. *
  358. * In case of backend unrecoverable errors frontend tries removing
  359. * the virtualized device. If this is possible at the moment of error,
  360. * then frontend goes into the XenbusStateInitialising state and is ready for
  361. * new connection with backend. If the virtualized device is still in use and
  362. * cannot be removed, then frontend goes into the XenbusStateReconfiguring state
  363. * until either the virtualized device removed or backend initiates a new
  364. * connection. On the virtualized device removal frontend goes into the
  365. * XenbusStateInitialising state.
  366. *
  367. * Note on XenbusStateReconfiguring state of the frontend: if backend has
  368. * unrecoverable errors then frontend cannot send requests to the backend
  369. * and thus cannot provide functionality of the virtualized device anymore.
  370. * After backend is back to normal the virtualized device may still hold some
  371. * state: configuration in use, allocated buffers, client application state etc.
  372. * So, in most cases, this will require frontend to implement complex recovery
  373. * reconnect logic. Instead, by going into XenbusStateReconfiguring state,
  374. * frontend will make sure no new clients of the virtualized device are
  375. * accepted, allow existing client(s) to exit gracefully by signaling error
  376. * state etc.
  377. * Once all the clients are gone frontend can reinitialize the virtualized
  378. * device and get into XenbusStateInitialising state again signaling the
  379. * backend that a new connection can be made.
  380. *
  381. * There are multiple conditions possible under which frontend will go from
  382. * XenbusStateReconfiguring into XenbusStateInitialising, some of them are OS
  383. * specific. For example:
  384. * 1. The underlying OS framework may provide callbacks to signal that the last
  385. * client of the virtualized device has gone and the device can be removed
  386. * 2. Frontend can schedule a deferred work (timer/tasklet/workqueue)
  387. * to periodically check if this is the right time to re-try removal of
  388. * the virtualized device.
  389. * 3. By any other means.
  390. *
  391. ******************************************************************************
  392. * PCM FORMATS
  393. ******************************************************************************
  394. *
  395. * XENSND_PCM_FORMAT_<format>[_<endian>]
  396. *
  397. * format: <S/U/F><bits> or <name>
  398. * S - signed, U - unsigned, F - float
  399. * bits - 8, 16, 24, 32
  400. * name - MU_LAW, GSM, etc.
  401. *
  402. * endian: <LE/BE>, may be absent
  403. * LE - Little endian, BE - Big endian
  404. */
  405. #define XENSND_PCM_FORMAT_S8 0
  406. #define XENSND_PCM_FORMAT_U8 1
  407. #define XENSND_PCM_FORMAT_S16_LE 2
  408. #define XENSND_PCM_FORMAT_S16_BE 3
  409. #define XENSND_PCM_FORMAT_U16_LE 4
  410. #define XENSND_PCM_FORMAT_U16_BE 5
  411. #define XENSND_PCM_FORMAT_S24_LE 6
  412. #define XENSND_PCM_FORMAT_S24_BE 7
  413. #define XENSND_PCM_FORMAT_U24_LE 8
  414. #define XENSND_PCM_FORMAT_U24_BE 9
  415. #define XENSND_PCM_FORMAT_S32_LE 10
  416. #define XENSND_PCM_FORMAT_S32_BE 11
  417. #define XENSND_PCM_FORMAT_U32_LE 12
  418. #define XENSND_PCM_FORMAT_U32_BE 13
  419. #define XENSND_PCM_FORMAT_F32_LE 14 /* 4-byte float, IEEE-754 32-bit, */
  420. #define XENSND_PCM_FORMAT_F32_BE 15 /* range -1.0 to 1.0 */
  421. #define XENSND_PCM_FORMAT_F64_LE 16 /* 8-byte float, IEEE-754 64-bit, */
  422. #define XENSND_PCM_FORMAT_F64_BE 17 /* range -1.0 to 1.0 */
  423. #define XENSND_PCM_FORMAT_IEC958_SUBFRAME_LE 18
  424. #define XENSND_PCM_FORMAT_IEC958_SUBFRAME_BE 19
  425. #define XENSND_PCM_FORMAT_MU_LAW 20
  426. #define XENSND_PCM_FORMAT_A_LAW 21
  427. #define XENSND_PCM_FORMAT_IMA_ADPCM 22
  428. #define XENSND_PCM_FORMAT_MPEG 23
  429. #define XENSND_PCM_FORMAT_GSM 24
  430. /*
  431. ******************************************************************************
  432. * REQUEST CODES
  433. ******************************************************************************
  434. */
  435. #define XENSND_OP_OPEN 0
  436. #define XENSND_OP_CLOSE 1
  437. #define XENSND_OP_READ 2
  438. #define XENSND_OP_WRITE 3
  439. #define XENSND_OP_SET_VOLUME 4
  440. #define XENSND_OP_GET_VOLUME 5
  441. #define XENSND_OP_MUTE 6
  442. #define XENSND_OP_UNMUTE 7
  443. #define XENSND_OP_TRIGGER 8
  444. #define XENSND_OP_HW_PARAM_QUERY 9
  445. #define XENSND_OP_TRIGGER_START 0
  446. #define XENSND_OP_TRIGGER_PAUSE 1
  447. #define XENSND_OP_TRIGGER_STOP 2
  448. #define XENSND_OP_TRIGGER_RESUME 3
  449. /*
  450. ******************************************************************************
  451. * EVENT CODES
  452. ******************************************************************************
  453. */
  454. #define XENSND_EVT_CUR_POS 0
  455. /*
  456. ******************************************************************************
  457. * XENSTORE FIELD AND PATH NAME STRINGS, HELPERS
  458. ******************************************************************************
  459. */
  460. #define XENSND_DRIVER_NAME "vsnd"
  461. #define XENSND_LIST_SEPARATOR ","
  462. /* Field names */
  463. #define XENSND_FIELD_BE_VERSIONS "versions"
  464. #define XENSND_FIELD_FE_VERSION "version"
  465. #define XENSND_FIELD_VCARD_SHORT_NAME "short-name"
  466. #define XENSND_FIELD_VCARD_LONG_NAME "long-name"
  467. #define XENSND_FIELD_RING_REF "ring-ref"
  468. #define XENSND_FIELD_EVT_CHNL "event-channel"
  469. #define XENSND_FIELD_EVT_RING_REF "evt-ring-ref"
  470. #define XENSND_FIELD_EVT_EVT_CHNL "evt-event-channel"
  471. #define XENSND_FIELD_DEVICE_NAME "name"
  472. #define XENSND_FIELD_TYPE "type"
  473. #define XENSND_FIELD_STREAM_UNIQUE_ID "unique-id"
  474. #define XENSND_FIELD_CHANNELS_MIN "channels-min"
  475. #define XENSND_FIELD_CHANNELS_MAX "channels-max"
  476. #define XENSND_FIELD_SAMPLE_RATES "sample-rates"
  477. #define XENSND_FIELD_SAMPLE_FORMATS "sample-formats"
  478. #define XENSND_FIELD_BUFFER_SIZE "buffer-size"
  479. /* Stream type field values. */
  480. #define XENSND_STREAM_TYPE_PLAYBACK "p"
  481. #define XENSND_STREAM_TYPE_CAPTURE "c"
  482. /* Sample rate max string length */
  483. #define XENSND_SAMPLE_RATE_MAX_LEN 11
  484. /* Sample format field values */
  485. #define XENSND_SAMPLE_FORMAT_MAX_LEN 24
  486. #define XENSND_PCM_FORMAT_S8_STR "s8"
  487. #define XENSND_PCM_FORMAT_U8_STR "u8"
  488. #define XENSND_PCM_FORMAT_S16_LE_STR "s16_le"
  489. #define XENSND_PCM_FORMAT_S16_BE_STR "s16_be"
  490. #define XENSND_PCM_FORMAT_U16_LE_STR "u16_le"
  491. #define XENSND_PCM_FORMAT_U16_BE_STR "u16_be"
  492. #define XENSND_PCM_FORMAT_S24_LE_STR "s24_le"
  493. #define XENSND_PCM_FORMAT_S24_BE_STR "s24_be"
  494. #define XENSND_PCM_FORMAT_U24_LE_STR "u24_le"
  495. #define XENSND_PCM_FORMAT_U24_BE_STR "u24_be"
  496. #define XENSND_PCM_FORMAT_S32_LE_STR "s32_le"
  497. #define XENSND_PCM_FORMAT_S32_BE_STR "s32_be"
  498. #define XENSND_PCM_FORMAT_U32_LE_STR "u32_le"
  499. #define XENSND_PCM_FORMAT_U32_BE_STR "u32_be"
  500. #define XENSND_PCM_FORMAT_F32_LE_STR "float_le"
  501. #define XENSND_PCM_FORMAT_F32_BE_STR "float_be"
  502. #define XENSND_PCM_FORMAT_F64_LE_STR "float64_le"
  503. #define XENSND_PCM_FORMAT_F64_BE_STR "float64_be"
  504. #define XENSND_PCM_FORMAT_IEC958_SUBFRAME_LE_STR "iec958_subframe_le"
  505. #define XENSND_PCM_FORMAT_IEC958_SUBFRAME_BE_STR "iec958_subframe_be"
  506. #define XENSND_PCM_FORMAT_MU_LAW_STR "mu_law"
  507. #define XENSND_PCM_FORMAT_A_LAW_STR "a_law"
  508. #define XENSND_PCM_FORMAT_IMA_ADPCM_STR "ima_adpcm"
  509. #define XENSND_PCM_FORMAT_MPEG_STR "mpeg"
  510. #define XENSND_PCM_FORMAT_GSM_STR "gsm"
  511. /*
  512. ******************************************************************************
  513. * STATUS RETURN CODES
  514. ******************************************************************************
  515. *
  516. * Status return code is zero on success and -XEN_EXX on failure.
  517. *
  518. ******************************************************************************
  519. * Assumptions
  520. ******************************************************************************
  521. * o usage of grant reference 0 as invalid grant reference:
  522. * grant reference 0 is valid, but never exposed to a PV driver,
  523. * because of the fact it is already in use/reserved by the PV console.
  524. * o all references in this document to page sizes must be treated
  525. * as pages of size XEN_PAGE_SIZE unless otherwise noted.
  526. *
  527. ******************************************************************************
  528. * Description of the protocol between frontend and backend driver
  529. ******************************************************************************
  530. *
  531. * The two halves of a Para-virtual sound driver communicate with
  532. * each other using shared pages and event channels.
  533. * Shared page contains a ring with request/response packets.
  534. *
  535. * Packets, used for input/output operations, e.g. read/write, set/get volume,
  536. * etc., provide offset/length fields in order to allow asynchronous protocol
  537. * operation with buffer space sharing: part of the buffer allocated at
  538. * XENSND_OP_OPEN can be used for audio samples and part, for example,
  539. * for volume control.
  540. *
  541. * All reserved fields in the structures below must be 0.
  542. *
  543. *---------------------------------- Requests ---------------------------------
  544. *
  545. * All request packets have the same length (64 octets)
  546. * All request packets have common header:
  547. * 0 1 2 3 octet
  548. * +----------------+----------------+----------------+----------------+
  549. * | id | operation | reserved | 4
  550. * +----------------+----------------+----------------+----------------+
  551. * | reserved | 8
  552. * +----------------+----------------+----------------+----------------+
  553. * id - uint16_t, private guest value, echoed in response
  554. * operation - uint8_t, operation code, XENSND_OP_???
  555. *
  556. * For all packets which use offset and length:
  557. * offset - uint32_t, read or write data offset within the shared buffer,
  558. * passed with XENSND_OP_OPEN request, octets,
  559. * [0; XENSND_OP_OPEN.buffer_sz - 1].
  560. * length - uint32_t, read or write data length, octets
  561. *
  562. * Request open - open a PCM stream for playback or capture:
  563. *
  564. * 0 1 2 3 octet
  565. * +----------------+----------------+----------------+----------------+
  566. * | id | XENSND_OP_OPEN | reserved | 4
  567. * +----------------+----------------+----------------+----------------+
  568. * | reserved | 8
  569. * +----------------+----------------+----------------+----------------+
  570. * | pcm_rate | 12
  571. * +----------------+----------------+----------------+----------------+
  572. * | pcm_format | pcm_channels | reserved | 16
  573. * +----------------+----------------+----------------+----------------+
  574. * | buffer_sz | 20
  575. * +----------------+----------------+----------------+----------------+
  576. * | gref_directory | 24
  577. * +----------------+----------------+----------------+----------------+
  578. * | period_sz | 28
  579. * +----------------+----------------+----------------+----------------+
  580. * | reserved | 32
  581. * +----------------+----------------+----------------+----------------+
  582. * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
  583. * +----------------+----------------+----------------+----------------+
  584. * | reserved | 64
  585. * +----------------+----------------+----------------+----------------+
  586. *
  587. * pcm_rate - uint32_t, stream data rate, Hz
  588. * pcm_format - uint8_t, XENSND_PCM_FORMAT_XXX value
  589. * pcm_channels - uint8_t, number of channels of this stream,
  590. * [channels-min; channels-max]
  591. * buffer_sz - uint32_t, buffer size to be allocated, octets
  592. * period_sz - uint32_t, event period size, octets
  593. * This is the requested value of the period at which frontend would
  594. * like to receive XENSND_EVT_CUR_POS notifications from the backend when
  595. * stream position advances during playback/capture.
  596. * It shows how many octets are expected to be played/captured before
  597. * sending such an event.
  598. * If set to 0 no XENSND_EVT_CUR_POS events are sent by the backend.
  599. *
  600. * gref_directory - grant_ref_t, a reference to the first shared page
  601. * describing shared buffer references. At least one page exists. If shared
  602. * buffer size (buffer_sz) exceeds what can be addressed by this single page,
  603. * then reference to the next page must be supplied (see gref_dir_next_page
  604. * below)
  605. */
  606. struct xensnd_open_req {
  607. uint32_t pcm_rate;
  608. uint8_t pcm_format;
  609. uint8_t pcm_channels;
  610. uint16_t reserved;
  611. uint32_t buffer_sz;
  612. grant_ref_t gref_directory;
  613. uint32_t period_sz;
  614. };
  615. /*
  616. * Shared page for XENSND_OP_OPEN buffer descriptor (gref_directory in the
  617. * request) employs a list of pages, describing all pages of the shared data
  618. * buffer:
  619. * 0 1 2 3 octet
  620. * +----------------+----------------+----------------+----------------+
  621. * | gref_dir_next_page | 4
  622. * +----------------+----------------+----------------+----------------+
  623. * | gref[0] | 8
  624. * +----------------+----------------+----------------+----------------+
  625. * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
  626. * +----------------+----------------+----------------+----------------+
  627. * | gref[i] | i*4+8
  628. * +----------------+----------------+----------------+----------------+
  629. * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
  630. * +----------------+----------------+----------------+----------------+
  631. * | gref[N - 1] | N*4+8
  632. * +----------------+----------------+----------------+----------------+
  633. *
  634. * gref_dir_next_page - grant_ref_t, reference to the next page describing
  635. * page directory. Must be 0 if there are no more pages in the list.
  636. * gref[i] - grant_ref_t, reference to a shared page of the buffer
  637. * allocated at XENSND_OP_OPEN
  638. *
  639. * Number of grant_ref_t entries in the whole page directory is not
  640. * passed, but instead can be calculated as:
  641. * num_grefs_total = (XENSND_OP_OPEN.buffer_sz + XEN_PAGE_SIZE - 1) /
  642. * XEN_PAGE_SIZE
  643. */
  644. struct xensnd_page_directory {
  645. grant_ref_t gref_dir_next_page;
  646. grant_ref_t gref[1]; /* Variable length */
  647. };
  648. /*
  649. * Request close - close an opened pcm stream:
  650. * 0 1 2 3 octet
  651. * +----------------+----------------+----------------+----------------+
  652. * | id | XENSND_OP_CLOSE| reserved | 4
  653. * +----------------+----------------+----------------+----------------+
  654. * | reserved | 8
  655. * +----------------+----------------+----------------+----------------+
  656. * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
  657. * +----------------+----------------+----------------+----------------+
  658. * | reserved | 64
  659. * +----------------+----------------+----------------+----------------+
  660. *
  661. * Request read/write - used for read (for capture) or write (for playback):
  662. * 0 1 2 3 octet
  663. * +----------------+----------------+----------------+----------------+
  664. * | id | operation | reserved | 4
  665. * +----------------+----------------+----------------+----------------+
  666. * | reserved | 8
  667. * +----------------+----------------+----------------+----------------+
  668. * | offset | 12
  669. * +----------------+----------------+----------------+----------------+
  670. * | length | 16
  671. * +----------------+----------------+----------------+----------------+
  672. * | reserved | 20
  673. * +----------------+----------------+----------------+----------------+
  674. * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
  675. * +----------------+----------------+----------------+----------------+
  676. * | reserved | 64
  677. * +----------------+----------------+----------------+----------------+
  678. *
  679. * operation - XENSND_OP_READ for read or XENSND_OP_WRITE for write
  680. */
  681. struct xensnd_rw_req {
  682. uint32_t offset;
  683. uint32_t length;
  684. };
  685. /*
  686. * Request set/get volume - set/get channels' volume of the stream given:
  687. * 0 1 2 3 octet
  688. * +----------------+----------------+----------------+----------------+
  689. * | id | operation | reserved | 4
  690. * +----------------+----------------+----------------+----------------+
  691. * | reserved | 8
  692. * +----------------+----------------+----------------+----------------+
  693. * | offset | 12
  694. * +----------------+----------------+----------------+----------------+
  695. * | length | 16
  696. * +----------------+----------------+----------------+----------------+
  697. * | reserved | 20
  698. * +----------------+----------------+----------------+----------------+
  699. * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
  700. * +----------------+----------------+----------------+----------------+
  701. * | reserved | 64
  702. * +----------------+----------------+----------------+----------------+
  703. *
  704. * operation - XENSND_OP_SET_VOLUME for volume set
  705. * or XENSND_OP_GET_VOLUME for volume get
  706. * Buffer passed with XENSND_OP_OPEN is used to exchange volume
  707. * values:
  708. *
  709. * 0 1 2 3 octet
  710. * +----------------+----------------+----------------+----------------+
  711. * | channel[0] | 4
  712. * +----------------+----------------+----------------+----------------+
  713. * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
  714. * +----------------+----------------+----------------+----------------+
  715. * | channel[i] | i*4
  716. * +----------------+----------------+----------------+----------------+
  717. * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
  718. * +----------------+----------------+----------------+----------------+
  719. * | channel[N - 1] | (N-1)*4
  720. * +----------------+----------------+----------------+----------------+
  721. *
  722. * N = XENSND_OP_OPEN.pcm_channels
  723. * i - uint8_t, index of a channel
  724. * channel[i] - sint32_t, volume of i-th channel
  725. * Volume is expressed as a signed value in steps of 0.001 dB,
  726. * while 0 being 0 dB.
  727. *
  728. * Request mute/unmute - mute/unmute stream:
  729. * 0 1 2 3 octet
  730. * +----------------+----------------+----------------+----------------+
  731. * | id | operation | reserved | 4
  732. * +----------------+----------------+----------------+----------------+
  733. * | reserved | 8
  734. * +----------------+----------------+----------------+----------------+
  735. * | offset | 12
  736. * +----------------+----------------+----------------+----------------+
  737. * | length | 16
  738. * +----------------+----------------+----------------+----------------+
  739. * | reserved | 20
  740. * +----------------+----------------+----------------+----------------+
  741. * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
  742. * +----------------+----------------+----------------+----------------+
  743. * | reserved | 64
  744. * +----------------+----------------+----------------+----------------+
  745. *
  746. * operation - XENSND_OP_MUTE for mute or XENSND_OP_UNMUTE for unmute
  747. * Buffer passed with XENSND_OP_OPEN is used to exchange mute/unmute
  748. * values:
  749. *
  750. * 0 octet
  751. * +----------------+----------------+----------------+----------------+
  752. * | channel[0] | 4
  753. * +----------------+----------------+----------------+----------------+
  754. * +/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
  755. * +----------------+----------------+----------------+----------------+
  756. * | channel[i] | i*4
  757. * +----------------+----------------+----------------+----------------+
  758. * +/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
  759. * +----------------+----------------+----------------+----------------+
  760. * | channel[N - 1] | (N-1)*4
  761. * +----------------+----------------+----------------+----------------+
  762. *
  763. * N = XENSND_OP_OPEN.pcm_channels
  764. * i - uint8_t, index of a channel
  765. * channel[i] - uint8_t, non-zero if i-th channel needs to be muted/unmuted
  766. *
  767. *------------------------------------ N.B. -----------------------------------
  768. *
  769. * The 'struct xensnd_rw_req' is also used for XENSND_OP_SET_VOLUME,
  770. * XENSND_OP_GET_VOLUME, XENSND_OP_MUTE, XENSND_OP_UNMUTE.
  771. *
  772. * Request stream running state change - trigger PCM stream running state
  773. * to start, stop, pause or resume:
  774. *
  775. * 0 1 2 3 octet
  776. * +----------------+----------------+----------------+----------------+
  777. * | id | _OP_TRIGGER | reserved | 4
  778. * +----------------+----------------+----------------+----------------+
  779. * | reserved | 8
  780. * +----------------+----------------+----------------+----------------+
  781. * | type | reserved | 12
  782. * +----------------+----------------+----------------+----------------+
  783. * | reserved | 16
  784. * +----------------+----------------+----------------+----------------+
  785. * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
  786. * +----------------+----------------+----------------+----------------+
  787. * | reserved | 64
  788. * +----------------+----------------+----------------+----------------+
  789. *
  790. * type - uint8_t, XENSND_OP_TRIGGER_XXX value
  791. */
  792. struct xensnd_trigger_req {
  793. uint8_t type;
  794. };
  795. /*
  796. * Request stream parameter ranges: request intervals and
  797. * masks of supported ranges for stream configuration values.
  798. *
  799. * Sound device configuration for a particular stream is a limited subset
  800. * of the multidimensional configuration available on XenStore, e.g.
  801. * once the frame rate has been selected there is a limited supported range
  802. * for sample rates becomes available (which might be the same set configured
  803. * on XenStore or less). For example, selecting 96kHz sample rate may limit
  804. * number of channels available for such configuration from 4 to 2, etc.
  805. * Thus, each call to XENSND_OP_HW_PARAM_QUERY may reduce configuration
  806. * space making it possible to iteratively get the final stream configuration,
  807. * used in XENSND_OP_OPEN request.
  808. *
  809. * See response format for this request.
  810. *
  811. * 0 1 2 3 octet
  812. * +----------------+----------------+----------------+----------------+
  813. * | id | _HW_PARAM_QUERY| reserved | 4
  814. * +----------------+----------------+----------------+----------------+
  815. * | reserved | 8
  816. * +----------------+----------------+----------------+----------------+
  817. * | formats mask low 32-bit | 12
  818. * +----------------+----------------+----------------+----------------+
  819. * | formats mask high 32-bit | 16
  820. * +----------------+----------------+----------------+----------------+
  821. * | min rate | 20
  822. * +----------------+----------------+----------------+----------------+
  823. * | max rate | 24
  824. * +----------------+----------------+----------------+----------------+
  825. * | min channels | 28
  826. * +----------------+----------------+----------------+----------------+
  827. * | max channels | 32
  828. * +----------------+----------------+----------------+----------------+
  829. * | min buffer frames | 36
  830. * +----------------+----------------+----------------+----------------+
  831. * | max buffer frames | 40
  832. * +----------------+----------------+----------------+----------------+
  833. * | min period frames | 44
  834. * +----------------+----------------+----------------+----------------+
  835. * | max period frames | 48
  836. * +----------------+----------------+----------------+----------------+
  837. * | reserved | 52
  838. * +----------------+----------------+----------------+----------------+
  839. * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
  840. * +----------------+----------------+----------------+----------------+
  841. * | reserved | 64
  842. * +----------------+----------------+----------------+----------------+
  843. *
  844. * formats - uint64_t, bit mask representing values of the parameter
  845. * made as bitwise OR of (1 << XENSND_PCM_FORMAT_XXX) values
  846. *
  847. * For interval parameters:
  848. * min - uint32_t, minimum value of the parameter
  849. * max - uint32_t, maximum value of the parameter
  850. *
  851. * Frame is defined as a product of the number of channels by the
  852. * number of octets per one sample.
  853. */
  854. struct xensnd_query_hw_param {
  855. uint64_t formats;
  856. struct {
  857. uint32_t min;
  858. uint32_t max;
  859. } rates;
  860. struct {
  861. uint32_t min;
  862. uint32_t max;
  863. } channels;
  864. struct {
  865. uint32_t min;
  866. uint32_t max;
  867. } buffer;
  868. struct {
  869. uint32_t min;
  870. uint32_t max;
  871. } period;
  872. };
  873. /*
  874. *---------------------------------- Responses --------------------------------
  875. *
  876. * All response packets have the same length (64 octets)
  877. *
  878. * All response packets have common header:
  879. * 0 1 2 3 octet
  880. * +----------------+----------------+----------------+----------------+
  881. * | id | operation | reserved | 4
  882. * +----------------+----------------+----------------+----------------+
  883. * | status | 8
  884. * +----------------+----------------+----------------+----------------+
  885. *
  886. * id - uint16_t, copied from the request
  887. * operation - uint8_t, XENSND_OP_* - copied from request
  888. * status - int32_t, response status, zero on success and -XEN_EXX on failure
  889. *
  890. *
  891. * HW parameter query response - response for XENSND_OP_HW_PARAM_QUERY:
  892. * 0 1 2 3 octet
  893. * +----------------+----------------+----------------+----------------+
  894. * | id | operation | reserved | 4
  895. * +----------------+----------------+----------------+----------------+
  896. * | status | 8
  897. * +----------------+----------------+----------------+----------------+
  898. * | formats mask low 32-bit | 12
  899. * +----------------+----------------+----------------+----------------+
  900. * | formats mask high 32-bit | 16
  901. * +----------------+----------------+----------------+----------------+
  902. * | min rate | 20
  903. * +----------------+----------------+----------------+----------------+
  904. * | max rate | 24
  905. * +----------------+----------------+----------------+----------------+
  906. * | min channels | 28
  907. * +----------------+----------------+----------------+----------------+
  908. * | max channels | 32
  909. * +----------------+----------------+----------------+----------------+
  910. * | min buffer frames | 36
  911. * +----------------+----------------+----------------+----------------+
  912. * | max buffer frames | 40
  913. * +----------------+----------------+----------------+----------------+
  914. * | min period frames | 44
  915. * +----------------+----------------+----------------+----------------+
  916. * | max period frames | 48
  917. * +----------------+----------------+----------------+----------------+
  918. * | reserved | 52
  919. * +----------------+----------------+----------------+----------------+
  920. * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
  921. * +----------------+----------------+----------------+----------------+
  922. * | reserved | 64
  923. * +----------------+----------------+----------------+----------------+
  924. *
  925. * Meaning of the values in this response is the same as for
  926. * XENSND_OP_HW_PARAM_QUERY request.
  927. */
  928. /*
  929. *----------------------------------- Events ----------------------------------
  930. *
  931. * Events are sent via shared page allocated by the front and propagated by
  932. * evt-event-channel/evt-ring-ref XenStore entries
  933. * All event packets have the same length (64 octets)
  934. * All event packets have common header:
  935. * 0 1 2 3 octet
  936. * +----------------+----------------+----------------+----------------+
  937. * | id | type | reserved | 4
  938. * +----------------+----------------+----------------+----------------+
  939. * | reserved | 8
  940. * +----------------+----------------+----------------+----------------+
  941. *
  942. * id - uint16_t, event id, may be used by front
  943. * type - uint8_t, type of the event
  944. *
  945. *
  946. * Current stream position - event from back to front when stream's
  947. * playback/capture position has advanced:
  948. * 0 1 2 3 octet
  949. * +----------------+----------------+----------------+----------------+
  950. * | id | _EVT_CUR_POS | reserved | 4
  951. * +----------------+----------------+----------------+----------------+
  952. * | reserved | 8
  953. * +----------------+----------------+----------------+----------------+
  954. * | position low 32-bit | 12
  955. * +----------------+----------------+----------------+----------------+
  956. * | position high 32-bit | 16
  957. * +----------------+----------------+----------------+----------------+
  958. * | reserved | 20
  959. * +----------------+----------------+----------------+----------------+
  960. * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
  961. * +----------------+----------------+----------------+----------------+
  962. * | reserved | 64
  963. * +----------------+----------------+----------------+----------------+
  964. *
  965. * position - current value of stream's playback/capture position, octets
  966. *
  967. */
  968. struct xensnd_cur_pos_evt {
  969. uint64_t position;
  970. };
  971. struct xensnd_req {
  972. uint16_t id;
  973. uint8_t operation;
  974. uint8_t reserved[5];
  975. union {
  976. struct xensnd_open_req open;
  977. struct xensnd_rw_req rw;
  978. struct xensnd_trigger_req trigger;
  979. struct xensnd_query_hw_param hw_param;
  980. uint8_t reserved[56];
  981. } op;
  982. };
  983. struct xensnd_resp {
  984. uint16_t id;
  985. uint8_t operation;
  986. uint8_t reserved;
  987. int32_t status;
  988. union {
  989. struct xensnd_query_hw_param hw_param;
  990. uint8_t reserved1[56];
  991. } resp;
  992. };
  993. struct xensnd_evt {
  994. uint16_t id;
  995. uint8_t type;
  996. uint8_t reserved[5];
  997. union {
  998. struct xensnd_cur_pos_evt cur_pos;
  999. uint8_t reserved[56];
  1000. } op;
  1001. };
  1002. DEFINE_RING_TYPES(xen_sndif, struct xensnd_req, struct xensnd_resp);
  1003. /*
  1004. ******************************************************************************
  1005. * Back to front events delivery
  1006. ******************************************************************************
  1007. * In order to deliver asynchronous events from back to front a shared page is
  1008. * allocated by front and its granted reference propagated to back via
  1009. * XenStore entries (evt-ring-ref/evt-event-channel).
  1010. * This page has a common header used by both front and back to synchronize
  1011. * access and control event's ring buffer, while back being a producer of the
  1012. * events and front being a consumer. The rest of the page after the header
  1013. * is used for event packets.
  1014. *
  1015. * Upon reception of an event(s) front may confirm its reception
  1016. * for either each event, group of events or none.
  1017. */
  1018. struct xensnd_event_page {
  1019. uint32_t in_cons;
  1020. uint32_t in_prod;
  1021. uint8_t reserved[56];
  1022. };
  1023. #define XENSND_EVENT_PAGE_SIZE XEN_PAGE_SIZE
  1024. #define XENSND_IN_RING_OFFS (sizeof(struct xensnd_event_page))
  1025. #define XENSND_IN_RING_SIZE (XENSND_EVENT_PAGE_SIZE - XENSND_IN_RING_OFFS)
  1026. #define XENSND_IN_RING_LEN (XENSND_IN_RING_SIZE / sizeof(struct xensnd_evt))
  1027. #define XENSND_IN_RING(page) \
  1028. ((struct xensnd_evt *)((char *)(page) + XENSND_IN_RING_OFFS))
  1029. #define XENSND_IN_RING_REF(page, idx) \
  1030. (XENSND_IN_RING((page))[(idx) % XENSND_IN_RING_LEN])
  1031. #endif /* __XEN_PUBLIC_IO_SNDIF_H__ */