Index: apps/screens.c =================================================================== --- apps/screens.c (revision 20737) +++ apps/screens.c (working copy) @@ -59,6 +59,7 @@ #include "yesno.h" #include "backdrop.h" #include "viewport.h" +#include "storage.h" #ifdef HAVE_LCD_BITMAP #include "bitmaps/usblogo.h" @@ -95,27 +96,53 @@ static int handle_usb_events(struct event_queue *q) { struct queue_event ev; +#if defined(HAVE_USBSTACK) && defined(USE_ROCKBOX_USB) + int read_sectors_per_period[NUM_VOLUMES]={0}; + int write_sectors_per_period[NUM_VOLUMES]={0}; + int locked[NUM_VOLUMES]={0}; + int prevlocked[NUM_VOLUMES]={0}; +#endif int next_update=0; /* Don't return until we get SYS_USB_DISCONNECTED or SYS_TIMEOUT */ while(1) { - queue_wait_w_tmo(q, &ev, HZ/4); + queue_wait_w_tmo(q, &ev, HZ); switch(ev.id) { case SYS_USB_DISCONNECTED: usb_acknowledge(SYS_USB_DISCONNECTED_ACK); return 0; +#if defined(HAVE_USBSTACK) && defined(USE_ROCKBOX_USB) + case SYS_USB_LUN_LOCKED: + { + int lun,value; + lun=ev.data>>16; + value=ev.data&0x0000ffff; + locked[lun]=value; + prevlocked[lun]=!value; + break; + } + case SYS_USB_READ_DATA: + { + int lun,value; + lun=ev.data>>16; + value=ev.data&0x0000ffff; + read_sectors_per_period[lun]+=value; + break; + } + case SYS_USB_WRITE_DATA: + { + int lun,value; + lun=ev.data>>16; + value=ev.data&0x0000ffff; + write_sectors_per_period[lun]+=value; + break; + } +#endif case SYS_TIMEOUT: break; } -#if defined(HAVE_USBSTACK) && defined(USE_ROCKBOX_USB) \ - && defined(HAVE_USB_POWER) - if((button_status() & ~USBPOWER_BTN_IGNORE) == USBPOWER_BUTTON) - { - usb_storage_try_release_storage(); - } -#endif if(TIME_AFTER(current_tick,next_update)) { if(usb_inserted()) { @@ -124,7 +151,38 @@ #endif /* STORAGE_MMC */ gui_syncstatusbar_draw(&statusbars, false); } - next_update=current_tick+HZ/2; +#if defined(HAVE_USBSTACK) && defined(USE_ROCKBOX_USB) + int lun; + for(lun=0;lun