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
);
56 #include "load_code.h"
64 #include "mp3_playback.h"
70 #include "filefuncs.h"
71 #if (CONFIG_CODEC == SWCODEC)
75 #include "codec_thread.h"
77 #include "recording.h"
81 #endif /* CONFIG_CODEC == SWCODEC */
85 #ifdef HAVE_LCD_BITMAP
86 #include "screendump.h"
87 #include "scrollbar.h"
88 #include "jpeg_load.h"
89 #include "../recorder/bmp.h"
91 #include "statusbar.h"
93 #include "rbunicode.h"
96 #include "color_picker.h"
97 #include "buffering.h"
100 #include "ata_idle_notify.h"
101 #include "settings_list.h"
102 #include "timefuncs.h"
106 #include "albumart.h"
109 #ifdef HAVE_REMOTE_LCD
110 #include "lcd-remote.h"
115 #include "filetypes.h"
117 #ifdef USB_ENABLE_HID
118 #include "usbstack/usb_hid_usage_tables.h"
122 /* on some platforms strcmp() seems to be a tricky define which
123 * breaks if we write down strcmp's prototype */
128 #if defined(DEBUG) || defined(SIMULATOR)
130 #define DEBUGF rb->debugf
132 #define LDEBUGF rb->debugf
135 #define DEBUGF(...) do { } while(0)
137 #define LDEBUGF(...) do { } while(0)
140 #ifdef ROCKBOX_HAS_LOGF
142 #define LOGF rb->logf
149 #define PLUGIN_MAGIC 0x526F634B /* RocK */
151 /* increase this every time the api struct changes */
152 #define PLUGIN_API_VERSION 198
154 /* update this to latest version if a change to the api struct breaks
155 backwards compatibility (and please take the opportunity to sort in any
156 new function which are "waiting" at the end of the function table) */
157 #define PLUGIN_MIN_API_VERSION 198
159 /* plugin return codes */
160 /* internal returns start at 0x100 to make exit(1..255) work */
161 #define INTERNAL_PLUGIN_RETVAL_START 0x100
163 PLUGIN_OK
= 0, /* PLUGIN_OK == EXIT_SUCCESS */
164 /* 1...255 reserved for exit() */
165 PLUGIN_USB_CONNECTED
= INTERNAL_PLUGIN_RETVAL_START
,
171 /* NOTE: To support backwards compatibility, only add new functions at
172 the end of the structure. Every time you add a new function,
173 remember to increase PLUGIN_API_VERSION. If you make changes to the
174 existing APIs then also update PLUGIN_MIN_API_VERSION to current
181 #ifdef HAVE_LCD_CONTRAST
182 void (*lcd_set_contrast
)(int x
);
184 void (*lcd_update
)(void);
185 void (*lcd_clear_display
)(void);
186 int (*lcd_getstringsize
)(const unsigned char *str
, int *w
, int *h
);
187 void (*lcd_putsxy
)(int x
, int y
, const unsigned char *string
);
188 void (*lcd_putsxyf
)(int x
, int y
, const unsigned char *fmt
, ...);
189 void (*lcd_puts
)(int x
, int y
, const unsigned char *string
);
190 void (*lcd_putsf
)(int x
, int y
, const unsigned char *fmt
, ...);
191 void (*lcd_puts_scroll
)(int x
, int y
, const unsigned char* string
);
192 void (*lcd_stop_scroll
)(void);
193 #ifdef HAVE_LCD_CHARCELLS
194 void (*lcd_define_pattern
)(unsigned long ucs
, const char *pattern
);
195 unsigned long (*lcd_get_locked_pattern
)(void);
196 void (*lcd_unlock_pattern
)(unsigned long ucs
);
197 void (*lcd_putc
)(int x
, int y
, unsigned long ucs
);
198 void (*lcd_put_cursor
)(int x
, int y
, unsigned long ucs
);
199 void (*lcd_remove_cursor
)(void);
200 void (*lcd_icon
)(int icon
, bool enable
);
201 void (*lcd_double_height
)(bool on
);
202 #else /* HAVE_LCD_BITMAP */
203 fb_data
* lcd_framebuffer
;
204 void (*lcd_update_rect
)(int x
, int y
, int width
, int height
);
205 void (*lcd_set_drawmode
)(int mode
);
206 int (*lcd_get_drawmode
)(void);
207 void (*lcd_setfont
)(int font
);
208 void (*lcd_drawpixel
)(int x
, int y
);
209 void (*lcd_drawline
)(int x1
, int y1
, int x2
, int y2
);
210 void (*lcd_hline
)(int x1
, int x2
, int y
);
211 void (*lcd_vline
)(int x
, int y1
, int y2
);
212 void (*lcd_drawrect
)(int x
, int y
, int width
, int height
);
213 void (*lcd_fillrect
)(int x
, int y
, int width
, int height
);
214 void (*lcd_mono_bitmap_part
)(const unsigned char *src
, int src_x
, int src_y
,
215 int stride
, int x
, int y
, int width
, int height
);
216 void (*lcd_mono_bitmap
)(const unsigned char *src
, int x
, int y
,
217 int width
, int height
);
219 void (*lcd_set_foreground
)(unsigned foreground
);
220 unsigned (*lcd_get_foreground
)(void);
221 void (*lcd_set_background
)(unsigned foreground
);
222 unsigned (*lcd_get_background
)(void);
223 void (*lcd_bitmap_part
)(const fb_data
*src
, int src_x
, int src_y
,
224 int stride
, int x
, int y
, int width
, int height
);
225 void (*lcd_bitmap
)(const fb_data
*src
, int x
, int y
, int width
,
227 fb_data
* (*lcd_get_backdrop
)(void);
228 void (*lcd_set_backdrop
)(fb_data
* backdrop
);
231 void (*lcd_bitmap_transparent_part
)(const fb_data
*src
,
232 int src_x
, int src_y
, int stride
,
233 int x
, int y
, int width
, int height
);
234 void (*lcd_bitmap_transparent
)(const fb_data
*src
, int x
, int y
,
235 int width
, int height
);
237 void (*lcd_blit_yuv
)(unsigned char * const src
[3],
238 int src_x
, int src_y
, int stride
,
239 int x
, int y
, int width
, int height
);
240 #if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) || defined(SANSA_C200) \
241 || defined(IRIVER_H10) || defined(COWON_D2) || defined(PHILIPS_HDD1630) \
242 || defined(SANSA_FUZE) || defined(SANSA_E200V2) || defined(SANSA_FUZEV2) \
243 || defined(TOSHIBA_GIGABEAT_S) || defined(PHILIPS_SA9200)
244 void (*lcd_yuv_set_options
)(unsigned options
);
246 #endif /* MEMORYSIZE > 2 */
247 #elif (LCD_DEPTH < 4) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
248 void (*lcd_blit_mono
)(const unsigned char *data
, int x
, int by
, int width
,
249 int bheight
, int stride
);
250 void (*lcd_blit_grey_phase
)(unsigned char *values
, unsigned char *phases
,
251 int bx
, int by
, int bwidth
, int bheight
,
253 #endif /* LCD_DEPTH */
254 #if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
255 void (*lcd_blit_pal256
)(unsigned char *src
, int src_x
, int src_y
, int x
, int y
,
256 int width
, int height
);
257 void (*lcd_pal256_update_pal
)(fb_data
*palette
);
259 void (*lcd_puts_style
)(int x
, int y
, const unsigned char *str
, int style
);
260 void (*lcd_puts_scroll_style
)(int x
, int y
, const unsigned char* string
,
262 #ifdef HAVE_LCD_INVERT
263 void (*lcd_set_invert_display
)(bool yesno
);
264 #endif /* HAVE_LCD_INVERT */
265 #if defined(HAVE_LCD_MODES)
266 void (*lcd_set_mode
)(int mode
);
269 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
270 struct event_queue
*button_queue
;
272 unsigned short *(*bidi_l2v
)( const unsigned char *str
, int orientation
);
273 #ifdef HAVE_LCD_BITMAP
274 bool (*is_diacritic
)(const unsigned short char_code
, bool *is_rtl
);
276 const unsigned char *(*font_get_bits
)( struct font
*pf
, unsigned short char_code
);
277 int (*font_load
)(struct font
*, const char *path
);
278 struct font
* (*font_get
)(int font
);
279 int (*font_getstringsize
)(const unsigned char *str
, int *w
, int *h
,
281 int (*font_get_width
)(struct font
* pf
, unsigned short char_code
);
282 void (*screen_clear_area
)(struct screen
* display
, int xstart
, int ystart
,
283 int width
, int height
);
284 void (*gui_scrollbar_draw
)(struct screen
* screen
, int x
, int y
,
285 int width
, int height
, int items
,
286 int min_shown
, int max_shown
,
288 #endif /* HAVE_LCD_BITMAP */
289 const char* (*get_codepage_name
)(int cp
);
292 /* The backlight_* functions must be present in the API regardless whether
293 * HAVE_BACKLIGHT is defined or not. The reason is that the stock Ondio has
294 * no backlight but can be modded to have backlight (it's prepared on the
295 * PCB). This makes backlight an all-target feature API wise, and keeps API
296 * compatible between stock and modded Ondio.
297 * For OLED targets like the Sansa Clip, the backlight_* functions control
298 * the display enable, which has essentially the same effect. */
299 void (*backlight_on
)(void);
300 void (*backlight_off
)(void);
301 void (*backlight_set_timeout
)(int index
);
302 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
303 void (*backlight_set_brightness
)(int val
);
304 #endif /* HAVE_BACKLIGHT_BRIGHTNESS */
307 void (*backlight_set_timeout_plugged
)(int index
);
309 bool (*is_backlight_on
)(bool ignore_always_off
);
310 void (*splash
)(int ticks
, const char *str
);
311 void (*splashf
)(int ticks
, const char *fmt
, ...) ATTRIBUTE_PRINTF(2, 3);
313 #ifdef HAVE_REMOTE_LCD
315 void (*lcd_remote_set_contrast
)(int x
);
316 void (*lcd_remote_clear_display
)(void);
317 void (*lcd_remote_puts
)(int x
, int y
, const unsigned char *string
);
318 void (*lcd_remote_puts_scroll
)(int x
, int y
, const unsigned char* string
);
319 void (*lcd_remote_stop_scroll
)(void);
320 void (*lcd_remote_set_drawmode
)(int mode
);
321 int (*lcd_remote_get_drawmode
)(void);
322 void (*lcd_remote_setfont
)(int font
);
323 int (*lcd_remote_getstringsize
)(const unsigned char *str
, int *w
, int *h
);
324 void (*lcd_remote_drawpixel
)(int x
, int y
);
325 void (*lcd_remote_drawline
)(int x1
, int y1
, int x2
, int y2
);
326 void (*lcd_remote_hline
)(int x1
, int x2
, int y
);
327 void (*lcd_remote_vline
)(int x
, int y1
, int y2
);
328 void (*lcd_remote_drawrect
)(int x
, int y
, int nx
, int ny
);
329 void (*lcd_remote_fillrect
)(int x
, int y
, int nx
, int ny
);
330 void (*lcd_remote_mono_bitmap_part
)(const unsigned char *src
, int src_x
,
331 int src_y
, int stride
, int x
, int y
,
332 int width
, int height
);
333 void (*lcd_remote_mono_bitmap
)(const unsigned char *src
, int x
, int y
,
334 int width
, int height
);
335 void (*lcd_remote_putsxy
)(int x
, int y
, const unsigned char *string
);
336 void (*lcd_remote_puts_style
)(int x
, int y
, const unsigned char *str
, int style
);
337 void (*lcd_remote_puts_scroll_style
)(int x
, int y
, const unsigned char* string
,
339 fb_remote_data
* lcd_remote_framebuffer
;
340 void (*lcd_remote_update
)(void);
341 void (*lcd_remote_update_rect
)(int x
, int y
, int width
, int height
);
343 void (*remote_backlight_on
)(void);
344 void (*remote_backlight_off
)(void);
345 void (*remote_backlight_set_timeout
)(int index
);
347 void (*remote_backlight_set_timeout_plugged
)(int index
);
349 #endif /* HAVE_REMOTE_LCD */
350 struct screen
* screens
[NB_SCREENS
];
351 #if defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)
352 void (*lcd_remote_set_foreground
)(unsigned foreground
);
353 unsigned (*lcd_remote_get_foreground
)(void);
354 void (*lcd_remote_set_background
)(unsigned background
);
355 unsigned (*lcd_remote_get_background
)(void);
356 void (*lcd_remote_bitmap_part
)(const fb_remote_data
*src
,
357 int src_x
, int src_y
, int stride
,
358 int x
, int y
, int width
, int height
);
359 void (*lcd_remote_bitmap
)(const fb_remote_data
*src
, int x
, int y
,
360 int width
, int height
);
362 void (*viewport_set_defaults
)(struct viewport
*vp
,
363 const enum screen_type screen
);
364 #ifdef HAVE_LCD_BITMAP
365 void (*viewportmanager_theme_enable
)(enum screen_type screen
, bool enable
,
366 struct viewport
*viewport
);
367 void (*viewportmanager_theme_undo
)(enum screen_type screen
, bool force_redraw
);
370 void (*gui_synclist_init
)(struct gui_synclist
* lists
,
371 list_get_name callback_get_item_name
, void * data
,
372 bool scroll_all
,int selected_size
,
373 struct viewport parent
[NB_SCREENS
]);
374 void (*gui_synclist_set_nb_items
)(struct gui_synclist
* lists
, int nb_items
);
375 void (*gui_synclist_set_icon_callback
)(struct gui_synclist
* lists
,
376 list_get_icon icon_callback
);
377 int (*gui_synclist_get_nb_items
)(struct gui_synclist
* lists
);
378 int (*gui_synclist_get_sel_pos
)(struct gui_synclist
* lists
);
379 void (*gui_synclist_draw
)(struct gui_synclist
* lists
);
380 void (*gui_synclist_select_item
)(struct gui_synclist
* lists
,
382 void (*gui_synclist_add_item
)(struct gui_synclist
* lists
);
383 void (*gui_synclist_del_item
)(struct gui_synclist
* lists
);
384 void (*gui_synclist_limit_scroll
)(struct gui_synclist
* lists
, bool scroll
);
385 bool (*gui_synclist_do_button
)(struct gui_synclist
* lists
,
386 int *action
, enum list_wrap wrap
);
387 void (*gui_synclist_set_title
)(struct gui_synclist
*lists
, char* title
,
388 enum themable_icons icon
);
389 enum yesno_res (*gui_syncyesno_run
)(const struct text_message
* main_message
,
390 const struct text_message
* yes_message
,
391 const struct text_message
* no_message
);
392 void (*simplelist_info_init
)(struct simplelist_info
*info
, char* title
,
393 int count
, void* data
);
394 bool (*simplelist_show_list
)(struct simplelist_info
*info
);
397 long (*button_get
)(bool block
);
398 long (*button_get_w_tmo
)(int ticks
);
399 int (*button_status
)(void);
400 #ifdef HAVE_BUTTON_DATA
401 intptr_t (*button_get_data
)(void);
402 int (*button_status_wdata
)(int *pdata
);
404 void (*button_clear_queue
)(void);
405 int (*button_queue_count
)(void);
406 #ifdef HAS_BUTTON_HOLD
407 bool (*button_hold
)(void);
409 #ifdef HAVE_TOUCHSCREEN
410 void (*touchscreen_set_mode
)(enum touchscreen_mode
);
412 #ifdef HAVE_BUTTON_LIGHT
413 void (*buttonlight_set_timeout
)(int value
);
414 void (*buttonlight_off
)(void);
415 void (*buttonlight_on
)(void);
416 #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
417 void (*buttonlight_set_brightness
)(int val
);
418 #endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
419 #endif /* HAVE_BUTTON_LIGHT */
422 int (*open_utf8
)(const char* pathname
, int flags
);
423 int (*open
)(const char* pathname
, int flags
, ...);
424 int (*close
)(int fd
);
425 ssize_t (*read
)(int fd
, void* buf
, size_t count
);
426 off_t (*lseek
)(int fd
, off_t offset
, int whence
);
427 int (*creat
)(const char *pathname
, mode_t mode
);
428 ssize_t (*write
)(int fd
, const void* buf
, size_t count
);
429 int (*remove
)(const char* pathname
);
430 int (*rename
)(const char* path
, const char* newname
);
431 int (*ftruncate
)(int fd
, off_t length
);
432 off_t (*filesize
)(int fd
);
433 int (*fdprintf
)(int fd
, const char *fmt
, ...) ATTRIBUTE_PRINTF(2, 3);
434 int (*read_line
)(int fd
, char* buffer
, int buffer_size
);
435 bool (*settings_parseline
)(char* line
, char** name
, char** value
);
436 void (*storage_sleep
)(void);
437 void (*storage_spin
)(void);
438 void (*storage_spindown
)(int seconds
);
439 #if USING_STORAGE_CALLBACK
440 void (*register_storage_idle_func
)(void (*function
)(void *data
));
441 void (*unregister_storage_idle_func
)(void (*function
)(void *data
), bool run
);
442 #endif /* USING_STORAGE_CALLBACK */
443 void (*reload_directory
)(void);
444 char *(*create_numbered_filename
)(char *buffer
, const char *path
,
445 const char *prefix
, const char *suffix
,
446 int numberlen
IF_CNFN_NUM_(, int *num
));
447 bool (*file_exists
)(const char *file
);
448 char* (*strip_extension
)(char* buffer
, int buffer_size
, const char *filename
);
449 unsigned (*crc_32
)(const void *src
, unsigned len
, unsigned crc32
);
451 int (*filetype_get_attr
)(const char* file
);
456 DIR* (*opendir
)(const char* name
);
457 int (*closedir
)(DIR* dir
);
458 struct dirent
* (*readdir
)(DIR* dir
);
459 int (*mkdir
)(const char *name
);
460 int (*rmdir
)(const char *name
);
461 bool (*dir_exists
)(const char *path
);
462 struct dirinfo (*dir_get_info
)(DIR* parent
, struct dirent
*entry
);
465 void (*browse_context_init
)(struct browse_context
*browse
,
466 int dirfilter
, unsigned flags
,
467 char *title
, enum themable_icons icon
,
468 const char *root
, const char *selected
);
469 int (*rockbox_browse
)(struct browse_context
*browse
);
472 #if defined(CPU_ARM) && CONFIG_PLATFORM & PLATFORM_NATIVE
473 void (*__div0
)(void);
475 unsigned (*sleep
)(unsigned ticks
);
477 volatile long* current_tick
;
478 long (*default_event_handler
)(long event
);
479 long (*default_event_handler_ex
)(long event
,
480 void (*callback
)(void *), void *parameter
);
481 unsigned int (*create_thread
)(void (*function
)(void), void* stack
,
482 size_t stack_size
, unsigned flags
,
484 IF_PRIO(, int priority
)
485 IF_COP(, unsigned int core
));
486 void (*thread_exit
)(void);
487 void (*thread_wait
)(unsigned int thread_id
);
488 #if CONFIG_CODEC == SWCODEC
489 void (*thread_thaw
)(unsigned int thread_id
);
490 #ifdef HAVE_PRIORITY_SCHEDULING
491 int (*thread_set_priority
)(unsigned int thread_id
, int priority
);
493 void (*mutex_init
)(struct mutex
*m
);
494 void (*mutex_lock
)(struct mutex
*m
);
495 void (*mutex_unlock
)(struct mutex
*m
);
498 void (*reset_poweroff_timer
)(void);
499 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
500 int (*system_memory_guard
)(int newmode
);
502 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
503 #ifdef CPU_BOOST_LOGGING
504 void (*cpu_boost_
)(bool on_off
,char*location
,int line
);
506 void (*cpu_boost
)(bool on_off
);
508 #endif /* HAVE_ADJUSTABLE_CPU_FREQ */
509 #endif /* PLATFORM_NATIVE */
510 #ifdef HAVE_SCHEDULER_BOOSTCTRL
511 void (*trigger_cpu_boost
)(void);
512 void (*cancel_cpu_boost
)(void);
515 void (*cpucache_flush
)(void);
516 void (*cpucache_invalidate
)(void);
518 /* load code api for overlay */
519 void* (*lc_open
)(const char *filename
, unsigned char *buf
, size_t buf_size
);
520 void* (*lc_open_from_mem
)(void* addr
, size_t blob_size
);
521 void* (*lc_get_header
)(void *handle
);
522 void (*lc_close
)(void *handle
);
524 bool (*timer_register
)(int reg_prio
, void (*unregister_callback
)(void),
525 long cycles
, void (*timer_callback
)(void)
527 void (*timer_unregister
)(void);
528 bool (*timer_set_period
)(long count
);
530 void (*queue_init
)(struct event_queue
*q
, bool register_queue
);
531 void (*queue_delete
)(struct event_queue
*q
);
532 void (*queue_post
)(struct event_queue
*q
, long id
, intptr_t data
);
533 void (*queue_wait_w_tmo
)(struct event_queue
*q
, struct queue_event
*ev
,
535 #if CONFIG_CODEC == SWCODEC
536 void (*queue_enable_queue_send
)(struct event_queue
*q
,
537 struct queue_sender_list
*send
,
538 unsigned int thread_id
);
539 bool (*queue_empty
)(const struct event_queue
*q
);
540 void (*queue_wait
)(struct event_queue
*q
, struct queue_event
*ev
);
541 intptr_t (*queue_send
)(struct event_queue
*q
, long id
,
543 void (*queue_reply
)(struct event_queue
*q
, intptr_t retval
);
544 #endif /* CONFIG_CODEC == SWCODEC */
546 void (*usb_acknowledge
)(long id
);
547 #ifdef USB_ENABLE_HID
548 void (*usb_hid_send
)(usage_page_t usage_page
, int id
);
551 void (*profile_thread
)(void);
552 void (*profstop
)(void);
553 void (*profile_func_enter
)(void *this_fn
, void *call_site
);
554 void (*profile_func_exit
)(void *this_fn
, void *call_site
);
557 bool (*add_event
)(unsigned short id
, bool oneshot
, void (*handler
)(void *data
));
558 void (*remove_event
)(unsigned short id
, void (*handler
)(void *data
));
559 void (*send_event
)(unsigned short id
, void *data
);
561 #if (CONFIG_PLATFORM & PLATFORM_HOSTED)
562 /* special simulator hooks */
563 #if defined(HAVE_LCD_BITMAP) && LCD_DEPTH < 8
564 void (*sim_lcd_ex_init
)(unsigned long (*getpixel
)(int, int));
565 void (*sim_lcd_ex_update_rect
)(int x
, int y
, int width
, int height
);
569 /* strings and memory */
570 int (*snprintf
)(char *buf
, size_t size
, const char *fmt
, ...)
571 ATTRIBUTE_PRINTF(3, 4);
572 int (*vsnprintf
)(char *buf
, size_t size
, const char *fmt
, va_list ap
);
573 char* (*strcpy
)(char *dst
, const char *src
);
574 size_t (*strlcpy
)(char *dst
, const char *src
, size_t length
);
575 size_t (*strlen
)(const char *str
);
576 char * (*strrchr
)(const char *s
, int c
);
577 int (*strcmp
)(const char *, const char *);
578 int (*strncmp
)(const char *, const char *, size_t);
579 int (*strcasecmp
)(const char *, const char *);
580 int (*strncasecmp
)(const char *s1
, const char *s2
, size_t n
);
581 void* (*memset
)(void *dst
, int c
, size_t length
);
582 void* (*memcpy
)(void *out
, const void *in
, size_t n
);
583 void* (*memmove
)(void *out
, const void *in
, size_t n
);
584 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
585 const unsigned char *_rbctype_
;
587 int (*atoi
)(const char *str
);
588 char *(*strchr
)(const char *s
, int c
);
589 char *(*strcat
)(char *s1
, const char *s2
);
590 size_t (*strlcat
)(char *dst
, const char *src
, size_t length
);
591 void *(*memchr
)(const void *s1
, int c
, size_t n
);
592 int (*memcmp
)(const void *s1
, const void *s2
, size_t n
);
593 char *(*strcasestr
) (const char* phaystack
, const char* pneedle
);
594 char* (*strtok_r
)(char *ptr
, const char *sep
, char **end
);
596 const unsigned char* (*utf8decode
)(const unsigned char *utf8
, unsigned short *ucs
);
597 unsigned char* (*iso_decode
)(const unsigned char *iso
, unsigned char *utf8
, int cp
, int count
);
598 unsigned char* (*utf16LEdecode
)(const unsigned char *utf16
, unsigned char *utf8
, int count
);
599 unsigned char* (*utf16BEdecode
)(const unsigned char *utf16
, unsigned char *utf8
, int count
);
600 unsigned char* (*utf8encode
)(unsigned long ucs
, unsigned char *utf8
);
601 unsigned long (*utf8length
)(const unsigned char *utf8
);
602 int (*utf8seek
)(const unsigned char* utf8
, int offset
);
605 void (*sound_set
)(int setting
, int value
);
606 int (*sound_default
)(int setting
);
607 int (*sound_min
)(int setting
);
608 int (*sound_max
)(int setting
);
609 const char * (*sound_unit
)(int setting
);
610 int (*sound_val2phys
)(int setting
, int value
);
611 #ifdef AUDIOHW_HAVE_EQ
612 int (*sound_enum_hw_eq_band_setting
)(unsigned int band
,
613 unsigned int band_setting
);
614 #endif /* AUDIOHW_HAVE_EQ */
615 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
616 void (*mp3_play_data
)(const unsigned char* start
, int size
,
617 void (*get_more
)(unsigned char** start
, size_t* size
));
618 void (*mp3_play_pause
)(bool play
);
619 void (*mp3_play_stop
)(void);
620 bool (*mp3_is_playing
)(void);
621 #if CONFIG_CODEC != SWCODEC
622 void (*bitswap
)(unsigned char *data
, int length
);
624 #endif /* PLATFORM_NATIVE */
625 #if CONFIG_CODEC == SWCODEC
626 const unsigned long *audio_master_sampr_list
;
627 const unsigned long *hw_freq_sampr
;
628 void (*pcm_apply_settings
)(void);
629 void (*pcm_play_data
)(pcm_play_callback_type get_more
,
630 unsigned char* start
, size_t size
);
631 void (*pcm_play_stop
)(void);
632 void (*pcm_set_frequency
)(unsigned int frequency
);
633 bool (*pcm_is_playing
)(void);
634 bool (*pcm_is_paused
)(void);
635 void (*pcm_play_pause
)(bool play
);
636 size_t (*pcm_get_bytes_waiting
)(void);
637 void (*pcm_calculate_peaks
)(int *left
, int *right
);
638 const void* (*pcm_get_peak_buffer
)(int *count
);
639 void (*pcm_play_lock
)(void);
640 void (*pcm_play_unlock
)(void);
641 void (*pcmbuf_beep
)(unsigned int frequency
,
644 #ifdef HAVE_RECORDING
645 const unsigned long *rec_freq_sampr
;
646 void (*pcm_init_recording
)(void);
647 void (*pcm_close_recording
)(void);
648 void (*pcm_record_data
)(pcm_rec_callback_type more_ready
,
649 void *start
, size_t size
);
650 void (*pcm_stop_recording
)(void);
651 void (*pcm_calculate_rec_peaks
)(int *left
, int *right
);
652 void (*audio_set_recording_gain
)(int left
, int right
, int type
);
653 #endif /* HAVE_RECORDING */
654 #if INPUT_SRC_CAPS != 0
655 void (*audio_set_output_source
)(int monitor
);
656 void (*audio_set_input_source
)(int source
, unsigned flags
);
658 void (*dsp_set_crossfeed
)(bool enable
);
659 void (*dsp_set_eq
)(bool enable
);
660 void (*dsp_dither_enable
)(bool enable
);
661 intptr_t (*dsp_configure
)(struct dsp_config
*dsp
, int setting
,
663 int (*dsp_process
)(struct dsp_config
*dsp
, char *dest
,
664 const char *src
[], int count
);
665 int (*dsp_input_count
)(struct dsp_config
*dsp
, int count
);
666 int (*dsp_output_count
)(struct dsp_config
*dsp
, int count
);
667 #endif /* CONFIG_CODEC == SWCODC */
669 /* playback control */
670 int (*playlist_amount
)(void);
671 int (*playlist_resume
)(void);
672 void (*playlist_start
)(int start_index
, int offset
);
673 int (*playlist_add
)(const char *filename
);
674 void (*playlist_sync
)(struct playlist_info
* playlist
);
675 int (*playlist_remove_all_tracks
)(struct playlist_info
*playlist
);
676 int (*playlist_create
)(const char *dir
, const char *file
);
677 int (*playlist_insert_track
)(struct playlist_info
* playlist
,
678 const char *filename
, int position
, bool queue
, bool sync
);
679 int (*playlist_insert_directory
)(struct playlist_info
* playlist
,
680 const char *dirname
, int position
, bool queue
,
682 int (*playlist_shuffle
)(int random_seed
, int start_index
);
683 void (*audio_play
)(long offset
);
684 void (*audio_stop
)(void);
685 void (*audio_pause
)(void);
686 void (*audio_resume
)(void);
687 void (*audio_next
)(void);
688 void (*audio_prev
)(void);
689 void (*audio_ff_rewind
)(long newtime
);
690 struct mp3entry
* (*audio_next_track
)(void);
691 int (*audio_status
)(void);
692 struct mp3entry
* (*audio_current_track
)(void);
693 void (*audio_flush_and_reload_tracks
)(void);
694 int (*audio_get_file_pos
)(void);
695 #if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
696 unsigned long (*mpeg_get_last_header
)(void);
698 #if ((CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) || \
699 (CONFIG_CODEC == SWCODEC)) && defined (HAVE_PITCHSCREEN)
700 void (*sound_set_pitch
)(int32_t pitch
);
703 /* MAS communication */
704 #if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
705 int (*mas_readmem
)(int bank
, int addr
, unsigned long* dest
, int len
);
706 int (*mas_writemem
)(int bank
, int addr
, const unsigned long* src
, int len
);
707 int (*mas_readreg
)(int reg
);
708 int (*mas_writereg
)(int reg
, unsigned int val
);
709 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
710 int (*mas_codec_writereg
)(int reg
, unsigned int val
);
711 int (*mas_codec_readreg
)(int reg
);
712 void (*i2c_begin
)(void);
713 void (*i2c_end
)(void);
714 int (*i2c_write
)(int address
, const unsigned char* buf
, int count
);
719 int (*do_menu
)(const struct menu_item_ex
*menu
, int *start_selected
,
720 struct viewport parent
[NB_SCREENS
], bool hide_theme
);
723 struct gui_syncstatusbar
*statusbars
;
724 void (*gui_syncstatusbar_draw
)(struct gui_syncstatusbar
* bars
, bool force_redraw
);
727 const struct settings_list
* (*get_settings_list
)(int*count
);
728 const struct settings_list
* (*find_setting
)(const void* variable
, int *id
);
729 bool (*option_screen
)(const struct settings_list
*setting
,
730 struct viewport parent
[NB_SCREENS
],
731 bool use_temp_var
, unsigned char* option_title
);
732 bool (*set_option
)(const char* string
, const void* variable
,
733 enum optiontype type
, const struct opt_items
* options
,
734 int numoptions
, void (*function
)(int));
735 bool (*set_bool_options
)(const char* string
, const bool* variable
,
736 const char* yes_str
, int yes_voice
,
737 const char* no_str
, int no_voice
,
738 void (*function
)(bool));
739 bool (*set_int
)(const unsigned char* string
, const char* unit
, int voice_unit
,
740 const int* variable
, void (*function
)(int), int step
,
742 const char* (*formatter
)(char*, size_t, int, const char*) );
743 bool (*set_bool
)(const char* string
, const bool* variable
);
745 #ifdef HAVE_LCD_COLOR
746 bool (*set_color
)(struct screen
*display
, char *title
,
747 unsigned *color
, unsigned banned_color
);
749 /* action handling */
750 int (*get_custom_action
)(int context
,int timeout
,
751 const struct button_mapping
* (*get_context_map
)(int));
752 int (*get_action
)(int context
, int timeout
);
753 #ifdef HAVE_TOUCHSCREEN
754 int (*action_get_touchscreen_press
)(short *x
, short *y
);
756 bool (*action_userabort
)(int timeout
);
759 int (*battery_level
)(void);
760 bool (*battery_level_safe
)(void);
761 int (*battery_time
)(void);
762 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
763 unsigned int (*battery_voltage
)(void);
766 bool (*charger_inserted
)(void);
767 # if CONFIG_CHARGING >= CHARGING_MONITOR
768 bool (*charging_state
)(void);
771 #ifdef HAVE_USB_POWER
772 bool (*usb_powered
)(void);
776 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
779 void (*srand
)(unsigned int seed
);
781 void (*qsort
)(void *base
, size_t nmemb
, size_t size
,
782 int(*compar
)(const void *, const void *));
783 int (*kbd_input
)(char* buffer
, int buflen
);
784 struct tm
* (*get_time
)(void);
785 int (*set_time
)(const struct tm
*tm
);
787 time_t (*mktime
)(struct tm
*t
);
789 void* (*plugin_get_buffer
)(size_t *buffer_size
);
790 void* (*plugin_get_audio_buffer
)(size_t *buffer_size
);
791 void (*plugin_tsr
)(bool (*exit_callback
)(bool reenter
));
792 char* (*plugin_get_current_filename
)(void);
793 #if defined(DEBUG) || defined(SIMULATOR)
794 void (*debugf
)(const char *fmt
, ...) ATTRIBUTE_PRINTF(1, 2);
796 #ifdef ROCKBOX_HAS_LOGF
797 void (*logf
)(const char *fmt
, ...) ATTRIBUTE_PRINTF(1, 2);
799 struct user_settings
* global_settings
;
800 struct system_status
*global_status
;
801 void (*talk_disable
)(bool disable
);
802 #if CONFIG_CODEC == SWCODEC
803 void (*codec_thread_do_callback
)(void (*fn
)(void),
804 unsigned int *audio_thread_id
);
805 int (*codec_load_file
)(const char* codec
, struct codec_api
*api
);
806 const char *(*get_codec_filename
)(int cod_spec
);
807 void ** (*find_array_ptr
)(void **arr
, void *ptr
);
808 int (*remove_array_ptr
)(void **arr
, void *ptr
);
809 int (*round_value_to_list32
)(unsigned long value
,
810 const unsigned long list
[],
813 #endif /* CONFIG_CODEC == SWCODEC */
814 bool (*get_metadata
)(struct mp3entry
* id3
, int fd
, const char* trackname
);
815 bool (*mp3info
)(struct mp3entry
*entry
, const char *filename
);
816 int (*count_mp3_frames
)(int fd
, int startpos
, int filesize
,
817 void (*progressfunc
)(int));
818 int (*create_xing_header
)(int fd
, long startpos
, long filesize
,
819 unsigned char *buf
, unsigned long num_frames
,
820 unsigned long rec_time
, unsigned long header_template
,
821 void (*progressfunc
)(int), bool generate_toc
);
822 unsigned long (*find_next_frame
)(int fd
, long *offset
,
823 long max_offset
, unsigned long last_header
);
825 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
826 unsigned short (*peak_meter_scale_value
)(unsigned short val
,
828 void (*peak_meter_set_use_dbfs
)(bool use
);
829 bool (*peak_meter_get_use_dbfs
)(void);
831 #ifdef HAVE_LCD_BITMAP
832 int (*read_bmp_file
)(const char* filename
, struct bitmap
*bm
, int maxsize
,
833 int format
, const struct custom_format
*cformat
);
834 int (*read_bmp_fd
)(int fd
, struct bitmap
*bm
, int maxsize
,
835 int format
, const struct custom_format
*cformat
);
837 int (*read_jpeg_file
)(const char* filename
, struct bitmap
*bm
, int maxsize
,
838 int format
, const struct custom_format
*cformat
);
839 int (*read_jpeg_fd
)(int fd
, struct bitmap
*bm
, int maxsize
,
840 int format
, const struct custom_format
*cformat
);
842 void (*screen_dump_set_hook
)(void (*hook
)(int fh
));
844 int (*show_logo
)(void);
845 struct tree_context
* (*tree_get_context
)(void);
846 void (*set_current_file
)(const char* path
);
847 void (*set_dirfilter
)(int l_dirfilter
);
849 #ifdef HAVE_WHEEL_POSITION
850 int (*wheel_status
)(void);
851 void (*wheel_send_events
)(bool send
);
854 #ifdef IRIVER_H100_SERIES
855 /* Routines for the iriver_flash -plugin. */
856 bool (*detect_original_firmware
)(void);
857 bool (*detect_flashed_ramimage
)(void);
858 bool (*detect_flashed_romimage
)(void);
861 void (*led
)(bool on
);
863 #if (CONFIG_CODEC == SWCODEC)
865 int (*bufopen
)(const char *file
, size_t offset
, enum data_type type
,
867 int (*bufalloc
)(const void *src
, size_t size
, enum data_type type
);
868 bool (*bufclose
)(int handle_id
);
869 int (*bufseek
)(int handle_id
, size_t newpos
);
870 int (*bufadvance
)(int handle_id
, off_t offset
);
871 ssize_t (*bufread
)(int handle_id
, size_t size
, void *dest
);
872 ssize_t (*bufgetdata
)(int handle_id
, size_t size
, void **data
);
873 ssize_t (*bufgettail
)(int handle_id
, size_t size
, void **data
);
874 ssize_t (*bufcuttail
)(int handle_id
, size_t size
);
876 ssize_t (*buf_get_offset
)(int handle_id
, void *ptr
);
877 ssize_t (*buf_handle_offset
)(int handle_id
);
878 void (*buf_request_buffer_handle
)(int handle_id
);
879 void (*buf_set_base_handle
)(int handle_id
);
880 size_t (*buf_used
)(void);
884 bool (*tagcache_search
)(struct tagcache_search
*tcs
, int tag
);
885 void (*tagcache_search_set_uniqbuf
)(struct tagcache_search
*tcs
,
886 void *buffer
, long length
);
887 bool (*tagcache_search_add_filter
)(struct tagcache_search
*tcs
,
889 bool (*tagcache_get_next
)(struct tagcache_search
*tcs
);
890 bool (*tagcache_retrieve
)(struct tagcache_search
*tcs
, int idxid
,
891 int tag
, char *buf
, long size
);
892 void (*tagcache_search_finish
)(struct tagcache_search
*tcs
);
893 long (*tagcache_get_numeric
)(const struct tagcache_search
*tcs
, int tag
);
894 #if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE)
895 bool (*tagcache_fill_tags
)(struct mp3entry
*id3
, const char *filename
);
900 bool (*search_albumart_files
)(const struct mp3entry
*id3
, const char *size_string
,
901 char *buf
, int buflen
);
904 #ifdef HAVE_SEMAPHORE_OBJECTS
905 void (*semaphore_init
)(struct semaphore
*s
, int max
, int start
);
906 void (*semaphore_wait
)(struct semaphore
*s
);
907 void (*semaphore_release
)(struct semaphore
*s
);
910 const char *rbversion
;
912 /* new stuff at the end, sort into place next time
913 the API gets incompatible */
917 struct plugin_header
{
918 struct lc_header lc_hdr
; /* must be the first */
919 enum plugin_status(*entry_point
)(const void*);
920 const struct plugin_api
**api
;
924 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
925 extern unsigned char plugin_start_addr
[];
926 extern unsigned char plugin_end_addr
[];
927 #define PLUGIN_HEADER \
928 const struct plugin_api *rb DATA_ATTR; \
929 const struct plugin_header __header \
930 __attribute__ ((section (".header")))= { \
931 { PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \
932 plugin_start_addr, plugin_end_addr }, plugin__start, &rb };
933 #else /* PLATFORM_HOSTED */
934 #define PLUGIN_HEADER \
935 const struct plugin_api *rb DATA_ATTR; \
936 const struct plugin_header __header \
937 __attribute__((visibility("default"))) = { \
938 { PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, NULL, NULL }, \
939 plugin__start, &rb };
940 #endif /* CONFIG_PLATFORM */
943 int plugin_load(const char* plugin
, const void* parameter
);
944 void* plugin_get_audio_buffer(size_t *buffer_size
);
947 callback returns true to allow the new plugin to load,
948 reenter means the currently running plugin is being reloaded */
949 void plugin_tsr(bool (*exit_callback
)(bool reenter
));
951 /* defined by the plugin */
952 extern const struct plugin_api
*rb
;
953 enum plugin_status
plugin__start(const void* parameter
)
956 #endif /* __PCTOOL__ */