Gigabeat S can do dithered YUV blitting too, so put it into the plugin API and enable...
[kugel-rb.git] / apps / plugin.h
blob74daa2a67b005be848106726e343df537705a56c
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 162
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 162
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) \
216 || defined(SANSA_FUZE) || defined(SANSA_E200V2) || defined(TOSHIBA_GIGABEAT_S)
217 void (*lcd_yuv_set_options)(unsigned options);
218 #endif
219 #endif /* MEMORYSIZE > 2 */
220 #elif (LCD_DEPTH < 4) && !defined(SIMULATOR)
221 void (*lcd_blit_mono)(const unsigned char *data, int x, int by, int width,
222 int bheight, int stride);
223 void (*lcd_blit_grey_phase)(unsigned char *values, unsigned char *phases,
224 int bx, int by, int bwidth, int bheight,
225 int stride);
226 #endif /* LCD_DEPTH */
227 #if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
228 void (*lcd_blit_pal256)(unsigned char *src, int src_x, int src_y, int x, int y,
229 int width, int height);
230 void (*lcd_pal256_update_pal)(fb_data *palette);
231 #endif
232 void (*lcd_puts_style)(int x, int y, const unsigned char *str, int style);
233 void (*lcd_puts_scroll_style)(int x, int y, const unsigned char* string,
234 int style);
235 #ifdef HAVE_LCD_INVERT
236 void (*lcd_set_invert_display)(bool yesno);
237 #endif /* HAVE_LCD_INVERT */
238 #if defined(HAVE_LCD_MODES)
239 void (*lcd_set_mode)(int mode);
240 #endif
242 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
243 void (*lcd_activation_set_hook)(void (*enable_hook)(void));
244 struct event_queue *button_queue;
245 #endif
246 unsigned short *(*bidi_l2v)( const unsigned char *str, int orientation );
247 const unsigned char *(*font_get_bits)( struct font *pf, unsigned short char_code );
248 struct font* (*font_load)(const char *path);
249 struct font* (*font_get)(int font);
250 int (*font_getstringsize)(const unsigned char *str, int *w, int *h,
251 int fontnumber);
252 int (*font_get_width)(struct font* pf, unsigned short char_code);
253 void (*screen_clear_area)(struct screen * display, int xstart, int ystart,
254 int width, int height);
255 void (*gui_scrollbar_draw)(struct screen * screen, int x, int y,
256 int width, int height, int items,
257 int min_shown, int max_shown,
258 unsigned flags);
259 #endif /* HAVE_LCD_BITMAP */
260 const char* (*get_codepage_name)(int cp);
262 /* backlight */
263 /* The backlight_* functions must be present in the API regardless whether
264 * HAVE_BACKLIGHT is defined or not. The reason is that the stock Ondio has
265 * no backlight but can be modded to have backlight (it's prepared on the
266 * PCB). This makes backlight an all-target feature API wise, and keeps API
267 * compatible between stock and modded Ondio.
268 * For OLED targets like the Sansa Clip, the backlight_* functions control
269 * the display enable, which has essentially the same effect. */
270 void (*backlight_on)(void);
271 void (*backlight_off)(void);
272 void (*backlight_set_timeout)(int index);
273 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
274 void (*backlight_set_brightness)(int val);
275 #endif /* HAVE_BACKLIGHT_BRIGHTNESS */
277 #if CONFIG_CHARGING
278 void (*backlight_set_timeout_plugged)(int index);
279 #endif
280 bool (*is_backlight_on)(bool ignore_always_off);
281 void (*splash)(int ticks, const char *str);
282 void (*splashf)(int ticks, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3);
284 #ifdef HAVE_REMOTE_LCD
285 /* remote lcd */
286 void (*lcd_remote_set_contrast)(int x);
287 void (*lcd_remote_clear_display)(void);
288 void (*lcd_remote_puts)(int x, int y, const unsigned char *string);
289 void (*lcd_remote_puts_scroll)(int x, int y, const unsigned char* string);
290 void (*lcd_remote_stop_scroll)(void);
291 void (*lcd_remote_set_drawmode)(int mode);
292 int (*lcd_remote_get_drawmode)(void);
293 void (*lcd_remote_setfont)(int font);
294 int (*lcd_remote_getstringsize)(const unsigned char *str, int *w, int *h);
295 void (*lcd_remote_drawpixel)(int x, int y);
296 void (*lcd_remote_drawline)(int x1, int y1, int x2, int y2);
297 void (*lcd_remote_hline)(int x1, int x2, int y);
298 void (*lcd_remote_vline)(int x, int y1, int y2);
299 void (*lcd_remote_drawrect)(int x, int y, int nx, int ny);
300 void (*lcd_remote_fillrect)(int x, int y, int nx, int ny);
301 void (*lcd_remote_mono_bitmap_part)(const unsigned char *src, int src_x,
302 int src_y, int stride, int x, int y,
303 int width, int height);
304 void (*lcd_remote_mono_bitmap)(const unsigned char *src, int x, int y,
305 int width, int height);
306 void (*lcd_remote_putsxy)(int x, int y, const unsigned char *string);
307 void (*lcd_remote_puts_style)(int x, int y, const unsigned char *str, int style);
308 void (*lcd_remote_puts_scroll_style)(int x, int y, const unsigned char* string,
309 int style);
310 fb_remote_data* lcd_remote_framebuffer;
311 void (*lcd_remote_update)(void);
312 void (*lcd_remote_update_rect)(int x, int y, int width, int height);
314 void (*remote_backlight_on)(void);
315 void (*remote_backlight_off)(void);
316 void (*remote_backlight_set_timeout)(int index);
317 #if CONFIG_CHARGING
318 void (*remote_backlight_set_timeout_plugged)(int index);
319 #endif
320 #endif /* HAVE_REMOTE_LCD */
321 struct screen* screens[NB_SCREENS];
322 #if defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)
323 void (*lcd_remote_set_foreground)(unsigned foreground);
324 unsigned (*lcd_remote_get_foreground)(void);
325 void (*lcd_remote_set_background)(unsigned background);
326 unsigned (*lcd_remote_get_background)(void);
327 void (*lcd_remote_bitmap_part)(const fb_remote_data *src, int src_x, int src_y,
328 int stride, int x, int y, int width, int height);
329 void (*lcd_remote_bitmap)(const fb_remote_data *src, int x, int y, int width,
330 int height);
331 #endif
332 void (*viewport_set_defaults)(struct viewport *vp, enum screen_type screen);
333 int (*viewportmanager_set_statusbar)(int enable_status);
334 /* list */
335 void (*gui_synclist_init)(struct gui_synclist * lists,
336 list_get_name callback_get_item_name, void * data,
337 bool scroll_all,int selected_size,
338 struct viewport parent[NB_SCREENS]);
339 void (*gui_synclist_set_nb_items)(struct gui_synclist * lists, int nb_items);
340 void (*gui_synclist_set_icon_callback)(struct gui_synclist * lists, list_get_icon icon_callback);
341 int (*gui_synclist_get_nb_items)(struct gui_synclist * lists);
342 int (*gui_synclist_get_sel_pos)(struct gui_synclist * lists);
343 void (*gui_synclist_draw)(struct gui_synclist * lists);
344 void (*gui_synclist_select_item)(struct gui_synclist * lists,
345 int item_number);
346 void (*gui_synclist_add_item)(struct gui_synclist * lists);
347 void (*gui_synclist_del_item)(struct gui_synclist * lists);
348 void (*gui_synclist_limit_scroll)(struct gui_synclist * lists, bool scroll);
349 bool (*gui_synclist_do_button)(struct gui_synclist * lists,
350 int *action, enum list_wrap wrap);
351 void (*gui_synclist_set_title)(struct gui_synclist *lists, char* title,
352 enum themable_icons icon);
353 enum yesno_res (*gui_syncyesno_run)(const struct text_message * main_message,
354 const struct text_message * yes_message,
355 const struct text_message * no_message);
356 void (*simplelist_info_init)(struct simplelist_info *info, char* title,
357 int count, void* data);
358 bool (*simplelist_show_list)(struct simplelist_info *info);
360 /* button */
361 long (*button_get)(bool block);
362 long (*button_get_w_tmo)(int ticks);
363 int (*button_status)(void);
364 #ifdef HAVE_BUTTON_DATA
365 intptr_t (*button_get_data)(void);
366 #endif
367 void (*button_clear_queue)(void);
368 int (*button_queue_count)(void);
369 #ifdef HAS_BUTTON_HOLD
370 bool (*button_hold)(void);
371 #endif
372 #ifdef HAVE_TOUCHSCREEN
373 void (*touchscreen_set_mode)(enum touchscreen_mode);
374 #endif
375 #ifdef HAVE_BUTTON_LIGHT
376 void (*buttonlight_set_timeout)(int value);
377 void (*buttonlight_off)(void);
378 void (*buttonlight_on)(void);
379 #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
380 void (*buttonlight_set_brightness)(int val);
381 #endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
382 #endif /* HAVE_BUTTON_LIGHT */
384 /* file */
385 int (*open)(const char* pathname, int flags);
386 int (*close)(int fd);
387 ssize_t (*read)(int fd, void* buf, size_t count);
388 off_t (*lseek)(int fd, off_t offset, int whence);
389 int (*creat)(const char *pathname);
390 ssize_t (*write)(int fd, const void* buf, size_t count);
391 int (*remove)(const char* pathname);
392 int (*rename)(const char* path, const char* newname);
393 int (*ftruncate)(int fd, off_t length);
394 off_t (*filesize)(int fd);
395 int (*fdprintf)(int fd, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3);
396 int (*read_line)(int fd, char* buffer, int buffer_size);
397 bool (*settings_parseline)(char* line, char** name, char** value);
398 void (*storage_sleep)(void);
399 void (*storage_spin)(void);
400 void (*storage_spindown)(int seconds);
401 #if USING_STORAGE_CALLBACK
402 void (*register_storage_idle_func)(storage_idle_notify function);
403 void (*unregister_storage_idle_func)(storage_idle_notify function, bool run);
404 #endif /* USING_STORAGE_CALLBACK */
405 void (*reload_directory)(void);
406 char *(*create_numbered_filename)(char *buffer, const char *path,
407 const char *prefix, const char *suffix,
408 int numberlen IF_CNFN_NUM_(, int *num));
409 bool (*file_exists)(const char *file);
410 char* (*strip_extension)(char* buffer, int buffer_size, const char *filename);
413 /* dir */
414 DIR* (*opendir)(const char* name);
415 int (*closedir)(DIR* dir);
416 struct dirent* (*readdir)(DIR* dir);
417 int (*mkdir)(const char *name);
418 int (*rmdir)(const char *name);
419 bool (*dir_exists)(const char *path);
421 /* kernel/ system */
422 #ifdef CPU_ARM
423 void (*__div0)(void);
424 #endif
425 void (*sleep)(int ticks);
426 void (*yield)(void);
427 volatile long* current_tick;
428 long (*default_event_handler)(long event);
429 long (*default_event_handler_ex)(long event, void (*callback)(void *), void *parameter);
430 unsigned int (*create_thread)(void (*function)(void), void* stack,
431 size_t stack_size, unsigned flags,
432 const char *name
433 IF_PRIO(, int priority)
434 IF_COP(, unsigned int core));
435 void (*thread_exit)(void);
436 void (*thread_wait)(unsigned int thread_id);
437 #if CONFIG_CODEC == SWCODEC
438 void (*thread_thaw)(unsigned int thread_id);
439 #ifdef HAVE_PRIORITY_SCHEDULING
440 int (*thread_set_priority)(unsigned int thread_id, int priority);
441 #endif
442 void (*mutex_init)(struct mutex *m);
443 void (*mutex_lock)(struct mutex *m);
444 void (*mutex_unlock)(struct mutex *m);
445 #endif
447 void (*reset_poweroff_timer)(void);
448 #ifndef SIMULATOR
449 int (*system_memory_guard)(int newmode);
450 long *cpu_frequency;
451 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
452 #ifdef CPU_BOOST_LOGGING
453 void (*cpu_boost_)(bool on_off,char*location,int line);
454 #else
455 void (*cpu_boost)(bool on_off);
456 #endif
457 #endif /* HAVE_ADJUSTABLE_CPU_FREQ */
458 #endif /* !SIMULATOR */
459 #ifdef HAVE_SCHEDULER_BOOSTCTRL
460 void (*trigger_cpu_boost)(void);
461 void (*cancel_cpu_boost)(void);
462 #endif
463 #if NUM_CORES > 1
464 void (*cpucache_flush)(void);
465 void (*cpucache_invalidate)(void);
466 #endif
467 bool (*timer_register)(int reg_prio, void (*unregister_callback)(void),
468 long cycles, void (*timer_callback)(void)
469 IF_COP(, int core));
470 void (*timer_unregister)(void);
471 bool (*timer_set_period)(long count);
473 void (*queue_init)(struct event_queue *q, bool register_queue);
474 void (*queue_delete)(struct event_queue *q);
475 void (*queue_post)(struct event_queue *q, long id, intptr_t data);
476 void (*queue_wait_w_tmo)(struct event_queue *q, struct queue_event *ev,
477 int ticks);
478 #if CONFIG_CODEC == SWCODEC
479 void (*queue_enable_queue_send)(struct event_queue *q,
480 struct queue_sender_list *send,
481 unsigned int thread_id);
482 bool (*queue_empty)(const struct event_queue *q);
483 void (*queue_wait)(struct event_queue *q, struct queue_event *ev);
484 intptr_t (*queue_send)(struct event_queue *q, long id,
485 intptr_t data);
486 void (*queue_reply)(struct event_queue *q, intptr_t retval);
487 #endif /* CONFIG_CODEC == SWCODEC */
489 void (*usb_acknowledge)(long id);
490 #ifdef RB_PROFILE
491 void (*profile_thread)(void);
492 void (*profstop)(void);
493 void (*profile_func_enter)(void *this_fn, void *call_site);
494 void (*profile_func_exit)(void *this_fn, void *call_site);
495 #endif
497 #ifdef SIMULATOR
498 /* special simulator hooks */
499 #if defined(HAVE_LCD_BITMAP) && LCD_DEPTH < 8
500 void (*sim_lcd_ex_init)(unsigned long (*getpixel)(int, int));
501 void (*sim_lcd_ex_update_rect)(int x, int y, int width, int height);
502 #endif
503 #endif
505 /* strings and memory */
506 int (*snprintf)(char *buf, size_t size, const char *fmt, ...)
507 ATTRIBUTE_PRINTF(3, 4);
508 int (*vsnprintf)(char *buf, int size, const char *fmt, va_list ap);
509 char* (*strcpy)(char *dst, const char *src);
510 size_t (*strlcpy)(char *dst, const char *src, size_t length);
511 size_t (*strlen)(const char *str);
512 char * (*strrchr)(const char *s, int c);
513 int (*strcmp)(const char *, const char *);
514 int (*strncmp)(const char *, const char *, size_t);
515 int (*strcasecmp)(const char *, const char *);
516 int (*strncasecmp)(const char *s1, const char *s2, size_t n);
517 void* (*memset)(void *dst, int c, size_t length);
518 void* (*memcpy)(void *out, const void *in, size_t n);
519 void* (*memmove)(void *out, const void *in, size_t n);
520 const unsigned char *_rbctype_;
521 int (*atoi)(const char *str);
522 char *(*strchr)(const char *s, int c);
523 char *(*strcat)(char *s1, const char *s2);
524 void *(*memchr)(const void *s1, int c, size_t n);
525 int (*memcmp)(const void *s1, const void *s2, size_t n);
526 char *(*strcasestr) (const char* phaystack, const char* pneedle);
527 char* (*strtok_r)(char *ptr, const char *sep, char **end);
528 /* unicode stuff */
529 const unsigned char* (*utf8decode)(const unsigned char *utf8, unsigned short *ucs);
530 unsigned char* (*iso_decode)(const unsigned char *iso, unsigned char *utf8, int cp, int count);
531 unsigned char* (*utf16LEdecode)(const unsigned char *utf16, unsigned char *utf8, int count);
532 unsigned char* (*utf16BEdecode)(const unsigned char *utf16, unsigned char *utf8, int count);
533 unsigned char* (*utf8encode)(unsigned long ucs, unsigned char *utf8);
534 unsigned long (*utf8length)(const unsigned char *utf8);
535 int (*utf8seek)(const unsigned char* utf8, int offset);
537 /* sound */
538 void (*sound_set)(int setting, int value);
539 int (*sound_default)(int setting);
540 int (*sound_min)(int setting);
541 int (*sound_max)(int setting);
542 const char * (*sound_unit)(int setting);
543 int (*sound_val2phys)(int setting, int value);
544 #ifndef SIMULATOR
545 void (*mp3_play_data)(const unsigned char* start, int size, void (*get_more)(unsigned char** start, size_t* size));
546 void (*mp3_play_pause)(bool play);
547 void (*mp3_play_stop)(void);
548 bool (*mp3_is_playing)(void);
549 #if CONFIG_CODEC != SWCODEC
550 void (*bitswap)(unsigned char *data, int length);
551 #endif
552 #endif /* !SIMULATOR */
553 #if CONFIG_CODEC == SWCODEC
554 const unsigned long *audio_master_sampr_list;
555 const unsigned long *hw_freq_sampr;
556 void (*pcm_apply_settings)(void);
557 void (*pcm_play_data)(pcm_more_callback_type get_more,
558 unsigned char* start, size_t size);
559 void (*pcm_play_stop)(void);
560 void (*pcm_set_frequency)(unsigned int frequency);
561 bool (*pcm_is_playing)(void);
562 bool (*pcm_is_paused)(void);
563 void (*pcm_play_pause)(bool play);
564 size_t (*pcm_get_bytes_waiting)(void);
565 void (*pcm_calculate_peaks)(int *left, int *right);
566 void (*pcm_play_lock)(void);
567 void (*pcm_play_unlock)(void);
568 #ifdef HAVE_RECORDING
569 const unsigned long *rec_freq_sampr;
570 void (*pcm_init_recording)(void);
571 void (*pcm_close_recording)(void);
572 void (*pcm_record_data)(pcm_more_callback_type2 more_ready,
573 void *start, size_t size);
574 void (*pcm_record_more)(void *start, size_t size);
575 void (*pcm_stop_recording)(void);
576 void (*pcm_calculate_rec_peaks)(int *left, int *right);
577 void (*audio_set_recording_gain)(int left, int right, int type);
578 #endif /* HAVE_RECORDING */
579 #if INPUT_SRC_CAPS != 0
580 void (*audio_set_output_source)(int monitor);
581 void (*audio_set_input_source)(int source, unsigned flags);
582 #endif
583 void (*dsp_set_crossfeed)(bool enable);
584 void (*dsp_set_eq)(bool enable);
585 void (*dsp_dither_enable)(bool enable);
586 intptr_t (*dsp_configure)(struct dsp_config *dsp, int setting,
587 intptr_t value);
588 int (*dsp_process)(struct dsp_config *dsp, char *dest,
589 const char *src[], int count);
590 #endif /* CONFIG_CODEC == SWCODC */
592 /* playback control */
593 int (*playlist_amount)(void);
594 int (*playlist_resume)(void);
595 void (*playlist_start)(int start_index, int offset);
596 int (*playlist_add)(const char *filename);
597 void (*playlist_sync)(struct playlist_info* playlist);
598 int (*playlist_remove_all_tracks)(struct playlist_info *playlist);
599 int (*playlist_create)(const char *dir, const char *file);
600 int (*playlist_insert_track)(struct playlist_info* playlist,
601 const char *filename, int position, bool queue, bool sync);
602 int (*playlist_insert_directory)(struct playlist_info* playlist,
603 const char *dirname, int position, bool queue,
604 bool recurse);
605 int (*playlist_shuffle)(int random_seed, int start_index);
606 void (*audio_play)(long offset);
607 void (*audio_stop)(void);
608 void (*audio_pause)(void);
609 void (*audio_resume)(void);
610 void (*audio_next)(void);
611 void (*audio_prev)(void);
612 void (*audio_ff_rewind)(long newtime);
613 struct mp3entry* (*audio_next_track)(void);
614 int (*audio_status)(void);
615 struct mp3entry* (*audio_current_track)(void);
616 void (*audio_flush_and_reload_tracks)(void);
617 int (*audio_get_file_pos)(void);
618 #if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
619 unsigned long (*mpeg_get_last_header)(void);
620 #endif
621 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) || \
622 (CONFIG_CODEC == SWCODEC)
623 void (*sound_set_pitch)(int32_t pitch);
624 #endif
626 /* MAS communication */
627 #if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
628 int (*mas_readmem)(int bank, int addr, unsigned long* dest, int len);
629 int (*mas_writemem)(int bank, int addr, const unsigned long* src, int len);
630 int (*mas_readreg)(int reg);
631 int (*mas_writereg)(int reg, unsigned int val);
632 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
633 int (*mas_codec_writereg)(int reg, unsigned int val);
634 int (*mas_codec_readreg)(int reg);
635 void (*i2c_begin)(void);
636 void (*i2c_end)(void);
637 int (*i2c_write)(int address, const unsigned char* buf, int count );
638 #endif
639 #endif
641 /* menu */
642 int (*do_menu)(const struct menu_item_ex *menu, int *start_selected,
643 struct viewport parent[NB_SCREENS], bool hide_bars);
645 /* scroll bar */
646 struct gui_syncstatusbar *statusbars;
647 void (*gui_syncstatusbar_draw)(struct gui_syncstatusbar * bars, bool force_redraw);
649 /* options */
650 const struct settings_list* (*get_settings_list)(int*count);
651 const struct settings_list* (*find_setting)(const void* variable, int *id);
652 bool (*option_screen)(const struct settings_list *setting,
653 struct viewport parent[NB_SCREENS],
654 bool use_temp_var, unsigned char* option_title);
655 bool (*set_option)(const char* string, const void* variable,
656 enum optiontype type, const struct opt_items* options,
657 int numoptions, void (*function)(int));
658 bool (*set_bool_options)(const char* string, const bool* variable,
659 const char* yes_str, int yes_voice,
660 const char* no_str, int no_voice,
661 void (*function)(bool));
662 bool (*set_int)(const unsigned char* string, const char* unit, int voice_unit,
663 const int* variable, void (*function)(int), int step,
664 int min, int max,
665 void (*formatter)(char*, size_t, int, const char*) );
666 bool (*set_bool)(const char* string, const bool* variable );
668 #ifdef HAVE_LCD_COLOR
669 bool (*set_color)(struct screen *display, char *title, unsigned *color,
670 unsigned banned_color);
671 #endif
672 /* action handling */
673 int (*get_custom_action)(int context,int timeout,
674 const struct button_mapping* (*get_context_map)(int));
675 int (*get_action)(int context, int timeout);
676 #ifdef HAVE_TOUCHSCREEN
677 int (*action_get_touchscreen_press)(short *x, short *y);
678 #endif
679 bool (*action_userabort)(int timeout);
681 /* power */
682 int (*battery_level)(void);
683 bool (*battery_level_safe)(void);
684 int (*battery_time)(void);
685 #ifndef SIMULATOR
686 unsigned int (*battery_voltage)(void);
687 #endif
688 #if CONFIG_CHARGING
689 bool (*charger_inserted)(void);
690 # if CONFIG_CHARGING >= CHARGING_MONITOR
691 bool (*charging_state)(void);
692 # endif
693 #endif
694 #ifdef HAVE_USB_POWER
695 bool (*usb_powered)(void);
696 #endif
698 /* misc */
699 void (*srand)(unsigned int seed);
700 int (*rand)(void);
701 void (*qsort)(void *base, size_t nmemb, size_t size,
702 int(*compar)(const void *, const void *));
703 int (*kbd_input)(char* buffer, int buflen);
704 struct tm* (*get_time)(void);
705 int (*set_time)(const struct tm *tm);
706 #if CONFIG_RTC
707 time_t (*mktime)(struct tm *t);
708 #endif
709 void* (*plugin_get_buffer)(size_t *buffer_size);
710 void* (*plugin_get_audio_buffer)(size_t *buffer_size);
711 void (*plugin_tsr)(bool (*exit_callback)(bool reenter));
712 char* (*plugin_get_current_filename)(void);
713 #ifdef PLUGIN_USE_IRAM
714 void (*plugin_iram_init)(char *iramstart, char *iramcopy, size_t iram_size,
715 char *iedata, size_t iedata_size);
716 #endif
717 #if defined(DEBUG) || defined(SIMULATOR)
718 void (*debugf)(const char *fmt, ...) ATTRIBUTE_PRINTF(1, 2);
719 #endif
720 #ifdef ROCKBOX_HAS_LOGF
721 void (*logf)(const char *fmt, ...) ATTRIBUTE_PRINTF(1, 2);
722 #endif
723 struct user_settings* global_settings;
724 struct system_status *global_status;
725 void (*talk_disable)(bool disable);
726 #if CONFIG_CODEC == SWCODEC
727 void (*codec_thread_do_callback)(void (*fn)(void),
728 unsigned int *audio_thread_id);
729 int (*codec_load_file)(const char* codec, struct codec_api *api);
730 const char *(*get_codec_filename)(int cod_spec);
731 #endif
732 bool (*get_metadata)(struct mp3entry* id3, int fd, const char* trackname);
733 bool (*mp3info)(struct mp3entry *entry, const char *filename);
734 int (*count_mp3_frames)(int fd, int startpos, int filesize,
735 void (*progressfunc)(int));
736 int (*create_xing_header)(int fd, long startpos, long filesize,
737 unsigned char *buf, unsigned long num_frames,
738 unsigned long rec_time, unsigned long header_template,
739 void (*progressfunc)(int), bool generate_toc);
740 unsigned long (*find_next_frame)(int fd, long *offset,
741 long max_offset, unsigned long last_header);
743 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
744 unsigned short (*peak_meter_scale_value)(unsigned short val,
745 int meterwidth);
746 void (*peak_meter_set_use_dbfs)(bool use);
747 bool (*peak_meter_get_use_dbfs)(void);
748 #endif
749 #ifdef HAVE_LCD_BITMAP
750 int (*read_bmp_file)(const char* filename, struct bitmap *bm, int maxsize,
751 int format, const struct custom_format *cformat);
752 int (*read_bmp_fd)(int fd, struct bitmap *bm, int maxsize,
753 int format, const struct custom_format *cformat);
754 #ifdef HAVE_JPEG
755 int (*read_jpeg_file)(const char* filename, struct bitmap *bm, int maxsize,
756 int format, const struct custom_format *cformat);
757 int (*read_jpeg_fd)(int fd, struct bitmap *bm, int maxsize,
758 int format, const struct custom_format *cformat);
759 #endif
760 void (*screen_dump_set_hook)(void (*hook)(int fh));
761 #endif
762 int (*show_logo)(void);
763 struct tree_context* (*tree_get_context)(void);
764 void (*set_current_file)(char* path);
765 void (*set_dirfilter)(int l_dirfilter);
767 #ifdef HAVE_WHEEL_POSITION
768 int (*wheel_status)(void);
769 void (*wheel_send_events)(bool send);
770 #endif
772 #ifdef IRIVER_H100_SERIES
773 /* Routines for the iriver_flash -plugin. */
774 bool (*detect_original_firmware)(void);
775 bool (*detect_flashed_ramimage)(void);
776 bool (*detect_flashed_romimage)(void);
777 #endif
779 void (*led)(bool on);
781 #if (CONFIG_CODEC == SWCODEC)
782 /* buffering API */
783 int (*bufopen)(const char *file, size_t offset, enum data_type type);
784 int (*bufalloc)(const void *src, size_t size, enum data_type type);
785 bool (*bufclose)(int handle_id);
786 int (*bufseek)(int handle_id, size_t newpos);
787 int (*bufadvance)(int handle_id, off_t offset);
788 ssize_t (*bufread)(int handle_id, size_t size, void *dest);
789 ssize_t (*bufgetdata)(int handle_id, size_t size, void **data);
790 ssize_t (*bufgettail)(int handle_id, size_t size, void **data);
791 ssize_t (*bufcuttail)(int handle_id, size_t size);
793 ssize_t (*buf_get_offset)(int handle_id, void *ptr);
794 ssize_t (*buf_handle_offset)(int handle_id);
795 void (*buf_request_buffer_handle)(int handle_id);
796 void (*buf_set_base_handle)(int handle_id);
797 size_t (*buf_used)(void);
798 #endif
800 #ifdef HAVE_TAGCACHE
801 bool (*tagcache_search)(struct tagcache_search *tcs, int tag);
802 void (*tagcache_search_set_uniqbuf)(struct tagcache_search *tcs,
803 void *buffer, long length);
804 bool (*tagcache_search_add_filter)(struct tagcache_search *tcs,
805 int tag, int seek);
806 bool (*tagcache_get_next)(struct tagcache_search *tcs);
807 bool (*tagcache_retrieve)(struct tagcache_search *tcs, int idxid,
808 int tag, char *buf, long size);
809 void (*tagcache_search_finish)(struct tagcache_search *tcs);
810 long (*tagcache_get_numeric)(const struct tagcache_search *tcs, int tag);
811 #ifdef HAVE_TC_RAMCACHE
812 bool (*tagcache_fill_tags)(struct mp3entry *id3, const char *filename);
813 #endif
814 #endif
816 #ifdef HAVE_ALBUMART
817 bool (*find_albumart)(const struct mp3entry *id3, char *buf, int buflen);
818 bool (*search_albumart_files)(const struct mp3entry *id3, const char *size_string,
819 char *buf, int buflen);
820 #endif
822 #ifdef HAVE_SEMAPHORE_OBJECTS
823 void (*semaphore_init)(struct semaphore *s, int max, int start);
824 void (*semaphore_wait)(struct semaphore *s);
825 void (*semaphore_release)(struct semaphore *s);
826 #endif
828 const char *appsversion;
829 /* new stuff at the end, sort into place next time
830 the API gets incompatible */
833 /* plugin header */
834 struct plugin_header {
835 unsigned long magic;
836 unsigned short target_id;
837 unsigned short api_version;
838 unsigned char *load_addr;
839 unsigned char *end_addr;
840 enum plugin_status(*entry_point)(const void*);
841 const struct plugin_api **api;
844 #ifdef PLUGIN
845 #ifndef SIMULATOR
846 extern unsigned char plugin_start_addr[];
847 extern unsigned char plugin_end_addr[];
848 #define PLUGIN_HEADER \
849 const struct plugin_api *rb DATA_ATTR; \
850 const struct plugin_header __header \
851 __attribute__ ((section (".header")))= { \
852 PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \
853 plugin_start_addr, plugin_end_addr, plugin_start, &rb };
854 #else /* SIMULATOR */
855 #define PLUGIN_HEADER \
856 const struct plugin_api *rb DATA_ATTR; \
857 const struct plugin_header __header \
858 __attribute__((visibility("default"))) = { \
859 PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \
860 NULL, NULL, plugin_start, &rb };
861 #endif /* SIMULATOR */
863 #ifdef PLUGIN_USE_IRAM
864 /* Declare IRAM variables */
865 #define PLUGIN_IRAM_DECLARE \
866 extern char iramcopy[]; \
867 extern char iramstart[]; \
868 extern char iramend[]; \
869 extern char iedata[]; \
870 extern char iend[];
871 /* Initialize IRAM */
872 #define PLUGIN_IRAM_INIT(api) \
873 (api)->plugin_iram_init(iramstart, iramcopy, iramend-iramstart, \
874 iedata, iend-iedata);
875 #else
876 #define PLUGIN_IRAM_DECLARE
877 #define PLUGIN_IRAM_INIT(api)
878 #endif /* PLUGIN_USE_IRAM */
879 #endif /* PLUGIN */
881 int plugin_load(const char* plugin, const void* parameter);
882 void* plugin_get_audio_buffer(size_t *buffer_size);
883 #ifdef PLUGIN_USE_IRAM
884 void plugin_iram_init(char *iramstart, char *iramcopy, size_t iram_size,
885 char *iedata, size_t iedata_size);
886 #endif
888 /* plugin_tsr,
889 callback returns true to allow the new plugin to load,
890 reenter means the currently running plugin is being reloaded */
891 void plugin_tsr(bool (*exit_callback)(bool reenter));
893 /* defined by the plugin */
894 extern const struct plugin_api *rb;
895 enum plugin_status plugin_start(const void* parameter)
896 NO_PROF_ATTR;
898 #endif /* __PCTOOL__ */
899 #endif