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