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