* [PATCH] usb: misc: Add driver for ALVA Nanoface
@ 2014-11-11 7:05 Lauri Niskanen
2014-11-11 7:07 ` Greg Kroah-Hartman
0 siblings, 1 reply; 4+ messages in thread
From: Lauri Niskanen @ 2014-11-11 7:05 UTC (permalink / raw)
To: Greg Kroah-Hartman, linux-kernel, linux-usb; +Cc: Lauri Niskanen
ALVA Nanoface is a USB audio interface device that only works after
receiving an initialization command. This driver does not handle any
actual audio features, but only initializes the device enabling its
audio I/O and physical controls. There are some additional USB audio
features on the device that are currently not supported. The support
for these features may be added later.
Signed-off-by: Lauri Niskanen <ape@ape3000.com>
---
drivers/usb/misc/Kconfig | 9 +++++
drivers/usb/misc/Makefile | 1 +
drivers/usb/misc/nanoface.c | 95 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 105 insertions(+)
create mode 100644 drivers/usb/misc/nanoface.c
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig
index 76d7720..d01d5c0 100644
--- a/drivers/usb/misc/Kconfig
+++ b/drivers/usb/misc/Kconfig
@@ -249,6 +249,15 @@ config USB_HSIC_USB3503
help
This option enables support for SMSC USB3503 HSIC to USB 2.0 Driver.
+config USB_NANOFACE
+ tristate "ALVA Nanoface USB driver"
+ help
+ Say Y here if you need ALVA Nanoface device support. ALVA
+ Nanoface is a USB audio interface device. See
+ <http://www.alva-audio.de/nanoface/> for further information.
+ This driver does not support USB audio features, but enables basic
+ audio I/O connections and physical controls.
+
config USB_LINK_LAYER_TEST
tristate "USB Link Layer Test driver"
help
diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile
index 65b0402..2ee5b73 100644
--- a/drivers/usb/misc/Makefile
+++ b/drivers/usb/misc/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_USB_USS720) += uss720.o
obj-$(CONFIG_USB_SEVSEG) += usbsevseg.o
obj-$(CONFIG_USB_YUREX) += yurex.o
obj-$(CONFIG_USB_HSIC_USB3503) += usb3503.o
+obj-$(CONFIG_USB_NANOFACE) += nanoface.o
obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/
obj-$(CONFIG_USB_LINK_LAYER_TEST) += lvstest.o
diff --git a/drivers/usb/misc/nanoface.c b/drivers/usb/misc/nanoface.c
new file mode 100644
index 0000000..1201240
--- /dev/null
+++ b/drivers/usb/misc/nanoface.c
@@ -0,0 +1,95 @@
+/*
+ * Minimal driver for ALVA Nanoface USB audio interface. This driver does not
+ * support USB audio, but enables other audio I/O connections on the device.
+ *
+ * Copyright (C) 2014 Lauri Niskanen (ape@ape3000.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/usb.h>
+
+static unsigned char init_setup[] = {0x01, 0x0b, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00};
+static unsigned char init_data[] = {};
+
+static void init_complete_callback(struct urb *request)
+{
+ dev_info(&request->dev->dev, "ALVA Nanoface initialized\n");
+ usb_free_urb(request);
+}
+
+static int nanoface_probe(struct usb_interface *interface,
+ const struct usb_device_id *id)
+{
+ int status;
+ struct usb_device *dev;
+ struct urb *init_request;
+
+ dev = interface_to_usbdev(interface);
+
+ init_request = usb_alloc_urb(0, 0);
+ if (init_request == 0) {
+ dev_err(&dev->dev, "ALVA Nanoface initialization failed: Cannot allocate memory for URB request\n");
+ return -ENOMEM;
+ }
+
+ dev_info(&dev->dev, "ALVA Nanoface (%04X:%04X) connected\n",
+ id->idVendor, id->idProduct);
+
+ usb_fill_control_urb(init_request, dev,
+ usb_sndctrlpipe(dev, 0), init_setup,
+ init_data, sizeof(init_data),
+ init_complete_callback, 0);
+
+ status = usb_submit_urb(init_request, 0);
+ if (status != 0) {
+ dev_err(&dev->dev, "ALVA Nanoface initialization failed: Error %d when submitting URB\n",
+ status);
+ return status;
+ }
+
+ /* do not manage the device */
+ return -ENODEV;
+}
+
+static void nanoface_disconnect(struct usb_interface *interface)
+{
+ dev_info(&interface->dev, "ALVA Nanoface disconnected\n");
+}
+
+static struct usb_device_id nanoface_table[] = {
+ { USB_DEVICE(0x0a4a, 0xaffe) },
+ { /* Terminating entry */ }
+};
+
+MODULE_DEVICE_TABLE(usb, nanoface_table);
+
+static struct usb_driver nanoface_driver = {
+ .name = "nanoface",
+ .id_table = nanoface_table,
+ .probe = nanoface_probe,
+ .disconnect = nanoface_disconnect,
+};
+
+static int __init nanoface_init(void)
+{
+ return usb_register(&nanoface_driver);
+}
+
+static void __exit nanoface_exit(void)
+{
+ usb_deregister(&nanoface_driver);
+}
+
+module_init(nanoface_init);
+module_exit(nanoface_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Lauri Niskanen <ape@ape3000.com>");
+MODULE_DESCRIPTION("ALVA Nanoface USB driver");
--
2.1.3
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] usb: misc: Add driver for ALVA Nanoface
2014-11-11 7:05 [PATCH] usb: misc: Add driver for ALVA Nanoface Lauri Niskanen
@ 2014-11-11 7:07 ` Greg Kroah-Hartman
2014-11-11 7:17 ` Lauri Niskanen
0 siblings, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2014-11-11 7:07 UTC (permalink / raw)
To: Lauri Niskanen; +Cc: linux-kernel, linux-usb
On Tue, Nov 11, 2014 at 09:05:06AM +0200, Lauri Niskanen wrote:
> ALVA Nanoface is a USB audio interface device that only works after
> receiving an initialization command. This driver does not handle any
> actual audio features, but only initializes the device enabling its
> audio I/O and physical controls. There are some additional USB audio
> features on the device that are currently not supported. The support
> for these features may be added later.
>
> Signed-off-by: Lauri Niskanen <ape@ape3000.com>
> ---
> drivers/usb/misc/Kconfig | 9 +++++
> drivers/usb/misc/Makefile | 1 +
> drivers/usb/misc/nanoface.c | 95 +++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 105 insertions(+)
> create mode 100644 drivers/usb/misc/nanoface.c
Any reason this can't be a simple userspace program that writes the
needed command to the device using libusb instead of being a kernel
driver? This seems like overkill for a kernel driver to me.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] usb: misc: Add driver for ALVA Nanoface
2014-11-11 7:07 ` Greg Kroah-Hartman
@ 2014-11-11 7:17 ` Lauri Niskanen
2014-11-11 8:03 ` Greg Kroah-Hartman
0 siblings, 1 reply; 4+ messages in thread
From: Lauri Niskanen @ 2014-11-11 7:17 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-kernel, linux-usb
On 11/11/14 09:07, Greg Kroah-Hartman wrote:
> Any reason this can't be a simple userspace program that writes the
> needed command to the device using libusb instead of being a kernel
> driver? This seems like overkill for a kernel driver to me.
You are probably right. It indeed should be possible to do this in
userspace. I thought that having a kernel driver would still be
benefical since it adds plug-and-play availability for all Linux users
without having to deal with userspace driver programs.
You are far more experienced with these things than me, so I am happy to
let you make the decision about whether to have a kernel driver or not.
--
Lauri Niskanen
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] usb: misc: Add driver for ALVA Nanoface
2014-11-11 7:17 ` Lauri Niskanen
@ 2014-11-11 8:03 ` Greg Kroah-Hartman
0 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2014-11-11 8:03 UTC (permalink / raw)
To: Lauri Niskanen; +Cc: linux-kernel, linux-usb
On Tue, Nov 11, 2014 at 09:17:03AM +0200, Lauri Niskanen wrote:
> On 11/11/14 09:07, Greg Kroah-Hartman wrote:
> >Any reason this can't be a simple userspace program that writes the
> >needed command to the device using libusb instead of being a kernel
> >driver? This seems like overkill for a kernel driver to me.
>
> You are probably right. It indeed should be possible to do this in
> userspace. I thought that having a kernel driver would still be benefical
> since it adds plug-and-play availability for all Linux users without having
> to deal with userspace driver programs.
You can do that by just providing a package that adds a udev rule to run
your program when the device is seen.
Yes, it's not as "easy" as being in the main kernel tree, but we do like
to keep things out of the kernel that don't have to be in the kernel.
We removed a number of drivers like this about 10 years go for that very
reaason.
> You are far more experienced with these things than me, so I am happy to let
> you make the decision about whether to have a kernel driver or not.
I think a userspace program would be best.
sorry,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-11-11 8:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-11 7:05 [PATCH] usb: misc: Add driver for ALVA Nanoface Lauri Niskanen
2014-11-11 7:07 ` Greg Kroah-Hartman
2014-11-11 7:17 ` Lauri Niskanen
2014-11-11 8:03 ` Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox