grr.. typo
[Rockbox.git] / apps / plugin.h
blob2db38eda4cc72ec2e4b25d90edc4b4eb77ffb53d
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 108
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 108
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);
216 unsigned short *(*bidi_l2v)( const unsigned char *str, int orientation );
217 const unsigned char *(*font_get_bits)( struct font *pf, unsigned short char_code );
218 struct font* (*font_load)(const char *path);
219 struct font* (*font_get)(int font);
220 int (*font_getstringsize)(const unsigned char *str, int *w, int *h,
221 int fontnumber);
222 int (*font_get_width)(struct font* pf, unsigned short char_code);
223 void (*screen_clear_area)(struct screen * display, int xstart, int ystart,
224 int width, int height);
225 void (*gui_scrollbar_draw)(struct screen * screen, int x, int y,
226 int width, int height, int items,
227 int min_shown, int max_shown,
228 unsigned flags);
229 #endif /* HAVE_LCD_BITMAP */
231 /* backlight */
232 void (*backlight_on)(void);
233 void (*backlight_off)(void);
234 void (*backlight_set_timeout)(int index);
235 #if CONFIG_CHARGING
236 void (*backlight_set_timeout_plugged)(int index);
237 #endif
238 bool (*is_backlight_on)(bool ignore_always_off);
239 void (*splash)(int ticks, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3);
241 #ifdef HAVE_REMOTE_LCD
242 /* remote lcd */
243 void (*lcd_remote_set_contrast)(int x);
244 void (*lcd_remote_clear_display)(void);
245 void (*lcd_remote_setmargins)(int x, int y);
246 void (*lcd_remote_puts)(int x, int y, const unsigned char *string);
247 void (*lcd_remote_puts_scroll)(int x, int y, const unsigned char* string);
248 void (*lcd_remote_stop_scroll)(void);
249 void (*lcd_remote_set_drawmode)(int mode);
250 int (*lcd_remote_get_drawmode)(void);
251 void (*lcd_remote_setfont)(int font);
252 int (*lcd_remote_getstringsize)(const unsigned char *str, int *w, int *h);
253 void (*lcd_remote_drawpixel)(int x, int y);
254 void (*lcd_remote_drawline)(int x1, int y1, int x2, int y2);
255 void (*lcd_remote_hline)(int x1, int x2, int y);
256 void (*lcd_remote_vline)(int x, int y1, int y2);
257 void (*lcd_remote_drawrect)(int x, int y, int nx, int ny);
258 void (*lcd_remote_fillrect)(int x, int y, int nx, int ny);
259 void (*lcd_remote_mono_bitmap_part)(const unsigned char *src, int src_x,
260 int src_y, int stride, int x, int y,
261 int width, int height);
262 void (*lcd_remote_mono_bitmap)(const unsigned char *src, int x, int y,
263 int width, int height);
264 void (*lcd_remote_putsxy)(int x, int y, const unsigned char *string);
265 void (*lcd_remote_puts_style)(int x, int y, const unsigned char *str, int style);
266 void (*lcd_remote_puts_scroll_style)(int x, int y, const unsigned char* string,
267 int style);
268 fb_remote_data* lcd_remote_framebuffer;
269 void (*lcd_remote_update)(void);
270 void (*lcd_remote_update_rect)(int x, int y, int width, int height);
272 void (*remote_backlight_on)(void);
273 void (*remote_backlight_off)(void);
274 void (*remote_backlight_set_timeout)(int index);
275 #if CONFIG_CHARGING
276 void (*remote_backlight_set_timeout_plugged)(int index);
277 #endif
278 #endif /* HAVE_REMOTE_LCD */
279 struct screen* screens[NB_SCREENS];
280 #if defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)
281 void (*lcd_remote_set_foreground)(unsigned foreground);
282 unsigned (*lcd_remote_get_foreground)(void);
283 void (*lcd_remote_set_background)(unsigned background);
284 unsigned (*lcd_remote_get_background)(void);
285 void (*lcd_remote_bitmap_part)(const fb_remote_data *src, int src_x, int src_y,
286 int stride, int x, int y, int width, int height);
287 void (*lcd_remote_bitmap)(const fb_remote_data *src, int x, int y, int width,
288 int height);
289 #endif
290 void (*viewport_set_defaults)(struct viewport *vp, enum screen_type screen);
291 /* list */
292 void (*gui_synclist_init)(struct gui_synclist * lists,
293 list_get_name callback_get_item_name,void * data,
294 bool scroll_all,int selected_size,
295 struct viewport parent[NB_SCREENS]);
296 void (*gui_synclist_set_nb_items)(struct gui_synclist * lists, int nb_items);
297 void (*gui_synclist_set_icon_callback)(struct gui_synclist * lists, list_get_icon icon_callback);
298 int (*gui_synclist_get_nb_items)(struct gui_synclist * lists);
299 int (*gui_synclist_get_sel_pos)(struct gui_synclist * lists);
300 void (*gui_synclist_draw)(struct gui_synclist * lists);
301 void (*gui_synclist_select_item)(struct gui_synclist * lists,
302 int item_number);
303 void (*gui_synclist_add_item)(struct gui_synclist * lists);
304 void (*gui_synclist_del_item)(struct gui_synclist * lists);
305 void (*gui_synclist_limit_scroll)(struct gui_synclist * lists, bool scroll);
306 bool (*gui_synclist_do_button)(struct gui_synclist * lists,
307 unsigned *action, enum list_wrap wrap);
308 void (*gui_synclist_set_title)(struct gui_synclist *lists, char* title, int icon);
310 /* button */
311 long (*button_get)(bool block);
312 long (*button_get_w_tmo)(int ticks);
313 int (*button_status)(void);
314 void (*button_clear_queue)(void);
315 int (*button_queue_count)(void);
316 #ifdef HAS_BUTTON_HOLD
317 bool (*button_hold)(void);
318 #endif
320 /* file */
321 int (*PREFIX(open))(const char* pathname, int flags);
322 int (*PREFIX(close))(int fd);
323 ssize_t (*PREFIX(read))(int fd, void* buf, size_t count);
324 off_t (*PREFIX(lseek))(int fd, off_t offset, int whence);
325 int (*PREFIX(creat))(const char *pathname);
326 ssize_t (*PREFIX(write))(int fd, const void* buf, size_t count);
327 int (*PREFIX(remove))(const char* pathname);
328 int (*PREFIX(rename))(const char* path, const char* newname);
329 int (*PREFIX(ftruncate))(int fd, off_t length);
330 off_t (*PREFIX(filesize))(int fd);
331 int (*fdprintf)(int fd, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3);
332 int (*read_line)(int fd, char* buffer, int buffer_size);
333 bool (*settings_parseline)(char* line, char** name, char** value);
334 void (*ata_sleep)(void);
335 #ifndef SIMULATOR
336 bool (*ata_disk_is_active)(void);
337 #endif
338 void (*ata_spin)(void);
339 void (*ata_spindown)(int seconds);
340 void (*reload_directory)(void);
341 char *(*create_numbered_filename)(char *buffer, const char *path,
342 const char *prefix, const char *suffix,
343 int numberlen IF_CNFN_NUM_(, int *num));
344 bool (*file_exists)(const char *file);
347 /* dir */
348 DIR* (*opendir)(const char* name);
349 int (*closedir)(DIR* dir);
350 struct dirent* (*readdir)(DIR* dir);
351 int (*mkdir)(const char *name);
352 int (*rmdir)(const char *name);
353 bool (*dir_exists)(const char *path);
355 /* kernel/ system */
356 void (*PREFIX(sleep))(int ticks);
357 void (*yield)(void);
358 volatile long* current_tick;
359 long (*default_event_handler)(long event);
360 long (*default_event_handler_ex)(long event, void (*callback)(void *), void *parameter);
361 struct thread_entry* threads;
362 struct thread_entry* (*create_thread)(void (*function)(void), void* stack,
363 size_t stack_size, unsigned flags,
364 const char *name
365 IF_PRIO(, int priority)
366 IF_COP(, unsigned int core));
367 void (*thread_exit)(void);
368 void (*thread_wait)(struct thread_entry *thread);
369 #if CONFIG_CODEC == SWCODEC
370 void (*mutex_init)(struct mutex *m);
371 void (*mutex_lock)(struct mutex *m);
372 void (*mutex_unlock)(struct mutex *m);
373 size_t (*align_buffer)(void **start, size_t size, size_t align);
374 #endif
376 void (*reset_poweroff_timer)(void);
377 #ifndef SIMULATOR
378 int (*system_memory_guard)(int newmode);
379 long *cpu_frequency;
380 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
381 #ifdef CPU_BOOST_LOGGING
382 void (*cpu_boost_)(bool on_off,char*location,int line);
383 #else
384 void (*cpu_boost)(bool on_off);
385 #endif
386 #endif /* HAVE_ADJUSTABLE_CPU_FREQ */
387 #endif /* !SIMULATOR */
388 #ifdef HAVE_SCHEDULER_BOOSTCTRL
389 void (*trigger_cpu_boost)(void);
390 void (*cancel_cpu_boost)(void);
391 #endif
392 #ifdef CACHE_FUNCTIONS_AS_CALL
393 void (*flush_icache)(void);
394 void (*invalidate_icache)(void);
395 #endif
396 bool (*timer_register)(int reg_prio, void (*unregister_callback)(void),
397 long cycles, int int_prio,
398 void (*timer_callback)(void) IF_COP(, int core));
399 void (*timer_unregister)(void);
400 bool (*timer_set_period)(long count);
402 void (*queue_init)(struct event_queue *q, bool register_queue);
403 void (*queue_delete)(struct event_queue *q);
404 void (*queue_post)(struct event_queue *q, long id, intptr_t data);
405 void (*queue_wait_w_tmo)(struct event_queue *q, struct queue_event *ev,
406 int ticks);
407 #if CONFIG_CODEC == SWCODEC
408 void (*queue_enable_queue_send)(struct event_queue *q,
409 struct queue_sender_list *send,
410 struct thread_entry *owner);
411 bool (*queue_empty)(const struct event_queue *q);
412 void (*queue_wait)(struct event_queue *q, struct queue_event *ev);
413 intptr_t (*queue_send)(struct event_queue *q, long id,
414 intptr_t data);
415 void (*queue_reply)(struct event_queue *q, intptr_t retval);
416 #endif /* CONFIG_CODEC == SWCODEC */
418 void (*usb_acknowledge)(long id);
419 #ifdef RB_PROFILE
420 void (*profile_thread)(void);
421 void (*profstop)(void);
422 void (*profile_func_enter)(void *this_fn, void *call_site);
423 void (*profile_func_exit)(void *this_fn, void *call_site);
424 #endif
426 #ifdef SIMULATOR
427 /* special simulator hooks */
428 #if defined(HAVE_LCD_BITMAP) && LCD_DEPTH < 8
429 void (*sim_lcd_ex_init)(int shades, unsigned long (*getpixel)(int, int));
430 void (*sim_lcd_ex_update_rect)(int x, int y, int width, int height);
431 #endif
432 #endif
434 /* strings and memory */
435 int (*snprintf)(char *buf, size_t size, const char *fmt, ...)
436 ATTRIBUTE_PRINTF(3, 4);
437 int (*vsnprintf)(char *buf, int size, const char *fmt, va_list ap);
438 char* (*strcpy)(char *dst, const char *src);
439 char* (*strncpy)(char *dst, const char *src, size_t length);
440 size_t (*strlen)(const char *str);
441 char * (*strrchr)(const char *s, int c);
442 int (*strcmp)(const char *, const char *);
443 int (*strncmp)(const char *, const char *, size_t);
444 int (*strcasecmp)(const char *, const char *);
445 int (*strncasecmp)(const char *s1, const char *s2, size_t n);
446 void* (*memset)(void *dst, int c, size_t length);
447 void* (*memcpy)(void *out, const void *in, size_t n);
448 void* (*memmove)(void *out, const void *in, size_t n);
449 const unsigned char *_ctype_;
450 int (*atoi)(const char *str);
451 char *(*strchr)(const char *s, int c);
452 char *(*strcat)(char *s1, const char *s2);
453 void *(*memchr)(const void *s1, int c, size_t n);
454 int (*memcmp)(const void *s1, const void *s2, size_t n);
455 char *(*strcasestr) (const char* phaystack, const char* pneedle);
456 char* (*strtok_r)(char *ptr, const char *sep, char **end);
457 /* unicode stuff */
458 const unsigned char* (*utf8decode)(const unsigned char *utf8, unsigned short *ucs);
459 unsigned char* (*iso_decode)(const unsigned char *iso, unsigned char *utf8, int cp, int count);
460 unsigned char* (*utf16LEdecode)(const unsigned char *utf16, unsigned char *utf8, int count);
461 unsigned char* (*utf16BEdecode)(const unsigned char *utf16, unsigned char *utf8, int count);
462 unsigned char* (*utf8encode)(unsigned long ucs, unsigned char *utf8);
463 unsigned long (*utf8length)(const unsigned char *utf8);
464 int (*utf8seek)(const unsigned char* utf8, int offset);
466 /* sound */
467 void (*sound_set)(int setting, int value);
468 int (*sound_default)(int setting);
469 int (*sound_min)(int setting);
470 int (*sound_max)(int setting);
471 const char * (*sound_unit)(int setting);
472 int (*sound_val2phys)(int setting, int value);
473 #ifndef SIMULATOR
474 void (*mp3_play_data)(const unsigned char* start, int size, void (*get_more)(unsigned char** start, size_t* size));
475 void (*mp3_play_pause)(bool play);
476 void (*mp3_play_stop)(void);
477 bool (*mp3_is_playing)(void);
478 #if CONFIG_CODEC != SWCODEC
479 void (*bitswap)(unsigned char *data, int length);
480 #endif
481 #endif /* !SIMULATOR */
482 #if CONFIG_CODEC == SWCODEC
483 const unsigned long *audio_master_sampr_list;
484 const unsigned long *hw_freq_sampr;
485 void (*pcm_apply_settings)(void);
486 void (*pcm_play_data)(pcm_more_callback_type get_more,
487 unsigned char* start, size_t size);
488 void (*pcm_play_stop)(void);
489 void (*pcm_set_frequency)(unsigned int frequency);
490 bool (*pcm_is_playing)(void);
491 bool (*pcm_is_paused)(void);
492 void (*pcm_play_pause)(bool play);
493 size_t (*pcm_get_bytes_waiting)(void);
494 void (*pcm_calculate_peaks)(int *left, int *right);
495 void (*pcm_play_lock)(void);
496 void (*pcm_play_unlock)(void);
497 #ifdef HAVE_RECORDING
498 const unsigned long *rec_freq_sampr;
499 void (*pcm_init_recording)(void);
500 void (*pcm_close_recording)(void);
501 void (*pcm_record_data)(pcm_more_callback_type2 more_ready,
502 void *start, size_t size);
503 void (*pcm_record_more)(void *start, size_t size);
504 void (*pcm_stop_recording)(void);
505 void (*pcm_calculate_rec_peaks)(int *left, int *right);
506 void (*audio_set_recording_gain)(int left, int right, int type);
507 #endif /* HAVE_RECORDING */
508 #if INPUT_SRC_CAPS != 0
509 void (*audio_set_output_source)(int monitor);
510 void (*audio_set_input_source)(int source, unsigned flags);
511 #endif
512 void (*dsp_set_crossfeed)(bool enable);
513 void (*dsp_set_eq)(bool enable);
514 void (*dsp_dither_enable)(bool enable);
515 intptr_t (*dsp_configure)(struct dsp_config *dsp, int setting,
516 intptr_t value);
517 int (*dsp_process)(struct dsp_config *dsp, char *dest,
518 const char *src[], int count);
519 #endif /* CONFIG_CODEC == SWCODC */
521 /* playback control */
522 int (*playlist_amount)(void);
523 int (*playlist_resume)(void);
524 int (*playlist_start)(int start_index, int offset);
525 void (*PREFIX(audio_play))(long offset);
526 void (*audio_stop)(void);
527 void (*audio_pause)(void);
528 void (*audio_resume)(void);
529 void (*audio_next)(void);
530 void (*audio_prev)(void);
531 void (*audio_ff_rewind)(long newtime);
532 struct mp3entry* (*audio_next_track)(void);
533 int (*audio_status)(void);
534 bool (*audio_has_changed_track)(void);
535 struct mp3entry* (*audio_current_track)(void);
536 void (*audio_flush_and_reload_tracks)(void);
537 int (*audio_get_file_pos)(void);
538 #if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
539 unsigned long (*mpeg_get_last_header)(void);
540 #endif
541 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) || \
542 (CONFIG_CODEC == SWCODEC)
543 void (*sound_set_pitch)(int pitch);
544 #endif
546 /* MAS communication */
547 #if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
548 int (*mas_readmem)(int bank, int addr, unsigned long* dest, int len);
549 int (*mas_writemem)(int bank, int addr, const unsigned long* src, int len);
550 int (*mas_readreg)(int reg);
551 int (*mas_writereg)(int reg, unsigned int val);
552 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
553 int (*mas_codec_writereg)(int reg, unsigned int val);
554 int (*mas_codec_readreg)(int reg);
555 void (*i2c_begin)(void);
556 void (*i2c_end)(void);
557 int (*i2c_write)(int address, unsigned char* buf, int count );
558 #endif
559 #endif
561 /* menu */
562 int (*do_menu)(const struct menu_item_ex *menu, int *start_selected,
563 struct viewport parent[NB_SCREENS], bool hide_bars);
565 /* scroll bar */
566 struct gui_syncstatusbar *statusbars;
567 void (*gui_syncstatusbar_draw)(struct gui_syncstatusbar * bars, bool force_redraw);
569 /* options */
570 const struct settings_list* (*find_setting)(const void* variable, int *id);
571 bool (*option_screen)(struct settings_list *setting,
572 bool use_temp_var, unsigned char* option_title);
573 bool (*set_option)(const char* string, const void* variable,
574 enum optiontype type, const struct opt_items* options,
575 int numoptions, void (*function)(int));
576 bool (*set_bool_options)(const char* string, const bool* variable,
577 const char* yes_str, int yes_voice,
578 const char* no_str, int no_voice,
579 void (*function)(bool));
580 bool (*set_int)(const unsigned char* string, const char* unit, int voice_unit,
581 const int* variable, void (*function)(int), int step,
582 int min, int max,
583 void (*formatter)(char*, size_t, int, const char*) );
584 bool (*set_bool)(const char* string, const bool* variable );
586 #ifdef HAVE_LCD_COLOR
587 bool (*set_color)(struct screen *display, char *title, unsigned *color,
588 unsigned banned_color);
589 #endif
590 /* action handling */
591 int (*get_custom_action)(int context,int timeout,
592 const struct button_mapping* (*get_context_map)(int));
593 int (*get_action)(int context, int timeout);
594 bool (*action_userabort)(int timeout);
596 /* power */
597 int (*battery_level)(void);
598 bool (*battery_level_safe)(void);
599 int (*battery_time)(void);
600 #ifndef SIMULATOR
601 unsigned int (*battery_voltage)(void);
602 #endif
603 #if CONFIG_CHARGING
604 bool (*charger_inserted)(void);
605 # if CONFIG_CHARGING == CHARGING_MONITOR
606 bool (*charging_state)(void);
607 # endif
608 #endif
609 #ifdef HAVE_USB_POWER
610 bool (*usb_powered)(void);
611 #endif
613 /* misc */
614 void (*srand)(unsigned int seed);
615 int (*rand)(void);
616 void (*qsort)(void *base, size_t nmemb, size_t size,
617 int(*compar)(const void *, const void *));
618 int (*kbd_input)(char* buffer, int buflen);
619 struct tm* (*get_time)(void);
620 int (*set_time)(const struct tm *tm);
621 #if CONFIG_RTC
622 time_t (*mktime)(struct tm *t);
623 #endif
624 void* (*plugin_get_buffer)(size_t *buffer_size);
625 void* (*plugin_get_audio_buffer)(size_t *buffer_size);
626 void (*plugin_tsr)(bool (*exit_callback)(bool reenter));
627 char* (*plugin_get_current_filename)(void);
628 #ifdef PLUGIN_USE_IRAM
629 void (*plugin_iram_init)(char *iramstart, char *iramcopy, size_t iram_size,
630 char *iedata, size_t iedata_size);
631 #endif
632 #if defined(DEBUG) || defined(SIMULATOR)
633 void (*debugf)(const char *fmt, ...) ATTRIBUTE_PRINTF(1, 2);
634 #endif
635 #ifdef ROCKBOX_HAS_LOGF
636 void (*logf)(const char *fmt, ...) ATTRIBUTE_PRINTF(1, 2);
637 #endif
638 struct user_settings* global_settings;
639 struct system_status *global_status;
640 void (*talk_disable)(bool disable);
641 #if CONFIG_CODEC == SWCODEC
642 int (*codec_load_file)(const char* codec, struct codec_api *api);
643 const char *(*get_codec_filename)(int cod_spec);
644 bool (*get_metadata)(struct mp3entry* id3, int fd, const char* trackname);
645 #endif
646 bool (*mp3info)(struct mp3entry *entry, const char *filename);
647 int (*count_mp3_frames)(int fd, int startpos, int filesize,
648 void (*progressfunc)(int));
649 int (*create_xing_header)(int fd, long startpos, long filesize,
650 unsigned char *buf, unsigned long num_frames,
651 unsigned long rec_time, unsigned long header_template,
652 void (*progressfunc)(int), bool generate_toc);
653 unsigned long (*find_next_frame)(int fd, long *offset,
654 long max_offset, unsigned long last_header);
656 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
657 unsigned short (*peak_meter_scale_value)(unsigned short val,
658 int meterwidth);
659 void (*peak_meter_set_use_dbfs)(bool use);
660 bool (*peak_meter_get_use_dbfs)(void);
661 #endif
662 #ifdef HAVE_LCD_BITMAP
663 int (*read_bmp_file)(const char* filename, struct bitmap *bm, int maxsize,
664 int format);
665 void (*screen_dump_set_hook)(void (*hook)(int fh));
666 #endif
667 int (*show_logo)(void);
668 struct tree_context* (*tree_get_context)(void);
669 void (*set_current_file)(char* path);
670 void (*set_dirfilter)(int l_dirfilter);
672 #ifdef HAVE_WHEEL_POSITION
673 int (*wheel_status)(void);
674 void (*wheel_send_events)(bool send);
675 #endif
677 #ifdef IRIVER_H100_SERIES
678 /* Routines for the iriver_flash -plugin. */
679 bool (*detect_original_firmware)(void);
680 bool (*detect_flashed_ramimage)(void);
681 bool (*detect_flashed_romimage)(void);
682 #endif
684 void (*led)(bool on);
686 #if (CONFIG_CODEC == SWCODEC)
687 /* buffering API */
688 int (*bufopen)(const char *file, size_t offset, enum data_type type);
689 int (*bufalloc)(const void *src, size_t size, enum data_type type);
690 bool (*bufclose)(int handle_id);
691 int (*bufseek)(int handle_id, size_t newpos);
692 int (*bufadvance)(int handle_id, off_t offset);
693 ssize_t (*bufread)(int handle_id, size_t size, void *dest);
694 ssize_t (*bufgetdata)(int handle_id, size_t size, void **data);
695 ssize_t (*bufgettail)(int handle_id, size_t size, void **data);
696 ssize_t (*bufcuttail)(int handle_id, size_t size);
698 ssize_t (*buf_get_offset)(int handle_id, void *ptr);
699 ssize_t (*buf_handle_offset)(int handle_id);
700 void (*buf_request_buffer_handle)(int handle_id);
701 void (*buf_set_base_handle)(int handle_id);
702 size_t (*buf_used)(void);
703 #endif
705 #ifdef HAVE_TAGCACHE
706 bool (*tagcache_search)(struct tagcache_search *tcs, int tag);
707 void (*tagcache_search_set_uniqbuf)(struct tagcache_search *tcs,
708 void *buffer, long length);
709 bool (*tagcache_search_add_filter)(struct tagcache_search *tcs,
710 int tag, int seek);
711 bool (*tagcache_get_next)(struct tagcache_search *tcs);
712 bool (*tagcache_retrieve)(struct tagcache_search *tcs, int idxid,
713 int tag, char *buf, long size);
714 void (*tagcache_search_finish)(struct tagcache_search *tcs);
715 #endif
717 #ifdef HAVE_ALBUMART
718 bool (*find_albumart)(const struct mp3entry *id3, char *buf, int buflen);
719 bool (*search_albumart_files)(const struct mp3entry *id3, const char *size_string,
720 char *buf, int buflen);
721 #endif
723 /* new stuff at the end, sort into place next time
724 the API gets incompatible */
728 /* plugin header */
729 struct plugin_header {
730 unsigned long magic;
731 unsigned short target_id;
732 unsigned short api_version;
733 unsigned char *load_addr;
734 unsigned char *end_addr;
735 enum plugin_status(*entry_point)(struct plugin_api*, void*);
738 #ifdef PLUGIN
739 #ifndef SIMULATOR
740 extern unsigned char plugin_start_addr[];
741 extern unsigned char plugin_end_addr[];
742 #define PLUGIN_HEADER \
743 const struct plugin_header __header \
744 __attribute__ ((section (".header")))= { \
745 PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \
746 plugin_start_addr, plugin_end_addr, plugin_start };
747 #else /* SIMULATOR */
748 #define PLUGIN_HEADER \
749 const struct plugin_header __header \
750 __attribute__((visibility("default"))) = { \
751 PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \
752 NULL, NULL, plugin_start };
753 #endif /* SIMULATOR */
755 #ifdef PLUGIN_USE_IRAM
756 /* Declare IRAM variables */
757 #define PLUGIN_IRAM_DECLARE \
758 extern char iramcopy[]; \
759 extern char iramstart[]; \
760 extern char iramend[]; \
761 extern char iedata[]; \
762 extern char iend[];
763 /* Initialize IRAM */
764 #define PLUGIN_IRAM_INIT(api) \
765 (api)->plugin_iram_init(iramstart, iramcopy, iramend-iramstart, \
766 iedata, iend-iedata);
767 #else
768 #define PLUGIN_IRAM_DECLARE
769 #define PLUGIN_IRAM_INIT(api)
770 #endif /* PLUGIN_USE_IRAM */
771 #endif /* PLUGIN */
773 int plugin_load(const char* plugin, void* parameter);
774 void* plugin_get_buffer(size_t *buffer_size);
775 void* plugin_get_audio_buffer(size_t *buffer_size);
776 #ifdef PLUGIN_USE_IRAM
777 void plugin_iram_init(char *iramstart, char *iramcopy, size_t iram_size,
778 char *iedata, size_t iedata_size);
779 #endif
781 /* plugin_tsr,
782 callback returns true to allow the new plugin to load,
783 reenter means the currently running plugin is being reloaded */
784 void plugin_tsr(bool (*exit_callback)(bool reenter));
786 /* defined by the plugin */
787 enum plugin_status plugin_start(struct plugin_api* rockbox, void* parameter)
788 NO_PROF_ATTR;
790 /* Use this macro in plugins where gcc tries to optimize by calling
791 * these functions directly */
792 #define MEM_FUNCTION_WRAPPERS(api) \
793 void *memcpy(void *dest, const void *src, size_t n) \
795 return (api)->memcpy(dest, src, n); \
797 void *memset(void *dest, int c, size_t n) \
799 return (api)->memset(dest, c, n); \
801 void *memmove(void *dest, const void *src, size_t n) \
803 return (api)->memmove(dest, src, n); \
805 int memcmp(const void *s1, const void *s2, size_t n) \
807 return (api)->memcmp(s1, s2, n); \
810 #ifndef CACHE_FUNCTION_WRAPPERS
812 #ifdef CACHE_FUNCTIONS_AS_CALL
813 #define CACHE_FUNCTION_WRAPPERS(api) \
814 void flush_icache(void) \
816 (api)->flush_icache(); \
818 void invalidate_icache(void) \
820 (api)->invalidate_icache(); \
822 #else
823 #define CACHE_FUNCTION_WRAPPERS(api)
824 #endif /* CACHE_FUNCTIONS_AS_CALL */
826 #endif /* CACHE_FUNCTION_WRAPPERS */
828 #ifndef ALIGN_BUFFER_WRAPPER
829 #define ALIGN_BUFFER_WRAPPER(api) \
830 size_t align_buffer(void **start, size_t size, size_t align) \
832 return (api)->align_buffer(start, size, align); \
834 #endif /* ALIGN_BUFFER_WRAPPER */
836 #endif