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