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