3 Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
12 (backwards compability up to version 25)
14 Info: To get the latest plugin api specs:
15 look at struct plugin_api in apps/plugin.h
16 (and apps/plugins/helloworld.c for an example)
23 static struct plugin_api* rb;
26 enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
32 //insert your code here
37 to call a function, use the plugin_api structure this way : rb->function()
44 Plugin version number.
46 int plugin_test(int api_version, int model, int memsize);
48 This function is called by the TEST_PLUGIN_API() macro to test
49 compability of the plugin with current software.
50 Returns PLUGIN_OK if plugin is supported.
51 Returns PLUGIN_WRONG_API_VERSION if plugin version isn't compatible.
52 Returns PLUGIN_WRONG_MODEL if the model or memsize is wrong.
60 Most LCD functions are specific for which output we work with, due to the
63 void lcd_clear_display(void);
65 Clear the whole display
67 void backlight_on(void);
71 void backlight_off(void);
73 Turn the backlight off
75 void splash(int ticks, bool center, char *fmt, ...);
77 Display a formated string in a box durring time ticks. If center is
78 FALSE, the display is left justified. If center is TRUE, the display
79 is centered horizontaly and verticaly. The string is formated as with
81 (There are HZ ticks per second)
83 void lcd_puts(int x, int y, const unsigned char *string);
85 Write a string at given character position.
87 void lcd_puts_scroll(int x, int y, unsigned char* string);
89 Print a scrolling string at screen coordinates (x,y). The scrolling
90 style is STYLE_DEFAULT.
92 void lcd_stop_scroll(void);
94 Stop all scrolling lines on the screen.
96 void lcd_set_contrast(int val);
98 Set the screen contrast. Argument val should be a value between
99 MIN_CONTRAST_SETTING and MAX_CONTRAST_SETTING.
104 All the functions operate on a display buffer. You make the buffer get
105 shown on screen by calling lcd_update().
107 void lcd_update(void);
109 Update the LCD according to the internal buffer.
111 void lcd_update_rect(int x, int y, int width, int height);
113 Update the given rectangle to the LCD. Give arguments measured in
114 pixels. Notice that the smallest vertical resolution in updates that the
115 hardware supports is even 8 pixels. This function will adjust to those.
117 void lcd_setfont(int font);
121 struc font* font_get(int font);
123 Return a pointer to an incore font structure. If the requested font
124 isn't loaded/compiled-in, decrement the font number and try again.
126 void lcd_putsxy(int x, int y, const unsigned char *string);
128 Put a string at given coordinates.
130 void lcd_puts_style(int x, int y, const unsigned char *str, int style);
132 Put a string at given coordinates. Intger style can be STYLE_DEFAULT
133 for black text display or STYLE_INVERT for white text display.
135 void lcd_puts_scroll_style(int x, int y, unsigned char* string, int style);
137 Same as lcd_puts_style and scrolling is enabled.
138 {new in plugin API version 26}
140 void lcd_bitmap(const unsigned char *src, int x, int y, int width,
141 int height, bool clear);
143 Put a bitmap at given coordinates. If clear is true, the area is
144 cleared before the bitmap is put.
145 Element src[i] is the binary representation of column number i of
146 the bitmap read from bottom to top.
148 void lcd_clearrect(int x, int y, int width, int height);
150 Clear a rectangle area.
152 void lcd_fillrect(int x, int y, int width, int height);
154 Fill a rectangle area.
156 void lcd_drawrect(int x, int y, int width, int height);
160 void lcd_invertrect(int x, int y, int width, int height);
162 Revert the graphics of the given area.
164 void lcd_drawline(int x1, int y1, int x2, int y2);
166 Draw a line between the coordinates.
168 void lcd_clearline(int x1, int y1, int x2, int y2);
170 Clear a line between two coordinates.
172 void lcd_drawpixel(int x, int y);
174 Draw a pixel on the given coordinate.
176 void lcd_clearpixel(int x, int y);
178 Clear the pixel at the given coordinate.
180 int lcd_getstringsize(const unsigned char *str, int *w, int *h);
182 Get the height and width of string str as it would appear on display.
183 Return value is the width.
185 void scrollbar(int x, int y, int width, int height, int items,
186 int min_shown, int max_shown, int orientation);
188 Print a scroll bar at coordinates (x,y) of size width*height.
189 orientation can be VERTICAL for a vertical scroll bar or anything else
190 for a horizontal scroll bar.
191 Item is the total number of items which the scroll bar refers to,
192 min_show the rank of the first item displayed and max_show the
193 rank of the last displayed item.
195 void checkbox(int x, int y, int width, int height, bool checked);
197 Draw a checkbox area. If checked is TRUE, the checkbox is drawn
200 void lcd_blit(unsigned char* p_data, int x, int y, int width,
201 int height, int stride);
203 ??? (see firmware/drivers/lcd-recorder.c:168)
205 void lcd_roll(int pixels);
207 Rolls up the lcd display by the specified amount of lines.
208 Lines that are rolled out over the top of the screen are rolled in
209 from the bottom again. This is a hardware remapping only and all
210 operations on the lcd are affected.
211 The screen is rolled up of pixel lines. The value must be between
218 void lcd_define_pattern(int pat, char *pattern);
220 Define a custom pattern of index pat. char *pattern is a 8x8 pixel
223 unsigned char lcd_get_locked_pattern(void);
225 Get a locked pattern index.
226 (see firmware/drivers/lcd-player.c:382)
228 void lcd_unlock_pattern(unsigned char pat);
230 Unlock pattern of index pat.
232 void lcd_putc(int x, int y, unsigned char ch);
234 Put character c at coordinates (x,y).
236 void lcd_put_cursor(int x, int y, char cursor_char);
238 Put cursor at coordinated (x,y).
239 See firmware/export/lcd.h for possible cursor_char values.
241 void lcd_remove_cursor(void);
243 Remove the cursor from the screen.
245 void lcd_icon(int icon, bool enable);
247 ??? (see firmware/drivers/lcd-player.c:463)
253 These functions work the same regardless of which keypad you have, but they
254 return a different set of values. Note that the Recorder keypad has 10
255 keys, while the Player keypad only features 6.
257 Possible return values can be found in the firmware/export/button.h file.
259 int button_get(bool block);
261 Returns a bitmask for which keys were pressed. If 'block' is set TRUE it
262 won't return until a key is pressed.
264 int button_get_w_tmo(int ticks);
266 Wait for a key press for ticks ticks. (There are HZ ticks per second)
267 Returns a bitmask for which keys were pressed. If no key was pressed,
270 int button_status(void);
272 Returns a bitmask for which keys are currently pressed.
274 void button_clear_queue(void);
276 Empty the button queue.
282 (These functions are POSIX look-alikes)
284 int open(const char *pathname, int flags);
286 The open() function establishes the connection between a file and a file
287 descriptor. It creates an open file description that refers to a file
288 and a file descriptor that refers to that open file description. The file
289 descriptor is used by other I/O functions to refer to that file.
291 ssize_t read(int fd, void *buf, size_t count);
293 The read() function attempts to read count bytes from the file associated
294 with the open file descriptor, fd, into the buffer pointed to by buf.
296 off_t lseek(int fd, off_t offset, int whence);
298 The lseek() function sets the file pointer associated with the open file
299 descriptor specified by fd as follows:
301 o If whence is SEEK_SET, the pointer is set to offset bytes.
303 o If whence is SEEK_CUR, the pointer is set to its
304 current location plus offset.
306 o If whence is SEEK_END, the pointer is set to the size
307 of the file plus offset.
309 int creat(const char *pathname, mode_t mode)
311 Create a file with mode O_RDONLY, O_WRONLY or O_RDWR. Returns the
312 file descriptor associated to this file.
314 ssize_t write(int fd, const void *buf, size_t count);
316 Write writes up to count bytes to the file referenced by the file
317 descriptor fd from the buffer starting at buf.
321 The close() function will deallocate the file descriptor indicated by
322 fd. To deallocate means to make the file descriptor available for
323 return by subsequent calls to open() or other functions that allocate
325 Returns 0 upon success.
327 int rename(const char *path, const char *newname);
329 The rename() function changes the name of a file. The path argument
330 points to the pathname of the file to be renamed. The newname argument
331 points to the new pathname of the file.
333 int remove(const char *pathname);
335 remove() deletes a name from the filesystem. It calls unlink for files,
336 and rmdir for directories.
338 int ftruncate(int fd, off_t length);
340 Truncate file to the specified length.
342 int filesize(int fd);
344 Returns size of a file. Upon error, returns -1.
346 int fprintf(int fd, const char *fmt, ...);
348 Write a formated string in the fd.
349 Returns the number of characters writen to file.
350 Returns a negative value upon error.
352 int read_line(int fd, char* buffer, int buffer_size);
354 Read (up to) a line of text from fd into buffer and return number of bytes
355 read (which may be larger than the number of bytes stored in buffer). If
356 an error occurs, -1 is returned (and buffer contains whatever could be
357 read). A line is terminated by a LF char. Neither LF nor CR chars are
360 int settings_parseline(char* line, char** name, char** value);
362 Parse a line from a configuration file. The line format is:
364 Any whitespace before setting name or value (after ':') is ignored.
365 A # as first non-whitespace character discards the whole line.
366 Function sets pointers to null-terminated setting name and value.
367 Returns false if no valid config entry was found
371 Give the disk some rest.
378 DIR *opendir(const char *name);
380 The opendir() function opens a directory stream corresponding to the
381 directory name, and returns a pointer to the directory stream. The
382 stream is positioned at the first entry in the directory.
384 struct dirent *readdir(DIR *dir);
386 The readdir() function returns a pointer to a dirent structure
387 representing the next directory entry in the directory stream pointed to
388 by dir. It returns NULL on reaching the end-of-file or if an error
392 unsigned char d_name[MAX_PATH];
396 unsigned short wrtdate; /* Last write date */
397 unsigned short wrttime; /* Last write time */
400 int closedir(DIR *dir);
402 The closedir() function closes the directory stream associated with dir.
403 The directory stream descriptor dir is not available after this call.
411 Sleep a specified number of ticks, we have HZ ticks per second.
415 Let another thread run. This should be used as soon as you have to "wait"
416 for something or similar, and also if you do anything that takes "a long
417 time". This function is the entire foundation that our "cooperative
418 multitasking" is based on. Use it.
420 void usb_screen(void);
422 Show the usb connection screen.
426 The global tick variable.
428 int default_event_handler(int event);
430 If event == SYS_USB_CONNECTED, call usb_screen and return
431 SYS_USB_CONNECTED. Else do nothing and return 0.
433 int create_thread(void* function, void* stack, int stack_size,
437 ??? (see firmware/thread.c:145)
438 Return its ID if context area could be allocated, else return -1.
440 void remove_thread(int threadnum);
442 Remove a thread from the scheduler.
443 Parameter is the ID as returned from create_thread().
445 void reset_poweroff_timer(void);
447 The function name pretty much says what it's supposed to do.
453 int strcmp(const char *a, const char *b);
455 strcmp compares the string a to string b. If a sorts lexicographically
456 after b, strcmp returns a number greater than zero. If the two strings
457 match, strcmp returns zero. If a sorts lexicographically before b,
458 strcmp returns a number less than zero.
460 char *strcpy(char *dst, const char *src);
462 strcpy copies the string pointed to by src (including the terminating
463 null character) to the arra pointed to by dst.
464 This function returns the initial value of dst.
466 void *memcpy(void *out, const void *in, size_t length);
468 Copies length bytes of data in memory from source to dest.
470 void *memset(void *dst, int c, size_t length);
472 Fills a memory region with specified byte value.
474 int snprintf(char *buf, size_t size, const char *fmt, ...);
476 Write a formated formated string in buffer buf of size size
477 (including the trailing '\0').
478 Upon success, return the number of characters printed or that would have
479 been printed if the output was truncated (not including the trailing
481 These support %c, %s, %d and %x only with the width and zero padding
484 char *strncpy(char *dst, const char *src, size_t length);
486 strncpy copies not more than length characters from the string pointed
487 to by src (including the terminating null character) to the array pointed
488 to by dst. If the string pointed to by src is shorter than length
489 characters, null characters are apended to the destination array until
490 a total of length characters have been written.
491 This function returns the initial value of dst.
493 size_t strlen(const char *str);
495 The strlen function works out the length of the string starting at str
496 by counting characters until it reaches a null character.
497 strlen returns the character count.
499 char *strrchr(const char *string, int c);
501 This function finds the last occurence of c (converted to a char) in the
502 string pointed to by string (including the terminating null character).
503 Returns a pointer to the located character, or a null pointer if c
504 does not occur in string.
506 int strcasecmp(const char *s1, const char *s2);
508 The strcasecmp() function compares the two strings s1 and s2, ignoring
509 the case of the characters. It returns an integer less than, equal to,
510 or greater than zero if s1 is found, respectively, to be less than, to
511 match, or be greater than s2.
513 int strncasecmp(const char *s1, const char *s2, size_t n);
515 Like strncasecmp() but only on the first n characters.
516 {new in plugin API version 26}
520 ??? (see firmware/common/ctype.c)
523 int atoi(const char *str);
525 The atoi() function converts the initial portion of a string pointed
532 void mpeg_sound_set(int setting, int value);
534 The function mpeg_sound_set() is used to set sound output characteristics.
535 This characterisitic is chosen with the setting argument. Possible
536 settings (and the effective values) are :
539 SOUND_BALANCE (only effective with MAS3587F)
546 value : MPEG_SOUND_STEREO
549 MPEG_SOUND_MONO_RIGHT
550 MPEG_SOUND_STEREO_NARROW
551 MPEG_SOUND_STEREO_WIDE
554 only available with MAS3587F :
580 void mp3_play_data(unsigned char* start, int size,
581 void (*get_more)(unsigned char** start, int* size));
583 Plays a chunk of an mp3 file.
584 start points to the begining of the file to play.
585 size is the size to play.
586 getmore is a callback function.
587 ??? (see firmware/mp3_playback.c:1062)
590 void mp3_play_pause(bool play);
592 If playback was paused and play is TRUE, resume playback.
593 If playback isn't paused and play is FALSE, pause playback.
596 void mp3_play_stop(void);
601 bool mp3_is_playing(void);
603 Return true if an mp3 is playing, else return false. Note : a paused
604 mp3 is considered as a playing mp3.
607 void bitswap(unsigned char *data, int length);
609 Swap the bits for each element of array data of size length.
616 void mpeg_play(int offset);
619 ??? what does offset do (see firmware/mpeg.c:2459)
621 void mpeg_stop(void);
625 void mpeg_pause(void);
629 void mpeg_resume(void);
633 void mpeg_next(void);
635 Play the next item in playlist.
637 void mpeg_prev(void);
639 Play the previous item in playlist.
641 void mpeg_ff_rewind(int newtime);
643 Change playback time.
644 Has no effect in simulator.
646 struct mp3entry *mpeg_next_track(void);
648 Return info about the next track.
649 struct mp3entry is defined in file firmware/export/id3.h
651 int playlist_amount(void);
653 Returns the number of tracks in current playlist.
655 int mpeg_status(void);
657 Returns a bitmask about current mpeg stream status.
661 MPEG_STATUS_RECORD [MAS3587F only]
662 MPEG_STATUS_PRERECORD [MAS3587F only]
665 bool mpeg_has_changed_track(void);
667 Returns true if track has changed since last call of this function.
670 struct mp3entry *mpeg_current_track(void);
672 Return info about current track
673 struct mp3entry is defined in file firmware/export/id3.h
681 int mas_readmem(int bank, int addr, unsigned long* dest, int len);
685 int mas_writemem(int bank, int addr, unsigned long* src, int len);
689 int mas_readreg(int reg);
693 int mas_writereg(int reg, unsigned int val);
697 int mas_codec_writereg(int reg, unsigned int val);
702 int mas_codec_readreg(int reg);
711 void srand(unsigned int seed);
713 Seed the random number generator.
717 Return a pseudo random number between 0 and 0x7fffffff.
719 void qsort(void *base, size_t nmemb, size_t size,
720 int(*compar)(const void *, const void *));
722 qsort sorts an array (begining at base) of nmemb objects, size
723 describes the size of each element of the array.
725 You must supply a pointer to a comparison function, using the
726 argument shown as compar. (This permits the sorting objects of
727 unknown properties.) Define the comparison function to accept
728 two arguments, each a pointer to an element of the array starting
729 at base. The result of (*compar) must be negative if the first
730 argument is less than the second, zero if the two arguments match,
731 and positive if the first argument is greater than the second
732 (chere ``less than'' and ``greter than'' refer to whatever
733 arbitrary ordering is appropriate).
735 The arra is sorted in place; that is, when qsort returns, the array
736 elements begining at base have been reordered.
738 int kbd_input(char *buffer, int buflen);
740 Prompt for a string to be stored in buffer which is of length buflen.
741 Return FALSE upon success.
743 struct tm *get_time(void);
759 int set_time(struct tm *tm);
762 Return FALSE upon success.
763 (see get_time() for a description of struct tm)
765 void *plugin_get_buffer(int *buffer_size);
767 Returns a pointer to the portion of the plugin buffer that is not
768 already being used. If no plugin is loaded, returns the entire
770 Upon return, *buffer_size is the memory size left in plugin buffer.
772 void *plugin_get_mp3_buffer(int *buffer_size);
774 Returns a pointer to the mp3 buffer.
775 Playback gets stopped to avoid conflicts.
777 int plugin_register_timer(int cycles, int prio,
778 void (*timer_callback)(void));
780 Register a periodic time callbeck, called every 'cycles' CPU clocks.
781 Note that this function will be called in interrupt context!
784 void plugin_unregister_timer(void);
786 Disable the user timer.
789 void plugin_tsr(void (*exit_callback)(void));
791 The plugin wants to stay resdent after leaving its main function, e.g.
792 runs from timer or own thread. The callback is registered to later
793 instruct it to free its resources before a new plugin gets loaded.
795 void debugf(char *fmt, ...);
797 Debug output in formated string format.
798 [Simulator or debug only]
800 struct user_settings *global_settings;
802 Access to rockbox's settings.
803 struct user_settings is defined in apps/settings.h
805 void backlight_set_timeout(int index);
807 Set the backlight timeout.
808 index possible values :
809 0 : backlight always off
828 other : backlight always off
830 bool mp3info(mp3entry *entry, char *filename);
832 Return FALSE if successful. The given mp3entry is then filled in with
833 whatever id3 info it could find about the given file.
834 struct mp3entry is defined in file firmware/export/id3.h
836 int count_mp3_frames(int fd, int startpos, int filesize,
837 void (*progressfunc)(int));
839 ??? (see firmware/mp3data.c:531)
840 something related to VBR files
842 int create_xing_header(int fd, int startpos, int filesize,
843 unsigned char *buf, int num_frames,
844 unsigned long header_template,
845 void (*progressfunc)(int), bool generate_toc);
847 ??? (see firmware/mp3data.c:593)
849 int battery_level(void);
851 Returns battery level in percent.
852 On the simulator, battery_level always returns 75.
854 void mpeg_set_pitch(int pitch);
856 Change the pitch of audio playback. pitch is given in tenths of
859 {new in plugin API version 26}
861 unsigned short peak_meter_scale_value(unsigned short val, int meterwidth);
863 Scales a peak value as read from the MAS to the range of meterwidth.
864 The scaling is performed according to the scaling method (dBfs / linear)
865 and the range (peak_meter_range_min .. peak_meter_range_max).
866 unsigned short val is the volume value. Range: 0 <= val < MAX_PEAK
867 int meterwidht is the widht of the meter in pixel
868 Returns an a value between 0 and meterwidth
870 {new in plugin API version 26}
872 void peak_meter_set_use_dbfs(int use);
874 Specifies wether the values displayed are scaled as dBfs or as
875 linear percent values. If use is 0 use linear percent scale, else
878 {new in plugin API version 26}
880 int peak_meter_get_use_dbfs(void);
882 Returns 1 if the meter currently is displaying dBfs values, 0
883 if the meter is displaying percent values.
885 {new in plugin API version 26}
887 void mpeg_flush_and_reload_tracks(void);
889 ??? Flush the mpeg buffer and reload data ???
890 (see firmware/mpeg.c:2597)
891 (has no effect on simulator)
892 {new in plugin API version 26}
894 int mpeg_get_file_pos(void);
896 ??? Returns the current cursor position in mpeg file ???
897 (see firmware/mpeg.c:260)
898 {new in plugin API version 26}
900 unsigned long find_next_frame(int fd, int *offset, int max_offset,
901 unsigned long last_header);
904 (see firmware/mp3data.c:262)
905 {new in plugin API version 26}
907 unsigned long mpeg_get_last_header(void);
910 (see firmware/mpeg.c:320)
911 {new in plugin API version 26}