Re: [PATCH 2/7] uapi: virtio_snd: add the sound device header file

2021-01-24 Thread Anton Yakovlev

Hello, Michael.

Thanks you for your comments!


On 20.01.2021 09:19, Michael S. Tsirkin wrote:

CAUTION: This email originated from outside of the organization.
Do not click links or open attachments unless you recognize the sender and know 
the content is safe.


On Wed, Jan 20, 2021 at 01:36:30AM +0100, Anton Yakovlev wrote:

The file contains the definitions for the sound device from the OASIS
virtio spec.

Signed-off-by: Anton Yakovlev 
---
  MAINTAINERS |   6 +
  include/uapi/linux/virtio_snd.h | 361 
  2 files changed, 367 insertions(+)
  create mode 100644 include/uapi/linux/virtio_snd.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 00836f6452f0..6dfd59eafe82 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -18936,6 +18936,12 @@ W:   https://virtio-mem.gitlab.io/
  F:   drivers/virtio/virtio_mem.c
  F:   include/uapi/linux/virtio_mem.h

+VIRTIO SOUND DRIVER
+M:   Anton Yakovlev 
+L:   virtualization@lists.linux-foundation.org
+S:   Maintained
+F:   include/uapi/linux/virtio_snd.h
+
  VIRTUAL BOX GUEST DEVICE DRIVER
  M:   Hans de Goede 
  M:   Arnd Bergmann 


You want sound/virtio here too, right?
I'd just squash this with the next patch in series.


Yes, I squashed these two in v2 and added you to the MAINTAINERS.



diff --git a/include/uapi/linux/virtio_snd.h b/include/uapi/linux/virtio_snd.h
new file mode 100644
index ..1ff6310e54d6
--- /dev/null
+++ b/include/uapi/linux/virtio_snd.h
@@ -0,0 +1,361 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Copyright (C) 2020  OpenSynergy GmbH
+ *
+ * This header is BSD licensed so anyone can use the definitions to
+ * implement compatible drivers/servers.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of OpenSynergy GmbH nor the names of its contributors
+ *may be used to endorse or promote products derived from this software
+ *without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL IBM OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#ifndef VIRTIO_SND_IF_H
+#define VIRTIO_SND_IF_H
+
+#include 
+
+/***
+ * CONFIGURATION SPACE
+ */
+struct virtio_snd_config {
+ /* # of available physical jacks */
+ __le32 jacks;
+ /* # of available PCM streams */
+ __le32 streams;
+ /* # of available channel maps */
+ __le32 chmaps;
+};
+
+enum {
+ /* device virtqueue indexes */
+ VIRTIO_SND_VQ_CONTROL = 0,
+ VIRTIO_SND_VQ_EVENT,
+ VIRTIO_SND_VQ_TX,
+ VIRTIO_SND_VQ_RX,
+ /* # of device virtqueues */
+ VIRTIO_SND_VQ_MAX
+};
+
+/***
+ * COMMON DEFINITIONS
+ */
+
+/* supported dataflow directions */
+enum {
+ VIRTIO_SND_D_OUTPUT = 0,
+ VIRTIO_SND_D_INPUT
+};
+
+enum {
+ /* jack control request types */
+ VIRTIO_SND_R_JACK_INFO = 1,
+ VIRTIO_SND_R_JACK_REMAP,
+
+ /* PCM control request types */
+ VIRTIO_SND_R_PCM_INFO = 0x0100,
+ VIRTIO_SND_R_PCM_SET_PARAMS,
+ VIRTIO_SND_R_PCM_PREPARE,
+ VIRTIO_SND_R_PCM_RELEASE,
+ VIRTIO_SND_R_PCM_START,
+ VIRTIO_SND_R_PCM_STOP,
+
+ /* channel map control request types */
+ VIRTIO_SND_R_CHMAP_INFO = 0x0200,
+
+ /* jack event types */
+ VIRTIO_SND_EVT_JACK_CONNECTED = 0x1000,
+ VIRTIO_SND_EVT_JACK_DISCONNECTED,
+
+ /* PCM event types */
+ VIRTIO_SND_EVT_PCM_PERIOD_ELAPSED = 0x1100,
+ VIRTIO_SND_EVT_PCM_XRUN,
+
+ /* common status codes */
+ VIRTIO_SND_S_OK = 0x8000,
+ VIRTIO_SND_S_BAD_MSG,
+ VIRTIO_SND_S_NOT_SUPP,
+ VIRTIO_SND_S_IO_ERR
+};
+
+/* common header */
+struct virtio_snd_hdr {
+ __le32 code;
+};
+
+/* event notification */
+struct virtio_snd_event 

Re: [PATCH 2/7] uapi: virtio_snd: add the sound device header file

2021-01-20 Thread Michael S. Tsirkin
On Wed, Jan 20, 2021 at 03:19:55AM -0500, Michael S. Tsirkin wrote:
> On Wed, Jan 20, 2021 at 01:36:30AM +0100, Anton Yakovlev wrote:
> > The file contains the definitions for the sound device from the OASIS
> > virtio spec.
> > 
> > Signed-off-by: Anton Yakovlev 
> > ---
> >  MAINTAINERS |   6 +
> >  include/uapi/linux/virtio_snd.h | 361 
> >  2 files changed, 367 insertions(+)
> >  create mode 100644 include/uapi/linux/virtio_snd.h
> > 
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 00836f6452f0..6dfd59eafe82 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -18936,6 +18936,12 @@ W: https://virtio-mem.gitlab.io/
> >  F: drivers/virtio/virtio_mem.c
> >  F: include/uapi/linux/virtio_mem.h
> >  
> > +VIRTIO SOUND DRIVER
> > +M: Anton Yakovlev 
> > +L: virtualization@lists.linux-foundation.org
> > +S: Maintained
> > +F: include/uapi/linux/virtio_snd.h
> > +
> >  VIRTUAL BOX GUEST DEVICE DRIVER
> >  M: Hans de Goede 
> >  M: Arnd Bergmann 
> 
> You want sound/virtio here too, right?
> I'd just squash this with the next patch in series.


I meant just the MAINTAINERS part. Not a big deal, admittedly ...

> 
> > diff --git a/include/uapi/linux/virtio_snd.h 
> > b/include/uapi/linux/virtio_snd.h
> > new file mode 100644
> > index ..1ff6310e54d6
> > --- /dev/null
> > +++ b/include/uapi/linux/virtio_snd.h
> > @@ -0,0 +1,361 @@
> > +/* SPDX-License-Identifier: BSD-3-Clause */
> > +/*
> > + * Copyright (C) 2020  OpenSynergy GmbH
> > + *
> > + * This header is BSD licensed so anyone can use the definitions to
> > + * implement compatible drivers/servers.
> > + *
> > + * Redistribution and use in source and binary forms, with or without
> > + * modification, are permitted provided that the following conditions
> > + * are met:
> > + * 1. Redistributions of source code must retain the above copyright
> > + *notice, this list of conditions and the following disclaimer.
> > + * 2. Redistributions in binary form must reproduce the above copyright
> > + *notice, this list of conditions and the following disclaimer in the
> > + *documentation and/or other materials provided with the distribution.
> > + * 3. Neither the name of OpenSynergy GmbH nor the names of its 
> > contributors
> > + *may be used to endorse or promote products derived from this software
> > + *without specific prior written permission.
> > + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
> > + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> > + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
> > + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL IBM OR
> > + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> > + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
> > + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
> > + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
> > + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
> > + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
> > + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> > + * SUCH DAMAGE.
> > + */
> > +#ifndef VIRTIO_SND_IF_H
> > +#define VIRTIO_SND_IF_H
> > +
> > +#include 
> > +
> > +/***
> > + * CONFIGURATION SPACE
> > + */
> > +struct virtio_snd_config {
> > +   /* # of available physical jacks */
> > +   __le32 jacks;
> > +   /* # of available PCM streams */
> > +   __le32 streams;
> > +   /* # of available channel maps */
> > +   __le32 chmaps;
> > +};
> > +
> > +enum {
> > +   /* device virtqueue indexes */
> > +   VIRTIO_SND_VQ_CONTROL = 0,
> > +   VIRTIO_SND_VQ_EVENT,
> > +   VIRTIO_SND_VQ_TX,
> > +   VIRTIO_SND_VQ_RX,
> > +   /* # of device virtqueues */
> > +   VIRTIO_SND_VQ_MAX
> > +};
> > +
> > +/***
> > + * COMMON DEFINITIONS
> > + */
> > +
> > +/* supported dataflow directions */
> > +enum {
> > +   VIRTIO_SND_D_OUTPUT = 0,
> > +   VIRTIO_SND_D_INPUT
> > +};
> > +
> > +enum {
> > +   /* jack control request types */
> > +   VIRTIO_SND_R_JACK_INFO = 1,
> > +   VIRTIO_SND_R_JACK_REMAP,
> > +
> > +   /* PCM control request types */
> > +   VIRTIO_SND_R_PCM_INFO = 0x0100,
> > +   VIRTIO_SND_R_PCM_SET_PARAMS,
> > +   VIRTIO_SND_R_PCM_PREPARE,
> > +   VIRTIO_SND_R_PCM_RELEASE,
> > +   VIRTIO_SND_R_PCM_START,
> > +   VIRTIO_SND_R_PCM_STOP,
> > +
> > +   /* channel map control request types */
> > +   VIRTIO_SND_R_CHMAP_INFO = 0x0200,
> > +
> > +   /* jack event types */
> > +   VIRTIO_SND_EVT_JACK_CONNECTED = 0x1000,
> > +   VIRTIO_SND_EVT_JACK_DISCONNECTED,
> > +
> > +   /* PCM event types */
> > +   VIRTIO_SND_EVT_PCM_PERIOD_ELAPSED = 0x1100,
> > +   VIRTIO_SND_EVT_PCM_XRUN,
> > +
> > +   /* common status codes */
> > +   VIRTIO_

Re: [PATCH 2/7] uapi: virtio_snd: add the sound device header file

2021-01-20 Thread Michael S. Tsirkin
On Wed, Jan 20, 2021 at 01:36:30AM +0100, Anton Yakovlev wrote:
> The file contains the definitions for the sound device from the OASIS
> virtio spec.
> 
> Signed-off-by: Anton Yakovlev 
> ---
>  MAINTAINERS |   6 +
>  include/uapi/linux/virtio_snd.h | 361 
>  2 files changed, 367 insertions(+)
>  create mode 100644 include/uapi/linux/virtio_snd.h
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 00836f6452f0..6dfd59eafe82 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -18936,6 +18936,12 @@ W:   https://virtio-mem.gitlab.io/
>  F:   drivers/virtio/virtio_mem.c
>  F:   include/uapi/linux/virtio_mem.h
>  
> +VIRTIO SOUND DRIVER
> +M:   Anton Yakovlev 
> +L:   virtualization@lists.linux-foundation.org
> +S:   Maintained
> +F:   include/uapi/linux/virtio_snd.h
> +
>  VIRTUAL BOX GUEST DEVICE DRIVER
>  M:   Hans de Goede 
>  M:   Arnd Bergmann 

Who's merging this driver me? If so pls add m...@redhat.com so I'm copied
on patches.

> diff --git a/include/uapi/linux/virtio_snd.h b/include/uapi/linux/virtio_snd.h
> new file mode 100644
> index ..1ff6310e54d6
> --- /dev/null
> +++ b/include/uapi/linux/virtio_snd.h
> @@ -0,0 +1,361 @@
> +/* SPDX-License-Identifier: BSD-3-Clause */
> +/*
> + * Copyright (C) 2020  OpenSynergy GmbH
> + *
> + * This header is BSD licensed so anyone can use the definitions to
> + * implement compatible drivers/servers.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + * 1. Redistributions of source code must retain the above copyright
> + *notice, this list of conditions and the following disclaimer.
> + * 2. Redistributions in binary form must reproduce the above copyright
> + *notice, this list of conditions and the following disclaimer in the
> + *documentation and/or other materials provided with the distribution.
> + * 3. Neither the name of OpenSynergy GmbH nor the names of its contributors
> + *may be used to endorse or promote products derived from this software
> + *without specific prior written permission.
> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
> + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
> + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL IBM OR
> + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
> + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
> + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
> + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
> + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
> + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> + * SUCH DAMAGE.
> + */
> +#ifndef VIRTIO_SND_IF_H
> +#define VIRTIO_SND_IF_H
> +
> +#include 
> +
> +/***
> + * CONFIGURATION SPACE
> + */
> +struct virtio_snd_config {
> + /* # of available physical jacks */
> + __le32 jacks;
> + /* # of available PCM streams */
> + __le32 streams;
> + /* # of available channel maps */
> + __le32 chmaps;
> +};
> +
> +enum {
> + /* device virtqueue indexes */
> + VIRTIO_SND_VQ_CONTROL = 0,
> + VIRTIO_SND_VQ_EVENT,
> + VIRTIO_SND_VQ_TX,
> + VIRTIO_SND_VQ_RX,
> + /* # of device virtqueues */
> + VIRTIO_SND_VQ_MAX
> +};
> +
> +/***
> + * COMMON DEFINITIONS
> + */
> +
> +/* supported dataflow directions */
> +enum {
> + VIRTIO_SND_D_OUTPUT = 0,
> + VIRTIO_SND_D_INPUT
> +};
> +
> +enum {
> + /* jack control request types */
> + VIRTIO_SND_R_JACK_INFO = 1,
> + VIRTIO_SND_R_JACK_REMAP,
> +
> + /* PCM control request types */
> + VIRTIO_SND_R_PCM_INFO = 0x0100,
> + VIRTIO_SND_R_PCM_SET_PARAMS,
> + VIRTIO_SND_R_PCM_PREPARE,
> + VIRTIO_SND_R_PCM_RELEASE,
> + VIRTIO_SND_R_PCM_START,
> + VIRTIO_SND_R_PCM_STOP,
> +
> + /* channel map control request types */
> + VIRTIO_SND_R_CHMAP_INFO = 0x0200,
> +
> + /* jack event types */
> + VIRTIO_SND_EVT_JACK_CONNECTED = 0x1000,
> + VIRTIO_SND_EVT_JACK_DISCONNECTED,
> +
> + /* PCM event types */
> + VIRTIO_SND_EVT_PCM_PERIOD_ELAPSED = 0x1100,
> + VIRTIO_SND_EVT_PCM_XRUN,
> +
> + /* common status codes */
> + VIRTIO_SND_S_OK = 0x8000,
> + VIRTIO_SND_S_BAD_MSG,
> + VIRTIO_SND_S_NOT_SUPP,
> + VIRTIO_SND_S_IO_ERR
> +};
> +
> +/* common header */
> +struct virtio_snd_hdr {
> + __le32 code;
> +};
> +
> +/* event notification */
> +struct virtio_snd_event {
> + /* VIRTIO_SND_EVT_XXX */
> + struct virtio_snd_hdr hdr;
> + 

Re: [PATCH 2/7] uapi: virtio_snd: add the sound device header file

2021-01-20 Thread Michael S. Tsirkin
On Wed, Jan 20, 2021 at 01:36:30AM +0100, Anton Yakovlev wrote:
> The file contains the definitions for the sound device from the OASIS
> virtio spec.
> 
> Signed-off-by: Anton Yakovlev 
> ---
>  MAINTAINERS |   6 +
>  include/uapi/linux/virtio_snd.h | 361 
>  2 files changed, 367 insertions(+)
>  create mode 100644 include/uapi/linux/virtio_snd.h
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 00836f6452f0..6dfd59eafe82 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -18936,6 +18936,12 @@ W:   https://virtio-mem.gitlab.io/
>  F:   drivers/virtio/virtio_mem.c
>  F:   include/uapi/linux/virtio_mem.h
>  
> +VIRTIO SOUND DRIVER
> +M:   Anton Yakovlev 
> +L:   virtualization@lists.linux-foundation.org
> +S:   Maintained
> +F:   include/uapi/linux/virtio_snd.h
> +
>  VIRTUAL BOX GUEST DEVICE DRIVER
>  M:   Hans de Goede 
>  M:   Arnd Bergmann 

You want sound/virtio here too, right?
I'd just squash this with the next patch in series.

> diff --git a/include/uapi/linux/virtio_snd.h b/include/uapi/linux/virtio_snd.h
> new file mode 100644
> index ..1ff6310e54d6
> --- /dev/null
> +++ b/include/uapi/linux/virtio_snd.h
> @@ -0,0 +1,361 @@
> +/* SPDX-License-Identifier: BSD-3-Clause */
> +/*
> + * Copyright (C) 2020  OpenSynergy GmbH
> + *
> + * This header is BSD licensed so anyone can use the definitions to
> + * implement compatible drivers/servers.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + * 1. Redistributions of source code must retain the above copyright
> + *notice, this list of conditions and the following disclaimer.
> + * 2. Redistributions in binary form must reproduce the above copyright
> + *notice, this list of conditions and the following disclaimer in the
> + *documentation and/or other materials provided with the distribution.
> + * 3. Neither the name of OpenSynergy GmbH nor the names of its contributors
> + *may be used to endorse or promote products derived from this software
> + *without specific prior written permission.
> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
> + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
> + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL IBM OR
> + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
> + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
> + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
> + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
> + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
> + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> + * SUCH DAMAGE.
> + */
> +#ifndef VIRTIO_SND_IF_H
> +#define VIRTIO_SND_IF_H
> +
> +#include 
> +
> +/***
> + * CONFIGURATION SPACE
> + */
> +struct virtio_snd_config {
> + /* # of available physical jacks */
> + __le32 jacks;
> + /* # of available PCM streams */
> + __le32 streams;
> + /* # of available channel maps */
> + __le32 chmaps;
> +};
> +
> +enum {
> + /* device virtqueue indexes */
> + VIRTIO_SND_VQ_CONTROL = 0,
> + VIRTIO_SND_VQ_EVENT,
> + VIRTIO_SND_VQ_TX,
> + VIRTIO_SND_VQ_RX,
> + /* # of device virtqueues */
> + VIRTIO_SND_VQ_MAX
> +};
> +
> +/***
> + * COMMON DEFINITIONS
> + */
> +
> +/* supported dataflow directions */
> +enum {
> + VIRTIO_SND_D_OUTPUT = 0,
> + VIRTIO_SND_D_INPUT
> +};
> +
> +enum {
> + /* jack control request types */
> + VIRTIO_SND_R_JACK_INFO = 1,
> + VIRTIO_SND_R_JACK_REMAP,
> +
> + /* PCM control request types */
> + VIRTIO_SND_R_PCM_INFO = 0x0100,
> + VIRTIO_SND_R_PCM_SET_PARAMS,
> + VIRTIO_SND_R_PCM_PREPARE,
> + VIRTIO_SND_R_PCM_RELEASE,
> + VIRTIO_SND_R_PCM_START,
> + VIRTIO_SND_R_PCM_STOP,
> +
> + /* channel map control request types */
> + VIRTIO_SND_R_CHMAP_INFO = 0x0200,
> +
> + /* jack event types */
> + VIRTIO_SND_EVT_JACK_CONNECTED = 0x1000,
> + VIRTIO_SND_EVT_JACK_DISCONNECTED,
> +
> + /* PCM event types */
> + VIRTIO_SND_EVT_PCM_PERIOD_ELAPSED = 0x1100,
> + VIRTIO_SND_EVT_PCM_XRUN,
> +
> + /* common status codes */
> + VIRTIO_SND_S_OK = 0x8000,
> + VIRTIO_SND_S_BAD_MSG,
> + VIRTIO_SND_S_NOT_SUPP,
> + VIRTIO_SND_S_IO_ERR
> +};
> +
> +/* common header */
> +struct virtio_snd_hdr {
> + __le32 code;
> +};
> +
> +/* event notification */
> +struct virtio_snd_event {
> + /* VIRTIO_SND_EVT_XXX */
> + struct virtio_snd_hdr hdr;

[PATCH 2/7] uapi: virtio_snd: add the sound device header file

2021-01-19 Thread Anton Yakovlev
The file contains the definitions for the sound device from the OASIS
virtio spec.

Signed-off-by: Anton Yakovlev 
---
 MAINTAINERS |   6 +
 include/uapi/linux/virtio_snd.h | 361 
 2 files changed, 367 insertions(+)
 create mode 100644 include/uapi/linux/virtio_snd.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 00836f6452f0..6dfd59eafe82 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -18936,6 +18936,12 @@ W: https://virtio-mem.gitlab.io/
 F: drivers/virtio/virtio_mem.c
 F: include/uapi/linux/virtio_mem.h
 
+VIRTIO SOUND DRIVER
+M: Anton Yakovlev 
+L: virtualization@lists.linux-foundation.org
+S: Maintained
+F: include/uapi/linux/virtio_snd.h
+
 VIRTUAL BOX GUEST DEVICE DRIVER
 M: Hans de Goede 
 M: Arnd Bergmann 
diff --git a/include/uapi/linux/virtio_snd.h b/include/uapi/linux/virtio_snd.h
new file mode 100644
index ..1ff6310e54d6
--- /dev/null
+++ b/include/uapi/linux/virtio_snd.h
@@ -0,0 +1,361 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Copyright (C) 2020  OpenSynergy GmbH
+ *
+ * This header is BSD licensed so anyone can use the definitions to
+ * implement compatible drivers/servers.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of OpenSynergy GmbH nor the names of its contributors
+ *may be used to endorse or promote products derived from this software
+ *without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL IBM OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#ifndef VIRTIO_SND_IF_H
+#define VIRTIO_SND_IF_H
+
+#include 
+
+/***
+ * CONFIGURATION SPACE
+ */
+struct virtio_snd_config {
+   /* # of available physical jacks */
+   __le32 jacks;
+   /* # of available PCM streams */
+   __le32 streams;
+   /* # of available channel maps */
+   __le32 chmaps;
+};
+
+enum {
+   /* device virtqueue indexes */
+   VIRTIO_SND_VQ_CONTROL = 0,
+   VIRTIO_SND_VQ_EVENT,
+   VIRTIO_SND_VQ_TX,
+   VIRTIO_SND_VQ_RX,
+   /* # of device virtqueues */
+   VIRTIO_SND_VQ_MAX
+};
+
+/***
+ * COMMON DEFINITIONS
+ */
+
+/* supported dataflow directions */
+enum {
+   VIRTIO_SND_D_OUTPUT = 0,
+   VIRTIO_SND_D_INPUT
+};
+
+enum {
+   /* jack control request types */
+   VIRTIO_SND_R_JACK_INFO = 1,
+   VIRTIO_SND_R_JACK_REMAP,
+
+   /* PCM control request types */
+   VIRTIO_SND_R_PCM_INFO = 0x0100,
+   VIRTIO_SND_R_PCM_SET_PARAMS,
+   VIRTIO_SND_R_PCM_PREPARE,
+   VIRTIO_SND_R_PCM_RELEASE,
+   VIRTIO_SND_R_PCM_START,
+   VIRTIO_SND_R_PCM_STOP,
+
+   /* channel map control request types */
+   VIRTIO_SND_R_CHMAP_INFO = 0x0200,
+
+   /* jack event types */
+   VIRTIO_SND_EVT_JACK_CONNECTED = 0x1000,
+   VIRTIO_SND_EVT_JACK_DISCONNECTED,
+
+   /* PCM event types */
+   VIRTIO_SND_EVT_PCM_PERIOD_ELAPSED = 0x1100,
+   VIRTIO_SND_EVT_PCM_XRUN,
+
+   /* common status codes */
+   VIRTIO_SND_S_OK = 0x8000,
+   VIRTIO_SND_S_BAD_MSG,
+   VIRTIO_SND_S_NOT_SUPP,
+   VIRTIO_SND_S_IO_ERR
+};
+
+/* common header */
+struct virtio_snd_hdr {
+   __le32 code;
+};
+
+/* event notification */
+struct virtio_snd_event {
+   /* VIRTIO_SND_EVT_XXX */
+   struct virtio_snd_hdr hdr;
+   /* optional event data */
+   __le32 data;
+};
+
+/* common control request to query an item information */
+struct virtio_snd_query_info {
+   /* VIRTIO_SND_R_XXX_INFO */
+   struct virtio_snd_hdr hdr;
+   /* item start identifier */
+   __le32 start_id;
+   /* item count to query */
+   __le32 count