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