2003-06-29 16:33:04 +00:00
|
|
|
|
/***************************************************************************
|
|
|
|
|
* __________ __ ___.
|
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
|
* $Id$
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2002 Bj<EFBFBD>rn Stenberg
|
|
|
|
|
*
|
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
|
*
|
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
|
* KIND, either express or implied.
|
|
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdio.h>
|
2003-07-24 10:02:45 +00:00
|
|
|
|
#include <atoi.h>
|
|
|
|
|
#include <timefuncs.h>
|
2004-07-13 14:01:41 +00:00
|
|
|
|
#include <ctype.h>
|
2004-06-10 13:29:52 +00:00
|
|
|
|
#include "debug.h"
|
2003-06-29 16:33:04 +00:00
|
|
|
|
#include "button.h"
|
|
|
|
|
#include "lcd.h"
|
|
|
|
|
#include "dir.h"
|
|
|
|
|
#include "file.h"
|
|
|
|
|
#include "kernel.h"
|
2006-01-25 18:29:56 +00:00
|
|
|
|
#include "usb.h"
|
2003-06-29 16:33:04 +00:00
|
|
|
|
#include "sprintf.h"
|
2005-06-14 14:36:46 +00:00
|
|
|
|
#include "logf.h"
|
2003-06-29 16:33:04 +00:00
|
|
|
|
#include "screens.h"
|
|
|
|
|
#include "misc.h"
|
|
|
|
|
#include "mas.h"
|
|
|
|
|
#include "plugin.h"
|
|
|
|
|
#include "lang.h"
|
2003-07-09 22:36:23 +00:00
|
|
|
|
#include "keyboard.h"
|
2003-07-20 21:29:16 +00:00
|
|
|
|
#include "mpeg.h"
|
2004-01-30 22:30:40 +00:00
|
|
|
|
#include "buffer.h"
|
|
|
|
|
#include "mp3_playback.h"
|
|
|
|
|
#include "backlight.h"
|
2004-02-03 23:56:25 +00:00
|
|
|
|
#include "ata.h"
|
2004-03-14 21:33:53 +00:00
|
|
|
|
#include "talk.h"
|
2004-06-10 13:29:52 +00:00
|
|
|
|
#include "mp3data.h"
|
2004-06-15 22:54:37 +00:00
|
|
|
|
#include "powermgmt.h"
|
2005-02-09 14:23:35 +00:00
|
|
|
|
#include "system.h"
|
2005-07-26 20:01:11 +00:00
|
|
|
|
#include "timer.h"
|
2005-04-01 13:41:03 +00:00
|
|
|
|
#include "sound.h"
|
2005-04-28 12:33:38 +00:00
|
|
|
|
#include "database.h"
|
2005-11-16 15:12:15 +00:00
|
|
|
|
#include "splash.h"
|
2005-08-29 21:15:27 +00:00
|
|
|
|
#if (CONFIG_CODEC == SWCODEC)
|
2005-03-20 23:05:44 +00:00
|
|
|
|
#include "pcm_playback.h"
|
2005-03-21 00:24:31 +00:00
|
|
|
|
#endif
|
2003-07-09 22:36:23 +00:00
|
|
|
|
|
2006-02-07 14:46:03 +00:00
|
|
|
|
#ifdef HAVE_CHARGING
|
|
|
|
|
#include "power.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2003-07-09 22:36:23 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2004-07-29 13:59:04 +00:00
|
|
|
|
#include "peakmeter.h"
|
2003-07-09 22:36:23 +00:00
|
|
|
|
#include "widgets.h"
|
2005-04-25 07:42:10 +00:00
|
|
|
|
#include "bmp.h"
|
2003-07-09 22:36:23 +00:00
|
|
|
|
#endif
|
2003-06-29 16:33:04 +00:00
|
|
|
|
|
2005-04-15 12:55:31 +00:00
|
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
|
#include "lcd-remote.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2003-07-25 23:04:59 +00:00
|
|
|
|
#ifdef SIMULATOR
|
|
|
|
|
static unsigned char pluginbuf[PLUGIN_BUFFER_SIZE];
|
2005-02-22 12:19:12 +00:00
|
|
|
|
void *sim_plugin_load(char *plugin, int *fd);
|
2005-02-22 12:55:40 +00:00
|
|
|
|
void sim_plugin_close(int fd);
|
2003-07-25 23:04:59 +00:00
|
|
|
|
#else
|
2005-02-22 12:19:12 +00:00
|
|
|
|
#define sim_plugin_close(x)
|
2003-07-25 23:04:59 +00:00
|
|
|
|
extern unsigned char pluginbuf[];
|
2004-09-26 09:25:59 +00:00
|
|
|
|
#include "bitswap.h"
|
2003-07-25 23:04:59 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2005-06-22 02:47:54 +00:00
|
|
|
|
/* for actual plugins only, not for codecs */
|
2003-07-25 23:04:59 +00:00
|
|
|
|
static bool plugin_loaded = false;
|
|
|
|
|
static int plugin_size = 0;
|
2004-04-30 20:37:11 +00:00
|
|
|
|
static void (*pfn_tsr_exit)(void) = NULL; /* TSR exit callback */
|
2003-07-25 23:04:59 +00:00
|
|
|
|
|
2004-07-20 21:37:36 +00:00
|
|
|
|
static const struct plugin_api rockbox_api = {
|
2003-06-29 16:33:04 +00:00
|
|
|
|
|
|
|
|
|
/* lcd */
|
2005-06-24 22:33:21 +00:00
|
|
|
|
lcd_set_contrast,
|
2003-06-29 16:33:04 +00:00
|
|
|
|
lcd_clear_display,
|
|
|
|
|
lcd_puts,
|
|
|
|
|
lcd_puts_scroll,
|
|
|
|
|
lcd_stop_scroll,
|
|
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
|
|
|
|
lcd_define_pattern,
|
2003-07-24 09:35:32 +00:00
|
|
|
|
lcd_get_locked_pattern,
|
|
|
|
|
lcd_unlock_pattern,
|
|
|
|
|
lcd_putc,
|
2004-07-27 14:10:48 +00:00
|
|
|
|
lcd_put_cursor,
|
|
|
|
|
lcd_remove_cursor,
|
2005-02-22 13:02:33 +00:00
|
|
|
|
PREFIX(lcd_icon),
|
2005-09-02 05:39:09 +00:00
|
|
|
|
lcd_double_height,
|
2003-06-29 16:33:04 +00:00
|
|
|
|
#else
|
2005-06-24 22:33:21 +00:00
|
|
|
|
#ifndef SIMULATOR
|
|
|
|
|
lcd_roll,
|
|
|
|
|
#endif
|
|
|
|
|
lcd_set_drawmode,
|
|
|
|
|
lcd_get_drawmode,
|
|
|
|
|
lcd_setfont,
|
|
|
|
|
lcd_getstringsize,
|
|
|
|
|
lcd_drawpixel,
|
|
|
|
|
lcd_drawline,
|
2005-06-28 23:15:47 +00:00
|
|
|
|
lcd_hline,
|
|
|
|
|
lcd_vline,
|
2005-06-24 22:33:21 +00:00
|
|
|
|
lcd_drawrect,
|
|
|
|
|
lcd_fillrect,
|
2005-07-06 22:58:02 +00:00
|
|
|
|
lcd_mono_bitmap_part,
|
|
|
|
|
lcd_mono_bitmap,
|
2005-07-26 20:01:11 +00:00
|
|
|
|
#if LCD_DEPTH > 1
|
|
|
|
|
lcd_set_foreground,
|
|
|
|
|
lcd_get_foreground,
|
|
|
|
|
lcd_set_background,
|
|
|
|
|
lcd_get_background,
|
|
|
|
|
lcd_bitmap_part,
|
|
|
|
|
lcd_bitmap,
|
2006-02-07 20:38:55 +00:00
|
|
|
|
#endif
|
|
|
|
|
#if LCD_DEPTH == 16
|
|
|
|
|
lcd_bitmap_transparent_part,
|
|
|
|
|
lcd_bitmap_transparent,
|
2005-07-26 20:01:11 +00:00
|
|
|
|
#endif
|
2003-06-29 16:33:04 +00:00
|
|
|
|
lcd_putsxy,
|
2004-07-27 14:10:48 +00:00
|
|
|
|
lcd_puts_style,
|
2004-10-23 09:59:53 +00:00
|
|
|
|
lcd_puts_scroll_style,
|
2005-06-24 22:33:21 +00:00
|
|
|
|
&lcd_framebuffer[0][0],
|
|
|
|
|
lcd_blit,
|
2003-06-29 16:33:04 +00:00
|
|
|
|
lcd_update,
|
|
|
|
|
lcd_update_rect,
|
2003-07-09 22:36:23 +00:00
|
|
|
|
scrollbar,
|
2004-07-27 14:10:48 +00:00
|
|
|
|
checkbox,
|
2005-06-24 22:33:21 +00:00
|
|
|
|
font_get,
|
2005-07-26 20:01:11 +00:00
|
|
|
|
font_getstringsize,
|
2006-01-15 18:20:18 +00:00
|
|
|
|
font_get_width,
|
2003-06-29 16:33:04 +00:00
|
|
|
|
#endif
|
2004-07-27 14:10:48 +00:00
|
|
|
|
backlight_on,
|
|
|
|
|
backlight_off,
|
2004-10-23 09:59:53 +00:00
|
|
|
|
backlight_set_timeout,
|
2005-11-16 15:12:15 +00:00
|
|
|
|
gui_syncsplash,
|
2005-04-15 12:55:31 +00:00
|
|
|
|
#ifdef HAVE_REMOTE_LCD
|
2005-06-18 01:25:47 +00:00
|
|
|
|
/* remote lcd */
|
2005-06-29 01:39:50 +00:00
|
|
|
|
lcd_remote_set_contrast,
|
2005-04-25 07:42:10 +00:00
|
|
|
|
lcd_remote_clear_display,
|
2005-04-25 23:47:51 +00:00
|
|
|
|
lcd_remote_puts,
|
|
|
|
|
lcd_remote_puts_scroll,
|
|
|
|
|
lcd_remote_stop_scroll,
|
2005-06-29 02:01:24 +00:00
|
|
|
|
#ifndef SIMULATOR
|
2005-06-29 01:39:50 +00:00
|
|
|
|
lcd_remote_roll,
|
2005-06-29 02:01:24 +00:00
|
|
|
|
#endif
|
2005-06-29 01:39:50 +00:00
|
|
|
|
lcd_remote_set_drawmode,
|
|
|
|
|
lcd_remote_get_drawmode,
|
|
|
|
|
lcd_remote_setfont,
|
|
|
|
|
lcd_remote_getstringsize,
|
|
|
|
|
lcd_remote_drawpixel,
|
|
|
|
|
lcd_remote_drawline,
|
|
|
|
|
lcd_remote_hline,
|
|
|
|
|
lcd_remote_vline,
|
|
|
|
|
lcd_remote_drawrect,
|
|
|
|
|
lcd_remote_fillrect,
|
2005-07-07 00:05:29 +00:00
|
|
|
|
lcd_remote_mono_bitmap_part,
|
|
|
|
|
lcd_remote_mono_bitmap,
|
2005-04-25 23:47:51 +00:00
|
|
|
|
lcd_remote_putsxy,
|
|
|
|
|
lcd_remote_puts_style,
|
|
|
|
|
lcd_remote_puts_scroll_style,
|
2005-06-29 01:39:50 +00:00
|
|
|
|
&lcd_remote_framebuffer[0][0],
|
2005-04-25 23:47:51 +00:00
|
|
|
|
lcd_remote_update,
|
|
|
|
|
lcd_remote_update_rect,
|
2005-06-18 01:25:47 +00:00
|
|
|
|
|
2005-11-21 23:55:39 +00:00
|
|
|
|
remote_backlight_on,
|
|
|
|
|
remote_backlight_off,
|
2005-04-15 12:55:31 +00:00
|
|
|
|
#endif
|
2003-06-29 16:33:04 +00:00
|
|
|
|
/* button */
|
|
|
|
|
button_get,
|
|
|
|
|
button_get_w_tmo,
|
2004-07-27 14:10:48 +00:00
|
|
|
|
button_status,
|
|
|
|
|
button_clear_queue,
|
2005-06-18 01:25:47 +00:00
|
|
|
|
#if CONFIG_KEYPAD == IRIVER_H100_PAD
|
|
|
|
|
button_hold,
|
|
|
|
|
#endif
|
2003-06-29 16:33:04 +00:00
|
|
|
|
|
|
|
|
|
/* file */
|
2003-12-09 06:48:55 +00:00
|
|
|
|
(open_func)PREFIX(open),
|
2005-02-22 12:19:12 +00:00
|
|
|
|
close,
|
2003-12-09 06:48:55 +00:00
|
|
|
|
(read_func)read,
|
2005-02-28 18:32:57 +00:00
|
|
|
|
PREFIX(lseek),
|
2003-12-09 06:48:55 +00:00
|
|
|
|
(creat_func)PREFIX(creat),
|
|
|
|
|
(write_func)write,
|
2004-07-23 14:51:49 +00:00
|
|
|
|
PREFIX(remove),
|
|
|
|
|
PREFIX(rename),
|
2005-02-22 12:19:12 +00:00
|
|
|
|
PREFIX(ftruncate),
|
2003-06-29 16:33:04 +00:00
|
|
|
|
PREFIX(filesize),
|
2005-02-22 12:19:12 +00:00
|
|
|
|
fdprintf,
|
2003-06-29 16:33:04 +00:00
|
|
|
|
read_line,
|
2004-07-27 14:10:48 +00:00
|
|
|
|
settings_parseline,
|
2004-07-27 19:16:58 +00:00
|
|
|
|
#ifndef SIMULATOR
|
|
|
|
|
ata_sleep,
|
2006-02-07 20:38:55 +00:00
|
|
|
|
ata_disk_is_active,
|
2004-07-27 19:16:58 +00:00
|
|
|
|
#endif
|
2003-06-29 16:33:04 +00:00
|
|
|
|
|
|
|
|
|
/* dir */
|
|
|
|
|
PREFIX(opendir),
|
|
|
|
|
PREFIX(closedir),
|
|
|
|
|
PREFIX(readdir),
|
2005-06-18 01:25:47 +00:00
|
|
|
|
PREFIX(mkdir),
|
2003-06-29 16:33:04 +00:00
|
|
|
|
|
2004-10-23 09:59:53 +00:00
|
|
|
|
/* kernel/ system */
|
2003-06-29 16:33:04 +00:00
|
|
|
|
PREFIX(sleep),
|
2004-07-27 14:10:48 +00:00
|
|
|
|
yield,
|
2003-06-29 16:33:04 +00:00
|
|
|
|
¤t_tick,
|
2004-07-27 14:10:48 +00:00
|
|
|
|
default_event_handler,
|
2004-10-23 09:59:53 +00:00
|
|
|
|
default_event_handler_ex,
|
2004-07-27 14:10:48 +00:00
|
|
|
|
create_thread,
|
|
|
|
|
remove_thread,
|
2004-07-27 19:16:58 +00:00
|
|
|
|
reset_poweroff_timer,
|
2004-10-23 09:59:53 +00:00
|
|
|
|
#ifndef SIMULATOR
|
|
|
|
|
system_memory_guard,
|
2005-06-18 01:25:47 +00:00
|
|
|
|
&cpu_frequency,
|
|
|
|
|
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
|
|
|
|
cpu_boost,
|
|
|
|
|
#endif
|
2005-07-26 20:01:11 +00:00
|
|
|
|
timer_register,
|
|
|
|
|
timer_unregister,
|
|
|
|
|
timer_set_period,
|
2004-10-23 09:59:53 +00:00
|
|
|
|
#endif
|
2006-02-07 20:38:55 +00:00
|
|
|
|
queue_init,
|
|
|
|
|
queue_delete,
|
|
|
|
|
queue_post,
|
|
|
|
|
queue_wait_w_tmo,
|
|
|
|
|
usb_acknowledge,
|
|
|
|
|
#ifdef RB_PROFILE
|
|
|
|
|
profile_thread,
|
|
|
|
|
profstop,
|
|
|
|
|
profile_func_enter,
|
|
|
|
|
profile_func_exit,
|
|
|
|
|
#endif
|
2003-06-29 16:33:04 +00:00
|
|
|
|
|
|
|
|
|
/* strings and memory */
|
|
|
|
|
snprintf,
|
|
|
|
|
strcpy,
|
2004-07-27 14:10:48 +00:00
|
|
|
|
strncpy,
|
2003-06-29 16:33:04 +00:00
|
|
|
|
strlen,
|
2004-07-13 14:14:30 +00:00
|
|
|
|
strrchr,
|
2004-07-27 14:10:48 +00:00
|
|
|
|
strcmp,
|
2005-07-26 20:01:11 +00:00
|
|
|
|
strncmp,
|
2004-07-27 14:10:48 +00:00
|
|
|
|
strcasecmp,
|
2004-10-23 09:59:53 +00:00
|
|
|
|
strncasecmp,
|
2003-06-29 16:33:04 +00:00
|
|
|
|
memset,
|
|
|
|
|
memcpy,
|
2006-02-07 20:38:55 +00:00
|
|
|
|
memmove,
|
2004-07-13 14:01:41 +00:00
|
|
|
|
_ctype_,
|
2004-07-27 19:16:58 +00:00
|
|
|
|
atoi,
|
2005-02-22 12:19:12 +00:00
|
|
|
|
strchr,
|
|
|
|
|
strcat,
|
|
|
|
|
memcmp,
|
2005-06-18 01:25:47 +00:00
|
|
|
|
strcasestr,
|
2006-01-15 18:20:18 +00:00
|
|
|
|
/* unicode stuff */
|
|
|
|
|
utf8decode,
|
|
|
|
|
iso_decode,
|
|
|
|
|
utf16LEdecode,
|
|
|
|
|
utf16BEdecode,
|
|
|
|
|
utf8encode,
|
|
|
|
|
utf8length,
|
2003-06-29 16:33:04 +00:00
|
|
|
|
|
|
|
|
|
/* sound */
|
2005-04-01 13:41:03 +00:00
|
|
|
|
sound_set,
|
2006-01-15 18:20:18 +00:00
|
|
|
|
sound_min,
|
|
|
|
|
sound_max,
|
2003-06-29 16:33:04 +00:00
|
|
|
|
#ifndef SIMULATOR
|
2004-07-27 14:10:48 +00:00
|
|
|
|
mp3_play_data,
|
|
|
|
|
mp3_play_pause,
|
|
|
|
|
mp3_play_stop,
|
|
|
|
|
mp3_is_playing,
|
2005-08-29 21:15:27 +00:00
|
|
|
|
#if CONFIG_CODEC != SWCODEC
|
2004-07-27 14:10:48 +00:00
|
|
|
|
bitswap,
|
2005-06-06 00:34:07 +00:00
|
|
|
|
#endif
|
2005-08-29 21:15:27 +00:00
|
|
|
|
#if CONFIG_CODEC == SWCODEC
|
2005-06-18 01:25:47 +00:00
|
|
|
|
pcm_play_data,
|
|
|
|
|
pcm_play_stop,
|
|
|
|
|
pcm_set_frequency,
|
|
|
|
|
pcm_is_playing,
|
|
|
|
|
pcm_play_pause,
|
|
|
|
|
#endif
|
2003-06-29 16:33:04 +00:00
|
|
|
|
#endif
|
2005-06-18 01:25:47 +00:00
|
|
|
|
|
2004-07-27 14:10:48 +00:00
|
|
|
|
/* playback control */
|
2005-04-04 12:06:29 +00:00
|
|
|
|
PREFIX(audio_play),
|
|
|
|
|
audio_stop,
|
|
|
|
|
audio_pause,
|
|
|
|
|
audio_resume,
|
|
|
|
|
audio_next,
|
|
|
|
|
audio_prev,
|
|
|
|
|
audio_ff_rewind,
|
|
|
|
|
audio_next_track,
|
2004-07-27 14:10:48 +00:00
|
|
|
|
playlist_amount,
|
2005-04-04 12:06:29 +00:00
|
|
|
|
audio_status,
|
|
|
|
|
audio_has_changed_track,
|
|
|
|
|
audio_current_track,
|
|
|
|
|
audio_flush_and_reload_tracks,
|
|
|
|
|
audio_get_file_pos,
|
2005-08-29 21:15:27 +00:00
|
|
|
|
#if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
|
2005-04-25 08:21:10 +00:00
|
|
|
|
mpeg_get_last_header,
|
2005-04-25 08:59:19 +00:00
|
|
|
|
#endif
|
2005-08-29 21:15:27 +00:00
|
|
|
|
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
|
2005-04-01 13:41:03 +00:00
|
|
|
|
sound_set_pitch,
|
2004-10-23 09:59:53 +00:00
|
|
|
|
#endif
|
2004-07-27 19:16:58 +00:00
|
|
|
|
|
2005-08-29 21:15:27 +00:00
|
|
|
|
#if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
|
2004-07-27 19:16:58 +00:00
|
|
|
|
/* MAS communication */
|
|
|
|
|
mas_readmem,
|
|
|
|
|
mas_writemem,
|
|
|
|
|
mas_readreg,
|
|
|
|
|
mas_writereg,
|
2005-08-29 21:15:27 +00:00
|
|
|
|
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
|
2004-07-27 19:16:58 +00:00
|
|
|
|
mas_codec_writereg,
|
|
|
|
|
mas_codec_readreg,
|
|
|
|
|
#endif
|
2005-08-29 21:15:27 +00:00
|
|
|
|
#endif /* !SIMULATOR && CONFIG_CODEC != SWCODEC */
|
2004-07-27 14:10:48 +00:00
|
|
|
|
|
2005-06-18 01:25:47 +00:00
|
|
|
|
/* tag database */
|
|
|
|
|
&tagdbheader,
|
|
|
|
|
&tagdb_fd,
|
|
|
|
|
&tagdb_initialized,
|
|
|
|
|
tagdb_init,
|
2005-07-26 20:01:11 +00:00
|
|
|
|
/* runtime database */
|
|
|
|
|
&rundbheader,
|
|
|
|
|
&rundb_fd,
|
|
|
|
|
&rundb_initialized,
|
2005-06-18 01:25:47 +00:00
|
|
|
|
|
2006-01-15 18:20:18 +00:00
|
|
|
|
/* menu */
|
|
|
|
|
menu_init,
|
|
|
|
|
menu_exit,
|
|
|
|
|
menu_show,
|
|
|
|
|
menu_run,
|
|
|
|
|
menu_cursor,
|
|
|
|
|
menu_description,
|
|
|
|
|
menu_delete,
|
|
|
|
|
menu_count,
|
|
|
|
|
menu_moveup,
|
|
|
|
|
menu_movedown,
|
|
|
|
|
menu_draw,
|
|
|
|
|
menu_insert,
|
|
|
|
|
menu_set_cursor,
|
|
|
|
|
|
2006-02-07 20:38:55 +00:00
|
|
|
|
/* power */
|
|
|
|
|
battery_level,
|
|
|
|
|
battery_level_safe,
|
|
|
|
|
battery_time,
|
|
|
|
|
#ifndef SIMULATOR
|
|
|
|
|
battery_voltage,
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef HAVE_CHARGING
|
|
|
|
|
charger_inserted,
|
|
|
|
|
# ifdef HAVE_CHARGE_STATE
|
|
|
|
|
charging_state,
|
|
|
|
|
# endif
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef HAVE_USB_POWER
|
|
|
|
|
usb_powered,
|
|
|
|
|
#endif
|
|
|
|
|
|
2003-06-29 16:33:04 +00:00
|
|
|
|
/* misc */
|
|
|
|
|
srand,
|
|
|
|
|
rand,
|
2003-12-09 06:48:55 +00:00
|
|
|
|
(qsort_func)qsort,
|
2003-07-09 22:36:23 +00:00
|
|
|
|
kbd_input,
|
2003-07-25 23:04:59 +00:00
|
|
|
|
get_time,
|
2004-07-27 19:16:58 +00:00
|
|
|
|
set_time,
|
2003-07-25 23:04:59 +00:00
|
|
|
|
plugin_get_buffer,
|
2005-04-05 11:33:58 +00:00
|
|
|
|
plugin_get_audio_buffer,
|
2004-07-27 14:10:48 +00:00
|
|
|
|
plugin_tsr,
|
2004-06-10 13:29:52 +00:00
|
|
|
|
#if defined(DEBUG) || defined(SIMULATOR)
|
|
|
|
|
debugf,
|
2005-07-26 20:01:11 +00:00
|
|
|
|
#endif
|
|
|
|
|
#ifdef ROCKBOX_HAS_LOGF
|
|
|
|
|
logf,
|
2004-06-10 13:29:52 +00:00
|
|
|
|
#endif
|
2004-07-27 19:16:58 +00:00
|
|
|
|
&global_settings,
|
2004-06-10 13:29:52 +00:00
|
|
|
|
mp3info,
|
|
|
|
|
count_mp3_frames,
|
|
|
|
|
create_xing_header,
|
2004-10-23 09:59:53 +00:00
|
|
|
|
find_next_frame,
|
2005-08-29 21:15:27 +00:00
|
|
|
|
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
|
2004-07-29 13:59:04 +00:00
|
|
|
|
peak_meter_scale_value,
|
2004-10-23 09:59:53 +00:00
|
|
|
|
peak_meter_set_use_dbfs,
|
2004-07-29 13:59:04 +00:00
|
|
|
|
peak_meter_get_use_dbfs,
|
|
|
|
|
#endif
|
2005-04-25 07:42:10 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
read_bmp_file,
|
2006-01-15 18:20:18 +00:00
|
|
|
|
screen_dump_set_hook,
|
2005-04-25 07:42:10 +00:00
|
|
|
|
#endif
|
2005-09-02 05:39:09 +00:00
|
|
|
|
show_logo,
|
2005-06-18 01:25:47 +00:00
|
|
|
|
|
|
|
|
|
/* new stuff at the end, sort into place next time
|
|
|
|
|
the API gets incompatible */
|
2006-02-18 20:51:34 +00:00
|
|
|
|
tree_get_context,
|
2003-06-29 16:33:04 +00:00
|
|
|
|
};
|
|
|
|
|
|
2004-08-18 01:09:31 +00:00
|
|
|
|
int plugin_load(const char* plugin, void* parameter)
|
2003-06-29 16:33:04 +00:00
|
|
|
|
{
|
2006-01-16 23:20:58 +00:00
|
|
|
|
int fd, rc;
|
2006-01-17 20:39:44 +00:00
|
|
|
|
struct plugin_header *hdr;
|
2005-02-22 12:56:58 +00:00
|
|
|
|
#ifndef SIMULATOR
|
2006-01-15 18:20:18 +00:00
|
|
|
|
ssize_t readsize;
|
2005-02-22 12:56:58 +00:00
|
|
|
|
#endif
|
2004-05-01 15:14:09 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2006-01-16 23:20:58 +00:00
|
|
|
|
int xm, ym;
|
2004-05-01 15:14:09 +00:00
|
|
|
|
#endif
|
2006-02-18 00:13:44 +00:00
|
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
|
int rxm, rym;
|
|
|
|
|
#endif
|
2006-02-02 20:42:56 +00:00
|
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
|
fb_data* old_backdrop;
|
|
|
|
|
#endif
|
2003-06-29 16:33:04 +00:00
|
|
|
|
|
2004-04-30 20:37:11 +00:00
|
|
|
|
if (pfn_tsr_exit != NULL) /* if we have a resident old plugin: */
|
|
|
|
|
{
|
|
|
|
|
pfn_tsr_exit(); /* force it to exit now */
|
|
|
|
|
pfn_tsr_exit = NULL;
|
2005-11-10 08:07:31 +00:00
|
|
|
|
plugin_loaded = false;
|
2004-04-30 20:37:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-02-16 22:36:04 +00:00
|
|
|
|
gui_syncsplash(0, true, str(LANG_WAIT));
|
|
|
|
|
|
2003-06-29 16:33:04 +00:00
|
|
|
|
#ifdef SIMULATOR
|
2006-01-16 23:20:58 +00:00
|
|
|
|
hdr = sim_plugin_load((char *)plugin, &fd);
|
|
|
|
|
if (!fd) {
|
|
|
|
|
gui_syncsplash(HZ*2, true, str(LANG_PLUGIN_CANT_OPEN), plugin);
|
2003-06-29 16:33:04 +00:00
|
|
|
|
return -1;
|
2006-01-16 23:20:58 +00:00
|
|
|
|
}
|
|
|
|
|
if (hdr == NULL
|
|
|
|
|
|| hdr->magic != PLUGIN_MAGIC
|
2006-01-18 08:34:32 +00:00
|
|
|
|
|| hdr->target_id != TARGET_ID) {
|
2006-01-16 23:20:58 +00:00
|
|
|
|
sim_plugin_close(fd);
|
|
|
|
|
gui_syncsplash(HZ*2, true, str(LANG_PLUGIN_WRONG_MODEL));
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if (hdr->api_version > PLUGIN_API_VERSION
|
|
|
|
|
|| hdr->api_version < PLUGIN_MIN_API_VERSION) {
|
|
|
|
|
sim_plugin_close(fd);
|
|
|
|
|
gui_syncsplash(HZ*2, true, str(LANG_PLUGIN_WRONG_VERSION));
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2003-06-29 16:33:04 +00:00
|
|
|
|
#else
|
|
|
|
|
fd = open(plugin, O_RDONLY);
|
|
|
|
|
if (fd < 0) {
|
2006-01-15 18:20:18 +00:00
|
|
|
|
gui_syncsplash(HZ*2, true, str(LANG_PLUGIN_CANT_OPEN), plugin);
|
2003-06-29 16:33:04 +00:00
|
|
|
|
return fd;
|
|
|
|
|
}
|
2006-01-17 20:39:44 +00:00
|
|
|
|
/* zero out plugin buffer to ensure a properly zeroed bss area */
|
|
|
|
|
memset(pluginbuf, 0, PLUGIN_BUFFER_SIZE);
|
|
|
|
|
|
|
|
|
|
readsize = read(fd, pluginbuf, PLUGIN_BUFFER_SIZE);
|
2006-01-16 23:20:58 +00:00
|
|
|
|
close(fd);
|
2006-01-15 18:20:18 +00:00
|
|
|
|
|
2006-01-18 08:34:32 +00:00
|
|
|
|
if (readsize < 0) {
|
2006-01-15 18:20:18 +00:00
|
|
|
|
gui_syncsplash(HZ*2, true, str(LANG_READ_FAILED), plugin);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2006-01-17 20:39:44 +00:00
|
|
|
|
hdr = (struct plugin_header *)pluginbuf;
|
|
|
|
|
|
2006-01-18 08:34:32 +00:00
|
|
|
|
if ((unsigned)readsize <= sizeof(struct plugin_header)
|
|
|
|
|
|| hdr->magic != PLUGIN_MAGIC
|
2006-01-17 20:39:44 +00:00
|
|
|
|
|| hdr->target_id != TARGET_ID
|
|
|
|
|
|| hdr->load_addr != pluginbuf
|
|
|
|
|
|| hdr->end_addr > pluginbuf + PLUGIN_BUFFER_SIZE) {
|
2006-01-15 18:20:18 +00:00
|
|
|
|
gui_syncsplash(HZ*2, true, str(LANG_PLUGIN_WRONG_MODEL));
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2006-01-17 20:39:44 +00:00
|
|
|
|
if (hdr->api_version > PLUGIN_API_VERSION
|
|
|
|
|
|| hdr->api_version < PLUGIN_MIN_API_VERSION) {
|
2006-01-15 18:20:18 +00:00
|
|
|
|
gui_syncsplash(HZ*2, true, str(LANG_PLUGIN_WRONG_VERSION));
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2006-01-17 20:39:44 +00:00
|
|
|
|
plugin_size = hdr->end_addr - pluginbuf;
|
2003-06-29 16:33:04 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2003-07-25 23:04:59 +00:00
|
|
|
|
plugin_loaded = true;
|
2005-02-09 14:19:14 +00:00
|
|
|
|
|
2006-02-16 22:36:04 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
xm = lcd_getxmargin();
|
|
|
|
|
ym = lcd_getymargin();
|
|
|
|
|
lcd_setmargins(0,0);
|
2006-02-14 00:39:11 +00:00
|
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
|
old_backdrop = lcd_get_backdrop();
|
|
|
|
|
lcd_set_backdrop(NULL);
|
2006-02-16 22:36:04 +00:00
|
|
|
|
#endif
|
|
|
|
|
lcd_clear_display();
|
2006-02-14 00:39:11 +00:00
|
|
|
|
lcd_update();
|
2006-02-16 22:36:04 +00:00
|
|
|
|
#else /* !HAVE_LCD_BITMAP */
|
|
|
|
|
lcd_clear_display();
|
2006-02-14 00:39:11 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2006-02-18 00:13:44 +00:00
|
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
|
rxm = lcd_remote_getxmargin();
|
|
|
|
|
rym = lcd_remote_getymargin();
|
|
|
|
|
lcd_remote_setmargins(0, 0);
|
|
|
|
|
lcd_remote_clear_display();
|
|
|
|
|
lcd_remote_update();
|
|
|
|
|
#endif
|
|
|
|
|
|
2005-02-09 14:19:14 +00:00
|
|
|
|
invalidate_icache();
|
|
|
|
|
|
2006-01-17 20:39:44 +00:00
|
|
|
|
rc = hdr->entry_point((struct plugin_api*) &rockbox_api, parameter);
|
2004-07-21 08:02:23 +00:00
|
|
|
|
/* explicitly casting the pointer here to avoid touching every plugin. */
|
|
|
|
|
|
|
|
|
|
button_clear_queue();
|
2006-02-18 00:13:44 +00:00
|
|
|
|
|
2005-06-24 22:33:21 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2005-07-14 18:12:27 +00:00
|
|
|
|
#if LCD_DEPTH > 1
|
2005-11-16 21:09:23 +00:00
|
|
|
|
lcd_set_drawinfo(DRMODE_SOLID, LCD_DEFAULT_FG, LCD_DEFAULT_BG);
|
2005-07-19 10:33:41 +00:00
|
|
|
|
#else /* LCD_DEPTH == 1 */
|
2005-06-24 22:33:21 +00:00
|
|
|
|
lcd_set_drawmode(DRMODE_SOLID);
|
2005-07-19 10:33:41 +00:00
|
|
|
|
#endif /* LCD_DEPTH */
|
2006-01-16 23:20:58 +00:00
|
|
|
|
/* restore margins */
|
|
|
|
|
lcd_setmargins(xm,ym);
|
2006-02-02 20:42:56 +00:00
|
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
|
lcd_set_backdrop(old_backdrop);
|
|
|
|
|
#endif
|
2006-02-16 22:36:04 +00:00
|
|
|
|
lcd_clear_display();
|
|
|
|
|
lcd_update();
|
|
|
|
|
#endif /* HAVE_LCD_BITMAP */
|
2006-02-18 00:13:44 +00:00
|
|
|
|
|
|
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
|
lcd_remote_set_drawmode(DRMODE_SOLID);
|
|
|
|
|
lcd_remote_setmargins(rxm, rym);
|
|
|
|
|
lcd_remote_clear_display();
|
|
|
|
|
lcd_remote_update();
|
|
|
|
|
#endif
|
|
|
|
|
|
2005-11-10 08:07:31 +00:00
|
|
|
|
if (pfn_tsr_exit == NULL)
|
|
|
|
|
plugin_loaded = false;
|
2003-07-25 23:04:59 +00:00
|
|
|
|
|
2006-01-16 23:20:58 +00:00
|
|
|
|
sim_plugin_close(fd);
|
|
|
|
|
|
2003-06-29 16:33:04 +00:00
|
|
|
|
switch (rc) {
|
|
|
|
|
case PLUGIN_OK:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PLUGIN_USB_CONNECTED:
|
|
|
|
|
return PLUGIN_USB_CONNECTED;
|
|
|
|
|
|
|
|
|
|
default:
|
2005-11-16 15:12:15 +00:00
|
|
|
|
gui_syncsplash(HZ*2, true, str(LANG_PLUGIN_ERROR));
|
2003-06-29 16:33:04 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return PLUGIN_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2003-07-25 23:04:59 +00:00
|
|
|
|
/* Returns a pointer to the portion of the plugin buffer that is not already
|
|
|
|
|
being used. If no plugin is loaded, returns the entire plugin buffer */
|
|
|
|
|
void* plugin_get_buffer(int* buffer_size)
|
|
|
|
|
{
|
|
|
|
|
int buffer_pos;
|
|
|
|
|
|
|
|
|
|
if (plugin_loaded)
|
|
|
|
|
{
|
|
|
|
|
if (plugin_size >= PLUGIN_BUFFER_SIZE)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
*buffer_size = PLUGIN_BUFFER_SIZE-plugin_size;
|
|
|
|
|
buffer_pos = plugin_size;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*buffer_size = PLUGIN_BUFFER_SIZE;
|
|
|
|
|
buffer_pos = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return &pluginbuf[buffer_pos];
|
|
|
|
|
}
|
|
|
|
|
|
2004-01-30 22:30:40 +00:00
|
|
|
|
/* Returns a pointer to the mp3 buffer.
|
|
|
|
|
Playback gets stopped, to avoid conflicts. */
|
2005-04-05 11:33:58 +00:00
|
|
|
|
void* plugin_get_audio_buffer(int* buffer_size)
|
2004-01-30 22:30:40 +00:00
|
|
|
|
{
|
2005-04-04 12:06:29 +00:00
|
|
|
|
audio_stop();
|
2004-03-14 21:33:53 +00:00
|
|
|
|
talk_buffer_steal(); /* we use the mp3 buffer, need to tell */
|
2005-04-05 11:33:58 +00:00
|
|
|
|
*buffer_size = audiobufend - audiobuf;
|
|
|
|
|
return audiobuf;
|
2004-01-30 22:30:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-04-30 20:37:11 +00:00
|
|
|
|
/* The plugin wants to stay resident after leaving its main function, e.g.
|
|
|
|
|
runs from timer or own thread. The callback is registered to later
|
|
|
|
|
instruct it to free its resources before a new plugin gets loaded. */
|
|
|
|
|
void plugin_tsr(void (*exit_callback)(void))
|
|
|
|
|
{
|
|
|
|
|
pfn_tsr_exit = exit_callback; /* remember the callback for later */
|
|
|
|
|
}
|