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