Re: [Xen-devel] [PATCH v3 1/2] xen-sndfront: add sound frontend driver

2015-01-22 Thread Oleksandr Dmytryshyn
On Wed, Jan 21, 2015 at 5:14 PM, Stefano Stabellini
stefano.stabell...@eu.citrix.com wrote:
 On Tue, 20 Jan 2015, Oleksandr Dmytryshyn wrote:
 This is Para-virtual sound driver.

 Frontend driver registers an virtual sound card
 and sends an PCM streams to the backend driver.
 Backend driver is an user-space application and
 uses ALSA with dmix plugin to play audio.

 Signed-off-by: Oleksandr Dmytryshyn oleksandr.dmytrys...@globallogic.com
 Signed-off-by: Iurii Konovalenko iurii.konovale...@globallogic.com

 The code isn't bad but we still lack a document that describes how the
 protocol works.  It should have enough details in it to allow somebody
 to write a backend for it without looking at the frontend code.

 Without it, it is very difficult to tell if the frontend implementation
 is right.
I'll describe a protocol in the next patch-set. There will be some
description inside the file sndif.h.
The rest I'll describe additionally.


  include/xen/interface/io/sndif.h |  208 ++
  sound/drivers/Kconfig|   10 +
  sound/drivers/Makefile   |2 +
  sound/drivers/xen-sndfront.c | 1478 
 ++
  4 files changed, 1698 insertions(+)
  create mode 100644 include/xen/interface/io/sndif.h
  create mode 100644 sound/drivers/xen-sndfront.c

 diff --git a/include/xen/interface/io/sndif.h 
 b/include/xen/interface/io/sndif.h
 new file mode 100644
 index 000..99e6f8e
 --- /dev/null
 +++ b/include/xen/interface/io/sndif.h
 @@ -0,0 +1,208 @@
 +/**
 + * sndif.h
 + *
 + * Unified sound-device I/O interface for Xen guest OSes.
 + *
 + * Permission is hereby granted, free of charge, to any person obtaining a 
 copy
 + * of this software and associated documentation files (the Software), to
 + * deal in the Software without restriction, including without limitation 
 the
 + * rights to use, copy, modify, merge, publish, distribute, sublicense, 
 and/or
 + * sell copies of the Software, and to permit persons to whom the Software 
 is
 + * furnished to do so, subject to the following conditions:
 + *
 + * The above copyright notice and this permission notice shall be included 
 in
 + * all copies or substantial portions of the Software.
 + *
 + * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS 
 OR
 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
 THE
 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 + * DEALINGS IN THE SOFTWARE.
 + *
 + * Copyright (C) 2013-2015 GlobalLogic Inc.
 + */
 +
 +#ifndef __XEN_PUBLIC_IO_SNDIF_H__
 +#define __XEN_PUBLIC_IO_SNDIF_H__
 +
 +#include xen/interface/io/ring.h
 +#include xen/interface/grant_table.h
 +
 +/*
 + * Feature and Parameter Negotiation
 + * =
 + * The two halves of a Xen vsnd driver utilize nodes within the XenStore to
 + * communicate capabilities and to negotiate operating parameters.  This
 + * section enumerates these nodes which reside in the respective front and
 + * backend portions of the XenStore, following the XenBus convention.
 + *
 + * All data in the XenStore is stored as strings.  Nodes specifying numeric
 + * values are encoded in decimal.  Integer value ranges listed below are
 + * expressed as fixed sized integer types capable of storing the conversion
 + * of a properly formated node string, without loss of information.
 + *
 + * Any specified default value is in effect if the corresponding XenBus node
 + * is not present in the XenStore.
 + *
 + * XenStore nodes in sections marked PRIVATE are solely for use by the
 + * driver side whose XenBus tree contains them.
 + *
 + 
 *
 + *Backend XenBus Nodes
 + 
 *
 + *
 + *-- Backend Device Identification (PRIVATE) 
 --
 + *
 + * stream_id
 + *  Values: uint32_t
 + *
 + *  Virtuelized stream number
 + *
 + 
 *
 + *Frontend XenBus Nodes
 + 
 *
 + *
 + *--- Request Transport Parameters 
 ---
 + *
 + * event-channel
 + *  Values: uint32_t
 + *
 + *  The identifier of the Xen event channel used to signal activity
 + *  in the ring buffer.
 + *
 + * ring-ref
 + *  Values: uint32_t
 + *  Notes:  6
 + *
 + *  The Xen grant reference granting permission for the backend 

Re: [Xen-devel] [PATCH v3 1/2] xen-sndfront: add sound frontend driver

2015-01-21 Thread Stefano Stabellini
On Tue, 20 Jan 2015, Oleksandr Dmytryshyn wrote:
 This is Para-virtual sound driver.
 
 Frontend driver registers an virtual sound card
 and sends an PCM streams to the backend driver.
 Backend driver is an user-space application and
 uses ALSA with dmix plugin to play audio.
 
 Signed-off-by: Oleksandr Dmytryshyn oleksandr.dmytrys...@globallogic.com
 Signed-off-by: Iurii Konovalenko iurii.konovale...@globallogic.com

The code isn't bad but we still lack a document that describes how the
protocol works.  It should have enough details in it to allow somebody
to write a backend for it without looking at the frontend code.

Without it, it is very difficult to tell if the frontend implementation
is right.


  include/xen/interface/io/sndif.h |  208 ++
  sound/drivers/Kconfig|   10 +
  sound/drivers/Makefile   |2 +
  sound/drivers/xen-sndfront.c | 1478 
 ++
  4 files changed, 1698 insertions(+)
  create mode 100644 include/xen/interface/io/sndif.h
  create mode 100644 sound/drivers/xen-sndfront.c
 
 diff --git a/include/xen/interface/io/sndif.h 
 b/include/xen/interface/io/sndif.h
 new file mode 100644
 index 000..99e6f8e
 --- /dev/null
 +++ b/include/xen/interface/io/sndif.h
 @@ -0,0 +1,208 @@
 +/**
 + * sndif.h
 + *
 + * Unified sound-device I/O interface for Xen guest OSes.
 + *
 + * Permission is hereby granted, free of charge, to any person obtaining a 
 copy
 + * of this software and associated documentation files (the Software), to
 + * deal in the Software without restriction, including without limitation the
 + * rights to use, copy, modify, merge, publish, distribute, sublicense, 
 and/or
 + * sell copies of the Software, and to permit persons to whom the Software is
 + * furnished to do so, subject to the following conditions:
 + *
 + * The above copyright notice and this permission notice shall be included in
 + * all copies or substantial portions of the Software.
 + *
 + * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
 THE
 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 + * DEALINGS IN THE SOFTWARE.
 + *
 + * Copyright (C) 2013-2015 GlobalLogic Inc.
 + */
 +
 +#ifndef __XEN_PUBLIC_IO_SNDIF_H__
 +#define __XEN_PUBLIC_IO_SNDIF_H__
 +
 +#include xen/interface/io/ring.h
 +#include xen/interface/grant_table.h
 +
 +/*
 + * Feature and Parameter Negotiation
 + * =
 + * The two halves of a Xen vsnd driver utilize nodes within the XenStore to
 + * communicate capabilities and to negotiate operating parameters.  This
 + * section enumerates these nodes which reside in the respective front and
 + * backend portions of the XenStore, following the XenBus convention.
 + *
 + * All data in the XenStore is stored as strings.  Nodes specifying numeric
 + * values are encoded in decimal.  Integer value ranges listed below are
 + * expressed as fixed sized integer types capable of storing the conversion
 + * of a properly formated node string, without loss of information.
 + *
 + * Any specified default value is in effect if the corresponding XenBus node
 + * is not present in the XenStore.
 + *
 + * XenStore nodes in sections marked PRIVATE are solely for use by the
 + * driver side whose XenBus tree contains them.
 + *
 + 
 *
 + *Backend XenBus Nodes
 + 
 *
 + *
 + *-- Backend Device Identification (PRIVATE) 
 --
 + *
 + * stream_id
 + *  Values: uint32_t
 + *
 + *  Virtuelized stream number
 + *
 + 
 *
 + *Frontend XenBus Nodes
 + 
 *
 + *
 + *--- Request Transport Parameters 
 ---
 + *
 + * event-channel
 + *  Values: uint32_t
 + *
 + *  The identifier of the Xen event channel used to signal activity
 + *  in the ring buffer.
 + *
 + * ring-ref
 + *  Values: uint32_t
 + *  Notes:  6
 + *
 + *  The Xen grant reference granting permission for the backend to map
 + *  the sole page in a single page sized ring buffer.
 + */
 +
 +/*
 + * PCM FORMATS.
 + */
 +#define SNDIF_PCM_FORMAT_S8  (0)
 +#define SNDIF_PCM_FORMAT_U8  (1)
 +#define SNDIF_PCM_FORMAT_S16_LE  (2)
 

[Xen-devel] [PATCH v3 1/2] xen-sndfront: add sound frontend driver

2015-01-20 Thread Oleksandr Dmytryshyn
This is Para-virtual sound driver.

Frontend driver registers an virtual sound card
and sends an PCM streams to the backend driver.
Backend driver is an user-space application and
uses ALSA with dmix plugin to play audio.

Signed-off-by: Oleksandr Dmytryshyn oleksandr.dmytrys...@globallogic.com
Signed-off-by: Iurii Konovalenko iurii.konovale...@globallogic.com
---
 include/xen/interface/io/sndif.h |  208 ++
 sound/drivers/Kconfig|   10 +
 sound/drivers/Makefile   |2 +
 sound/drivers/xen-sndfront.c | 1478 ++
 4 files changed, 1698 insertions(+)
 create mode 100644 include/xen/interface/io/sndif.h
 create mode 100644 sound/drivers/xen-sndfront.c

diff --git a/include/xen/interface/io/sndif.h b/include/xen/interface/io/sndif.h
new file mode 100644
index 000..99e6f8e
--- /dev/null
+++ b/include/xen/interface/io/sndif.h
@@ -0,0 +1,208 @@
+/**
+ * sndif.h
+ *
+ * Unified sound-device I/O interface for Xen guest OSes.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the Software), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Copyright (C) 2013-2015 GlobalLogic Inc.
+ */
+
+#ifndef __XEN_PUBLIC_IO_SNDIF_H__
+#define __XEN_PUBLIC_IO_SNDIF_H__
+
+#include xen/interface/io/ring.h
+#include xen/interface/grant_table.h
+
+/*
+ * Feature and Parameter Negotiation
+ * =
+ * The two halves of a Xen vsnd driver utilize nodes within the XenStore to
+ * communicate capabilities and to negotiate operating parameters.  This
+ * section enumerates these nodes which reside in the respective front and
+ * backend portions of the XenStore, following the XenBus convention.
+ *
+ * All data in the XenStore is stored as strings.  Nodes specifying numeric
+ * values are encoded in decimal.  Integer value ranges listed below are
+ * expressed as fixed sized integer types capable of storing the conversion
+ * of a properly formated node string, without loss of information.
+ *
+ * Any specified default value is in effect if the corresponding XenBus node
+ * is not present in the XenStore.
+ *
+ * XenStore nodes in sections marked PRIVATE are solely for use by the
+ * driver side whose XenBus tree contains them.
+ *
+ *
+ *Backend XenBus Nodes
+ *
+ *
+ *-- Backend Device Identification (PRIVATE) --
+ *
+ * stream_id
+ *  Values: uint32_t
+ *
+ *  Virtuelized stream number
+ *
+ *
+ *Frontend XenBus Nodes
+ *
+ *
+ *--- Request Transport Parameters ---
+ *
+ * event-channel
+ *  Values: uint32_t
+ *
+ *  The identifier of the Xen event channel used to signal activity
+ *  in the ring buffer.
+ *
+ * ring-ref
+ *  Values: uint32_t
+ *  Notes:  6
+ *
+ *  The Xen grant reference granting permission for the backend to map
+ *  the sole page in a single page sized ring buffer.
+ */
+
+/*
+ * PCM FORMATS.
+ */
+#define SNDIF_PCM_FORMAT_S8(0)
+#define SNDIF_PCM_FORMAT_U8(1)
+#define SNDIF_PCM_FORMAT_S16_LE(2)
+#define SNDIF_PCM_FORMAT_S16_BE(3)
+#define SNDIF_PCM_FORMAT_U16_LE(4)
+#define SNDIF_PCM_FORMAT_U16_BE(5)
+
+/* low three bytes */
+#define SNDIF_PCM_FORMAT_S24_LE(6)
+
+/* low three bytes */
+#define SNDIF_PCM_FORMAT_S24_BE(7)
+
+/* low three bytes */
+#define SNDIF_PCM_FORMAT_U24_LE(8)
+
+/* low three bytes */
+#define SNDIF_PCM_FORMAT_U24_BE(9)
+