From 297c29cba60e34ed01fb72974dcb562e58df322b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mo=C5=84?= Date: Mon, 28 Nov 2011 21:12:54 +0000 Subject: [PATCH] dm320: call storage idle notifys on in sdmmc thread git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31086 a1c6a512-1295-4272-9138-f99709370657 --- .../sansa-connect/powermgmt-sansaconnect.c | 4 +++- firmware/target/arm/tms320dm320/sdmmc-dm320.c | 14 +++++++++++++- firmware/target/arm/tms320dm320/system-dm320.c | 4 ++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/firmware/target/arm/tms320dm320/sansa-connect/powermgmt-sansaconnect.c b/firmware/target/arm/tms320dm320/sansa-connect/powermgmt-sansaconnect.c index 9085679b32..4b22b85c09 100644 --- a/firmware/target/arm/tms320dm320/sansa-connect/powermgmt-sansaconnect.c +++ b/firmware/target/arm/tms320dm320/sansa-connect/powermgmt-sansaconnect.c @@ -28,11 +28,13 @@ static unsigned int current_battery_level = 100; +/* This specifies the battery level that writes are still safe */ const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = { - 0 + 1 }; +/* Below this the player cannot be considered to operate reliably */ const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = { 0 diff --git a/firmware/target/arm/tms320dm320/sdmmc-dm320.c b/firmware/target/arm/tms320dm320/sdmmc-dm320.c index 307b90ec3b..7df2925e20 100644 --- a/firmware/target/arm/tms320dm320/sdmmc-dm320.c +++ b/firmware/target/arm/tms320dm320/sdmmc-dm320.c @@ -27,6 +27,7 @@ #include "panic.h" #include "kernel.h" #include "dma-target.h" +#include "ata_idle_notify.h" //#define SD_DEBUG @@ -576,8 +577,8 @@ static void sd_thread(void) NORETURN_ATTR; static void sd_thread(void) { struct queue_event ev; + bool idle_notified = false; - /* TODO */ while (1) { queue_wait_w_tmo(&sd_queue, &ev, HZ); @@ -627,6 +628,17 @@ static void sd_thread(void) } break; #endif + case SYS_TIMEOUT: + if (TIME_BEFORE(current_tick, last_disk_activity+(3*HZ))) + { + idle_notified = false; + } + else if (!idle_notified) + { + call_storage_idle_notifys(false); + idle_notified = true; + } + break; } } } diff --git a/firmware/target/arm/tms320dm320/system-dm320.c b/firmware/target/arm/tms320dm320/system-dm320.c index 528d442ce5..029aecc610 100644 --- a/firmware/target/arm/tms320dm320/system-dm320.c +++ b/firmware/target/arm/tms320dm320/system-dm320.c @@ -359,6 +359,10 @@ void system_init(void) #endif #ifdef SANSA_CONNECT + /* keep WIFI CS low to save power */ + IO_GIO_DIR0 &= ~(1 << 4); + IO_GIO_BITCLR0 = (1 << 4); + i2c_init(); avr_hid_init(); avr_hid_enable_charger();