summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Gevaerts <frank@gevaerts.be>2009-05-23 14:30:20 +0000
committerFrank Gevaerts <frank@gevaerts.be>2009-05-23 14:30:20 +0000
commitc61a75173b2e81ea3ae3aa1d3cdf84d15e4304c3 (patch)
treef9056ad1a886d1741b009a6d026b689e18040a17
parentbca3d3dca44bbe111d8e8595932d2a9491679dab (diff)
downloadrockbox-c61a75173b2e81ea3ae3aa1d3cdf84d15e4304c3.tar.gz
rockbox-c61a75173b2e81ea3ae3aa1d3cdf84d15e4304c3.zip
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
-rw-r--r--apps/debug_menu.c10
-rw-r--r--firmware/SOURCES8
-rw-r--r--firmware/export/config-gigabeat-s.h1
-rw-r--r--firmware/export/config-iaudio7.h3
-rw-r--r--firmware/export/config.h43
-rw-r--r--firmware/export/usb_core.h10
-rw-r--r--firmware/logf.c2
-rw-r--r--firmware/usb.c22
-rw-r--r--firmware/usbstack/usb_charging_only.c4
-rw-r--r--firmware/usbstack/usb_core.c16
-rw-r--r--firmware/usbstack/usb_hid.c4
-rw-r--r--firmware/usbstack/usb_serial.c4
-rw-r--r--firmware/usbstack/usb_storage.c4
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 @@
114 114
115#ifdef HAVE_USBSTACK 115#ifdef HAVE_USBSTACK
116#include "usb_core.h" 116#include "usb_core.h"
117#ifdef USB_HID 117#ifdef USB_ENABLE_HID
118#include "usbstack/usb_hid.h" 118#include "usbstack/usb_hid.h"
119#endif 119#endif
120#endif 120#endif
@@ -2588,7 +2588,7 @@ static bool dbg_scrollwheel(void)
2588 2588
2589#if defined (HAVE_USBSTACK) 2589#if defined (HAVE_USBSTACK)
2590 2590
2591#if defined(ROCKBOX_HAS_LOGF) && defined(USB_SERIAL) 2591#if defined(ROCKBOX_HAS_LOGF) && defined(USB_ENABLE_SERIAL)
2592static bool toggle_usb_core_driver(int driver, char *msg) 2592static bool toggle_usb_core_driver(int driver, char *msg)
2593{ 2593{
2594 bool enabled = !usb_core_driver_enabled(driver); 2594 bool enabled = !usb_core_driver_enabled(driver);
@@ -2605,7 +2605,7 @@ static bool toggle_usb_serial(void)
2605} 2605}
2606#endif 2606#endif
2607 2607
2608#ifdef USB_HID 2608#ifdef USB_ENABLE_HID
2609static bool hid_send_cmd(consumer_usage_page_t cmd, char *msg) 2609static bool hid_send_cmd(consumer_usage_page_t cmd, char *msg)
2610{ 2610{
2611 (void)msg; 2611 (void)msg;
@@ -2786,10 +2786,10 @@ static const struct the_menu_item menuitems[] = {
2786 {"logfdump", logfdump }, 2786 {"logfdump", logfdump },
2787#endif 2787#endif
2788#if defined(HAVE_USBSTACK) 2788#if defined(HAVE_USBSTACK)
2789#if defined(ROCKBOX_HAS_LOGF) && defined(USB_SERIAL) 2789#if defined(ROCKBOX_HAS_LOGF) && defined(USB_ENABLE_SERIAL)
2790 {"USB Serial driver (logf)", toggle_usb_serial }, 2790 {"USB Serial driver (logf)", toggle_usb_serial },
2791#endif 2791#endif
2792#if defined(USB_HID) 2792#if defined(USB_ENABLE_HID)
2793 {"USB HID play/pause", usb_hid_send_play_pause }, 2793 {"USB HID play/pause", usb_hid_send_play_pause },
2794 {"USB HID stop", usb_hid_send_stop }, 2794 {"USB HID stop", usb_hid_send_stop },
2795 {"USB HID prev track", usb_hid_send_scan_previous_track }, 2795 {"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
257#if !defined(SIMULATOR) 257#if !defined(SIMULATOR)
258#ifdef HAVE_USBSTACK 258#ifdef HAVE_USBSTACK
259usbstack/usb_core.c 259usbstack/usb_core.c
260#ifdef USB_ENABLE_STORAGE
260usbstack/usb_storage.c 261usbstack/usb_storage.c
262#endif
263#ifdef USB_ENABLE_SERIAL
261usbstack/usb_serial.c 264usbstack/usb_serial.c
265#endif
266#ifdef USB_ENABLE_CHARGING_ONLY
262usbstack/usb_charging_only.c 267usbstack/usb_charging_only.c
268#endif
269#ifdef USB_ENABLE_HID
263usbstack/usb_hid.c 270usbstack/usb_hid.c
271#endif
264#if CONFIG_USBOTG == USBOTG_ARC 272#if CONFIG_USBOTG == USBOTG_ARC
265target/arm/usb-drv-arc.c 273target/arm/usb-drv-arc.c
266#elif CONFIG_USBOTG == USBOTG_ISP1583 274#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 @@
183/* enable these for the usb stack */ 183/* enable these for the usb stack */
184#define USE_ROCKBOX_USB 184#define USE_ROCKBOX_USB
185#define HAVE_USBSTACK 185#define HAVE_USBSTACK
186#define USB_STORAGE
187/* usb stack and driver settings */ 186/* usb stack and driver settings */
188#define USB_PORTSCX_PHY_TYPE PORTSCX_PTS_ULPI 187#define USB_PORTSCX_PHY_TYPE PORTSCX_PTS_ULPI
189#define USB_VENDOR_ID 0x0930 188#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 @@
66#define HAVE_USBSTACK 66#define HAVE_USBSTACK
67#define USB_VENDOR_ID 0x0e21 67#define USB_VENDOR_ID 0x0e21
68#define USB_PRODUCT_ID 0x0750 68#define USB_PRODUCT_ID 0x0750
69
70#define USB_STORAGE
71#define USB_SERIAL
72#endif 69#endif
73 70
74/* define this if you have a flash memory storage */ 71/* 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*/
540#endif 540#endif
541#endif /* HAVE_USBSTACK */ 541#endif /* HAVE_USBSTACK */
542 542
543
543#endif /* BOOTLOADER */ 544#endif /* BOOTLOADER */
544 545
545#if defined(HAVE_USBSTACK) || (CONFIG_CPU == JZ4732) \ 546#if defined(HAVE_USBSTACK) || (CONFIG_CPU == JZ4732) \
@@ -756,4 +757,46 @@ Lyre prototype 1*/
756#include <stdbool.h> /* MIPS GCC fix? */ 757#include <stdbool.h> /* MIPS GCC fix? */
757#endif 758#endif
758 759
760#if defined(HAVE_USBSTACK)
761/* Define the implemented USB transport classes */
762#if CONFIG_USBOTG == USBOTG_ISP1583
763#define USB_HAS_BULK
764#elif CONFIG_USBOTG == USBOTG_ARC
765#define USB_HAS_BULK
766#define USB_HAS_INTERRUPT
767#elif CONFIG_USBOTG == USBOTG_JZ4740
768#define USB_HAS_BULK
769#define USB_HAS_INTERRUPT
770#elif defined(CPU_TCC780X) || defined(define CPU_TCC77X)
771#define USB_HAS_BULK
772#endif /* CONFIG_USBOTG */
773
774/* define the class drivers to enable */
775#ifndef BOOTLOADER
776
777//#define USB_ENABLE_SERIAL
778#define USB_ENABLE_STORAGE
779
780#ifdef USB_HAS_INTERRUPT
781#define USB_ENABLE_HID
782#else
783#define USB_ENABLE_CHARGING_ONLY
784#endif
785
786#else /* BOOTLOADER */
787
788/* enable usb storage for targets that do bootloader usb */
789#if (defined(TOSHIBA_GIGABEAT_S) && defined(USE_ROCKBOX_USB) && defined(USB_STORAGE)) || \
790 (defined(HAVE_USBSTACK) && (defined(CREATIVE_ZVx) || \
791 defined(CPU_TCC77X) || defined(CPU_TCC780X))) || \
792 (CONFIG_USBOTG == USBOTG_JZ4740)
793#define USB_ENABLE_STORAGE
794#endif
795
796#endif /* BOOTLOADER */
797
798#endif /* HAVE_USBSTACK */
799
800
801
759#endif /* __CONFIG_H__ */ 802#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 @@
21#ifndef USB_CORE_H 21#ifndef USB_CORE_H
22#define USB_CORE_H 22#define USB_CORE_H
23 23
24#ifndef BOOTLOADER
25
26//#define USB_SERIAL
27#define USB_STORAGE
28#define USB_CHARGING_ONLY
29//#define USB_HID
30#else /* BOOTLOADER */
31#define USB_CHARGING_ONLY
32#endif /* BOOTLOADER */
33
34#include "usb_ch9.h" 24#include "usb_ch9.h"
35#include "usb.h" 25#include "usb.h"
36 26
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, ...)
135 serial_tx(buf); 135 serial_tx(buf);
136 serial_tx("\r\n"); 136 serial_tx("\r\n");
137#endif 137#endif
138#ifdef USB_SERIAL 138#ifdef USB_ENABLE_SERIAL
139 usb_serial_send(buf, len); 139 usb_serial_send(buf, len);
140 usb_serial_send("\r\n", 2); 140 usb_serial_send("\r\n", 2);
141#endif 141#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 @@
47 47
48/* Conditions under which we want the entire driver */ 48/* Conditions under which we want the entire driver */
49#if !defined(BOOTLOADER) || (CONFIG_CPU == SH7034) || \ 49#if !defined(BOOTLOADER) || (CONFIG_CPU == SH7034) || \
50 (defined(TOSHIBA_GIGABEAT_S) && defined(USE_ROCKBOX_USB) && defined(USB_STORAGE)) || \ 50 (defined(TOSHIBA_GIGABEAT_S) && defined(USE_ROCKBOX_USB) && defined(USB_ENABLE_STORAGE)) || \
51 (defined(HAVE_USBSTACK) && (defined(CREATIVE_ZVx) || \ 51 (defined(HAVE_USBSTACK) && (defined(CREATIVE_ZVx) || \
52 defined(CPU_TCC77X) || defined(CPU_TCC780X))) || \ 52 defined(CPU_TCC77X) || defined(CPU_TCC780X))) || \
53 (CONFIG_USBOTG == USBOTG_JZ4740) 53 (CONFIG_USBOTG == USBOTG_JZ4740)
@@ -270,13 +270,19 @@ static void usb_thread(void)
270 /* Only charging is desired */ 270 /* Only charging is desired */
271 usb_state = USB_POWERED; 271 usb_state = USB_POWERED;
272#ifdef HAVE_USBSTACK 272#ifdef HAVE_USBSTACK
273#ifdef USB_STORAGE 273#ifdef USB_ENABLE_STORAGE
274 usb_core_enable_driver(USB_DRIVER_MASS_STORAGE, false); 274 usb_core_enable_driver(USB_DRIVER_MASS_STORAGE, false);
275#endif 275#endif
276#ifdef USB_HID 276
277#ifdef USB_ENABLE_HID
278#ifdef USB_ENABLE_CHARGING_ONLY
277 usb_core_enable_driver(USB_DRIVER_HID, false); 279 usb_core_enable_driver(USB_DRIVER_HID, false);
278#endif 280#else
279#ifdef USB_CHARGING_ONLY 281 usb_core_enable_driver(USB_DRIVER_HID, true);
282#endif /* USB_ENABLE_CHARGING_ONLY */
283#endif /* USB_ENABLE_HID */
284
285#ifdef USB_ENABLE_CHARGING_ONLY
280 usb_core_enable_driver(USB_DRIVER_CHARGING_ONLY, true); 286 usb_core_enable_driver(USB_DRIVER_CHARGING_ONLY, true);
281#endif 287#endif
282 usb_attach(); 288 usb_attach();
@@ -291,13 +297,13 @@ static void usb_thread(void)
291 * USB_CONNECTED. */ 297 * USB_CONNECTED. */
292 usb_state = USB_POWERED; 298 usb_state = USB_POWERED;
293#endif 299#endif
294#ifdef USB_STORAGE 300#ifdef USB_ENABLE_STORAGE
295 usb_core_enable_driver(USB_DRIVER_MASS_STORAGE, true); 301 usb_core_enable_driver(USB_DRIVER_MASS_STORAGE, true);
296#endif 302#endif
297#ifdef USB_HID 303#ifdef USB_ENABLE_HID
298 usb_core_enable_driver(USB_DRIVER_HID, true); 304 usb_core_enable_driver(USB_DRIVER_HID, true);
299#endif 305#endif
300#ifdef USB_CHARGING_ONLY 306#ifdef USB_ENABLE_CHARGING_ONLY
301 usb_core_enable_driver(USB_DRIVER_CHARGING_ONLY, false); 307 usb_core_enable_driver(USB_DRIVER_CHARGING_ONLY, false);
302#endif 308#endif
303 309
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 @@
29//#define LOGF_ENABLE 29//#define LOGF_ENABLE
30#include "logf.h" 30#include "logf.h"
31 31
32#ifdef USB_CHARGING_ONLY
33
34/* charging_only interface */ 32/* charging_only interface */
35static struct usb_interface_descriptor __attribute__((aligned(2))) 33static struct usb_interface_descriptor __attribute__((aligned(2)))
36 interface_descriptor = 34 interface_descriptor =
@@ -70,5 +68,3 @@ int usb_charging_only_get_config_descriptor(unsigned char *dest,int max_packet_s
70 68
71 return (dest-orig_dest); 69 return (dest-orig_dest);
72} 70}
73
74#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 @@
31#include "usb_core.h" 31#include "usb_core.h"
32#include "usb_class_driver.h" 32#include "usb_class_driver.h"
33 33
34#if defined(USB_STORAGE) 34#if defined(USB_ENABLE_STORAGE)
35#include "usb_storage.h" 35#include "usb_storage.h"
36#endif 36#endif
37 37
38#if defined(USB_SERIAL) 38#if defined(USB_ENABLE_SERIAL)
39#include "usb_serial.h" 39#include "usb_serial.h"
40#endif 40#endif
41 41
42#if defined(USB_CHARGING_ONLY) 42#if defined(USB_ENABLE_CHARGING_ONLY)
43#include "usb_charging_only.h" 43#include "usb_charging_only.h"
44#endif 44#endif
45 45
46#if defined(USB_HID) 46#if defined(USB_ENABLE_HID)
47#include "usb_hid.h" 47#include "usb_hid.h"
48#endif 48#endif
49 49
@@ -182,7 +182,7 @@ static struct
182 182
183static struct usb_class_driver drivers[USB_NUM_DRIVERS] = 183static struct usb_class_driver drivers[USB_NUM_DRIVERS] =
184{ 184{
185#ifdef USB_STORAGE 185#ifdef USB_ENABLE_STORAGE
186 [USB_DRIVER_MASS_STORAGE] = { 186 [USB_DRIVER_MASS_STORAGE] = {
187 .enabled = false, 187 .enabled = false,
188 .needs_exclusive_storage = true, 188 .needs_exclusive_storage = true,
@@ -201,7 +201,7 @@ static struct usb_class_driver drivers[USB_NUM_DRIVERS] =
201#endif 201#endif
202 }, 202 },
203#endif 203#endif
204#ifdef USB_SERIAL 204#ifdef USB_ENABLE_SERIAL
205 [USB_DRIVER_SERIAL] = { 205 [USB_DRIVER_SERIAL] = {
206 .enabled = false, 206 .enabled = false,
207 .needs_exclusive_storage = false, 207 .needs_exclusive_storage = false,
@@ -220,7 +220,7 @@ static struct usb_class_driver drivers[USB_NUM_DRIVERS] =
220#endif 220#endif
221 }, 221 },
222#endif 222#endif
223#ifdef USB_CHARGING_ONLY 223#ifdef USB_ENABLE_CHARGING_ONLY
224 [USB_DRIVER_CHARGING_ONLY] = { 224 [USB_DRIVER_CHARGING_ONLY] = {
225 .enabled = false, 225 .enabled = false,
226 .needs_exclusive_storage = false, 226 .needs_exclusive_storage = false,
@@ -239,7 +239,7 @@ static struct usb_class_driver drivers[USB_NUM_DRIVERS] =
239#endif 239#endif
240 }, 240 },
241#endif 241#endif
242#ifdef USB_HID 242#ifdef USB_ENABLE_HID
243 [USB_DRIVER_HID] = { 243 [USB_DRIVER_HID] = {
244 .enabled = false, 244 .enabled = false,
245 .needs_exclusive_storage = false, 245 .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 @@
28//#define LOGF_ENABLE 28//#define LOGF_ENABLE
29#include "logf.h" 29#include "logf.h"
30 30
31#ifdef USB_HID
32
33#define CONCAT(low, high) ((high << 8) | low) 31#define CONCAT(low, high) ((high << 8) | low)
34#define PACK_VAL1(dest, val) *(dest)++ = (val) & 0xff 32#define PACK_VAL1(dest, val) *(dest)++ = (val) & 0xff
35#define PACK_VAL2(dest, val) PACK_VAL1((dest), (val)); \ 33#define PACK_VAL2(dest, val) PACK_VAL1((dest), (val)); \
@@ -392,5 +390,3 @@ void usb_hid_send_consumer_usage(consumer_usage_page_t id)
392 390
393 usb_hid_try_send_drv(); 391 usb_hid_try_send_drv();
394} 392}
395
396#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 @@
28//#define LOGF_ENABLE 28//#define LOGF_ENABLE
29#include "logf.h" 29#include "logf.h"
30 30
31#ifdef USB_SERIAL
32
33/* serial interface */ 31/* serial interface */
34static struct usb_interface_descriptor __attribute__((aligned(2))) 32static struct usb_interface_descriptor __attribute__((aligned(2)))
35 interface_descriptor = 33 interface_descriptor =
@@ -240,5 +238,3 @@ void usb_serial_transfer_complete(int ep,int dir, int status, int length)
240 break; 238 break;
241 } 239 }
242} 240}
243
244#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 @@
33#include "usb_storage.h" 33#include "usb_storage.h"
34 34
35 35
36#ifdef USB_STORAGE
37
38/* Enable the following define to export only the SD card slot. This 36/* Enable the following define to export only the SD card slot. This
39 * is useful for USBCV MSC tests, as those are destructive. 37 * is useful for USBCV MSC tests, as those are destructive.
40 * This won't work right if the device doesn't have a card slot. 38 * 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))
1158 tb.inquiry->DeviceTypeModifier = DEVICE_REMOVABLE; 1156 tb.inquiry->DeviceTypeModifier = DEVICE_REMOVABLE;
1159#endif 1157#endif
1160} 1158}
1161
1162#endif /* USB_STORAGE */