summaryrefslogtreecommitdiff
path: root/firmware/target/hosted/android/dx50/powermgmt-dx50.c
diff options
context:
space:
mode:
authorUdo Schläpfer <rockbox-2014.10@desktopwarrior.net>2015-02-02 21:44:29 +0100
committerUdo Schläpfer <rockbox-2014.10@desktopwarrior.net>2015-02-02 21:57:55 +0100
commitdbabd0d9c34a33bc0c51243ec37f230d117db955 (patch)
tree46de348929ce739702a230a2587fdb5539585753 /firmware/target/hosted/android/dx50/powermgmt-dx50.c
parentcef17e3d59ad93f766e8ee23b1610540a33dfe5e (diff)
downloadrockbox-dbabd0d9c34a33bc0c51243ec37f230d117db955.tar.gz
rockbox-dbabd0d9c34a33bc0c51243ec37f230d117db955.zip
iBasso DX50/DX90: Major code cleanup and reorganization.
Reorganization - Separated iBasso devices from PLATFORM_ANDROID. These are now standlone hosted targets. Most device specific code is in the firmware/target/hosted/ibasso directory. - No dependency on Android SDK, only the Android NDK is needed. 32 bit Android NDK and Android API Level 16. - Separate implementation for each device where feasible. Code cleanup - Rewrite of existing code, from simple reformat to complete reimplementation. - New backlight interface, seperating backlight from touchscreen. - Rewrite of device button handler, removing unneeded code and fixing memory leaks. - New Debug messages interface logging to Android adb logcat (DEBUGF, panicf, logf). - Rewrite of lcd device handler, removing unneeded code and fixing memory leaks. - Rewrite of audiohw device handler/pcm interface, removing unneeded code and fixing memory leaks, enabling 44.1/48kHz pthreaded playback. - Rewrite of power and powermng, proper shutdown, using batterylog results (see http://gerrit.rockbox.org/r/#/c/1047/). - Rewrite of configure (Android NDK) and device specific config. - Rewrite of the Android NDK specific Makefile. Misc - All plugins/games/demos activated. - Update tinyalsa to latest from https://github.com/tinyalsa/tinyalsa. Includes - http://gerrit.rockbox.org/r/#/c/993/ - http://gerrit.rockbox.org/r/#/c/1010/ - http://gerrit.rockbox.org/r/#/c/1035/ Does not include http://gerrit.rockbox.org/r/#/c/1007/ due to new backlight interface and new option for hold switch, touchscreen, physical button interaction. Rockbox needs the iBasso DX50/DX90 loader for startup, see http://gerrit.rockbox.org/r/#/c/1099/ The loader expects Rockbox to be installed in /mnt/sdcard/.rockbox/. If /mnt/sdcard/ is accessed as USB mass storage device, Rockbox will exit gracefully and the loader will restart Rockbox on USB disconnect. Tested on iBasso DX50. Compiled (not tested) for iBasso DX90. Compiled (not tested) for PLATFORM_ANDROID. Change-Id: I5f5e22e68f5b4cf29c28e2b40b2c265f2beb7ab7
Diffstat (limited to 'firmware/target/hosted/android/dx50/powermgmt-dx50.c')
-rw-r--r--firmware/target/hosted/android/dx50/powermgmt-dx50.c97
1 files changed, 0 insertions, 97 deletions
diff --git a/firmware/target/hosted/android/dx50/powermgmt-dx50.c b/firmware/target/hosted/android/dx50/powermgmt-dx50.c
deleted file mode 100644
index 713e8a977e..0000000000
--- a/firmware/target/hosted/android/dx50/powermgmt-dx50.c
+++ /dev/null
@@ -1,97 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 by Thomas Martitz
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include <stdbool.h>
23#include <stdio.h>
24#include <stdlib.h>
25#include "config.h"
26#include "power.h"
27#include "powermgmt.h"
28
29
30unsigned int power_input_status(void)
31{
32 int val;
33 FILE *f = fopen("/sys/class/power_supply/ac/present", "r");
34 fscanf(f, "%d", &val);
35 fclose(f);
36 return val?POWER_INPUT_MAIN_CHARGER:POWER_INPUT_NONE;
37}
38
39
40/* Returns true, if battery is charging, false else. */
41bool charging_state( void )
42{
43 /* Full, Charging, Discharging */
44 char state[9];
45
46 /* true if charging. */
47 bool charging = false;
48
49 FILE *f = fopen( "/sys/class/power_supply/battery/status", "r" );
50 if( f != NULL )
51 {
52 if( fgets( state, 9, f ) != NULL )
53 {
54 charging = ( strcmp( state, "Charging" ) == 0 );
55 }
56 }
57 fclose( f );
58
59 return charging;
60}
61
62
63/* Values for stock PISEN battery. TODO: Needs optimization */
64const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
65{
66 3380
67};
68
69const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
70{
71 3100
72};
73
74/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
75const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
76{
77 { 3370, 3650, 3700, 3740, 3780, 3820, 3870, 3930, 4000, 4090, 4190 }
78};
79
80/* Voltages (millivolt) of 0%, 10%, ... 100% when charging is enabled. */
81const unsigned short percent_to_volt_charge[11] =
82{
83 3370, 3650, 3700, 3740, 3780, 3820, 3870, 3930, 4000, 4090, 4190
84};
85
86
87/* Returns battery voltage from android measurement [millivolts] */
88int _battery_voltage(void)
89{
90 int val;
91 FILE *f = fopen("/sys/class/power_supply/battery/voltage_now", "r");
92 fscanf(f, "%d", &val);
93 fclose(f);
94 return (val/1000);
95}
96
97