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