From 871db6f5d997e9fffe4fe951e708e42ac77cc181 Mon Sep 17 00:00:00 2001 From: Frank Gevaerts Date: Sun, 8 Mar 2009 18:45:19 +0000 Subject: Allow the user to leave MSC mode by pressing the USB POWER button (the one that's used to go to usb power mode on plugin) when the host OS hasn't locked the device. This only works for devices that expose a removable device, so for now the gigabeat S is out of luck. (slightly modified from FS#9993) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20244 a1c6a512-1295-4272-9138-f99709370657 --- firmware/export/usb.h | 1 + firmware/usbstack/usb_storage.c | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) (limited to 'firmware') diff --git a/firmware/export/usb.h b/firmware/export/usb.h index ecbec3a914..be36ee0b31 100644 --- a/firmware/export/usb.h +++ b/firmware/export/usb.h @@ -131,6 +131,7 @@ bool usb_charging_enabled(void); void usb_signal_transfer_completion(struct usb_transfer_completion_event_data* event_data); bool usb_driver_enabled(int driver); bool usb_exclusive_storage(void); /* storage is available for usb */ +void usb_storage_try_release_storage(void); #endif int usb_release_exclusive_storage(void); diff --git a/firmware/usbstack/usb_storage.c b/firmware/usbstack/usb_storage.c index 9b0625e4e2..aa8cb29da3 100644 --- a/firmware/usbstack/usb_storage.c +++ b/firmware/usbstack/usb_storage.c @@ -260,6 +260,7 @@ static void receive_block_data(void *data,int size); static void fill_inquiry(IF_MV_NONVOID(int lun)); static void send_and_read_next(void); static bool ejected[NUM_VOLUMES]; +static bool locked[NUM_VOLUMES]; static int usb_interface; static int ep_in, ep_out; @@ -304,14 +305,14 @@ static bool check_disk_present(IF_MV_NONVOID(int volume)) #endif } -static void try_release_ata(void) +void usb_storage_try_release_storage(void) { /* Check if there is a connected drive left. If not, release excusive access */ bool canrelease=true; int i; for(i=0;icommand_block[4] & 0x03) == 0) { + locked[lun]=false; queue_broadcast(SYS_USB_LUN_LOCKED, (lun<<16)+0); } else { + locked[lun]=true; queue_broadcast(SYS_USB_LUN_LOCKED, (lun<<16)+1); } send_csw(UMS_STATUS_GOOD); -- cgit v1.2.3