[PATCH v2 0/4] Equivalent of g_zero with configfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This series aims at integrating configfs into gadget zero, the way
it has been done for acm, ncm, ecm, eem, ecm subset, rndis, obex, phonet,
mass_storage and FunctionFS. It contains everything that is required to provide the
equivalent of g_zero.ko with configfs.


v1..v2:

- fixes after Michal's review, thank you, Michal!
- simplified redirecting the setup request

Rebased onto Felipe's master.

BACKWARD COMPATIBILITY
======================

Please note that the old g_zero.ko is still available and works.

USING THE NEW "GADGET"
======================

Please refer to this post:

http://www.spinics.net/lists/linux-usb/msg76388.html

for general information from Sebastian on how to use configfs-based
gadgets (*).

With configfs the procedure is as follows, compared to the information
mentioned above (*):

instead of mkdir functions/acm.ttyS1 do

mkdir functions/Loopback.0
mkdir functions/SourceSink.0

In the Loopback.0 directory there will be two attributes:

qlen - depth of loopback queue
bulk_buflen - buffer length

In the SourceSink.0 directory there will be six attributes:

pattern - 0 (all zeros), 1 (mod63), 2 (none)
isoc_interval - 1..16
isoc_maxpacket - 0 - 1023 (fs), 0 - 1024 (hs/ss)
isoc_mult - 0..2 (hs/ss only)
isoc_maxburst - 0..15 (ss only)
bulk_buflen - buffer length


An example gadget with Loopback and SourceSink functions:

$ modprobe libcomposite

$ mount none cfg -t configfs

$ mkdir cfg/usb_gadget/g1
$ cd cfg/usb_gadget/g1
 
$ mkdir configs/c.1
$ mkdir configs/c.2
$ mkdir functions/Loopback.0
$ mkdir functions/SourceSink.0

$ mkdir strings/0x409
$ mkdir configs/c.1/strings/0x409
$ mkdir configs/c.2/strings/0x409

$ echo 0x2d01 > idProduct
$ echo 0x04e8 > idVendor

$ echo my-serial-num > strings/0x409/serialnumber
$ echo my-manufacturer > strings/0x409/manufacturer
$ echo "Test gadget" > strings/0x409/product

$ echo "Conf 1" > configs/c.1/strings/0x409/configuration
$ echo "Conf 2" > configs/c.2/strings/0x409/configuration
$ echo 120 > configs/c.1/MaxPower
$ ln -s functions/Loopback.0 configs/c.1
$ ln -s functions/SourceSink.0 configs/c.2

$ echo s3c-hsotg > cfg/usb_gadget/g1/UDC


After unbinding the gadget with echo "" > UDC
the symbolic links in the configuration directory can be removed,
the strings/* subdirectories in the configuration directory can
be removed, the strings/* subdirectories at the gadget level can
be removed and the configs/* subdirectories can be removed.
The functions/* subdirectories can be removed.
After that the gadget directory can be removed.
Daemons need to be closed and then the respective modules can be unloaded.


TESTING THE FUNCTIONS (actually there is only one)
=====================

loopback, souresink)

device: run the gadget
host: test-usb

http://www.linux-usb.org/usbtest/testusb.c

The results should be the same as with the g_zero.ko.


Andrzej Pietrasiewicz (4):
  usb/gadget: composite: redirect setup requests
  usb/gadget: factor out alloc_ep_req
  usb/gadget: f_loopback: add configfs support
  usb/gadget: f_sourcesink: add configfs support

 .../ABI/testing/configfs-usb-gadget-loopback       |    8 +
 .../ABI/testing/configfs-usb-gadget-sourcesink     |   12 +
 drivers/usb/gadget/Kconfig                         |   13 +
 drivers/usb/gadget/Makefile                        |    2 +-
 drivers/usb/gadget/composite.c                     |   16 +-
 drivers/usb/gadget/f_hid.c                         |   18 +-
 drivers/usb/gadget/f_loopback.c                    |  140 ++++++++-
 drivers/usb/gadget/f_midi.c                        |   22 +-
 drivers/usb/gadget/f_sourcesink.c                  |  341 ++++++++++++++++++-
 drivers/usb/gadget/g_zero.h                        |   24 ++-
 drivers/usb/gadget/u_f.c                           |   32 ++
 drivers/usb/gadget/u_f.h                           |   26 ++
 drivers/usb/gadget/zero.c                          |    8 +-
 13 files changed, 608 insertions(+), 54 deletions(-)
 create mode 100644 Documentation/ABI/testing/configfs-usb-gadget-loopback
 create mode 100644 Documentation/ABI/testing/configfs-usb-gadget-sourcesink
 create mode 100644 drivers/usb/gadget/u_f.c
 create mode 100644 drivers/usb/gadget/u_f.h

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux