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