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>
54 #include "mp3_playback.h"
60 #if (CONFIG_CODEC == SWCODEC)
63 #include "recording.h"
67 #endif /* CONFIG_CODEC == SWCODEC */
71 #ifdef HAVE_LCD_BITMAP
72 #include "scrollbar.h"
75 #include "rbunicode.h"
79 #ifdef HAVE_REMOTE_LCD
80 #include "lcd-remote.h"
85 #if defined(DEBUG) || defined(SIMULATOR)
87 #define DEBUGF rb->debugf
89 #define LDEBUGF rb->debugf
95 #ifdef ROCKBOX_HAS_LOGF
105 #define PREFIX(_x_) sim_ ## _x_
107 #define PREFIX(_x_) _x_
110 #define PLUGIN_MAGIC 0x526F634B /* RocK */
112 /* increase this every time the api struct changes */
113 #define PLUGIN_API_VERSION 45
115 /* update this to latest version if a change to the api struct breaks
116 backwards compatibility (and please take the opportunity to sort in any
117 new function which are "waiting" at the end of the function table) */
118 #define PLUGIN_MIN_API_VERSION 45
120 /* plugin return codes */
123 PLUGIN_USB_CONNECTED
,
127 /* NOTE: To support backwards compatibility, only add new functions at
128 the end of the structure. Every time you add a new function,
129 remember to increase PLUGIN_API_VERSION. If you make changes to the
130 existing APIs then also update PLUGIN_MIN_API_VERSION to current
136 void (*lcd_set_contrast
)(int x
);
137 void (*lcd_clear_display
)(void);
138 void (*lcd_puts
)(int x
, int y
, const unsigned char *string
);
139 void (*lcd_puts_scroll
)(int x
, int y
, const unsigned char* string
);
140 void (*lcd_stop_scroll
)(void);
141 #ifdef HAVE_LCD_CHARCELLS
142 void (*lcd_define_pattern
)(int which
,const char *pattern
);
143 unsigned char (*lcd_get_locked_pattern
)(void);
144 void (*lcd_unlock_pattern
)(unsigned char pat
);
145 void (*lcd_putc
)(int x
, int y
, unsigned short ch
);
146 void (*lcd_put_cursor
)(int x
, int y
, char cursor_char
);
147 void (*lcd_remove_cursor
)(void);
148 void (*PREFIX(lcd_icon
))(int icon
, bool enable
);
149 void (*lcd_double_height
)(bool on
);
151 void (*lcd_setmargins
)(int x
, int y
);
152 void (*lcd_set_drawmode
)(int mode
);
153 int (*lcd_get_drawmode
)(void);
154 void (*lcd_setfont
)(int font
);
155 int (*lcd_getstringsize
)(const unsigned char *str
, int *w
, int *h
);
156 void (*lcd_drawpixel
)(int x
, int y
);
157 void (*lcd_drawline
)(int x1
, int y1
, int x2
, int y2
);
158 void (*lcd_hline
)(int x1
, int x2
, int y
);
159 void (*lcd_vline
)(int x
, int y1
, int y2
);
160 void (*lcd_drawrect
)(int x
, int y
, int width
, int height
);
161 void (*lcd_fillrect
)(int x
, int y
, int width
, int height
);
162 void (*lcd_mono_bitmap_part
)(const unsigned char *src
, int src_x
, int src_y
,
163 int stride
, int x
, int y
, int width
, int height
);
164 void (*lcd_mono_bitmap
)(const unsigned char *src
, int x
, int y
,
165 int width
, int height
);
167 void (*lcd_set_foreground
)(unsigned foreground
);
168 unsigned (*lcd_get_foreground
)(void);
169 void (*lcd_set_background
)(unsigned foreground
);
170 unsigned (*lcd_get_background
)(void);
171 void (*lcd_bitmap_part
)(const fb_data
*src
, int src_x
, int src_y
,
172 int stride
, int x
, int y
, int width
, int height
);
173 void (*lcd_bitmap
)(const fb_data
*src
, int x
, int y
, int width
,
175 void (*lcd_set_backdrop
)(fb_data
* backdrop
);
178 void (*lcd_bitmap_transparent_part
)(const fb_data
*src
,
179 int src_x
, int src_y
, int stride
,
180 int x
, int y
, int width
, int height
);
181 void (*lcd_bitmap_transparent
)(const fb_data
*src
, int x
, int y
,
182 int width
, int height
);
184 unsigned short *(*bidi_l2v
)( const unsigned char *str
, int orientation
);
185 const unsigned char *(*font_get_bits
)( struct font
*pf
, unsigned short char_code
);
186 struct font
* (*font_load
)(const char *path
);
187 void (*lcd_putsxy
)(int x
, int y
, const unsigned char *string
);
188 void (*lcd_puts_style
)(int x
, int y
, const unsigned char *str
, int style
);
189 void (*lcd_puts_scroll_style
)(int x
, int y
, const unsigned char* string
,
191 fb_data
* lcd_framebuffer
;
192 void (*lcd_blit
) (const fb_data
* data
, int x
, int by
, int width
,
193 int bheight
, int stride
);
194 void (*lcd_update
)(void);
195 void (*lcd_update_rect
)(int x
, int y
, int width
, int height
);
196 void (*gui_scrollbar_draw
)(struct screen
* screen
, int x
, int y
,
197 int width
, int height
, int items
,
198 int min_shown
, int max_shown
,
200 struct font
* (*font_get
)(int font
);
201 int (*font_getstringsize
)(const unsigned char *str
, int *w
, int *h
,
203 int (*font_get_width
)(struct font
* pf
, unsigned short char_code
);
205 void (*backlight_on
)(void);
206 void (*backlight_off
)(void);
207 void (*backlight_set_timeout
)(int index
);
208 void (*splash
)(int ticks
, bool center
, const unsigned char *fmt
, ...);
210 #ifdef HAVE_REMOTE_LCD
212 void (*lcd_remote_set_contrast
)(int x
);
213 void (*lcd_remote_clear_display
)(void);
214 void (*lcd_remote_puts
)(int x
, int y
, const unsigned char *string
);
215 void (*lcd_remote_lcd_puts_scroll
)(int x
, int y
, const unsigned char* string
);
216 void (*lcd_remote_lcd_stop_scroll
)(void);
217 void (*lcd_remote_set_drawmode
)(int mode
);
218 int (*lcd_remote_get_drawmode
)(void);
219 void (*lcd_remote_setfont
)(int font
);
220 int (*lcd_remote_getstringsize
)(const unsigned char *str
, int *w
, int *h
);
221 void (*lcd_remote_drawpixel
)(int x
, int y
);
222 void (*lcd_remote_drawline
)(int x1
, int y1
, int x2
, int y2
);
223 void (*lcd_remote_hline
)(int x1
, int x2
, int y
);
224 void (*lcd_remote_vline
)(int x
, int y1
, int y2
);
225 void (*lcd_remote_drawrect
)(int x
, int y
, int nx
, int ny
);
226 void (*lcd_remote_fillrect
)(int x
, int y
, int nx
, int ny
);
227 void (*lcd_remote_mono_bitmap_part
)(const unsigned char *src
, int src_x
,
228 int src_y
, int stride
, int x
, int y
,
229 int width
, int height
);
230 void (*lcd_remote_mono_bitmap
)(const unsigned char *src
, int x
, int y
,
231 int width
, int height
);
232 void (*lcd_remote_putsxy
)(int x
, int y
, const unsigned char *string
);
233 void (*lcd_remote_puts_style
)(int x
, int y
, const unsigned char *str
, int style
);
234 void (*lcd_remote_puts_scroll_style
)(int x
, int y
, const unsigned char* string
,
236 fb_remote_data
* lcd_remote_framebuffer
;
237 void (*lcd_remote_update
)(void);
238 void (*lcd_remote_update_rect
)(int x
, int y
, int width
, int height
);
240 void (*remote_backlight_on
)(void);
241 void (*remote_backlight_off
)(void);
243 struct screen
* screens
[NB_SCREENS
];
244 #if defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)
245 void (*lcd_remote_set_foreground
)(unsigned foreground
);
246 unsigned (*lcd_remote_get_foreground
)(void);
247 void (*lcd_remote_set_background
)(unsigned background
);
248 unsigned (*lcd_remote_get_background
)(void);
249 void (*lcd_remote_bitmap_part
)(const fb_remote_data
*src
, int src_x
, int src_y
,
250 int stride
, int x
, int y
, int width
, int height
);
251 void (*lcd_remote_bitmap
)(const fb_remote_data
*src
, int x
, int y
, int width
,
254 #if defined(HAVE_LCD_COLOR) && !defined(SIMULATOR)
255 void (*lcd_yuv_blit
)(unsigned char * const src
[3],
256 int src_x
, int src_y
, int stride
,
257 int x
, int y
, int width
, int height
);
261 void (*gui_synclist_init
)(struct gui_synclist
* lists
,
262 list_get_name callback_get_item_name
,void * data
,
263 bool scroll_all
,int selected_size
);
264 void (*gui_synclist_set_nb_items
)(struct gui_synclist
* lists
, int nb_items
);
265 void (*gui_synclist_set_icon_callback
)(struct gui_synclist
* lists
, list_get_icon icon_callback
);
266 int (*gui_synclist_get_nb_items
)(struct gui_synclist
* lists
);
267 int (*gui_synclist_get_sel_pos
)(struct gui_synclist
* lists
);
268 void (*gui_synclist_draw
)(struct gui_synclist
* lists
);
269 void (*gui_synclist_select_item
)(struct gui_synclist
* lists
,
271 void (*gui_synclist_add_item
)(struct gui_synclist
* lists
);
272 void (*gui_synclist_del_item
)(struct gui_synclist
* lists
);
273 void (*gui_synclist_limit_scroll
)(struct gui_synclist
* lists
, bool scroll
);
274 void (*gui_synclist_flash
)(struct gui_synclist
* lists
);
275 unsigned (*gui_synclist_do_button
)(struct gui_synclist
* lists
,
276 unsigned button
,enum list_wrap wrap
);
277 void (*gui_synclist_set_title
)(struct gui_synclist
*lists
, char* title
, ICON icon
);
280 long (*button_get
)(bool block
);
281 long (*button_get_w_tmo
)(int ticks
);
282 int (*button_status
)(void);
283 void (*button_clear_queue
)(void);
284 #ifdef HAS_BUTTON_HOLD
285 bool (*button_hold
)(void);
289 int (*PREFIX(open
))(const char* pathname
, int flags
);
290 int (*close
)(int fd
);
291 ssize_t (*read
)(int fd
, void* buf
, size_t count
);
292 off_t (*PREFIX(lseek
))(int fd
, off_t offset
, int whence
);
293 int (*PREFIX(creat
))(const char *pathname
);
294 ssize_t (*write
)(int fd
, const void* buf
, size_t count
);
295 int (*PREFIX(remove
))(const char* pathname
);
296 int (*PREFIX(rename
))(const char* path
, const char* newname
);
297 int (*PREFIX(ftruncate
))(int fd
, off_t length
);
298 off_t (*PREFIX(filesize
))(int fd
);
299 int (*fdprintf
)(int fd
, const char *fmt
, ...);
300 int (*read_line
)(int fd
, char* buffer
, int buffer_size
);
301 bool (*settings_parseline
)(char* line
, char** name
, char** value
);
303 void (*ata_sleep
)(void);
304 bool (*ata_disk_is_active
)(void);
306 void (*ata_spindown
)(int seconds
);
307 void (*reload_directory
)(void);
310 DIR* (*PREFIX(opendir
))(const char* name
);
311 int (*PREFIX(closedir
))(DIR* dir
);
312 struct dirent
* (*PREFIX(readdir
))(DIR* dir
);
313 int (*PREFIX(mkdir
))(const char *name
);
314 int (*PREFIX(rmdir
))(const char *name
);
317 DIRCACHED
* (*opendir_cached
)(const char* name
);
318 struct dircache_entry
* (*readdir_cached
)(DIRCACHED
* dir
);
319 int (*closedir_cached
)(DIRCACHED
* dir
);
323 void (*PREFIX(sleep
))(int ticks
);
326 long (*default_event_handler
)(long event
);
327 long (*default_event_handler_ex
)(long event
, void (*callback
)(void *), void *parameter
);
328 struct thread_entry
* (*create_thread
)(void (*function
)(void), void* stack
,
329 int stack_size
, const char *name
330 IF_PRIO(, int priority
));
331 void (*remove_thread
)(struct thread_entry
*thread
);
332 void (*reset_poweroff_timer
)(void);
334 int (*system_memory_guard
)(int newmode
);
336 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
337 #ifdef CPU_BOOST_LOGGING
338 void (*cpu_boost_
)(bool on_off
,char*location
,int line
);
340 void (*cpu_boost
)(bool on_off
);
343 bool (*timer_register
)(int reg_prio
, void (*unregister_callback
)(void),
344 long cycles
, int int_prio
,
345 void (*timer_callback
)(void));
346 void (*timer_unregister
)(void);
347 bool (*timer_set_period
)(long count
);
349 void (*queue_init
)(struct event_queue
*q
, bool register_queue
);
350 void (*queue_delete
)(struct event_queue
*q
);
351 void (*queue_post
)(struct event_queue
*q
, long id
, intptr_t data
);
352 void (*queue_wait_w_tmo
)(struct event_queue
*q
, struct event
*ev
,
354 void (*usb_acknowledge
)(long id
);
356 void (*profile_thread
)(void);
357 void (*profstop
)(void);
358 void (*profile_func_enter
)(void *this_fn
, void *call_site
);
359 void (*profile_func_exit
)(void *this_fn
, void *call_site
);
363 /* special simulator hooks */
364 #if defined(HAVE_LCD_BITMAP) && LCD_DEPTH < 8
365 void (*sim_lcd_ex_init
)(int shades
, unsigned long (*getpixel
)(int, int));
366 void (*sim_lcd_ex_update_rect
)(int x
, int y
, int width
, int height
);
370 /* strings and memory */
371 int (*snprintf
)(char *buf
, size_t size
, const char *fmt
, ...);
372 int (*vsnprintf
)(char *buf
, int size
, const char *fmt
, va_list ap
);
373 char* (*strcpy
)(char *dst
, const char *src
);
374 char* (*strncpy
)(char *dst
, const char *src
, size_t length
);
375 size_t (*strlen
)(const char *str
);
376 char * (*strrchr
)(const char *s
, int c
);
377 int (*strcmp
)(const char *, const char *);
378 int (*strncmp
)(const char *, const char *, size_t);
379 int (*strcasecmp
)(const char *, const char *);
380 int (*strncasecmp
)(const char *s1
, const char *s2
, size_t n
);
381 void* (*memset
)(void *dst
, int c
, size_t length
);
382 void* (*memcpy
)(void *out
, const void *in
, size_t n
);
383 void* (*memmove
)(void *out
, const void *in
, size_t n
);
384 const unsigned char *_ctype_
;
385 int (*atoi
)(const char *str
);
386 char *(*strchr
)(const char *s
, int c
);
387 char *(*strcat
)(char *s1
, const char *s2
);
388 void *(*memchr
)(const void *s1
, int c
, size_t n
);
389 int (*memcmp
)(const void *s1
, const void *s2
, size_t n
);
390 char *(*strcasestr
) (const char* phaystack
, const char* pneedle
);
391 char* (*strtok_r
)(char *ptr
, const char *sep
, char **end
);
393 const unsigned char* (*utf8decode
)(const unsigned char *utf8
, unsigned short *ucs
);
394 unsigned char* (*iso_decode
)(const unsigned char *iso
, unsigned char *utf8
, int cp
, int count
);
395 unsigned char* (*utf16LEdecode
)(const unsigned char *utf16
, unsigned char *utf8
, int count
);
396 unsigned char* (*utf16BEdecode
)(const unsigned char *utf16
, unsigned char *utf8
, int count
);
397 unsigned char* (*utf8encode
)(unsigned long ucs
, unsigned char *utf8
);
398 unsigned long (*utf8length
)(const unsigned char *utf8
);
399 int (*utf8seek
)(const unsigned char* utf8
, int offset
);
402 void (*sound_set
)(int setting
, int value
);
403 bool (*set_sound
)(const unsigned char * string
,
404 int* variable
, int setting
);
405 int (*sound_min
)(int setting
);
406 int (*sound_max
)(int setting
);
408 void (*mp3_play_data
)(const unsigned char* start
, int size
, void (*get_more
)(unsigned char** start
, int* size
));
409 void (*mp3_play_pause
)(bool play
);
410 void (*mp3_play_stop
)(void);
411 bool (*mp3_is_playing
)(void);
412 #if CONFIG_CODEC != SWCODEC
413 void (*bitswap
)(unsigned char *data
, int length
);
415 #endif /* !SIMULATOR */
416 #if CONFIG_CODEC == SWCODEC
417 void (*pcm_play_data
)(pcm_more_callback_type get_more
,
418 unsigned char* start
, size_t size
);
419 void (*pcm_play_stop
)(void);
420 void (*pcm_set_frequency
)(unsigned int frequency
);
421 bool (*pcm_is_playing
)(void);
422 void (*pcm_play_pause
)(bool play
);
424 #if CONFIG_CODEC == SWCODEC
425 void (*pcm_calculate_peaks
)(int *left
, int *right
);
428 /* playback control */
429 void (*PREFIX(audio_play
))(long offset
);
430 void (*audio_stop
)(void);
431 void (*audio_pause
)(void);
432 void (*audio_resume
)(void);
433 void (*audio_next
)(void);
434 void (*audio_prev
)(void);
435 void (*audio_ff_rewind
)(long newtime
);
436 struct mp3entry
* (*audio_next_track
)(void);
437 int (*playlist_amount
)(void);
438 int (*audio_status
)(void);
439 bool (*audio_has_changed_track
)(void);
440 struct mp3entry
* (*audio_current_track
)(void);
441 void (*audio_flush_and_reload_tracks
)(void);
442 int (*audio_get_file_pos
)(void);
443 #if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
444 unsigned long (*mpeg_get_last_header
)(void);
446 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) || \
447 (CONFIG_CODEC == SWCODEC)
448 void (*sound_set_pitch
)(int pitch
);
451 /* MAS communication */
452 #if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
453 int (*mas_readmem
)(int bank
, int addr
, unsigned long* dest
, int len
);
454 int (*mas_writemem
)(int bank
, int addr
, const unsigned long* src
, int len
);
455 int (*mas_readreg
)(int reg
);
456 int (*mas_writereg
)(int reg
, unsigned int val
);
457 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
458 int (*mas_codec_writereg
)(int reg
, unsigned int val
);
459 int (*mas_codec_readreg
)(int reg
);
460 void (*i2c_begin
)(void);
461 void (*i2c_end
)(void);
462 int (*i2c_write
)(int address
, unsigned char* buf
, int count
);
467 int (*menu_init
)(const struct menu_item
* mitems
, int count
,
468 int (*callback
)(int, int),
469 const char *button1
, const char *button2
, const char *button3
);
470 void (*menu_exit
)(int menu
);
471 int (*menu_show
)(int m
);
472 bool (*menu_run
)(int menu
);
473 int (*menu_cursor
)(int menu
);
474 char* (*menu_description
)(int menu
, int position
);
475 void (*menu_delete
)(int menu
, int position
);
476 int (*menu_count
)(int menu
);
477 void (*menu_draw
)(int menu
);
478 void (*menu_insert
)(int menu
, int position
, char *desc
, bool (*function
) (void));
479 void (*menu_set_cursor
)(int menu
, int position
);
481 bool (*set_option
)(const char* string
, void* variable
,
482 enum optiontype type
, const struct opt_items
* options
,
483 int numoptions
, void (*function
)(int));
484 bool (*set_int
)(const unsigned char* string
, const char* unit
, int voice_unit
,
485 int* variable
, void (*function
)(int), int step
, int min
,
486 int max
, void (*formatter
)(char*, int, int, const char*) );
487 bool (*set_bool
)(const char* string
, bool* variable
);
489 /* action handling */
490 int (*get_custom_action
)(int context
,int timeout
,
491 const struct button_mapping
* (*get_context_map
)(int));
492 int (*get_action
)(int context
, int timeout
);
493 void (*action_signalscreenchange
)(void);
494 bool (*action_userabort
)(int timeout
);
497 int (*battery_level
)(void);
498 bool (*battery_level_safe
)(void);
499 int (*battery_time
)(void);
501 unsigned int (*battery_voltage
)(void);
504 bool (*charger_inserted
)(void);
505 # if CONFIG_CHARGING == CHARGING_MONITOR
506 bool (*charging_state
)(void);
509 #ifdef HAVE_USB_POWER
510 bool (*usb_powered
)(void);
514 void (*srand
)(unsigned int seed
);
516 void (*qsort
)(void *base
, size_t nmemb
, size_t size
,
517 int(*compar
)(const void *, const void *));
518 int (*kbd_input
)(char* buffer
, int buflen
);
519 struct tm
* (*get_time
)(void);
520 int (*set_time
)(const struct tm
*tm
);
521 void* (*plugin_get_buffer
)(int* buffer_size
);
522 void* (*plugin_get_audio_buffer
)(int* buffer_size
);
523 void (*plugin_tsr
)(bool (*exit_callback
)(bool reenter
));
524 #if defined(DEBUG) || defined(SIMULATOR)
525 void (*debugf
)(const char *fmt
, ...);
527 #ifdef ROCKBOX_HAS_LOGF
528 void (*logf
)(const char *fmt
, ...);
530 struct user_settings
* global_settings
;
531 bool (*mp3info
)(struct mp3entry
*entry
, const char *filename
, bool v1first
);
532 int (*count_mp3_frames
)(int fd
, int startpos
, int filesize
,
533 void (*progressfunc
)(int));
534 int (*create_xing_header
)(int fd
, long startpos
, long filesize
,
535 unsigned char *buf
, unsigned long num_frames
,
536 unsigned long rec_time
, unsigned long header_template
,
537 void (*progressfunc
)(int), bool generate_toc
);
538 unsigned long (*find_next_frame
)(int fd
, long *offset
,
539 long max_offset
, unsigned long last_header
);
541 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
542 unsigned short (*peak_meter_scale_value
)(unsigned short val
,
544 void (*peak_meter_set_use_dbfs
)(bool use
);
545 bool (*peak_meter_get_use_dbfs
)(void);
547 #ifdef HAVE_LCD_BITMAP
548 int (*read_bmp_file
)(char* filename
, struct bitmap
*bm
, int maxsize
,
550 void (*screen_dump_set_hook
)(void (*hook
)(int fh
));
552 int (*show_logo
)(void);
553 struct tree_context
* (*tree_get_context
)(void);
555 #ifdef HAVE_WHEEL_POSITION
556 int (*wheel_status
)(void);
557 void (*wheel_send_events
)(bool send
);
560 fb_data
* (*lcd_get_backdrop
)(void);
562 /* new stuff at the end, sort into place next time
563 the API gets incompatible */
565 /* Keep these at the bottom till fully proven */
566 #if CONFIG_CODEC == SWCODEC
567 const unsigned long *audio_master_sampr_list
;
568 const unsigned long *hw_freq_sampr
;
570 void (*pcm_apply_settings
)(bool reset
);
572 #ifdef HAVE_RECORDING
573 const unsigned long *rec_freq_sampr
;
575 void (*pcm_init_recording
)(void);
576 void (*pcm_close_recording
)(void);
577 void (*pcm_record_data
)(pcm_more_callback_type2 more_ready
,
578 void *start
, size_t size
);
579 void (*pcm_stop_recording
)(void);
580 void (*pcm_calculate_rec_peaks
)(int *left
, int *right
);
581 void (*audio_set_recording_gain
)(int left
, int right
, int type
);
582 void (*audio_set_output_source
)(int monitor
);
583 void (*rec_set_source
)(int source
, unsigned flags
);
585 #endif /* HAVE_RECORDING */
586 #endif /* CONFIG_CODEC == SWCODEC */
589 void (*plugin_iram_init
)(char *iramstart
, char *iramcopy
, size_t iram_size
,
590 char *iedata
, size_t iedata_size
);
593 #if CONFIG_CODEC == SWCODEC && defined(HAVE_RECORDING) && !defined(SIMULATOR)
594 int (*sound_default
)(int setting
);
595 void (*pcm_record_more
)(void *start
, size_t size
);
598 struct thread_entry
*(*create_thread_on_core
)(
599 unsigned int core
, void (*function
)(void),
600 void* stack
, int stack_size
,
601 const char *name
IF_PRIO(, int priority
));
603 #ifdef IRIVER_H100_SERIES
604 /* Routines for the iriver_flash -plugin. */
605 bool (*detect_original_firmware
)(void);
606 bool (*detect_flashed_ramimage
)(void);
607 bool (*detect_flashed_romimage
)(void);
612 struct plugin_header
{
614 unsigned short target_id
;
615 unsigned short api_version
;
616 unsigned char *load_addr
;
617 unsigned char *end_addr
;
618 enum plugin_status(*entry_point
)(struct plugin_api
*, void*);
623 extern unsigned char plugin_start_addr
[];
624 extern unsigned char plugin_end_addr
[];
625 #define PLUGIN_HEADER \
626 const struct plugin_header __header \
627 __attribute__ ((section (".header")))= { \
628 PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \
629 plugin_start_addr, plugin_end_addr, plugin_start };
630 #else /* SIMULATOR */
631 #define PLUGIN_HEADER \
632 const struct plugin_header __header = { \
633 PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \
634 NULL, NULL, plugin_start };
635 #endif /* SIMULATOR */
638 /* Declare IRAM variables */
639 #define PLUGIN_IRAM_DECLARE \
640 extern char iramcopy[]; \
641 extern char iramstart[]; \
642 extern char iramend[]; \
643 extern char iedata[]; \
645 /* Initialize IRAM */
646 #define PLUGIN_IRAM_INIT(api) \
647 (api)->plugin_iram_init(iramstart, iramcopy, iramend-iramstart, \
648 iedata, iend-iedata);
650 #define PLUGIN_IRAM_DECLARE
651 #define PLUGIN_IRAM_INIT(api)
652 #endif /* USE_IRAM */
655 int plugin_load(const char* plugin
, void* parameter
);
656 void* plugin_get_buffer(int *buffer_size
);
657 void* plugin_get_audio_buffer(int *buffer_size
);
659 void plugin_iram_init(char *iramstart
, char *iramcopy
, size_t iram_size
,
660 char *iedata
, size_t iedata_size
);
664 callback returns true to allow the new plugin to load,
665 reenter means the currently running plugin is being reloaded */
666 void plugin_tsr(bool (*exit_callback
)(bool reenter
));
668 /* defined by the plugin */
669 enum plugin_status
plugin_start(struct plugin_api
* rockbox
, void* parameter
)