1 /* SPDX-License-Identifier: BSD-3-Clause */
3 * Copyright (C) 2021 OpenSynergy GmbH
5 #ifndef VIRTIO_SND_IF_H
6 #define VIRTIO_SND_IF_H
8 #include "standard-headers/linux/virtio_types.h"
10 /*******************************************************************************
14 /* device supports control elements */
18 /*******************************************************************************
21 struct virtio_snd_config
{
22 /* # of available physical jacks */
24 /* # of available PCM streams */
26 /* # of available channel maps */
28 /* # of available control elements */
33 /* device virtqueue indexes */
34 VIRTIO_SND_VQ_CONTROL
= 0,
38 /* # of device virtqueues */
42 /*******************************************************************************
46 /* supported dataflow directions */
48 VIRTIO_SND_D_OUTPUT
= 0,
53 /* jack control request types */
54 VIRTIO_SND_R_JACK_INFO
= 1,
55 VIRTIO_SND_R_JACK_REMAP
,
57 /* PCM control request types */
58 VIRTIO_SND_R_PCM_INFO
= 0x0100,
59 VIRTIO_SND_R_PCM_SET_PARAMS
,
60 VIRTIO_SND_R_PCM_PREPARE
,
61 VIRTIO_SND_R_PCM_RELEASE
,
62 VIRTIO_SND_R_PCM_START
,
63 VIRTIO_SND_R_PCM_STOP
,
65 /* channel map control request types */
66 VIRTIO_SND_R_CHMAP_INFO
= 0x0200,
68 /* control element request types */
69 VIRTIO_SND_R_CTL_INFO
= 0x0300,
70 VIRTIO_SND_R_CTL_ENUM_ITEMS
,
71 VIRTIO_SND_R_CTL_READ
,
72 VIRTIO_SND_R_CTL_WRITE
,
73 VIRTIO_SND_R_CTL_TLV_READ
,
74 VIRTIO_SND_R_CTL_TLV_WRITE
,
75 VIRTIO_SND_R_CTL_TLV_COMMAND
,
77 /* jack event types */
78 VIRTIO_SND_EVT_JACK_CONNECTED
= 0x1000,
79 VIRTIO_SND_EVT_JACK_DISCONNECTED
,
82 VIRTIO_SND_EVT_PCM_PERIOD_ELAPSED
= 0x1100,
83 VIRTIO_SND_EVT_PCM_XRUN
,
85 /* control element event types */
86 VIRTIO_SND_EVT_CTL_NOTIFY
= 0x1200,
88 /* common status codes */
89 VIRTIO_SND_S_OK
= 0x8000,
91 VIRTIO_SND_S_NOT_SUPP
,
96 struct virtio_snd_hdr
{
100 /* event notification */
101 struct virtio_snd_event
{
102 /* VIRTIO_SND_EVT_XXX */
103 struct virtio_snd_hdr hdr
;
104 /* optional event data */
108 /* common control request to query an item information */
109 struct virtio_snd_query_info
{
110 /* VIRTIO_SND_R_XXX_INFO */
111 struct virtio_snd_hdr hdr
;
112 /* item start identifier */
114 /* item count to query */
116 /* item information size in bytes */
120 /* common item information header */
121 struct virtio_snd_info
{
122 /* function group node id (High Definition Audio Specification 7.1.2) */
126 /*******************************************************************************
127 * JACK CONTROL MESSAGES
129 struct virtio_snd_jack_hdr
{
130 /* VIRTIO_SND_R_JACK_XXX */
131 struct virtio_snd_hdr hdr
;
132 /* 0 ... virtio_snd_config::jacks - 1 */
136 /* supported jack features */
138 VIRTIO_SND_JACK_F_REMAP
= 0
141 struct virtio_snd_jack_info
{
143 struct virtio_snd_info hdr
;
144 /* supported feature bit map (1 << VIRTIO_SND_JACK_F_XXX) */
146 /* pin configuration (High Definition Audio Specification 7.3.3.31) */
147 uint32_t hda_reg_defconf
;
148 /* pin capabilities (High Definition Audio Specification 7.3.4.9) */
149 uint32_t hda_reg_caps
;
150 /* current jack connection status (0: disconnected, 1: connected) */
156 /* jack remapping control request */
157 struct virtio_snd_jack_remap
{
158 /* .code = VIRTIO_SND_R_JACK_REMAP */
159 struct virtio_snd_jack_hdr hdr
;
160 /* selected association number */
161 uint32_t association
;
162 /* selected sequence number */
166 /*******************************************************************************
167 * PCM CONTROL MESSAGES
169 struct virtio_snd_pcm_hdr
{
170 /* VIRTIO_SND_R_PCM_XXX */
171 struct virtio_snd_hdr hdr
;
172 /* 0 ... virtio_snd_config::streams - 1 */
176 /* supported PCM stream features */
178 VIRTIO_SND_PCM_F_SHMEM_HOST
= 0,
179 VIRTIO_SND_PCM_F_SHMEM_GUEST
,
180 VIRTIO_SND_PCM_F_MSG_POLLING
,
181 VIRTIO_SND_PCM_F_EVT_SHMEM_PERIODS
,
182 VIRTIO_SND_PCM_F_EVT_XRUNS
185 /* supported PCM sample formats */
187 /* analog formats (width / physical width) */
188 VIRTIO_SND_PCM_FMT_IMA_ADPCM
= 0, /* 4 / 4 bits */
189 VIRTIO_SND_PCM_FMT_MU_LAW
, /* 8 / 8 bits */
190 VIRTIO_SND_PCM_FMT_A_LAW
, /* 8 / 8 bits */
191 VIRTIO_SND_PCM_FMT_S8
, /* 8 / 8 bits */
192 VIRTIO_SND_PCM_FMT_U8
, /* 8 / 8 bits */
193 VIRTIO_SND_PCM_FMT_S16
, /* 16 / 16 bits */
194 VIRTIO_SND_PCM_FMT_U16
, /* 16 / 16 bits */
195 VIRTIO_SND_PCM_FMT_S18_3
, /* 18 / 24 bits */
196 VIRTIO_SND_PCM_FMT_U18_3
, /* 18 / 24 bits */
197 VIRTIO_SND_PCM_FMT_S20_3
, /* 20 / 24 bits */
198 VIRTIO_SND_PCM_FMT_U20_3
, /* 20 / 24 bits */
199 VIRTIO_SND_PCM_FMT_S24_3
, /* 24 / 24 bits */
200 VIRTIO_SND_PCM_FMT_U24_3
, /* 24 / 24 bits */
201 VIRTIO_SND_PCM_FMT_S20
, /* 20 / 32 bits */
202 VIRTIO_SND_PCM_FMT_U20
, /* 20 / 32 bits */
203 VIRTIO_SND_PCM_FMT_S24
, /* 24 / 32 bits */
204 VIRTIO_SND_PCM_FMT_U24
, /* 24 / 32 bits */
205 VIRTIO_SND_PCM_FMT_S32
, /* 32 / 32 bits */
206 VIRTIO_SND_PCM_FMT_U32
, /* 32 / 32 bits */
207 VIRTIO_SND_PCM_FMT_FLOAT
, /* 32 / 32 bits */
208 VIRTIO_SND_PCM_FMT_FLOAT64
, /* 64 / 64 bits */
209 /* digital formats (width / physical width) */
210 VIRTIO_SND_PCM_FMT_DSD_U8
, /* 8 / 8 bits */
211 VIRTIO_SND_PCM_FMT_DSD_U16
, /* 16 / 16 bits */
212 VIRTIO_SND_PCM_FMT_DSD_U32
, /* 32 / 32 bits */
213 VIRTIO_SND_PCM_FMT_IEC958_SUBFRAME
/* 32 / 32 bits */
216 /* supported PCM frame rates */
218 VIRTIO_SND_PCM_RATE_5512
= 0,
219 VIRTIO_SND_PCM_RATE_8000
,
220 VIRTIO_SND_PCM_RATE_11025
,
221 VIRTIO_SND_PCM_RATE_16000
,
222 VIRTIO_SND_PCM_RATE_22050
,
223 VIRTIO_SND_PCM_RATE_32000
,
224 VIRTIO_SND_PCM_RATE_44100
,
225 VIRTIO_SND_PCM_RATE_48000
,
226 VIRTIO_SND_PCM_RATE_64000
,
227 VIRTIO_SND_PCM_RATE_88200
,
228 VIRTIO_SND_PCM_RATE_96000
,
229 VIRTIO_SND_PCM_RATE_176400
,
230 VIRTIO_SND_PCM_RATE_192000
,
231 VIRTIO_SND_PCM_RATE_384000
234 struct virtio_snd_pcm_info
{
236 struct virtio_snd_info hdr
;
237 /* supported feature bit map (1 << VIRTIO_SND_PCM_F_XXX) */
239 /* supported sample format bit map (1 << VIRTIO_SND_PCM_FMT_XXX) */
241 /* supported frame rate bit map (1 << VIRTIO_SND_PCM_RATE_XXX) */
243 /* dataflow direction (VIRTIO_SND_D_XXX) */
245 /* minimum # of supported channels */
246 uint8_t channels_min
;
247 /* maximum # of supported channels */
248 uint8_t channels_max
;
253 /* set PCM stream format */
254 struct virtio_snd_pcm_set_params
{
255 /* .code = VIRTIO_SND_R_PCM_SET_PARAMS */
256 struct virtio_snd_pcm_hdr hdr
;
257 /* size of the hardware buffer */
258 uint32_t buffer_bytes
;
259 /* size of the hardware period */
260 uint32_t period_bytes
;
261 /* selected feature bit map (1 << VIRTIO_SND_PCM_F_XXX) */
263 /* selected # of channels */
265 /* selected sample format (VIRTIO_SND_PCM_FMT_XXX) */
267 /* selected frame rate (VIRTIO_SND_PCM_RATE_XXX) */
273 /*******************************************************************************
277 /* I/O request header */
278 struct virtio_snd_pcm_xfer
{
279 /* 0 ... virtio_snd_config::streams - 1 */
283 /* I/O request status */
284 struct virtio_snd_pcm_status
{
285 /* VIRTIO_SND_S_XXX */
287 /* current device latency */
288 uint32_t latency_bytes
;
291 /*******************************************************************************
292 * CHANNEL MAP CONTROL MESSAGES
294 struct virtio_snd_chmap_hdr
{
295 /* VIRTIO_SND_R_CHMAP_XXX */
296 struct virtio_snd_hdr hdr
;
297 /* 0 ... virtio_snd_config::chmaps - 1 */
301 /* standard channel position definition */
303 VIRTIO_SND_CHMAP_NONE
= 0, /* undefined */
304 VIRTIO_SND_CHMAP_NA
, /* silent */
305 VIRTIO_SND_CHMAP_MONO
, /* mono stream */
306 VIRTIO_SND_CHMAP_FL
, /* front left */
307 VIRTIO_SND_CHMAP_FR
, /* front right */
308 VIRTIO_SND_CHMAP_RL
, /* rear left */
309 VIRTIO_SND_CHMAP_RR
, /* rear right */
310 VIRTIO_SND_CHMAP_FC
, /* front center */
311 VIRTIO_SND_CHMAP_LFE
, /* low frequency (LFE) */
312 VIRTIO_SND_CHMAP_SL
, /* side left */
313 VIRTIO_SND_CHMAP_SR
, /* side right */
314 VIRTIO_SND_CHMAP_RC
, /* rear center */
315 VIRTIO_SND_CHMAP_FLC
, /* front left center */
316 VIRTIO_SND_CHMAP_FRC
, /* front right center */
317 VIRTIO_SND_CHMAP_RLC
, /* rear left center */
318 VIRTIO_SND_CHMAP_RRC
, /* rear right center */
319 VIRTIO_SND_CHMAP_FLW
, /* front left wide */
320 VIRTIO_SND_CHMAP_FRW
, /* front right wide */
321 VIRTIO_SND_CHMAP_FLH
, /* front left high */
322 VIRTIO_SND_CHMAP_FCH
, /* front center high */
323 VIRTIO_SND_CHMAP_FRH
, /* front right high */
324 VIRTIO_SND_CHMAP_TC
, /* top center */
325 VIRTIO_SND_CHMAP_TFL
, /* top front left */
326 VIRTIO_SND_CHMAP_TFR
, /* top front right */
327 VIRTIO_SND_CHMAP_TFC
, /* top front center */
328 VIRTIO_SND_CHMAP_TRL
, /* top rear left */
329 VIRTIO_SND_CHMAP_TRR
, /* top rear right */
330 VIRTIO_SND_CHMAP_TRC
, /* top rear center */
331 VIRTIO_SND_CHMAP_TFLC
, /* top front left center */
332 VIRTIO_SND_CHMAP_TFRC
, /* top front right center */
333 VIRTIO_SND_CHMAP_TSL
, /* top side left */
334 VIRTIO_SND_CHMAP_TSR
, /* top side right */
335 VIRTIO_SND_CHMAP_LLFE
, /* left LFE */
336 VIRTIO_SND_CHMAP_RLFE
, /* right LFE */
337 VIRTIO_SND_CHMAP_BC
, /* bottom center */
338 VIRTIO_SND_CHMAP_BLC
, /* bottom left center */
339 VIRTIO_SND_CHMAP_BRC
/* bottom right center */
342 /* maximum possible number of channels */
343 #define VIRTIO_SND_CHMAP_MAX_SIZE 18
345 struct virtio_snd_chmap_info
{
347 struct virtio_snd_info hdr
;
348 /* dataflow direction (VIRTIO_SND_D_XXX) */
350 /* # of valid channel position values */
352 /* channel position values (VIRTIO_SND_CHMAP_XXX) */
353 uint8_t positions
[VIRTIO_SND_CHMAP_MAX_SIZE
];
356 /*******************************************************************************
357 * CONTROL ELEMENTS MESSAGES
359 struct virtio_snd_ctl_hdr
{
360 /* VIRTIO_SND_R_CTL_XXX */
361 struct virtio_snd_hdr hdr
;
362 /* 0 ... virtio_snd_config::controls - 1 */
366 /* supported roles for control elements */
368 VIRTIO_SND_CTL_ROLE_UNDEFINED
= 0,
369 VIRTIO_SND_CTL_ROLE_VOLUME
,
370 VIRTIO_SND_CTL_ROLE_MUTE
,
371 VIRTIO_SND_CTL_ROLE_GAIN
374 /* supported value types for control elements */
376 VIRTIO_SND_CTL_TYPE_BOOLEAN
= 0,
377 VIRTIO_SND_CTL_TYPE_INTEGER
,
378 VIRTIO_SND_CTL_TYPE_INTEGER64
,
379 VIRTIO_SND_CTL_TYPE_ENUMERATED
,
380 VIRTIO_SND_CTL_TYPE_BYTES
,
381 VIRTIO_SND_CTL_TYPE_IEC958
384 /* supported access rights for control elements */
386 VIRTIO_SND_CTL_ACCESS_READ
= 0,
387 VIRTIO_SND_CTL_ACCESS_WRITE
,
388 VIRTIO_SND_CTL_ACCESS_VOLATILE
,
389 VIRTIO_SND_CTL_ACCESS_INACTIVE
,
390 VIRTIO_SND_CTL_ACCESS_TLV_READ
,
391 VIRTIO_SND_CTL_ACCESS_TLV_WRITE
,
392 VIRTIO_SND_CTL_ACCESS_TLV_COMMAND
395 struct virtio_snd_ctl_info
{
397 struct virtio_snd_info hdr
;
398 /* element role (VIRTIO_SND_CTL_ROLE_XXX) */
400 /* element value type (VIRTIO_SND_CTL_TYPE_XXX) */
402 /* element access right bit map (1 << VIRTIO_SND_CTL_ACCESS_XXX) */
404 /* # of members in the element value */
406 /* index for an element with a non-unique name */
408 /* name identifier string for the element */
410 /* additional information about the element's value */
412 /* VIRTIO_SND_CTL_TYPE_INTEGER */
414 /* minimum supported value */
416 /* maximum supported value */
418 /* fixed step size for value (0 = variable size) */
421 /* VIRTIO_SND_CTL_TYPE_INTEGER64 */
423 /* minimum supported value */
425 /* maximum supported value */
427 /* fixed step size for value (0 = variable size) */
430 /* VIRTIO_SND_CTL_TYPE_ENUMERATED */
432 /* # of options supported for value */
438 struct virtio_snd_ctl_enum_item
{
443 struct virtio_snd_ctl_iec958
{
444 /* AES/IEC958 channel status bits */
446 /* AES/IEC958 subcode bits */
447 uint8_t subcode
[147];
450 /* AES/IEC958 subframe bits */
451 uint8_t dig_subframe
[4];
454 struct virtio_snd_ctl_value
{
456 /* VIRTIO_SND_CTL_TYPE_BOOLEAN|INTEGER value */
457 uint32_t integer
[128];
458 /* VIRTIO_SND_CTL_TYPE_INTEGER64 value */
459 uint64_t integer64
[64];
460 /* VIRTIO_SND_CTL_TYPE_ENUMERATED value (option indexes) */
461 uint32_t enumerated
[128];
462 /* VIRTIO_SND_CTL_TYPE_BYTES value */
464 /* VIRTIO_SND_CTL_TYPE_IEC958 value */
465 struct virtio_snd_ctl_iec958 iec958
;
469 /* supported event reason types */
471 /* element's value has changed */
472 VIRTIO_SND_CTL_EVT_MASK_VALUE
= 0,
473 /* element's information has changed */
474 VIRTIO_SND_CTL_EVT_MASK_INFO
,
475 /* element's metadata has changed */
476 VIRTIO_SND_CTL_EVT_MASK_TLV
479 struct virtio_snd_ctl_event
{
480 /* VIRTIO_SND_EVT_CTL_NOTIFY */
481 struct virtio_snd_hdr hdr
;
482 /* 0 ... virtio_snd_config::controls - 1 */
484 /* event reason bit map (1 << VIRTIO_SND_CTL_EVT_MASK_XXX) */
488 #endif /* VIRTIO_SND_IF_H */