From c61a75173b2e81ea3ae3aa1d3cdf84d15e4304c3 Mon Sep 17 00:00:00 2001 From: Frank Gevaerts Date: Sat, 23 May 2009 14:30:20 +0000 Subject: Reorganise USB stack defines. Now config.h decides which class drivers get enabled instead of usb_core.h Also enable HID, and use that as the dummy class instead of charging-only for controllers that have working interrupt transfers. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21053 a1c6a512-1295-4272-9138-f99709370657 --- apps/debug_menu.c | 10 ++++---- firmware/SOURCES | 8 +++++++ firmware/export/config-gigabeat-s.h | 1 - firmware/export/config-iaudio7.h | 3 --- firmware/export/config.h | 43 +++++++++++++++++++++++++++++++++++ firmware/export/usb_core.h | 10 -------- firmware/logf.c | 2 +- firmware/usb.c | 22 +++++++++++------- firmware/usbstack/usb_charging_only.c | 4 ---- firmware/usbstack/usb_core.c | 16 ++++++------- firmware/usbstack/usb_hid.c | 4 ---- firmware/usbstack/usb_serial.c | 4 ---- firmware/usbstack/usb_storage.c | 4 ---- 13 files changed, 79 insertions(+), 52 deletions(-) diff --git a/apps/debug_menu.c b/apps/debug_menu.c index f1a4c4d998..8a2b945fe1 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c @@ -114,7 +114,7 @@ #ifdef HAVE_USBSTACK #include "usb_core.h" -#ifdef USB_HID +#ifdef USB_ENABLE_HID #include "usbstack/usb_hid.h" #endif #endif @@ -2588,7 +2588,7 @@ static bool dbg_scrollwheel(void) #if defined (HAVE_USBSTACK) -#if defined(ROCKBOX_HAS_LOGF) && defined(USB_SERIAL) +#if defined(ROCKBOX_HAS_LOGF) && defined(USB_ENABLE_SERIAL) static bool toggle_usb_core_driver(int driver, char *msg) { bool enabled = !usb_core_driver_enabled(driver); @@ -2605,7 +2605,7 @@ static bool toggle_usb_serial(void) } #endif -#ifdef USB_HID +#ifdef USB_ENABLE_HID static bool hid_send_cmd(consumer_usage_page_t cmd, char *msg) { (void)msg; @@ -2786,10 +2786,10 @@ static const struct the_menu_item menuitems[] = { {"logfdump", logfdump }, #endif #if defined(HAVE_USBSTACK) -#if defined(ROCKBOX_HAS_LOGF) && defined(USB_SERIAL) +#if defined(ROCKBOX_HAS_LOGF) && defined(USB_ENABLE_SERIAL) {"USB Serial driver (logf)", toggle_usb_serial }, #endif -#if defined(USB_HID) +#if defined(USB_ENABLE_HID) {"USB HID play/pause", usb_hid_send_play_pause }, {"USB HID stop", usb_hid_send_stop }, {"USB HID prev track", usb_hid_send_scan_previous_track }, diff --git a/firmware/SOURCES b/firmware/SOURCES index 7a00bb903a..a3bc4f2a1f 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES @@ -257,10 +257,18 @@ drivers/audio/mas35xx.c #if !defined(SIMULATOR) #ifdef HAVE_USBSTACK usbstack/usb_core.c +#ifdef USB_ENABLE_STORAGE usbstack/usb_storage.c +#endif +#ifdef USB_ENABLE_SERIAL usbstack/usb_serial.c +#endif +#ifdef USB_ENABLE_CHARGING_ONLY usbstack/usb_charging_only.c +#endif +#ifdef USB_ENABLE_HID usbstack/usb_hid.c +#endif #if CONFIG_USBOTG == USBOTG_ARC target/arm/usb-drv-arc.c #elif CONFIG_USBOTG == USBOTG_ISP1583 diff --git a/firmware/export/config-gigabeat-s.h b/firmware/export/config-gigabeat-s.h index d122edbf74..015e863fc9 100644 --- a/firmware/export/config-gigabeat-s.h +++ b/firmware/export/config-gigabeat-s.h @@ -183,7 +183,6 @@ /* enable these for the usb stack */ #define USE_ROCKBOX_USB #define HAVE_USBSTACK -#define USB_STORAGE /* usb stack and driver settings */ #define USB_PORTSCX_PHY_TYPE PORTSCX_PTS_ULPI #define USB_VENDOR_ID 0x0930 diff --git a/firmware/export/config-iaudio7.h b/firmware/export/config-iaudio7.h index 8886b18633..1e7c42258c 100644 --- a/firmware/export/config-iaudio7.h +++ b/firmware/export/config-iaudio7.h @@ -66,9 +66,6 @@ #define HAVE_USBSTACK #define USB_VENDOR_ID 0x0e21 #define USB_PRODUCT_ID 0x0750 - -#define USB_STORAGE -#define USB_SERIAL #endif /* define this if you have a flash memory storage */ diff --git a/firmware/export/config.h b/firmware/export/config.h index efaf326384..abc159e13c 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h @@ -540,6 +540,7 @@ Lyre prototype 1*/ #endif #endif /* HAVE_USBSTACK */ + #endif /* BOOTLOADER */ #if defined(HAVE_USBSTACK) || (CONFIG_CPU == JZ4732) \ @@ -756,4 +757,46 @@ Lyre prototype 1*/ #include /* MIPS GCC fix? */ #endif +#if defined(HAVE_USBSTACK) +/* Define the implemented USB transport classes */ +#if CONFIG_USBOTG == USBOTG_ISP1583 +#define USB_HAS_BULK +#elif CONFIG_USBOTG == USBOTG_ARC +#define USB_HAS_BULK +#define USB_HAS_INTERRUPT +#elif CONFIG_USBOTG == USBOTG_JZ4740 +#define USB_HAS_BULK +#define USB_HAS_INTERRUPT +#elif defined(CPU_TCC780X) || defined(define CPU_TCC77X) +#define USB_HAS_BULK +#endif /* CONFIG_USBOTG */ + +/* define the class drivers to enable */ +#ifndef BOOTLOADER + +//#define USB_ENABLE_SERIAL +#define USB_ENABLE_STORAGE + +#ifdef USB_HAS_INTERRUPT +#define USB_ENABLE_HID +#else +#define USB_ENABLE_CHARGING_ONLY +#endif + +#else /* BOOTLOADER */ + +/* enable usb storage for targets that do bootloader usb */ +#if (defined(TOSHIBA_GIGABEAT_S) && defined(USE_ROCKBOX_USB) && defined(USB_STORAGE)) || \ + (defined(HAVE_USBSTACK) && (defined(CREATIVE_ZVx) || \ + defined(CPU_TCC77X) || defined(CPU_TCC780X))) || \ + (CONFIG_USBOTG == USBOTG_JZ4740) +#define USB_ENABLE_STORAGE +#endif + +#endif /* BOOTLOADER */ + +#endif /* HAVE_USBSTACK */ + + + #endif /* __CONFIG_H__ */ diff --git a/firmware/export/usb_core.h b/firmware/export/usb_core.h index 9c105fbc7c..c65be5fa3c 100644 --- a/firmware/export/usb_core.h +++ b/firmware/export/usb_core.h @@ -21,16 +21,6 @@ #ifndef USB_CORE_H #define USB_CORE_H -#ifndef BOOTLOADER - -//#define USB_SERIAL -#define USB_STORAGE -#define USB_CHARGING_ONLY -//#define USB_HID -#else /* BOOTLOADER */ -#define USB_CHARGING_ONLY -#endif /* BOOTLOADER */ - #include "usb_ch9.h" #include "usb.h" diff --git a/firmware/logf.c b/firmware/logf.c index 75aaf31e64..a704ad2d67 100644 --- a/firmware/logf.c +++ b/firmware/logf.c @@ -135,7 +135,7 @@ void _logf(const char *format, ...) serial_tx(buf); serial_tx("\r\n"); #endif -#ifdef USB_SERIAL +#ifdef USB_ENABLE_SERIAL usb_serial_send(buf, len); usb_serial_send("\r\n", 2); #endif diff --git a/firmware/usb.c b/firmware/usb.c index f115a92407..f918f19bc4 100644 --- a/firmware/usb.c +++ b/firmware/usb.c @@ -47,7 +47,7 @@ /* Conditions under which we want the entire driver */ #if !defined(BOOTLOADER) || (CONFIG_CPU == SH7034) || \ - (defined(TOSHIBA_GIGABEAT_S) && defined(USE_ROCKBOX_USB) && defined(USB_STORAGE)) || \ + (defined(TOSHIBA_GIGABEAT_S) && defined(USE_ROCKBOX_USB) && defined(USB_ENABLE_STORAGE)) || \ (defined(HAVE_USBSTACK) && (defined(CREATIVE_ZVx) || \ defined(CPU_TCC77X) || defined(CPU_TCC780X))) || \ (CONFIG_USBOTG == USBOTG_JZ4740) @@ -270,13 +270,19 @@ static void usb_thread(void) /* Only charging is desired */ usb_state = USB_POWERED; #ifdef HAVE_USBSTACK -#ifdef USB_STORAGE +#ifdef USB_ENABLE_STORAGE usb_core_enable_driver(USB_DRIVER_MASS_STORAGE, false); #endif -#ifdef USB_HID + +#ifdef USB_ENABLE_HID +#ifdef USB_ENABLE_CHARGING_ONLY usb_core_enable_driver(USB_DRIVER_HID, false); -#endif -#ifdef USB_CHARGING_ONLY +#else + usb_core_enable_driver(USB_DRIVER_HID, true); +#endif /* USB_ENABLE_CHARGING_ONLY */ +#endif /* USB_ENABLE_HID */ + +#ifdef USB_ENABLE_CHARGING_ONLY usb_core_enable_driver(USB_DRIVER_CHARGING_ONLY, true); #endif usb_attach(); @@ -291,13 +297,13 @@ static void usb_thread(void) * USB_CONNECTED. */ usb_state = USB_POWERED; #endif -#ifdef USB_STORAGE +#ifdef USB_ENABLE_STORAGE usb_core_enable_driver(USB_DRIVER_MASS_STORAGE, true); #endif -#ifdef USB_HID +#ifdef USB_ENABLE_HID usb_core_enable_driver(USB_DRIVER_HID, true); #endif -#ifdef USB_CHARGING_ONLY +#ifdef USB_ENABLE_CHARGING_ONLY usb_core_enable_driver(USB_DRIVER_CHARGING_ONLY, false); #endif diff --git a/firmware/usbstack/usb_charging_only.c b/firmware/usbstack/usb_charging_only.c index fc6139c1ae..8dd9fdf742 100644 --- a/firmware/usbstack/usb_charging_only.c +++ b/firmware/usbstack/usb_charging_only.c @@ -29,8 +29,6 @@ //#define LOGF_ENABLE #include "logf.h" -#ifdef USB_CHARGING_ONLY - /* charging_only interface */ static struct usb_interface_descriptor __attribute__((aligned(2))) interface_descriptor = @@ -70,5 +68,3 @@ int usb_charging_only_get_config_descriptor(unsigned char *dest,int max_packet_s return (dest-orig_dest); } - -#endif /*USB_CHARGING_ONLY*/ diff --git a/firmware/usbstack/usb_core.c b/firmware/usbstack/usb_core.c index 81333fe0d2..c4450af964 100644 --- a/firmware/usbstack/usb_core.c +++ b/firmware/usbstack/usb_core.c @@ -31,19 +31,19 @@ #include "usb_core.h" #include "usb_class_driver.h" -#if defined(USB_STORAGE) +#if defined(USB_ENABLE_STORAGE) #include "usb_storage.h" #endif -#if defined(USB_SERIAL) +#if defined(USB_ENABLE_SERIAL) #include "usb_serial.h" #endif -#if defined(USB_CHARGING_ONLY) +#if defined(USB_ENABLE_CHARGING_ONLY) #include "usb_charging_only.h" #endif -#if defined(USB_HID) +#if defined(USB_ENABLE_HID) #include "usb_hid.h" #endif @@ -182,7 +182,7 @@ static struct static struct usb_class_driver drivers[USB_NUM_DRIVERS] = { -#ifdef USB_STORAGE +#ifdef USB_ENABLE_STORAGE [USB_DRIVER_MASS_STORAGE] = { .enabled = false, .needs_exclusive_storage = true, @@ -201,7 +201,7 @@ static struct usb_class_driver drivers[USB_NUM_DRIVERS] = #endif }, #endif -#ifdef USB_SERIAL +#ifdef USB_ENABLE_SERIAL [USB_DRIVER_SERIAL] = { .enabled = false, .needs_exclusive_storage = false, @@ -220,7 +220,7 @@ static struct usb_class_driver drivers[USB_NUM_DRIVERS] = #endif }, #endif -#ifdef USB_CHARGING_ONLY +#ifdef USB_ENABLE_CHARGING_ONLY [USB_DRIVER_CHARGING_ONLY] = { .enabled = false, .needs_exclusive_storage = false, @@ -239,7 +239,7 @@ static struct usb_class_driver drivers[USB_NUM_DRIVERS] = #endif }, #endif -#ifdef USB_HID +#ifdef USB_ENABLE_HID [USB_DRIVER_HID] = { .enabled = false, .needs_exclusive_storage = false, diff --git a/firmware/usbstack/usb_hid.c b/firmware/usbstack/usb_hid.c index 0c35da2acb..31554eed48 100644 --- a/firmware/usbstack/usb_hid.c +++ b/firmware/usbstack/usb_hid.c @@ -28,8 +28,6 @@ //#define LOGF_ENABLE #include "logf.h" -#ifdef USB_HID - #define CONCAT(low, high) ((high << 8) | low) #define PACK_VAL1(dest, val) *(dest)++ = (val) & 0xff #define PACK_VAL2(dest, val) PACK_VAL1((dest), (val)); \ @@ -392,5 +390,3 @@ void usb_hid_send_consumer_usage(consumer_usage_page_t id) usb_hid_try_send_drv(); } - -#endif /*USB_HID*/ diff --git a/firmware/usbstack/usb_serial.c b/firmware/usbstack/usb_serial.c index 246938a1ef..6c654ad898 100644 --- a/firmware/usbstack/usb_serial.c +++ b/firmware/usbstack/usb_serial.c @@ -28,8 +28,6 @@ //#define LOGF_ENABLE #include "logf.h" -#ifdef USB_SERIAL - /* serial interface */ static struct usb_interface_descriptor __attribute__((aligned(2))) interface_descriptor = @@ -240,5 +238,3 @@ void usb_serial_transfer_complete(int ep,int dir, int status, int length) break; } } - -#endif /*USB_SERIAL*/ diff --git a/firmware/usbstack/usb_storage.c b/firmware/usbstack/usb_storage.c index b498311014..63ff4f059b 100644 --- a/firmware/usbstack/usb_storage.c +++ b/firmware/usbstack/usb_storage.c @@ -33,8 +33,6 @@ #include "usb_storage.h" -#ifdef USB_STORAGE - /* Enable the following define to export only the SD card slot. This * is useful for USBCV MSC tests, as those are destructive. * This won't work right if the device doesn't have a card slot. @@ -1158,5 +1156,3 @@ static void fill_inquiry(IF_MV_NONVOID(int lun)) tb.inquiry->DeviceTypeModifier = DEVICE_REMOVABLE; #endif } - -#endif /* USB_STORAGE */ -- cgit v1.2.3