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