Set the default battery capacity for ipod video properly depending on detected RAM size.
Also set up a callback for the battery capacity setting (for all players) so changes take effect without having to reboot.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30170 a1c6a512-1295-4272-9138-f99709370657
diff --git a/apps/settings_list.c b/apps/settings_list.c
index 019a144..62a2d94 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -784,10 +784,20 @@
 #define BATTERY_CAPACITY_MAX BATTERY_CAPACITY_DEFAULT
 #define BATTERY_CAPACITY_INC 0
 #endif
+#ifdef IPOD_VIDEO
+    /* its easier to leave this one un-macro()ed for the time being */
+    { F_T_INT|F_DEF_ISFUNC|F_INT_SETTING, &global_settings.battery_capacity,
+        LANG_BATTERY_CAPACITY, FUNCTYPE(battery_default_capacity),
+        "battery capacity", NULL , {
+            .int_setting = (struct int_setting[]) {
+                { set_battery_capacity, UNIT_MAH, BATTERY_CAPACITY_MIN,
+                  BATTERY_CAPACITY_MAX, BATTERY_CAPACITY_INC, NULL, NULL }}}},
+#else /* IPOD_VIDEO */
     INT_SETTING(0, battery_capacity, LANG_BATTERY_CAPACITY,
                 BATTERY_CAPACITY_DEFAULT, "battery capacity", UNIT_MAH,
                 BATTERY_CAPACITY_MIN, BATTERY_CAPACITY_MAX,
-                BATTERY_CAPACITY_INC, NULL, NULL, NULL),
+                BATTERY_CAPACITY_INC, NULL, NULL, set_battery_capacity),
+#endif /* IPOD_VIDEO */
 #endif
 #if CONFIG_CHARGING
     OFFON_SETTING(NVRAM(1), car_adapter_mode,
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 4aef86f..28e72e8 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -1188,6 +1188,7 @@
 target/arm/ipod/powermgmt-ipod-pcf.c
 target/arm/ipod/video/lcd-as-video.S
 target/arm/ipod/video/lcd-video.c
+target/arm/ipod/video/battery-video.c
 target/arm/usb-fw-pp502x.c
 #endif /* SIMULATOR */
 #endif /* IPOD_VIDEO */
diff --git a/firmware/export/config/ipodvideo.h b/firmware/export/config/ipodvideo.h
index 124f788..dd21bb5 100644
--- a/firmware/export/config/ipodvideo.h
+++ b/firmware/export/config/ipodvideo.h
@@ -136,8 +136,11 @@
 #define HAVE_HEADPHONE_DETECTION
 
 /* Type of mobile power */
-#define BATTERY_CAPACITY_DEFAULT  400 /* default battery capacity for the   */
-                                      /* 30GB model. 60/80GB would have 600 */
+#define BATTERY_CAPACITY_DEFAULT  400  /* only for variable initialisation */
+#define BATTERY_CAPACITY_DEFAULT_THIN  400 /* default battery capacity for the
+                                              30GB model */
+#define BATTERY_CAPACITY_DEFAULT_THICK 600 /* default battery capacity for the
+                                              60/80GB model */
 #define BATTERY_CAPACITY_MIN      300 /* min. capacity selectable */
 #define BATTERY_CAPACITY_MAX     1400 /* max. capacity selectable */
 #define BATTERY_CAPACITY_INC       50 /* capacity increment */
diff --git a/firmware/target/arm/ipod/video/battery-video.c b/firmware/target/arm/ipod/video/battery-video.c
new file mode 100644
index 0000000..b4c4602
--- /dev/null
+++ b/firmware/target/arm/ipod/video/battery-video.c
@@ -0,0 +1,33 @@
+/***************************************************************************
+ *             __________               __   ___.
+ *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
+ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
+ *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
+ *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
+ *                     \/            \/     \/    \/            \/
+ * $Id $
+ *
+ * Default battery capacity for ipod video
+ *
+ * Copyright (c) 2011 Frank Gevaerts
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "config.h"
+#include "system.h"
+
+int battery_default_capacity(void)
+{
+    if(probed_ramsize==64)
+        return BATTERY_CAPACITY_DEFAULT_THICK;
+    else
+        return BATTERY_CAPACITY_DEFAULT_THIN;
+}
diff --git a/firmware/target/arm/system-target.h b/firmware/target/arm/system-target.h
index eb2a07f..e5a8b15 100644
--- a/firmware/target/arm/system-target.h
+++ b/firmware/target/arm/system-target.h
@@ -173,6 +173,7 @@
 
 #if defined(IPOD_VIDEO) && !defined(BOOTLOADER)
 extern unsigned char probed_ramsize;
+int battery_default_capacity(void);
 #endif
 
 
diff --git a/manual/configure_rockbox/system_options.tex b/manual/configure_rockbox/system_options.tex
index 9f47a7f..f53fa50 100644
--- a/manual/configure_rockbox/system_options.tex
+++ b/manual/configure_rockbox/system_options.tex
@@ -39,7 +39,7 @@
       \opt{ipodmini}{400~mAh (1G) or 630~mAh (2G)}%
       \opt{ipodcolor}{700~mAh}%
       \opt{ipodnano}{300~mAh}%
-      \opt{ipodvideo}{400~mAh}%
+      \opt{ipodvideo}{400~mAh (30~GB) or 600~mAh (60~GB and 80~GB)}%
       \opt{ipod4g}{630~mAh}%
       \opt{ipod3g}{630~mAh}%
       \opt{ipod1g2g}{1200~mAh}%
@@ -53,10 +53,6 @@
         calculation. Changing this setting has no effect whatsoever on
         actual battery life. This setting only affects the accuracy of the
         runtime estimation as shown on screen.
-      \opt{ipodvideo}{Rockbox does not automatically distinguish
-        between the 60/80~GB models and the 30~GB models which determine the
-        default value. If your \dap{} is a 60~GB or 80~GB model 
-        set the value to 600~mAh for more accuracy in the runtime estimation.}
       \opt{iaudiom3,iaudiom5,iaudiox5}{Rockbox does not automatically distinguish
         between the ``L'' models and the ``simple'' models which determine the
         default value. If your \dap{} is an