summaryrefslogtreecommitdiff
path: root/firmware/usbstack
diff options
context:
space:
mode:
authorFrank Gevaerts <frank@gevaerts.be>2011-09-09 16:15:35 +0000
committerFrank Gevaerts <frank@gevaerts.be>2011-09-09 16:15:35 +0000
commit544a52d9eb274c8989df2268324dcbf8f18795c6 (patch)
treeab152284efafceada3b5554a16e037d8003151f2 /firmware/usbstack
parent49b64f13e548f5622d2932e3dd5c77b65c1d9fdd (diff)
downloadrockbox-544a52d9eb274c8989df2268324dcbf8f18795c6.tar.gz
rockbox-544a52d9eb274c8989df2268324dcbf8f18795c6.zip
Add "USB Hide Internal Drive" option for multidrive devices with software usb.
This option allows accessing the card slot from "dumb" USB hosts like some car audio systems that do not handle multi-LUN devices. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30489 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/usbstack')
-rw-r--r--firmware/usbstack/usb_storage.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/firmware/usbstack/usb_storage.c b/firmware/usbstack/usb_storage.c
index 6d407cccc5..8203ad4177 100644
--- a/firmware/usbstack/usb_storage.c
+++ b/firmware/usbstack/usb_storage.c
@@ -36,12 +36,6 @@
36/* For sector filter macro definitions */ 36/* For sector filter macro definitions */
37#include "usb-target.h" 37#include "usb-target.h"
38 38
39/* Enable the following define to export only the SD card slot. This
40 * is useful for USBCV MSC tests, as those are destructive.
41 * This won't work right if the device doesn't have a card slot.
42 */
43//#define HIDE_FIRST_DRIVE
44
45#ifdef USB_USE_RAMDISK 39#ifdef USB_USE_RAMDISK
46#define RAMDISK_SIZE 2048 40#define RAMDISK_SIZE 2048
47#endif 41#endif
@@ -314,6 +308,10 @@ static bool locked[NUM_DRIVES];
314static int usb_interface; 308static int usb_interface;
315static int ep_in, ep_out; 309static int ep_in, ep_out;
316 310
311#if defined(HAVE_MULTIDRIVE)
312static bool skip_first = 0;
313#endif
314
317#ifdef USB_USE_RAMDISK 315#ifdef USB_USE_RAMDISK
318static unsigned char* ramdisk_buffer; 316static unsigned char* ramdisk_buffer;
319#endif 317#endif
@@ -400,6 +398,13 @@ void usb_storage_notify_hotswap(int volume,bool inserted)
400} 398}
401#endif 399#endif
402 400
401#ifdef HAVE_MULTIDRIVE
402void usb_set_skip_first_drive(bool skip)
403{
404 skip_first = skip;
405}
406#endif
407
403/* called by usb_core_init() */ 408/* called by usb_core_init() */
404void usb_storage_init(void) 409void usb_storage_init(void)
405{ 410{
@@ -690,8 +695,8 @@ bool usb_storage_control_request(struct usb_ctrlrequest* req, unsigned char* des
690 switch (req->bRequest) { 695 switch (req->bRequest) {
691 case USB_BULK_GET_MAX_LUN: { 696 case USB_BULK_GET_MAX_LUN: {
692 *tb.max_lun = storage_num_drives() - 1; 697 *tb.max_lun = storage_num_drives() - 1;
693#ifdef HIDE_FIRST_DRIVE 698#if defined(HAVE_MULTIDRIVE)
694 *tb.max_lun --; 699 if(skip_first) (*tb.max_lun) --;
695#endif 700#endif
696 logf("ums: getmaxlun"); 701 logf("ums: getmaxlun");
697 usb_drv_recv(EP_CONTROL, NULL, 0); /* ack */ 702 usb_drv_recv(EP_CONTROL, NULL, 0); /* ack */
@@ -777,8 +782,8 @@ static void handle_scsi(struct command_block_wrapper* cbw)
777 * bogus data */ 782 * bogus data */
778 cbw->signature=0; 783 cbw->signature=0;
779 784
780#ifdef HIDE_FIRST_DRIVE 785#if defined(HAVE_MULTIDRIVE)
781 lun++; 786 if(skip_first) lun++;
782#endif 787#endif
783 788
784 storage_get_info(lun,&info); 789 storage_get_info(lun,&info);