[packages] utils/gadgetfs-test: add test program for gadgetfs from linux-usb.org
authorjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Thu, 29 Nov 2007 08:27:09 +0000 (08:27 +0000)
committerjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Thu, 29 Nov 2007 08:27:09 +0000 (08:27 +0000)
git-svn-id: svn://svn.openwrt.org/openwrt/packages@9628 3c298f89-4303-0410-b956-a3cf2f4a3e73

utils/gadgetfs-test/Makefile [new file with mode: 0644]
utils/gadgetfs-test/patches/001-linux_usb_org_2007_11_29.patch [new file with mode: 0644]

diff --git a/utils/gadgetfs-test/Makefile b/utils/gadgetfs-test/Makefile
new file mode 100644 (file)
index 0000000..08fe875
--- /dev/null
@@ -0,0 +1,113 @@
+#
+# Copyright (C) 2007 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+# $Id$
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=gadgetfs-test
+PKG_VERSION:=2007-11-29
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME).tar.bz2
+PKG_SOURCE_URL:=http://avr32linux.org/twiki/pub/Main/GadgetFsTest
+PKG_MD5SUM:=49476a74c29f1281c8a4c035aa57a5bd
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/gadgetfs-test
+  SECTION:=utils
+  CATEGORY:=Utilities
+  TITLE:=Test program for gadgetfs
+  DEPENDS:=@DEVEL +libpthread
+  URL:=http://linux-usb.org/gadget
+endef
+
+define Package/gadgetfs-test/description
+ Test program for gadgetfs from linux-usb.org.
+endef
+
+define Package/gadgetfs-test-bulk
+$(call Package/gadgetfs-test)
+  TITLE+= (BULK transfer)
+endef
+
+define Package/gadgetfs-test-bulk/description
+$(call Package/gadgetfs-test/description)
+ This package is built with BULK transfer support.
+endef
+
+define Package/gadgetfs-test-isoc
+$(call Package/gadgetfs-test)
+  DEPENDS+= +libaio
+  TITLE+= (ISOCHRONOUS transfer)
+endef
+
+define Package/gadgetfs-test-isoc/description
+$(call Package/gadgetfs-test/description)
+ This package is built with ISOCHRONOUS transfer support using libaio.
+endef
+
+
+GADGETFS_CFLAGS:=$(TARGET_CFLAGS) $(EXTRA_CFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)
+GADGETFS_LDFLAGS:=$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)
+GADGETFS_LIBS:=-lpthread
+
+define Build/Template
+
+$(STAMP_BUILT)-$(1): $(STAMP_PREPARED)
+       -$(MAKE) -C $(PKG_BUILD_DIR) clean
+       $(MAKE_VARS) \
+       $(MAKE) -C $(PKG_BUILD_DIR) \
+               $(TARGET_CONFIGURE_OPTS) \
+               CC="$(TARGET_CC)" \
+               LDFLAGS="$(GADGETFS_LDFLAGS)" \
+               $(2) \
+               all
+       mv -f $(PKG_BUILD_DIR)/gadgetfs-test $(PKG_BUILD_DIR)/gadgetfs-test-$(1)
+       touch $$@
+
+$(STAMP_BUILT): $(STAMP_BUILT)-$(1)
+
+define Package/gadgetfs-test-$(1)/install
+       $(INSTALL_DIR) $$(1)/usr/sbin
+       $(INSTALL_BIN) $$(PKG_BUILD_DIR)/gadgetfs-test-$(1) $$(1)/usr/sbin/
+endef
+
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+endef
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_gadgetfs-test-bulk),)
+  define Build/bulk
+    $(call Build/Template,bulk, \
+               CFLAGS="$(GADGETFS_CFLAGS)" \
+               LIBS="$(GADGETFS_LIBS)" \
+    )
+  endef
+endif
+$(eval $(Build/bulk))
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_gadgetfs-test-isoc),)
+  define Build/isoc
+    $(call Build/Template,isoc, \
+               CFLAGS="$(GADGETFS_CFLAGS) -DAIO" \
+               LIBS="$(GADGETFS_LIBS) -laio" \
+    )
+  endef
+endif
+$(eval $(Build/isoc))
+
+$(eval $(call BuildPackage,gadgetfs-test-bulk))
+$(eval $(call BuildPackage,gadgetfs-test-isoc))
+
diff --git a/utils/gadgetfs-test/patches/001-linux_usb_org_2007_11_29.patch b/utils/gadgetfs-test/patches/001-linux_usb_org_2007_11_29.patch
new file mode 100644 (file)
index 0000000..fce5b68
--- /dev/null
@@ -0,0 +1,214 @@
+diff -Nur gadgetfs-test.orig/usb.c gadgetfs-test.2007-11-29/usb.c
+--- gadgetfs-test.orig/usb.c   2007-06-21 16:36:32.000000000 +0200
++++ gadgetfs-test.2007-11-29/usb.c     2007-09-25 09:01:48.000000000 +0200
+@@ -34,8 +34,8 @@
+ #include <asm/byteorder.h>
+ #include <linux/types.h>
+-#include <linux/usb_gadgetfs.h>
+-#include <linux/usb_ch9.h>
++#include <linux/usb/gadgetfs.h>
++#include <linux/usb/ch9.h>
+ #ifdef        AIO
+ /* this aio code works with libaio-0.3.106 */
+@@ -402,6 +402,26 @@
+               fs_status_desc.bEndpointAddress = USB_DIR_IN | 3;
+               EP_STATUS_NAME = "ep3in-int";
++      /* Atmel AT32AP700x processors, high/full speed */
++      } else if (stat (DEVNAME = "atmel_usba_udc", &statb) == 0) {
++              HIGHSPEED = 1;
++              device_desc.bcdDevice = __constant_cpu_to_le16 (0x0108);
++
++              fs_source_desc.bEndpointAddress
++                      = hs_source_desc.bEndpointAddress
++                      = USB_DIR_IN | 1;
++              EP_IN_NAME = "ep1in-bulk";
++              fs_sink_desc.bEndpointAddress
++                      = hs_sink_desc.bEndpointAddress
++                      = USB_DIR_OUT | 2;
++              EP_OUT_NAME = "ep2out-bulk";
++
++              source_sink_intf.bNumEndpoints = 3;
++              fs_status_desc.bEndpointAddress
++                      = hs_status_desc.bEndpointAddress
++                      = USB_DIR_IN | 3;
++              EP_STATUS_NAME = "ep3in-int";
++
+       } else {
+               DEVNAME = 0;
+               return -ENODEV;
+@@ -597,18 +617,58 @@
+               fs_status_desc.bEndpointAddress = USB_DIR_IN | 3;
+               EP_STATUS_NAME = "ep3-int";
++      /* Atmel AT32AP700x processors, high/full speed */
++      } else if (stat (DEVNAME = "atmel_usba_udc", &statb) == 0){
++              HIGHSPEED = 1;
++
++              device_desc.bcdDevice = __constant_cpu_to_le16 (0x0105);
++
++              fs_source_desc.bEndpointAddress
++                      = hs_source_desc.bEndpointAddress
++                      = USB_DIR_IN | 5;
++              fs_source_desc.bmAttributes
++                      = hs_source_desc.bmAttributes
++                      = USB_ENDPOINT_XFER_ISOC;
++              fs_source_desc.wMaxPacketSize
++                      = hs_source_desc.wMaxPacketSize
++                      = __cpu_to_le16(min (bufsize, 1024));
++              fs_source_desc.bInterval
++                      = hs_source_desc.bInterval
++                      = interval;
++              EP_IN_NAME = "ep5in-iso";
++
++              fs_sink_desc.bEndpointAddress
++                      = hs_sink_desc.bEndpointAddress
++                      = USB_DIR_OUT | 6;
++              fs_sink_desc.bmAttributes
++                      = hs_sink_desc.bmAttributes
++                      = USB_ENDPOINT_XFER_ISOC;
++              fs_sink_desc.wMaxPacketSize
++                      = hs_sink_desc.wMaxPacketSize
++                      = __cpu_to_le16(min (bufsize, 1024));
++              fs_sink_desc.bInterval
++                      = hs_sink_desc.bInterval
++                      = interval;
++              EP_OUT_NAME = "ep6out-iso";
++
++              source_sink_intf.bNumEndpoints = 3;
++              fs_status_desc.bEndpointAddress
++                      = hs_status_desc.bEndpointAddress
++                      = USB_DIR_IN | 3;
++              EP_STATUS_NAME = "ep3in-int";
++
+       } else {
+               DEVNAME = 0;
+               return -ENODEV;
+       }
+       if (verbose) {
+               fprintf (stderr, "iso fs wMaxPacket %04x bInterval %02x\n",
+-                      fs_sink_desc.wMaxPacketSize,
++                      __le16_to_cpu(fs_sink_desc.wMaxPacketSize),
+                       fs_sink_desc.bInterval);
+               if (HIGHSPEED)
+                       fprintf (stderr,
+                               "iso hs wMaxPacket %04x bInterval %02x\n",
+-                              hs_sink_desc.wMaxPacketSize,
++                              __le16_to_cpu(hs_sink_desc.wMaxPacketSize),
+                               hs_sink_desc.bInterval);
+       }
+       return 0;
+@@ -1285,13 +1345,17 @@
+ {
+       int             status, tmp;
+       __u8            buf [256];
++      __u16           value, index, length;
++
++      value = __le16_to_cpu(setup->wValue);
++      index = __le16_to_cpu(setup->wIndex);
++      length = __le16_to_cpu(setup->wLength);
+       if (verbose)
+               fprintf (stderr, "SETUP %02x.%02x "
+                               "v%04x i%04x %d\n",
+                       setup->bRequestType, setup->bRequest,
+-                      setup->wValue, setup->wIndex,
+-                      setup->wLength);
++                      value, index, length);
+       /*
+       if ((setup->bRequestType & USB_TYPE_MASK) != USB_TYPE_STANDARD)
+@@ -1302,21 +1366,21 @@
+       case USB_REQ_GET_DESCRIPTOR:
+               if (setup->bRequestType != USB_DIR_IN)
+                       goto stall;
+-              switch (setup->wValue >> 8) {
++              switch (value >> 8) {
+               case USB_DT_STRING:
+-                      tmp = setup->wValue & 0x0ff;
++                      tmp = value & 0x0ff;
+                       if (verbose > 1)
+                               fprintf (stderr,
+                                       "... get string %d lang %04x\n",
+-                                      tmp, setup->wIndex);
+-                      if (tmp != 0 && setup->wIndex != strings.language)
++                                      tmp, index);
++                      if (tmp != 0 && index != strings.language)
+                               goto stall;
+                       status = usb_gadget_get_string (&strings, tmp, buf);
+                       if (status < 0)
+                               goto stall;
+                       tmp = status;
+-                      if (setup->wLength < tmp)
+-                              tmp = setup->wLength;
++                      if (length < tmp)
++                              tmp = length;
+                       status = write (fd, buf, tmp);
+                       if (status < 0) {
+                               if (errno == EIDRM)
+@@ -1336,7 +1400,7 @@
+               if (setup->bRequestType != USB_DIR_OUT)
+                       goto stall;
+               if (verbose)
+-                      fprintf (stderr, "CONFIG #%d\n", setup->wValue);
++                      fprintf (stderr, "CONFIG #%d\n", value);
+               /* Kernel is normally waiting for us to finish reconfiguring
+                * the device.
+@@ -1349,7 +1413,7 @@
+                * the endpoints always active and don't rely on seeing any
+                * config change events, either this or SET_INTERFACE.
+                */
+-              switch (setup->wValue) {
++              switch (value) {
+               case CONFIG_VALUE:
+                       start_io ();
+                       break;
+@@ -1369,27 +1433,27 @@
+               return;
+       case USB_REQ_GET_INTERFACE:
+               if (setup->bRequestType != (USB_DIR_IN|USB_RECIP_INTERFACE)
+-                              || setup->wIndex != 0
+-                              || setup->wLength > 1)
++                              || index != 0
++                              || length > 1)
+                       goto stall;
+               /* only one altsetting in this driver */
+               buf [0] = 0;
+-              status = write (fd, buf, setup->wLength);
++              status = write (fd, buf, length);
+               if (status < 0) {
+                       if (errno == EIDRM)
+                               fprintf (stderr, "GET_INTERFACE timeout\n");
+                       else
+                               perror ("write GET_INTERFACE data");
+-              } else if (status != setup->wLength) {
++              } else if (status != length) {
+                       fprintf (stderr, "short GET_INTERFACE write, %d\n",
+                               status);
+               }
+               return;
+       case USB_REQ_SET_INTERFACE:
+               if (setup->bRequestType != USB_RECIP_INTERFACE
+-                              || setup->wIndex != 0
+-                              || setup->wValue != 0)
++                              || index != 0
++                              || value != 0)
+                       goto stall;
+               /* just reset toggle/halt for the interface's endpoints */
+diff -Nur gadgetfs-test.orig/usbstring.c gadgetfs-test.2007-11-29/usbstring.c
+--- gadgetfs-test.orig/usbstring.c     2007-06-21 16:36:32.000000000 +0200
++++ gadgetfs-test.2007-11-29/usbstring.c       2007-09-25 09:01:48.000000000 +0200
+@@ -11,7 +11,7 @@
+ #include <string.h>
+ #include <linux/types.h>
+-#include <linux/usb_ch9.h>
++#include <linux/usb/ch9.h>
+ #include "usbstring.h"