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