diff options
Diffstat (limited to 'apps/plugin.h')
-rw-r--r-- | apps/plugin.h | 113 |
1 files changed, 55 insertions, 58 deletions
diff --git a/apps/plugin.h b/apps/plugin.h index f935809949..bf8f34ab9e 100644 --- a/apps/plugin.h +++ b/apps/plugin.h | |||
@@ -90,44 +90,23 @@ | |||
90 | #define PREFIX(_x_) _x_ | 90 | #define PREFIX(_x_) _x_ |
91 | #endif | 91 | #endif |
92 | 92 | ||
93 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ | ||
94 | |||
93 | /* increase this every time the api struct changes */ | 95 | /* increase this every time the api struct changes */ |
94 | #define PLUGIN_API_VERSION 54 | 96 | #define PLUGIN_API_VERSION 1 |
95 | 97 | ||
96 | /* update this to latest version if a change to the api struct breaks | 98 | /* update this to latest version if a change to the api struct breaks |
97 | backwards compatibility (and please take the opportunity to sort in any | 99 | backwards compatibility (and please take the opportunity to sort in any |
98 | new function which are "waiting" at the end of the function table) */ | 100 | new function which are "waiting" at the end of the function table) */ |
99 | #define PLUGIN_MIN_API_VERSION 51 | 101 | #define PLUGIN_MIN_API_VERSION 1 |
100 | 102 | ||
101 | /* plugin return codes */ | 103 | /* plugin return codes */ |
102 | enum plugin_status { | 104 | enum plugin_status { |
103 | PLUGIN_OK = 0, | 105 | PLUGIN_OK = 0, |
104 | PLUGIN_USB_CONNECTED, | 106 | PLUGIN_USB_CONNECTED, |
105 | 107 | PLUGIN_ERROR = -1, | |
106 | PLUGIN_WRONG_API_VERSION = -1, | ||
107 | PLUGIN_WRONG_MODEL = -2, | ||
108 | PLUGIN_ERROR = -3, | ||
109 | }; | 108 | }; |
110 | 109 | ||
111 | /* different (incompatible) plugin models */ | ||
112 | enum model { | ||
113 | PLAYER, | ||
114 | RECORDER | ||
115 | }; | ||
116 | |||
117 | #ifdef HAVE_LCD_CHARCELLS | ||
118 | #define MODEL PLAYER | ||
119 | #else | ||
120 | #define MODEL RECORDER | ||
121 | #endif | ||
122 | |||
123 | /* compatibility test macro */ | ||
124 | #define TEST_PLUGIN_API(_api_) \ | ||
125 | do { \ | ||
126 | int _rc_ = _api_->plugin_test(PLUGIN_API_VERSION, MODEL, MEM); \ | ||
127 | if (_rc_<0) \ | ||
128 | return _rc_; \ | ||
129 | } while(0) | ||
130 | |||
131 | /* NOTE: To support backwards compatibility, only add new functions at | 110 | /* NOTE: To support backwards compatibility, only add new functions at |
132 | the end of the structure. Every time you add a new function, | 111 | the end of the structure. Every time you add a new function, |
133 | remember to increase PLUGIN_API_VERSION. If you make changes to the | 112 | remember to increase PLUGIN_API_VERSION. If you make changes to the |
@@ -135,10 +114,6 @@ do { \ | |||
135 | version | 114 | version |
136 | */ | 115 | */ |
137 | struct plugin_api { | 116 | struct plugin_api { |
138 | /* these two fields must always be first, to ensure | ||
139 | TEST_PLUGIN_API will always work */ | ||
140 | int version; | ||
141 | int (*plugin_test)(int api_version, int model, int memsize); | ||
142 | 117 | ||
143 | /* lcd */ | 118 | /* lcd */ |
144 | void (*lcd_set_contrast)(int x); | 119 | void (*lcd_set_contrast)(int x); |
@@ -198,6 +173,7 @@ struct plugin_api { | |||
198 | struct font* (*font_get)(int font); | 173 | struct font* (*font_get)(int font); |
199 | int (*font_getstringsize)(const unsigned char *str, int *w, int *h, | 174 | int (*font_getstringsize)(const unsigned char *str, int *w, int *h, |
200 | int fontnumber); | 175 | int fontnumber); |
176 | int (*font_get_width)(struct font* pf, unsigned short char_code); | ||
201 | #endif | 177 | #endif |
202 | void (*backlight_on)(void); | 178 | void (*backlight_on)(void); |
203 | void (*backlight_off)(void); | 179 | void (*backlight_off)(void); |
@@ -314,9 +290,18 @@ struct plugin_api { | |||
314 | char *(*strcat)(char *s1, const char *s2); | 290 | char *(*strcat)(char *s1, const char *s2); |
315 | int (*memcmp)(const void *s1, const void *s2, size_t n); | 291 | int (*memcmp)(const void *s1, const void *s2, size_t n); |
316 | char *(*strcasestr) (const char* phaystack, const char* pneedle); | 292 | char *(*strcasestr) (const char* phaystack, const char* pneedle); |
293 | /* unicode stuff */ | ||
294 | const unsigned char* (*utf8decode)(const unsigned char *utf8, unsigned short *ucs); | ||
295 | unsigned char* (*iso_decode)(const unsigned char *iso, unsigned char *utf8, int cp, int count); | ||
296 | unsigned char* (*utf16LEdecode)(const unsigned char *utf16, unsigned char *utf8, unsigned int count); | ||
297 | unsigned char* (*utf16BEdecode)(const unsigned char *utf16, unsigned char *utf8, unsigned int count); | ||
298 | unsigned char* (*utf8encode)(unsigned long ucs, unsigned char *utf8); | ||
299 | unsigned long (*utf8length)(const unsigned char *utf8); | ||
317 | 300 | ||
318 | /* sound */ | 301 | /* sound */ |
319 | void (*sound_set)(int setting, int value); | 302 | void (*sound_set)(int setting, int value); |
303 | int (*sound_min)(int setting); | ||
304 | int (*sound_max)(int setting); | ||
320 | #ifndef SIMULATOR | 305 | #ifndef SIMULATOR |
321 | void (*mp3_play_data)(const unsigned char* start, int size, void (*get_more)(unsigned char** start, int* size)); | 306 | void (*mp3_play_data)(const unsigned char* start, int size, void (*get_more)(unsigned char** start, int* size)); |
322 | void (*mp3_play_pause)(bool play); | 307 | void (*mp3_play_pause)(bool play); |
@@ -378,6 +363,23 @@ struct plugin_api { | |||
378 | int *rundb_fd; | 363 | int *rundb_fd; |
379 | int *rundb_initialized; | 364 | int *rundb_initialized; |
380 | 365 | ||
366 | /* menu */ | ||
367 | int (*menu_init)(const struct menu_item* mitems, int count, | ||
368 | int (*callback)(int, int), | ||
369 | const char *button1, const char *button2, const char *button3); | ||
370 | void (*menu_exit)(int menu); | ||
371 | int (*menu_show)(int m); | ||
372 | bool (*menu_run)(int menu); | ||
373 | int (*menu_cursor)(int menu); | ||
374 | char* (*menu_description)(int menu, int position); | ||
375 | void (*menu_delete)(int menu, int position); | ||
376 | int (*menu_count)(int menu); | ||
377 | bool (*menu_moveup)(int menu); | ||
378 | bool (*menu_movedown)(int menu); | ||
379 | void (*menu_draw)(int menu); | ||
380 | void (*menu_insert)(int menu, int position, char *desc, bool (*function) (void)); | ||
381 | void (*menu_set_cursor)(int menu, int position); | ||
382 | |||
381 | /* misc */ | 383 | /* misc */ |
382 | void (*srand)(unsigned int seed); | 384 | void (*srand)(unsigned int seed); |
383 | int (*rand)(void); | 385 | int (*rand)(void); |
@@ -416,42 +418,37 @@ struct plugin_api { | |||
416 | #ifdef HAVE_LCD_BITMAP | 418 | #ifdef HAVE_LCD_BITMAP |
417 | int (*read_bmp_file)(char* filename, int *get_width, int *get_height, | 419 | int (*read_bmp_file)(char* filename, int *get_width, int *get_height, |
418 | char *bitmap, int maxsize); | 420 | char *bitmap, int maxsize); |
421 | void (*screen_dump_set_hook)(void (*hook)(int fh)); | ||
419 | #endif | 422 | #endif |
420 | int (*show_logo)(void); | 423 | int (*show_logo)(void); |
421 | 424 | ||
422 | /* new stuff at the end, sort into place next time | 425 | /* new stuff at the end, sort into place next time |
423 | the API gets incompatible */ | 426 | the API gets incompatible */ |
424 | 427 | ||
425 | int (*menu_init)(const struct menu_item* mitems, int count, | 428 | }; |
426 | int (*callback)(int, int), | ||
427 | const char *button1, const char *button2, const char *button3); | ||
428 | void (*menu_exit)(int menu); | ||
429 | int (*menu_show)(int m); | ||
430 | bool (*menu_run)(int menu); | ||
431 | int (*menu_cursor)(int menu); | ||
432 | char* (*menu_description)(int menu, int position); | ||
433 | void (*menu_delete)(int menu, int position); | ||
434 | int (*menu_count)(int menu); | ||
435 | bool (*menu_moveup)(int menu); | ||
436 | bool (*menu_movedown)(int menu); | ||
437 | void (*menu_draw)(int menu); | ||
438 | void (*menu_insert)(int menu, int position, char *desc, bool (*function) (void)); | ||
439 | void (*menu_set_cursor)(int menu, int position); | ||
440 | 429 | ||
441 | #ifdef HAVE_LCD_BITMAP | 430 | #ifndef SIMULATOR |
442 | void (*screen_dump_set_hook)(void (*hook)(int fh)); | 431 | /* plugin header */ |
443 | int (*font_get_width)(struct font* pf, unsigned short char_code); | 432 | struct plugin_header { |
444 | #endif | 433 | unsigned long magic; |
445 | const unsigned char* (*utf8decode)(const unsigned char *utf8, unsigned short *ucs); | 434 | unsigned short target_id; |
446 | unsigned char* (*iso_decode)(const unsigned char *iso, unsigned char *utf8, int cp, int count); | 435 | unsigned short api_version; |
447 | unsigned char* (*utf16LEdecode)(const unsigned char *utf16, unsigned char *utf8, unsigned int count); | 436 | unsigned char *load_addr; |
448 | unsigned char* (*utf16BEdecode)(const unsigned char *utf16, unsigned char *utf8, unsigned int count); | 437 | unsigned char *end_addr; |
449 | unsigned char* (*utf8encode)(unsigned long ucs, unsigned char *utf8); | 438 | enum plugin_status(*entry_point)(struct plugin_api*, void*); |
450 | unsigned long (*utf8length)(const unsigned char *utf8); | ||
451 | |||
452 | int (*sound_min)(int setting); | ||
453 | int (*sound_max)(int setting); | ||
454 | }; | 439 | }; |
440 | #ifdef PLUGIN | ||
441 | extern unsigned char plugin_start_addr[]; | ||
442 | extern unsigned char plugin_end_addr[]; | ||
443 | #define PLUGIN_HEADER \ | ||
444 | const struct plugin_header __header \ | ||
445 | __attribute__ ((section (".header")))= { \ | ||
446 | PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \ | ||
447 | plugin_start_addr, plugin_end_addr, plugin_start }; | ||
448 | #endif | ||
449 | #else /* SIMULATOR */ | ||
450 | #define PLUGIN_HEADER | ||
451 | #endif | ||
455 | 452 | ||
456 | int plugin_load(const char* plugin, void* parameter); | 453 | int plugin_load(const char* plugin, void* parameter); |
457 | void* plugin_get_buffer(int *buffer_size); | 454 | void* plugin_get_buffer(int *buffer_size); |