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