blob: 1506554790ae05acbfbb893303e8a3ab07f8e6c8 [file] [log] [blame]
Björn Stenbergba371fb2003-06-29 16:33:04 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
Nicolas Pennequin357ffb32008-05-05 10:32:46 +000010 * Copyright (C) 2002 Björn Stenberg
Björn Stenbergba371fb2003-06-29 16:33:04 +000011 *
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000012 * 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.
Björn Stenbergba371fb2003-06-29 16:33:04 +000016 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
Michael Sevakis7d1a47c2013-08-05 22:02:45 -040021#define DIRFUNCTIONS_DEFINED
22#define FILEFUNCTIONS_DEFINED
Björn Stenbergba371fb2003-06-29 16:33:04 +000023#include "plugin.h"
Michael Sevakis806d8f32006-11-11 05:11:05 +000024#include <ctype.h>
25#include <string.h>
Bertrik Sikken28434692008-04-28 16:18:04 +000026#include <stdlib.h>
Michael Sevakis806d8f32006-11-11 05:11:05 +000027#include "debug.h"
Michael Sevakis466e0662006-11-11 05:47:42 +000028#include "i2c.h"
Björn Stenbergba371fb2003-06-29 16:33:04 +000029#include "lang.h"
Kevin Ferrare81aac2a2007-07-29 03:43:37 +000030#include "led.h"
Björn Stenberg0ef911d2003-07-09 22:36:23 +000031#include "keyboard.h"
Jörg Hohensohn95298a92004-01-30 22:30:40 +000032#include "backlight.h"
Linus Nielsen Feltzing6f4d7212006-03-26 22:33:25 +000033#include "sound_menu.h"
Linus Nielsen Feltzinga6142ab2004-06-10 13:29:52 +000034#include "mp3data.h"
Björn Stenbergdd265832004-06-15 22:54:37 +000035#include "powermgmt.h"
Kevin Ferraree991bee2005-11-16 15:12:15 +000036#include "splash.h"
Miika Pekkarinen202b7262006-11-11 08:00:28 +000037#include "logf.h"
Jonathan Gordona5278fa2007-07-11 05:41:23 +000038#include "option_select.h"
Steve Bavin5a78a062007-10-03 16:17:36 +000039#include "talk.h"
Frank Gevaerts0a1d3652008-09-22 19:59:00 +000040#include "version.h"
Frank Gevaerts2f8a0082008-11-01 16:14:28 +000041#include "storage.h"
Maurus Cuelenaere8fb25882009-10-29 16:52:12 +000042#include "pcmbuf.h"
Amaury Pouly081da632009-12-24 17:07:20 +000043#include "errno.h"
Tomer Shalev9e4bd412010-04-07 17:22:16 +000044#include "diacritic.h"
Michael Sevakis7d1a47c2013-08-05 22:02:45 -040045#include "pathfuncs.h"
Thomas Martitz194174a2010-08-27 00:29:50 +000046#include "load_code.h"
Michael Sevakis7d1a47c2013-08-05 22:02:45 -040047#include "file.h"
Björn Stenberg0ef911d2003-07-09 22:36:23 +000048
Jonathan Gordon9a6f4192007-02-18 05:32:06 +000049#if CONFIG_CHARGING
Hristo Kovachev14cfc652006-02-07 14:46:03 +000050#include "power.h"
51#endif
52
Björn Stenberg0ef911d2003-07-09 22:36:23 +000053#ifdef HAVE_LCD_BITMAP
Jonathan Gordon62885232006-11-19 14:11:42 +000054#include "scrollbar.h"
Michael Sevakis6689cb02007-04-10 14:18:30 +000055#include "peakmeter.h"
Linus Nielsen Feltzing250678b2005-04-25 07:42:10 +000056#include "bmp.h"
Antoine Cellerier06e6acd2006-07-19 19:47:34 +000057#include "bidi.h"
Björn Stenberg0ef911d2003-07-09 22:36:23 +000058#endif
Björn Stenbergba371fb2003-06-29 16:33:04 +000059
Tomer Shalev8c5141b2009-09-30 10:06:04 +000060#ifdef USB_ENABLE_HID
Frank Gevaertse409fba2009-07-18 12:58:29 +000061#include "usbstack/usb_hid.h"
62#endif
63
Michael Sevakis7d1a47c2013-08-05 22:02:45 -040064#define WRAPPER(_x_) _x_ ## _wrapper
Amaury Poulye5caf932010-02-11 19:15:37 +000065
Thomas Martitz35e8b142010-06-21 16:53:00 +000066#if (CONFIG_PLATFORM & PLATFORM_HOSTED)
Hardeep Sidhu48c2d0f2003-07-25 23:04:59 +000067static unsigned char pluginbuf[PLUGIN_BUFFER_SIZE];
Jens Arnold0d935ce2009-02-09 00:32:59 +000068void sim_lcd_ex_init(unsigned long (*getpixel)(int, int));
Jens Arnold6a972e02006-02-26 13:37:42 +000069void sim_lcd_ex_update_rect(int x, int y, int width, int height);
Hardeep Sidhu48c2d0f2003-07-25 23:04:59 +000070#else
71extern unsigned char pluginbuf[];
Jens Arnold43412112004-09-26 09:25:59 +000072#include "bitswap.h"
Hardeep Sidhu48c2d0f2003-07-25 23:04:59 +000073#endif
74
Linus Nielsen Feltzingecf2f7472005-06-22 02:47:54 +000075/* for actual plugins only, not for codecs */
Hardeep Sidhu48c2d0f2003-07-25 23:04:59 +000076static int plugin_size = 0;
Jonathan Gordon0218a152006-10-31 11:30:37 +000077static bool (*pfn_tsr_exit)(bool reenter) = NULL; /* TSR exit callback */
Jonathan Gordon29e259a2006-10-31 11:17:00 +000078static char current_plugin[MAX_PATH];
Thomas Martitz194174a2010-08-27 00:29:50 +000079/* NULL if no plugin is loaded, otherwise the handle that lc_open() returned */
80static void *current_plugin_handle;
Hardeep Sidhu48c2d0f2003-07-25 23:04:59 +000081
Jonathan Gordonfda7d722007-08-06 13:42:52 +000082char *plugin_get_current_filename(void);
83
Thomas Martitz95761342014-04-09 09:00:36 +020084static void* plugin_get_audio_buffer(size_t *buffer_size);
85static void plugin_release_audio_buffer(void);
86static void plugin_tsr(bool (*exit_callback)(bool));
Michael Sevakis7d1a47c2013-08-05 22:02:45 -040087
88#ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE
89/* File handle leak prophylaxis */
90#include "bitarray.h"
91#include "file_internal.h" /* for MAX_OPEN_FILES */
92
93#define PCOC_WRAPPER(_x_) WRAPPER(_x_)
94
95BITARRAY_TYPE_DECLARE(plugin_check_open_close_bitmap_t, open_files_bitmap,
96 MAX_OPEN_FILES)
97
98static plugin_check_open_close_bitmap_t open_files_bitmap;
99
100static void plugin_check_open_close__enter(void)
101{
102 if (!current_plugin_handle)
103 open_files_bitmap_clear(&open_files_bitmap);
104}
105
106static void plugin_check_open_close__open(int fildes)
107{
108 if (fildes >= 0)
109 open_files_bitmap_set_bit(&open_files_bitmap, fildes);
110}
111
112static void plugin_check_open_close__close(int fildes)
113{
114 if (fildes < 0)
115 return;
116
117 if (!open_files_bitmap_test_bit(&open_files_bitmap, fildes))
118 {
119 logf("double close from plugin");
120 }
121
122 open_files_bitmap_clear_bit(&open_files_bitmap, fildes);
123}
124
125static int WRAPPER(open)(const char *path, int oflag, ...)
126{
127 int fildes = FS_PREFIX(open)(path, oflag __OPEN_MODE_ARG);
128 plugin_check_open_close__open(fildes);
129 return fildes;
130}
131
132static int WRAPPER(creat)(const char *path, mode_t mode)
133{
134 int fildes = FS_PREFIX(creat)(path __CREAT_MODE_ARG);
135 plugin_check_open_close__open(fildes);
136 return fildes;
137 (void)mode;
138}
139
140static int WRAPPER(close)(int fildes)
141{
142 int rc = FS_PREFIX(close)(fildes);
143 if (rc >= 0)
144 plugin_check_open_close__close(fildes);
145
146 return rc;
147}
148
149static void plugin_check_open_close__exit(void)
150{
151 if (current_plugin_handle)
152 return;
153
154 if (open_files_bitmap_is_clear(&open_files_bitmap))
155 return;
156
Mihail Zenkov25fc7f12016-03-30 20:48:17 +0000157 logf("Plugin '%s' leaks file handles", current_plugin);
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400158
159 static const char *lines[] =
160 { ID2P(LANG_PLUGIN_ERROR), "#leak-file-handles" };
161 static const struct text_message message = { lines, 2 };
162 button_clear_queue(); /* Empty the keyboard buffer */
163 gui_syncyesno_run(&message, NULL, NULL);
164
165 FOR_EACH_BITARRAY_SET_BIT(&open_files_bitmap, fildes)
166 WRAPPER(close)(fildes);
167}
168
169#else /* !HAVE_PLUGIN_CHECK_OPEN_CLOSE */
170
171#define PCOC_WRAPPER(_x_) FS_PREFIX(_x_)
172#define plugin_check_open_close__enter()
173#define plugin_check_open_close__exit()
174
175#endif /* HAVE_PLUGIN_CHECK_OPEN_CLOSE */
176
Jens Arnold398e4012004-07-20 21:37:36 +0000177static const struct plugin_api rockbox_api = {
Solomon Peachy55eb1c52019-02-03 20:12:50 -0500178 rbversion,
179 &global_settings,
180 &global_status,
181 language_strings,
Björn Stenbergba371fb2003-06-29 16:33:04 +0000182
Björn Stenbergba371fb2003-06-29 16:33:04 +0000183 /* lcd */
William Wilgus6392e052019-07-20 04:46:14 -0500184 splash,
185 splashf,
Thomas Martitz1034dea2009-03-30 16:06:02 +0000186#ifdef HAVE_LCD_CONTRAST
Jens Arnold04daef12005-06-24 22:33:21 +0000187 lcd_set_contrast,
Thomas Martitz1034dea2009-03-30 16:06:02 +0000188#endif
Jens Arnold54ea2e42007-03-31 09:58:49 +0000189 lcd_update,
Björn Stenbergba371fb2003-06-29 16:33:04 +0000190 lcd_clear_display,
Jens Arnoldad4e3d62007-03-26 07:52:13 +0000191 lcd_getstringsize,
192 lcd_putsxy,
Rafaël Carréda162482010-08-30 20:47:53 +0000193 lcd_putsxyf,
Björn Stenbergba371fb2003-06-29 16:33:04 +0000194 lcd_puts,
Rafaël Carréda162482010-08-30 20:47:53 +0000195 lcd_putsf,
Björn Stenbergba371fb2003-06-29 16:33:04 +0000196 lcd_puts_scroll,
Thomas Martitz1c5d0b42013-04-03 16:33:23 +0200197 lcd_scroll_stop,
Björn Stenbergba371fb2003-06-29 16:33:04 +0000198#ifdef HAVE_LCD_CHARCELLS
199 lcd_define_pattern,
Daniel Stenbergafd70422003-07-24 09:35:32 +0000200 lcd_get_locked_pattern,
201 lcd_unlock_pattern,
202 lcd_putc,
Linus Nielsen Feltzingf4f41112004-07-27 14:10:48 +0000203 lcd_put_cursor,
204 lcd_remove_cursor,
Jens Arnold323d75d2007-04-03 18:06:13 +0000205 lcd_icon,
Linus Nielsen Feltzing60895bc2005-09-02 05:39:09 +0000206 lcd_double_height,
William Wilgus6392e052019-07-20 04:46:14 -0500207#else /* HAVE_LCD_BITMAP */
Jonathan Gordonb37e6bc2012-02-22 21:18:05 +1100208 &lcd_static_framebuffer[0][0],
Richard Quirk212e7802012-12-09 21:04:17 +0100209 lcd_set_viewport,
210 lcd_set_framebuffer,
211 lcd_bmp_part,
Jens Arnoldc84e3452008-03-24 00:45:03 +0000212 lcd_update_rect,
Jens Arnold04daef12005-06-24 22:33:21 +0000213 lcd_set_drawmode,
214 lcd_get_drawmode,
Jonathan Gordonaa0f4a42011-09-24 13:19:34 +0000215 screen_helper_setfont,
Jens Arnold04daef12005-06-24 22:33:21 +0000216 lcd_drawpixel,
217 lcd_drawline,
Jens Arnold7e11acb2005-06-28 23:15:47 +0000218 lcd_hline,
219 lcd_vline,
Jens Arnold04daef12005-06-24 22:33:21 +0000220 lcd_drawrect,
221 lcd_fillrect,
Jens Arnoldf894a4c2005-07-06 22:58:02 +0000222 lcd_mono_bitmap_part,
223 lcd_mono_bitmap,
Jens Arnolde44372e2005-07-26 20:01:11 +0000224#if LCD_DEPTH > 1
225 lcd_set_foreground,
226 lcd_get_foreground,
227 lcd_set_background,
228 lcd_get_background,
229 lcd_bitmap_part,
230 lcd_bitmap,
Michael Sevakisea255fb2007-06-22 09:34:57 +0000231 lcd_get_backdrop,
Jonathan Gordon62885232006-11-19 14:11:42 +0000232 lcd_set_backdrop,
Jens Arnolde44372e2005-07-26 20:01:11 +0000233#endif
Thomas Martitza1842c02014-06-18 07:15:00 +0200234#if LCD_DEPTH >= 16
Brandon Low413da2a2006-02-07 20:38:55 +0000235 lcd_bitmap_transparent_part,
236 lcd_bitmap_transparent,
Rafaël Carréa98c54f2009-06-21 14:09:48 +0000237#if MEMORYSIZE > 2
Jens Arnold68a21682008-03-24 00:35:53 +0000238 lcd_blit_yuv,
239#if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) || defined(SANSA_C200) \
Jens Arnold27f5cda2009-07-15 22:02:42 +0000240 || defined(IRIVER_H10) || defined(COWON_D2) || defined(PHILIPS_HDD1630) \
Rafaël Carré35500c22010-03-28 02:41:29 +0000241 || defined(SANSA_FUZE) || defined(SANSA_E200V2) || defined(SANSA_FUZEV2) \
Michael Sevakis0dd74ca2011-01-11 01:21:31 +0000242 || defined(TOSHIBA_GIGABEAT_S) || defined(PHILIPS_SA9200)
Jens Arnold68a21682008-03-24 00:35:53 +0000243 lcd_yuv_set_options,
Brandon Low413da2a2006-02-07 20:38:55 +0000244#endif
Rafaël Carréa98c54f2009-06-21 14:09:48 +0000245#endif /* MEMORYSIZE > 2 */
Thomas Martitz35e8b142010-06-21 16:53:00 +0000246#elif (LCD_DEPTH < 4) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
Jens Arnold68a21682008-03-24 00:35:53 +0000247 lcd_blit_mono,
248 lcd_blit_grey_phase,
249#endif /* LCD_DEPTH */
Andrew Mahoneeef79452009-05-06 04:53:56 +0000250#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
251 lcd_blit_pal256,
252 lcd_pal256_update_pal,
253#endif
Jonathan Gordon3e5b3892008-05-15 06:58:36 +0000254#ifdef HAVE_LCD_INVERT
255 lcd_set_invert_display,
256#endif /* HAVE_LCD_INVERT */
Andrew Mahoneeef79452009-05-06 04:53:56 +0000257#if defined(HAVE_LCD_MODES)
258 lcd_set_mode,
259#endif
Thomas Martitzb7739fb2009-03-17 02:43:47 +0000260#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
Jonathan Gordonbdbdb972008-06-23 13:20:35 +0000261 &button_queue,
262#endif
Miika Pekkarinena85044b2006-09-16 16:18:11 +0000263 bidi_l2v,
Michael Sevakisd5699982010-05-24 16:42:32 +0000264 is_diacritic,
Miika Pekkarinena85044b2006-09-16 16:18:11 +0000265 font_get_bits,
266 font_load,
Jonathan Gordonaa0f4a42011-09-24 13:19:34 +0000267 font_unload,
Jens Arnold04daef12005-06-24 22:33:21 +0000268 font_get,
Jens Arnolde44372e2005-07-26 20:01:11 +0000269 font_getstringsize,
Jens Arnolda36b1d42006-01-15 18:20:18 +0000270 font_get_width,
Jonathan Gordonfda7d722007-08-06 13:42:52 +0000271 screen_clear_area,
Jens Arnold68a21682008-03-24 00:35:53 +0000272 gui_scrollbar_draw,
Michael Sevakis8cfbd362008-12-10 08:57:10 +0000273#endif /* HAVE_LCD_BITMAP */
Frank Gevaerts859f7622019-07-20 22:06:30 +0200274 get_codepage_name,
Jens Arnold68a21682008-03-24 00:35:53 +0000275
Christian Gmeinerc63430e2005-04-15 12:55:31 +0000276#ifdef HAVE_REMOTE_LCD
Jens Arnold4c7da882005-06-18 01:25:47 +0000277 /* remote lcd */
Jens Arnold576908d2005-06-29 01:39:50 +0000278 lcd_remote_set_contrast,
Linus Nielsen Feltzing250678b2005-04-25 07:42:10 +0000279 lcd_remote_clear_display,
Christian Gmeiner7d984812005-04-25 23:47:51 +0000280 lcd_remote_puts,
281 lcd_remote_puts_scroll,
Thomas Martitz1c5d0b42013-04-03 16:33:23 +0200282 lcd_remote_scroll_stop,
Jens Arnold576908d2005-06-29 01:39:50 +0000283 lcd_remote_set_drawmode,
284 lcd_remote_get_drawmode,
285 lcd_remote_setfont,
286 lcd_remote_getstringsize,
287 lcd_remote_drawpixel,
288 lcd_remote_drawline,
289 lcd_remote_hline,
290 lcd_remote_vline,
291 lcd_remote_drawrect,
292 lcd_remote_fillrect,
Jens Arnoldd7f94392005-07-07 00:05:29 +0000293 lcd_remote_mono_bitmap_part,
294 lcd_remote_mono_bitmap,
Christian Gmeiner7d984812005-04-25 23:47:51 +0000295 lcd_remote_putsxy,
Jonathan Gordonb37e6bc2012-02-22 21:18:05 +1100296 &lcd_remote_static_framebuffer[0][0],
Christian Gmeiner7d984812005-04-25 23:47:51 +0000297 lcd_remote_update,
298 lcd_remote_update_rect,
William Wilgus6392e052019-07-20 04:46:14 -0500299#if (LCD_REMOTE_DEPTH > 1)
Miika Pekkarinena85044b2006-09-16 16:18:11 +0000300 lcd_remote_set_foreground,
301 lcd_remote_get_foreground,
302 lcd_remote_set_background,
303 lcd_remote_get_background,
304 lcd_remote_bitmap_part,
305 lcd_remote_bitmap,
306#endif
William Wilgus6392e052019-07-20 04:46:14 -0500307#endif /* HAVE_REMOTE_LCD */
308#if NB_SCREENS == 2
309 {&screens[SCREEN_MAIN], &screens[SCREEN_REMOTE]},
310#else
311 {&screens[SCREEN_MAIN]},
312#endif
313
Jonathan Gordon5ca15392008-03-26 03:35:24 +0000314 viewport_set_defaults,
Jonathan Gordon1c2aa352010-02-14 06:26:16 +0000315#ifdef HAVE_LCD_BITMAP
316 viewportmanager_theme_enable,
317 viewportmanager_theme_undo,
Richard Quirk212e7802012-12-09 21:04:17 +0100318 viewport_set_fullscreen,
Jonathan Gordon1c2aa352010-02-14 06:26:16 +0000319#endif
Solomon Peachy55eb1c52019-02-03 20:12:50 -0500320
William Wilgus6392e052019-07-20 04:46:14 -0500321 /* lcd backlight */
322 /* The backlight_* functions must be present in the API regardless whether
323 * HAVE_BACKLIGHT is defined or not. The reason is that the stock Ondio has
324 * no backlight but can be modded to have backlight (it's prepared on the
325 * PCB). This makes backlight an all-target feature API wise, and keeps API
326 * compatible between stock and modded Ondio.
327 * For OLED targets like the Sansa Clip, the backlight_* functions control
328 * the display enable, which has essentially the same effect. */
329 is_backlight_on,
330 backlight_on,
331 backlight_off,
332 backlight_set_timeout,
333#ifdef HAVE_BACKLIGHT_BRIGHTNESS
334 backlight_set_brightness,
335#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
336
337#if CONFIG_CHARGING
338 backlight_set_timeout_plugged,
339#endif
340
341#ifdef HAVE_REMOTE_LCD
342 remote_backlight_on,
343 remote_backlight_off,
344 remote_backlight_set_timeout,
345#if CONFIG_CHARGING
346 remote_backlight_set_timeout_plugged,
347#endif
348#endif /* HAVE_REMOTE_LCD */
349
Miika Pekkarinena85044b2006-09-16 16:18:11 +0000350 /* list */
351 gui_synclist_init,
352 gui_synclist_set_nb_items,
Solomon Peachy55eb1c52019-02-03 20:12:50 -0500353 gui_synclist_set_voice_callback,
Miika Pekkarinena85044b2006-09-16 16:18:11 +0000354 gui_synclist_set_icon_callback,
355 gui_synclist_get_nb_items,
356 gui_synclist_get_sel_pos,
357 gui_synclist_draw,
Solomon Peachy55eb1c52019-02-03 20:12:50 -0500358 gui_synclist_speak_item,
Miika Pekkarinena85044b2006-09-16 16:18:11 +0000359 gui_synclist_select_item,
Miika Pekkarinena85044b2006-09-16 16:18:11 +0000360 gui_synclist_add_item,
361 gui_synclist_del_item,
362 gui_synclist_limit_scroll,
Miika Pekkarinena85044b2006-09-16 16:18:11 +0000363 gui_synclist_do_button,
Peter D'Hoye0f02e4f2006-11-30 22:29:48 +0000364 gui_synclist_set_title,
Bertrik Sikken9464fdd2008-08-14 22:35:00 +0000365 gui_syncyesno_run,
Jonathan Gordonbdbdb972008-06-23 13:20:35 +0000366 simplelist_info_init,
367 simplelist_show_list,
Michael Sevakis6aa12c12006-10-14 01:32:58 +0000368
William Wilgus6392e052019-07-20 04:46:14 -0500369 /* action handling */
370 get_custom_action,
371 get_action,
372#ifdef HAVE_TOUCHSCREEN
373 action_get_touchscreen_press,
374#endif
375 action_userabort,
376
Björn Stenbergba371fb2003-06-29 16:33:04 +0000377 /* button */
378 button_get,
379 button_get_w_tmo,
Linus Nielsen Feltzingf4f41112004-07-27 14:10:48 +0000380 button_status,
Jonathan Gordon3e5b3892008-05-15 06:58:36 +0000381#ifdef HAVE_BUTTON_DATA
382 button_get_data,
Thomas Martitzd85c3ec2009-10-20 21:54:59 +0000383 button_status_wdata,
Jonathan Gordon3e5b3892008-05-15 06:58:36 +0000384#endif
Linus Nielsen Feltzingf4f41112004-07-27 14:10:48 +0000385 button_clear_queue,
Michael Sevakisa9b2fb52007-10-16 01:25:17 +0000386 button_queue_count,
Zakk Roberts07fcf772006-05-01 05:45:18 +0000387#ifdef HAS_BUTTON_HOLD
Jens Arnold4c7da882005-06-18 01:25:47 +0000388 button_hold,
389#endif
Maurus Cuelenaere1392dc22008-08-23 09:46:38 +0000390#ifdef HAVE_TOUCHSCREEN
391 touchscreen_set_mode,
Thomas Martitzb8439f22012-01-26 23:37:27 +0100392 touchscreen_get_mode,
Jonathan Gordon3e5b3892008-05-15 06:58:36 +0000393#endif
Solomon Peachy55eb1c52019-02-03 20:12:50 -0500394
Jonathan Gordon3e5b3892008-05-15 06:58:36 +0000395#ifdef HAVE_BUTTON_LIGHT
396 buttonlight_set_timeout,
397 buttonlight_off,
398 buttonlight_on,
399#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
400 buttonlight_set_brightness,
401#endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
402#endif /* HAVE_BUTTON_LIGHT */
Björn Stenbergba371fb2003-06-29 16:33:04 +0000403
404 /* file */
Jonathan Gordon1c2aa352010-02-14 06:26:16 +0000405 open_utf8,
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400406 PCOC_WRAPPER(open),
407 PCOC_WRAPPER(creat),
408 PCOC_WRAPPER(close),
409 FS_PREFIX(read),
410 FS_PREFIX(lseek),
411 FS_PREFIX(write),
412 FS_PREFIX(remove),
413 FS_PREFIX(rename),
414 FS_PREFIX(ftruncate),
415 FS_PREFIX(filesize),
Daniel Stenberg22b77012005-02-22 12:19:12 +0000416 fdprintf,
Björn Stenbergba371fb2003-06-29 16:33:04 +0000417 read_line,
Linus Nielsen Feltzingf4f41112004-07-27 14:10:48 +0000418 settings_parseline,
Frank Gevaerts2f8a0082008-11-01 16:14:28 +0000419 storage_sleep,
420 storage_spin,
421 storage_spindown,
422#if USING_STORAGE_CALLBACK
423 register_storage_idle_func,
424 unregister_storage_idle_func,
425#endif /* USING_STORAGE_CALLBACK */
Miika Pekkarinena85044b2006-09-16 16:18:11 +0000426 reload_directory,
Michael Sevakisea255fb2007-06-22 09:34:57 +0000427 create_numbered_filename,
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400428 FS_PREFIX(file_exists),
Thomas Martitz54810902009-02-11 16:37:12 +0000429 strip_extension,
Jonathan Gordon1c2aa352010-02-14 06:26:16 +0000430 crc_32,
Michael Sevakis2da0f9b2011-01-20 17:11:23 +0000431 filetype_get_attr,
Björn Stenbergba371fb2003-06-29 16:33:04 +0000432
433 /* dir */
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400434 FS_PREFIX(opendir),
435 FS_PREFIX(closedir),
436 FS_PREFIX(readdir),
437 FS_PREFIX(mkdir),
438 FS_PREFIX(rmdir),
439 FS_PREFIX(dir_exists),
Nils Wallménius8123dff2010-10-16 12:30:06 +0000440 dir_get_info,
Björn Stenbergba371fb2003-06-29 16:33:04 +0000441
Michael Sevakis2da0f9b2011-01-20 17:11:23 +0000442 /* browsing */
443 browse_context_init,
444 rockbox_browse,
William Wilgus6392e052019-07-20 04:46:14 -0500445 tree_get_context,
446 tree_get_entries,
447 tree_get_entry_at,
448 set_current_file,
449 set_dirfilter,
Michael Sevakis2da0f9b2011-01-20 17:11:23 +0000450
Solomon Peachy55eb1c52019-02-03 20:12:50 -0500451 /* talking */
452 talk_id,
453 talk_file,
454 talk_file_or_spell,
455 talk_dir_or_spell,
456 talk_number,
457 talk_value,
458 talk_spell,
459 talk_time,
460 talk_date,
461 talk_disable,
462 talk_shutup,
463 talk_force_shutup,
464 talk_force_enqueue_next,
465
Jens Arnold1c841b82004-10-23 09:59:53 +0000466 /* kernel/ system */
Rafaël Carré851be212010-08-03 19:00:29 +0000467#if defined(CPU_ARM) && CONFIG_PLATFORM & PLATFORM_NATIVE
Thomas Martitz54810902009-02-11 16:37:12 +0000468 __div0,
469#endif
Thomas Martitz6eaab4d2010-09-01 21:29:34 +0000470 sleep,
Linus Nielsen Feltzingf4f41112004-07-27 14:10:48 +0000471 yield,
Björn Stenbergba371fb2003-06-29 16:33:04 +0000472 &current_tick,
Linus Nielsen Feltzingf4f41112004-07-27 14:10:48 +0000473 default_event_handler,
Jens Arnold1c841b82004-10-23 09:59:53 +0000474 default_event_handler_ex,
Linus Nielsen Feltzingf4f41112004-07-27 14:10:48 +0000475 create_thread,
Michael Sevakis56dd75d2011-03-16 05:38:37 +0000476 thread_self,
Michael Sevakis27cf6772008-03-25 02:34:12 +0000477 thread_exit,
Jens Arnold68a21682008-03-24 00:35:53 +0000478 thread_wait,
479#if (CONFIG_CODEC == SWCODEC)
Michael Sevakis20546272009-01-05 10:31:19 +0000480 thread_thaw,
481#ifdef HAVE_PRIORITY_SCHEDULING
482 thread_set_priority,
483#endif
Jens Arnold68a21682008-03-24 00:35:53 +0000484 mutex_init,
485 mutex_lock,
486 mutex_unlock,
Jens Arnold68a21682008-03-24 00:35:53 +0000487#endif
William Wilgus6392e052019-07-20 04:46:14 -0500488#ifdef HAVE_SEMAPHORE_OBJECTS
489 semaphore_init,
490 semaphore_wait,
491 semaphore_release,
492#endif
Linus Nielsen Feltzing70de4ec2004-07-27 19:16:58 +0000493 reset_poweroff_timer,
William Wilgus6392e052019-07-20 04:46:14 -0500494 set_sleeptimer_duration, /*stub*/
495 get_sleep_timer, /*stub*/
Thomas Martitz35e8b142010-06-21 16:53:00 +0000496#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
Jens Arnold1c841b82004-10-23 09:59:53 +0000497 system_memory_guard,
Jens Arnold4c7da882005-06-18 01:25:47 +0000498 &cpu_frequency,
Jonathan Gordonf8c68c72007-01-22 10:41:25 +0000499
Jens Arnold4c7da882005-06-18 01:25:47 +0000500#ifdef HAVE_ADJUSTABLE_CPU_FREQ
Jonathan Gordonf8c68c72007-01-22 10:41:25 +0000501#ifdef CPU_BOOST_LOGGING
502 cpu_boost_,
503#else
Jens Arnold4c7da882005-06-18 01:25:47 +0000504 cpu_boost,
505#endif
Jens Arnold68a21682008-03-24 00:35:53 +0000506#endif /* HAVE_ADJUSTABLE_CPU_FREQ */
Thomas Martitz35e8b142010-06-21 16:53:00 +0000507#endif /* PLATFORM_NATIVE */
Jens Arnold68a21682008-03-24 00:35:53 +0000508#ifdef HAVE_SCHEDULER_BOOSTCTRL
509 trigger_cpu_boost,
510 cancel_cpu_boost,
Jonathan Gordonf8c68c72007-01-22 10:41:25 +0000511#endif
Nils Wallménius8123dff2010-10-16 12:30:06 +0000512
Michael Sevakis6a677072011-12-17 07:27:24 +0000513 commit_dcache,
514 commit_discard_dcache,
Thomas Martitzc6d69ae2012-01-27 09:31:34 +0100515 commit_discard_idcache,
Nils Wallménius8123dff2010-10-16 12:30:06 +0000516
517 lc_open,
518 lc_open_from_mem,
519 lc_get_header,
520 lc_close,
521
Jens Arnolde44372e2005-07-26 20:01:11 +0000522 timer_register,
523 timer_unregister,
524 timer_set_period,
Kevin Ferrare81aac2a2007-07-29 03:43:37 +0000525
Brandon Low413da2a2006-02-07 20:38:55 +0000526 queue_init,
527 queue_delete,
528 queue_post,
529 queue_wait_w_tmo,
Jens Arnold68a21682008-03-24 00:35:53 +0000530#if CONFIG_CODEC == SWCODEC
531 queue_enable_queue_send,
532 queue_empty,
533 queue_wait,
534 queue_send,
535 queue_reply,
536#endif
William Wilgus6392e052019-07-20 04:46:14 -0500537
Brandon Low413da2a2006-02-07 20:38:55 +0000538#ifdef RB_PROFILE
539 profile_thread,
540 profstop,
Michael Giacomelli52bdcba2008-07-28 22:43:41 +0000541 __cyg_profile_func_enter,
542 __cyg_profile_func_exit,
Brandon Low413da2a2006-02-07 20:38:55 +0000543#endif
Thomas Martitzd85c3ec2009-10-20 21:54:59 +0000544 add_event,
545 remove_event,
546 send_event,
Björn Stenbergba371fb2003-06-29 16:33:04 +0000547
Thomas Martitz35e8b142010-06-21 16:53:00 +0000548#if (CONFIG_PLATFORM & PLATFORM_HOSTED)
Jens Arnold06bc6272006-03-11 09:28:49 +0000549 /* special simulator hooks */
550#if defined(HAVE_LCD_BITMAP) && LCD_DEPTH < 8
551 sim_lcd_ex_init,
552 sim_lcd_ex_update_rect,
553#endif
554#endif
555
Björn Stenbergba371fb2003-06-29 16:33:04 +0000556 /* strings and memory */
557 snprintf,
Miika Pekkarinena85044b2006-09-16 16:18:11 +0000558 vsnprintf,
Björn Stenbergba371fb2003-06-29 16:33:04 +0000559 strcpy,
Nils Wallménius3d4701a2009-07-14 13:57:45 +0000560 strlcpy,
Björn Stenbergba371fb2003-06-29 16:33:04 +0000561 strlen,
Linus Nielsen Feltzinga96a1302004-07-13 14:14:30 +0000562 strrchr,
Linus Nielsen Feltzingf4f41112004-07-27 14:10:48 +0000563 strcmp,
Jens Arnolde44372e2005-07-26 20:01:11 +0000564 strncmp,
Linus Nielsen Feltzingf4f41112004-07-27 14:10:48 +0000565 strcasecmp,
Jens Arnold1c841b82004-10-23 09:59:53 +0000566 strncasecmp,
Björn Stenbergba371fb2003-06-29 16:33:04 +0000567 memset,
568 memcpy,
Brandon Low413da2a2006-02-07 20:38:55 +0000569 memmove,
Thomas Martitz35e8b142010-06-21 16:53:00 +0000570#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
Linus Nielsen Feltzing0c458c02004-07-13 14:01:41 +0000571 _ctype_,
Thomas Martitz3cca7e82010-05-14 12:37:05 +0000572#endif
Linus Nielsen Feltzing70de4ec2004-07-27 19:16:58 +0000573 atoi,
Daniel Stenberg22b77012005-02-22 12:19:12 +0000574 strchr,
575 strcat,
Jonathan Gordon1c2aa352010-02-14 06:26:16 +0000576 strlcat,
Miika Pekkarinena85044b2006-09-16 16:18:11 +0000577 memchr,
Daniel Stenberg22b77012005-02-22 12:19:12 +0000578 memcmp,
Jens Arnold4c7da882005-06-18 01:25:47 +0000579 strcasestr,
Jonathan Gordon29e259a2006-10-31 11:17:00 +0000580 strtok_r,
Jens Arnolda36b1d42006-01-15 18:20:18 +0000581 /* unicode stuff */
582 utf8decode,
583 iso_decode,
584 utf16LEdecode,
585 utf16BEdecode,
586 utf8encode,
587 utf8length,
Miika Pekkarinena85044b2006-09-16 16:18:11 +0000588 utf8seek,
Solomon Peachy55eb1c52019-02-03 20:12:50 -0500589
Thomas Martitza13e9642011-10-17 18:28:35 +0000590 /* the buflib memory management library */
591 buflib_init,
592 buflib_available,
593 buflib_alloc,
594 buflib_alloc_ex,
595 buflib_alloc_maximum,
596 buflib_buffer_in,
597 buflib_buffer_out,
598 buflib_free,
599 buflib_shrink,
600 buflib_get_data,
601 buflib_get_name,
Björn Stenbergba371fb2003-06-29 16:33:04 +0000602
603 /* sound */
Linus Nielsen Feltzing674eaca2005-04-01 13:41:03 +0000604 sound_set,
William Wilgus6392e052019-07-20 04:46:14 -0500605 sound_current, /*stub*/
Jens Arnold68a21682008-03-24 00:35:53 +0000606 sound_default,
Jens Arnolda36b1d42006-01-15 18:20:18 +0000607 sound_min,
608 sound_max,
Jens Arnold68a21682008-03-24 00:35:53 +0000609 sound_unit,
610 sound_val2phys,
Michael Sevakisd5699982010-05-24 16:42:32 +0000611#ifdef AUDIOHW_HAVE_EQ
612 sound_enum_hw_eq_band_setting,
613#endif
William Wilgus6392e052019-07-20 04:46:14 -0500614#if ((CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) || \
615 (CONFIG_CODEC == SWCODEC)) && defined (HAVE_PITCHCONTROL)
616 sound_set_pitch,
617#endif
Thomas Martitz35e8b142010-06-21 16:53:00 +0000618#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
Jörg Hohensohn95298a92004-01-30 22:30:40 +0000619 mp3_play_data,
620 mp3_play_pause,
621 mp3_play_stop,
622 mp3_is_playing,
Jens Arnoldd6c05452005-08-29 21:15:27 +0000623#if CONFIG_CODEC != SWCODEC
Jörg Hohensohn95298a92004-01-30 22:30:40 +0000624 bitswap,
Jörg Hohensohnfacfec02004-02-03 23:56:25 +0000625#endif
Dave Chapmanfd8bac82007-01-01 13:21:19 +0000626#endif
Jens Arnoldd6c05452005-08-29 21:15:27 +0000627#if CONFIG_CODEC == SWCODEC
Michael Sevakis6689cb02007-04-10 14:18:30 +0000628 &audio_master_sampr_list[0],
629 &hw_freq_sampr[0],
Michael Sevakis6689cb02007-04-10 14:18:30 +0000630 pcm_apply_settings,
Zakk Roberts07fcf772006-05-01 05:45:18 +0000631 pcm_play_data,
Jens Arnold4c7da882005-06-18 01:25:47 +0000632 pcm_play_stop,
633 pcm_set_frequency,
634 pcm_is_playing,
Michael Sevakis6689cb02007-04-10 14:18:30 +0000635 pcm_is_paused,
Jens Arnold4c7da882005-06-18 01:25:47 +0000636 pcm_play_pause,
Michael Sevakis6689cb02007-04-10 14:18:30 +0000637 pcm_get_bytes_waiting,
Jens Arnolddae698c2006-03-11 09:38:12 +0000638 pcm_calculate_peaks,
Frank Gevaerts43264a92010-02-10 19:44:11 +0000639 pcm_get_peak_buffer,
Jens Arnold68a21682008-03-24 00:35:53 +0000640 pcm_play_lock,
641 pcm_play_unlock,
Michael Sevakisa2b67032011-06-29 06:37:04 +0000642 beep_play,
Michael Sevakis6689cb02007-04-10 14:18:30 +0000643#ifdef HAVE_RECORDING
644 &rec_freq_sampr[0],
Michael Sevakis6689cb02007-04-10 14:18:30 +0000645 pcm_init_recording,
646 pcm_close_recording,
647 pcm_record_data,
Michael Sevakis6689cb02007-04-10 14:18:30 +0000648 pcm_stop_recording,
649 pcm_calculate_rec_peaks,
650 audio_set_recording_gain,
Michael Sevakis6689cb02007-04-10 14:18:30 +0000651#endif /* HAVE_RECORDING */
Michael Sevakis2d48d0f2007-06-08 23:42:04 +0000652#if INPUT_SRC_CAPS != 0
653 audio_set_output_source,
654 audio_set_input_source,
Jens Arnolddae698c2006-03-11 09:38:12 +0000655#endif
Bertrik Sikkenafc96082012-05-01 03:58:27 -0400656 dsp_set_crossfeed_type ,
Michael Sevakisc9bcbe22012-03-27 19:52:15 -0400657 dsp_eq_enable,
Jens Arnold68a21682008-03-24 00:35:53 +0000658 dsp_dither_enable,
Nils Wallméniusd29a11b2012-05-08 16:34:26 +0200659#ifdef HAVE_PITCHCONTROL
Michael Sevakisc9bcbe22012-03-27 19:52:15 -0400660 dsp_set_timestretch,
661#endif
Jens Arnold68a21682008-03-24 00:35:53 +0000662 dsp_configure,
Michael Sevakisc9bcbe22012-03-27 19:52:15 -0400663 dsp_get_config,
Jens Arnold68a21682008-03-24 00:35:53 +0000664 dsp_process,
Jens Arnold4c7da882005-06-18 01:25:47 +0000665
Thomas Martitz589879b2011-08-03 09:52:23 +0000666 mixer_channel_status,
667 mixer_channel_get_buffer,
668 mixer_channel_calculate_peaks,
669 mixer_channel_play_data,
670 mixer_channel_play_pause,
671 mixer_channel_stop,
672 mixer_channel_set_amplitude,
673 mixer_channel_get_bytes_waiting,
Richard Quirk212e7802012-12-09 21:04:17 +0100674 mixer_channel_set_buffer_hook,
Thomas Martitz1fc19042013-12-14 23:15:45 +0100675 mixer_set_frequency,
676 mixer_get_frequency,
Thomas Martitz589879b2011-08-03 09:52:23 +0000677
Solomon Peachy55eb1c52019-02-03 20:12:50 -0500678 pcmbuf_fade,
Thomas Martitz589879b2011-08-03 09:52:23 +0000679 system_sound_play,
680 keyclick_click,
Michael Sevakisc9bcbe22012-03-27 19:52:15 -0400681#endif /* CONFIG_CODEC == SWCODEC */
William Wilgus6392e052019-07-20 04:46:14 -0500682
683#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
684 peak_meter_scale_value,
685 peak_meter_set_use_dbfs,
686 peak_meter_get_use_dbfs,
687#endif
688
689
690 /* metadata */
691 get_metadata,
692 mp3info,
693 count_mp3_frames,
694 create_xing_header,
695 find_next_frame,
696#ifdef HAVE_TAGCACHE
697 tagcache_search,
698 tagcache_search_set_uniqbuf,
699 tagcache_search_add_filter,
700 tagcache_get_next,
701 tagcache_retrieve,
702 tagcache_search_finish,
703 tagcache_get_numeric,
704#if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE)
705 tagcache_fill_tags,
706#endif
707#endif /* HAVE_TAGCACHE */
708
709#ifdef HAVE_ALBUMART
710 search_albumart_files,
711#endif
712
Linus Nielsen Feltzingf4f41112004-07-27 14:10:48 +0000713 /* playback control */
Michael Sevakis6689cb02007-04-10 14:18:30 +0000714 playlist_amount,
715 playlist_resume,
Richard Quirk212e7802012-12-09 21:04:17 +0100716 playlist_resume_track,
Michael Sevakis6689cb02007-04-10 14:18:30 +0000717 playlist_start,
Andrew Mahonec1c3d052009-06-01 21:08:49 +0000718 playlist_add,
719 playlist_sync,
720 playlist_remove_all_tracks,
721 playlist_create,
722 playlist_insert_track,
Jonathan Gordonf1034e02009-07-05 18:07:58 +0000723 playlist_insert_directory,
Andrew Mahonec1c3d052009-06-01 21:08:49 +0000724 playlist_shuffle,
Thomas Martitz6eaab4d2010-09-01 21:29:34 +0000725 audio_play,
Linus Nielsen Feltzing8a237a82005-04-04 12:06:29 +0000726 audio_stop,
727 audio_pause,
728 audio_resume,
729 audio_next,
730 audio_prev,
731 audio_ff_rewind,
732 audio_next_track,
Linus Nielsen Feltzing8a237a82005-04-04 12:06:29 +0000733 audio_status,
Linus Nielsen Feltzing8a237a82005-04-04 12:06:29 +0000734 audio_current_track,
735 audio_flush_and_reload_tracks,
736 audio_get_file_pos,
Jens Arnoldd6c05452005-08-29 21:15:27 +0000737#if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
Linus Nielsen Feltzing78c829f2005-04-25 08:21:10 +0000738 mpeg_get_last_header,
Linus Nielsen Feltzingef73c2e2005-04-25 08:59:19 +0000739#endif
Linus Nielsen Feltzingf4f41112004-07-27 14:10:48 +0000740
Jens Arnoldd6c05452005-08-29 21:15:27 +0000741#if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
Linus Nielsen Feltzing70de4ec2004-07-27 19:16:58 +0000742 /* MAS communication */
Linus Nielsen Feltzing8fc5b782004-06-10 13:48:53 +0000743 mas_readmem,
744 mas_writemem,
745 mas_readreg,
746 mas_writereg,
Jens Arnoldd6c05452005-08-29 21:15:27 +0000747#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
Linus Nielsen Feltzing8fc5b782004-06-10 13:48:53 +0000748 mas_codec_writereg,
Linus Nielsen Feltzing70de4ec2004-07-27 19:16:58 +0000749 mas_codec_readreg,
Miika Pekkarinena85044b2006-09-16 16:18:11 +0000750 i2c_begin,
751 i2c_end,
752 i2c_write,
Linus Nielsen Feltzing8fc5b782004-06-10 13:48:53 +0000753#endif
Jens Arnoldd6c05452005-08-29 21:15:27 +0000754#endif /* !SIMULATOR && CONFIG_CODEC != SWCODEC */
Linus Nielsen Feltzing70de4ec2004-07-27 19:16:58 +0000755
Jens Arnolda36b1d42006-01-15 18:20:18 +0000756 /* menu */
Solomon Peachy55eb1c52019-02-03 20:12:50 -0500757 root_menu_get_options,
Jonathan Gordon34521462007-03-07 13:00:46 +0000758 do_menu,
Solomon Peachy55eb1c52019-02-03 20:12:50 -0500759 root_menu_set_default,
760 root_menu_write_to_cfg,
761 root_menu_load_from_cfg,
762
Jonathan Gordon77a458a2007-05-08 11:55:43 +0000763 /* statusbars */
764 &statusbars,
765 gui_syncstatusbar_draw,
Yoshihisa Uchidae5a25762010-07-07 11:35:30 +0000766
Jonathan Gordon77a458a2007-05-08 11:55:43 +0000767 /* options */
Michael Sevakis8cfbd362008-12-10 08:57:10 +0000768 get_settings_list,
Jonathan Gordona5278fa2007-07-11 05:41:23 +0000769 find_setting,
Solomon Peachy55eb1c52019-02-03 20:12:50 -0500770 settings_save,
Jonathan Gordona5278fa2007-07-11 05:41:23 +0000771 option_screen,
Hristo Kovachevf53f64a2006-03-21 09:36:13 +0000772 set_option,
Michael Sevakisea255fb2007-06-22 09:34:57 +0000773 set_bool_options,
Miika Pekkarinena85044b2006-09-16 16:18:11 +0000774 set_int,
Solomon Peachy55eb1c52019-02-03 20:12:50 -0500775 set_int_ex,
Miika Pekkarinena85044b2006-09-16 16:18:11 +0000776 set_bool,
Michael Sevakisea255fb2007-06-22 09:34:57 +0000777#ifdef HAVE_LCD_COLOR
778 set_color,
779#endif
Jens Arnolda36b1d42006-01-15 18:20:18 +0000780
Brandon Low413da2a2006-02-07 20:38:55 +0000781 /* power */
782 battery_level,
783 battery_level_safe,
784 battery_time,
Zakk Roberts07fcf772006-05-01 05:45:18 +0000785 battery_voltage,
Jonathan Gordon9a6f4192007-02-18 05:32:06 +0000786#if CONFIG_CHARGING
Brandon Low413da2a2006-02-07 20:38:55 +0000787 charger_inserted,
Bertrik Sikken52d29802009-03-24 21:59:44 +0000788# if CONFIG_CHARGING >= CHARGING_MONITOR
Brandon Low413da2a2006-02-07 20:38:55 +0000789 charging_state,
790# endif
791#endif
William Wilgus6392e052019-07-20 04:46:14 -0500792 /* usb */
Amaury Poulydc127f22015-01-02 22:15:31 +0100793 usb_inserted,
William Wilgus6392e052019-07-20 04:46:14 -0500794 usb_acknowledge,
795#ifdef USB_ENABLE_HID
796 usb_hid_send,
797#endif
Linus Nielsen Feltzing70de4ec2004-07-27 19:16:58 +0000798 /* misc */
Thomas Martitz35e8b142010-06-21 16:53:00 +0000799#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
Michael Sevakis355b5402014-04-28 09:15:06 -0400800 __errno,
Jonathan Gordon1c2aa352010-02-14 06:26:16 +0000801#endif
Linus Nielsen Feltzing70de4ec2004-07-27 19:16:58 +0000802 srand,
803 rand,
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400804 (void *)qsort,
Linus Nielsen Feltzing70de4ec2004-07-27 19:16:58 +0000805 kbd_input,
806 get_time,
Björn Stenbergc05b7d72004-06-16 19:35:20 +0000807 set_time,
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400808 gmtime_r,
Tom Rosse1147b82007-07-30 05:19:05 +0000809#if CONFIG_RTC
810 mktime,
811#endif
William Wilgus6392e052019-07-20 04:46:14 -0500812
Linus Nielsen Feltzing70de4ec2004-07-27 19:16:58 +0000813#if defined(DEBUG) || defined(SIMULATOR)
814 debugf,
815#endif
Jens Arnolde44372e2005-07-26 20:01:11 +0000816#ifdef ROCKBOX_HAS_LOGF
Miika Pekkarinen202b7262006-11-11 08:00:28 +0000817 _logf,
Jens Arnolde44372e2005-07-26 20:01:11 +0000818#endif
Michael Sevakisa9b2fb52007-10-16 01:25:17 +0000819#if CONFIG_CODEC == SWCODEC
Michael Sevakis20546272009-01-05 10:31:19 +0000820 codec_thread_do_callback,
Michael Sevakisa9b2fb52007-10-16 01:25:17 +0000821 codec_load_file,
Michael Sevakisc537d592011-04-27 03:08:23 +0000822 codec_run_proc,
Michael Sevakis65109732011-02-23 14:31:13 +0000823 codec_close,
Michael Sevakisa9b2fb52007-10-16 01:25:17 +0000824 get_codec_filename,
Michael Sevakisd5699982010-05-24 16:42:32 +0000825 find_array_ptr,
826 remove_array_ptr,
Michael Sevakisd5699982010-05-24 16:42:32 +0000827 round_value_to_list32,
Michael Sevakisd5699982010-05-24 16:42:32 +0000828#endif /* CONFIG_CODEC == SWCODEC */
William Wilgus6392e052019-07-20 04:46:14 -0500829
Linus Nielsen Feltzing250678b2005-04-25 07:42:10 +0000830#ifdef HAVE_LCD_BITMAP
831 read_bmp_file,
Andrew Mahoneeef79452009-05-06 04:53:56 +0000832 read_bmp_fd,
833#ifdef HAVE_JPEG
834 read_jpeg_file,
835 read_jpeg_fd,
836#endif
Jens Arnolda36b1d42006-01-15 18:20:18 +0000837 screen_dump_set_hook,
Linus Nielsen Feltzing250678b2005-04-25 07:42:10 +0000838#endif
Linus Nielsen Feltzing60895bc2005-09-02 05:39:09 +0000839 show_logo,
Jens Arnold4c7da882005-06-18 01:25:47 +0000840
Dave Chapman491458e2006-09-26 19:25:52 +0000841#ifdef HAVE_WHEEL_POSITION
842 wheel_status,
843 wheel_send_events,
844#endif
Jonathan Gordon29e259a2006-10-31 11:17:00 +0000845
Miika Pekkarinen0ea4d312007-01-12 18:34:00 +0000846#ifdef IRIVER_H100_SERIES
847 /* Routines for the iriver_flash -plugin. */
848 detect_original_firmware,
849 detect_flashed_ramimage,
850 detect_flashed_romimage,
851#endif
Michael Sevakisa9b2fb52007-10-16 01:25:17 +0000852 led,
Nicolas Pennequin90ce8262007-12-09 18:48:02 +0000853
William Wilgus6392e052019-07-20 04:46:14 -0500854 /*plugin*/
855 plugin_get_buffer,
856 plugin_get_audio_buffer, /* defined in plugin.c */
857 plugin_release_audio_buffer, /* defined in plugin.c */
858 plugin_tsr, /* defined in plugin.c */
859 plugin_get_current_filename,
860#ifdef PLUGIN_USE_IRAM
861 audio_hard_stop,
Jonathan Gordon468edbb2008-09-23 09:59:06 +0000862#endif
Michael Sevakiseffceea2008-10-23 13:13:00 +0000863
Jens Arnold68a21682008-03-24 00:35:53 +0000864 /* new stuff at the end, sort into place next time
Jonathan Gordon8358dff2008-06-24 10:20:22 +0000865 the API gets incompatible */
Björn Stenbergba371fb2003-06-29 16:33:04 +0000866};
867
Thomas Martitz22e802e2013-05-30 11:24:16 +0200868static int plugin_buffer_handle;
Michael Sevakis81f5a222017-10-14 05:59:09 -0400869static size_t plugin_buffer_size;
Thomas Martitz22e802e2013-05-30 11:24:16 +0200870
Steve Bavin65265772008-05-13 09:57:56 +0000871int plugin_load(const char* plugin, const void* parameter)
Björn Stenbergba371fb2003-06-29 16:33:04 +0000872{
Thomas Martitz0d4585b2010-09-09 16:17:21 +0000873 struct plugin_header *p_hdr;
874 struct lc_header *hdr;
Karl Kurbjund6b0c972006-11-15 06:14:27 +0000875
Thomas Martitz194174a2010-08-27 00:29:50 +0000876 if (current_plugin_handle && pfn_tsr_exit)
877 { /* if we have a resident old plugin and a callback */
Jonathan Gordond7d2e692007-08-08 07:27:07 +0000878 if (pfn_tsr_exit(!strcmp(current_plugin, plugin)) == false )
Jonathan Gordon29e259a2006-10-31 11:17:00 +0000879 {
880 /* not allowing another plugin to load */
881 return PLUGIN_OK;
882 }
Thomas Martitz194174a2010-08-27 00:29:50 +0000883 lc_close(current_plugin_handle);
884 current_plugin_handle = pfn_tsr_exit = NULL;
Thomas Martitz22e802e2013-05-30 11:24:16 +0200885 if (plugin_buffer_handle > 0)
886 plugin_buffer_handle = core_free(plugin_buffer_handle);
Jörg Hohensohn68002762004-04-30 20:37:11 +0000887 }
Michael Sevakis6689cb02007-04-10 14:18:30 +0000888
Nils Wallménius01729e72008-08-15 08:27:39 +0000889 splash(0, ID2P(LANG_WAIT));
Jonathan Gordond7d2e692007-08-08 07:27:07 +0000890 strcpy(current_plugin, plugin);
Jens Arnold7ea4d592006-02-16 22:36:04 +0000891
Thomas Martitz194174a2010-08-27 00:29:50 +0000892 current_plugin_handle = lc_open(plugin, pluginbuf, PLUGIN_BUFFER_SIZE);
893 if (current_plugin_handle == NULL) {
Nils Wallménius01729e72008-08-15 08:27:39 +0000894 splashf(HZ*2, str(LANG_PLUGIN_CANT_OPEN), plugin);
Björn Stenbergba371fb2003-06-29 16:33:04 +0000895 return -1;
Jens Arnolda7902772006-01-16 23:20:58 +0000896 }
Thomas Martitz194174a2010-08-27 00:29:50 +0000897
Thomas Martitz0d4585b2010-09-09 16:17:21 +0000898 p_hdr = lc_get_header(current_plugin_handle);
899
900 hdr = p_hdr ? &p_hdr->lc_hdr : NULL;
Solomon Peachy55eb1c52019-02-03 20:12:50 -0500901
Thomas Martitz194174a2010-08-27 00:29:50 +0000902
Jens Arnolda7902772006-01-16 23:20:58 +0000903 if (hdr == NULL
904 || hdr->magic != PLUGIN_MAGIC
Thomas Martitz97d2a6e2010-08-27 00:16:26 +0000905 || hdr->target_id != TARGET_ID
Thomas Martitz194174a2010-08-27 00:29:50 +0000906#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
Thomas Martitz97d2a6e2010-08-27 00:16:26 +0000907 || hdr->load_addr != pluginbuf
Thomas Martitz194174a2010-08-27 00:29:50 +0000908 || hdr->end_addr > pluginbuf + PLUGIN_BUFFER_SIZE
909#endif
910 )
911 {
912 lc_close(current_plugin_handle);
Solomon Peachy55eb1c52019-02-03 20:12:50 -0500913 splash(HZ*2, ID2P(LANG_PLUGIN_WRONG_MODEL));
Thomas Martitz97d2a6e2010-08-27 00:16:26 +0000914 return -1;
915 }
916 if (hdr->api_version > PLUGIN_API_VERSION
Thomas Martitz194174a2010-08-27 00:29:50 +0000917 || hdr->api_version < PLUGIN_MIN_API_VERSION)
918 {
919 lc_close(current_plugin_handle);
Solomon Peachy55eb1c52019-02-03 20:12:50 -0500920 splash(HZ*2, ID2P(LANG_PLUGIN_WRONG_VERSION));
Thomas Martitz97d2a6e2010-08-27 00:16:26 +0000921 return -1;
922 }
Thomas Martitz194174a2010-08-27 00:29:50 +0000923#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
William Wilguse1475a32019-07-17 00:39:14 -0500924 /* tlsf crashes observed on arm with 0x4 aligned addresses */
925 plugin_size = ALIGN_UP(hdr->end_addr - pluginbuf, 0x8);
Thomas Martitz194174a2010-08-27 00:29:50 +0000926#else
927 plugin_size = 0;
Björn Stenbergba371fb2003-06-29 16:33:04 +0000928#endif
929
Thomas Martitz0d4585b2010-09-09 16:17:21 +0000930 *(p_hdr->api) = &rockbox_api;
Michael Sevakis6689cb02007-04-10 14:18:30 +0000931
Jens Arnold7ea4d592006-02-16 22:36:04 +0000932 lcd_clear_display();
Dave Chapman1c398552006-02-14 00:39:11 +0000933 lcd_update();
Dave Chapman1c398552006-02-14 00:39:11 +0000934
Jens Arnold35e05ca2006-02-18 00:13:44 +0000935#ifdef HAVE_REMOTE_LCD
Jens Arnold35e05ca2006-02-18 00:13:44 +0000936 lcd_remote_clear_display();
937 lcd_remote_update();
938#endif
Jonathan Gordon32dfc0c2011-08-04 13:40:24 +0000939 push_current_activity(ACTIVITY_PLUGIN);
Thomas Martitzbaa070c2011-08-30 14:01:45 +0000940 /* some plugins assume the entry cache doesn't move and save pointers to it
941 * they should be fixed properly instead of this lock */
942 tree_lock_cache(tree_get_context());
Jens Arnold35e05ca2006-02-18 00:13:44 +0000943
Jonathan Gordonb2eb44c2009-12-09 07:25:46 +0000944 FOR_NB_SCREENS(i)
945 viewportmanager_theme_enable(i, false, NULL);
Solomon Peachy55eb1c52019-02-03 20:12:50 -0500946
Maurus Cuelenaerea10ff232009-04-19 12:46:04 +0000947#ifdef HAVE_TOUCHSCREEN
Maurus Cuelenaerea10ff232009-04-19 12:46:04 +0000948 touchscreen_set_mode(TOUCHSCREEN_BUTTON);
949#endif
Jonathan Gordone4689fd2007-03-21 07:26:07 +0000950
Thomas Martitz22e802e2013-05-30 11:24:16 +0200951 /* allow voice to back off if the plugin needs lots of memory */
Solomon Peachy55eb1c52019-02-03 20:12:50 -0500952 if (!global_settings.talk_menu)
953 talk_buffer_set_policy(TALK_BUFFER_LOOSE);
Thomas Martitz22e802e2013-05-30 11:24:16 +0200954
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400955 plugin_check_open_close__enter();
Amaury Poulye5caf932010-02-11 19:15:37 +0000956
Björn Stenberg0942e2a2011-10-15 19:35:02 +0000957 int rc = p_hdr->entry_point(parameter);
Solomon Peachy55eb1c52019-02-03 20:12:50 -0500958
Thomas Martitzbaa070c2011-08-30 14:01:45 +0000959 tree_unlock_cache(tree_get_context());
Jonathan Gordon32dfc0c2011-08-04 13:40:24 +0000960 pop_current_activity();
Amaury Poulye5caf932010-02-11 19:15:37 +0000961
Thomas Martitz194174a2010-08-27 00:29:50 +0000962 if (!pfn_tsr_exit)
963 { /* close handle if plugin is no tsr one */
964 lc_close(current_plugin_handle);
965 current_plugin_handle = NULL;
Thomas Martitz22e802e2013-05-30 11:24:16 +0200966 if (plugin_buffer_handle > 0)
967 plugin_buffer_handle = core_free(plugin_buffer_handle);
Thomas Martitz194174a2010-08-27 00:29:50 +0000968 }
969
Thomas Martitz22e802e2013-05-30 11:24:16 +0200970 talk_buffer_set_policy(TALK_BUFFER_DEFAULT);
971
Karl Kurbjunc2480c32009-08-04 05:22:10 +0000972 /* Go back to the global setting in case the plugin changed it */
Maurus Cuelenaerea10ff232009-04-19 12:46:04 +0000973#ifdef HAVE_TOUCHSCREEN
Karl Kurbjunc2480c32009-08-04 05:22:10 +0000974 touchscreen_set_mode(global_settings.touch_mode);
Maurus Cuelenaerea10ff232009-04-19 12:46:04 +0000975#endif
Michael Sevakis6689cb02007-04-10 14:18:30 +0000976
Jens Arnold04daef12005-06-24 22:33:21 +0000977#ifdef HAVE_LCD_BITMAP
Jonathan Gordonaa0f4a42011-09-24 13:19:34 +0000978 screen_helper_setfont(FONT_UI);
Jens Arnold34a610b2005-07-14 18:12:27 +0000979#if LCD_DEPTH > 1
Jens Arnold02978732006-11-13 00:45:21 +0000980#ifdef HAVE_LCD_COLOR
Zakk Roberts07fcf772006-05-01 05:45:18 +0000981 lcd_set_drawinfo(DRMODE_SOLID, global_settings.fg_color,
Dave Chapman603f87f2006-02-26 02:48:05 +0000982 global_settings.bg_color);
983#else
Jens Arnold5b2cba12005-11-16 21:09:23 +0000984 lcd_set_drawinfo(DRMODE_SOLID, LCD_DEFAULT_FG, LCD_DEFAULT_BG);
Dave Chapman603f87f2006-02-26 02:48:05 +0000985#endif
Jens Arnoldb0e056b2005-07-19 10:33:41 +0000986#else /* LCD_DEPTH == 1 */
Jens Arnold04daef12005-06-24 22:33:21 +0000987 lcd_set_drawmode(DRMODE_SOLID);
Jens Arnoldb0e056b2005-07-19 10:33:41 +0000988#endif /* LCD_DEPTH */
Jens Arnoldf9b90e92007-04-06 22:55:00 +0000989#endif /* HAVE_LCD_BITMAP */
990
Jens Arnold35e05ca2006-02-18 00:13:44 +0000991
992#ifdef HAVE_REMOTE_LCD
Jens Arnoldd8dda932006-10-09 07:00:50 +0000993#if LCD_REMOTE_DEPTH > 1
Michael Sevakis6aa12c12006-10-14 01:32:58 +0000994 lcd_remote_set_drawinfo(DRMODE_SOLID, LCD_REMOTE_DEFAULT_FG,
Jens Arnoldd8dda932006-10-09 07:00:50 +0000995 LCD_REMOTE_DEFAULT_BG);
996#else
Jens Arnold35e05ca2006-02-18 00:13:44 +0000997 lcd_remote_set_drawmode(DRMODE_SOLID);
Jens Arnoldd8dda932006-10-09 07:00:50 +0000998#endif
Jens Arnold35e05ca2006-02-18 00:13:44 +0000999#endif
Thomas Martitzdf6f9552009-07-05 22:12:42 +00001000
Teruaki Kawashima19b1fe42009-12-10 13:53:38 +00001001 lcd_clear_display();
Nils Wallménius296ac7f2010-07-24 10:53:58 +00001002#ifdef HAVE_REMOTE_LCD
Teruaki Kawashima19b1fe42009-12-10 13:53:38 +00001003 lcd_remote_clear_display();
1004#endif
1005
Jonathan Gordonb2eb44c2009-12-09 07:25:46 +00001006 FOR_NB_SCREENS(i)
Jonathan Gordon08d285b2011-09-14 12:47:26 +00001007 viewportmanager_theme_undo(i, true);
Thomas Martitzdf6f9552009-07-05 22:12:42 +00001008
Michael Sevakis7d1a47c2013-08-05 22:02:45 -04001009 plugin_check_open_close__exit();
Amaury Poulye5caf932010-02-11 19:15:37 +00001010
Solomon Peachy2d70fdc2019-08-05 22:05:32 -04001011 status_save();
1012
Thomas Martitzdf6f9552009-07-05 22:12:42 +00001013 if (rc == PLUGIN_ERROR)
1014 splash(HZ*2, str(LANG_PLUGIN_ERROR));
Björn Stenbergba371fb2003-06-29 16:33:04 +00001015
Thomas Martitzdf6f9552009-07-05 22:12:42 +00001016 return rc;
Björn Stenbergba371fb2003-06-29 16:33:04 +00001017}
1018
Hardeep Sidhu48c2d0f2003-07-25 23:04:59 +00001019/* Returns a pointer to the portion of the plugin buffer that is not already
1020 being used. If no plugin is loaded, returns the entire plugin buffer */
Michael Sevakis26d242a2007-04-21 18:38:25 +00001021void* plugin_get_buffer(size_t *buffer_size)
Björn Stenbergba371fb2003-06-29 16:33:04 +00001022{
Hardeep Sidhu48c2d0f2003-07-25 23:04:59 +00001023 int buffer_pos;
1024
Thomas Martitz194174a2010-08-27 00:29:50 +00001025 if (current_plugin_handle)
Hardeep Sidhu48c2d0f2003-07-25 23:04:59 +00001026 {
1027 if (plugin_size >= PLUGIN_BUFFER_SIZE)
1028 return NULL;
Zakk Roberts07fcf772006-05-01 05:45:18 +00001029
Hardeep Sidhu48c2d0f2003-07-25 23:04:59 +00001030 *buffer_size = PLUGIN_BUFFER_SIZE-plugin_size;
1031 buffer_pos = plugin_size;
1032 }
1033 else
1034 {
1035 *buffer_size = PLUGIN_BUFFER_SIZE;
1036 buffer_pos = 0;
1037 }
1038
1039 return &pluginbuf[buffer_pos];
1040}
1041
Zakk Roberts07fcf772006-05-01 05:45:18 +00001042/* Returns a pointer to the mp3 buffer.
Michael Sevakis0f5cb942006-11-06 18:07:30 +00001043 Playback gets stopped, to avoid conflicts.
1044 Talk buffer is stolen as well.
1045 */
Thomas Martitz95761342014-04-09 09:00:36 +02001046static void* plugin_get_audio_buffer(size_t *buffer_size)
Jörg Hohensohn95298a92004-01-30 22:30:40 +00001047{
Thomas Martitz22e802e2013-05-30 11:24:16 +02001048 /* dummy ops with no callbacks, needed because by
1049 * default buflib buffers can be moved around which must be avoided */
1050 static struct buflib_callbacks dummy_ops;
Michael Sevakis81f5a222017-10-14 05:59:09 -04001051 if (plugin_buffer_handle <= 0)
1052 {
1053 plugin_buffer_handle = core_alloc_maximum("plugin audio buf",
1054 &plugin_buffer_size,
1055 &dummy_ops);
1056 }
1057
1058 if (buffer_size)
1059 *buffer_size = plugin_buffer_size;
1060
Thomas Martitz22e802e2013-05-30 11:24:16 +02001061 return core_get_data(plugin_buffer_handle);
Jörg Hohensohn95298a92004-01-30 22:30:40 +00001062}
1063
Thomas Martitz95761342014-04-09 09:00:36 +02001064static void plugin_release_audio_buffer(void)
1065{
1066 if (plugin_buffer_handle > 0)
Michael Sevakis81f5a222017-10-14 05:59:09 -04001067 {
Thomas Martitz95761342014-04-09 09:00:36 +02001068 plugin_buffer_handle = core_free(plugin_buffer_handle);
Michael Sevakis81f5a222017-10-14 05:59:09 -04001069 plugin_buffer_size = 0;
1070 }
Thomas Martitz95761342014-04-09 09:00:36 +02001071}
1072
Jörg Hohensohn68002762004-04-30 20:37:11 +00001073/* The plugin wants to stay resident after leaving its main function, e.g.
Zakk Roberts07fcf772006-05-01 05:45:18 +00001074 runs from timer or own thread. The callback is registered to later
Jörg Hohensohn68002762004-04-30 20:37:11 +00001075 instruct it to free its resources before a new plugin gets loaded. */
Thomas Martitz95761342014-04-09 09:00:36 +02001076static void plugin_tsr(bool (*exit_callback)(bool))
Jörg Hohensohn68002762004-04-30 20:37:11 +00001077{
1078 pfn_tsr_exit = exit_callback; /* remember the callback for later */
1079}
Jonathan Gordonfda7d722007-08-06 13:42:52 +00001080
1081char *plugin_get_current_filename(void)
1082{
1083 return current_plugin;
1084}