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