Make TTS name conversion functions static members.
[Rockbox.git] / apps / plugin.h
blob164a2c9847eab7670599b64388bc1567c93745f0
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 Björn Stenberg
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
19 #ifndef _PLUGIN_H_
20 #define _PLUGIN_H_
22 /* instruct simulator code to not redefine any symbols when compiling plugins.
23 (the PLUGIN macro is defined in apps/plugins/Makefile) */
24 #ifdef PLUGIN
25 #define NO_REDEFINES_PLEASE
26 #endif
28 #ifndef MEM
29 #define MEM 2
30 #endif
32 #include <stdbool.h>
33 #include <sys/types.h>
34 #include <stdarg.h>
35 #include <stdio.h>
36 #include <stdlib.h>
37 #include "config.h"
38 #include "system.h"
39 #include "dir.h"
40 #include "general.h"
41 #include "kernel.h"
42 #include "thread.h"
43 #include "button.h"
44 #include "action.h"
45 #include "usb.h"
46 #include "font.h"
47 #include "lcd.h"
48 #include "id3.h"
49 #include "sound.h"
50 #include "mpeg.h"
51 #include "audio.h"
52 #include "mp3_playback.h"
53 #include "talk.h"
54 #ifdef RB_PROFILE
55 #include "profile.h"
56 #endif
57 #include "misc.h"
58 #if (CONFIG_CODEC == SWCODEC)
59 #include "dsp.h"
60 #include "codecs.h"
61 #include "playback.h"
62 #include "metadata.h"
63 #ifdef HAVE_RECORDING
64 #include "recording.h"
65 #endif
66 #else
67 #include "mas.h"
68 #endif /* CONFIG_CODEC == SWCODEC */
69 #include "settings.h"
70 #include "timer.h"
71 #include "playlist.h"
72 #ifdef HAVE_LCD_BITMAP
73 #include "scrollbar.h"
74 #endif
75 #include "statusbar.h"
76 #include "menu.h"
77 #include "rbunicode.h"
78 #include "list.h"
79 #include "tree.h"
80 #include "color_picker.h"
81 #include "buffering.h"
82 #include "tagcache.h"
84 #ifdef HAVE_ALBUMART
85 #include "albumart.h"
86 #endif
88 #ifdef HAVE_REMOTE_LCD
89 #include "lcd-remote.h"
90 #endif
92 #ifdef PLUGIN
94 #if defined(DEBUG) || defined(SIMULATOR)
95 #undef DEBUGF
96 #define DEBUGF rb->debugf
97 #undef LDEBUGF
98 #define LDEBUGF rb->debugf
99 #else
100 #define DEBUGF(...)
101 #define LDEBUGF(...)
102 #endif
104 #ifdef ROCKBOX_HAS_LOGF
105 #undef LOGF
106 #define LOGF rb->logf
107 #else
108 #define LOGF(...)
109 #endif
111 #endif
113 #ifdef SIMULATOR
114 #define PREFIX(_x_) sim_ ## _x_
115 #else
116 #define PREFIX(_x_) _x_
117 #endif
119 #define PLUGIN_MAGIC 0x526F634B /* RocK */
121 /* increase this every time the api struct changes */
122 #define PLUGIN_API_VERSION 99
124 /* update this to latest version if a change to the api struct breaks
125 backwards compatibility (and please take the opportunity to sort in any
126 new function which are "waiting" at the end of the function table) */
127 #define PLUGIN_MIN_API_VERSION 98
129 /* plugin return codes */
130 enum plugin_status {
131 PLUGIN_OK = 0,
132 PLUGIN_USB_CONNECTED,
133 PLUGIN_ERROR = -1,
136 /* NOTE: To support backwards compatibility, only add new functions at
137 the end of the structure. Every time you add a new function,
138 remember to increase PLUGIN_API_VERSION. If you make changes to the
139 existing APIs then also update PLUGIN_MIN_API_VERSION to current
140 version
142 struct plugin_api {
144 /* lcd */
145 void (*lcd_set_contrast)(int x);
146 void (*lcd_update)(void);
147 void (*lcd_clear_display)(void);
148 void (*lcd_setmargins)(int x, int y);
149 int (*lcd_getstringsize)(const unsigned char *str, int *w, int *h);
150 void (*lcd_putsxy)(int x, int y, const unsigned char *string);
151 void (*lcd_puts)(int x, int y, const unsigned char *string);
152 void (*lcd_puts_scroll)(int x, int y, const unsigned char* string);
153 void (*lcd_stop_scroll)(void);
154 #ifdef HAVE_LCD_CHARCELLS
155 void (*lcd_define_pattern)(unsigned long ucs, const char *pattern);
156 unsigned long (*lcd_get_locked_pattern)(void);
157 void (*lcd_unlock_pattern)(unsigned long ucs);
158 void (*lcd_putc)(int x, int y, unsigned long ucs);
159 void (*lcd_put_cursor)(int x, int y, unsigned long ucs);
160 void (*lcd_remove_cursor)(void);
161 void (*lcd_icon)(int icon, bool enable);
162 void (*lcd_double_height)(bool on);
163 #else
164 void (*lcd_set_drawmode)(int mode);
165 int (*lcd_get_drawmode)(void);
166 void (*lcd_setfont)(int font);
167 void (*lcd_drawpixel)(int x, int y);
168 void (*lcd_drawline)(int x1, int y1, int x2, int y2);
169 void (*lcd_hline)(int x1, int x2, int y);
170 void (*lcd_vline)(int x, int y1, int y2);
171 void (*lcd_drawrect)(int x, int y, int width, int height);
172 void (*lcd_fillrect)(int x, int y, int width, int height);
173 void (*lcd_mono_bitmap_part)(const unsigned char *src, int src_x, int src_y,
174 int stride, int x, int y, int width, int height);
175 void (*lcd_mono_bitmap)(const unsigned char *src, int x, int y,
176 int width, int height);
177 #if LCD_DEPTH > 1
178 void (*lcd_set_foreground)(unsigned foreground);
179 unsigned (*lcd_get_foreground)(void);
180 void (*lcd_set_background)(unsigned foreground);
181 unsigned (*lcd_get_background)(void);
182 void (*lcd_bitmap_part)(const fb_data *src, int src_x, int src_y,
183 int stride, int x, int y, int width, int height);
184 void (*lcd_bitmap)(const fb_data *src, int x, int y, int width,
185 int height);
186 fb_data* (*lcd_get_backdrop)(void);
187 void (*lcd_set_backdrop)(fb_data* backdrop);
188 #endif
189 #if LCD_DEPTH == 16
190 void (*lcd_bitmap_transparent_part)(const fb_data *src,
191 int src_x, int src_y, int stride,
192 int x, int y, int width, int height);
193 void (*lcd_bitmap_transparent)(const fb_data *src, int x, int y,
194 int width, int height);
195 #endif
196 unsigned short *(*bidi_l2v)( const unsigned char *str, int orientation );
197 const unsigned char *(*font_get_bits)( struct font *pf, unsigned short char_code );
198 struct font* (*font_load)(const char *path);
199 void (*lcd_puts_style)(int x, int y, const unsigned char *str, int style);
200 void (*lcd_puts_scroll_style)(int x, int y, const unsigned char* string,
201 int style);
202 fb_data* lcd_framebuffer;
203 void (*lcd_blit) (const fb_data* data, int x, int by, int width,
204 int bheight, int stride);
205 void (*lcd_update_rect)(int x, int y, int width, int height);
206 void (*gui_scrollbar_draw)(struct screen * screen, int x, int y,
207 int width, int height, int items,
208 int min_shown, int max_shown,
209 unsigned flags);
210 struct font* (*font_get)(int font);
211 int (*font_getstringsize)(const unsigned char *str, int *w, int *h,
212 int fontnumber);
213 int (*font_get_width)(struct font* pf, unsigned short char_code);
214 void (*screen_clear_area)(struct screen * display, int xstart, int ystart,
215 int width, int height);
216 #endif
217 void (*backlight_on)(void);
218 void (*backlight_off)(void);
219 void (*backlight_set_timeout)(int index);
220 #if CONFIG_CHARGING
221 void (*backlight_set_timeout_plugged)(int index);
222 #endif
223 void (*splash)(int ticks, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3);
225 #ifdef HAVE_REMOTE_LCD
226 /* remote lcd */
227 void (*lcd_remote_set_contrast)(int x);
228 void (*lcd_remote_clear_display)(void);
229 void (*lcd_remote_setmargins)(int x, int y);
230 void (*lcd_remote_puts)(int x, int y, const unsigned char *string);
231 void (*lcd_remote_puts_scroll)(int x, int y, const unsigned char* string);
232 void (*lcd_remote_stop_scroll)(void);
233 void (*lcd_remote_set_drawmode)(int mode);
234 int (*lcd_remote_get_drawmode)(void);
235 void (*lcd_remote_setfont)(int font);
236 int (*lcd_remote_getstringsize)(const unsigned char *str, int *w, int *h);
237 void (*lcd_remote_drawpixel)(int x, int y);
238 void (*lcd_remote_drawline)(int x1, int y1, int x2, int y2);
239 void (*lcd_remote_hline)(int x1, int x2, int y);
240 void (*lcd_remote_vline)(int x, int y1, int y2);
241 void (*lcd_remote_drawrect)(int x, int y, int nx, int ny);
242 void (*lcd_remote_fillrect)(int x, int y, int nx, int ny);
243 void (*lcd_remote_mono_bitmap_part)(const unsigned char *src, int src_x,
244 int src_y, int stride, int x, int y,
245 int width, int height);
246 void (*lcd_remote_mono_bitmap)(const unsigned char *src, int x, int y,
247 int width, int height);
248 void (*lcd_remote_putsxy)(int x, int y, const unsigned char *string);
249 void (*lcd_remote_puts_style)(int x, int y, const unsigned char *str, int style);
250 void (*lcd_remote_puts_scroll_style)(int x, int y, const unsigned char* string,
251 int style);
252 fb_remote_data* lcd_remote_framebuffer;
253 void (*lcd_remote_update)(void);
254 void (*lcd_remote_update_rect)(int x, int y, int width, int height);
256 void (*remote_backlight_on)(void);
257 void (*remote_backlight_off)(void);
258 #endif
259 struct screen* screens[NB_SCREENS];
260 #if defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)
261 void (*lcd_remote_set_foreground)(unsigned foreground);
262 unsigned (*lcd_remote_get_foreground)(void);
263 void (*lcd_remote_set_background)(unsigned background);
264 unsigned (*lcd_remote_get_background)(void);
265 void (*lcd_remote_bitmap_part)(const fb_remote_data *src, int src_x, int src_y,
266 int stride, int x, int y, int width, int height);
267 void (*lcd_remote_bitmap)(const fb_remote_data *src, int x, int y, int width,
268 int height);
269 #endif
270 #if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4) && !defined(SIMULATOR)
271 void (*lcd_grey_phase_blit)(unsigned char *values, unsigned char *phases,
272 int bx, int by, int bwidth, int bheight,
273 int stride);
274 #endif
275 #if defined(HAVE_LCD_COLOR)
276 void (*lcd_yuv_blit)(unsigned char * const src[3],
277 int src_x, int src_y, int stride,
278 int x, int y, int width, int height);
279 #endif
281 #if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) || defined(SANSA_C200) \
282 || defined (IRIVER_H10)
283 void (*lcd_yuv_set_options)(unsigned options);
284 #endif
286 /* list */
287 void (*gui_synclist_init)(struct gui_synclist * lists,
288 list_get_name callback_get_item_name,void * data,
289 bool scroll_all,int selected_size);
290 void (*gui_synclist_set_nb_items)(struct gui_synclist * lists, int nb_items);
291 void (*gui_synclist_set_icon_callback)(struct gui_synclist * lists, list_get_icon icon_callback);
292 int (*gui_synclist_get_nb_items)(struct gui_synclist * lists);
293 int (*gui_synclist_get_sel_pos)(struct gui_synclist * lists);
294 void (*gui_synclist_draw)(struct gui_synclist * lists);
295 void (*gui_synclist_select_item)(struct gui_synclist * lists,
296 int item_number);
297 void (*gui_synclist_add_item)(struct gui_synclist * lists);
298 void (*gui_synclist_del_item)(struct gui_synclist * lists);
299 void (*gui_synclist_limit_scroll)(struct gui_synclist * lists, bool scroll);
300 bool (*gui_synclist_do_button)(struct gui_synclist * lists,
301 unsigned *action, enum list_wrap wrap);
302 void (*gui_synclist_set_title)(struct gui_synclist *lists, char* title, int icon);
304 /* button */
305 long (*button_get)(bool block);
306 long (*button_get_w_tmo)(int ticks);
307 int (*button_status)(void);
308 void (*button_clear_queue)(void);
309 int (*button_queue_count)(void);
310 #ifdef HAS_BUTTON_HOLD
311 bool (*button_hold)(void);
312 #endif
314 /* file */
315 int (*PREFIX(open))(const char* pathname, int flags);
316 int (*PREFIX(close))(int fd);
317 ssize_t (*PREFIX(read))(int fd, void* buf, size_t count);
318 off_t (*PREFIX(lseek))(int fd, off_t offset, int whence);
319 int (*PREFIX(creat))(const char *pathname);
320 ssize_t (*PREFIX(write))(int fd, const void* buf, size_t count);
321 int (*PREFIX(remove))(const char* pathname);
322 int (*PREFIX(rename))(const char* path, const char* newname);
323 int (*PREFIX(ftruncate))(int fd, off_t length);
324 off_t (*PREFIX(filesize))(int fd);
325 int (*fdprintf)(int fd, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3);
326 int (*read_line)(int fd, char* buffer, int buffer_size);
327 bool (*settings_parseline)(char* line, char** name, char** value);
328 #ifndef SIMULATOR
329 void (*ata_sleep)(void);
330 bool (*ata_disk_is_active)(void);
331 #endif
332 void (*ata_spindown)(int seconds);
333 void (*reload_directory)(void);
334 char *(*create_numbered_filename)(char *buffer, const char *path,
335 const char *prefix, const char *suffix,
336 int numberlen IF_CNFN_NUM_(, int *num));
338 /* dir */
339 DIR* (*opendir)(const char* name);
340 int (*closedir)(DIR* dir);
341 struct dirent* (*readdir)(DIR* dir);
342 int (*mkdir)(const char *name);
343 int (*rmdir)(const char *name);
345 /* kernel/ system */
346 void (*PREFIX(sleep))(int ticks);
347 void (*yield)(void);
348 #ifdef HAVE_PRIORITY_SCHEDULING
349 void (*priority_yield)(void);
350 #endif
351 volatile long* current_tick;
352 long (*default_event_handler)(long event);
353 long (*default_event_handler_ex)(long event, void (*callback)(void *), void *parameter);
354 struct thread_entry* threads;
355 struct thread_entry* (*create_thread)(void (*function)(void), void* stack,
356 int stack_size, unsigned flags,
357 const char *name
358 IF_PRIO(, int priority)
359 IF_COP(, unsigned int core));
360 void (*remove_thread)(struct thread_entry *thread);
361 void (*reset_poweroff_timer)(void);
362 #ifndef SIMULATOR
363 int (*system_memory_guard)(int newmode);
364 long *cpu_frequency;
365 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
366 #ifdef CPU_BOOST_LOGGING
367 void (*cpu_boost_)(bool on_off,char*location,int line);
368 #else
369 void (*cpu_boost)(bool on_off);
370 #endif
371 #endif
372 #endif
373 bool (*timer_register)(int reg_prio, void (*unregister_callback)(void),
374 long cycles, int int_prio,
375 void (*timer_callback)(void));
376 void (*timer_unregister)(void);
377 bool (*timer_set_period)(long count);
379 void (*queue_init)(struct event_queue *q, bool register_queue);
380 void (*queue_delete)(struct event_queue *q);
381 void (*queue_post)(struct event_queue *q, long id, intptr_t data);
382 void (*queue_wait_w_tmo)(struct event_queue *q, struct queue_event *ev,
383 int ticks);
384 void (*usb_acknowledge)(long id);
385 #ifdef RB_PROFILE
386 void (*profile_thread)(void);
387 void (*profstop)(void);
388 void (*profile_func_enter)(void *this_fn, void *call_site);
389 void (*profile_func_exit)(void *this_fn, void *call_site);
390 #endif
392 #ifdef SIMULATOR
393 /* special simulator hooks */
394 #if defined(HAVE_LCD_BITMAP) && LCD_DEPTH < 8
395 void (*sim_lcd_ex_init)(int shades, unsigned long (*getpixel)(int, int));
396 void (*sim_lcd_ex_update_rect)(int x, int y, int width, int height);
397 #endif
398 #endif
400 /* strings and memory */
401 int (*snprintf)(char *buf, size_t size, const char *fmt, ...)
402 ATTRIBUTE_PRINTF(3, 4);
403 int (*vsnprintf)(char *buf, int size, const char *fmt, va_list ap);
404 char* (*strcpy)(char *dst, const char *src);
405 char* (*strncpy)(char *dst, const char *src, size_t length);
406 size_t (*strlen)(const char *str);
407 char * (*strrchr)(const char *s, int c);
408 int (*strcmp)(const char *, const char *);
409 int (*strncmp)(const char *, const char *, size_t);
410 int (*strcasecmp)(const char *, const char *);
411 int (*strncasecmp)(const char *s1, const char *s2, size_t n);
412 void* (*memset)(void *dst, int c, size_t length);
413 void* (*memcpy)(void *out, const void *in, size_t n);
414 void* (*memmove)(void *out, const void *in, size_t n);
415 const unsigned char *_ctype_;
416 int (*atoi)(const char *str);
417 char *(*strchr)(const char *s, int c);
418 char *(*strcat)(char *s1, const char *s2);
419 void *(*memchr)(const void *s1, int c, size_t n);
420 int (*memcmp)(const void *s1, const void *s2, size_t n);
421 char *(*strcasestr) (const char* phaystack, const char* pneedle);
422 char* (*strtok_r)(char *ptr, const char *sep, char **end);
423 /* unicode stuff */
424 const unsigned char* (*utf8decode)(const unsigned char *utf8, unsigned short *ucs);
425 unsigned char* (*iso_decode)(const unsigned char *iso, unsigned char *utf8, int cp, int count);
426 unsigned char* (*utf16LEdecode)(const unsigned char *utf16, unsigned char *utf8, int count);
427 unsigned char* (*utf16BEdecode)(const unsigned char *utf16, unsigned char *utf8, int count);
428 unsigned char* (*utf8encode)(unsigned long ucs, unsigned char *utf8);
429 unsigned long (*utf8length)(const unsigned char *utf8);
430 int (*utf8seek)(const unsigned char* utf8, int offset);
432 /* sound */
433 #if CONFIG_CODEC == SWCODEC
434 int (*sound_default)(int setting);
435 #endif
436 void (*sound_set)(int setting, int value);
437 int (*sound_min)(int setting);
438 int (*sound_max)(int setting);
439 #ifndef SIMULATOR
440 void (*mp3_play_data)(const unsigned char* start, int size, void (*get_more)(unsigned char** start, size_t* size));
441 void (*mp3_play_pause)(bool play);
442 void (*mp3_play_stop)(void);
443 bool (*mp3_is_playing)(void);
444 #if CONFIG_CODEC != SWCODEC
445 void (*bitswap)(unsigned char *data, int length);
446 #endif
447 #endif /* !SIMULATOR */
448 #if CONFIG_CODEC == SWCODEC
449 const unsigned long *audio_master_sampr_list;
450 const unsigned long *hw_freq_sampr;
451 void (*pcm_apply_settings)(void);
452 void (*pcm_play_data)(pcm_more_callback_type get_more,
453 unsigned char* start, size_t size);
454 void (*pcm_play_stop)(void);
455 void (*pcm_set_frequency)(unsigned int frequency);
456 bool (*pcm_is_playing)(void);
457 bool (*pcm_is_paused)(void);
458 void (*pcm_play_pause)(bool play);
459 size_t (*pcm_get_bytes_waiting)(void);
460 void (*pcm_calculate_peaks)(int *left, int *right);
461 #ifdef HAVE_RECORDING
462 const unsigned long *rec_freq_sampr;
463 void (*pcm_init_recording)(void);
464 void (*pcm_close_recording)(void);
465 void (*pcm_record_data)(pcm_more_callback_type2 more_ready,
466 void *start, size_t size);
467 void (*pcm_record_more)(void *start, size_t size);
468 void (*pcm_stop_recording)(void);
469 void (*pcm_calculate_rec_peaks)(int *left, int *right);
470 void (*audio_set_recording_gain)(int left, int right, int type);
471 #endif /* HAVE_RECORDING */
472 #if INPUT_SRC_CAPS != 0
473 void (*audio_set_output_source)(int monitor);
474 void (*audio_set_input_source)(int source, unsigned flags);
475 #endif
476 #endif /* CONFIG_CODEC == SWCODC */
478 /* playback control */
479 int (*playlist_amount)(void);
480 int (*playlist_resume)(void);
481 int (*playlist_start)(int start_index, int offset);
482 void (*PREFIX(audio_play))(long offset);
483 void (*audio_stop)(void);
484 void (*audio_pause)(void);
485 void (*audio_resume)(void);
486 void (*audio_next)(void);
487 void (*audio_prev)(void);
488 void (*audio_ff_rewind)(long newtime);
489 struct mp3entry* (*audio_next_track)(void);
490 int (*audio_status)(void);
491 bool (*audio_has_changed_track)(void);
492 struct mp3entry* (*audio_current_track)(void);
493 void (*audio_flush_and_reload_tracks)(void);
494 int (*audio_get_file_pos)(void);
495 #if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
496 unsigned long (*mpeg_get_last_header)(void);
497 #endif
498 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) || \
499 (CONFIG_CODEC == SWCODEC)
500 void (*sound_set_pitch)(int pitch);
501 #endif
503 /* MAS communication */
504 #if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
505 int (*mas_readmem)(int bank, int addr, unsigned long* dest, int len);
506 int (*mas_writemem)(int bank, int addr, const unsigned long* src, int len);
507 int (*mas_readreg)(int reg);
508 int (*mas_writereg)(int reg, unsigned int val);
509 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
510 int (*mas_codec_writereg)(int reg, unsigned int val);
511 int (*mas_codec_readreg)(int reg);
512 void (*i2c_begin)(void);
513 void (*i2c_end)(void);
514 int (*i2c_write)(int address, unsigned char* buf, int count );
515 #endif
516 #endif
518 /* menu */
519 int (*do_menu)(const struct menu_item_ex *menu, int *start_selected);
521 /* scroll bar */
522 struct gui_syncstatusbar *statusbars;
523 void (*gui_syncstatusbar_draw)(struct gui_syncstatusbar * bars, bool force_redraw);
525 /* options */
526 const struct settings_list* (*find_setting)(void* variable, int *id);
527 bool (*option_screen)(struct settings_list *setting,
528 bool use_temp_var, unsigned char* option_title);
529 bool (*set_option)(const char* string, void* variable,
530 enum optiontype type, const struct opt_items* options,
531 int numoptions, void (*function)(int));
532 bool (*set_bool_options)(const char* string, bool* variable,
533 const char* yes_str, int yes_voice,
534 const char* no_str, int no_voice,
535 void (*function)(bool));
536 bool (*set_int)(const unsigned char* string, const char* unit, int voice_unit,
537 int* variable, void (*function)(int), int step, int min,
538 int max, void (*formatter)(char*, size_t, int, const char*) );
539 bool (*set_bool)(const char* string, bool* variable );
541 #ifdef HAVE_LCD_COLOR
542 bool (*set_color)(struct screen *display, char *title, unsigned *color,
543 unsigned banned_color);
544 #endif
545 /* action handling */
546 int (*get_custom_action)(int context,int timeout,
547 const struct button_mapping* (*get_context_map)(int));
548 int (*get_action)(int context, int timeout);
549 bool (*action_userabort)(int timeout);
551 /* power */
552 int (*battery_level)(void);
553 bool (*battery_level_safe)(void);
554 int (*battery_time)(void);
555 #ifndef SIMULATOR
556 unsigned int (*battery_voltage)(void);
557 #endif
558 #if CONFIG_CHARGING
559 bool (*charger_inserted)(void);
560 # if CONFIG_CHARGING == CHARGING_MONITOR
561 bool (*charging_state)(void);
562 # endif
563 #endif
564 #ifdef HAVE_USB_POWER
565 bool (*usb_powered)(void);
566 #endif
568 /* misc */
569 void (*srand)(unsigned int seed);
570 int (*rand)(void);
571 void (*qsort)(void *base, size_t nmemb, size_t size,
572 int(*compar)(const void *, const void *));
573 int (*kbd_input)(char* buffer, int buflen);
574 struct tm* (*get_time)(void);
575 int (*set_time)(const struct tm *tm);
576 #if CONFIG_RTC
577 time_t (*mktime)(struct tm *t);
578 #endif
579 void* (*plugin_get_buffer)(size_t *buffer_size);
580 void* (*plugin_get_audio_buffer)(size_t *buffer_size);
581 void (*plugin_tsr)(bool (*exit_callback)(bool reenter));
582 char* (*plugin_get_current_filename)(void);
583 #ifdef PLUGIN_USE_IRAM
584 void (*plugin_iram_init)(char *iramstart, char *iramcopy, size_t iram_size,
585 char *iedata, size_t iedata_size);
586 #endif
587 #if defined(DEBUG) || defined(SIMULATOR)
588 void (*debugf)(const char *fmt, ...) ATTRIBUTE_PRINTF(1, 2);
589 #endif
590 #ifdef ROCKBOX_HAS_LOGF
591 void (*logf)(const char *fmt, ...) ATTRIBUTE_PRINTF(1, 2);
592 #endif
593 struct user_settings* global_settings;
594 struct system_status *global_status;
595 void (*talk_disable)(bool disable);
596 #if CONFIG_CODEC == SWCODEC
597 int (*codec_load_file)(const char* codec, struct codec_api *api);
598 const char *(*get_codec_filename)(int cod_spec);
599 bool (*get_metadata)(struct mp3entry* id3, int fd, const char* trackname);
600 #endif
601 bool (*mp3info)(struct mp3entry *entry, const char *filename);
602 int (*count_mp3_frames)(int fd, int startpos, int filesize,
603 void (*progressfunc)(int));
604 int (*create_xing_header)(int fd, long startpos, long filesize,
605 unsigned char *buf, unsigned long num_frames,
606 unsigned long rec_time, unsigned long header_template,
607 void (*progressfunc)(int), bool generate_toc);
608 unsigned long (*find_next_frame)(int fd, long *offset,
609 long max_offset, unsigned long last_header);
611 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
612 unsigned short (*peak_meter_scale_value)(unsigned short val,
613 int meterwidth);
614 void (*peak_meter_set_use_dbfs)(bool use);
615 bool (*peak_meter_get_use_dbfs)(void);
616 #endif
617 #ifdef HAVE_LCD_BITMAP
618 int (*read_bmp_file)(const char* filename, struct bitmap *bm, int maxsize,
619 int format);
620 void (*screen_dump_set_hook)(void (*hook)(int fh));
621 #endif
622 int (*show_logo)(void);
623 struct tree_context* (*tree_get_context)(void);
624 void (*set_current_file)(char* path);
625 void (*set_dirfilter)(int l_dirfilter);
627 #ifdef HAVE_WHEEL_POSITION
628 int (*wheel_status)(void);
629 void (*wheel_send_events)(bool send);
630 #endif
632 #ifdef IRIVER_H100_SERIES
633 /* Routines for the iriver_flash -plugin. */
634 bool (*detect_original_firmware)(void);
635 bool (*detect_flashed_ramimage)(void);
636 bool (*detect_flashed_romimage)(void);
637 #endif
639 void (*led)(bool on);
641 #ifdef CACHE_FUNCTIONS_AS_CALL
642 void (*flush_icache)(void);
643 void (*invalidate_icache)(void);
644 #endif
646 /* new stuff at the end, sort into place next time
647 the API gets incompatible */
649 #if (CONFIG_CODEC == SWCODEC)
650 void (*mutex_init)(struct mutex *m);
651 void (*mutex_lock)(struct mutex *m);
652 void (*mutex_unlock)(struct mutex *m);
653 #endif
655 void (*thread_wait)(struct thread_entry *thread);
657 #if (CONFIG_CODEC == SWCODEC)
658 size_t (*align_buffer)(void **start, size_t size, size_t align);
659 #endif
661 bool (*file_exists)(const char *file);
662 bool (*dir_exists)(const char *path);
664 #ifdef HAVE_REMOTE_LCD
665 void (*remote_backlight_set_timeout)(int index);
666 #if CONFIG_CHARGING
667 void (*remote_backlight_set_timeout_plugged)(int index);
668 #endif
669 #endif /* HAVE_REMOTE_LCD */
671 #if (CONFIG_CODEC == SWCODEC)
672 int (*bufopen)(const char *file, size_t offset, enum data_type type);
673 int (*bufalloc)(const void *src, size_t size, enum data_type type);
674 bool (*bufclose)(int handle_id);
675 int (*bufseek)(int handle_id, size_t newpos);
676 int (*bufadvance)(int handle_id, off_t offset);
677 ssize_t (*bufread)(int handle_id, size_t size, void *dest);
678 ssize_t (*bufgetdata)(int handle_id, size_t size, void **data);
679 ssize_t (*bufgettail)(int handle_id, size_t size, void **data);
680 ssize_t (*bufcuttail)(int handle_id, size_t size);
682 ssize_t (*buf_get_offset)(int handle_id, void *ptr);
683 ssize_t (*buf_handle_offset)(int handle_id);
684 void (*buf_request_buffer_handle)(int handle_id);
685 void (*buf_set_base_handle)(int handle_id);
686 size_t (*buf_used)(void);
687 #endif
689 #ifdef HAVE_TAGCACHE
690 bool (*tagcache_search)(struct tagcache_search *tcs, int tag);
691 void (*tagcache_search_set_uniqbuf)(struct tagcache_search *tcs,
692 void *buffer, long length);
693 bool (*tagcache_search_add_filter)(struct tagcache_search *tcs,
694 int tag, int seek);
695 bool (*tagcache_get_next)(struct tagcache_search *tcs);
696 bool (*tagcache_retrieve)(struct tagcache_search *tcs, int idxid,
697 int tag, char *buf, long size);
698 void (*tagcache_search_finish)(struct tagcache_search *tcs);
699 #endif
701 #ifdef HAVE_ALBUMART
702 bool (*find_albumart)(const struct mp3entry *id3, char *buf, int buflen);
703 bool (*search_albumart_files)(const struct mp3entry *id3, const char *size_string,
704 char *buf, int buflen);
705 #endif
707 #if CONFIG_CODEC == SWCODEC
708 void (*pcm_play_lock)(void);
709 void (*pcm_play_unlock)(void);
710 void (*queue_enable_queue_send)(struct event_queue *q,
711 struct queue_sender_list *send);
712 bool (*queue_empty)(const struct event_queue *q);
713 void (*queue_wait)(struct event_queue *q, struct queue_event *ev);
714 intptr_t (*queue_send)(struct event_queue *q, long id,
715 intptr_t data);
716 void (*queue_reply)(struct event_queue *q, intptr_t retval);
717 #ifndef HAVE_FLASH_STORAGE
718 void (*ata_spin)(void);
719 #endif
720 #ifdef HAVE_SCHEDULER_BOOSTCTRL
721 void (*trigger_cpu_boost)(void);
722 void (*cancel_cpu_boost)(void);
723 #endif
724 const char * (*sound_unit)(int setting);
725 int (*sound_val2phys)(int setting, int value);
726 void (*dsp_set_crossfeed)(bool enable);
727 void (*dsp_set_eq)(bool enable);
728 void (*dsp_dither_enable)(bool enable);
729 intptr_t (*dsp_configure)(struct dsp_config *dsp, int setting,
730 intptr_t value);
731 int (*dsp_process)(struct dsp_config *dsp, char *dest,
732 const char *src[], int count);
733 #endif /* CONFIG_CODEC == SWCODEC */
736 /* plugin header */
737 struct plugin_header {
738 unsigned long magic;
739 unsigned short target_id;
740 unsigned short api_version;
741 unsigned char *load_addr;
742 unsigned char *end_addr;
743 enum plugin_status(*entry_point)(struct plugin_api*, void*);
746 #ifdef PLUGIN
747 #ifndef SIMULATOR
748 extern unsigned char plugin_start_addr[];
749 extern unsigned char plugin_end_addr[];
750 #define PLUGIN_HEADER \
751 const struct plugin_header __header \
752 __attribute__ ((section (".header")))= { \
753 PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \
754 plugin_start_addr, plugin_end_addr, plugin_start };
755 #else /* SIMULATOR */
756 #define PLUGIN_HEADER \
757 const struct plugin_header __header \
758 __attribute__((visibility("default"))) = { \
759 PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \
760 NULL, NULL, plugin_start };
761 #endif /* SIMULATOR */
763 #ifdef PLUGIN_USE_IRAM
764 /* Declare IRAM variables */
765 #define PLUGIN_IRAM_DECLARE \
766 extern char iramcopy[]; \
767 extern char iramstart[]; \
768 extern char iramend[]; \
769 extern char iedata[]; \
770 extern char iend[];
771 /* Initialize IRAM */
772 #define PLUGIN_IRAM_INIT(api) \
773 (api)->plugin_iram_init(iramstart, iramcopy, iramend-iramstart, \
774 iedata, iend-iedata);
775 #else
776 #define PLUGIN_IRAM_DECLARE
777 #define PLUGIN_IRAM_INIT(api)
778 #endif /* PLUGIN_USE_IRAM */
779 #endif /* PLUGIN */
781 int plugin_load(const char* plugin, void* parameter);
782 void* plugin_get_buffer(size_t *buffer_size);
783 void* plugin_get_audio_buffer(size_t *buffer_size);
784 #ifdef PLUGIN_USE_IRAM
785 void plugin_iram_init(char *iramstart, char *iramcopy, size_t iram_size,
786 char *iedata, size_t iedata_size);
787 #endif
789 /* plugin_tsr,
790 callback returns true to allow the new plugin to load,
791 reenter means the currently running plugin is being reloaded */
792 void plugin_tsr(bool (*exit_callback)(bool reenter));
794 /* defined by the plugin */
795 enum plugin_status plugin_start(struct plugin_api* rockbox, void* parameter)
796 NO_PROF_ATTR;
798 /* Use this macro in plugins where gcc tries to optimize by calling
799 * these functions directly */
800 #define MEM_FUNCTION_WRAPPERS(api) \
801 void *memcpy(void *dest, const void *src, size_t n) \
803 return (api)->memcpy(dest, src, n); \
805 void *memset(void *dest, int c, size_t n) \
807 return (api)->memset(dest, c, n); \
809 void *memmove(void *dest, const void *src, size_t n) \
811 return (api)->memmove(dest, src, n); \
813 int memcmp(const void *s1, const void *s2, size_t n) \
815 return (api)->memcmp(s1, s2, n); \
818 #ifndef CACHE_FUNCTION_WRAPPERS
820 #ifdef CACHE_FUNCTIONS_AS_CALL
821 #define CACHE_FUNCTION_WRAPPERS(api) \
822 void flush_icache(void) \
824 (api)->flush_icache(); \
826 void invalidate_icache(void) \
828 (api)->invalidate_icache(); \
830 #else
831 #define CACHE_FUNCTION_WRAPPERS(api)
832 #endif /* CACHE_FUNCTIONS_AS_CALL */
834 #endif /* CACHE_FUNCTION_WRAPPERS */
836 #ifndef ALIGN_BUFFER_WRAPPER
837 #define ALIGN_BUFFER_WRAPPER(api) \
838 size_t align_buffer(void **start, size_t size, size_t align) \
840 return (api)->align_buffer(start, size, align); \
842 #endif /* ALIGN_BUFFER_WRAPPER */
844 #endif