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