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
44 #include "mp3_playback.h"
48 #ifdef HAVE_LCD_BITMAP
53 #if defined(DEBUG) || defined(SIMULATOR)
54 #define DEBUGF rb->debugf
55 #define LDEBUGF rb->debugf
62 /* increase this every time the api struct changes */
63 #define PLUGIN_API_VERSION 23
65 /* update this to latest version if a change to the api struct breaks
66 backwards compatibility (and please take the opportunity to sort in any
67 new function which are "waiting" at the end of the function table) */
68 #define PLUGIN_MIN_API_VERSION 19
70 /* plugin return codes */
75 PLUGIN_WRONG_API_VERSION
= -1,
76 PLUGIN_WRONG_MODEL
= -2,
80 /* different (incompatible) plugin models */
86 #ifdef HAVE_LCD_CHARCELLS
89 #define MODEL RECORDER
92 /* compatibility test macro */
93 #define TEST_PLUGIN_API(_api_) \
95 int _rc_ = _api_->plugin_test(PLUGIN_API_VERSION, MODEL, MEM); \
100 /* NOTE: To support backwards compatibility, only add new functions at
101 the end of the structure. Every time you add a new function,
102 remember to increase PLUGIN_API_VERSION. If you make changes to the
103 existing APIs then also update PLUGIN_MIN_API_VERSION to current
107 /* these two fields must always be first, to ensure
108 TEST_PLUGIN_API will always work */
110 int (*plugin_test
)(int api_version
, int model
, int memsize
);
113 void (*lcd_clear_display
)(void);
114 void (*lcd_puts
)(int x
, int y
, unsigned char *string
);
115 void (*lcd_puts_scroll
)(int x
, int y
, unsigned char* string
);
116 void (*lcd_stop_scroll
)(void);
117 #ifdef HAVE_LCD_CHARCELLS
118 void (*lcd_define_pattern
)(int which
,char *pattern
);
119 unsigned char (*lcd_get_locked_pattern
)(void);
120 void (*lcd_unlock_pattern
)(unsigned char pat
);
121 void (*lcd_putc
)(int x
, int y
, unsigned short ch
);
123 void (*lcd_putsxy
)(int x
, int y
, const unsigned char *string
);
124 void (*lcd_bitmap
)(const unsigned char *src
, int x
, int y
,
125 int nx
, int ny
, bool clear
);
126 void (*lcd_drawline
)(int x1
, int y1
, int x2
, int y2
);
127 void (*lcd_clearline
)(int x1
, int y1
, int x2
, int y2
);
128 void (*lcd_drawpixel
)(int x
, int y
);
129 void (*lcd_clearpixel
)(int x
, int y
);
130 void (*lcd_setfont
)(int font
);
131 void (*lcd_clearrect
)(int x
, int y
, int nx
, int ny
);
132 void (*lcd_fillrect
)(int x
, int y
, int nx
, int ny
);
133 void (*lcd_drawrect
)(int x
, int y
, int nx
, int ny
);
134 void (*lcd_invertrect
)(int x
, int y
, int nx
, int ny
);
135 int (*lcd_getstringsize
)(unsigned char *str
, int *w
, int *h
);
136 void (*lcd_update
)(void);
137 void (*lcd_update_rect
)(int x
, int y
, int width
, int height
);
138 void (*scrollbar
)(int x
, int y
, int width
, int height
, int items
,
139 int min_shown
, int max_shown
, int orientation
);
141 void (*lcd_roll
)(int pixels
);
146 int (*button_get
)(bool block
);
147 int (*button_get_w_tmo
)(int ticks
);
150 int (*open
)(const char* pathname
, int flags
);
151 int (*close
)(int fd
);
152 ssize_t (*read
)(int fd
, void* buf
, size_t count
);
153 off_t (*lseek
)(int fd
, off_t offset
, int whence
);
154 int (*creat
)(const char *pathname
, mode_t mode
);
155 ssize_t (*write
)(int fd
, const void* buf
, size_t count
);
156 int (*remove
)(const char* pathname
);
157 int (*rename
)(const char* path
, const char* newname
);
158 int (*ftruncate
)(int fd
, off_t length
);
159 int (*filesize
)(int fd
);
160 int (*fprintf
)(int fd
, const char *fmt
, ...);
161 int (*read_line
)(int fd
, char* buffer
, int buffer_size
);
164 DIR* (*opendir
)(const char* name
);
165 int (*closedir
)(DIR* dir
);
166 struct dirent
* (*readdir
)(DIR* dir
);
169 void (*sleep
)(int ticks
);
170 void (*usb_screen
)(void);
173 /* strings and memory */
174 int (*snprintf
)(char *buf
, size_t size
, const char *fmt
, ...);
175 char* (*strcpy
)(char *dst
, const char *src
);
176 size_t (*strlen
)(const char *str
);
177 char * (*strrchr
)(const char *s
, int c
);
178 void* (*memset
)(void *dst
, int c
, size_t length
);
179 void* (*memcpy
)(void *out
, const void *in
, size_t n
);
187 int (*mas_codec_readreg
)(int reg
);
192 void (*srand
)(unsigned int seed
);
194 void (*splash
)(int ticks
, bool center
, char *fmt
, ...);
195 void (*qsort
)(void *base
, size_t nmemb
, size_t size
,
196 int(*compar
)(const void *, const void *));
197 int (*kbd_input
)(char* buffer
, int buflen
);
198 struct mp3entry
* (*mpeg_current_track
)(void);
199 int (*atoi
)(const char *str
);
200 struct tm
* (*get_time
)(void);
201 void* (*plugin_get_buffer
)(int* buffer_size
);
203 /* new stuff, sort in next time the API gets broken! */
204 #ifndef HAVE_LCD_CHARCELLS
205 unsigned char* lcd_framebuffer
;
206 void (*lcd_blit
) (unsigned char* p_data
, int x
, int y
, int width
, int height
, int stride
);
210 void* (*plugin_get_mp3_buffer
)(int* buffer_size
);
211 void (*mpeg_sound_set
)(int setting
, int value
);
213 void (*mp3_play_data
)(unsigned char* start
, int size
, void (*get_more
)(unsigned char** start
, int* size
));
214 void (*mp3_play_pause
)(bool play
);
215 void (*mp3_play_stop
)(void);
216 bool (*mp3_is_playing
)(void);
217 void (*bitswap
)(unsigned char *data
, int length
);
219 struct user_settings
* global_settings
;
220 void (*backlight_set_timeout
)(int index
);
222 int (*ata_sleep
)(void);
224 #ifdef HAVE_LCD_BITMAP
225 void (*checkbox
)(int x
, int y
, int width
, int height
, bool checked
);
228 int (*plugin_register_timer
)(int cycles
, int prio
, void (*timer_callback
)(void));
229 void (*plugin_unregister_timer
)(void);
231 void (*plugin_tsr
)(void (*exit_callback
)(void));
232 int (*create_thread
)(void* function
, void* stack
, int stack_size
, char *name
);
233 void (*remove_thread
)(int threadnum
);
234 void (*lcd_set_contrast
)(int x
);
236 /* playback control */
237 void (*mpeg_play
)(int offset
);
238 void (*mpeg_stop
)(void);
239 void (*mpeg_pause
)(void);
240 void (*mpeg_resume
)(void);
241 void (*mpeg_next
)(void);
242 void (*mpeg_prev
)(void);
243 void (*mpeg_ff_rewind
)(int newtime
);
244 struct mp3entry
* (*mpeg_next_track
)(void);
245 int (*playlist_amount
)(void);
246 int (*mpeg_status
)(void);
247 bool (*mpeg_has_changed_track
)(void);
249 #ifdef HAVE_LCD_BITMAP
250 struct font
* (*font_get
)(int font
);
253 #if defined(DEBUG) || defined(SIMULATOR)
254 void (*debugf
)(char *fmt
, ...);
256 bool (*mp3info
)(struct mp3entry
*entry
, char *filename
) ;
257 int (*count_mp3_frames
)(int fd
, int startpos
, int filesize
,
258 void (*progressfunc
)(int));
259 int (*create_xing_header
)(int fd
, int startpos
, int filesize
,
260 unsigned char *buf
, int num_frames
,
261 unsigned long header_template
,
262 void (*progressfunc
)(int), bool generate_toc
);
265 int (*mas_readmem
)(int bank
, int addr
, unsigned long* dest
, int len
);
266 int (*mas_writemem
)(int bank
, int addr
, unsigned long* src
, int len
);
267 int (*mas_readreg
)(int reg
);
268 int (*mas_writereg
)(int reg
, unsigned int val
);
270 int (*mas_codec_writereg
)(int reg
, unsigned int val
);
273 int (*battery_level
)(void);
274 int (*set_time
)(struct tm
*tm
);
275 void (*reset_poweroff_timer
)(void);
277 void (*backlight_on
)(void);
278 void (*backlight_off
)(void);
280 #ifdef HAVE_LCD_CHARCELLS
281 void (*lcd_icon
)(int icon
, bool enable
);
283 #ifdef HAVE_LCD_BITMAP
284 void (*lcd_puts_style
)(int x
, int y
, unsigned char *str
, int style
);
286 #ifdef HAVE_LCD_CHARCELLS
287 void (*lcd_put_cursor
)(int x
, int y
, char cursor_char
);
288 void (*lcd_remove_cursor
)(void);
290 bool (*settings_parseline
)(char* line
, char** name
, char** value
);
291 int (*strcmp
)(const char *, const char *);
292 int (*button_status
)(void);
293 void (*button_clear_queue
)(void);
294 char *(*strncpy
)(char *dst
, const char *src
, size_t length
);
295 int (*strcasecmp
)(const char *, const char *);
298 /* defined by the plugin loader (plugin.c) */
299 int plugin_load(char* plugin
, void* parameter
);
300 void* plugin_get_buffer(int *buffer_size
);
301 void* plugin_get_mp3_buffer(int *buffer_size
);
302 int plugin_register_timer(int cycles
, int prio
, void (*timer_callback
)(void));
303 void plugin_unregister_timer(void);
304 void plugin_tsr(void (*exit_callback
)(void));
306 /* defined by the plugin */
307 enum plugin_status
plugin_start(struct plugin_api
* rockbox
, void* parameter
)
308 __attribute__ ((section (".entry")));