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>
38 void* plugin_get_buffer(size_t *buffer_size
);
56 #include "mp3_playback.h"
62 #if (CONFIG_CODEC == SWCODEC)
68 #include "recording.h"
72 #endif /* CONFIG_CODEC == SWCODEC */
76 #ifdef HAVE_LCD_BITMAP
77 #include "scrollbar.h"
79 #include "statusbar.h"
81 #include "rbunicode.h"
84 #include "color_picker.h"
85 #include "buffering.h"
93 #ifdef HAVE_REMOTE_LCD
94 #include "lcd-remote.h"
99 #if defined(DEBUG) || defined(SIMULATOR)
101 #define DEBUGF rb->debugf
103 #define LDEBUGF rb->debugf
109 #ifdef ROCKBOX_HAS_LOGF
111 #define LOGF rb->logf
119 #define PREFIX(_x_) sim_ ## _x_
121 #define PREFIX(_x_) _x_
124 #define PLUGIN_MAGIC 0x526F634B /* RocK */
126 /* increase this every time the api struct changes */
127 #define PLUGIN_API_VERSION 118
129 /* update this to latest version if a change to the api struct breaks
130 backwards compatibility (and please take the opportunity to sort in any
131 new function which are "waiting" at the end of the function table) */
132 #define PLUGIN_MIN_API_VERSION 117
134 /* plugin return codes */
137 PLUGIN_USB_CONNECTED
,
141 /* NOTE: To support backwards compatibility, only add new functions at
142 the end of the structure. Every time you add a new function,
143 remember to increase PLUGIN_API_VERSION. If you make changes to the
144 existing APIs then also update PLUGIN_MIN_API_VERSION to current
150 void (*lcd_set_contrast
)(int x
);
151 void (*lcd_update
)(void);
152 void (*lcd_clear_display
)(void);
153 int (*lcd_getstringsize
)(const unsigned char *str
, int *w
, int *h
);
154 void (*lcd_putsxy
)(int x
, int y
, const unsigned char *string
);
155 void (*lcd_puts
)(int x
, int y
, const unsigned char *string
);
156 void (*lcd_puts_scroll
)(int x
, int y
, const unsigned char* string
);
157 void (*lcd_stop_scroll
)(void);
158 #ifdef HAVE_LCD_CHARCELLS
159 void (*lcd_define_pattern
)(unsigned long ucs
, const char *pattern
);
160 unsigned long (*lcd_get_locked_pattern
)(void);
161 void (*lcd_unlock_pattern
)(unsigned long ucs
);
162 void (*lcd_putc
)(int x
, int y
, unsigned long ucs
);
163 void (*lcd_put_cursor
)(int x
, int y
, unsigned long ucs
);
164 void (*lcd_remove_cursor
)(void);
165 void (*lcd_icon
)(int icon
, bool enable
);
166 void (*lcd_double_height
)(bool on
);
167 #else /* HAVE_LCD_BITMAP */
168 fb_data
* lcd_framebuffer
;
169 void (*lcd_update_rect
)(int x
, int y
, int width
, int height
);
170 void (*lcd_set_drawmode
)(int mode
);
171 int (*lcd_get_drawmode
)(void);
172 void (*lcd_setfont
)(int font
);
173 void (*lcd_drawpixel
)(int x
, int y
);
174 void (*lcd_drawline
)(int x1
, int y1
, int x2
, int y2
);
175 void (*lcd_hline
)(int x1
, int x2
, int y
);
176 void (*lcd_vline
)(int x
, int y1
, int y2
);
177 void (*lcd_drawrect
)(int x
, int y
, int width
, int height
);
178 void (*lcd_fillrect
)(int x
, int y
, int width
, int height
);
179 void (*lcd_mono_bitmap_part
)(const unsigned char *src
, int src_x
, int src_y
,
180 int stride
, int x
, int y
, int width
, int height
);
181 void (*lcd_mono_bitmap
)(const unsigned char *src
, int x
, int y
,
182 int width
, int height
);
184 void (*lcd_set_foreground
)(unsigned foreground
);
185 unsigned (*lcd_get_foreground
)(void);
186 void (*lcd_set_background
)(unsigned foreground
);
187 unsigned (*lcd_get_background
)(void);
188 void (*lcd_bitmap_part
)(const fb_data
*src
, int src_x
, int src_y
,
189 int stride
, int x
, int y
, int width
, int height
);
190 void (*lcd_bitmap
)(const fb_data
*src
, int x
, int y
, int width
,
192 fb_data
* (*lcd_get_backdrop
)(void);
193 void (*lcd_set_backdrop
)(fb_data
* backdrop
);
196 void (*lcd_bitmap_transparent_part
)(const fb_data
*src
,
197 int src_x
, int src_y
, int stride
,
198 int x
, int y
, int width
, int height
);
199 void (*lcd_bitmap_transparent
)(const fb_data
*src
, int x
, int y
,
200 int width
, int height
);
201 void (*lcd_blit_yuv
)(unsigned char * const src
[3],
202 int src_x
, int src_y
, int stride
,
203 int x
, int y
, int width
, int height
);
204 #if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) || defined(SANSA_C200) \
205 || defined (IRIVER_H10)
206 void (*lcd_yuv_set_options
)(unsigned options
);
208 #elif (LCD_DEPTH < 4) && !defined(SIMULATOR)
209 void (*lcd_blit_mono
)(const unsigned char *data
, int x
, int by
, int width
,
210 int bheight
, int stride
);
211 void (*lcd_blit_grey_phase
)(unsigned char *values
, unsigned char *phases
,
212 int bx
, int by
, int bwidth
, int bheight
,
214 #endif /* LCD_DEPTH */
215 void (*lcd_puts_style
)(int x
, int y
, const unsigned char *str
, int style
);
216 void (*lcd_puts_scroll_style
)(int x
, int y
, const unsigned char* string
,
218 #ifdef HAVE_LCD_INVERT
219 void (*lcd_set_invert_display
)(bool yesno
);
220 #endif /* HAVE_LCD_INVERT */
222 #ifdef HAVE_LCD_ENABLE
223 void (*lcd_set_enable_hook
)(void (*enable_hook
)(void));
224 struct event_queue
*button_queue
;
226 unsigned short *(*bidi_l2v
)( const unsigned char *str
, int orientation
);
227 const unsigned char *(*font_get_bits
)( struct font
*pf
, unsigned short char_code
);
228 struct font
* (*font_load
)(const char *path
);
229 struct font
* (*font_get
)(int font
);
230 int (*font_getstringsize
)(const unsigned char *str
, int *w
, int *h
,
232 int (*font_get_width
)(struct font
* pf
, unsigned short char_code
);
233 void (*screen_clear_area
)(struct screen
* display
, int xstart
, int ystart
,
234 int width
, int height
);
235 void (*gui_scrollbar_draw
)(struct screen
* screen
, int x
, int y
,
236 int width
, int height
, int items
,
237 int min_shown
, int max_shown
,
239 #endif /* HAVE_LCD_BITMAP */
242 void (*backlight_on
)(void);
243 void (*backlight_off
)(void);
244 void (*backlight_set_timeout
)(int index
);
245 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
246 void (*backlight_set_brightness
)(int val
);
247 #endif /* HAVE_BACKLIGHT_BRIGHTNESS */
250 void (*backlight_set_timeout_plugged
)(int index
);
252 bool (*is_backlight_on
)(bool ignore_always_off
);
253 void (*splash
)(int ticks
, const char *fmt
, ...) ATTRIBUTE_PRINTF(2, 3);
255 #ifdef HAVE_REMOTE_LCD
257 void (*lcd_remote_set_contrast
)(int x
);
258 void (*lcd_remote_clear_display
)(void);
259 void (*lcd_remote_puts
)(int x
, int y
, const unsigned char *string
);
260 void (*lcd_remote_puts_scroll
)(int x
, int y
, const unsigned char* string
);
261 void (*lcd_remote_stop_scroll
)(void);
262 void (*lcd_remote_set_drawmode
)(int mode
);
263 int (*lcd_remote_get_drawmode
)(void);
264 void (*lcd_remote_setfont
)(int font
);
265 int (*lcd_remote_getstringsize
)(const unsigned char *str
, int *w
, int *h
);
266 void (*lcd_remote_drawpixel
)(int x
, int y
);
267 void (*lcd_remote_drawline
)(int x1
, int y1
, int x2
, int y2
);
268 void (*lcd_remote_hline
)(int x1
, int x2
, int y
);
269 void (*lcd_remote_vline
)(int x
, int y1
, int y2
);
270 void (*lcd_remote_drawrect
)(int x
, int y
, int nx
, int ny
);
271 void (*lcd_remote_fillrect
)(int x
, int y
, int nx
, int ny
);
272 void (*lcd_remote_mono_bitmap_part
)(const unsigned char *src
, int src_x
,
273 int src_y
, int stride
, int x
, int y
,
274 int width
, int height
);
275 void (*lcd_remote_mono_bitmap
)(const unsigned char *src
, int x
, int y
,
276 int width
, int height
);
277 void (*lcd_remote_putsxy
)(int x
, int y
, const unsigned char *string
);
278 void (*lcd_remote_puts_style
)(int x
, int y
, const unsigned char *str
, int style
);
279 void (*lcd_remote_puts_scroll_style
)(int x
, int y
, const unsigned char* string
,
281 fb_remote_data
* lcd_remote_framebuffer
;
282 void (*lcd_remote_update
)(void);
283 void (*lcd_remote_update_rect
)(int x
, int y
, int width
, int height
);
285 void (*remote_backlight_on
)(void);
286 void (*remote_backlight_off
)(void);
287 void (*remote_backlight_set_timeout
)(int index
);
289 void (*remote_backlight_set_timeout_plugged
)(int index
);
291 #endif /* HAVE_REMOTE_LCD */
292 struct screen
* screens
[NB_SCREENS
];
293 #if defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)
294 void (*lcd_remote_set_foreground
)(unsigned foreground
);
295 unsigned (*lcd_remote_get_foreground
)(void);
296 void (*lcd_remote_set_background
)(unsigned background
);
297 unsigned (*lcd_remote_get_background
)(void);
298 void (*lcd_remote_bitmap_part
)(const fb_remote_data
*src
, int src_x
, int src_y
,
299 int stride
, int x
, int y
, int width
, int height
);
300 void (*lcd_remote_bitmap
)(const fb_remote_data
*src
, int x
, int y
, int width
,
303 void (*viewport_set_defaults
)(struct viewport
*vp
, enum screen_type screen
);
305 void (*gui_synclist_init
)(struct gui_synclist
* lists
,
306 list_get_name callback_get_item_name
, void * data
,
307 bool scroll_all
,int selected_size
,
308 struct viewport parent
[NB_SCREENS
]);
309 void (*gui_synclist_set_nb_items
)(struct gui_synclist
* lists
, int nb_items
);
310 void (*gui_synclist_set_icon_callback
)(struct gui_synclist
* lists
, list_get_icon icon_callback
);
311 int (*gui_synclist_get_nb_items
)(struct gui_synclist
* lists
);
312 int (*gui_synclist_get_sel_pos
)(struct gui_synclist
* lists
);
313 void (*gui_synclist_draw
)(struct gui_synclist
* lists
);
314 void (*gui_synclist_select_item
)(struct gui_synclist
* lists
,
316 void (*gui_synclist_add_item
)(struct gui_synclist
* lists
);
317 void (*gui_synclist_del_item
)(struct gui_synclist
* lists
);
318 void (*gui_synclist_limit_scroll
)(struct gui_synclist
* lists
, bool scroll
);
319 bool (*gui_synclist_do_button
)(struct gui_synclist
* lists
,
320 unsigned *action
, enum list_wrap wrap
);
321 void (*gui_synclist_set_title
)(struct gui_synclist
*lists
, char* title
, int icon
);
322 void (*simplelist_info_init
)(struct simplelist_info
*info
, char* title
,
323 int count
, void* data
);
324 bool (*simplelist_show_list
)(struct simplelist_info
*info
);
327 long (*button_get
)(bool block
);
328 long (*button_get_w_tmo
)(int ticks
);
329 int (*button_status
)(void);
330 #ifdef HAVE_BUTTON_DATA
331 intptr_t (*button_get_data
)(void);
333 void (*button_clear_queue
)(void);
334 int (*button_queue_count
)(void);
335 #ifdef HAS_BUTTON_HOLD
336 bool (*button_hold
)(void);
339 void (*touchpad_set_mode
)(enum touchpad_mode
);
341 #ifdef HAVE_BUTTON_LIGHT
342 void (*buttonlight_set_timeout
)(int value
);
343 void (*buttonlight_off
)(void);
344 void (*buttonlight_on
)(void);
345 #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
346 void (*buttonlight_set_brightness
)(int val
);
347 #endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
348 #endif /* HAVE_BUTTON_LIGHT */
351 int (*PREFIX(open
))(const char* pathname
, int flags
);
352 int (*PREFIX(close
))(int fd
);
353 ssize_t (*PREFIX(read
))(int fd
, void* buf
, size_t count
);
354 off_t (*PREFIX(lseek
))(int fd
, off_t offset
, int whence
);
355 int (*PREFIX(creat
))(const char *pathname
);
356 ssize_t (*PREFIX(write
))(int fd
, const void* buf
, size_t count
);
357 int (*PREFIX(remove
))(const char* pathname
);
358 int (*PREFIX(rename
))(const char* path
, const char* newname
);
359 int (*PREFIX(ftruncate
))(int fd
, off_t length
);
360 off_t (*PREFIX(filesize
))(int fd
);
361 int (*fdprintf
)(int fd
, const char *fmt
, ...) ATTRIBUTE_PRINTF(2, 3);
362 int (*read_line
)(int fd
, char* buffer
, int buffer_size
);
363 bool (*settings_parseline
)(char* line
, char** name
, char** value
);
364 void (*ata_sleep
)(void);
366 bool (*ata_disk_is_active
)(void);
368 void (*ata_spin
)(void);
369 void (*ata_spindown
)(int seconds
);
370 void (*reload_directory
)(void);
371 char *(*create_numbered_filename
)(char *buffer
, const char *path
,
372 const char *prefix
, const char *suffix
,
373 int numberlen
IF_CNFN_NUM_(, int *num
));
374 bool (*file_exists
)(const char *file
);
378 DIR* (*opendir
)(const char* name
);
379 int (*closedir
)(DIR* dir
);
380 struct dirent
* (*readdir
)(DIR* dir
);
381 int (*mkdir
)(const char *name
);
382 int (*rmdir
)(const char *name
);
383 bool (*dir_exists
)(const char *path
);
386 void (*PREFIX(sleep
))(int ticks
);
388 volatile long* current_tick
;
389 long (*default_event_handler
)(long event
);
390 long (*default_event_handler_ex
)(long event
, void (*callback
)(void *), void *parameter
);
391 struct thread_entry
* threads
;
392 struct thread_entry
* (*create_thread
)(void (*function
)(void), void* stack
,
393 size_t stack_size
, unsigned flags
,
395 IF_PRIO(, int priority
)
396 IF_COP(, unsigned int core
));
397 void (*thread_exit
)(void);
398 void (*thread_wait
)(struct thread_entry
*thread
);
399 #if CONFIG_CODEC == SWCODEC
400 void (*mutex_init
)(struct mutex
*m
);
401 void (*mutex_lock
)(struct mutex
*m
);
402 void (*mutex_unlock
)(struct mutex
*m
);
403 size_t (*align_buffer
)(void **start
, size_t size
, size_t align
);
406 void (*reset_poweroff_timer
)(void);
408 int (*system_memory_guard
)(int newmode
);
410 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
411 #ifdef CPU_BOOST_LOGGING
412 void (*cpu_boost_
)(bool on_off
,char*location
,int line
);
414 void (*cpu_boost
)(bool on_off
);
416 #endif /* HAVE_ADJUSTABLE_CPU_FREQ */
417 #endif /* !SIMULATOR */
418 #ifdef HAVE_SCHEDULER_BOOSTCTRL
419 void (*trigger_cpu_boost
)(void);
420 void (*cancel_cpu_boost
)(void);
422 #ifdef CACHE_FUNCTIONS_AS_CALL
423 void (*flush_icache
)(void);
424 void (*invalidate_icache
)(void);
426 bool (*timer_register
)(int reg_prio
, void (*unregister_callback
)(void),
427 long cycles
, int int_prio
,
428 void (*timer_callback
)(void) IF_COP(, int core
));
429 void (*timer_unregister
)(void);
430 bool (*timer_set_period
)(long count
);
432 void (*queue_init
)(struct event_queue
*q
, bool register_queue
);
433 void (*queue_delete
)(struct event_queue
*q
);
434 void (*queue_post
)(struct event_queue
*q
, long id
, intptr_t data
);
435 void (*queue_wait_w_tmo
)(struct event_queue
*q
, struct queue_event
*ev
,
437 #if CONFIG_CODEC == SWCODEC
438 void (*queue_enable_queue_send
)(struct event_queue
*q
,
439 struct queue_sender_list
*send
,
440 struct thread_entry
*owner
);
441 bool (*queue_empty
)(const struct event_queue
*q
);
442 void (*queue_wait
)(struct event_queue
*q
, struct queue_event
*ev
);
443 intptr_t (*queue_send
)(struct event_queue
*q
, long id
,
445 void (*queue_reply
)(struct event_queue
*q
, intptr_t retval
);
446 #endif /* CONFIG_CODEC == SWCODEC */
448 void (*usb_acknowledge
)(long id
);
450 void (*profile_thread
)(void);
451 void (*profstop
)(void);
452 void (*profile_func_enter
)(void *this_fn
, void *call_site
);
453 void (*profile_func_exit
)(void *this_fn
, void *call_site
);
457 /* special simulator hooks */
458 #if defined(HAVE_LCD_BITMAP) && LCD_DEPTH < 8
459 void (*sim_lcd_ex_init
)(int shades
, unsigned long (*getpixel
)(int, int));
460 void (*sim_lcd_ex_update_rect
)(int x
, int y
, int width
, int height
);
464 /* strings and memory */
465 int (*snprintf
)(char *buf
, size_t size
, const char *fmt
, ...)
466 ATTRIBUTE_PRINTF(3, 4);
467 int (*vsnprintf
)(char *buf
, int size
, const char *fmt
, va_list ap
);
468 char* (*strcpy
)(char *dst
, const char *src
);
469 char* (*strncpy
)(char *dst
, const char *src
, size_t length
);
470 size_t (*strlen
)(const char *str
);
471 char * (*strrchr
)(const char *s
, int c
);
472 int (*strcmp
)(const char *, const char *);
473 int (*strncmp
)(const char *, const char *, size_t);
474 int (*strcasecmp
)(const char *, const char *);
475 int (*strncasecmp
)(const char *s1
, const char *s2
, size_t n
);
476 void* (*memset
)(void *dst
, int c
, size_t length
);
477 void* (*memcpy
)(void *out
, const void *in
, size_t n
);
478 void* (*memmove
)(void *out
, const void *in
, size_t n
);
479 const unsigned char *_ctype_
;
480 int (*atoi
)(const char *str
);
481 char *(*strchr
)(const char *s
, int c
);
482 char *(*strcat
)(char *s1
, const char *s2
);
483 void *(*memchr
)(const void *s1
, int c
, size_t n
);
484 int (*memcmp
)(const void *s1
, const void *s2
, size_t n
);
485 char *(*strcasestr
) (const char* phaystack
, const char* pneedle
);
486 char* (*strtok_r
)(char *ptr
, const char *sep
, char **end
);
488 const unsigned char* (*utf8decode
)(const unsigned char *utf8
, unsigned short *ucs
);
489 unsigned char* (*iso_decode
)(const unsigned char *iso
, unsigned char *utf8
, int cp
, int count
);
490 unsigned char* (*utf16LEdecode
)(const unsigned char *utf16
, unsigned char *utf8
, int count
);
491 unsigned char* (*utf16BEdecode
)(const unsigned char *utf16
, unsigned char *utf8
, int count
);
492 unsigned char* (*utf8encode
)(unsigned long ucs
, unsigned char *utf8
);
493 unsigned long (*utf8length
)(const unsigned char *utf8
);
494 int (*utf8seek
)(const unsigned char* utf8
, int offset
);
497 void (*sound_set
)(int setting
, int value
);
498 int (*sound_default
)(int setting
);
499 int (*sound_min
)(int setting
);
500 int (*sound_max
)(int setting
);
501 const char * (*sound_unit
)(int setting
);
502 int (*sound_val2phys
)(int setting
, int value
);
504 void (*mp3_play_data
)(const unsigned char* start
, int size
, void (*get_more
)(unsigned char** start
, size_t* size
));
505 void (*mp3_play_pause
)(bool play
);
506 void (*mp3_play_stop
)(void);
507 bool (*mp3_is_playing
)(void);
508 #if CONFIG_CODEC != SWCODEC
509 void (*bitswap
)(unsigned char *data
, int length
);
511 #endif /* !SIMULATOR */
512 #if CONFIG_CODEC == SWCODEC
513 const unsigned long *audio_master_sampr_list
;
514 const unsigned long *hw_freq_sampr
;
515 void (*pcm_apply_settings
)(void);
516 void (*pcm_play_data
)(pcm_more_callback_type get_more
,
517 unsigned char* start
, size_t size
);
518 void (*pcm_play_stop
)(void);
519 void (*pcm_set_frequency
)(unsigned int frequency
);
520 bool (*pcm_is_playing
)(void);
521 bool (*pcm_is_paused
)(void);
522 void (*pcm_play_pause
)(bool play
);
523 size_t (*pcm_get_bytes_waiting
)(void);
524 void (*pcm_calculate_peaks
)(int *left
, int *right
);
525 void (*pcm_play_lock
)(void);
526 void (*pcm_play_unlock
)(void);
527 #ifdef HAVE_RECORDING
528 const unsigned long *rec_freq_sampr
;
529 void (*pcm_init_recording
)(void);
530 void (*pcm_close_recording
)(void);
531 void (*pcm_record_data
)(pcm_more_callback_type2 more_ready
,
532 void *start
, size_t size
);
533 void (*pcm_record_more
)(void *start
, size_t size
);
534 void (*pcm_stop_recording
)(void);
535 void (*pcm_calculate_rec_peaks
)(int *left
, int *right
);
536 void (*audio_set_recording_gain
)(int left
, int right
, int type
);
537 #endif /* HAVE_RECORDING */
538 #if INPUT_SRC_CAPS != 0
539 void (*audio_set_output_source
)(int monitor
);
540 void (*audio_set_input_source
)(int source
, unsigned flags
);
542 void (*dsp_set_crossfeed
)(bool enable
);
543 void (*dsp_set_eq
)(bool enable
);
544 void (*dsp_dither_enable
)(bool enable
);
545 intptr_t (*dsp_configure
)(struct dsp_config
*dsp
, int setting
,
547 int (*dsp_process
)(struct dsp_config
*dsp
, char *dest
,
548 const char *src
[], int count
);
549 #endif /* CONFIG_CODEC == SWCODC */
551 /* playback control */
552 int (*playlist_amount
)(void);
553 int (*playlist_resume
)(void);
554 int (*playlist_start
)(int start_index
, int offset
);
555 void (*PREFIX(audio_play
))(long offset
);
556 void (*audio_stop
)(void);
557 void (*audio_pause
)(void);
558 void (*audio_resume
)(void);
559 void (*audio_next
)(void);
560 void (*audio_prev
)(void);
561 void (*audio_ff_rewind
)(long newtime
);
562 struct mp3entry
* (*audio_next_track
)(void);
563 int (*audio_status
)(void);
564 bool (*audio_has_changed_track
)(void);
565 struct mp3entry
* (*audio_current_track
)(void);
566 void (*audio_flush_and_reload_tracks
)(void);
567 int (*audio_get_file_pos
)(void);
568 #if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
569 unsigned long (*mpeg_get_last_header
)(void);
571 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) || \
572 (CONFIG_CODEC == SWCODEC)
573 void (*sound_set_pitch
)(int pitch
);
576 /* MAS communication */
577 #if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
578 int (*mas_readmem
)(int bank
, int addr
, unsigned long* dest
, int len
);
579 int (*mas_writemem
)(int bank
, int addr
, const unsigned long* src
, int len
);
580 int (*mas_readreg
)(int reg
);
581 int (*mas_writereg
)(int reg
, unsigned int val
);
582 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
583 int (*mas_codec_writereg
)(int reg
, unsigned int val
);
584 int (*mas_codec_readreg
)(int reg
);
585 void (*i2c_begin
)(void);
586 void (*i2c_end
)(void);
587 int (*i2c_write
)(int address
, const unsigned char* buf
, int count
);
592 int (*do_menu
)(const struct menu_item_ex
*menu
, int *start_selected
,
593 struct viewport parent
[NB_SCREENS
], bool hide_bars
);
596 struct gui_syncstatusbar
*statusbars
;
597 void (*gui_syncstatusbar_draw
)(struct gui_syncstatusbar
* bars
, bool force_redraw
);
600 const struct settings_list
* (*find_setting
)(const void* variable
, int *id
);
601 bool (*option_screen
)(const struct settings_list
*setting
,
602 struct viewport parent
[NB_SCREENS
],
603 bool use_temp_var
, unsigned char* option_title
);
604 bool (*set_option
)(const char* string
, const void* variable
,
605 enum optiontype type
, const struct opt_items
* options
,
606 int numoptions
, void (*function
)(int));
607 bool (*set_bool_options
)(const char* string
, const bool* variable
,
608 const char* yes_str
, int yes_voice
,
609 const char* no_str
, int no_voice
,
610 void (*function
)(bool));
611 bool (*set_int
)(const unsigned char* string
, const char* unit
, int voice_unit
,
612 const int* variable
, void (*function
)(int), int step
,
614 void (*formatter
)(char*, size_t, int, const char*) );
615 bool (*set_bool
)(const char* string
, const bool* variable
);
617 #ifdef HAVE_LCD_COLOR
618 bool (*set_color
)(struct screen
*display
, char *title
, unsigned *color
,
619 unsigned banned_color
);
621 /* action handling */
622 int (*get_custom_action
)(int context
,int timeout
,
623 const struct button_mapping
* (*get_context_map
)(int));
624 int (*get_action
)(int context
, int timeout
);
625 bool (*action_userabort
)(int timeout
);
628 int (*battery_level
)(void);
629 bool (*battery_level_safe
)(void);
630 int (*battery_time
)(void);
632 unsigned int (*battery_voltage
)(void);
635 bool (*charger_inserted
)(void);
636 # if CONFIG_CHARGING == CHARGING_MONITOR
637 bool (*charging_state
)(void);
640 #ifdef HAVE_USB_POWER
641 bool (*usb_powered
)(void);
645 void (*srand
)(unsigned int seed
);
647 void (*qsort
)(void *base
, size_t nmemb
, size_t size
,
648 int(*compar
)(const void *, const void *));
649 int (*kbd_input
)(char* buffer
, int buflen
);
650 struct tm
* (*get_time
)(void);
651 int (*set_time
)(const struct tm
*tm
);
653 time_t (*mktime
)(struct tm
*t
);
655 void* (*plugin_get_buffer
)(size_t *buffer_size
);
656 void* (*plugin_get_audio_buffer
)(size_t *buffer_size
);
657 void (*plugin_tsr
)(bool (*exit_callback
)(bool reenter
));
658 char* (*plugin_get_current_filename
)(void);
659 #ifdef PLUGIN_USE_IRAM
660 void (*plugin_iram_init
)(char *iramstart
, char *iramcopy
, size_t iram_size
,
661 char *iedata
, size_t iedata_size
);
663 #if defined(DEBUG) || defined(SIMULATOR)
664 void (*debugf
)(const char *fmt
, ...) ATTRIBUTE_PRINTF(1, 2);
666 #ifdef ROCKBOX_HAS_LOGF
667 void (*logf
)(const char *fmt
, ...) ATTRIBUTE_PRINTF(1, 2);
669 struct user_settings
* global_settings
;
670 struct system_status
*global_status
;
671 void (*talk_disable
)(bool disable
);
672 #if CONFIG_CODEC == SWCODEC
673 int (*codec_load_file
)(const char* codec
, struct codec_api
*api
);
674 const char *(*get_codec_filename
)(int cod_spec
);
675 bool (*get_metadata
)(struct mp3entry
* id3
, int fd
, const char* trackname
);
677 bool (*mp3info
)(struct mp3entry
*entry
, const char *filename
);
678 int (*count_mp3_frames
)(int fd
, int startpos
, int filesize
,
679 void (*progressfunc
)(int));
680 int (*create_xing_header
)(int fd
, long startpos
, long filesize
,
681 unsigned char *buf
, unsigned long num_frames
,
682 unsigned long rec_time
, unsigned long header_template
,
683 void (*progressfunc
)(int), bool generate_toc
);
684 unsigned long (*find_next_frame
)(int fd
, long *offset
,
685 long max_offset
, unsigned long last_header
);
687 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
688 unsigned short (*peak_meter_scale_value
)(unsigned short val
,
690 void (*peak_meter_set_use_dbfs
)(bool use
);
691 bool (*peak_meter_get_use_dbfs
)(void);
693 #ifdef HAVE_LCD_BITMAP
694 int (*read_bmp_file
)(const char* filename
, struct bitmap
*bm
, int maxsize
,
696 void (*screen_dump_set_hook
)(void (*hook
)(int fh
));
698 int (*show_logo
)(void);
699 struct tree_context
* (*tree_get_context
)(void);
700 void (*set_current_file
)(char* path
);
701 void (*set_dirfilter
)(int l_dirfilter
);
703 #ifdef HAVE_WHEEL_POSITION
704 int (*wheel_status
)(void);
705 void (*wheel_send_events
)(bool send
);
708 #ifdef IRIVER_H100_SERIES
709 /* Routines for the iriver_flash -plugin. */
710 bool (*detect_original_firmware
)(void);
711 bool (*detect_flashed_ramimage
)(void);
712 bool (*detect_flashed_romimage
)(void);
715 void (*led
)(bool on
);
717 #if (CONFIG_CODEC == SWCODEC)
719 int (*bufopen
)(const char *file
, size_t offset
, enum data_type type
);
720 int (*bufalloc
)(const void *src
, size_t size
, enum data_type type
);
721 bool (*bufclose
)(int handle_id
);
722 int (*bufseek
)(int handle_id
, size_t newpos
);
723 int (*bufadvance
)(int handle_id
, off_t offset
);
724 ssize_t (*bufread
)(int handle_id
, size_t size
, void *dest
);
725 ssize_t (*bufgetdata
)(int handle_id
, size_t size
, void **data
);
726 ssize_t (*bufgettail
)(int handle_id
, size_t size
, void **data
);
727 ssize_t (*bufcuttail
)(int handle_id
, size_t size
);
729 ssize_t (*buf_get_offset
)(int handle_id
, void *ptr
);
730 ssize_t (*buf_handle_offset
)(int handle_id
);
731 void (*buf_request_buffer_handle
)(int handle_id
);
732 void (*buf_set_base_handle
)(int handle_id
);
733 size_t (*buf_used
)(void);
737 bool (*tagcache_search
)(struct tagcache_search
*tcs
, int tag
);
738 void (*tagcache_search_set_uniqbuf
)(struct tagcache_search
*tcs
,
739 void *buffer
, long length
);
740 bool (*tagcache_search_add_filter
)(struct tagcache_search
*tcs
,
742 bool (*tagcache_get_next
)(struct tagcache_search
*tcs
);
743 bool (*tagcache_retrieve
)(struct tagcache_search
*tcs
, int idxid
,
744 int tag
, char *buf
, long size
);
745 void (*tagcache_search_finish
)(struct tagcache_search
*tcs
);
749 bool (*find_albumart
)(const struct mp3entry
*id3
, char *buf
, int buflen
);
750 bool (*search_albumart_files
)(const struct mp3entry
*id3
, const char *size_string
,
751 char *buf
, int buflen
);
754 /* new stuff at the end, sort into place next time
755 the API gets incompatible */
757 long (*tagcache_get_numeric
)(const struct tagcache_search
*tcs
, int tag
);
763 struct plugin_header
{
765 unsigned short target_id
;
766 unsigned short api_version
;
767 unsigned char *load_addr
;
768 unsigned char *end_addr
;
769 enum plugin_status(*entry_point
)(const struct plugin_api
*, const void*);
774 extern unsigned char plugin_start_addr
[];
775 extern unsigned char plugin_end_addr
[];
776 #define PLUGIN_HEADER \
777 const struct plugin_header __header \
778 __attribute__ ((section (".header")))= { \
779 PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \
780 plugin_start_addr, plugin_end_addr, plugin_start };
781 #else /* SIMULATOR */
782 #define PLUGIN_HEADER \
783 const struct plugin_header __header \
784 __attribute__((visibility("default"))) = { \
785 PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \
786 NULL, NULL, plugin_start };
787 #endif /* SIMULATOR */
789 #ifdef PLUGIN_USE_IRAM
790 /* Declare IRAM variables */
791 #define PLUGIN_IRAM_DECLARE \
792 extern char iramcopy[]; \
793 extern char iramstart[]; \
794 extern char iramend[]; \
795 extern char iedata[]; \
797 /* Initialize IRAM */
798 #define PLUGIN_IRAM_INIT(api) \
799 (api)->plugin_iram_init(iramstart, iramcopy, iramend-iramstart, \
800 iedata, iend-iedata);
802 #define PLUGIN_IRAM_DECLARE
803 #define PLUGIN_IRAM_INIT(api)
804 #endif /* PLUGIN_USE_IRAM */
807 int plugin_load(const char* plugin
, const void* parameter
);
808 void* plugin_get_audio_buffer(size_t *buffer_size
);
809 #ifdef PLUGIN_USE_IRAM
810 void plugin_iram_init(char *iramstart
, char *iramcopy
, size_t iram_size
,
811 char *iedata
, size_t iedata_size
);
815 callback returns true to allow the new plugin to load,
816 reenter means the currently running plugin is being reloaded */
817 void plugin_tsr(bool (*exit_callback
)(bool reenter
));
819 /* defined by the plugin */
820 enum plugin_status
plugin_start(const struct plugin_api
* rockbox
, const void* parameter
)
823 /* Use this macro in plugins where gcc tries to optimize by calling
824 * these functions directly */
825 #define MEM_FUNCTION_WRAPPERS(api) \
826 void *memcpy(void *dest, const void *src, size_t n) \
828 return (api)->memcpy(dest, src, n); \
830 void *memset(void *dest, int c, size_t n) \
832 return (api)->memset(dest, c, n); \
834 void *memmove(void *dest, const void *src, size_t n) \
836 return (api)->memmove(dest, src, n); \
838 int memcmp(const void *s1, const void *s2, size_t n) \
840 return (api)->memcmp(s1, s2, n); \
843 #ifndef CACHE_FUNCTION_WRAPPERS
845 #ifdef CACHE_FUNCTIONS_AS_CALL
846 #define CACHE_FUNCTION_WRAPPERS(api) \
847 void flush_icache(void) \
849 (api)->flush_icache(); \
851 void invalidate_icache(void) \
853 (api)->invalidate_icache(); \
856 #define CACHE_FUNCTION_WRAPPERS(api)
857 #endif /* CACHE_FUNCTIONS_AS_CALL */
859 #endif /* CACHE_FUNCTION_WRAPPERS */
861 #ifndef ALIGN_BUFFER_WRAPPER
862 #define ALIGN_BUFFER_WRAPPER(api) \
863 size_t align_buffer(void **start, size_t size, size_t align) \
865 return (api)->align_buffer(start, size, align); \
867 #endif /* ALIGN_BUFFER_WRAPPER */
869 #endif /* __PCTOOL__ */