remove the last mr500 yello
[maemo-rb.git] / apps / plugin.c
blobb3710e4d62d084cab1835c62e4567c0738df8e8a
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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 ****************************************************************************/
19 #include "plugin.h"
20 #include <ctype.h>
21 #include <string.h>
22 #include <sprintf.h>
23 #include <atoi.h>
24 #include "debug.h"
25 #include "i2c.h"
26 #include "lang.h"
27 #include "led.h"
28 #include "keyboard.h"
29 #include "buffer.h"
30 #include "backlight.h"
31 #include "sound_menu.h"
32 #include "mp3data.h"
33 #include "powermgmt.h"
34 #include "splash.h"
35 #include "logf.h"
36 #include "option_select.h"
37 #include "talk.h"
39 #if CONFIG_CHARGING
40 #include "power.h"
41 #endif
43 #ifdef HAVE_LCD_BITMAP
44 #include "scrollbar.h"
45 #include "peakmeter.h"
46 #include "bmp.h"
47 #include "bidi.h"
48 #endif
50 #ifdef SIMULATOR
51 static unsigned char pluginbuf[PLUGIN_BUFFER_SIZE];
52 void *sim_plugin_load(char *plugin, void **pd);
53 void sim_plugin_close(void *pd);
54 void sim_lcd_ex_init(int shades, unsigned long (*getpixel)(int, int));
55 void sim_lcd_ex_update_rect(int x, int y, int width, int height);
56 #else
57 #define sim_plugin_close(x)
58 extern unsigned char pluginbuf[];
59 #include "bitswap.h"
60 #endif
62 /* for actual plugins only, not for codecs */
63 static bool plugin_loaded = false;
64 static int plugin_size = 0;
65 static bool (*pfn_tsr_exit)(bool reenter) = NULL; /* TSR exit callback */
66 static char current_plugin[MAX_PATH];
68 char *plugin_get_current_filename(void);
70 extern struct thread_entry threads[MAXTHREADS];
72 static const struct plugin_api rockbox_api = {
74 /* lcd */
75 lcd_set_contrast,
76 lcd_update,
77 lcd_clear_display,
78 lcd_setmargins,
79 lcd_getstringsize,
80 lcd_putsxy,
81 lcd_puts,
82 lcd_puts_scroll,
83 lcd_stop_scroll,
84 #ifdef HAVE_LCD_CHARCELLS
85 lcd_define_pattern,
86 lcd_get_locked_pattern,
87 lcd_unlock_pattern,
88 lcd_putc,
89 lcd_put_cursor,
90 lcd_remove_cursor,
91 lcd_icon,
92 lcd_double_height,
93 #else
94 &lcd_framebuffer[0][0],
95 lcd_update_rect,
96 lcd_set_drawmode,
97 lcd_get_drawmode,
98 lcd_setfont,
99 lcd_drawpixel,
100 lcd_drawline,
101 lcd_hline,
102 lcd_vline,
103 lcd_drawrect,
104 lcd_fillrect,
105 lcd_mono_bitmap_part,
106 lcd_mono_bitmap,
107 #if LCD_DEPTH > 1
108 lcd_set_foreground,
109 lcd_get_foreground,
110 lcd_set_background,
111 lcd_get_background,
112 lcd_bitmap_part,
113 lcd_bitmap,
114 lcd_get_backdrop,
115 lcd_set_backdrop,
116 #endif
117 #if LCD_DEPTH == 16
118 lcd_bitmap_transparent_part,
119 lcd_bitmap_transparent,
120 lcd_blit_yuv,
121 #if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) || defined(SANSA_C200) \
122 || defined (IRIVER_H10)
123 lcd_yuv_set_options,
124 #endif
125 #elif (LCD_DEPTH < 4) && !defined(SIMULATOR)
126 lcd_blit_mono,
127 lcd_blit_grey_phase,
128 #endif /* LCD_DEPTH */
129 lcd_puts_style,
130 lcd_puts_scroll_style,
131 bidi_l2v,
132 font_get_bits,
133 font_load,
134 font_get,
135 font_getstringsize,
136 font_get_width,
137 screen_clear_area,
138 gui_scrollbar_draw,
139 #endif
141 backlight_on,
142 backlight_off,
143 backlight_set_timeout,
145 #if CONFIG_CHARGING
146 backlight_set_timeout_plugged,
147 #endif
148 is_backlight_on,
149 gui_syncsplash,
151 #ifdef HAVE_REMOTE_LCD
152 /* remote lcd */
153 lcd_remote_set_contrast,
154 lcd_remote_clear_display,
155 lcd_remote_setmargins,
156 lcd_remote_puts,
157 lcd_remote_puts_scroll,
158 lcd_remote_stop_scroll,
159 lcd_remote_set_drawmode,
160 lcd_remote_get_drawmode,
161 lcd_remote_setfont,
162 lcd_remote_getstringsize,
163 lcd_remote_drawpixel,
164 lcd_remote_drawline,
165 lcd_remote_hline,
166 lcd_remote_vline,
167 lcd_remote_drawrect,
168 lcd_remote_fillrect,
169 lcd_remote_mono_bitmap_part,
170 lcd_remote_mono_bitmap,
171 lcd_remote_putsxy,
172 lcd_remote_puts_style,
173 lcd_remote_puts_scroll_style,
174 &lcd_remote_framebuffer[0][0],
175 lcd_remote_update,
176 lcd_remote_update_rect,
178 remote_backlight_on,
179 remote_backlight_off,
180 remote_backlight_set_timeout,
181 #if CONFIG_CHARGING
182 remote_backlight_set_timeout_plugged,
183 #endif
184 #endif /* HAVE_REMOTE_LCD */
185 #if NB_SCREENS == 2
186 {&screens[SCREEN_MAIN], &screens[SCREEN_REMOTE]},
187 #else
188 {&screens[SCREEN_MAIN]},
189 #endif
190 #if defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)
191 lcd_remote_set_foreground,
192 lcd_remote_get_foreground,
193 lcd_remote_set_background,
194 lcd_remote_get_background,
195 lcd_remote_bitmap_part,
196 lcd_remote_bitmap,
197 #endif
198 viewport_set_defaults,
200 /* list */
201 gui_synclist_init,
202 gui_synclist_set_nb_items,
203 gui_synclist_set_icon_callback,
204 gui_synclist_get_nb_items,
205 gui_synclist_get_sel_pos,
206 gui_synclist_draw,
207 gui_synclist_select_item,
208 gui_synclist_add_item,
209 gui_synclist_del_item,
210 gui_synclist_limit_scroll,
211 gui_synclist_do_button,
212 gui_synclist_set_title,
214 /* button */
215 button_get,
216 button_get_w_tmo,
217 button_status,
218 button_clear_queue,
219 button_queue_count,
220 #ifdef HAS_BUTTON_HOLD
221 button_hold,
222 #endif
224 /* file */
225 (open_func)PREFIX(open),
226 PREFIX(close),
227 (read_func)PREFIX(read),
228 PREFIX(lseek),
229 (creat_func)PREFIX(creat),
230 (write_func)PREFIX(write),
231 PREFIX(remove),
232 PREFIX(rename),
233 PREFIX(ftruncate),
234 PREFIX(filesize),
235 fdprintf,
236 read_line,
237 settings_parseline,
238 ata_sleep,
239 #ifndef SIMULATOR
240 ata_disk_is_active,
241 #endif
242 ata_spin,
243 ata_spindown,
244 reload_directory,
245 create_numbered_filename,
246 file_exists,
248 /* dir */
249 opendir,
250 closedir,
251 readdir,
252 mkdir,
253 rmdir,
254 dir_exists,
256 /* kernel/ system */
257 PREFIX(sleep),
258 yield,
259 &current_tick,
260 default_event_handler,
261 default_event_handler_ex,
262 threads,
263 create_thread,
264 thread_exit,
265 thread_wait,
266 #if (CONFIG_CODEC == SWCODEC)
267 mutex_init,
268 mutex_lock,
269 mutex_unlock,
270 align_buffer,
271 #endif
273 reset_poweroff_timer,
274 #ifndef SIMULATOR
275 system_memory_guard,
276 &cpu_frequency,
278 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
279 #ifdef CPU_BOOST_LOGGING
280 cpu_boost_,
281 #else
282 cpu_boost,
283 #endif
284 #endif /* HAVE_ADJUSTABLE_CPU_FREQ */
285 #endif /* !SIMULATOR */
286 #ifdef HAVE_SCHEDULER_BOOSTCTRL
287 trigger_cpu_boost,
288 cancel_cpu_boost,
289 #endif
290 #ifdef CACHE_FUNCTIONS_AS_CALL
291 flush_icache,
292 invalidate_icache,
293 #endif
294 timer_register,
295 timer_unregister,
296 timer_set_period,
298 queue_init,
299 queue_delete,
300 queue_post,
301 queue_wait_w_tmo,
302 #if CONFIG_CODEC == SWCODEC
303 queue_enable_queue_send,
304 queue_empty,
305 queue_wait,
306 queue_send,
307 queue_reply,
308 #endif
309 usb_acknowledge,
310 #ifdef RB_PROFILE
311 profile_thread,
312 profstop,
313 profile_func_enter,
314 profile_func_exit,
315 #endif
317 #ifdef SIMULATOR
318 /* special simulator hooks */
319 #if defined(HAVE_LCD_BITMAP) && LCD_DEPTH < 8
320 sim_lcd_ex_init,
321 sim_lcd_ex_update_rect,
322 #endif
323 #endif
325 /* strings and memory */
326 snprintf,
327 vsnprintf,
328 strcpy,
329 strncpy,
330 strlen,
331 strrchr,
332 strcmp,
333 strncmp,
334 strcasecmp,
335 strncasecmp,
336 memset,
337 memcpy,
338 memmove,
339 _ctype_,
340 atoi,
341 strchr,
342 strcat,
343 memchr,
344 memcmp,
345 strcasestr,
346 strtok_r,
347 /* unicode stuff */
348 utf8decode,
349 iso_decode,
350 utf16LEdecode,
351 utf16BEdecode,
352 utf8encode,
353 utf8length,
354 utf8seek,
356 /* sound */
357 sound_set,
358 sound_default,
359 sound_min,
360 sound_max,
361 sound_unit,
362 sound_val2phys,
363 #ifndef SIMULATOR
364 mp3_play_data,
365 mp3_play_pause,
366 mp3_play_stop,
367 mp3_is_playing,
368 #if CONFIG_CODEC != SWCODEC
369 bitswap,
370 #endif
371 #endif
372 #if CONFIG_CODEC == SWCODEC
373 &audio_master_sampr_list[0],
374 &hw_freq_sampr[0],
375 pcm_apply_settings,
376 pcm_play_data,
377 pcm_play_stop,
378 pcm_set_frequency,
379 pcm_is_playing,
380 pcm_is_paused,
381 pcm_play_pause,
382 pcm_get_bytes_waiting,
383 pcm_calculate_peaks,
384 pcm_play_lock,
385 pcm_play_unlock,
386 #ifdef HAVE_RECORDING
387 &rec_freq_sampr[0],
388 pcm_init_recording,
389 pcm_close_recording,
390 pcm_record_data,
391 pcm_record_more,
392 pcm_stop_recording,
393 pcm_calculate_rec_peaks,
394 audio_set_recording_gain,
395 #endif /* HAVE_RECORDING */
396 #if INPUT_SRC_CAPS != 0
397 audio_set_output_source,
398 audio_set_input_source,
399 #endif
400 dsp_set_crossfeed,
401 dsp_set_eq,
402 dsp_dither_enable,
403 dsp_configure,
404 dsp_process,
405 #endif /* CONFIG_CODEC == SWCODEC */
407 /* playback control */
408 playlist_amount,
409 playlist_resume,
410 playlist_start,
411 PREFIX(audio_play),
412 audio_stop,
413 audio_pause,
414 audio_resume,
415 audio_next,
416 audio_prev,
417 audio_ff_rewind,
418 audio_next_track,
419 audio_status,
420 audio_has_changed_track,
421 audio_current_track,
422 audio_flush_and_reload_tracks,
423 audio_get_file_pos,
424 #if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
425 mpeg_get_last_header,
426 #endif
427 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) || \
428 (CONFIG_CODEC == SWCODEC)
429 sound_set_pitch,
430 #endif
432 #if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
433 /* MAS communication */
434 mas_readmem,
435 mas_writemem,
436 mas_readreg,
437 mas_writereg,
438 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
439 mas_codec_writereg,
440 mas_codec_readreg,
441 i2c_begin,
442 i2c_end,
443 i2c_write,
444 #endif
445 #endif /* !SIMULATOR && CONFIG_CODEC != SWCODEC */
447 /* menu */
448 do_menu,
449 /* statusbars */
450 &statusbars,
451 gui_syncstatusbar_draw,
452 /* options */
453 find_setting,
454 option_screen,
455 set_option,
456 set_bool_options,
457 set_int,
458 set_bool,
459 #ifdef HAVE_LCD_COLOR
460 set_color,
461 #endif
463 /* action handling */
464 get_custom_action,
465 get_action,
466 action_userabort,
468 /* power */
469 battery_level,
470 battery_level_safe,
471 battery_time,
472 #ifndef SIMULATOR
473 battery_voltage,
474 #endif
475 #if CONFIG_CHARGING
476 charger_inserted,
477 # if CONFIG_CHARGING == CHARGING_MONITOR
478 charging_state,
479 # endif
480 #endif
481 #ifdef HAVE_USB_POWER
482 usb_powered,
483 #endif
485 /* misc */
486 srand,
487 rand,
488 (qsort_func)qsort,
489 kbd_input,
490 get_time,
491 set_time,
492 #if CONFIG_RTC
493 mktime,
494 #endif
495 plugin_get_buffer,
496 plugin_get_audio_buffer,
497 plugin_tsr,
498 plugin_get_current_filename,
499 #ifdef PLUGIN_USE_IRAM
500 plugin_iram_init,
501 #endif
502 #if defined(DEBUG) || defined(SIMULATOR)
503 debugf,
504 #endif
505 #ifdef ROCKBOX_HAS_LOGF
506 _logf,
507 #endif
508 &global_settings,
509 &global_status,
510 talk_disable,
511 #if CONFIG_CODEC == SWCODEC
512 codec_load_file,
513 get_codec_filename,
514 get_metadata,
515 #endif
516 mp3info,
517 count_mp3_frames,
518 create_xing_header,
519 find_next_frame,
520 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
521 peak_meter_scale_value,
522 peak_meter_set_use_dbfs,
523 peak_meter_get_use_dbfs,
524 #endif
525 #ifdef HAVE_LCD_BITMAP
526 read_bmp_file,
527 screen_dump_set_hook,
528 #endif
529 show_logo,
530 tree_get_context,
531 set_current_file,
532 set_dirfilter,
534 #ifdef HAVE_WHEEL_POSITION
535 wheel_status,
536 wheel_send_events,
537 #endif
539 #ifdef IRIVER_H100_SERIES
540 /* Routines for the iriver_flash -plugin. */
541 detect_original_firmware,
542 detect_flashed_ramimage,
543 detect_flashed_romimage,
544 #endif
545 led,
546 #if (CONFIG_CODEC == SWCODEC)
547 bufopen,
548 bufalloc,
549 bufclose,
550 bufseek,
551 bufadvance,
552 bufread,
553 bufgetdata,
554 bufgettail,
555 bufcuttail,
557 buf_get_offset,
558 buf_handle_offset,
559 buf_request_buffer_handle,
560 buf_set_base_handle,
561 buf_used,
562 #endif
564 #ifdef HAVE_TAGCACHE
565 tagcache_search,
566 tagcache_search_set_uniqbuf,
567 tagcache_search_add_filter,
568 tagcache_get_next,
569 tagcache_retrieve,
570 tagcache_search_finish,
571 #endif
573 #ifdef HAVE_ALBUMART
574 find_albumart,
575 search_albumart_files,
576 #endif
578 /* new stuff at the end, sort into place next time
579 the API gets incompatible */
581 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
582 backlight_set_brightness,
583 #endif /* HAVE_BACKLIGHT_BRIGHTNESS */
584 #ifdef HAVE_LCD_INVERT
585 lcd_set_invert_display,
586 #endif /* HAVE_LCD_INVERT */
589 int plugin_load(const char* plugin, void* parameter)
591 int rc;
592 struct plugin_header *hdr;
593 #ifdef SIMULATOR
594 void *pd;
595 #else /* !SIMULATOR */
596 int fd;
597 ssize_t readsize;
598 #if NUM_CORES > 1
599 unsigned my_core;
600 #endif
601 #endif /* !SIMULATOR */
602 int xm, ym;
603 #ifdef HAVE_REMOTE_LCD
604 int rxm, rym;
605 #endif
607 #if LCD_DEPTH > 1
608 fb_data* old_backdrop;
609 #endif
611 if (pfn_tsr_exit != NULL) /* if we have a resident old plugin: */
613 if (pfn_tsr_exit(!strcmp(current_plugin, plugin)) == false )
615 /* not allowing another plugin to load */
616 return PLUGIN_OK;
618 pfn_tsr_exit = NULL;
619 plugin_loaded = false;
622 gui_syncsplash(0, ID2P(LANG_WAIT));
623 strcpy(current_plugin, plugin);
625 #ifdef SIMULATOR
626 hdr = sim_plugin_load((char *)plugin, &pd);
627 if (pd == NULL) {
628 gui_syncsplash(HZ*2, str(LANG_PLUGIN_CANT_OPEN), plugin);
629 return -1;
631 if (hdr == NULL
632 || hdr->magic != PLUGIN_MAGIC
633 || hdr->target_id != TARGET_ID) {
634 sim_plugin_close(pd);
635 gui_syncsplash(HZ*2, str(LANG_PLUGIN_WRONG_MODEL));
636 return -1;
638 if (hdr->api_version > PLUGIN_API_VERSION
639 || hdr->api_version < PLUGIN_MIN_API_VERSION) {
640 sim_plugin_close(pd);
641 gui_syncsplash(HZ*2, str(LANG_PLUGIN_WRONG_VERSION));
642 return -1;
644 #else
645 fd = open(plugin, O_RDONLY);
646 if (fd < 0) {
647 gui_syncsplash(HZ*2, str(LANG_PLUGIN_CANT_OPEN), plugin);
648 return fd;
650 #if NUM_CORES > 1
651 /* Make sure COP cache is flushed and invalidated before loading */
652 my_core = switch_core(CURRENT_CORE ^ 1);
653 invalidate_icache();
654 switch_core(my_core);
655 #endif
657 readsize = read(fd, pluginbuf, PLUGIN_BUFFER_SIZE);
658 close(fd);
660 if (readsize < 0) {
661 gui_syncsplash(HZ*2, str(LANG_READ_FAILED), plugin);
662 return -1;
664 hdr = (struct plugin_header *)pluginbuf;
666 if ((unsigned)readsize <= sizeof(struct plugin_header)
667 || hdr->magic != PLUGIN_MAGIC
668 || hdr->target_id != TARGET_ID
669 || hdr->load_addr != pluginbuf
670 || hdr->end_addr > pluginbuf + PLUGIN_BUFFER_SIZE) {
671 gui_syncsplash(HZ*2, str(LANG_PLUGIN_WRONG_MODEL));
672 return -1;
674 if (hdr->api_version > PLUGIN_API_VERSION
675 || hdr->api_version < PLUGIN_MIN_API_VERSION) {
676 gui_syncsplash(HZ*2, str(LANG_PLUGIN_WRONG_VERSION));
677 return -1;
679 plugin_size = hdr->end_addr - pluginbuf;
681 /* zero out bss area only, above guards end of pluginbuf */
682 if (plugin_size > readsize)
683 memset(pluginbuf + readsize, 0, plugin_size - readsize);
684 #endif
686 plugin_loaded = true;
688 xm = lcd_getxmargin();
689 ym = lcd_getymargin();
690 lcd_setmargins(0,0);
692 #if defined HAVE_LCD_BITMAP && LCD_DEPTH > 1
693 old_backdrop = lcd_get_backdrop();
694 #endif
695 lcd_clear_display();
696 lcd_update();
698 #ifdef HAVE_REMOTE_LCD
699 rxm = lcd_remote_getxmargin();
700 rym = lcd_remote_getymargin();
701 lcd_remote_setmargins(0, 0);
702 lcd_remote_clear_display();
703 lcd_remote_update();
704 #endif
706 invalidate_icache();
708 rc = hdr->entry_point((struct plugin_api*) &rockbox_api, parameter);
709 /* explicitly casting the pointer here to avoid touching every plugin. */
711 button_clear_queue();
713 #ifdef HAVE_LCD_BITMAP
714 #if LCD_DEPTH > 1
715 lcd_set_backdrop(old_backdrop);
716 #ifdef HAVE_LCD_COLOR
717 lcd_set_drawinfo(DRMODE_SOLID, global_settings.fg_color,
718 global_settings.bg_color);
719 #else
720 lcd_set_drawinfo(DRMODE_SOLID, LCD_DEFAULT_FG, LCD_DEFAULT_BG);
721 #endif
722 #else /* LCD_DEPTH == 1 */
723 lcd_set_drawmode(DRMODE_SOLID);
724 #endif /* LCD_DEPTH */
725 #endif /* HAVE_LCD_BITMAP */
727 /* restore margins */
728 lcd_setmargins(xm,ym);
729 lcd_clear_display();
730 lcd_update();
732 #ifdef HAVE_REMOTE_LCD
733 #if LCD_REMOTE_DEPTH > 1
734 lcd_remote_set_drawinfo(DRMODE_SOLID, LCD_REMOTE_DEFAULT_FG,
735 LCD_REMOTE_DEFAULT_BG);
736 #else
737 lcd_remote_set_drawmode(DRMODE_SOLID);
738 #endif
739 lcd_remote_setmargins(rxm, rym);
740 lcd_remote_clear_display();
743 lcd_remote_update();
746 #endif
748 if (pfn_tsr_exit == NULL)
749 plugin_loaded = false;
751 sim_plugin_close(pd);
753 switch (rc) {
754 case PLUGIN_OK:
755 break;
757 case PLUGIN_USB_CONNECTED:
758 return PLUGIN_USB_CONNECTED;
760 default:
761 gui_syncsplash(HZ*2, str(LANG_PLUGIN_ERROR));
762 break;
764 return PLUGIN_OK;
767 /* Returns a pointer to the portion of the plugin buffer that is not already
768 being used. If no plugin is loaded, returns the entire plugin buffer */
769 void* plugin_get_buffer(size_t *buffer_size)
771 int buffer_pos;
773 if (plugin_loaded)
775 if (plugin_size >= PLUGIN_BUFFER_SIZE)
776 return NULL;
778 *buffer_size = PLUGIN_BUFFER_SIZE-plugin_size;
779 buffer_pos = plugin_size;
781 else
783 *buffer_size = PLUGIN_BUFFER_SIZE;
784 buffer_pos = 0;
787 return &pluginbuf[buffer_pos];
790 /* Returns a pointer to the mp3 buffer.
791 Playback gets stopped, to avoid conflicts.
792 Talk buffer is stolen as well.
794 void* plugin_get_audio_buffer(size_t *buffer_size)
796 #if CONFIG_CODEC == SWCODEC
797 return audio_get_buffer(true, buffer_size);
798 #else
799 audio_stop();
800 talk_buffer_steal(); /* we use the mp3 buffer, need to tell */
801 *buffer_size = audiobufend - audiobuf;
802 return audiobuf;
803 #endif
806 #ifdef PLUGIN_USE_IRAM
807 /* Initializes plugin IRAM */
808 void plugin_iram_init(char *iramstart, char *iramcopy, size_t iram_size,
809 char *iedata, size_t iedata_size)
811 /* We need to stop audio playback in order to use codec IRAM */
812 audio_hard_stop();
813 memcpy(iramstart, iramcopy, iram_size);
814 memset(iedata, 0, iedata_size);
815 memset(iramcopy, 0, iram_size);
816 #if NUM_CORES > 1
817 /* writeback cleared iedata and iramcopy areas */
818 flush_icache();
819 #endif
821 #endif /* PLUGIN_USE_IRAM */
823 /* The plugin wants to stay resident after leaving its main function, e.g.
824 runs from timer or own thread. The callback is registered to later
825 instruct it to free its resources before a new plugin gets loaded. */
826 void plugin_tsr(bool (*exit_callback)(bool))
828 pfn_tsr_exit = exit_callback; /* remember the callback for later */
831 char *plugin_get_current_filename(void)
833 return current_plugin;