summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Gmeiner <christian.gmeiner@gmail.com>2007-09-17 23:06:23 +0000
committerChristian Gmeiner <christian.gmeiner@gmail.com>2007-09-17 23:06:23 +0000
commit2077cebca00f57061b6a2c0ba41ab24cc97f3596 (patch)
tree92c085016a806e5c4e9f23b28c8e378f7de8c4e0
parent689d5fd4462c8b2069278e9c1c7ee054aae0b946 (diff)
downloadrockbox-2077cebca00f57061b6a2c0ba41ab24cc97f3596.tar.gz
rockbox-2077cebca00f57061b6a2c0ba41ab24cc97f3596.zip
* implement strstr
* clean up usb_arcotg_dcd_enable git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14740 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/SOURCES1
-rw-r--r--firmware/common/strstr.c45
-rw-r--r--firmware/drivers/usb/arcotg_dcd.c184
3 files changed, 136 insertions, 94 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index ab99167a8f..31b887c262 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -53,6 +53,7 @@ common/strncmp.c
common/strncpy.c
common/strrchr.c
common/strtok.c
+common/strstr.c
common/structec.c
common/timefuncs.c
common/unicode.c
diff --git a/firmware/common/strstr.c b/firmware/common/strstr.c
new file mode 100644
index 0000000000..2f33629997
--- /dev/null
+++ b/firmware/common/strstr.c
@@ -0,0 +1,45 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id: $
+ *
+ * Copyright (C) 2007 by Christian Gmeiner
+ *
+ ****************************************************************************/
+
+#include <string.h>
+
+/**
+ * Locate substring.
+ * @param search c string to be scanned.
+ * @param find c string containing the sequence of characters to match.
+ * @return a pointer to the first occurrence in search of any of the
+ * entire sequence of characters specified in find, or a
+ * null pointer if the sequence is not present in search.
+ */
+char *strstr(const char *search, const char *find)
+{
+ char *hend;
+ char *a, *b;
+
+ if (*find == 0) return (char*)search;
+ hend = (char *)search + strlen(search) - strlen(find) + 1;
+ while (search < hend) {
+ if (*search == *find) {
+ a = (char *)search;
+ b = (char *)find;
+ for (;;) {
+ if (*b == 0) return (char*)search;
+ if (*a++ != *b++) {
+ break;
+ }
+ }
+ }
+ search++;
+ }
+ return 0;
+}
diff --git a/firmware/drivers/usb/arcotg_dcd.c b/firmware/drivers/usb/arcotg_dcd.c
index b08f7eef58..124742cf13 100644
--- a/firmware/drivers/usb/arcotg_dcd.c
+++ b/firmware/drivers/usb/arcotg_dcd.c
@@ -523,29 +523,83 @@ int usb_arcotg_dcd_enable(struct usb_ep* ep,
max = desc->wMaxPacketSize;
retval = -EINVAL;
- /* check the max package size validate for this endpoint */
- /* Refer to USB2.0 spec table 9-13. */
+ /* check the max package size validate for this endpoint
+ * Refer to USB2.0 spec table 9-13, */
switch (desc->bmAttributes & 0x03) {
case USB_ENDPOINT_XFER_BULK:
+ if (strstr(ep->name, "-iso") || strstr(ep->name, "-int")) {
+ goto en_done;
+ }
+ mult = 0;
zlt = 1;
+
+ switch (arcotg_dcd.speed) {
+ case USB_SPEED_HIGH:
+ if ((max == 128) || (max == 256) || (max == 512)) {
+ break;
+ }
+ default:
+ switch (max) {
+ case 4:
+ case 8:
+ case 16:
+ case 32:
+ case 64:
+ break;
+ default:
+ case USB_SPEED_LOW:
+ goto en_done;
+ }
+ }
break;
case USB_ENDPOINT_XFER_INT:
+ if (strstr(ep->name, "-iso")) { /* bulk is ok */
+ goto en_done;
+ }
+ mult = 0;
zlt = 1;
- break;
- case USB_ENDPOINT_XFER_ISOC:
+ switch (arcotg_dcd.speed) {
+ case USB_SPEED_HIGH:
+ if (max <= 1024) {
+ break;
+ }
+ case USB_SPEED_FULL:
+ if (max <= 64) {
+ break;
+ }
+ default:
+ if (max <= 8) {
+ break;
+ }
+ goto en_done;
+ }
break;
- case USB_ENDPOINT_XFER_CONTROL:
- zlt = 1;
+ case USB_ENDPOINT_XFER_ISOC:
+ if (strstr(ep->name, "-bulk") || strstr(ep->name, "-int")) {
+ goto en_done;
+ }
+ mult = (unsigned char) (1 +((desc->wMaxPacketSize >> 11) & 0x03));
+ zlt = 0;
+
+ switch (arcotg_dcd.speed) {
+ case USB_SPEED_HIGH:
+ if (max <= 1024) {
+ break;
+ }
+ case USB_SPEED_FULL:
+ if (max <= 1023) {
+ break;
+ }
+ default:
+ goto en_done;
+ }
break;
- }
-#if 0
- switch (ep->desc->bmAttributes & 0x03) {
- case USB_ENDPOINT_XFER_BULK:
- if (strstr(ep->ep.name, "-iso") || strstr(ep->ep.name, "-int")) {
+ case USB_ENDPOINT_XFER_CONTROL:
+ if (strstr(ep->name, "-iso") || strstr(ep->name, "-int")) {
goto en_done;
}
mult = 0;
@@ -553,11 +607,10 @@ int usb_arcotg_dcd_enable(struct usb_ep* ep,
switch (arcotg_dcd.speed) {
case USB_SPEED_HIGH:
- if ((max == 128) || (max == 256) || (max == 512)) {
- break;
- }
- default:
+ case USB_SPEED_FULL:
switch (max) {
+ case 1:
+ case 2:
case 4:
case 8:
case 16:
@@ -565,85 +618,27 @@ int usb_arcotg_dcd_enable(struct usb_ep* ep,
case 64:
break;
default:
- + case USB_SPEED_LOW:
- + goto en_done;
- + }
- + }
- + break;
- + case USB_ENDPOINT_XFER_INT:
- + if (strstr(ep->ep.name, "-iso")) /* bulk is ok */
- + goto en_done;
- + mult = 0;
- + zlt = 1;
- + switch (udc->gadget.speed) {
- + case USB_SPEED_HIGH:
- + if (max <= 1024)
- + break;
- + case USB_SPEED_FULL:
- + if (max <= 64)
- + break;
- + default:
- + if (max <= 8)
- + break;
- + goto en_done;
- + }
- + break;
- + case USB_ENDPOINT_XFER_ISOC:
- + if (strstr(ep->ep.name, "-bulk") || strstr(ep->ep.name, "-int"))
- + goto en_done;
- + mult = (unsigned char)
- + (1 + ((le16_to_cpu(desc->wMaxPacketSize) >> 11) & 0x03));
- + zlt = 0;
- + switch (udc->gadget.speed) {
- + case USB_SPEED_HIGH:
- + if (max <= 1024)
- + break;
- + case USB_SPEED_FULL:
- + if (max <= 1023)
- + break;
- + default:
- + goto en_done;
- + }
- + break;
- + case USB_ENDPOINT_XFER_CONTROL:
- + if (strstr(ep->ep.name, "-iso") || strstr(ep->ep.name, "-int"))
- + goto en_done;
- + mult = 0;
- + zlt = 1;
- + switch (udc->gadget.speed) {
- + case USB_SPEED_HIGH:
- + case USB_SPEED_FULL:
- + switch (max) {
- + case 1:
- + case 2:
- + case 4:
- + case 8:
- + case 16:
- + case 32:
- + case 64:
- + break;
- + default:
- + goto en_done;
- + }
- + case USB_SPEED_LOW:
- + switch (max) {
- + case 1:
- + case 2:
- + case 4:
- + case 8:
- + break;
- + default:
- + goto en_done;
- + }
- + default:
- + goto en_done;
- + }
- + break;
- +
- + default:
- + goto en_done;
- + }
-#endif
+ goto en_done;
+ }
+ case USB_SPEED_LOW:
+ switch (max) {
+ case 1:
+ case 2:
+ case 4:
+ case 8:
+ break;
+ default:
+ goto en_done;
+ }
+ default:
+ goto en_done;
+ }
+ break;
+
+ default:
+ goto en_done;
+ }
+
/* here initialize variable of ep */
ep->maxpacket = max;
@@ -690,6 +685,7 @@ int usb_arcotg_dcd_enable(struct usb_ep* ep,
(desc->bEndpointAddress & USB_DIR_IN) ? "in" : "out", val);
logf(" maxpacket %d", max);
+en_done:
return retval;
}