Use ldr instead of adr, so that it compiles with a newer ld, although setting lr...
[kugel-rb.git] / apps / plugin.h
bloba8b341ff04747114086760e5cfc5c55eaae3bd74
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 Björn Stenberg
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
21 #ifndef _PLUGIN_H_
22 #define _PLUGIN_H_
24 /* instruct simulator code to not redefine any symbols when compiling plugins.
25 (the PLUGIN macro is defined in apps/plugins/Makefile) */
26 #ifdef PLUGIN
27 #define NO_REDEFINES_PLEASE
28 #endif
30 #ifndef MEM
31 #define MEM 2
32 #endif
34 #include <stdbool.h>
35 #include <sys/types.h>
36 #include <stdarg.h>
37 #include <stdio.h>
38 #include <stdlib.h>
39 #include <string.h>
41 char* strncpy(char *, const char *, size_t);
42 void* plugin_get_buffer(size_t *buffer_size);
44 #ifndef __PCTOOL__
45 #include "config.h"
46 #include "system.h"
47 #include "dir.h"
48 #include "general.h"
49 #include "kernel.h"
50 #include "thread.h"
51 #include "button.h"
52 #include "action.h"
53 #include "usb.h"
54 #include "font.h"
55 #include "lcd.h"
56 #include "metadata.h"
57 #include "sound.h"
58 #include "mpeg.h"
59 #include "audio.h"
60 #include "mp3_playback.h"
61 #include "talk.h"
62 #ifdef RB_PROFILE
63 #include "profile.h"
64 #endif
65 #include "misc.h"
66 #if (CONFIG_CODEC == SWCODEC)
67 #include "dsp.h"
68 #include "codecs.h"
69 #include "playback.h"
70 #include "codec_thread.h"
71 #ifdef HAVE_RECORDING
72 #include "recording.h"
73 #endif
74 #else
75 #include "mas.h"
76 #endif /* CONFIG_CODEC == SWCODEC */
77 #include "settings.h"
78 #include "timer.h"
79 #include "playlist.h"
80 #ifdef HAVE_LCD_BITMAP
81 #include "screendump.h"
82 #include "scrollbar.h"
83 #include "jpeg_load.h"
84 #include "../recorder/bmp.h"
85 #endif
86 #include "statusbar.h"
87 #include "menu.h"
88 #include "rbunicode.h"
89 #include "list.h"
90 #include "tree.h"
91 #include "color_picker.h"
92 #include "buffering.h"
93 #include "tagcache.h"
94 #include "viewport.h"
95 #include "ata_idle_notify.h"
96 #include "settings_list.h"
97 #include "timefuncs.h"
98 #include "crc32.h"
100 #ifdef HAVE_ALBUMART
101 #include "albumart.h"
102 #endif
104 #ifdef HAVE_REMOTE_LCD
105 #include "lcd-remote.h"
106 #endif
108 #include "yesno.h"
110 #ifdef USB_ENABLE_HID
111 #include "usbstack/usb_hid_usage_tables.h"
112 #endif
114 #ifdef PLUGIN
116 #if defined(DEBUG) || defined(SIMULATOR)
117 #undef DEBUGF
118 #define DEBUGF rb->debugf
119 #undef LDEBUGF
120 #define LDEBUGF rb->debugf
121 #else
122 #define DEBUGF(...)
123 #define LDEBUGF(...)
124 #endif
126 #ifdef ROCKBOX_HAS_LOGF
127 #undef LOGF
128 #define LOGF rb->logf
129 #else
130 #define LOGF(...)
131 #endif
133 #endif
135 #define PLUGIN_MAGIC 0x526F634B /* RocK */
137 /* increase this every time the api struct changes */
138 #define PLUGIN_API_VERSION 182
140 /* update this to latest version if a change to the api struct breaks
141 backwards compatibility (and please take the opportunity to sort in any
142 new function which are "waiting" at the end of the function table) */
143 #define PLUGIN_MIN_API_VERSION 182
145 /* plugin return codes */
146 enum plugin_status {
147 PLUGIN_OK = 0,
148 PLUGIN_USB_CONNECTED,
149 PLUGIN_GOTO_WPS,
150 PLUGIN_ERROR = -1,
153 /* NOTE: To support backwards compatibility, only add new functions at
154 the end of the structure. Every time you add a new function,
155 remember to increase PLUGIN_API_VERSION. If you make changes to the
156 existing APIs then also update PLUGIN_MIN_API_VERSION to current
157 version
159 struct plugin_api {
161 /* lcd */
163 #ifdef HAVE_LCD_CONTRAST
164 void (*lcd_set_contrast)(int x);
165 #endif
166 void (*lcd_update)(void);
167 void (*lcd_clear_display)(void);
168 int (*lcd_getstringsize)(const unsigned char *str, int *w, int *h);
169 void (*lcd_putsxy)(int x, int y, const unsigned char *string);
170 void (*lcd_puts)(int x, int y, const unsigned char *string);
171 void (*lcd_puts_scroll)(int x, int y, const unsigned char* string);
172 void (*lcd_stop_scroll)(void);
173 #ifdef HAVE_LCD_CHARCELLS
174 void (*lcd_define_pattern)(unsigned long ucs, const char *pattern);
175 unsigned long (*lcd_get_locked_pattern)(void);
176 void (*lcd_unlock_pattern)(unsigned long ucs);
177 void (*lcd_putc)(int x, int y, unsigned long ucs);
178 void (*lcd_put_cursor)(int x, int y, unsigned long ucs);
179 void (*lcd_remove_cursor)(void);
180 void (*lcd_icon)(int icon, bool enable);
181 void (*lcd_double_height)(bool on);
182 #else /* HAVE_LCD_BITMAP */
183 fb_data* lcd_framebuffer;
184 void (*lcd_update_rect)(int x, int y, int width, int height);
185 void (*lcd_set_drawmode)(int mode);
186 int (*lcd_get_drawmode)(void);
187 void (*lcd_setfont)(int font);
188 void (*lcd_drawpixel)(int x, int y);
189 void (*lcd_drawline)(int x1, int y1, int x2, int y2);
190 void (*lcd_hline)(int x1, int x2, int y);
191 void (*lcd_vline)(int x, int y1, int y2);
192 void (*lcd_drawrect)(int x, int y, int width, int height);
193 void (*lcd_fillrect)(int x, int y, int width, int height);
194 void (*lcd_mono_bitmap_part)(const unsigned char *src, int src_x, int src_y,
195 int stride, int x, int y, int width, int height);
196 void (*lcd_mono_bitmap)(const unsigned char *src, int x, int y,
197 int width, int height);
198 #if LCD_DEPTH > 1
199 void (*lcd_set_foreground)(unsigned foreground);
200 unsigned (*lcd_get_foreground)(void);
201 void (*lcd_set_background)(unsigned foreground);
202 unsigned (*lcd_get_background)(void);
203 void (*lcd_bitmap_part)(const fb_data *src, int src_x, int src_y,
204 int stride, int x, int y, int width, int height);
205 void (*lcd_bitmap)(const fb_data *src, int x, int y, int width,
206 int height);
207 fb_data* (*lcd_get_backdrop)(void);
208 void (*lcd_set_backdrop)(fb_data* backdrop);
209 #endif
210 #if LCD_DEPTH == 16
211 void (*lcd_bitmap_transparent_part)(const fb_data *src,
212 int src_x, int src_y, int stride,
213 int x, int y, int width, int height);
214 void (*lcd_bitmap_transparent)(const fb_data *src, int x, int y,
215 int width, int height);
216 #if MEMORYSIZE > 2
217 void (*lcd_blit_yuv)(unsigned char * const src[3],
218 int src_x, int src_y, int stride,
219 int x, int y, int width, int height);
220 #if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) || defined(SANSA_C200) \
221 || defined(IRIVER_H10) || defined(COWON_D2) || defined(PHILIPS_HDD1630) \
222 || defined(SANSA_FUZE) || defined(SANSA_E200V2) || defined(TOSHIBA_GIGABEAT_S)
223 void (*lcd_yuv_set_options)(unsigned options);
224 #endif
225 #endif /* MEMORYSIZE > 2 */
226 #elif (LCD_DEPTH < 4) && !defined(SIMULATOR)
227 void (*lcd_blit_mono)(const unsigned char *data, int x, int by, int width,
228 int bheight, int stride);
229 void (*lcd_blit_grey_phase)(unsigned char *values, unsigned char *phases,
230 int bx, int by, int bwidth, int bheight,
231 int stride);
232 #endif /* LCD_DEPTH */
233 #if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
234 void (*lcd_blit_pal256)(unsigned char *src, int src_x, int src_y, int x, int y,
235 int width, int height);
236 void (*lcd_pal256_update_pal)(fb_data *palette);
237 #endif
238 void (*lcd_puts_style)(int x, int y, const unsigned char *str, int style);
239 void (*lcd_puts_scroll_style)(int x, int y, const unsigned char* string,
240 int style);
241 #ifdef HAVE_LCD_INVERT
242 void (*lcd_set_invert_display)(bool yesno);
243 #endif /* HAVE_LCD_INVERT */
244 #if defined(HAVE_LCD_MODES)
245 void (*lcd_set_mode)(int mode);
246 #endif
248 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
249 struct event_queue *button_queue;
250 #endif
251 unsigned short *(*bidi_l2v)( const unsigned char *str, int orientation );
252 const unsigned char *(*font_get_bits)( struct font *pf, unsigned short char_code );
253 int (*font_load)(struct font*, const char *path);
254 struct font* (*font_get)(int font);
255 int (*font_getstringsize)(const unsigned char *str, int *w, int *h,
256 int fontnumber);
257 int (*font_get_width)(struct font* pf, unsigned short char_code);
258 void (*screen_clear_area)(struct screen * display, int xstart, int ystart,
259 int width, int height);
260 void (*gui_scrollbar_draw)(struct screen * screen, int x, int y,
261 int width, int height, int items,
262 int min_shown, int max_shown,
263 unsigned flags);
264 #endif /* HAVE_LCD_BITMAP */
265 const char* (*get_codepage_name)(int cp);
267 /* backlight */
268 /* The backlight_* functions must be present in the API regardless whether
269 * HAVE_BACKLIGHT is defined or not. The reason is that the stock Ondio has
270 * no backlight but can be modded to have backlight (it's prepared on the
271 * PCB). This makes backlight an all-target feature API wise, and keeps API
272 * compatible between stock and modded Ondio.
273 * For OLED targets like the Sansa Clip, the backlight_* functions control
274 * the display enable, which has essentially the same effect. */
275 void (*backlight_on)(void);
276 void (*backlight_off)(void);
277 void (*backlight_set_timeout)(int index);
278 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
279 void (*backlight_set_brightness)(int val);
280 #endif /* HAVE_BACKLIGHT_BRIGHTNESS */
282 #if CONFIG_CHARGING
283 void (*backlight_set_timeout_plugged)(int index);
284 #endif
285 bool (*is_backlight_on)(bool ignore_always_off);
286 void (*splash)(int ticks, const char *str);
287 void (*splashf)(int ticks, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3);
289 #ifdef HAVE_REMOTE_LCD
290 /* remote lcd */
291 void (*lcd_remote_set_contrast)(int x);
292 void (*lcd_remote_clear_display)(void);
293 void (*lcd_remote_puts)(int x, int y, const unsigned char *string);
294 void (*lcd_remote_puts_scroll)(int x, int y, const unsigned char* string);
295 void (*lcd_remote_stop_scroll)(void);
296 void (*lcd_remote_set_drawmode)(int mode);
297 int (*lcd_remote_get_drawmode)(void);
298 void (*lcd_remote_setfont)(int font);
299 int (*lcd_remote_getstringsize)(const unsigned char *str, int *w, int *h);
300 void (*lcd_remote_drawpixel)(int x, int y);
301 void (*lcd_remote_drawline)(int x1, int y1, int x2, int y2);
302 void (*lcd_remote_hline)(int x1, int x2, int y);
303 void (*lcd_remote_vline)(int x, int y1, int y2);
304 void (*lcd_remote_drawrect)(int x, int y, int nx, int ny);
305 void (*lcd_remote_fillrect)(int x, int y, int nx, int ny);
306 void (*lcd_remote_mono_bitmap_part)(const unsigned char *src, int src_x,
307 int src_y, int stride, int x, int y,
308 int width, int height);
309 void (*lcd_remote_mono_bitmap)(const unsigned char *src, int x, int y,
310 int width, int height);
311 void (*lcd_remote_putsxy)(int x, int y, const unsigned char *string);
312 void (*lcd_remote_puts_style)(int x, int y, const unsigned char *str, int style);
313 void (*lcd_remote_puts_scroll_style)(int x, int y, const unsigned char* string,
314 int style);
315 fb_remote_data* lcd_remote_framebuffer;
316 void (*lcd_remote_update)(void);
317 void (*lcd_remote_update_rect)(int x, int y, int width, int height);
319 void (*remote_backlight_on)(void);
320 void (*remote_backlight_off)(void);
321 void (*remote_backlight_set_timeout)(int index);
322 #if CONFIG_CHARGING
323 void (*remote_backlight_set_timeout_plugged)(int index);
324 #endif
325 #endif /* HAVE_REMOTE_LCD */
326 struct screen* screens[NB_SCREENS];
327 #if defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)
328 void (*lcd_remote_set_foreground)(unsigned foreground);
329 unsigned (*lcd_remote_get_foreground)(void);
330 void (*lcd_remote_set_background)(unsigned background);
331 unsigned (*lcd_remote_get_background)(void);
332 void (*lcd_remote_bitmap_part)(const fb_remote_data *src,
333 int src_x, int src_y, int stride,
334 int x, int y, int width, int height);
335 void (*lcd_remote_bitmap)(const fb_remote_data *src, int x, int y,
336 int width, int height);
337 #endif
338 void (*viewport_set_defaults)(struct viewport *vp,
339 const enum screen_type screen);
340 #ifdef HAVE_LCD_BITMAP
341 void (*viewportmanager_theme_enable)(enum screen_type screen, bool enable,
342 struct viewport *viewport);
343 void (*viewportmanager_theme_undo)(enum screen_type screen, bool force_redraw);
344 #endif
345 /* list */
346 void (*gui_synclist_init)(struct gui_synclist * lists,
347 list_get_name callback_get_item_name, void * data,
348 bool scroll_all,int selected_size,
349 struct viewport parent[NB_SCREENS]);
350 void (*gui_synclist_set_nb_items)(struct gui_synclist * lists, int nb_items);
351 void (*gui_synclist_set_icon_callback)(struct gui_synclist * lists,
352 list_get_icon icon_callback);
353 int (*gui_synclist_get_nb_items)(struct gui_synclist * lists);
354 int (*gui_synclist_get_sel_pos)(struct gui_synclist * lists);
355 void (*gui_synclist_draw)(struct gui_synclist * lists);
356 void (*gui_synclist_select_item)(struct gui_synclist * lists,
357 int item_number);
358 void (*gui_synclist_add_item)(struct gui_synclist * lists);
359 void (*gui_synclist_del_item)(struct gui_synclist * lists);
360 void (*gui_synclist_limit_scroll)(struct gui_synclist * lists, bool scroll);
361 bool (*gui_synclist_do_button)(struct gui_synclist * lists,
362 int *action, enum list_wrap wrap);
363 void (*gui_synclist_set_title)(struct gui_synclist *lists, char* title,
364 enum themable_icons icon);
365 enum yesno_res (*gui_syncyesno_run)(const struct text_message * main_message,
366 const struct text_message * yes_message,
367 const struct text_message * no_message);
368 void (*simplelist_info_init)(struct simplelist_info *info, char* title,
369 int count, void* data);
370 bool (*simplelist_show_list)(struct simplelist_info *info);
372 /* button */
373 long (*button_get)(bool block);
374 long (*button_get_w_tmo)(int ticks);
375 int (*button_status)(void);
376 #ifdef HAVE_BUTTON_DATA
377 intptr_t (*button_get_data)(void);
378 int (*button_status_wdata)(int *pdata);
379 #endif
380 void (*button_clear_queue)(void);
381 int (*button_queue_count)(void);
382 #ifdef HAS_BUTTON_HOLD
383 bool (*button_hold)(void);
384 #endif
385 #ifdef HAVE_TOUCHSCREEN
386 void (*touchscreen_set_mode)(enum touchscreen_mode);
387 #endif
388 #ifdef HAVE_BUTTON_LIGHT
389 void (*buttonlight_set_timeout)(int value);
390 void (*buttonlight_off)(void);
391 void (*buttonlight_on)(void);
392 #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
393 void (*buttonlight_set_brightness)(int val);
394 #endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
395 #endif /* HAVE_BUTTON_LIGHT */
397 /* file */
398 int (*open_utf8)(const char* pathname, int flags);
399 int (*open)(const char* pathname, int flags);
400 int (*close)(int fd);
401 ssize_t (*read)(int fd, void* buf, size_t count);
402 off_t (*lseek)(int fd, off_t offset, int whence);
403 int (*creat)(const char *pathname);
404 ssize_t (*write)(int fd, const void* buf, size_t count);
405 int (*remove)(const char* pathname);
406 int (*rename)(const char* path, const char* newname);
407 int (*ftruncate)(int fd, off_t length);
408 off_t (*filesize)(int fd);
409 int (*fdprintf)(int fd, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3);
410 int (*read_line)(int fd, char* buffer, int buffer_size);
411 bool (*settings_parseline)(char* line, char** name, char** value);
412 void (*storage_sleep)(void);
413 void (*storage_spin)(void);
414 void (*storage_spindown)(int seconds);
415 #if USING_STORAGE_CALLBACK
416 void (*register_storage_idle_func)(void (*function)(void *data));
417 void (*unregister_storage_idle_func)(void (*function)(void *data), bool run);
418 #endif /* USING_STORAGE_CALLBACK */
419 void (*reload_directory)(void);
420 char *(*create_numbered_filename)(char *buffer, const char *path,
421 const char *prefix, const char *suffix,
422 int numberlen IF_CNFN_NUM_(, int *num));
423 bool (*file_exists)(const char *file);
424 char* (*strip_extension)(char* buffer, int buffer_size, const char *filename);
425 unsigned (*crc_32)(const void *src, unsigned len, unsigned crc32);
428 /* dir */
429 DIR* (*opendir)(const char* name);
430 int (*closedir)(DIR* dir);
431 struct dirent* (*readdir)(DIR* dir);
432 int (*mkdir)(const char *name);
433 int (*rmdir)(const char *name);
434 bool (*dir_exists)(const char *path);
436 /* kernel/ system */
437 #ifdef CPU_ARM
438 void (*__div0)(void);
439 #endif
440 void (*sleep)(int ticks);
441 void (*yield)(void);
442 volatile long* current_tick;
443 long (*default_event_handler)(long event);
444 long (*default_event_handler_ex)(long event,
445 void (*callback)(void *), void *parameter);
446 unsigned int (*create_thread)(void (*function)(void), void* stack,
447 size_t stack_size, unsigned flags,
448 const char *name
449 IF_PRIO(, int priority)
450 IF_COP(, unsigned int core));
451 void (*thread_exit)(void);
452 void (*thread_wait)(unsigned int thread_id);
453 #if CONFIG_CODEC == SWCODEC
454 void (*thread_thaw)(unsigned int thread_id);
455 #ifdef HAVE_PRIORITY_SCHEDULING
456 int (*thread_set_priority)(unsigned int thread_id, int priority);
457 #endif
458 void (*mutex_init)(struct mutex *m);
459 void (*mutex_lock)(struct mutex *m);
460 void (*mutex_unlock)(struct mutex *m);
461 #endif
463 void (*reset_poweroff_timer)(void);
464 #ifndef SIMULATOR
465 int (*system_memory_guard)(int newmode);
466 long *cpu_frequency;
467 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
468 #ifdef CPU_BOOST_LOGGING
469 void (*cpu_boost_)(bool on_off,char*location,int line);
470 #else
471 void (*cpu_boost)(bool on_off);
472 #endif
473 #endif /* HAVE_ADJUSTABLE_CPU_FREQ */
474 #endif /* !SIMULATOR */
475 #ifdef HAVE_SCHEDULER_BOOSTCTRL
476 void (*trigger_cpu_boost)(void);
477 void (*cancel_cpu_boost)(void);
478 #endif
479 #if NUM_CORES > 1
480 void (*cpucache_flush)(void);
481 void (*cpucache_invalidate)(void);
482 #endif
483 bool (*timer_register)(int reg_prio, void (*unregister_callback)(void),
484 long cycles, void (*timer_callback)(void)
485 IF_COP(, int core));
486 void (*timer_unregister)(void);
487 bool (*timer_set_period)(long count);
489 void (*queue_init)(struct event_queue *q, bool register_queue);
490 void (*queue_delete)(struct event_queue *q);
491 void (*queue_post)(struct event_queue *q, long id, intptr_t data);
492 void (*queue_wait_w_tmo)(struct event_queue *q, struct queue_event *ev,
493 int ticks);
494 #if CONFIG_CODEC == SWCODEC
495 void (*queue_enable_queue_send)(struct event_queue *q,
496 struct queue_sender_list *send,
497 unsigned int thread_id);
498 bool (*queue_empty)(const struct event_queue *q);
499 void (*queue_wait)(struct event_queue *q, struct queue_event *ev);
500 intptr_t (*queue_send)(struct event_queue *q, long id,
501 intptr_t data);
502 void (*queue_reply)(struct event_queue *q, intptr_t retval);
503 #endif /* CONFIG_CODEC == SWCODEC */
505 void (*usb_acknowledge)(long id);
506 #ifdef USB_ENABLE_HID
507 void (*usb_hid_send)(usage_page_t usage_page, int id);
508 #endif
509 #ifdef RB_PROFILE
510 void (*profile_thread)(void);
511 void (*profstop)(void);
512 void (*profile_func_enter)(void *this_fn, void *call_site);
513 void (*profile_func_exit)(void *this_fn, void *call_site);
514 #endif
515 /* event api */
516 bool (*add_event)(unsigned short id, bool oneshot, void (*handler)(void *data));
517 void (*remove_event)(unsigned short id, void (*handler)(void *data));
518 void (*send_event)(unsigned short id, void *data);
520 #ifdef SIMULATOR
521 /* special simulator hooks */
522 #if defined(HAVE_LCD_BITMAP) && LCD_DEPTH < 8
523 void (*sim_lcd_ex_init)(unsigned long (*getpixel)(int, int));
524 void (*sim_lcd_ex_update_rect)(int x, int y, int width, int height);
525 #endif
526 #endif
528 /* strings and memory */
529 int (*snprintf)(char *buf, size_t size, const char *fmt, ...)
530 ATTRIBUTE_PRINTF(3, 4);
531 int (*vsnprintf)(char *buf, int size, const char *fmt, va_list ap);
532 char* (*strcpy)(char *dst, const char *src);
533 size_t (*strlcpy)(char *dst, const char *src, size_t length);
534 size_t (*strlen)(const char *str);
535 char * (*strrchr)(const char *s, int c);
536 int (*strcmp)(const char *, const char *);
537 int (*strncmp)(const char *, const char *, size_t);
538 int (*strcasecmp)(const char *, const char *);
539 int (*strncasecmp)(const char *s1, const char *s2, size_t n);
540 void* (*memset)(void *dst, int c, size_t length);
541 void* (*memcpy)(void *out, const void *in, size_t n);
542 void* (*memmove)(void *out, const void *in, size_t n);
543 const unsigned char *_rbctype_;
544 int (*atoi)(const char *str);
545 char *(*strchr)(const char *s, int c);
546 char *(*strcat)(char *s1, const char *s2);
547 size_t (*strlcat)(char *dst, const char *src, size_t length);
548 void *(*memchr)(const void *s1, int c, size_t n);
549 int (*memcmp)(const void *s1, const void *s2, size_t n);
550 char *(*strcasestr) (const char* phaystack, const char* pneedle);
551 char* (*strtok_r)(char *ptr, const char *sep, char **end);
552 /* unicode stuff */
553 const unsigned char* (*utf8decode)(const unsigned char *utf8, unsigned short *ucs);
554 unsigned char* (*iso_decode)(const unsigned char *iso, unsigned char *utf8, int cp, int count);
555 unsigned char* (*utf16LEdecode)(const unsigned char *utf16, unsigned char *utf8, int count);
556 unsigned char* (*utf16BEdecode)(const unsigned char *utf16, unsigned char *utf8, int count);
557 unsigned char* (*utf8encode)(unsigned long ucs, unsigned char *utf8);
558 unsigned long (*utf8length)(const unsigned char *utf8);
559 int (*utf8seek)(const unsigned char* utf8, int offset);
561 /* sound */
562 void (*sound_set)(int setting, int value);
563 int (*sound_default)(int setting);
564 int (*sound_min)(int setting);
565 int (*sound_max)(int setting);
566 const char * (*sound_unit)(int setting);
567 int (*sound_val2phys)(int setting, int value);
568 #ifndef SIMULATOR
569 void (*mp3_play_data)(const unsigned char* start, int size,
570 void (*get_more)(unsigned char** start, size_t* size));
571 void (*mp3_play_pause)(bool play);
572 void (*mp3_play_stop)(void);
573 bool (*mp3_is_playing)(void);
574 #if CONFIG_CODEC != SWCODEC
575 void (*bitswap)(unsigned char *data, int length);
576 #endif
577 #endif /* !SIMULATOR */
578 #if CONFIG_CODEC == SWCODEC
579 const unsigned long *audio_master_sampr_list;
580 const unsigned long *hw_freq_sampr;
581 void (*pcm_apply_settings)(void);
582 void (*pcm_play_data)(pcm_more_callback_type get_more,
583 unsigned char* start, size_t size);
584 void (*pcm_play_stop)(void);
585 void (*pcm_set_frequency)(unsigned int frequency);
586 bool (*pcm_is_playing)(void);
587 bool (*pcm_is_paused)(void);
588 void (*pcm_play_pause)(bool play);
589 size_t (*pcm_get_bytes_waiting)(void);
590 void (*pcm_calculate_peaks)(int *left, int *right);
591 const void* (*pcm_get_peak_buffer)(int *count);
592 void (*pcm_play_lock)(void);
593 void (*pcm_play_unlock)(void);
594 void (*pcmbuf_beep)(unsigned int frequency,
595 size_t duration,
596 int amplitude);
597 #ifdef HAVE_RECORDING
598 const unsigned long *rec_freq_sampr;
599 void (*pcm_init_recording)(void);
600 void (*pcm_close_recording)(void);
601 void (*pcm_record_data)(pcm_more_callback_type2 more_ready,
602 void *start, size_t size);
603 void (*pcm_record_more)(void *start, size_t size);
604 void (*pcm_stop_recording)(void);
605 void (*pcm_calculate_rec_peaks)(int *left, int *right);
606 void (*audio_set_recording_gain)(int left, int right, int type);
607 #endif /* HAVE_RECORDING */
608 #if INPUT_SRC_CAPS != 0
609 void (*audio_set_output_source)(int monitor);
610 void (*audio_set_input_source)(int source, unsigned flags);
611 #endif
612 void (*dsp_set_crossfeed)(bool enable);
613 void (*dsp_set_eq)(bool enable);
614 void (*dsp_dither_enable)(bool enable);
615 intptr_t (*dsp_configure)(struct dsp_config *dsp, int setting,
616 intptr_t value);
617 int (*dsp_process)(struct dsp_config *dsp, char *dest,
618 const char *src[], int count);
619 int (*dsp_input_count)(struct dsp_config *dsp, int count);
620 int (*dsp_output_count)(struct dsp_config *dsp, int count);
621 #endif /* CONFIG_CODEC == SWCODC */
623 /* playback control */
624 int (*playlist_amount)(void);
625 int (*playlist_resume)(void);
626 void (*playlist_start)(int start_index, int offset);
627 int (*playlist_add)(const char *filename);
628 void (*playlist_sync)(struct playlist_info* playlist);
629 int (*playlist_remove_all_tracks)(struct playlist_info *playlist);
630 int (*playlist_create)(const char *dir, const char *file);
631 int (*playlist_insert_track)(struct playlist_info* playlist,
632 const char *filename, int position, bool queue, bool sync);
633 int (*playlist_insert_directory)(struct playlist_info* playlist,
634 const char *dirname, int position, bool queue,
635 bool recurse);
636 int (*playlist_shuffle)(int random_seed, int start_index);
637 void (*audio_play)(long offset);
638 void (*audio_stop)(void);
639 void (*audio_pause)(void);
640 void (*audio_resume)(void);
641 void (*audio_next)(void);
642 void (*audio_prev)(void);
643 void (*audio_ff_rewind)(long newtime);
644 struct mp3entry* (*audio_next_track)(void);
645 int (*audio_status)(void);
646 struct mp3entry* (*audio_current_track)(void);
647 void (*audio_flush_and_reload_tracks)(void);
648 int (*audio_get_file_pos)(void);
649 #if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
650 unsigned long (*mpeg_get_last_header)(void);
651 #endif
652 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) || \
653 (CONFIG_CODEC == SWCODEC)
654 void (*sound_set_pitch)(int32_t pitch);
655 #endif
657 /* MAS communication */
658 #if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
659 int (*mas_readmem)(int bank, int addr, unsigned long* dest, int len);
660 int (*mas_writemem)(int bank, int addr, const unsigned long* src, int len);
661 int (*mas_readreg)(int reg);
662 int (*mas_writereg)(int reg, unsigned int val);
663 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
664 int (*mas_codec_writereg)(int reg, unsigned int val);
665 int (*mas_codec_readreg)(int reg);
666 void (*i2c_begin)(void);
667 void (*i2c_end)(void);
668 int (*i2c_write)(int address, const unsigned char* buf, int count );
669 #endif
670 #endif
672 /* menu */
673 int (*do_menu)(const struct menu_item_ex *menu, int *start_selected,
674 struct viewport parent[NB_SCREENS], bool hide_theme);
676 /* scroll bar */
677 struct gui_syncstatusbar *statusbars;
678 void (*gui_syncstatusbar_draw)(struct gui_syncstatusbar * bars, bool force_redraw);
680 /* options */
681 const struct settings_list* (*get_settings_list)(int*count);
682 const struct settings_list* (*find_setting)(const void* variable, int *id);
683 bool (*option_screen)(const struct settings_list *setting,
684 struct viewport parent[NB_SCREENS],
685 bool use_temp_var, unsigned char* option_title);
686 bool (*set_option)(const char* string, const void* variable,
687 enum optiontype type, const struct opt_items* options,
688 int numoptions, void (*function)(int));
689 bool (*set_bool_options)(const char* string, const bool* variable,
690 const char* yes_str, int yes_voice,
691 const char* no_str, int no_voice,
692 void (*function)(bool));
693 bool (*set_int)(const unsigned char* string, const char* unit, int voice_unit,
694 const int* variable, void (*function)(int), int step,
695 int min, int max,
696 const char* (*formatter)(char*, size_t, int, const char*) );
697 bool (*set_bool)(const char* string, const bool* variable );
699 #ifdef HAVE_LCD_COLOR
700 bool (*set_color)(struct screen *display, char *title,
701 unsigned *color, unsigned banned_color);
702 #endif
703 /* action handling */
704 int (*get_custom_action)(int context,int timeout,
705 const struct button_mapping* (*get_context_map)(int));
706 int (*get_action)(int context, int timeout);
707 #ifdef HAVE_TOUCHSCREEN
708 int (*action_get_touchscreen_press)(short *x, short *y);
709 #endif
710 bool (*action_userabort)(int timeout);
712 /* power */
713 int (*battery_level)(void);
714 bool (*battery_level_safe)(void);
715 int (*battery_time)(void);
716 #ifndef SIMULATOR
717 unsigned int (*battery_voltage)(void);
718 #endif
719 #if CONFIG_CHARGING
720 bool (*charger_inserted)(void);
721 # if CONFIG_CHARGING >= CHARGING_MONITOR
722 bool (*charging_state)(void);
723 # endif
724 #endif
725 #ifdef HAVE_USB_POWER
726 bool (*usb_powered)(void);
727 #endif
729 /* misc */
730 #if !defined(SIMULATOR) || defined(__MINGW32__) || defined(__CYGWIN__)
731 int* __errno;
732 #endif
733 void (*srand)(unsigned int seed);
734 int (*rand)(void);
735 void (*qsort)(void *base, size_t nmemb, size_t size,
736 int(*compar)(const void *, const void *));
737 int (*kbd_input)(char* buffer, int buflen);
738 struct tm* (*get_time)(void);
739 int (*set_time)(const struct tm *tm);
740 #if CONFIG_RTC
741 time_t (*mktime)(struct tm *t);
742 #endif
743 void* (*plugin_get_buffer)(size_t *buffer_size);
744 void* (*plugin_get_audio_buffer)(size_t *buffer_size);
745 void (*plugin_tsr)(bool (*exit_callback)(bool reenter));
746 char* (*plugin_get_current_filename)(void);
747 #ifdef PLUGIN_USE_IRAM
748 void (*plugin_iram_init)(char *iramstart, char *iramcopy, size_t iram_size,
749 char *iedata, size_t iedata_size);
750 #endif
751 #if defined(DEBUG) || defined(SIMULATOR)
752 void (*debugf)(const char *fmt, ...) ATTRIBUTE_PRINTF(1, 2);
753 #endif
754 #ifdef ROCKBOX_HAS_LOGF
755 void (*logf)(const char *fmt, ...) ATTRIBUTE_PRINTF(1, 2);
756 #endif
757 struct user_settings* global_settings;
758 struct system_status *global_status;
759 void (*talk_disable)(bool disable);
760 #if CONFIG_CODEC == SWCODEC
761 void (*codec_thread_do_callback)(void (*fn)(void),
762 unsigned int *audio_thread_id);
763 int (*codec_load_file)(const char* codec, struct codec_api *api);
764 const char *(*get_codec_filename)(int cod_spec);
765 #endif
766 bool (*get_metadata)(struct mp3entry* id3, int fd, const char* trackname);
767 bool (*mp3info)(struct mp3entry *entry, const char *filename);
768 int (*count_mp3_frames)(int fd, int startpos, int filesize,
769 void (*progressfunc)(int));
770 int (*create_xing_header)(int fd, long startpos, long filesize,
771 unsigned char *buf, unsigned long num_frames,
772 unsigned long rec_time, unsigned long header_template,
773 void (*progressfunc)(int), bool generate_toc);
774 unsigned long (*find_next_frame)(int fd, long *offset,
775 long max_offset, unsigned long last_header);
777 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
778 unsigned short (*peak_meter_scale_value)(unsigned short val,
779 int meterwidth);
780 void (*peak_meter_set_use_dbfs)(bool use);
781 bool (*peak_meter_get_use_dbfs)(void);
782 #endif
783 #ifdef HAVE_LCD_BITMAP
784 int (*read_bmp_file)(const char* filename, struct bitmap *bm, int maxsize,
785 int format, const struct custom_format *cformat);
786 int (*read_bmp_fd)(int fd, struct bitmap *bm, int maxsize,
787 int format, const struct custom_format *cformat);
788 #ifdef HAVE_JPEG
789 int (*read_jpeg_file)(const char* filename, struct bitmap *bm, int maxsize,
790 int format, const struct custom_format *cformat);
791 int (*read_jpeg_fd)(int fd, struct bitmap *bm, int maxsize,
792 int format, const struct custom_format *cformat);
793 #endif
794 void (*screen_dump_set_hook)(void (*hook)(int fh));
795 #endif
796 int (*show_logo)(void);
797 struct tree_context* (*tree_get_context)(void);
798 void (*set_current_file)(char* path);
799 void (*set_dirfilter)(int l_dirfilter);
801 #ifdef HAVE_WHEEL_POSITION
802 int (*wheel_status)(void);
803 void (*wheel_send_events)(bool send);
804 #endif
806 #ifdef IRIVER_H100_SERIES
807 /* Routines for the iriver_flash -plugin. */
808 bool (*detect_original_firmware)(void);
809 bool (*detect_flashed_ramimage)(void);
810 bool (*detect_flashed_romimage)(void);
811 #endif
813 void (*led)(bool on);
815 #if (CONFIG_CODEC == SWCODEC)
816 /* buffering API */
817 int (*bufopen)(const char *file, size_t offset, enum data_type type,
818 void *user_data);
819 int (*bufalloc)(const void *src, size_t size, enum data_type type);
820 bool (*bufclose)(int handle_id);
821 int (*bufseek)(int handle_id, size_t newpos);
822 int (*bufadvance)(int handle_id, off_t offset);
823 ssize_t (*bufread)(int handle_id, size_t size, void *dest);
824 ssize_t (*bufgetdata)(int handle_id, size_t size, void **data);
825 ssize_t (*bufgettail)(int handle_id, size_t size, void **data);
826 ssize_t (*bufcuttail)(int handle_id, size_t size);
828 ssize_t (*buf_get_offset)(int handle_id, void *ptr);
829 ssize_t (*buf_handle_offset)(int handle_id);
830 void (*buf_request_buffer_handle)(int handle_id);
831 void (*buf_set_base_handle)(int handle_id);
832 size_t (*buf_used)(void);
833 #endif
835 #ifdef HAVE_TAGCACHE
836 bool (*tagcache_search)(struct tagcache_search *tcs, int tag);
837 void (*tagcache_search_set_uniqbuf)(struct tagcache_search *tcs,
838 void *buffer, long length);
839 bool (*tagcache_search_add_filter)(struct tagcache_search *tcs,
840 int tag, int seek);
841 bool (*tagcache_get_next)(struct tagcache_search *tcs);
842 bool (*tagcache_retrieve)(struct tagcache_search *tcs, int idxid,
843 int tag, char *buf, long size);
844 void (*tagcache_search_finish)(struct tagcache_search *tcs);
845 long (*tagcache_get_numeric)(const struct tagcache_search *tcs, int tag);
846 #ifdef HAVE_TC_RAMCACHE
847 bool (*tagcache_fill_tags)(struct mp3entry *id3, const char *filename);
848 #endif
849 #endif
851 #ifdef HAVE_ALBUMART
852 bool (*search_albumart_files)(const struct mp3entry *id3, const char *size_string,
853 char *buf, int buflen);
854 #endif
856 #ifdef HAVE_SEMAPHORE_OBJECTS
857 void (*semaphore_init)(struct semaphore *s, int max, int start);
858 void (*semaphore_wait)(struct semaphore *s);
859 void (*semaphore_release)(struct semaphore *s);
860 #endif
862 const char *appsversion;
863 /* new stuff at the end, sort into place next time
864 the API gets incompatible */
867 /* plugin header */
868 struct plugin_header {
869 unsigned long magic;
870 unsigned short target_id;
871 unsigned short api_version;
872 unsigned char *load_addr;
873 unsigned char *end_addr;
874 enum plugin_status(*entry_point)(const void*);
875 const struct plugin_api **api;
878 #ifdef PLUGIN
879 #ifndef SIMULATOR
880 extern unsigned char plugin_start_addr[];
881 extern unsigned char plugin_end_addr[];
882 #define PLUGIN_HEADER \
883 const struct plugin_api *rb DATA_ATTR; \
884 const struct plugin_header __header \
885 __attribute__ ((section (".header")))= { \
886 PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \
887 plugin_start_addr, plugin_end_addr, plugin_start, &rb };
888 #else /* SIMULATOR */
889 #define PLUGIN_HEADER \
890 const struct plugin_api *rb DATA_ATTR; \
891 const struct plugin_header __header \
892 __attribute__((visibility("default"))) = { \
893 PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \
894 NULL, NULL, plugin_start, &rb };
895 #endif /* SIMULATOR */
897 #ifdef PLUGIN_USE_IRAM
898 /* Declare IRAM variables */
899 #define PLUGIN_IRAM_DECLARE \
900 extern char iramcopy[]; \
901 extern char iramstart[]; \
902 extern char iramend[]; \
903 extern char iedata[]; \
904 extern char iend[];
905 /* Initialize IRAM */
906 #define PLUGIN_IRAM_INIT(api) \
907 (api)->plugin_iram_init(iramstart, iramcopy, iramend-iramstart, \
908 iedata, iend-iedata);
909 #else
910 #define PLUGIN_IRAM_DECLARE
911 #define PLUGIN_IRAM_INIT(api)
912 #endif /* PLUGIN_USE_IRAM */
913 #endif /* PLUGIN */
915 int plugin_load(const char* plugin, const void* parameter);
916 void* plugin_get_audio_buffer(size_t *buffer_size);
917 #ifdef PLUGIN_USE_IRAM
918 void plugin_iram_init(char *iramstart, char *iramcopy, size_t iram_size,
919 char *iedata, size_t iedata_size);
920 #endif
922 /* plugin_tsr,
923 callback returns true to allow the new plugin to load,
924 reenter means the currently running plugin is being reloaded */
925 void plugin_tsr(bool (*exit_callback)(bool reenter));
927 /* defined by the plugin */
928 extern const struct plugin_api *rb;
929 enum plugin_status plugin_start(const void* parameter)
930 NO_PROF_ATTR;
932 #endif /* __PCTOOL__ */
933 #endif