Permanently enable powering down the disk when it's sleeping for supported targets (iriver h1xx, h3xx and h10, iaudio x5, gigabeat and archos recorders)

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12094 a1c6a512-1295-4272-9138-f99709370657
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index a4f937c..9e85f84 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -3850,16 +3850,16 @@
 </phrase>
 <phrase>
   id: LANG_POWEROFF
-  desc: disk poweroff flag
+  desc: DEPRECATED
   user:
   <source>
-    *: "Disk Poweroff"
+    *: ""
   </source>
   <dest>
-    *: "Disk Poweroff"
+    *: deprecated
   </dest>
   <voice>
-    *: "Disk Poweroff"
+    *: ""
   </voice>
 </phrase>
 <phrase>
diff --git a/apps/settings.c b/apps/settings.c
index 01ede41..c7794e1 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -489,9 +489,6 @@
     dac_line_in(global_settings.line_in);
 #endif
     mpeg_id3_options(global_settings.id3_v1_first);
-#ifdef HAVE_ATA_POWER_OFF
-    ata_poweroff(global_settings.disk_poweroff);
-#endif
 
     set_poweroff_timeout(global_settings.poweroff);
 
diff --git a/apps/settings.h b/apps/settings.h
index eee24f1..3ff3fe6 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -281,7 +281,6 @@
     int ff_rewind_min_step; /* FF/Rewind minimum step size */
     int ff_rewind_accel; /* FF/Rewind acceleration (in seconds per doubling) */
     int disk_spindown; /* time until disk spindown, in seconds (0=off) */
-    bool disk_poweroff; /* whether to cut disk power after spindown or not */
     int buffer_margin; /* MP3 buffer watermark margin, in seconds */
 
     int peak_meter_release;   /* units per read out */
diff --git a/apps/settings_list.c b/apps/settings_list.c
index 313524b..bffee25 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -268,9 +268,6 @@
 #endif
     /* disk */
 #ifndef HAVE_MMC
-#ifdef HAVE_ATA_POWER_OFF
-    OFFON_SETTING(0,disk_poweroff,false,"disk poweroff",NULL),
-#endif
     {F_T_INT,GS(disk_spindown),INT(5),"disk spindown",NULL,UNUSED},
 #endif /* HAVE_MMC */
     /* browser */
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index 04fd64b..1a19bb1 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -1104,14 +1104,6 @@
                    ata_spindown, 1, 3, 254, NULL );
 }
 
-#ifdef HAVE_ATA_POWER_OFF
-static bool poweroff(void)
-{
-    bool rc = set_bool(str(LANG_POWEROFF), &global_settings.disk_poweroff);
-    ata_poweroff(global_settings.disk_poweroff);
-    return rc;
-}
-#endif /* HAVE_ATA_POWEROFF */
 #endif /* !HAVE_MMC */
 
 #if CONFIG_CODEC == MAS3507D
@@ -2116,9 +2108,6 @@
 
     static const struct menu_item items[] = {
         { ID2P(LANG_SPINDOWN),    spindown        },
-#ifdef HAVE_ATA_POWER_OFF
-        { ID2P(LANG_POWEROFF),    poweroff        },
-#endif
 #ifdef HAVE_DIRCACHE
         { ID2P(LANG_DIRCACHE_ENABLE),  dircache },
 #endif
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index 4dd0fdc..349f76c 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -63,6 +63,10 @@
 
 #define READ_TIMEOUT 5*HZ
 
+#ifdef HAVE_ATA_POWER_OFF
+#define ATA_POWER_OFF_TIMEOUT 2*HZ
+#endif
+
 static struct mutex ata_mtx;
 int ata_device; /* device 0 (master) or 1 (slave) */
 
@@ -75,9 +79,6 @@
 static bool sleeping = true;
 static bool poweroff = false;
 static long sleep_timeout = 5*HZ;
-#ifdef HAVE_ATA_POWER_OFF
-static int poweroff_timeout = 2*HZ;
-#endif
 #ifdef HAVE_LBA48
 static bool lba48 = false; /* set for 48 bit addressing */
 #endif
@@ -561,16 +562,6 @@
     sleep_timeout = seconds * HZ;
 }
 
-#ifdef HAVE_ATA_POWER_OFF
-void ata_poweroff(bool enable)
-{
-    if (enable)
-        poweroff_timeout = 2*HZ;
-    else
-        poweroff_timeout = 0;
-}
-#endif
-
 bool ata_disk_is_active(void)
 {
     return !sleeping;
@@ -654,8 +645,8 @@
                 }
             }
 #ifdef HAVE_ATA_POWER_OFF
-            if ( !spinup && sleeping && poweroff_timeout && !poweroff &&
-                 TIME_AFTER( current_tick, last_sleep + poweroff_timeout ))
+            if ( !spinup && sleeping && !poweroff &&
+                 TIME_AFTER( current_tick, last_sleep + ATA_POWER_OFF_TIMEOUT ))
             {
                 mutex_lock(&ata_mtx);
                 ide_power_enable(false);
diff --git a/firmware/export/ata.h b/firmware/export/ata.h
index a2cb8ab..915a71f 100644
--- a/firmware/export/ata.h
+++ b/firmware/export/ata.h
@@ -38,7 +38,6 @@
 
 extern void ata_enable(bool on);
 extern void ata_spindown(int seconds);
-extern void ata_poweroff(bool enable);
 extern void ata_sleep(void);
 extern void ata_sleepnow(void);
 extern bool ata_disk_is_active(void);
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c
index 2fef005..7f796ab 100644
--- a/firmware/powermgmt.c
+++ b/firmware/powermgmt.c
@@ -30,7 +30,6 @@
 #include "ata.h"
 #include "power.h"
 #include "button.h"
-#include "ata.h"
 #include "audio.h"
 #include "mp3_playback.h"
 #include "usb.h"
@@ -638,9 +637,6 @@
         remote_backlight_set_timeout(2);
 #endif
         ata_spindown(3);
-#ifdef HAVE_ATA_POWER_OFF
-        ata_poweroff(true);
-#endif
         low_battery = true;
     } else if (low_battery && (battery_percent > 11)) {
         backlight_set_timeout(10);