1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
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 ****************************************************************************/
24 /* instruct simulator code to not redefine any symbols when compiling plugins.
25 (the PLUGIN macro is defined in apps/plugins/Makefile) */
27 #define NO_REDEFINES_PLEASE
36 #include <sys/types.h>
41 #include "string-extra.h"
42 #include "gcc_extensions.h"
44 char* strncpy(char *, const char *, size_t);
45 void* plugin_get_buffer(size_t *buffer_size
);
63 #include "mp3_playback.h"
69 #if (CONFIG_CODEC == SWCODEC)
73 #include "codec_thread.h"
75 #include "recording.h"
79 #endif /* CONFIG_CODEC == SWCODEC */
83 #ifdef HAVE_LCD_BITMAP
84 #include "screendump.h"
85 #include "scrollbar.h"
86 #include "jpeg_load.h"
87 #include "../recorder/bmp.h"
88 #include "statusbar-skinned.h"
90 #include "statusbar.h"
92 #include "rbunicode.h"
95 #include "color_picker.h"
96 #include "buffering.h"
99 #include "ata_idle_notify.h"
100 #include "settings_list.h"
101 #include "timefuncs.h"
105 #include "albumart.h"
108 #ifdef HAVE_REMOTE_LCD
109 #include "lcd-remote.h"
114 #ifdef USB_ENABLE_HID
115 #include "usbstack/usb_hid_usage_tables.h"
119 /* on some platforms strcmp() seems to be a tricky define which
120 * breaks if we write down strcmp's prototype */
125 #if defined(DEBUG) || defined(SIMULATOR)
127 #define DEBUGF rb->debugf
129 #define LDEBUGF rb->debugf
132 #define DEBUGF(...) do { } while(0)
134 #define LDEBUGF(...) do { } while(0)
137 #ifdef ROCKBOX_HAS_LOGF
139 #define LOGF rb->logf
146 #define PLUGIN_MAGIC 0x526F634B /* RocK */
148 /* increase this every time the api struct changes */
149 #define PLUGIN_API_VERSION 190
151 /* update this to latest version if a change to the api struct breaks
152 backwards compatibility (and please take the opportunity to sort in any
153 new function which are "waiting" at the end of the function table) */
154 #define PLUGIN_MIN_API_VERSION 190
156 /* plugin return codes */
159 PLUGIN_USB_CONNECTED
,
164 /* NOTE: To support backwards compatibility, only add new functions at
165 the end of the structure. Every time you add a new function,
166 remember to increase PLUGIN_API_VERSION. If you make changes to the
167 existing APIs then also update PLUGIN_MIN_API_VERSION to current
174 #ifdef HAVE_LCD_CONTRAST
175 void (*lcd_set_contrast
)(int x
);
177 void (*lcd_update
)(void);
178 void (*lcd_clear_display
)(void);
179 int (*lcd_getstringsize
)(const unsigned char *str
, int *w
, int *h
);
180 void (*lcd_putsxy
)(int x
, int y
, const unsigned char *string
);
181 void (*lcd_puts
)(int x
, int y
, const unsigned char *string
);
182 void (*lcd_puts_scroll
)(int x
, int y
, const unsigned char* string
);
183 void (*lcd_stop_scroll
)(void);
184 #ifdef HAVE_LCD_CHARCELLS
185 void (*lcd_define_pattern
)(unsigned long ucs
, const char *pattern
);
186 unsigned long (*lcd_get_locked_pattern
)(void);
187 void (*lcd_unlock_pattern
)(unsigned long ucs
);
188 void (*lcd_putc
)(int x
, int y
, unsigned long ucs
);
189 void (*lcd_put_cursor
)(int x
, int y
, unsigned long ucs
);
190 void (*lcd_remove_cursor
)(void);
191 void (*lcd_icon
)(int icon
, bool enable
);
192 void (*lcd_double_height
)(bool on
);
193 #else /* HAVE_LCD_BITMAP */
194 fb_data
* lcd_framebuffer
;
195 void (*lcd_update_rect
)(int x
, int y
, int width
, int height
);
196 void (*lcd_set_drawmode
)(int mode
);
197 int (*lcd_get_drawmode
)(void);
198 void (*lcd_setfont
)(int font
);
199 void (*lcd_drawpixel
)(int x
, int y
);
200 void (*lcd_drawline
)(int x1
, int y1
, int x2
, int y2
);
201 void (*lcd_hline
)(int x1
, int x2
, int y
);
202 void (*lcd_vline
)(int x
, int y1
, int y2
);
203 void (*lcd_drawrect
)(int x
, int y
, int width
, int height
);
204 void (*lcd_fillrect
)(int x
, int y
, int width
, int height
);
205 void (*lcd_mono_bitmap_part
)(const unsigned char *src
, int src_x
, int src_y
,
206 int stride
, int x
, int y
, int width
, int height
);
207 void (*lcd_mono_bitmap
)(const unsigned char *src
, int x
, int y
,
208 int width
, int height
);
210 void (*lcd_set_foreground
)(unsigned foreground
);
211 unsigned (*lcd_get_foreground
)(void);
212 void (*lcd_set_background
)(unsigned foreground
);
213 unsigned (*lcd_get_background
)(void);
214 void (*lcd_bitmap_part
)(const fb_data
*src
, int src_x
, int src_y
,
215 int stride
, int x
, int y
, int width
, int height
);
216 void (*lcd_bitmap
)(const fb_data
*src
, int x
, int y
, int width
,
218 fb_data
* (*lcd_get_backdrop
)(void);
219 void (*lcd_set_backdrop
)(fb_data
* backdrop
);
222 void (*lcd_bitmap_transparent_part
)(const fb_data
*src
,
223 int src_x
, int src_y
, int stride
,
224 int x
, int y
, int width
, int height
);
225 void (*lcd_bitmap_transparent
)(const fb_data
*src
, int x
, int y
,
226 int width
, int height
);
228 void (*lcd_blit_yuv
)(unsigned char * const src
[3],
229 int src_x
, int src_y
, int stride
,
230 int x
, int y
, int width
, int height
);
231 #if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) || defined(SANSA_C200) \
232 || defined(IRIVER_H10) || defined(COWON_D2) || defined(PHILIPS_HDD1630) \
233 || defined(SANSA_FUZE) || defined(SANSA_E200V2) || defined(SANSA_FUZEV2) \
234 || defined(TOSHIBA_GIGABEAT_S)
235 void (*lcd_yuv_set_options
)(unsigned options
);
237 #endif /* MEMORYSIZE > 2 */
238 #elif (LCD_DEPTH < 4) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
239 void (*lcd_blit_mono
)(const unsigned char *data
, int x
, int by
, int width
,
240 int bheight
, int stride
);
241 void (*lcd_blit_grey_phase
)(unsigned char *values
, unsigned char *phases
,
242 int bx
, int by
, int bwidth
, int bheight
,
244 #endif /* LCD_DEPTH */
245 #if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
246 void (*lcd_blit_pal256
)(unsigned char *src
, int src_x
, int src_y
, int x
, int y
,
247 int width
, int height
);
248 void (*lcd_pal256_update_pal
)(fb_data
*palette
);
250 void (*lcd_puts_style
)(int x
, int y
, const unsigned char *str
, int style
);
251 void (*lcd_puts_scroll_style
)(int x
, int y
, const unsigned char* string
,
253 #ifdef HAVE_LCD_INVERT
254 void (*lcd_set_invert_display
)(bool yesno
);
255 #endif /* HAVE_LCD_INVERT */
256 #if defined(HAVE_LCD_MODES)
257 void (*lcd_set_mode
)(int mode
);
260 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
261 struct event_queue
*button_queue
;
263 unsigned short *(*bidi_l2v
)( const unsigned char *str
, int orientation
);
264 #ifdef HAVE_LCD_BITMAP
265 bool (*is_diacritic
)(const unsigned short char_code
, bool *is_rtl
);
267 const unsigned char *(*font_get_bits
)( struct font
*pf
, unsigned short char_code
);
268 int (*font_load
)(struct font
*, const char *path
);
269 struct font
* (*font_get
)(int font
);
270 int (*font_getstringsize
)(const unsigned char *str
, int *w
, int *h
,
272 int (*font_get_width
)(struct font
* pf
, unsigned short char_code
);
273 void (*screen_clear_area
)(struct screen
* display
, int xstart
, int ystart
,
274 int width
, int height
);
275 void (*gui_scrollbar_draw
)(struct screen
* screen
, int x
, int y
,
276 int width
, int height
, int items
,
277 int min_shown
, int max_shown
,
279 #endif /* HAVE_LCD_BITMAP */
280 const char* (*get_codepage_name
)(int cp
);
283 /* The backlight_* functions must be present in the API regardless whether
284 * HAVE_BACKLIGHT is defined or not. The reason is that the stock Ondio has
285 * no backlight but can be modded to have backlight (it's prepared on the
286 * PCB). This makes backlight an all-target feature API wise, and keeps API
287 * compatible between stock and modded Ondio.
288 * For OLED targets like the Sansa Clip, the backlight_* functions control
289 * the display enable, which has essentially the same effect. */
290 void (*backlight_on
)(void);
291 void (*backlight_off
)(void);
292 void (*backlight_set_timeout
)(int index
);
293 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
294 void (*backlight_set_brightness
)(int val
);
295 #endif /* HAVE_BACKLIGHT_BRIGHTNESS */
298 void (*backlight_set_timeout_plugged
)(int index
);
300 bool (*is_backlight_on
)(bool ignore_always_off
);
301 void (*splash
)(int ticks
, const char *str
);
302 void (*splashf
)(int ticks
, const char *fmt
, ...) ATTRIBUTE_PRINTF(2, 3);
304 #ifdef HAVE_REMOTE_LCD
306 void (*lcd_remote_set_contrast
)(int x
);
307 void (*lcd_remote_clear_display
)(void);
308 void (*lcd_remote_puts
)(int x
, int y
, const unsigned char *string
);
309 void (*lcd_remote_puts_scroll
)(int x
, int y
, const unsigned char* string
);
310 void (*lcd_remote_stop_scroll
)(void);
311 void (*lcd_remote_set_drawmode
)(int mode
);
312 int (*lcd_remote_get_drawmode
)(void);
313 void (*lcd_remote_setfont
)(int font
);
314 int (*lcd_remote_getstringsize
)(const unsigned char *str
, int *w
, int *h
);
315 void (*lcd_remote_drawpixel
)(int x
, int y
);
316 void (*lcd_remote_drawline
)(int x1
, int y1
, int x2
, int y2
);
317 void (*lcd_remote_hline
)(int x1
, int x2
, int y
);
318 void (*lcd_remote_vline
)(int x
, int y1
, int y2
);
319 void (*lcd_remote_drawrect
)(int x
, int y
, int nx
, int ny
);
320 void (*lcd_remote_fillrect
)(int x
, int y
, int nx
, int ny
);
321 void (*lcd_remote_mono_bitmap_part
)(const unsigned char *src
, int src_x
,
322 int src_y
, int stride
, int x
, int y
,
323 int width
, int height
);
324 void (*lcd_remote_mono_bitmap
)(const unsigned char *src
, int x
, int y
,
325 int width
, int height
);
326 void (*lcd_remote_putsxy
)(int x
, int y
, const unsigned char *string
);
327 void (*lcd_remote_puts_style
)(int x
, int y
, const unsigned char *str
, int style
);
328 void (*lcd_remote_puts_scroll_style
)(int x
, int y
, const unsigned char* string
,
330 fb_remote_data
* lcd_remote_framebuffer
;
331 void (*lcd_remote_update
)(void);
332 void (*lcd_remote_update_rect
)(int x
, int y
, int width
, int height
);
334 void (*remote_backlight_on
)(void);
335 void (*remote_backlight_off
)(void);
336 void (*remote_backlight_set_timeout
)(int index
);
338 void (*remote_backlight_set_timeout_plugged
)(int index
);
340 #endif /* HAVE_REMOTE_LCD */
341 struct screen
* screens
[NB_SCREENS
];
342 #if defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)
343 void (*lcd_remote_set_foreground
)(unsigned foreground
);
344 unsigned (*lcd_remote_get_foreground
)(void);
345 void (*lcd_remote_set_background
)(unsigned background
);
346 unsigned (*lcd_remote_get_background
)(void);
347 void (*lcd_remote_bitmap_part
)(const fb_remote_data
*src
,
348 int src_x
, int src_y
, int stride
,
349 int x
, int y
, int width
, int height
);
350 void (*lcd_remote_bitmap
)(const fb_remote_data
*src
, int x
, int y
,
351 int width
, int height
);
353 void (*viewport_set_defaults
)(struct viewport
*vp
,
354 const enum screen_type screen
);
355 #ifdef HAVE_LCD_BITMAP
356 void (*viewportmanager_theme_enable
)(enum screen_type screen
, bool enable
,
357 struct viewport
*viewport
);
358 void (*viewportmanager_theme_undo
)(enum screen_type screen
, bool force_redraw
);
361 void (*gui_synclist_init
)(struct gui_synclist
* lists
,
362 list_get_name callback_get_item_name
, void * data
,
363 bool scroll_all
,int selected_size
,
364 struct viewport parent
[NB_SCREENS
]);
365 void (*gui_synclist_set_nb_items
)(struct gui_synclist
* lists
, int nb_items
);
366 void (*gui_synclist_set_icon_callback
)(struct gui_synclist
* lists
,
367 list_get_icon icon_callback
);
368 int (*gui_synclist_get_nb_items
)(struct gui_synclist
* lists
);
369 int (*gui_synclist_get_sel_pos
)(struct gui_synclist
* lists
);
370 void (*gui_synclist_draw
)(struct gui_synclist
* lists
);
371 void (*gui_synclist_select_item
)(struct gui_synclist
* lists
,
373 void (*gui_synclist_add_item
)(struct gui_synclist
* lists
);
374 void (*gui_synclist_del_item
)(struct gui_synclist
* lists
);
375 void (*gui_synclist_limit_scroll
)(struct gui_synclist
* lists
, bool scroll
);
376 bool (*gui_synclist_do_button
)(struct gui_synclist
* lists
,
377 int *action
, enum list_wrap wrap
);
378 void (*gui_synclist_set_title
)(struct gui_synclist
*lists
, char* title
,
379 enum themable_icons icon
);
380 enum yesno_res (*gui_syncyesno_run
)(const struct text_message
* main_message
,
381 const struct text_message
* yes_message
,
382 const struct text_message
* no_message
);
383 void (*simplelist_info_init
)(struct simplelist_info
*info
, char* title
,
384 int count
, void* data
);
385 bool (*simplelist_show_list
)(struct simplelist_info
*info
);
388 long (*button_get
)(bool block
);
389 long (*button_get_w_tmo
)(int ticks
);
390 int (*button_status
)(void);
391 #ifdef HAVE_BUTTON_DATA
392 intptr_t (*button_get_data
)(void);
393 int (*button_status_wdata
)(int *pdata
);
395 void (*button_clear_queue
)(void);
396 int (*button_queue_count
)(void);
397 #ifdef HAS_BUTTON_HOLD
398 bool (*button_hold
)(void);
400 #ifdef HAVE_TOUCHSCREEN
401 void (*touchscreen_set_mode
)(enum touchscreen_mode
);
403 #ifdef HAVE_BUTTON_LIGHT
404 void (*buttonlight_set_timeout
)(int value
);
405 void (*buttonlight_off
)(void);
406 void (*buttonlight_on
)(void);
407 #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
408 void (*buttonlight_set_brightness
)(int val
);
409 #endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
410 #endif /* HAVE_BUTTON_LIGHT */
413 int (*open_utf8
)(const char* pathname
, int flags
);
414 int (*open
)(const char* pathname
, int flags
, ...);
415 int (*close
)(int fd
);
416 ssize_t (*read
)(int fd
, void* buf
, size_t count
);
417 off_t (*lseek
)(int fd
, off_t offset
, int whence
);
418 int (*creat
)(const char *pathname
, mode_t mode
);
419 ssize_t (*write
)(int fd
, const void* buf
, size_t count
);
420 int (*remove
)(const char* pathname
);
421 int (*rename
)(const char* path
, const char* newname
);
422 int (*ftruncate
)(int fd
, off_t length
);
423 off_t (*filesize
)(int fd
);
424 int (*fdprintf
)(int fd
, const char *fmt
, ...) ATTRIBUTE_PRINTF(2, 3);
425 int (*read_line
)(int fd
, char* buffer
, int buffer_size
);
426 bool (*settings_parseline
)(char* line
, char** name
, char** value
);
427 void (*storage_sleep
)(void);
428 void (*storage_spin
)(void);
429 void (*storage_spindown
)(int seconds
);
430 #if USING_STORAGE_CALLBACK
431 void (*register_storage_idle_func
)(void (*function
)(void *data
));
432 void (*unregister_storage_idle_func
)(void (*function
)(void *data
), bool run
);
433 #endif /* USING_STORAGE_CALLBACK */
434 void (*reload_directory
)(void);
435 char *(*create_numbered_filename
)(char *buffer
, const char *path
,
436 const char *prefix
, const char *suffix
,
437 int numberlen
IF_CNFN_NUM_(, int *num
));
438 bool (*file_exists
)(const char *file
);
439 char* (*strip_extension
)(char* buffer
, int buffer_size
, const char *filename
);
440 unsigned (*crc_32
)(const void *src
, unsigned len
, unsigned crc32
);
444 DIR* (*opendir
)(const char* name
);
445 int (*closedir
)(DIR* dir
);
446 struct dirent
* (*readdir
)(DIR* dir
);
447 int (*mkdir
)(const char *name
);
448 int (*rmdir
)(const char *name
);
449 bool (*dir_exists
)(const char *path
);
453 void (*__div0
)(void);
455 void (*sleep
)(int ticks
);
457 volatile long* current_tick
;
458 long (*default_event_handler
)(long event
);
459 long (*default_event_handler_ex
)(long event
,
460 void (*callback
)(void *), void *parameter
);
461 unsigned int (*create_thread
)(void (*function
)(void), void* stack
,
462 size_t stack_size
, unsigned flags
,
464 IF_PRIO(, int priority
)
465 IF_COP(, unsigned int core
));
466 void (*thread_exit
)(void);
467 void (*thread_wait
)(unsigned int thread_id
);
468 #if CONFIG_CODEC == SWCODEC
469 void (*thread_thaw
)(unsigned int thread_id
);
470 #ifdef HAVE_PRIORITY_SCHEDULING
471 int (*thread_set_priority
)(unsigned int thread_id
, int priority
);
473 void (*mutex_init
)(struct mutex
*m
);
474 void (*mutex_lock
)(struct mutex
*m
);
475 void (*mutex_unlock
)(struct mutex
*m
);
478 void (*reset_poweroff_timer
)(void);
479 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
480 int (*system_memory_guard
)(int newmode
);
482 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
483 #ifdef CPU_BOOST_LOGGING
484 void (*cpu_boost_
)(bool on_off
,char*location
,int line
);
486 void (*cpu_boost
)(bool on_off
);
488 #endif /* HAVE_ADJUSTABLE_CPU_FREQ */
489 #endif /* PLATFORM_NATIVE */
490 #ifdef HAVE_SCHEDULER_BOOSTCTRL
491 void (*trigger_cpu_boost
)(void);
492 void (*cancel_cpu_boost
)(void);
495 void (*cpucache_flush
)(void);
496 void (*cpucache_invalidate
)(void);
498 bool (*timer_register
)(int reg_prio
, void (*unregister_callback
)(void),
499 long cycles
, void (*timer_callback
)(void)
501 void (*timer_unregister
)(void);
502 bool (*timer_set_period
)(long count
);
504 void (*queue_init
)(struct event_queue
*q
, bool register_queue
);
505 void (*queue_delete
)(struct event_queue
*q
);
506 void (*queue_post
)(struct event_queue
*q
, long id
, intptr_t data
);
507 void (*queue_wait_w_tmo
)(struct event_queue
*q
, struct queue_event
*ev
,
509 #if CONFIG_CODEC == SWCODEC
510 void (*queue_enable_queue_send
)(struct event_queue
*q
,
511 struct queue_sender_list
*send
,
512 unsigned int thread_id
);
513 bool (*queue_empty
)(const struct event_queue
*q
);
514 void (*queue_wait
)(struct event_queue
*q
, struct queue_event
*ev
);
515 intptr_t (*queue_send
)(struct event_queue
*q
, long id
,
517 void (*queue_reply
)(struct event_queue
*q
, intptr_t retval
);
518 #endif /* CONFIG_CODEC == SWCODEC */
520 void (*usb_acknowledge
)(long id
);
521 #ifdef USB_ENABLE_HID
522 void (*usb_hid_send
)(usage_page_t usage_page
, int id
);
525 void (*profile_thread
)(void);
526 void (*profstop
)(void);
527 void (*profile_func_enter
)(void *this_fn
, void *call_site
);
528 void (*profile_func_exit
)(void *this_fn
, void *call_site
);
531 bool (*add_event
)(unsigned short id
, bool oneshot
, void (*handler
)(void *data
));
532 void (*remove_event
)(unsigned short id
, void (*handler
)(void *data
));
533 void (*send_event
)(unsigned short id
, void *data
);
535 #if (CONFIG_PLATFORM & PLATFORM_HOSTED)
536 /* special simulator hooks */
537 #if defined(HAVE_LCD_BITMAP) && LCD_DEPTH < 8
538 void (*sim_lcd_ex_init
)(unsigned long (*getpixel
)(int, int));
539 void (*sim_lcd_ex_update_rect
)(int x
, int y
, int width
, int height
);
543 /* strings and memory */
544 int (*snprintf
)(char *buf
, size_t size
, const char *fmt
, ...)
545 ATTRIBUTE_PRINTF(3, 4);
546 int (*vsnprintf
)(char *buf
, size_t size
, const char *fmt
, va_list ap
);
547 char* (*strcpy
)(char *dst
, const char *src
);
548 size_t (*strlcpy
)(char *dst
, const char *src
, size_t length
);
549 size_t (*strlen
)(const char *str
);
550 char * (*strrchr
)(const char *s
, int c
);
551 int (*strcmp
)(const char *, const char *);
552 int (*strncmp
)(const char *, const char *, size_t);
553 int (*strcasecmp
)(const char *, const char *);
554 int (*strncasecmp
)(const char *s1
, const char *s2
, size_t n
);
555 void* (*memset
)(void *dst
, int c
, size_t length
);
556 void* (*memcpy
)(void *out
, const void *in
, size_t n
);
557 void* (*memmove
)(void *out
, const void *in
, size_t n
);
558 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
559 const unsigned char *_rbctype_
;
561 int (*atoi
)(const char *str
);
562 char *(*strchr
)(const char *s
, int c
);
563 char *(*strcat
)(char *s1
, const char *s2
);
564 size_t (*strlcat
)(char *dst
, const char *src
, size_t length
);
565 void *(*memchr
)(const void *s1
, int c
, size_t n
);
566 int (*memcmp
)(const void *s1
, const void *s2
, size_t n
);
567 char *(*strcasestr
) (const char* phaystack
, const char* pneedle
);
568 char* (*strtok_r
)(char *ptr
, const char *sep
, char **end
);
570 const unsigned char* (*utf8decode
)(const unsigned char *utf8
, unsigned short *ucs
);
571 unsigned char* (*iso_decode
)(const unsigned char *iso
, unsigned char *utf8
, int cp
, int count
);
572 unsigned char* (*utf16LEdecode
)(const unsigned char *utf16
, unsigned char *utf8
, int count
);
573 unsigned char* (*utf16BEdecode
)(const unsigned char *utf16
, unsigned char *utf8
, int count
);
574 unsigned char* (*utf8encode
)(unsigned long ucs
, unsigned char *utf8
);
575 unsigned long (*utf8length
)(const unsigned char *utf8
);
576 int (*utf8seek
)(const unsigned char* utf8
, int offset
);
579 void (*sound_set
)(int setting
, int value
);
580 int (*sound_default
)(int setting
);
581 int (*sound_min
)(int setting
);
582 int (*sound_max
)(int setting
);
583 const char * (*sound_unit
)(int setting
);
584 int (*sound_val2phys
)(int setting
, int value
);
585 #ifdef AUDIOHW_HAVE_EQ
586 int (*sound_enum_hw_eq_band_setting
)(unsigned int band
,
587 unsigned int band_setting
);
588 #endif /* AUDIOHW_HAVE_EQ */
589 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
590 void (*mp3_play_data
)(const unsigned char* start
, int size
,
591 void (*get_more
)(unsigned char** start
, size_t* size
));
592 void (*mp3_play_pause
)(bool play
);
593 void (*mp3_play_stop
)(void);
594 bool (*mp3_is_playing
)(void);
595 #if CONFIG_CODEC != SWCODEC
596 void (*bitswap
)(unsigned char *data
, int length
);
598 #endif /* PLATFORM_NATIVE */
599 #if CONFIG_CODEC == SWCODEC
600 const unsigned long *audio_master_sampr_list
;
601 const unsigned long *hw_freq_sampr
;
602 void (*pcm_apply_settings
)(void);
603 void (*pcm_play_data
)(pcm_play_callback_type get_more
,
604 unsigned char* start
, size_t size
);
605 void (*pcm_play_stop
)(void);
606 void (*pcm_set_frequency
)(unsigned int frequency
);
607 bool (*pcm_is_playing
)(void);
608 bool (*pcm_is_paused
)(void);
609 void (*pcm_play_pause
)(bool play
);
610 size_t (*pcm_get_bytes_waiting
)(void);
611 void (*pcm_calculate_peaks
)(int *left
, int *right
);
612 const void* (*pcm_get_peak_buffer
)(int *count
);
613 void (*pcm_play_lock
)(void);
614 void (*pcm_play_unlock
)(void);
615 void (*pcmbuf_beep
)(unsigned int frequency
,
618 #ifdef HAVE_RECORDING
619 const unsigned long *rec_freq_sampr
;
620 void (*pcm_init_recording
)(void);
621 void (*pcm_close_recording
)(void);
622 void (*pcm_record_data
)(pcm_rec_callback_type more_ready
,
623 void *start
, size_t size
);
624 void (*pcm_stop_recording
)(void);
625 void (*pcm_calculate_rec_peaks
)(int *left
, int *right
);
626 void (*audio_set_recording_gain
)(int left
, int right
, int type
);
627 #endif /* HAVE_RECORDING */
628 #if INPUT_SRC_CAPS != 0
629 void (*audio_set_output_source
)(int monitor
);
630 void (*audio_set_input_source
)(int source
, unsigned flags
);
632 void (*dsp_set_crossfeed
)(bool enable
);
633 void (*dsp_set_eq
)(bool enable
);
634 void (*dsp_dither_enable
)(bool enable
);
635 intptr_t (*dsp_configure
)(struct dsp_config
*dsp
, int setting
,
637 int (*dsp_process
)(struct dsp_config
*dsp
, char *dest
,
638 const char *src
[], int count
);
639 int (*dsp_input_count
)(struct dsp_config
*dsp
, int count
);
640 int (*dsp_output_count
)(struct dsp_config
*dsp
, int count
);
641 #endif /* CONFIG_CODEC == SWCODC */
643 /* playback control */
644 int (*playlist_amount
)(void);
645 int (*playlist_resume
)(void);
646 void (*playlist_start
)(int start_index
, int offset
);
647 int (*playlist_add
)(const char *filename
);
648 void (*playlist_sync
)(struct playlist_info
* playlist
);
649 int (*playlist_remove_all_tracks
)(struct playlist_info
*playlist
);
650 int (*playlist_create
)(const char *dir
, const char *file
);
651 int (*playlist_insert_track
)(struct playlist_info
* playlist
,
652 const char *filename
, int position
, bool queue
, bool sync
);
653 int (*playlist_insert_directory
)(struct playlist_info
* playlist
,
654 const char *dirname
, int position
, bool queue
,
656 int (*playlist_shuffle
)(int random_seed
, int start_index
);
657 void (*audio_play
)(long offset
);
658 void (*audio_stop
)(void);
659 void (*audio_pause
)(void);
660 void (*audio_resume
)(void);
661 void (*audio_next
)(void);
662 void (*audio_prev
)(void);
663 void (*audio_ff_rewind
)(long newtime
);
664 struct mp3entry
* (*audio_next_track
)(void);
665 int (*audio_status
)(void);
666 struct mp3entry
* (*audio_current_track
)(void);
667 void (*audio_flush_and_reload_tracks
)(void);
668 int (*audio_get_file_pos
)(void);
669 #if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
670 unsigned long (*mpeg_get_last_header
)(void);
672 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) || \
673 (CONFIG_CODEC == SWCODEC)
674 void (*sound_set_pitch
)(int32_t pitch
);
677 /* MAS communication */
678 #if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
679 int (*mas_readmem
)(int bank
, int addr
, unsigned long* dest
, int len
);
680 int (*mas_writemem
)(int bank
, int addr
, const unsigned long* src
, int len
);
681 int (*mas_readreg
)(int reg
);
682 int (*mas_writereg
)(int reg
, unsigned int val
);
683 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
684 int (*mas_codec_writereg
)(int reg
, unsigned int val
);
685 int (*mas_codec_readreg
)(int reg
);
686 void (*i2c_begin
)(void);
687 void (*i2c_end
)(void);
688 int (*i2c_write
)(int address
, const unsigned char* buf
, int count
);
693 int (*do_menu
)(const struct menu_item_ex
*menu
, int *start_selected
,
694 struct viewport parent
[NB_SCREENS
], bool hide_theme
);
697 struct gui_syncstatusbar
*statusbars
;
698 void (*gui_syncstatusbar_draw
)(struct gui_syncstatusbar
* bars
, bool force_redraw
);
701 const struct settings_list
* (*get_settings_list
)(int*count
);
702 const struct settings_list
* (*find_setting
)(const void* variable
, int *id
);
703 bool (*option_screen
)(const struct settings_list
*setting
,
704 struct viewport parent
[NB_SCREENS
],
705 bool use_temp_var
, unsigned char* option_title
);
706 bool (*set_option
)(const char* string
, const void* variable
,
707 enum optiontype type
, const struct opt_items
* options
,
708 int numoptions
, void (*function
)(int));
709 bool (*set_bool_options
)(const char* string
, const bool* variable
,
710 const char* yes_str
, int yes_voice
,
711 const char* no_str
, int no_voice
,
712 void (*function
)(bool));
713 bool (*set_int
)(const unsigned char* string
, const char* unit
, int voice_unit
,
714 const int* variable
, void (*function
)(int), int step
,
716 const char* (*formatter
)(char*, size_t, int, const char*) );
717 bool (*set_bool
)(const char* string
, const bool* variable
);
719 #ifdef HAVE_LCD_COLOR
720 bool (*set_color
)(struct screen
*display
, char *title
,
721 unsigned *color
, unsigned banned_color
);
723 /* action handling */
724 int (*get_custom_action
)(int context
,int timeout
,
725 const struct button_mapping
* (*get_context_map
)(int));
726 int (*get_action
)(int context
, int timeout
);
727 #ifdef HAVE_TOUCHSCREEN
728 int (*action_get_touchscreen_press
)(short *x
, short *y
);
730 bool (*action_userabort
)(int timeout
);
733 int (*battery_level
)(void);
734 bool (*battery_level_safe
)(void);
735 int (*battery_time
)(void);
736 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
737 unsigned int (*battery_voltage
)(void);
740 bool (*charger_inserted
)(void);
741 # if CONFIG_CHARGING >= CHARGING_MONITOR
742 bool (*charging_state
)(void);
745 #ifdef HAVE_USB_POWER
746 bool (*usb_powered
)(void);
750 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
753 void (*srand
)(unsigned int seed
);
755 void (*qsort
)(void *base
, size_t nmemb
, size_t size
,
756 int(*compar
)(const void *, const void *));
757 int (*kbd_input
)(char* buffer
, int buflen
);
758 struct tm
* (*get_time
)(void);
759 int (*set_time
)(const struct tm
*tm
);
761 time_t (*mktime
)(struct tm
*t
);
763 void* (*plugin_get_buffer
)(size_t *buffer_size
);
764 void* (*plugin_get_audio_buffer
)(size_t *buffer_size
);
765 void (*plugin_tsr
)(bool (*exit_callback
)(bool reenter
));
766 char* (*plugin_get_current_filename
)(void);
767 #ifdef PLUGIN_USE_IRAM
768 void (*plugin_iram_init
)(char *iramstart
, char *iramcopy
, size_t iram_size
,
769 char *iedata
, size_t iedata_size
);
771 #if defined(DEBUG) || defined(SIMULATOR)
772 void (*debugf
)(const char *fmt
, ...) ATTRIBUTE_PRINTF(1, 2);
774 #ifdef ROCKBOX_HAS_LOGF
775 void (*logf
)(const char *fmt
, ...) ATTRIBUTE_PRINTF(1, 2);
777 struct user_settings
* global_settings
;
778 struct system_status
*global_status
;
779 void (*talk_disable
)(bool disable
);
780 #if CONFIG_CODEC == SWCODEC
781 void (*codec_thread_do_callback
)(void (*fn
)(void),
782 unsigned int *audio_thread_id
);
783 int (*codec_load_file
)(const char* codec
, struct codec_api
*api
);
784 const char *(*get_codec_filename
)(int cod_spec
);
785 void ** (*find_array_ptr
)(void **arr
, void *ptr
);
786 int (*remove_array_ptr
)(void **arr
, void *ptr
);
787 int (*round_value_to_list32
)(unsigned long value
,
788 const unsigned long list
[],
791 #endif /* CONFIG_CODEC == SWCODEC */
792 bool (*get_metadata
)(struct mp3entry
* id3
, int fd
, const char* trackname
);
793 bool (*mp3info
)(struct mp3entry
*entry
, const char *filename
);
794 int (*count_mp3_frames
)(int fd
, int startpos
, int filesize
,
795 void (*progressfunc
)(int));
796 int (*create_xing_header
)(int fd
, long startpos
, long filesize
,
797 unsigned char *buf
, unsigned long num_frames
,
798 unsigned long rec_time
, unsigned long header_template
,
799 void (*progressfunc
)(int), bool generate_toc
);
800 unsigned long (*find_next_frame
)(int fd
, long *offset
,
801 long max_offset
, unsigned long last_header
);
803 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
804 unsigned short (*peak_meter_scale_value
)(unsigned short val
,
806 void (*peak_meter_set_use_dbfs
)(bool use
);
807 bool (*peak_meter_get_use_dbfs
)(void);
809 #ifdef HAVE_LCD_BITMAP
810 int (*read_bmp_file
)(const char* filename
, struct bitmap
*bm
, int maxsize
,
811 int format
, const struct custom_format
*cformat
);
812 int (*read_bmp_fd
)(int fd
, struct bitmap
*bm
, int maxsize
,
813 int format
, const struct custom_format
*cformat
);
815 int (*read_jpeg_file
)(const char* filename
, struct bitmap
*bm
, int maxsize
,
816 int format
, const struct custom_format
*cformat
);
817 int (*read_jpeg_fd
)(int fd
, struct bitmap
*bm
, int maxsize
,
818 int format
, const struct custom_format
*cformat
);
820 void (*screen_dump_set_hook
)(void (*hook
)(int fh
));
822 int (*show_logo
)(void);
823 struct tree_context
* (*tree_get_context
)(void);
824 void (*set_current_file
)(char* path
);
825 void (*set_dirfilter
)(int l_dirfilter
);
827 #ifdef HAVE_WHEEL_POSITION
828 int (*wheel_status
)(void);
829 void (*wheel_send_events
)(bool send
);
832 #ifdef IRIVER_H100_SERIES
833 /* Routines for the iriver_flash -plugin. */
834 bool (*detect_original_firmware
)(void);
835 bool (*detect_flashed_ramimage
)(void);
836 bool (*detect_flashed_romimage
)(void);
839 void (*led
)(bool on
);
841 #if (CONFIG_CODEC == SWCODEC)
843 int (*bufopen
)(const char *file
, size_t offset
, enum data_type type
,
845 int (*bufalloc
)(const void *src
, size_t size
, enum data_type type
);
846 bool (*bufclose
)(int handle_id
);
847 int (*bufseek
)(int handle_id
, size_t newpos
);
848 int (*bufadvance
)(int handle_id
, off_t offset
);
849 ssize_t (*bufread
)(int handle_id
, size_t size
, void *dest
);
850 ssize_t (*bufgetdata
)(int handle_id
, size_t size
, void **data
);
851 ssize_t (*bufgettail
)(int handle_id
, size_t size
, void **data
);
852 ssize_t (*bufcuttail
)(int handle_id
, size_t size
);
854 ssize_t (*buf_get_offset
)(int handle_id
, void *ptr
);
855 ssize_t (*buf_handle_offset
)(int handle_id
);
856 void (*buf_request_buffer_handle
)(int handle_id
);
857 void (*buf_set_base_handle
)(int handle_id
);
858 size_t (*buf_used
)(void);
862 bool (*tagcache_search
)(struct tagcache_search
*tcs
, int tag
);
863 void (*tagcache_search_set_uniqbuf
)(struct tagcache_search
*tcs
,
864 void *buffer
, long length
);
865 bool (*tagcache_search_add_filter
)(struct tagcache_search
*tcs
,
867 bool (*tagcache_get_next
)(struct tagcache_search
*tcs
);
868 bool (*tagcache_retrieve
)(struct tagcache_search
*tcs
, int idxid
,
869 int tag
, char *buf
, long size
);
870 void (*tagcache_search_finish
)(struct tagcache_search
*tcs
);
871 long (*tagcache_get_numeric
)(const struct tagcache_search
*tcs
, int tag
);
872 #ifdef HAVE_TC_RAMCACHE
873 bool (*tagcache_fill_tags
)(struct mp3entry
*id3
, const char *filename
);
878 bool (*search_albumart_files
)(const struct mp3entry
*id3
, const char *size_string
,
879 char *buf
, int buflen
);
882 #ifdef HAVE_SEMAPHORE_OBJECTS
883 void (*semaphore_init
)(struct semaphore
*s
, int max
, int start
);
884 void (*semaphore_wait
)(struct semaphore
*s
);
885 void (*semaphore_release
)(struct semaphore
*s
);
888 const char *rbversion
;
890 /* new stuff at the end, sort into place next time
891 the API gets incompatible */
895 struct plugin_header
{
897 unsigned short target_id
;
898 unsigned short api_version
;
899 unsigned char *load_addr
;
900 unsigned char *end_addr
;
901 enum plugin_status(*entry_point
)(const void*);
902 const struct plugin_api
**api
;
906 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
907 extern unsigned char plugin_start_addr
[];
908 extern unsigned char plugin_end_addr
[];
909 #define PLUGIN_HEADER \
910 const struct plugin_api *rb DATA_ATTR; \
911 const struct plugin_header __header \
912 __attribute__ ((section (".header")))= { \
913 PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \
914 plugin_start_addr, plugin_end_addr, plugin_start, &rb };
915 #else /* PLATFORM_HOSTED */
916 #define PLUGIN_HEADER \
917 const struct plugin_api *rb DATA_ATTR; \
918 const struct plugin_header __header \
919 __attribute__((visibility("default"))) = { \
920 PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \
921 NULL, NULL, plugin_start, &rb };
922 #endif /* CONFIG_PLATFORM */
924 #ifdef PLUGIN_USE_IRAM
925 /* Declare IRAM variables */
926 #define PLUGIN_IRAM_DECLARE \
927 extern char iramcopy[]; \
928 extern char iramstart[]; \
929 extern char iramend[]; \
930 extern char iedata[]; \
932 /* Initialize IRAM */
933 #define PLUGIN_IRAM_INIT(api) \
934 (api)->plugin_iram_init(iramstart, iramcopy, iramend-iramstart, \
935 iedata, iend-iedata);
937 #define PLUGIN_IRAM_DECLARE
938 #define PLUGIN_IRAM_INIT(api)
939 #endif /* PLUGIN_USE_IRAM */
942 int plugin_load(const char* plugin
, const void* parameter
);
943 void* plugin_get_audio_buffer(size_t *buffer_size
);
944 #ifdef PLUGIN_USE_IRAM
945 void plugin_iram_init(char *iramstart
, char *iramcopy
, size_t iram_size
,
946 char *iedata
, size_t iedata_size
);
950 callback returns true to allow the new plugin to load,
951 reenter means the currently running plugin is being reloaded */
952 void plugin_tsr(bool (*exit_callback
)(bool reenter
));
954 /* defined by the plugin */
955 extern const struct plugin_api
*rb
;
956 enum plugin_status
plugin_start(const void* parameter
)
959 #endif /* __PCTOOL__ */