diff options
Diffstat (limited to 'firmware/target/hosted/android/dx50/powermgmt-dx50.c')
-rw-r--r-- | firmware/target/hosted/android/dx50/powermgmt-dx50.c | 97 |
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 | |||
30 | unsigned 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. */ | ||
41 | bool 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 */ | ||
64 | const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = | ||
65 | { | ||
66 | 3380 | ||
67 | }; | ||
68 | |||
69 | const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = | ||
70 | { | ||
71 | 3100 | ||
72 | }; | ||
73 | |||
74 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ | ||
75 | const 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. */ | ||
81 | const 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] */ | ||
88 | int _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 | |||