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