Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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