2003-06-29 16:33:04 +00:00
|
|
|
|
/***************************************************************************
|
|
|
|
|
* __________ __ ___.
|
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
|
* $Id$
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2002 Bj<EFBFBD>rn Stenberg
|
|
|
|
|
*
|
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
|
*
|
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
|
* KIND, either express or implied.
|
|
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
#ifndef _PLUGIN_H_
|
|
|
|
|
#define _PLUGIN_H_
|
|
|
|
|
|
|
|
|
|
/* instruct simulator code to not redefine any symbols when compiling plugins.
|
|
|
|
|
(the PLUGIN macro is defined in apps/plugins/Makefile) */
|
|
|
|
|
#ifdef PLUGIN
|
|
|
|
|
#define NO_REDEFINES_PLEASE
|
|
|
|
|
#endif
|
|
|
|
|
|
2003-07-13 22:15:19 +00:00
|
|
|
|
#ifndef MEM
|
|
|
|
|
#define MEM 2
|
|
|
|
|
#endif
|
|
|
|
|
|
2003-06-29 16:33:04 +00:00
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include "config.h"
|
|
|
|
|
#include "dir.h"
|
|
|
|
|
#include "kernel.h"
|
|
|
|
|
#include "button.h"
|
|
|
|
|
#include "font.h"
|
|
|
|
|
#include "system.h"
|
|
|
|
|
#include "lcd.h"
|
2003-07-20 21:29:16 +00:00
|
|
|
|
#include "id3.h"
|
|
|
|
|
#include "mpeg.h"
|
2004-01-30 22:30:40 +00:00
|
|
|
|
#include "mp3_playback.h"
|
|
|
|
|
#include "settings.h"
|
2004-04-30 20:37:11 +00:00
|
|
|
|
#include "thread.h"
|
2003-07-24 09:35:32 +00:00
|
|
|
|
|
2004-06-10 13:29:52 +00:00
|
|
|
|
#ifdef PLUGIN
|
|
|
|
|
#if defined(DEBUG) || defined(SIMULATOR)
|
|
|
|
|
#define DEBUGF rb->debugf
|
|
|
|
|
#define LDEBUGF rb->debugf
|
|
|
|
|
#else
|
|
|
|
|
#define DEBUGF(...)
|
|
|
|
|
#define LDEBUGF(...)
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
2003-06-29 16:33:04 +00:00
|
|
|
|
/* increase this every time the api struct changes */
|
2004-06-16 19:35:20 +00:00
|
|
|
|
#define PLUGIN_API_VERSION 16
|
2003-07-25 23:04:59 +00:00
|
|
|
|
|
|
|
|
|
/* update this to latest version if a change to the api struct breaks
|
2004-02-03 23:56:25 +00:00
|
|
|
|
backwards compatibility (and please take the opportunity to sort in any
|
|
|
|
|
new function which are "waiting" at the end of the function table) */
|
2004-04-28 22:20:27 +00:00
|
|
|
|
#define PLUGIN_MIN_API_VERSION 10
|
2003-06-29 16:33:04 +00:00
|
|
|
|
|
|
|
|
|
/* plugin return codes */
|
|
|
|
|
enum plugin_status {
|
|
|
|
|
PLUGIN_OK = 0,
|
|
|
|
|
PLUGIN_USB_CONNECTED,
|
|
|
|
|
|
|
|
|
|
PLUGIN_WRONG_API_VERSION = -1,
|
|
|
|
|
PLUGIN_WRONG_MODEL = -2,
|
|
|
|
|
PLUGIN_ERROR = -3,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* different (incompatible) plugin models */
|
|
|
|
|
enum model {
|
|
|
|
|
PLAYER,
|
|
|
|
|
RECORDER
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
|
|
|
|
#define MODEL PLAYER
|
|
|
|
|
#else
|
|
|
|
|
#define MODEL RECORDER
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* compatibility test macro */
|
|
|
|
|
#define TEST_PLUGIN_API(_api_) \
|
|
|
|
|
do { \
|
2003-07-13 22:15:19 +00:00
|
|
|
|
int _rc_ = _api_->plugin_test(PLUGIN_API_VERSION, MODEL, MEM); \
|
2003-06-29 16:33:04 +00:00
|
|
|
|
if (_rc_<0) \
|
|
|
|
|
return _rc_; \
|
|
|
|
|
} while(0)
|
|
|
|
|
|
2003-07-25 23:04:59 +00:00
|
|
|
|
/* NOTE: To support backwards compatibility, only add new functions at
|
|
|
|
|
the end of the structure. Every time you add a new function,
|
|
|
|
|
remember to increase PLUGIN_API_VERSION. If you make changes to the
|
|
|
|
|
existing APIs then also update PLUGIN_MIN_API_VERSION to current
|
|
|
|
|
version
|
|
|
|
|
*/
|
2003-06-29 16:33:04 +00:00
|
|
|
|
struct plugin_api {
|
|
|
|
|
/* these two fields must always be first, to ensure
|
|
|
|
|
TEST_PLUGIN_API will always work */
|
|
|
|
|
int version;
|
2003-07-13 22:15:19 +00:00
|
|
|
|
int (*plugin_test)(int api_version, int model, int memsize);
|
2003-06-29 16:33:04 +00:00
|
|
|
|
|
|
|
|
|
/* lcd */
|
|
|
|
|
void (*lcd_clear_display)(void);
|
|
|
|
|
void (*lcd_puts)(int x, int y, unsigned char *string);
|
|
|
|
|
void (*lcd_puts_scroll)(int x, int y, unsigned char* string);
|
|
|
|
|
void (*lcd_stop_scroll)(void);
|
|
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
|
|
|
|
void (*lcd_define_pattern)(int which,char *pattern);
|
2003-07-24 09:35:32 +00:00
|
|
|
|
unsigned char (*lcd_get_locked_pattern)(void);
|
|
|
|
|
void (*lcd_unlock_pattern)(unsigned char pat);
|
|
|
|
|
void (*lcd_putc)(int x, int y, unsigned short ch);
|
2003-06-29 16:33:04 +00:00
|
|
|
|
#else
|
|
|
|
|
void (*lcd_putsxy)(int x, int y, unsigned char *string);
|
|
|
|
|
void (*lcd_bitmap)(unsigned char *src, int x, int y,
|
|
|
|
|
int nx, int ny, bool clear);
|
|
|
|
|
void (*lcd_drawline)(int x1, int y1, int x2, int y2);
|
|
|
|
|
void (*lcd_clearline)(int x1, int y1, int x2, int y2);
|
|
|
|
|
void (*lcd_drawpixel)(int x, int y);
|
|
|
|
|
void (*lcd_clearpixel)(int x, int y);
|
|
|
|
|
void (*lcd_setfont)(int font);
|
|
|
|
|
void (*lcd_clearrect)(int x, int y, int nx, int ny);
|
|
|
|
|
void (*lcd_fillrect)(int x, int y, int nx, int ny);
|
|
|
|
|
void (*lcd_drawrect)(int x, int y, int nx, int ny);
|
|
|
|
|
void (*lcd_invertrect)(int x, int y, int nx, int ny);
|
|
|
|
|
int (*lcd_getstringsize)(unsigned char *str, int *w, int *h);
|
|
|
|
|
void (*lcd_update)(void);
|
|
|
|
|
void (*lcd_update_rect)(int x, int y, int width, int height);
|
2003-07-09 22:36:23 +00:00
|
|
|
|
void (*progressbar)(int x, int y, int width, int height,
|
|
|
|
|
int percent, int direction);
|
|
|
|
|
void (*slidebar)(int x, int y, int width, int height,
|
|
|
|
|
int percent, int direction);
|
|
|
|
|
void (*scrollbar)(int x, int y, int width, int height, int items,
|
|
|
|
|
int min_shown, int max_shown, int orientation);
|
2003-06-29 16:33:04 +00:00
|
|
|
|
#ifndef SIMULATOR
|
|
|
|
|
void (*lcd_roll)(int pixels);
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* button */
|
|
|
|
|
int (*button_get)(bool block);
|
|
|
|
|
int (*button_get_w_tmo)(int ticks);
|
|
|
|
|
|
|
|
|
|
/* file */
|
|
|
|
|
int (*open)(const char* pathname, int flags);
|
|
|
|
|
int (*close)(int fd);
|
2003-12-08 21:58:38 +00:00
|
|
|
|
ssize_t (*read)(int fd, void* buf, size_t count);
|
|
|
|
|
off_t (*lseek)(int fd, off_t offset, int whence);
|
|
|
|
|
int (*creat)(const char *pathname, mode_t mode);
|
|
|
|
|
ssize_t (*write)(int fd, const void* buf, size_t count);
|
2003-06-29 16:33:04 +00:00
|
|
|
|
int (*remove)(const char* pathname);
|
|
|
|
|
int (*rename)(const char* path, const char* newname);
|
2003-12-08 21:58:38 +00:00
|
|
|
|
int (*ftruncate)(int fd, off_t length);
|
2003-06-29 16:33:04 +00:00
|
|
|
|
int (*filesize)(int fd);
|
|
|
|
|
int (*fprintf)(int fd, const char *fmt, ...);
|
|
|
|
|
int (*read_line)(int fd, char* buffer, int buffer_size);
|
|
|
|
|
|
|
|
|
|
/* dir */
|
2004-04-20 10:15:39 +00:00
|
|
|
|
DIR* (*opendir)(const char* name);
|
2003-06-29 16:33:04 +00:00
|
|
|
|
int (*closedir)(DIR* dir);
|
|
|
|
|
struct dirent* (*readdir)(DIR* dir);
|
|
|
|
|
|
|
|
|
|
/* kernel */
|
|
|
|
|
void (*sleep)(int ticks);
|
|
|
|
|
void (*usb_screen)(void);
|
|
|
|
|
long* current_tick;
|
|
|
|
|
|
|
|
|
|
/* strings and memory */
|
|
|
|
|
int (*snprintf)(char *buf, size_t size, const char *fmt, ...);
|
|
|
|
|
char* (*strcpy)(char *dst, const char *src);
|
|
|
|
|
size_t (*strlen)(const char *str);
|
|
|
|
|
void* (*memset)(void *dst, int c, size_t length);
|
|
|
|
|
void* (*memcpy)(void *out, const void *in, size_t n);
|
|
|
|
|
|
|
|
|
|
/* sound */
|
|
|
|
|
#ifndef SIMULATOR
|
|
|
|
|
#ifdef HAVE_MAS3587F
|
|
|
|
|
int (*mas_codec_readreg)(int reg);
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* misc */
|
|
|
|
|
void (*srand)(unsigned int seed);
|
|
|
|
|
int (*rand)(void);
|
2004-01-08 09:58:58 +00:00
|
|
|
|
void (*splash)(int ticks, bool center, char *fmt, ...);
|
2003-06-29 21:42:15 +00:00
|
|
|
|
void (*qsort)(void *base, size_t nmemb, size_t size,
|
|
|
|
|
int(*compar)(const void *, const void *));
|
2003-07-09 22:36:23 +00:00
|
|
|
|
int (*kbd_input)(char* buffer, int buflen);
|
2003-07-20 22:03:19 +00:00
|
|
|
|
struct mp3entry* (*mpeg_current_track)(void);
|
2003-07-24 10:02:45 +00:00
|
|
|
|
int (*atoi)(const char *str);
|
|
|
|
|
struct tm* (*get_time)(void);
|
2003-07-25 23:04:59 +00:00
|
|
|
|
void* (*plugin_get_buffer)(int* buffer_size);
|
2004-01-30 22:30:40 +00:00
|
|
|
|
|
|
|
|
|
/* new stuff, sort in next time the API gets broken! */
|
2003-12-15 07:44:43 +00:00
|
|
|
|
#ifndef HAVE_LCD_CHARCELLS
|
|
|
|
|
unsigned char* lcd_framebuffer;
|
|
|
|
|
void (*lcd_blit) (unsigned char* p_data, int x, int y, int width, int height, int stride);
|
|
|
|
|
#endif
|
|
|
|
|
void (*yield)(void);
|
2004-01-30 22:30:40 +00:00
|
|
|
|
|
|
|
|
|
void* (*plugin_get_mp3_buffer)(int* buffer_size);
|
|
|
|
|
void (*mpeg_sound_set)(int setting, int value);
|
|
|
|
|
#ifndef SIMULATOR
|
2004-04-30 20:37:11 +00:00
|
|
|
|
void (*mp3_play_init)(void); /* FIXME: remove this next time we break compatibility */
|
2004-01-30 22:30:40 +00:00
|
|
|
|
void (*mp3_play_data)(unsigned char* start, int size, void (*get_more)(unsigned char** start, int* size));
|
|
|
|
|
void (*mp3_play_pause)(bool play);
|
|
|
|
|
void (*mp3_play_stop)(void);
|
|
|
|
|
bool (*mp3_is_playing)(void);
|
|
|
|
|
void (*bitswap)(unsigned char *data, int length);
|
|
|
|
|
#endif
|
|
|
|
|
struct user_settings* global_settings;
|
2004-01-30 23:27:44 +00:00
|
|
|
|
void (*backlight_set_timeout)(int index);
|
2004-02-03 23:56:25 +00:00
|
|
|
|
#ifndef SIMULATOR
|
2004-02-05 09:22:29 +00:00
|
|
|
|
int (*ata_sleep)(void);
|
2004-02-03 23:56:25 +00:00
|
|
|
|
#endif
|
2004-04-28 22:20:27 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
void (*checkbox)(int x, int y, int width, int height, bool checked);
|
|
|
|
|
#endif
|
2004-04-30 20:37:11 +00:00
|
|
|
|
#ifndef SIMULATOR
|
|
|
|
|
int (*plugin_register_timer)(int cycles, int prio, void (*timer_callback)(void));
|
|
|
|
|
void (*plugin_unregister_timer)(void);
|
|
|
|
|
#endif
|
|
|
|
|
void (*plugin_tsr)(void (*exit_callback)(void));
|
|
|
|
|
int (*create_thread)(void* function, void* stack, int stack_size, char *name);
|
2004-05-01 15:14:09 +00:00
|
|
|
|
void (*remove_tread)(int threadnum);
|
2004-04-30 20:37:11 +00:00
|
|
|
|
void (*lcd_set_contrast)(int x);
|
|
|
|
|
|
|
|
|
|
/* playback control */
|
|
|
|
|
void (*mpeg_play)(int offset);
|
|
|
|
|
void (*mpeg_stop)(void);
|
|
|
|
|
void (*mpeg_pause)(void);
|
|
|
|
|
void (*mpeg_resume)(void);
|
|
|
|
|
void (*mpeg_next)(void);
|
|
|
|
|
void (*mpeg_prev)(void);
|
|
|
|
|
void (*mpeg_ff_rewind)(int newtime);
|
|
|
|
|
struct mp3entry* (*mpeg_next_track)(void);
|
|
|
|
|
bool (*mpeg_has_changed_track)(void);
|
|
|
|
|
int (*mpeg_status)(void);
|
2004-05-20 08:06:15 +00:00
|
|
|
|
|
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
struct font* (*font_get)(int font);
|
|
|
|
|
#endif
|
2004-06-10 13:29:52 +00:00
|
|
|
|
#if defined(DEBUG) || defined(SIMULATOR)
|
|
|
|
|
void (*debugf)(char *fmt, ...);
|
|
|
|
|
#endif
|
|
|
|
|
bool (*mp3info)(struct mp3entry *entry, char *filename) ;
|
|
|
|
|
int (*count_mp3_frames)(int fd, int startpos, int filesize,
|
|
|
|
|
void (*progressfunc)(int));
|
|
|
|
|
int (*create_xing_header)(int fd, int startpos, int filesize,
|
|
|
|
|
unsigned char *buf, int num_frames,
|
|
|
|
|
unsigned long header_template,
|
|
|
|
|
void (*progressfunc)(int), bool generate_toc);
|
2004-06-10 13:48:53 +00:00
|
|
|
|
|
|
|
|
|
#ifndef SIMULATOR
|
|
|
|
|
int (*mas_readmem)(int bank, int addr, unsigned long* dest, int len);
|
|
|
|
|
int (*mas_writemem)(int bank, int addr, unsigned long* src, int len);
|
|
|
|
|
int (*mas_readreg)(int reg);
|
|
|
|
|
int (*mas_writereg)(int reg, unsigned int val);
|
|
|
|
|
#ifdef HAVE_MAS3587F
|
|
|
|
|
int (*mas_codec_writereg)(int reg, unsigned int val);
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
2004-06-15 23:16:43 +00:00
|
|
|
|
int (*battery_level)(void);
|
2004-06-16 19:35:20 +00:00
|
|
|
|
int (*set_time)(struct tm *tm);
|
2003-06-29 16:33:04 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* defined by the plugin loader (plugin.c) */
|
|
|
|
|
int plugin_load(char* plugin, void* parameter);
|
2003-07-25 23:04:59 +00:00
|
|
|
|
void* plugin_get_buffer(int *buffer_size);
|
2004-01-30 22:30:40 +00:00
|
|
|
|
void* plugin_get_mp3_buffer(int *buffer_size);
|
2004-04-30 20:37:11 +00:00
|
|
|
|
int plugin_register_timer(int cycles, int prio, void (*timer_callback)(void));
|
|
|
|
|
void plugin_unregister_timer(void);
|
|
|
|
|
void plugin_tsr(void (*exit_callback)(void));
|
2003-06-29 16:33:04 +00:00
|
|
|
|
|
|
|
|
|
/* defined by the plugin */
|
|
|
|
|
enum plugin_status plugin_start(struct plugin_api* rockbox, void* parameter)
|
|
|
|
|
__attribute__ ((section (".entry")));
|
|
|
|
|
|
|
|
|
|
#endif
|