This is Para-virtual sound driver.
This driver creates sound files in /dev/snd/:
controlC0, pcmC0D0p, etc. Then it intercepts some
IOCTLs and redirects them to the backend driver.
Backend driver is build-in the kernel. It issues
those IOCTLs on the real sound files and returns
the result to the frontend driver.
Signed-off-by: Oleksandr Dmytryshyn oleksandr.dmytrys...@globallogic.com
---
include/xen/interface/io/sndif.h | 98
sound/drivers/Kconfig|9 +
sound/drivers/Makefile |2 +
sound/drivers/xen-sndfront.c | 1117 ++
4 files changed, 1226 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..9ef0c41
--- /dev/null
+++ b/include/xen/interface/io/sndif.h
@@ -0,0 +1,98 @@
+/**
+ * sndif.h
+ *
+ * Unified sound-device I/O interface for Xen guest OSes.
+ *
+ */
+#ifndef __XEN_PUBLIC_IO_SNDIF_H__
+#define __XEN_PUBLIC_IO_SNDIF_H__
+
+#include xen/interface/io/ring.h
+#include xen/interface/grant_table.h
+
+/*
+ * REQUEST CODES.
+ */
+#define SNDIF_OP_OPEN 0
+#define SNDIF_OP_CLOSE 1
+#define SNDIF_OP_READ 2
+#define SNDIF_OP_WRITE 3
+#define SNDIF_OP_IOCTL 4
+
+#define SNDIF_DEV_TYPE_CONTROL 0
+#define SNDIF_DEV_TYPE_STREAM_PLAY 1
+#define SNDIF_DEV_TYPE_STREAM_CAPTURE 2
+
+#define SNDIF_MAX_PAGES_PER_REQUEST10
+
+#define SNDIF_DEV_ID_CNT 5
+
+/*
+ * STATUS RETURN CODES.
+ */
+ /* Operation failed for some unspecified reason (-EIO). */
+#define SNDIF_RSP_ERROR -1
+ /* Operation completed successfully. */
+#define SNDIF_RSP_OKAY 0
+
+struct sndif_request_open {
+ unsigned int dev_num;
+ unsigned int card_num;
+ unsigned int dev_type;
+ unsigned int _pad1;
+ uint64_t id; /* private guest value, echoed in resp */
+ unsigned int _pad2;
+ unsigned int _pad3;
+} __attribute__((__packed__));
+
+struct sndif_request_ioctl {
+ unsigned int dev_num;
+ unsigned int card_num;
+ unsigned int dev_type;
+ unsigned int cmd;
+ uint64_t id; /* private guest value, echoed in resp */
+ unsigned int add_len_to;
+ unsigned int add_len_from;
+ grant_ref_t gref[SNDIF_MAX_PAGES_PER_REQUEST];
+} __attribute__((__packed__));
+
+struct sndif_request_rw {
+ unsigned int dev_num;
+ unsigned int card_num;
+ unsigned int dev_type;
+ unsigned int _pad1;
+ uint64_t id; /* private guest value, echoed in resp */
+ unsigned int len;
+ unsigned int is_write;
+ grant_ref_t gref[SNDIF_MAX_PAGES_PER_REQUEST];
+} __attribute__((__packed__));
+
+struct sndif_request_common {
+ unsigned int dev_num;
+ unsigned int _pad2;
+ unsigned int dev_type;
+ unsigned int _pad3;
+ uint64_t id; /* private guest value, echoed in resp */
+ unsigned int _pad4;
+ unsigned int _pad5;
+} __attribute__((__packed__));
+
+struct sndif_request {
+ uint8_t operation;/* SNDIF_OP_??? */
+ union {
+ struct sndif_request_open open;
+ struct sndif_request_ioctl ioctl;
+ struct sndif_request_rw rw;
+ struct sndif_request_common common;
+ } u;
+} __attribute__((__packed__));
+
+struct sndif_response {
+ uint64_tid; /* copied from request */
+ uint8_t operation; /* copied from request */
+ int16_t status; /* SNDIF_RSP_??? */
+};
+
+DEFINE_RING_TYPES(sndif, struct sndif_request, struct sndif_response);
+
+#endif /* __XEN_PUBLIC_IO_SNDIF_H__ */
diff --git a/sound/drivers/Kconfig b/sound/drivers/Kconfig
index 8545da9..7364679 100644
--- a/sound/drivers/Kconfig
+++ b/sound/drivers/Kconfig
@@ -24,6 +24,15 @@ config SND_AC97_CODEC
select AC97_BUS
select SND_VMASTER
+config XEN_SND_FRONTEND
+ tristate Xen virtual audio front-end driver support
+ depends on SND XEN_DOMU
+ default n
+ help
+ This driver implements the back-end of the Xen virtual
+ audio driver. It communicates with a back-end
+ in another domain.
+
menuconfig SND_DRIVERS
bool Generic sound devices
default y
diff --git a/sound/drivers/Makefile b/sound/drivers/Makefile
index 1a8440c..f9f7e19 100644
--- a/sound/drivers/Makefile
+++ b/sound/drivers/Makefile
@@ -11,6 +11,7 @@ snd-portman2x4-objs := portman2x4.o
snd-serial-u16550-objs := serial-u16550.o
snd-virmidi-objs := virmidi.o
snd-ml403-ac97cr-objs := ml403-ac97cr.o pcm-indirect2.o
+xen-sndfrontend-objs := xen-sndfront.o
# Toplevel Module