diff --git a/apps/SOURCES b/apps/SOURCES index c122427..4012255 100644 --- a/apps/SOURCES +++ b/apps/SOURCES @@ -312,6 +312,14 @@ keymaps/keymap-mpio-hd200.c keymaps/keymap-mpio-hd300.c #elif CONFIG_KEYPAD == ANDROID_PAD keymaps/keymap-android.c +#elif CONFIG_KEYPAD == ZIPIT_Z2_PAD +keymaps/keymap-sdl.c +#ifndef HAVE_TOUCHSCREEN +keymaps/keymap-touchscreen.c +#endif #elif CONFIG_KEYPAD == SDL_PAD keymaps/keymap-sdl.c +#ifndef HAVE_TOUCHSCREEN +keymaps/keymap-touchscreen.c +#endif #endif diff --git a/apps/codecs.c b/apps/codecs.c index cd4a9d5..8660033 100644 --- a/apps/codecs.c +++ b/apps/codecs.c @@ -54,7 +54,7 @@ #define LOGF_ENABLE #include "logf.h" -#if (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO|PLATFORM_PANDORA)) +#if (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO|PLATFORM_PANDORA|PLATFORM_ZIPIT_Z2)) #define PREFIX(_x_) sim_ ## _x_ #else #define PREFIX(_x_) _x_ diff --git a/apps/main.c b/apps/main.c index 0b566b5..8156022 100644 --- a/apps/main.c +++ b/apps/main.c @@ -125,7 +125,7 @@ #define MAIN_NORETURN_ATTR #endif -#if (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO|PLATFORM_PANDORA)) +#if (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO|PLATFORM_PANDORA|PLATFORM_ZIPIT_Z2)) #include "sim_tasks.h" #include "system-sdl.h" #define HAVE_ARGV_MAIN @@ -352,7 +352,7 @@ static void init(void) button_init(); powermgmt_init(); backlight_init(); -#if (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO|PLATFORM_PANDORA)) +#if (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO|PLATFORM_PANDORA|PLATFORM_ZIPIT_Z2)) sim_tasks_init(); #endif #if (CONFIG_PLATFORM & PLATFORM_ANDROID) diff --git a/firmware/SOURCES b/firmware/SOURCES index eee0c86..8817d52 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES @@ -1852,3 +1852,7 @@ target/hosted/android/app/button-application.c drivers/audio/android.c thread.c #endif + +#if (CONFIG_PLATFORM & PLATFORM_ZIPIT_Z2) +target/hosted/zipit/powermgmt-zipit-z2.c +#endif diff --git a/firmware/common/filefuncs.c b/firmware/common/filefuncs.c index 6eb2baf..9322ccb 100644 --- a/firmware/common/filefuncs.c +++ b/firmware/common/filefuncs.c @@ -91,7 +91,7 @@ bool dir_exists(const char *path) #endif /* __PCTOOL__ */ -#if (CONFIG_PLATFORM & (PLATFORM_NATIVE|PLATFORM_SDL|PLATFORM_MAEMO|PLATFORM_PANDORA)) +#if (CONFIG_PLATFORM & (PLATFORM_NATIVE|PLATFORM_SDL|PLATFORM_MAEMO|PLATFORM_PANDORA|PLATFORM_ZIPIT_Z2)) struct dirinfo dir_get_info(DIR* parent, struct dirent *entry) { (void)parent; diff --git a/firmware/common/rbpaths.c b/firmware/common/rbpaths.c index 1bbed97..2d887bc 100644 --- a/firmware/common/rbpaths.c +++ b/firmware/common/rbpaths.c @@ -43,7 +43,7 @@ #define opendir opendir_android #define mkdir mkdir_android #define rmdir rmdir_android -#elif (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO|PLATFORM_PANDORA)) +#elif (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO|PLATFORM_PANDORA|PLATFORM_ZIPIT_Z2)) #define open sim_open #define remove sim_remove #define rename sim_rename diff --git a/firmware/drivers/lcd-16bit.c b/firmware/drivers/lcd-16bit.c index 28c3285..ce24d5e 100644 --- a/firmware/drivers/lcd-16bit.c +++ b/firmware/drivers/lcd-16bit.c @@ -855,10 +855,10 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x, #ifdef CPU_ARM { int w, px; - asm volatile ( - ".rowstart: \n" + asm volatile ( + ".rowstart%=: \n" "mov %[w], %[width] \n" /* Load width for inner loop */ - ".nextpixel: \n" + ".nextpixel%=: \n" "ldrh %[px], [%[s]], #2 \n" /* Load src pixel */ "add %[d], %[d], #2 \n" /* Uncoditionally increment dst */ /* done here for better pipelining */ @@ -867,11 +867,11 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x, "cmpne %[px], %[transcolor] \n" /* Compare to transparent color */ "strneh %[px], [%[d], #-2] \n" /* Store dst if not transparent */ "subs %[w], %[w], #1 \n" /* Width counter has run down? */ - "bgt .nextpixel \n" /* More in this row? */ + "bgt .nextpixel%= \n" /* More in this row? */ "add %[s], %[s], %[sstp], lsl #1 \n" /* Skip over to start of next line */ "add %[d], %[d], %[dstp], lsl #1 \n" "subs %[h], %[h], #1 \n" /* Height counter has run down? */ - "bgt .rowstart \n" /* More rows? */ + "bgt .rowstart%= \n" /* More rows? */ : [w]"=&r"(w), [h]"+&r"(height), [px]"=&r"(px), [s]"+&r"(src), [d]"+&r"(dst) : [width]"r"(width), diff --git a/firmware/export/config.h b/firmware/export/config.h index 2c7c6e8..524f040 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h @@ -89,6 +89,7 @@ #define PLATFORM_MAEMO5 (1<<5) #define PLATFORM_MAEMO (PLATFORM_MAEMO4|PLATFORM_MAEMO5) #define PLATFORM_PANDORA (1<<6) +#define PLATFORM_ZIPIT_Z2 (1<<7) /* CONFIG_KEYPAD */ #define PLAYER_PAD 1 @@ -464,6 +465,8 @@ Lyre prototype 1 */ #include "config/nokian900.h" #elif defined(PANDORA) #include "config/pandora.h" +#elif defined(ZIPIT_Z2) +#include "config/zipit_z2.h" #else /* no known platform */ #endif @@ -538,6 +541,7 @@ Lyre prototype 1 */ #define ARM_ARCH 6 /* ARMv6 */ #elif defined(CPU_TCC77X) || defined(CPU_TCC780X) || (CONFIG_CPU == DM320) \ + || (CONFIG_PLATFORM & PLATFORM_ZIPIT_Z2) \ || (CONFIG_CPU == AT91SAM9260) || (CONFIG_CPU == AS3525v2) \ || (CONFIG_CPU == S5L8702) || (CONFIG_CPU == IMX233) \ || (CONFIG_CPU == RK27XX) ||(CONFIG_PLATFORM & PLATFORM_ANDROID) diff --git a/firmware/export/config/zipit_z2.h b/firmware/export/config/zipit_z2.h new file mode 100644 index 0000000..f86a98e --- /dev/null +++ b/firmware/export/config/zipit_z2.h @@ -0,0 +1,107 @@ +/* + * This config file is for the SDL application + */ +#define TARGET_TREE /* this target is using the target tree system */ + +/* We don't run on hardware directly */ +/* #define CONFIG_PLATFORM (PLATFORM_HOSTED|PLATFORM_ZIPIT_Z2) */ +/* ZIPIT_Z2 is just a minor tweak on PLATFORM_SDL so why not include both? */ +#define CONFIG_PLATFORM (PLATFORM_HOSTED|PLATFORM_SDL|PLATFORM_ZIPIT_Z2) + +/* For Rolo and boot loader */ +#define MODEL_NUMBER 100 + +#define MODEL_NAME "Rockbox" + +#define USB_NONE + +/* define this if you have a bitmap LCD display */ +#define HAVE_LCD_BITMAP + +/* define this if you have a colour LCD */ +#define HAVE_LCD_COLOR + +/* define this if you want album art for this target */ +#define HAVE_ALBUMART + +/* define this to enable bitmap scaling */ +#define HAVE_BMP_SCALING + +/* define this to enable JPEG decoding */ +#define HAVE_JPEG + +/* define this if you have access to the quickscreen */ +#define HAVE_QUICKSCREEN +/* define this if you have access to the pitchscreen */ +#define HAVE_PITCHSCREEN + +/* define this if you would like tagcache to build on this target */ +#define HAVE_TAGCACHE + +/* LCD dimensions + * + * overriden by configure for application builds */ +#ifndef LCD_WIDTH +#define LCD_WIDTH 320 +#endif + +#ifndef LCD_HEIGHT +#define LCD_HEIGHT 240 +#endif + +#define LCD_DEPTH 16 +#define LCD_PIXELFORMAT 565 + +/* define this to indicate your device's keypad */ +/* #define HAVE_TOUCHSCREEN */ +/* #define HAVE_BUTTON_DATA */ + +/* define this if you have RTC RAM available for settings */ +//#define HAVE_RTC_RAM + +/* define this if you have a real-time clock */ +#define CONFIG_RTC APPLICATION + +/* The number of bytes reserved for loadable codecs */ +#define CODEC_SIZE 0x100000 + +/* The number of bytes reserved for loadable plugins */ +/* Could save 512K here on IZ2S build. */ +#define PLUGIN_BUFFER_SIZE 0x80000 + +#define AB_REPEAT_ENABLE + +/* Define this if you do software codec */ +#define CONFIG_CODEC SWCODEC + +#define HAVE_SCROLLWHEEL +#define CONFIG_KEYPAD ZIPIT_Z2_PAD + +/* Use SDL audio/pcm in a SDL app build */ +#define HAVE_SDL +#define HAVE_SDL_AUDIO + +#define HAVE_SW_TONE_CONTROLS + +/* Define current usage levels. */ +#define CURRENT_NORMAL 88 /* 18 hours from a 1600 mAh battery */ +#define CURRENT_BACKLIGHT 30 /* TBD */ +#define CURRENT_RECORD 0 /* no recording yet */ + +/* Define this to the CPU frequency */ +/* +#define CPU_FREQ 48000000 +*/ + +/* Offset ( in the firmware file's header ) to the file CRC */ +#define FIRMWARE_OFFSET_FILE_CRC 0 + +/* Offset ( in the firmware file's header ) to the real data */ +#define FIRMWARE_OFFSET_FILE_DATA 8 + +#define CONFIG_LCD LCD_COWOND2 + +/* Define this if a programmable hotkey is mapped */ +#define HAVE_HOTKEY + +#define BOOTDIR "/.rockbox" diff --git a/firmware/include/dir_uncached.h b/firmware/include/dir_uncached.h index d9a29fb..b8afe5c 100644 --- a/firmware/include/dir_uncached.h +++ b/firmware/include/dir_uncached.h @@ -33,7 +33,7 @@ struct dirinfo { #include #include "file.h" -#if (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO|PLATFORM_PANDORA)) +#if (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO|PLATFORM_PANDORA|PLATFORM_ZIPIT_Z2)) # define dirent_uncached sim_dirent # define DIR_UNCACHED SIM_DIR # define opendir_uncached sim_opendir diff --git a/firmware/include/file.h b/firmware/include/file.h index 4835450..e1e6479 100644 --- a/firmware/include/file.h +++ b/firmware/include/file.h @@ -46,7 +46,7 @@ extern int app_open(const char *name, int o, ...); extern int app_creat(const char *name, mode_t mode); extern int app_remove(const char* pathname); extern int app_rename(const char* path, const char* newname); -# if (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO|PLATFORM_PANDORA)) +# if (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO|PLATFORM_PANDORA|PLATFORM_ZIPIT_Z2)) # define filesize(x) sim_filesize(x) # define fsync(x) sim_fsync(x) # define ftruncate(x,y) sim_ftruncate(x,y) diff --git a/firmware/target/hosted/sdl/app/button-application.c b/firmware/target/hosted/sdl/app/button-application.c index bb43d90..cdbfd96 100644 --- a/firmware/target/hosted/sdl/app/button-application.c +++ b/firmware/target/hosted/sdl/app/button-application.c @@ -17,7 +17,7 @@ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * - ***************************************************9*************************/ + ****************************************************************************/ #include @@ -50,7 +50,49 @@ int key_to_button(int keyboard_key) case SDLK_LEFT: new_btn = BUTTON_MIDLEFT; break; -#if (CONFIG_PLATFORM & PLATFORM_MAEMO|PLATFORM_PANDORA) +#if (CONFIG_PLATFORM & PLATFORM_ZIPIT_Z2) + case SDLK_HOME: /* Maybe switch home/end (prev/next on zipit z2) */ + case SDLK_TAB: + case SDLK_o: + case SDLK_9: + /* new_btn = BUTTON_MENU; */ + new_btn = BUTTON_TOPLEFT; + break; + case SDLK_END: /* Maybe switch home/end (prev/next on zipit z2) */ + case SDLK_p: + case SDLK_0: + /* new_btn = BUTTON_BACK; */ + new_btn = BUTTON_TOPRIGHT; + break; + case SDLK_KP_PLUS: + case SDLK_PAGEUP: + /* new_btn = BUTTON_VOL_UP (not in sdl button_target.h) */ + /* No BUTTON_VOL_UP defined in SDL application. Add it? */ + new_btn = BUTTON_TOPMIDDLE; + break; + case SDLK_KP_MINUS: + case SDLK_PAGEDOWN: + /* new_btn = BUTTON_VOL_DOWN (not in sdl button_target.h) */ + new_btn = BUTTON_BOTTOMMIDDLE; + break; + case SDLK_COMMA: + new_btn = BUTTON_MIDLEFT; + break; + case SDLK_l: + new_btn = BUTTON_BOTTOMLEFT; + break; + case SDLK_PERIOD: + case SDLK_KP_PERIOD: + new_btn = BUTTON_MIDRIGHT; + break; + case SDLK_BACKSPACE: + new_btn = BUTTON_BOTTOMRIGHT; + break; + case SDLK_KP_ENTER: + case SDLK_RETURN: + case SDLK_SPACE: +#endif /* ZIPIT_Z2 */ +#if (CONFIG_PLATFORM & (PLATFORM_MAEMO|PLATFORM_PANDORA)) case SDLK_RETURN: case SDLK_KP_ENTER: #endif diff --git a/firmware/target/hosted/sdl/button-sdl.c b/firmware/target/hosted/sdl/button-sdl.c index f14e53f..7f6d6b6 100644 --- a/firmware/target/hosted/sdl/button-sdl.c +++ b/firmware/target/hosted/sdl/button-sdl.c @@ -322,6 +322,12 @@ static void button_event(int key, bool pressed) } return; +#if (CONFIG_PLATFORM & PLATFORM_ZIPIT_Z2) + case SDLK_ESCAPE: + /* Will post SDL_USEREVENT in shutdown_hw() if successful. */ + sys_poweroff(); + break; +#endif #if (CONFIG_PLATFORM & PLATFORM_PANDORA) case SDLK_LCTRL: /* Will post SDL_USEREVENT in shutdown_hw() if successful. */ diff --git a/firmware/target/hosted/sdl/system-sdl.c b/firmware/target/hosted/sdl/system-sdl.c index 93a8a7c..af7d9aa 100644 --- a/firmware/target/hosted/sdl/system-sdl.c +++ b/firmware/target/hosted/sdl/system-sdl.c @@ -128,7 +128,7 @@ static int sdl_event_thread(void * param) depth = 16; flags = SDL_HWSURFACE|SDL_DOUBLEBUF; -#if (CONFIG_PLATFORM & (PLATFORM_MAEMO|PLATFORM_PANDORA)) +#if (CONFIG_PLATFORM & (PLATFORM_MAEMO|PLATFORM_PANDORA|PLATFORM_ZIPIT_Z2)) /* Fullscreen mode for maemo app */ flags |= SDL_FULLSCREEN; #endif @@ -137,7 +137,7 @@ static int sdl_event_thread(void * param) panicf("%s", SDL_GetError()); } -#if (CONFIG_PLATFORM & (PLATFORM_MAEMO|PLATFORM_PANDORA)) +#if (CONFIG_PLATFORM & (PLATFORM_MAEMO|PLATFORM_PANDORA|PLATFORM_ZIPIT_Z2)) /* SDL touch screen fix: Work around a SDL assumption that returns relative mouse coordinates when you get to the screen edges using the touchscreen and a disabled mouse cursor. diff --git a/firmware/target/hosted/zipit/powermgmt-zipit-z2.c b/firmware/target/hosted/zipit/powermgmt-zipit-z2.c new file mode 100644 index 0000000..3a4bd01 --- /dev/null +++ b/firmware/target/hosted/zipit/powermgmt-zipit-z2.c @@ -0,0 +1,241 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2002 by Heikki Hannikainen, Uwe Freese + * Revisions copyright (C) 2005 by Gerald Van Baren + * + * 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" +#include +#include "kernel.h" +#include "powermgmt.h" +#include + +#define BATT_MINMVOLT 3500 /* minimum millivolts of battery */ +#define BATT_MAXMVOLT 4200 /* maximum millivolts of battery */ +#define BATT_MAXRUNTIME (10 * 60) /* maximum runtime with full battery in + minutes */ + +#ifdef IZ2S +#include +#include +#include +#include +#include +#include +#include +#include + +unsigned char batlvl_calibration[256] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 5, + 6, 7, 8, 9, 11, 13, 16, 20, 23, 29, 36, 42, 48, 54, 58, 62, + 65, 68, 69, 71, 73, 77, 80,82, 83, 84, 85, 86, 88, 91, 92, 94, + 94, 95, 95, 95, 95, 95, 96,96, 96, 97, 97, 98, 99, 99,100,100, +}; + +#define MAP_SIZE 4096UL + +#define GPIO 0 /* AC Power */ +#define GPIO_BASE 0x40E00000 /* PXA270 GPIO Register Base */ + +typedef unsigned long u32; + +static int regoffset(int gpio) { + if (gpio < 32) return 0; + if (gpio < 64) return 4; + if (gpio < 96) return 8; + return 0x100; +} + +static int gpio_read(void *map_base, int gpio) { + volatile u32 *reg = (u32*)((u32)map_base + regoffset(gpio)); + return (*reg >> (gpio&31)) & 1; +} +#endif /* IZ2S */ + +extern void send_battery_level_event(void); +extern int last_sent_battery_level; +extern int battery_percent; + +static unsigned int battery_millivolts = BATT_MAXMVOLT; +/* estimated remaining time in minutes */ +static int powermgmt_est_runningtime_min = BATT_MAXRUNTIME; + +static void battery_status_update(void) +{ + static time_t last_change = 0; + static bool charging = false; + time_t now; + + time(&now); + +#ifdef IZ2S + /* Check once a second? */ + if ((last_change) < now) { + int fd; + void *map_base; + unsigned char res; + static int tot, n = -1; + static unsigned char lvl[64]; + + fd = open("/dev/mem", O_RDONLY | O_SYNC); + if (fd < 0) return; + map_base = mmap(0, MAP_SIZE, PROT_READ, MAP_SHARED, fd, GPIO_BASE); + if(map_base == (void *) -1) return; + if (gpio_read(map_base,GPIO) == 1) + charging= true; /* mains */ + else + charging= false; /* battery(0) or error */ + if(munmap(map_base, MAP_SIZE) == -1) return; + close(fd); + + /* Open lpc915 controller via i2c */ + if ( (fd = open("/dev/i2c-0",O_RDWR)) < 0) return; + /* FORCE so we can look at registers even when a driver is also running */ + if (ioctl(fd,I2C_SLAVE_FORCE,0x55) < 0) return; + /* Take 64 readings, and give the average value. */ + res = i2c_smbus_read_byte_data(fd, 0x02); /* batt chg level */ + close(fd); + if (n < 0) /* first time */ + { + n = 0; + memset(lvl, res, 64); + tot = res * 64; + } + tot -= lvl[n]; + tot += res; + lvl[n++] = res; + n = n %64; + battery_percent = batlvl_calibration[tot/64]; + /* got charging and battery_percent */ +#else /* NOT IZ2S */ + /* Check once a minute? */ + if ((last_change+60) < now) { + + int batteryTime = 0; + int ac, charge, flag; + char units[32]; + + FILE* fapm = fopen("/proc/apm", "r"); + + last_change = now; + + if (!fapm) return; + + fscanf(fapm, "%*s %*d.%*d %*x %x %x %x %d%% %d %s\n", &ac, + &charge, &flag, &battery_percent, &batteryTime, units); + fclose(fapm); + + if (charge) + charging = true; + else + charging = false; + +#if 0 + // BatteryTime not available on Zipit_Z2 yet. + if ((flag & 0x80) == 0 && charge != 0xFF && ac != 1 && batteryTime != -1) { + if (!strncmp(units, "min", 32)) + powermgmt_est_runningtime_min = batteryTime *= 60; + } +#endif + +#endif /* NOT IZ2S, move onto ZIPIT_Z2 common code. */ + powermgmt_est_runningtime_min = + battery_percent * BATT_MAXRUNTIME / 100; + + battery_millivolts = battery_percent * (BATT_MAXMVOLT - BATT_MINMVOLT); + battery_millivolts /= 100; + battery_millivolts += BATT_MINMVOLT; + + send_battery_level_event(); + } + return; + +} + +void battery_read_info(int *voltage, int *level) +{ + battery_status_update(); + + if (voltage) + *voltage = battery_millivolts; + + if (level) + *level = battery_percent; +} + +unsigned int battery_voltage(void) +{ + battery_status_update(); + return battery_millivolts; +} + +int battery_level(void) +{ + battery_status_update(); + return battery_percent; +} + +int battery_time(void) +{ + battery_status_update(); + return powermgmt_est_runningtime_min; +} + +bool battery_level_safe(void) +{ + return battery_level() >= 10; +} + +void set_battery_capacity(int capacity) +{ + (void)capacity; +} + +#if BATTERY_TYPES_COUNT > 1 +void set_battery_type(int type) +{ + (void)type; +} +#endif + +#ifdef HAVE_ACCESSORY_SUPPLY +void accessory_supply_set(bool enable) +{ + (void)enable; +} +#endif + +#ifdef HAVE_LINEOUT_POWEROFF +void lineout_set(bool enable) +{ + (void)enable; +} +#endif diff --git a/tools/configure b/tools/configure index 461e00c..ce08e28 100755 --- a/tools/configure +++ b/tools/configure @@ -1286,6 +1286,7 @@ cat <