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