summaryrefslogtreecommitdiff
path: root/apps/plugin.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugin.h')
-rw-r--r--apps/plugin.h161
1 files changed, 161 insertions, 0 deletions
diff --git a/apps/plugin.h b/apps/plugin.h
new file mode 100644
index 0000000000..3b79edefc6
--- /dev/null
+++ b/apps/plugin.h
@@ -0,0 +1,161 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 Björn Stenberg
11 *
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.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#ifndef _PLUGIN_H_
20#define _PLUGIN_H_
21
22/* instruct simulator code to not redefine any symbols when compiling plugins.
23 (the PLUGIN macro is defined in apps/plugins/Makefile) */
24#ifdef PLUGIN
25#define NO_REDEFINES_PLEASE
26#endif
27
28#include <stdbool.h>
29#include <stdio.h>
30#include <stdlib.h>
31#include "config.h"
32#include "dir.h"
33#include "kernel.h"
34#include "button.h"
35#include "font.h"
36#include "system.h"
37#include "lcd.h"
38
39/* increase this every time the api struct changes */
40#define PLUGIN_API_VERSION 1
41
42/* plugin return codes */
43enum plugin_status {
44 PLUGIN_OK = 0,
45 PLUGIN_USB_CONNECTED,
46
47 PLUGIN_WRONG_API_VERSION = -1,
48 PLUGIN_WRONG_MODEL = -2,
49 PLUGIN_ERROR = -3,
50};
51
52/* different (incompatible) plugin models */
53enum model {
54 PLAYER,
55 RECORDER
56};
57
58#ifdef HAVE_LCD_CHARCELLS
59#define MODEL PLAYER
60#else
61#define MODEL RECORDER
62#endif
63
64/* compatibility test macro */
65#define TEST_PLUGIN_API(_api_) \
66do { \
67 int _rc_ = _api_->plugin_test(PLUGIN_API_VERSION, MODEL); \
68 if (_rc_<0) \
69 return _rc_; \
70} while(0)
71
72struct plugin_api {
73 /* these two fields must always be first, to ensure
74 TEST_PLUGIN_API will always work */
75 int version;
76 int (*plugin_test)(int api_version, int model);
77
78 /* lcd */
79 void (*lcd_clear_display)(void);
80 void (*lcd_puts)(int x, int y, unsigned char *string);
81 void (*lcd_puts_scroll)(int x, int y, unsigned char* string);
82 void (*lcd_stop_scroll)(void);
83#ifdef HAVE_LCD_CHARCELLS
84 void (*lcd_define_pattern)(int which,char *pattern);
85#else
86 void (*lcd_putsxy)(int x, int y, unsigned char *string);
87 void (*lcd_bitmap)(unsigned char *src, int x, int y,
88 int nx, int ny, bool clear);
89 void (*lcd_drawline)(int x1, int y1, int x2, int y2);
90 void (*lcd_clearline)(int x1, int y1, int x2, int y2);
91 void (*lcd_drawpixel)(int x, int y);
92 void (*lcd_clearpixel)(int x, int y);
93 void (*lcd_setfont)(int font);
94 void (*lcd_clearrect)(int x, int y, int nx, int ny);
95 void (*lcd_fillrect)(int x, int y, int nx, int ny);
96 void (*lcd_drawrect)(int x, int y, int nx, int ny);
97 void (*lcd_invertrect)(int x, int y, int nx, int ny);
98 int (*lcd_getstringsize)(unsigned char *str, int *w, int *h);
99 void (*lcd_update)(void);
100 void (*lcd_update_rect)(int x, int y, int width, int height);
101#ifndef SIMULATOR
102 void (*lcd_roll)(int pixels);
103#endif
104#endif
105
106 /* button */
107 int (*button_get)(bool block);
108 int (*button_get_w_tmo)(int ticks);
109
110 /* file */
111 int (*open)(const char* pathname, int flags);
112 int (*close)(int fd);
113 int (*read)(int fd, void* buf, int count);
114 int (*lseek)(int fd, int offset, int whence);
115 int (*creat)(const char *pathname, int mode);
116 int (*write)(int fd, void* buf, int count);
117 int (*remove)(const char* pathname);
118 int (*rename)(const char* path, const char* newname);
119 int (*ftruncate)(int fd, unsigned int size);
120 int (*filesize)(int fd);
121 int (*fprintf)(int fd, const char *fmt, ...);
122 int (*read_line)(int fd, char* buffer, int buffer_size);
123
124 /* dir */
125 DIR* (*opendir)(char* name);
126 int (*closedir)(DIR* dir);
127 struct dirent* (*readdir)(DIR* dir);
128
129 /* kernel */
130 void (*sleep)(int ticks);
131 void (*usb_screen)(void);
132 long* current_tick;
133
134 /* strings and memory */
135 int (*snprintf)(char *buf, size_t size, const char *fmt, ...);
136 char* (*strcpy)(char *dst, const char *src);
137 size_t (*strlen)(const char *str);
138 void* (*memset)(void *dst, int c, size_t length);
139 void* (*memcpy)(void *out, const void *in, size_t n);
140
141 /* sound */
142#ifndef SIMULATOR
143#ifdef HAVE_MAS3587F
144 int (*mas_codec_readreg)(int reg);
145#endif
146#endif
147
148 /* misc */
149 void (*srand)(unsigned int seed);
150 int (*rand)(void);
151 void (*splash)(int ticks, int keymask, bool center, char *fmt, ...);
152};
153
154/* defined by the plugin loader (plugin.c) */
155int plugin_load(char* plugin, void* parameter);
156
157/* defined by the plugin */
158enum plugin_status plugin_start(struct plugin_api* rockbox, void* parameter)
159 __attribute__ ((section (".entry")));
160
161#endif