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