1
0
Fork 0
forked from len0rd/rockbox

Prevent the click of death when connecting an ipod to usb.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11622 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Miika Pekkarinen 2006-11-29 12:17:26 +00:00
parent 2b545c3104
commit 077ed4925e
3 changed files with 13 additions and 1 deletions

View file

@ -1215,6 +1215,15 @@ void ata_sleep(void)
queue_post(&ata_queue, Q_SLEEP, NULL); queue_post(&ata_queue, Q_SLEEP, NULL);
} }
void ata_sleepnow(void)
{
if (!spinup && !sleeping && !ata_mtx.locked)
{
call_ata_idle_notifys(false);
ata_perform_sleep();
}
}
void ata_spin(void) void ata_spin(void)
{ {
last_user_activity = current_tick; last_user_activity = current_tick;
@ -1288,7 +1297,6 @@ static void ata_thread(void)
call_ata_idle_notifys(false); call_ata_idle_notifys(false);
last_disk_activity = current_tick - sleep_timeout + (HZ/2); last_disk_activity = current_tick - sleep_timeout + (HZ/2);
break; break;
} }
} }
} }

View file

@ -40,6 +40,7 @@ extern void ata_enable(bool on);
extern void ata_spindown(int seconds); extern void ata_spindown(int seconds);
extern void ata_poweroff(bool enable); extern void ata_poweroff(bool enable);
extern void ata_sleep(void); extern void ata_sleep(void);
extern void ata_sleepnow(void);
extern bool ata_disk_is_active(void); extern bool ata_disk_is_active(void);
extern int ata_hard_reset(void); extern int ata_hard_reset(void);
extern int ata_soft_reset(void); extern int ata_soft_reset(void);

View file

@ -94,6 +94,9 @@ void usb_enable(bool on)
#elif defined(IPOD_NANO) || defined(IPOD_VIDEO) || defined(IPOD_MINI2G) #elif defined(IPOD_NANO) || defined(IPOD_VIDEO) || defined(IPOD_MINI2G)
unsigned char* storage_ptr = (unsigned char *)0x4001FF00; unsigned char* storage_ptr = (unsigned char *)0x4001FF00;
#endif #endif
ata_sleepnow(); /* Immediately spindown the disk. */
sleep(HZ*2);
memcpy(storage_ptr, "diskmode\0\0hotstuff\0\0\1", 21); memcpy(storage_ptr, "diskmode\0\0hotstuff\0\0\1", 21);
DEV_RS |= 4; /* Reboot */ DEV_RS |= 4; /* Reboot */
} }