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