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