Updated Italian translation (FS#7389)
[Rockbox.git] / apps / plugin.h
blob3b9ca03e32baaa8268647a1f36d3e623341648dc
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 #ifndef SIMULATOR
41 #include "dircache.h"
42 #endif
43 #include "kernel.h"
44 #include "thread.h"
45 #include "button.h"
46 #include "action.h"
47 #include "usb.h"
48 #include "font.h"
49 #include "lcd.h"
50 #include "id3.h"
51 #include "sound.h"
52 #include "mpeg.h"
53 #include "audio.h"
54 #include "mp3_playback.h"
55 #include "talk.h"
56 #ifdef RB_PROFILE
57 #include "profile.h"
58 #endif
59 #include "misc.h"
60 #if (CONFIG_CODEC == SWCODEC)
61 #include "dsp.h"
62 #include "codecs.h"
63 #include "playback.h"
64 #include "metadata.h"
65 #ifdef HAVE_RECORDING
66 #include "recording.h"
67 #endif
68 #else
69 #include "mas.h"
70 #endif /* CONFIG_CODEC == SWCODEC */
71 #include "settings.h"
72 #include "timer.h"
73 #include "playlist.h"
74 #ifdef HAVE_LCD_BITMAP
75 #include "scrollbar.h"
76 #endif
77 #include "statusbar.h"
78 #include "menu.h"
79 #include "rbunicode.h"
80 #include "list.h"
81 #include "tree.h"
82 #include "color_picker.h"
84 #ifdef HAVE_REMOTE_LCD
85 #include "lcd-remote.h"
86 #endif
88 #ifdef PLUGIN
90 #if defined(DEBUG) || defined(SIMULATOR)
91 #undef DEBUGF
92 #define DEBUGF rb->debugf
93 #undef LDEBUGF
94 #define LDEBUGF rb->debugf
95 #else
96 #define DEBUGF(...)
97 #define LDEBUGF(...)
98 #endif
100 #ifdef ROCKBOX_HAS_LOGF
101 #undef LOGF
102 #define LOGF rb->logf
103 #else
104 #define LOGF(...)
105 #endif
107 #endif
109 #ifdef SIMULATOR
110 #define PREFIX(_x_) sim_ ## _x_
111 #else
112 #define PREFIX(_x_) _x_
113 #endif
115 #define PLUGIN_MAGIC 0x526F634B /* RocK */
117 /* increase this every time the api struct changes */
118 #define PLUGIN_API_VERSION 60
120 /* update this to latest version if a change to the api struct breaks
121 backwards compatibility (and please take the opportunity to sort in any
122 new function which are "waiting" at the end of the function table) */
123 #define PLUGIN_MIN_API_VERSION 60
125 /* plugin return codes */
126 enum plugin_status {
127 PLUGIN_OK = 0,
128 PLUGIN_USB_CONNECTED,
129 PLUGIN_ERROR = -1,
132 /* NOTE: To support backwards compatibility, only add new functions at
133 the end of the structure. Every time you add a new function,
134 remember to increase PLUGIN_API_VERSION. If you make changes to the
135 existing APIs then also update PLUGIN_MIN_API_VERSION to current
136 version
138 struct plugin_api {
140 /* lcd */
141 void (*lcd_set_contrast)(int x);
142 void (*lcd_update)(void);
143 void (*lcd_clear_display)(void);
144 void (*lcd_setmargins)(int x, int y);
145 int (*lcd_getstringsize)(const unsigned char *str, int *w, int *h);
146 void (*lcd_putsxy)(int x, int y, const unsigned char *string);
147 void (*lcd_puts)(int x, int y, const unsigned char *string);
148 void (*lcd_puts_scroll)(int x, int y, const unsigned char* string);
149 void (*lcd_stop_scroll)(void);
150 #ifdef HAVE_LCD_CHARCELLS
151 void (*lcd_define_pattern)(unsigned long ucs, const char *pattern);
152 unsigned long (*lcd_get_locked_pattern)(void);
153 void (*lcd_unlock_pattern)(unsigned long ucs);
154 void (*lcd_putc)(int x, int y, unsigned long ucs);
155 void (*lcd_put_cursor)(int x, int y, unsigned long ucs);
156 void (*lcd_remove_cursor)(void);
157 void (*lcd_icon)(int icon, bool enable);
158 void (*lcd_double_height)(bool on);
159 #else
160 void (*lcd_set_drawmode)(int mode);
161 int (*lcd_get_drawmode)(void);
162 void (*lcd_setfont)(int font);
163 void (*lcd_drawpixel)(int x, int y);
164 void (*lcd_drawline)(int x1, int y1, int x2, int y2);
165 void (*lcd_hline)(int x1, int x2, int y);
166 void (*lcd_vline)(int x, int y1, int y2);
167 void (*lcd_drawrect)(int x, int y, int width, int height);
168 void (*lcd_fillrect)(int x, int y, int width, int height);
169 void (*lcd_mono_bitmap_part)(const unsigned char *src, int src_x, int src_y,
170 int stride, int x, int y, int width, int height);
171 void (*lcd_mono_bitmap)(const unsigned char *src, int x, int y,
172 int width, int height);
173 #if LCD_DEPTH > 1
174 void (*lcd_set_foreground)(unsigned foreground);
175 unsigned (*lcd_get_foreground)(void);
176 void (*lcd_set_background)(unsigned foreground);
177 unsigned (*lcd_get_background)(void);
178 void (*lcd_bitmap_part)(const fb_data *src, int src_x, int src_y,
179 int stride, int x, int y, int width, int height);
180 void (*lcd_bitmap)(const fb_data *src, int x, int y, int width,
181 int height);
182 fb_data* (*lcd_get_backdrop)(void);
183 void (*lcd_set_backdrop)(fb_data* backdrop);
184 #endif
185 #if LCD_DEPTH == 16
186 void (*lcd_bitmap_transparent_part)(const fb_data *src,
187 int src_x, int src_y, int stride,
188 int x, int y, int width, int height);
189 void (*lcd_bitmap_transparent)(const fb_data *src, int x, int y,
190 int width, int height);
191 #endif
192 unsigned short *(*bidi_l2v)( const unsigned char *str, int orientation );
193 const unsigned char *(*font_get_bits)( struct font *pf, unsigned short char_code );
194 struct font* (*font_load)(const char *path);
195 void (*lcd_puts_style)(int x, int y, const unsigned char *str, int style);
196 void (*lcd_puts_scroll_style)(int x, int y, const unsigned char* string,
197 int style);
198 fb_data* lcd_framebuffer;
199 void (*lcd_blit) (const fb_data* data, int x, int by, int width,
200 int bheight, int stride);
201 void (*lcd_update_rect)(int x, int y, int width, int height);
202 void (*gui_scrollbar_draw)(struct screen * screen, int x, int y,
203 int width, int height, int items,
204 int min_shown, int max_shown,
205 unsigned flags);
206 struct font* (*font_get)(int font);
207 int (*font_getstringsize)(const unsigned char *str, int *w, int *h,
208 int fontnumber);
209 int (*font_get_width)(struct font* pf, unsigned short char_code);
210 #endif
211 void (*backlight_on)(void);
212 void (*backlight_off)(void);
213 void (*backlight_set_timeout)(int index);
214 void (*splash)(int ticks, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3);
216 #ifdef HAVE_REMOTE_LCD
217 /* remote lcd */
218 void (*lcd_remote_set_contrast)(int x);
219 void (*lcd_remote_clear_display)(void);
220 void (*lcd_remote_puts)(int x, int y, const unsigned char *string);
221 void (*lcd_remote_lcd_puts_scroll)(int x, int y, const unsigned char* string);
222 void (*lcd_remote_lcd_stop_scroll)(void);
223 void (*lcd_remote_set_drawmode)(int mode);
224 int (*lcd_remote_get_drawmode)(void);
225 void (*lcd_remote_setfont)(int font);
226 int (*lcd_remote_getstringsize)(const unsigned char *str, int *w, int *h);
227 void (*lcd_remote_drawpixel)(int x, int y);
228 void (*lcd_remote_drawline)(int x1, int y1, int x2, int y2);
229 void (*lcd_remote_hline)(int x1, int x2, int y);
230 void (*lcd_remote_vline)(int x, int y1, int y2);
231 void (*lcd_remote_drawrect)(int x, int y, int nx, int ny);
232 void (*lcd_remote_fillrect)(int x, int y, int nx, int ny);
233 void (*lcd_remote_mono_bitmap_part)(const unsigned char *src, int src_x,
234 int src_y, int stride, int x, int y,
235 int width, int height);
236 void (*lcd_remote_mono_bitmap)(const unsigned char *src, int x, int y,
237 int width, int height);
238 void (*lcd_remote_putsxy)(int x, int y, const unsigned char *string);
239 void (*lcd_remote_puts_style)(int x, int y, const unsigned char *str, int style);
240 void (*lcd_remote_puts_scroll_style)(int x, int y, const unsigned char* string,
241 int style);
242 fb_remote_data* lcd_remote_framebuffer;
243 void (*lcd_remote_update)(void);
244 void (*lcd_remote_update_rect)(int x, int y, int width, int height);
246 void (*remote_backlight_on)(void);
247 void (*remote_backlight_off)(void);
248 #endif
249 struct screen* screens[NB_SCREENS];
250 #if defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)
251 void (*lcd_remote_set_foreground)(unsigned foreground);
252 unsigned (*lcd_remote_get_foreground)(void);
253 void (*lcd_remote_set_background)(unsigned background);
254 unsigned (*lcd_remote_get_background)(void);
255 void (*lcd_remote_bitmap_part)(const fb_remote_data *src, int src_x, int src_y,
256 int stride, int x, int y, int width, int height);
257 void (*lcd_remote_bitmap)(const fb_remote_data *src, int x, int y, int width,
258 int height);
259 #endif
260 #if defined(HAVE_LCD_COLOR) && !defined(SIMULATOR)
261 void (*lcd_yuv_blit)(unsigned char * const src[3],
262 int src_x, int src_y, int stride,
263 int x, int y, int width, int height);
264 #endif
266 /* list */
267 void (*gui_synclist_init)(struct gui_synclist * lists,
268 list_get_name callback_get_item_name,void * data,
269 bool scroll_all,int selected_size);
270 void (*gui_synclist_set_nb_items)(struct gui_synclist * lists, int nb_items);
271 void (*gui_synclist_set_icon_callback)(struct gui_synclist * lists, list_get_icon icon_callback);
272 int (*gui_synclist_get_nb_items)(struct gui_synclist * lists);
273 int (*gui_synclist_get_sel_pos)(struct gui_synclist * lists);
274 void (*gui_synclist_draw)(struct gui_synclist * lists);
275 void (*gui_synclist_select_item)(struct gui_synclist * lists,
276 int item_number);
277 void (*gui_synclist_add_item)(struct gui_synclist * lists);
278 void (*gui_synclist_del_item)(struct gui_synclist * lists);
279 void (*gui_synclist_limit_scroll)(struct gui_synclist * lists, bool scroll);
280 void (*gui_synclist_flash)(struct gui_synclist * lists);
281 unsigned (*gui_synclist_do_button)(struct gui_synclist * lists,
282 unsigned button,enum list_wrap wrap);
283 void (*gui_synclist_set_title)(struct gui_synclist *lists, char* title, int icon);
285 /* button */
286 long (*button_get)(bool block);
287 long (*button_get_w_tmo)(int ticks);
288 int (*button_status)(void);
289 void (*button_clear_queue)(void);
290 #ifdef HAS_BUTTON_HOLD
291 bool (*button_hold)(void);
292 #endif
294 /* file */
295 int (*PREFIX(open))(const char* pathname, int flags);
296 int (*close)(int fd);
297 ssize_t (*read)(int fd, void* buf, size_t count);
298 off_t (*PREFIX(lseek))(int fd, off_t offset, int whence);
299 int (*PREFIX(creat))(const char *pathname);
300 ssize_t (*write)(int fd, const void* buf, size_t count);
301 int (*PREFIX(remove))(const char* pathname);
302 int (*PREFIX(rename))(const char* path, const char* newname);
303 int (*PREFIX(ftruncate))(int fd, off_t length);
304 off_t (*PREFIX(filesize))(int fd);
305 int (*fdprintf)(int fd, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3);
306 int (*read_line)(int fd, char* buffer, int buffer_size);
307 bool (*settings_parseline)(char* line, char** name, char** value);
308 #ifndef SIMULATOR
309 void (*ata_sleep)(void);
310 bool (*ata_disk_is_active)(void);
311 #endif
312 void (*ata_spindown)(int seconds);
313 void (*reload_directory)(void);
314 char *(*create_numbered_filename)(char *buffer, const char *path,
315 const char *prefix, const char *suffix,
316 int numberlen IF_CNFN_NUM_(, int *num));
318 /* dir */
319 DIR* (*PREFIX(opendir))(const char* name);
320 int (*PREFIX(closedir))(DIR* dir);
321 struct dirent* (*PREFIX(readdir))(DIR* dir);
322 int (*PREFIX(mkdir))(const char *name);
323 int (*PREFIX(rmdir))(const char *name);
324 /* dir, cached */
325 #ifdef HAVE_DIRCACHE
326 DIRCACHED* (*opendir_cached)(const char* name);
327 struct dircache_entry* (*readdir_cached)(DIRCACHED* dir);
328 int (*closedir_cached)(DIRCACHED* dir);
329 #endif
331 /* kernel/ system */
332 void (*PREFIX(sleep))(int ticks);
333 void (*yield)(void);
334 #ifdef HAVE_PRIORITY_SCHEDULING
335 void (*priority_yield)(void);
336 #endif
337 volatile long* current_tick;
338 long (*default_event_handler)(long event);
339 long (*default_event_handler_ex)(long event, void (*callback)(void *), void *parameter);
340 struct thread_entry* threads;
341 struct thread_entry* (*create_thread)(void (*function)(void), void* stack,
342 int stack_size, const char *name
343 IF_PRIO(, int priority)
344 IF_COP(, unsigned int core, bool fallback));
345 void (*remove_thread)(struct thread_entry *thread);
346 void (*reset_poweroff_timer)(void);
347 #ifndef SIMULATOR
348 int (*system_memory_guard)(int newmode);
349 long *cpu_frequency;
350 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
351 #ifdef CPU_BOOST_LOGGING
352 void (*cpu_boost_)(bool on_off,char*location,int line);
353 #else
354 void (*cpu_boost)(bool on_off);
355 #endif
356 #endif
357 bool (*timer_register)(int reg_prio, void (*unregister_callback)(void),
358 long cycles, int int_prio,
359 void (*timer_callback)(void));
360 void (*timer_unregister)(void);
361 bool (*timer_set_period)(long count);
362 #endif
363 void (*queue_init)(struct event_queue *q, bool register_queue);
364 void (*queue_delete)(struct event_queue *q);
365 void (*queue_post)(struct event_queue *q, long id, intptr_t data);
366 void (*queue_wait_w_tmo)(struct event_queue *q, struct event *ev,
367 int ticks);
368 void (*usb_acknowledge)(long id);
369 #ifdef RB_PROFILE
370 void (*profile_thread)(void);
371 void (*profstop)(void);
372 void (*profile_func_enter)(void *this_fn, void *call_site);
373 void (*profile_func_exit)(void *this_fn, void *call_site);
374 #endif
376 #ifdef SIMULATOR
377 /* special simulator hooks */
378 #if defined(HAVE_LCD_BITMAP) && LCD_DEPTH < 8
379 void (*sim_lcd_ex_init)(int shades, unsigned long (*getpixel)(int, int));
380 void (*sim_lcd_ex_update_rect)(int x, int y, int width, int height);
381 #endif
382 #endif
384 /* strings and memory */
385 int (*snprintf)(char *buf, size_t size, const char *fmt, ...)
386 ATTRIBUTE_PRINTF(3, 4);
387 int (*vsnprintf)(char *buf, int size, const char *fmt, va_list ap);
388 char* (*strcpy)(char *dst, const char *src);
389 char* (*strncpy)(char *dst, const char *src, size_t length);
390 size_t (*strlen)(const char *str);
391 char * (*strrchr)(const char *s, int c);
392 int (*strcmp)(const char *, const char *);
393 int (*strncmp)(const char *, const char *, size_t);
394 int (*strcasecmp)(const char *, const char *);
395 int (*strncasecmp)(const char *s1, const char *s2, size_t n);
396 void* (*memset)(void *dst, int c, size_t length);
397 void* (*memcpy)(void *out, const void *in, size_t n);
398 void* (*memmove)(void *out, const void *in, size_t n);
399 const unsigned char *_ctype_;
400 int (*atoi)(const char *str);
401 char *(*strchr)(const char *s, int c);
402 char *(*strcat)(char *s1, const char *s2);
403 void *(*memchr)(const void *s1, int c, size_t n);
404 int (*memcmp)(const void *s1, const void *s2, size_t n);
405 char *(*strcasestr) (const char* phaystack, const char* pneedle);
406 char* (*strtok_r)(char *ptr, const char *sep, char **end);
407 /* unicode stuff */
408 const unsigned char* (*utf8decode)(const unsigned char *utf8, unsigned short *ucs);
409 unsigned char* (*iso_decode)(const unsigned char *iso, unsigned char *utf8, int cp, int count);
410 unsigned char* (*utf16LEdecode)(const unsigned char *utf16, unsigned char *utf8, int count);
411 unsigned char* (*utf16BEdecode)(const unsigned char *utf16, unsigned char *utf8, int count);
412 unsigned char* (*utf8encode)(unsigned long ucs, unsigned char *utf8);
413 unsigned long (*utf8length)(const unsigned char *utf8);
414 int (*utf8seek)(const unsigned char* utf8, int offset);
416 /* sound */
417 #if CONFIG_CODEC == SWCODEC
418 int (*sound_default)(int setting);
419 #endif
420 void (*sound_set)(int setting, int value);
421 bool (*set_sound)(const unsigned char * string,
422 int* variable, int setting);
423 int (*sound_min)(int setting);
424 int (*sound_max)(int setting);
425 #ifndef SIMULATOR
426 void (*mp3_play_data)(const unsigned char* start, int size, void (*get_more)(unsigned char** start, size_t* size));
427 void (*mp3_play_pause)(bool play);
428 void (*mp3_play_stop)(void);
429 bool (*mp3_is_playing)(void);
430 #if CONFIG_CODEC != SWCODEC
431 void (*bitswap)(unsigned char *data, int length);
432 #endif
433 #endif /* !SIMULATOR */
434 #if CONFIG_CODEC == SWCODEC
435 const unsigned long *audio_master_sampr_list;
436 const unsigned long *hw_freq_sampr;
437 void (*pcm_apply_settings)(void);
438 void (*pcm_play_data)(pcm_more_callback_type get_more,
439 unsigned char* start, size_t size);
440 void (*pcm_play_stop)(void);
441 void (*pcm_set_frequency)(unsigned int frequency);
442 bool (*pcm_is_playing)(void);
443 bool (*pcm_is_paused)(void);
444 void (*pcm_play_pause)(bool play);
445 size_t (*pcm_get_bytes_waiting)(void);
446 void (*pcm_calculate_peaks)(int *left, int *right);
447 #ifdef HAVE_RECORDING
448 const unsigned long *rec_freq_sampr;
449 void (*pcm_init_recording)(void);
450 void (*pcm_close_recording)(void);
451 void (*pcm_record_data)(pcm_more_callback_type2 more_ready,
452 void *start, size_t size);
453 void (*pcm_record_more)(void *start, size_t size);
454 void (*pcm_stop_recording)(void);
455 void (*pcm_calculate_rec_peaks)(int *left, int *right);
456 void (*audio_set_recording_gain)(int left, int right, int type);
457 #endif /* HAVE_RECORDING */
458 #if INPUT_SRC_CAPS != 0
459 void (*audio_set_output_source)(int monitor);
460 void (*audio_set_input_source)(int source, unsigned flags);
461 #endif
462 #endif /* CONFIG_CODEC == SWCODC */
464 /* playback control */
465 int (*playlist_amount)(void);
466 int (*playlist_resume)(void);
467 int (*playlist_start)(int start_index, int offset);
468 void (*PREFIX(audio_play))(long offset);
469 void (*audio_stop)(void);
470 void (*audio_pause)(void);
471 void (*audio_resume)(void);
472 void (*audio_next)(void);
473 void (*audio_prev)(void);
474 void (*audio_ff_rewind)(long newtime);
475 struct mp3entry* (*audio_next_track)(void);
476 int (*audio_status)(void);
477 bool (*audio_has_changed_track)(void);
478 struct mp3entry* (*audio_current_track)(void);
479 void (*audio_flush_and_reload_tracks)(void);
480 int (*audio_get_file_pos)(void);
481 #if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
482 unsigned long (*mpeg_get_last_header)(void);
483 #endif
484 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) || \
485 (CONFIG_CODEC == SWCODEC)
486 void (*sound_set_pitch)(int pitch);
487 #endif
489 /* MAS communication */
490 #if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
491 int (*mas_readmem)(int bank, int addr, unsigned long* dest, int len);
492 int (*mas_writemem)(int bank, int addr, const unsigned long* src, int len);
493 int (*mas_readreg)(int reg);
494 int (*mas_writereg)(int reg, unsigned int val);
495 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
496 int (*mas_codec_writereg)(int reg, unsigned int val);
497 int (*mas_codec_readreg)(int reg);
498 void (*i2c_begin)(void);
499 void (*i2c_end)(void);
500 int (*i2c_write)(int address, unsigned char* buf, int count );
501 #endif
502 #endif
504 /* menu */
505 int (*do_menu)(const struct menu_item_ex *menu, int *start_selected);
507 /* scroll bar */
508 struct gui_syncstatusbar *statusbars;
509 void (*gui_syncstatusbar_draw)(struct gui_syncstatusbar * bars, bool force_redraw);
511 /* options */
512 bool (*set_option)(const char* string, void* variable,
513 enum optiontype type, const struct opt_items* options,
514 int numoptions, void (*function)(int));
515 bool (*set_bool_options)(const char* string, bool* variable,
516 const char* yes_str, int yes_voice,
517 const char* no_str, int no_voice,
518 void (*function)(bool));
519 bool (*set_int)(const unsigned char* string, const char* unit, int voice_unit,
520 int* variable, void (*function)(int), int step, int min,
521 int max, void (*formatter)(char*, int, int, const char*) );
522 bool (*set_bool)(const char* string, bool* variable );
524 #ifdef HAVE_LCD_COLOR
525 bool (*set_color)(struct screen *display, char *title, unsigned *color,
526 unsigned banned_color);
527 #endif
528 /* action handling */
529 int (*get_custom_action)(int context,int timeout,
530 const struct button_mapping* (*get_context_map)(int));
531 int (*get_action)(int context, int timeout);
532 void (*action_signalscreenchange)(void);
533 bool (*action_userabort)(int timeout);
535 /* power */
536 int (*battery_level)(void);
537 bool (*battery_level_safe)(void);
538 int (*battery_time)(void);
539 #ifndef SIMULATOR
540 unsigned int (*battery_voltage)(void);
541 #endif
542 #if CONFIG_CHARGING
543 bool (*charger_inserted)(void);
544 # if CONFIG_CHARGING == CHARGING_MONITOR
545 bool (*charging_state)(void);
546 # endif
547 #endif
548 #ifdef HAVE_USB_POWER
549 bool (*usb_powered)(void);
550 #endif
552 /* misc */
553 void (*srand)(unsigned int seed);
554 int (*rand)(void);
555 void (*qsort)(void *base, size_t nmemb, size_t size,
556 int(*compar)(const void *, const void *));
557 int (*kbd_input)(char* buffer, int buflen);
558 struct tm* (*get_time)(void);
559 int (*set_time)(const struct tm *tm);
560 void* (*plugin_get_buffer)(size_t *buffer_size);
561 void* (*plugin_get_audio_buffer)(size_t *buffer_size);
562 void (*plugin_tsr)(bool (*exit_callback)(bool reenter));
563 #ifdef IRAM_STEAL
564 void (*plugin_iram_init)(char *iramstart, char *iramcopy, size_t iram_size,
565 char *iedata, size_t iedata_size);
566 #endif
567 #if defined(DEBUG) || defined(SIMULATOR)
568 void (*debugf)(const char *fmt, ...) ATTRIBUTE_PRINTF(1, 2);
569 #endif
570 #ifdef ROCKBOX_HAS_LOGF
571 void (*logf)(const char *fmt, ...) ATTRIBUTE_PRINTF(1, 2);
572 #endif
573 struct user_settings* global_settings;
574 struct system_status *global_status;
575 bool (*mp3info)(struct mp3entry *entry, const char *filename, bool v1first);
576 int (*count_mp3_frames)(int fd, int startpos, int filesize,
577 void (*progressfunc)(int));
578 int (*create_xing_header)(int fd, long startpos, long filesize,
579 unsigned char *buf, unsigned long num_frames,
580 unsigned long rec_time, unsigned long header_template,
581 void (*progressfunc)(int), bool generate_toc);
582 unsigned long (*find_next_frame)(int fd, long *offset,
583 long max_offset, unsigned long last_header);
585 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
586 unsigned short (*peak_meter_scale_value)(unsigned short val,
587 int meterwidth);
588 void (*peak_meter_set_use_dbfs)(bool use);
589 bool (*peak_meter_get_use_dbfs)(void);
590 #endif
591 #ifdef HAVE_LCD_BITMAP
592 int (*read_bmp_file)(char* filename, struct bitmap *bm, int maxsize,
593 int format);
594 void (*screen_dump_set_hook)(void (*hook)(int fh));
595 #endif
596 int (*show_logo)(void);
597 struct tree_context* (*tree_get_context)(void);
599 #ifdef HAVE_WHEEL_POSITION
600 int (*wheel_status)(void);
601 void (*wheel_send_events)(bool send);
602 #endif
604 #ifdef IRIVER_H100_SERIES
605 /* Routines for the iriver_flash -plugin. */
606 bool (*detect_original_firmware)(void);
607 bool (*detect_flashed_ramimage)(void);
608 bool (*detect_flashed_romimage)(void);
609 #endif
610 /* new stuff at the end, sort into place next time
611 the API gets incompatible */
613 #if NUM_CORES > 1
614 void (*spinlock_init)(struct mutex *m);
615 void (*spinlock_lock)(struct mutex *m);
616 void (*spinlock_unlock)(struct mutex *m);
617 #endif
619 #if (CONFIG_CODEC == SWCODEC)
620 int (*codec_load_file)(const char* codec, struct codec_api *api);
621 const char *(*get_codec_filename)(int cod_spec);
622 bool (*get_metadata)(struct track_info* track, int fd, const char* trackname,
623 bool v1first);
624 #endif
627 /* plugin header */
628 struct plugin_header {
629 unsigned long magic;
630 unsigned short target_id;
631 unsigned short api_version;
632 unsigned char *load_addr;
633 unsigned char *end_addr;
634 enum plugin_status(*entry_point)(struct plugin_api*, void*);
637 #ifdef PLUGIN
638 #ifndef SIMULATOR
639 extern unsigned char plugin_start_addr[];
640 extern unsigned char plugin_end_addr[];
641 #define PLUGIN_HEADER \
642 const struct plugin_header __header \
643 __attribute__ ((section (".header")))= { \
644 PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \
645 plugin_start_addr, plugin_end_addr, plugin_start };
646 #else /* SIMULATOR */
647 #define PLUGIN_HEADER \
648 const struct plugin_header __header = { \
649 PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \
650 NULL, NULL, plugin_start };
651 #endif /* SIMULATOR */
653 #ifdef USE_IRAM
654 /* Declare IRAM variables */
655 #define PLUGIN_IRAM_DECLARE \
656 extern char iramcopy[]; \
657 extern char iramstart[]; \
658 extern char iramend[]; \
659 extern char iedata[]; \
660 extern char iend[];
661 /* Initialize IRAM */
662 #define PLUGIN_IRAM_INIT(api) \
663 (api)->plugin_iram_init(iramstart, iramcopy, iramend-iramstart, \
664 iedata, iend-iedata);
665 #else
666 #define PLUGIN_IRAM_DECLARE
667 #define PLUGIN_IRAM_INIT(api)
668 #endif /* USE_IRAM */
669 #endif /* PLUGIN */
671 int plugin_load(const char* plugin, void* parameter);
672 void* plugin_get_buffer(size_t *buffer_size);
673 void* plugin_get_audio_buffer(size_t *buffer_size);
674 #ifdef IRAM_STEAL
675 void plugin_iram_init(char *iramstart, char *iramcopy, size_t iram_size,
676 char *iedata, size_t iedata_size);
677 #endif
679 /* plugin_tsr,
680 callback returns true to allow the new plugin to load,
681 reenter means the currently running plugin is being reloaded */
682 void plugin_tsr(bool (*exit_callback)(bool reenter));
684 /* defined by the plugin */
685 enum plugin_status plugin_start(struct plugin_api* rockbox, void* parameter)
686 NO_PROF_ATTR;
688 /* Use this macro in plugins where gcc tries to optimize by calling
689 * these functions directly */
690 #define MEM_FUNCTION_WRAPPERS(api) \
691 void *memcpy(void *dest, const void *src, size_t n) \
693 return (api)->memcpy(dest, src, n); \
695 void *memset(void *dest, int c, size_t n) \
697 return (api)->memset(dest, c, n); \
699 void *memmove(void *dest, const void *src, size_t n) \
701 return (api)->memmove(dest, src, n); \
703 int memcmp(const void *s1, const void *s2, size_t n) \
705 return (api)->memcmp(s1, s2, n); \
708 #endif