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