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