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