From b6c12a129e22dadff4be67e5b0fe8993c888d6d8 Mon Sep 17 00:00:00 2001 From: Andree Buschmann Date: Sat, 20 Mar 2010 15:02:29 +0000 Subject: Submit FS#11065. Introduce a new system setting for en-/disabling the Line-out. For now only implemented on iPod Video. This allows to save power if the user does not use the player's Line-out. On iPod 5G the saving is ~0.5 mA. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25257 a1c6a512-1295-4272-9138-f99709370657 --- apps/features.txt | 4 ++++ apps/lang/english.lang | 18 +++++++++++++++++- apps/main.c | 3 +++ apps/menus/settings_menu.c | 6 ++++++ apps/settings.h | 3 +++ apps/settings_list.c | 4 ++++ firmware/drivers/audio/wm8758.c | 17 +++++++++++++++++ firmware/export/config/ipodvideo.h | 3 +++ firmware/export/powermgmt.h | 3 +++ firmware/export/wm8758.h | 1 + firmware/target/arm/ipod/powermgmt-ipod-pcf.c | 9 +++++++++ manual/configure_rockbox/system_options.tex | 8 ++++++++ uisimulator/common/powermgmt-sim.c | 7 +++++++ 13 files changed, 85 insertions(+), 1 deletion(-) diff --git a/apps/features.txt b/apps/features.txt index 242d2d4386..af0da5b355 100644 --- a/apps/features.txt +++ b/apps/features.txt @@ -225,6 +225,10 @@ usb_hid_mouse wheel_acceleration #endif +#if defined(HAVE_LINEOUT_POWEROFF) +lineout_poweroff +#endif + #if defined(HAVE_TOUCHSCREEN) touchscreen #endif diff --git a/apps/lang/english.lang b/apps/lang/english.lang index ab5b6b59cf..3c847cff81 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang @@ -13377,4 +13377,20 @@ recording_histogram: "Histogram interval" - + + id: LANG_LINEOUT_ONOFF + desc: in system settings menu + user: core + + *: none + lineout_poweroff: "Line-out" + + + *: none + lineout_poweroff: "Line-out" + + + *: none + lineout_poweroff: "Line-out" + + diff --git a/apps/main.c b/apps/main.c index fa1500edd5..7c43c0c277 100644 --- a/apps/main.c +++ b/apps/main.c @@ -632,6 +632,9 @@ static void init(void) #ifdef HAVE_ACCESSORY_SUPPLY accessory_supply_set(global_settings.accessory_supply); #endif +#ifdef HAVE_LINEOUT_POWEROFF + lineout_set(global_settings.lineout_active); +#endif #ifdef HAVE_HOTSWAP_STORAGE_AS_MAIN check_bootfile(false); /* remember write time and filesize */ #endif diff --git a/apps/menus/settings_menu.c b/apps/menus/settings_menu.c index 5c30e5982f..b695d9265b 100644 --- a/apps/menus/settings_menu.c +++ b/apps/menus/settings_menu.c @@ -251,6 +251,9 @@ MENUITEM_SETTING(serial_bitrate, &global_settings.serial_bitrate, NULL); #ifdef HAVE_ACCESSORY_SUPPLY MENUITEM_SETTING(accessory_supply, &global_settings.accessory_supply, NULL); #endif +#ifdef HAVE_LINEOUT_POWEROFF +MENUITEM_SETTING(lineout_onoff, &global_settings.lineout_active, NULL); +#endif MENUITEM_SETTING(start_screen, &global_settings.start_in_screen, NULL); #ifdef USB_ENABLE_HID MENUITEM_SETTING(usb_hid, &global_settings.usb_hid, NULL); @@ -299,6 +302,9 @@ MAKE_MENU(system_menu, ID2P(LANG_SYSTEM), #ifdef HAVE_ACCESSORY_SUPPLY &accessory_supply, #endif +#ifdef HAVE_LINEOUT_POWEROFF + &lineout_onoff, +#endif #ifdef HAVE_BUTTON_LIGHT &buttonlight_timeout, #endif diff --git a/apps/settings.h b/apps/settings.h index 4cc2bd521e..62f85254aa 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -767,6 +767,9 @@ struct user_settings #ifdef HAVE_ACCESSORY_SUPPLY bool accessory_supply; /* 0=off 1=on, accessory power supply for iPod */ #endif +#ifdef HAVE_LINEOUT_POWEROFF + bool lineout_active; +#endif #ifdef HAVE_SPEAKER bool speaker_enabled; diff --git a/apps/settings_list.c b/apps/settings_list.c index 5759e24286..2638eac5a0 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c @@ -699,6 +699,10 @@ const struct settings_list settings[] = { #ifdef HAVE_ACCESSORY_SUPPLY OFFON_SETTING(0, accessory_supply, LANG_ACCESSORY_SUPPLY, true, "accessory power supply", accessory_supply_set), +#endif +#ifdef HAVE_LINEOUT_POWEROFF + OFFON_SETTING(0, lineout_active, LANG_LINEOUT_ONOFF, + true, "lineout", lineout_set), #endif /* tuner */ #if CONFIG_TUNER diff --git a/firmware/drivers/audio/wm8758.c b/firmware/drivers/audio/wm8758.c index 715c921e33..40ead0cdf2 100644 --- a/firmware/drivers/audio/wm8758.c +++ b/firmware/drivers/audio/wm8758.c @@ -181,6 +181,23 @@ void audiohw_set_lineout_vol(int vol_l, int vol_r) wmcodec_write(ROUT2VOL, amp_r | ROUT2VOL_ROUT2ZC | ROUT2VOL_OUT2VU); } +void audiohw_enable_lineout(bool enable) +{ + if (enable) + { + /* include enabling of OUT2 */ + wmcodec_write(PWRMGMT3, PWRMGMT3_LOUT2EN | PWRMGMT3_ROUT2EN + | PWRMGMT3_RMIXEN | PWRMGMT3_LMIXEN + | PWRMGMT3_DACENR | PWRMGMT3_DACENL); + } + else + { + /* exclude enabling of OUT2 */ + wmcodec_write(PWRMGMT3, PWRMGMT3_RMIXEN | PWRMGMT3_LMIXEN + | PWRMGMT3_DACENR | PWRMGMT3_DACENL); + } +} + void audiohw_set_bass(int value) { eq1_reg = (eq1_reg & ~EQ_GAIN_MASK) | EQ_GAIN_VALUE(value); diff --git a/firmware/export/config/ipodvideo.h b/firmware/export/config/ipodvideo.h index a8d2220b8c..eec513320a 100644 --- a/firmware/export/config/ipodvideo.h +++ b/firmware/export/config/ipodvideo.h @@ -77,6 +77,9 @@ /* Define this if you can switch on/off the accessory power supply */ #define HAVE_ACCESSORY_SUPPLY +/* Define this, if you can switch on/off the lineout */ +#define HAVE_LINEOUT_POWEROFF + /* Define this if you have a software controlled poweroff */ #define HAVE_SW_POWEROFF diff --git a/firmware/export/powermgmt.h b/firmware/export/powermgmt.h index 17519c5bfd..d86118cd9b 100644 --- a/firmware/export/powermgmt.h +++ b/firmware/export/powermgmt.h @@ -174,5 +174,8 @@ bool query_force_shutdown(void); #ifdef HAVE_ACCESSORY_SUPPLY void accessory_supply_set(bool); #endif +#ifdef HAVE_LINEOUT_POWEROFF +void lineout_set(bool); +#endif #endif /* _POWERMGMT_H_ */ diff --git a/firmware/export/wm8758.h b/firmware/export/wm8758.h index 9d1a938162..50cbc74e9a 100644 --- a/firmware/export/wm8758.h +++ b/firmware/export/wm8758.h @@ -34,6 +34,7 @@ extern int tenthdb2mixer(int db); extern void audiohw_set_master_vol(int vol_l, int vol_r); extern void audiohw_set_lineout_vol(int vol_l, int vol_r); extern void audiohw_set_mixer_vol(int channel1, int channel2); +extern void audiohw_enable_lineout(bool enable); #define RESET 0x00 #define RESET_RESET 0x0 diff --git a/firmware/target/arm/ipod/powermgmt-ipod-pcf.c b/firmware/target/arm/ipod/powermgmt-ipod-pcf.c index 5b8f974fda..95f5380b92 100644 --- a/firmware/target/arm/ipod/powermgmt-ipod-pcf.c +++ b/firmware/target/arm/ipod/powermgmt-ipod-pcf.c @@ -25,6 +25,7 @@ #include "powermgmt.h" #include "pcf5060x.h" #include "pcf50605.h" +#include "audiohw.h" const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = { @@ -129,3 +130,11 @@ void accessory_supply_set(bool enable) } #endif + +#ifdef HAVE_LINEOUT_POWEROFF +void lineout_set(bool enable) +{ + /* Call audio hardware driver implementation */ + audiohw_enable_lineout(enable); +} +#endif diff --git a/manual/configure_rockbox/system_options.tex b/manual/configure_rockbox/system_options.tex index e7f70b8f0f..64ec0f0487 100644 --- a/manual/configure_rockbox/system_options.tex +++ b/manual/configure_rockbox/system_options.tex @@ -159,6 +159,14 @@ thus there is a reasonable chance that your favourite accessory will work. The accessory may require power from the \dap{} to function, and if so you should turn this option \setting{On}. If it is not required, then turning this setting \setting{Off} will save battery and therefore result in better runtime. +} + +\opt{lineout_poweroff}{ +\subsection{Lineout} +This option turns the \dap{}'s lineout \setting{On} and \setting{Off}. On some +devices an enabled lineout will consume some power even if not used. If it is +not required, then turning this setting \setting{Off} will save battery and +therefore result in better runtime. } \opt{HAVE_BUTTON_LIGHTS}{ diff --git a/uisimulator/common/powermgmt-sim.c b/uisimulator/common/powermgmt-sim.c index c06f84670d..e2ce8c10d2 100644 --- a/uisimulator/common/powermgmt-sim.c +++ b/uisimulator/common/powermgmt-sim.c @@ -142,6 +142,13 @@ void accessory_supply_set(bool enable) } #endif +#ifdef HAVE_LINEOUT_POWEROFF +void lineout_set(bool enable) +{ + (void)enable; +} +#endif + void reset_poweroff_timer(void) { } -- cgit v1.2.3