summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-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
53common/strncpy.c 53common/strncpy.c
54common/strrchr.c 54common/strrchr.c
55common/strtok.c 55common/strtok.c
56common/strstr.c
56common/structec.c 57common/structec.c
57common/timefuncs.c 58common/timefuncs.c
58common/unicode.c 59common/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 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: $
9 *
10 * Copyright (C) 2007 by Christian Gmeiner
11 *
12 ****************************************************************************/
13
14#include <string.h>
15
16/**
17 * Locate substring.
18 * @param search c string to be scanned.
19 * @param find c string containing the sequence of characters to match.
20 * @return a pointer to the first occurrence in search of any of the
21 * entire sequence of characters specified in find, or a
22 * null pointer if the sequence is not present in search.
23 */
24char *strstr(const char *search, const char *find)
25{
26 char *hend;
27 char *a, *b;
28
29 if (*find == 0) return (char*)search;
30 hend = (char *)search + strlen(search) - strlen(find) + 1;
31 while (search < hend) {
32 if (*search == *find) {
33 a = (char *)search;
34 b = (char *)find;
35 for (;;) {
36 if (*b == 0) return (char*)search;
37 if (*a++ != *b++) {
38 break;
39 }
40 }
41 }
42 search++;
43 }
44 return 0;
45}
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,
523 max = desc->wMaxPacketSize; 523 max = desc->wMaxPacketSize;
524 retval = -EINVAL; 524 retval = -EINVAL;
525 525
526 /* check the max package size validate for this endpoint */ 526 /* check the max package size validate for this endpoint
527 /* Refer to USB2.0 spec table 9-13. */ 527 * Refer to USB2.0 spec table 9-13, */
528 switch (desc->bmAttributes & 0x03) { 528 switch (desc->bmAttributes & 0x03) {
529 case USB_ENDPOINT_XFER_BULK: 529 case USB_ENDPOINT_XFER_BULK:
530 if (strstr(ep->name, "-iso") || strstr(ep->name, "-int")) {
531 goto en_done;
532 }
533 mult = 0;
530 zlt = 1; 534 zlt = 1;
535
536 switch (arcotg_dcd.speed) {
537 case USB_SPEED_HIGH:
538 if ((max == 128) || (max == 256) || (max == 512)) {
539 break;
540 }
541 default:
542 switch (max) {
543 case 4:
544 case 8:
545 case 16:
546 case 32:
547 case 64:
548 break;
549 default:
550 case USB_SPEED_LOW:
551 goto en_done;
552 }
553 }
531 break; 554 break;
532 555
533 case USB_ENDPOINT_XFER_INT: 556 case USB_ENDPOINT_XFER_INT:
557 if (strstr(ep->name, "-iso")) { /* bulk is ok */
558 goto en_done;
559 }
560 mult = 0;
534 zlt = 1; 561 zlt = 1;
535 break;
536 562
537 case USB_ENDPOINT_XFER_ISOC: 563 switch (arcotg_dcd.speed) {
564 case USB_SPEED_HIGH:
565 if (max <= 1024) {
566 break;
567 }
568 case USB_SPEED_FULL:
569 if (max <= 64) {
570 break;
571 }
572 default:
573 if (max <= 8) {
574 break;
575 }
576 goto en_done;
577 }
538 break; 578 break;
539 579
540 case USB_ENDPOINT_XFER_CONTROL: 580 case USB_ENDPOINT_XFER_ISOC:
541 zlt = 1; 581 if (strstr(ep->name, "-bulk") || strstr(ep->name, "-int")) {
582 goto en_done;
583 }
584 mult = (unsigned char) (1 +((desc->wMaxPacketSize >> 11) & 0x03));
585 zlt = 0;
586
587 switch (arcotg_dcd.speed) {
588 case USB_SPEED_HIGH:
589 if (max <= 1024) {
590 break;
591 }
592 case USB_SPEED_FULL:
593 if (max <= 1023) {
594 break;
595 }
596 default:
597 goto en_done;
598 }
542 break; 599 break;
543 }
544 600
545#if 0 601 case USB_ENDPOINT_XFER_CONTROL:
546 switch (ep->desc->bmAttributes & 0x03) { 602 if (strstr(ep->name, "-iso") || strstr(ep->name, "-int")) {
547 case USB_ENDPOINT_XFER_BULK:
548 if (strstr(ep->ep.name, "-iso") || strstr(ep->ep.name, "-int")) {
549 goto en_done; 603 goto en_done;
550 } 604 }
551 mult = 0; 605 mult = 0;
@@ -553,11 +607,10 @@ int usb_arcotg_dcd_enable(struct usb_ep* ep,
553 607
554 switch (arcotg_dcd.speed) { 608 switch (arcotg_dcd.speed) {
555 case USB_SPEED_HIGH: 609 case USB_SPEED_HIGH:
556 if ((max == 128) || (max == 256) || (max == 512)) { 610 case USB_SPEED_FULL:
557 break;
558 }
559 default:
560 switch (max) { 611 switch (max) {
612 case 1:
613 case 2:
561 case 4: 614 case 4:
562 case 8: 615 case 8:
563 case 16: 616 case 16:
@@ -565,85 +618,27 @@ int usb_arcotg_dcd_enable(struct usb_ep* ep,
565 case 64: 618 case 64:
566 break; 619 break;
567 default: 620 default:
568 + case USB_SPEED_LOW: 621 goto en_done;
569 + goto en_done; 622 }
570 + } 623 case USB_SPEED_LOW:
571 + } 624 switch (max) {
572 + break; 625 case 1:
573 + case USB_ENDPOINT_XFER_INT: 626 case 2:
574 + if (strstr(ep->ep.name, "-iso")) /* bulk is ok */ 627 case 4:
575 + goto en_done; 628 case 8:
576 + mult = 0; 629 break;
577 + zlt = 1; 630 default:
578 + switch (udc->gadget.speed) { 631 goto en_done;
579 + case USB_SPEED_HIGH: 632 }
580 + if (max <= 1024) 633 default:
581 + break; 634 goto en_done;
582 + case USB_SPEED_FULL: 635 }
583 + if (max <= 64) 636 break;
584 + break; 637
585 + default: 638 default:
586 + if (max <= 8) 639 goto en_done;
587 + break; 640 }
588 + goto en_done; 641
589 + }
590 + break;
591 + case USB_ENDPOINT_XFER_ISOC:
592 + if (strstr(ep->ep.name, "-bulk") || strstr(ep->ep.name, "-int"))
593 + goto en_done;
594 + mult = (unsigned char)
595 + (1 + ((le16_to_cpu(desc->wMaxPacketSize) >> 11) & 0x03));
596 + zlt = 0;
597 + switch (udc->gadget.speed) {
598 + case USB_SPEED_HIGH:
599 + if (max <= 1024)
600 + break;
601 + case USB_SPEED_FULL:
602 + if (max <= 1023)
603 + break;
604 + default:
605 + goto en_done;
606 + }
607 + break;
608 + case USB_ENDPOINT_XFER_CONTROL:
609 + if (strstr(ep->ep.name, "-iso") || strstr(ep->ep.name, "-int"))
610 + goto en_done;
611 + mult = 0;
612 + zlt = 1;
613 + switch (udc->gadget.speed) {
614 + case USB_SPEED_HIGH:
615 + case USB_SPEED_FULL:
616 + switch (max) {
617 + case 1:
618 + case 2:
619 + case 4:
620 + case 8:
621 + case 16:
622 + case 32:
623 + case 64:
624 + break;
625 + default:
626 + goto en_done;
627 + }
628 + case USB_SPEED_LOW:
629 + switch (max) {
630 + case 1:
631 + case 2:
632 + case 4:
633 + case 8:
634 + break;
635 + default:
636 + goto en_done;
637 + }
638 + default:
639 + goto en_done;
640 + }
641 + break;
642 +
643 + default:
644 + goto en_done;
645 + }
646#endif
647 642
648 /* here initialize variable of ep */ 643 /* here initialize variable of ep */
649 ep->maxpacket = max; 644 ep->maxpacket = max;
@@ -690,6 +685,7 @@ int usb_arcotg_dcd_enable(struct usb_ep* ep,
690 (desc->bEndpointAddress & USB_DIR_IN) ? "in" : "out", val); 685 (desc->bEndpointAddress & USB_DIR_IN) ? "in" : "out", val);
691 logf(" maxpacket %d", max); 686 logf(" maxpacket %d", max);
692 687
688en_done:
693 return retval; 689 return retval;
694} 690}
695 691