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