Commit 3086775a authored by Felipe Balbi's avatar Felipe Balbi Committed by Greg Kroah-Hartman

usb gadget: cdc obex glue

The following patch introduces a new f_obex.c function driver.
It allows userspace obex servers to use usb as transport layer
for their messages.

[ dbrownell@users.sourceforge.net: various fixes and cleanups ]
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@nokia.com>
Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 60beed95
...@@ -557,6 +557,9 @@ Near-term plans include converting all of them, except for "gadgetfs". ...@@ -557,6 +557,9 @@ Near-term plans include converting all of them, except for "gadgetfs".
</para> </para>
!Edrivers/usb/gadget/f_acm.c !Edrivers/usb/gadget/f_acm.c
!Edrivers/usb/gadget/f_ecm.c
!Edrivers/usb/gadget/f_subset.c
!Edrivers/usb/gadget/f_obex.c
!Edrivers/usb/gadget/f_serial.c !Edrivers/usb/gadget/f_serial.c
</sect1> </sect1>
......
...@@ -576,19 +576,23 @@ config USB_FILE_STORAGE_TEST ...@@ -576,19 +576,23 @@ config USB_FILE_STORAGE_TEST
normal operation. normal operation.
config USB_G_SERIAL config USB_G_SERIAL
tristate "Serial Gadget (with CDC ACM support)" tristate "Serial Gadget (with CDC ACM and CDC OBEX support)"
help help
The Serial Gadget talks to the Linux-USB generic serial driver. The Serial Gadget talks to the Linux-USB generic serial driver.
This driver supports a CDC-ACM module option, which can be used This driver supports a CDC-ACM module option, which can be used
to interoperate with MS-Windows hosts or with the Linux-USB to interoperate with MS-Windows hosts or with the Linux-USB
"cdc-acm" driver. "cdc-acm" driver.
This driver also supports a CDC-OBEX option. You will need a
user space OBEX server talking to /dev/ttyGS*, since the kernel
itself doesn't implement the OBEX protocol.
Say "y" to link the driver statically, or "m" to build a Say "y" to link the driver statically, or "m" to build a
dynamically linked module called "g_serial". dynamically linked module called "g_serial".
For more information, see Documentation/usb/gadget_serial.txt For more information, see Documentation/usb/gadget_serial.txt
which includes instructions and a "driver info file" needed to which includes instructions and a "driver info file" needed to
make MS-Windows work with this driver. make MS-Windows work with CDC ACM.
config USB_MIDI_GADGET config USB_MIDI_GADGET
tristate "MIDI Gadget (EXPERIMENTAL)" tristate "MIDI Gadget (EXPERIMENTAL)"
......
This diff is collapsed.
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "epautoconf.c" #include "epautoconf.c"
#include "f_acm.c" #include "f_acm.c"
#include "f_obex.c"
#include "f_serial.c" #include "f_serial.c"
#include "u_serial.c" #include "u_serial.c"
...@@ -56,6 +57,7 @@ ...@@ -56,6 +57,7 @@
#define GS_VENDOR_ID 0x0525 /* NetChip */ #define GS_VENDOR_ID 0x0525 /* NetChip */
#define GS_PRODUCT_ID 0xa4a6 /* Linux-USB Serial Gadget */ #define GS_PRODUCT_ID 0xa4a6 /* Linux-USB Serial Gadget */
#define GS_CDC_PRODUCT_ID 0xa4a7 /* ... as CDC-ACM */ #define GS_CDC_PRODUCT_ID 0xa4a7 /* ... as CDC-ACM */
#define GS_CDC_OBEX_PRODUCT_ID 0xa4a9 /* ... as CDC-OBEX */
/* string IDs are assigned dynamically */ /* string IDs are assigned dynamically */
...@@ -125,6 +127,10 @@ static int use_acm = true; ...@@ -125,6 +127,10 @@ static int use_acm = true;
module_param(use_acm, bool, 0); module_param(use_acm, bool, 0);
MODULE_PARM_DESC(use_acm, "Use CDC ACM, default=yes"); MODULE_PARM_DESC(use_acm, "Use CDC ACM, default=yes");
static int use_obex = false;
module_param(use_obex, bool, 0);
MODULE_PARM_DESC(use_obex, "Use CDC OBEX, default=no");
static unsigned n_ports = 1; static unsigned n_ports = 1;
module_param(n_ports, uint, 0); module_param(n_ports, uint, 0);
MODULE_PARM_DESC(n_ports, "number of ports to create, default=1"); MODULE_PARM_DESC(n_ports, "number of ports to create, default=1");
...@@ -139,6 +145,8 @@ static int __init serial_bind_config(struct usb_configuration *c) ...@@ -139,6 +145,8 @@ static int __init serial_bind_config(struct usb_configuration *c)
for (i = 0; i < n_ports && status == 0; i++) { for (i = 0; i < n_ports && status == 0; i++) {
if (use_acm) if (use_acm)
status = acm_bind_config(c, i); status = acm_bind_config(c, i);
else if (use_obex)
status = obex_bind_config(c, i);
else else
status = gser_bind_config(c, i); status = gser_bind_config(c, i);
} }
...@@ -249,6 +257,12 @@ static int __init init(void) ...@@ -249,6 +257,12 @@ static int __init init(void)
device_desc.bDeviceClass = USB_CLASS_COMM; device_desc.bDeviceClass = USB_CLASS_COMM;
device_desc.idProduct = device_desc.idProduct =
__constant_cpu_to_le16(GS_CDC_PRODUCT_ID); __constant_cpu_to_le16(GS_CDC_PRODUCT_ID);
} else if (use_obex) {
serial_config_driver.label = "CDC OBEX config";
serial_config_driver.bConfigurationValue = 3;
device_desc.bDeviceClass = USB_CLASS_COMM;
device_desc.idProduct =
__constant_cpu_to_le16(GS_CDC_OBEX_PRODUCT_ID);
} else { } else {
serial_config_driver.label = "Generic Serial config"; serial_config_driver.label = "Generic Serial config";
serial_config_driver.bConfigurationValue = 1; serial_config_driver.bConfigurationValue = 1;
......
...@@ -62,5 +62,6 @@ void gserial_disconnect(struct gserial *); ...@@ -62,5 +62,6 @@ void gserial_disconnect(struct gserial *);
/* functions are bound to configurations by a config or gadget driver */ /* functions are bound to configurations by a config or gadget driver */
int acm_bind_config(struct usb_configuration *c, u8 port_num); int acm_bind_config(struct usb_configuration *c, u8 port_num);
int gser_bind_config(struct usb_configuration *c, u8 port_num); int gser_bind_config(struct usb_configuration *c, u8 port_num);
int obex_bind_config(struct usb_configuration *c, u8 port_num);
#endif /* __U_SERIAL_H */ #endif /* __U_SERIAL_H */
...@@ -160,6 +160,15 @@ struct usb_cdc_mdlm_detail_desc { ...@@ -160,6 +160,15 @@ struct usb_cdc_mdlm_detail_desc {
__u8 bDetailData[0]; __u8 bDetailData[0];
} __attribute__ ((packed)); } __attribute__ ((packed));
/* "OBEX Control Model Functional Descriptor" */
struct usb_cdc_obex_desc {
__u8 bLength;
__u8 bDescriptorType;
__u8 bDescriptorSubType;
__le16 bcdVersion;
} __attribute__ ((packed));
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment