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