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