summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2003-02-07 09:41:57 +0000
committerDaniel Stenberg <daniel@haxx.se>2003-02-07 09:41:57 +0000
commitf9b44900669c8af2b7a101d201c43beec2bc89dd (patch)
treec07c3b44f5d24acb865289eed580a6ca76bf52fa
parent850f597f95decd3a125f7915235ffbae67a195b4 (diff)
downloadrockbox-f9b44900669c8af2b7a101d201c43beec2bc89dd.tar.gz
rockbox-f9b44900669c8af2b7a101d201c43beec2bc89dd.zip
Include File Cleanup And Move-Around Party 2003.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3213 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/Makefile4
-rw-r--r--firmware/drivers/lcd-recorder.c2
-rw-r--r--firmware/export/backlight.h31
-rw-r--r--firmware/export/config-fmrecorder.h44
-rw-r--r--firmware/export/config-player.h33
-rw-r--r--firmware/export/config-recorder.h38
-rw-r--r--firmware/export/config.h33
-rw-r--r--firmware/export/debug.h51
-rw-r--r--firmware/export/disk.h35
-rw-r--r--firmware/export/font.h116
-rw-r--r--firmware/export/hwcompat.h37
-rw-r--r--firmware/export/id3.h76
-rw-r--r--firmware/export/kernel.h (renamed from firmware/include/kernel.h)0
-rw-r--r--firmware/export/mpeg.h116
-rw-r--r--firmware/export/panic.h25
-rw-r--r--firmware/export/powermgmt.h101
-rw-r--r--firmware/export/rolo.h24
-rw-r--r--firmware/export/system.h267
-rw-r--r--firmware/export/thread.h30
-rw-r--r--firmware/export/usb.h31
-rw-r--r--firmware/mpeg.c2
21 files changed, 1093 insertions, 3 deletions
diff --git a/firmware/Makefile b/firmware/Makefile
index 73bb8e9819..5f637bb907 100644
--- a/firmware/Makefile
+++ b/firmware/Makefile
@@ -13,7 +13,7 @@ AR = sh-elf-ar
13AS = sh-elf-as 13AS = sh-elf-as
14OC = sh-elf-objcopy 14OC = sh-elf-objcopy
15 15
16INCLUDES=-Iinclude -I. -Icommon -Idrivers 16INCLUDES=-Iinclude -I. -Iexport -Icommon -Idrivers
17 17
18TOOLSDIR = ../tools 18TOOLSDIR = ../tools
19 19
@@ -69,7 +69,7 @@ clean:
69 rm -rf $(OBJDIR)/$(DEPS) 69 rm -rf $(OBJDIR)/$(DEPS)
70 70
71# Special targets 71# Special targets
72$(OBJDIR)/thread.o: thread.c thread.h 72$(OBJDIR)/thread.o: thread.c export/thread.h
73 $(CC) -c -O -fomit-frame-pointer $(CFLAGS) $< -o $@ 73 $(CC) -c -O -fomit-frame-pointer $(CFLAGS) $< -o $@
74 74
75$(OBJDIR)/sysfont.o: fonts/clR6x8.bdf 75$(OBJDIR)/sysfont.o: fonts/clR6x8.bdf
diff --git a/firmware/drivers/lcd-recorder.c b/firmware/drivers/lcd-recorder.c
index d1e2a6b0da..fae4ea2945 100644
--- a/firmware/drivers/lcd-recorder.c
+++ b/firmware/drivers/lcd-recorder.c
@@ -669,6 +669,8 @@ void lcd_puts_scroll(int x, int y, unsigned char* string)
669 int index; 669 int index;
670 int free_index=0; 670 int free_index=0;
671 671
672 DEBUGF("puts_scroll: %s\n", string);
673
672 for (index = 0; index < SCROLLABLE_LINES; index++) { 674 for (index = 0; index < SCROLLABLE_LINES; index++) {
673 s = &scroll[index]; 675 s = &scroll[index];
674 676
diff --git a/firmware/export/backlight.h b/firmware/export/backlight.h
new file mode 100644
index 0000000000..09efc45060
--- /dev/null
+++ b/firmware/export/backlight.h
@@ -0,0 +1,31 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Daniel 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 BACKLIGHT_H
20#define BACKLIGHT_H
21
22void backlight_init(void);
23void backlight_on(void);
24void backlight_off(void);
25void backlight_tick(void);
26int backlight_get_timeout(void);
27void backlight_set_timeout(int seconds);
28bool backlight_get_on_when_charging(void);
29void backlight_set_on_when_charging(bool yesno);
30
31#endif
diff --git a/firmware/export/config-fmrecorder.h b/firmware/export/config-fmrecorder.h
new file mode 100644
index 0000000000..7befca8e52
--- /dev/null
+++ b/firmware/export/config-fmrecorder.h
@@ -0,0 +1,44 @@
1/* define this if you have recording possibility */
2#define HAVE_RECORDING 1
3
4/* define this if you have a bitmap LCD display */
5#define HAVE_LCD_BITMAP 1
6
7/* define this if you have a Recorder style 10-key keyboard */
8#define HAVE_RECORDER_KEYPAD 1
9
10/* define this if you have a real-time clock */
11#define HAVE_RTC 1
12
13/* Define this if you have a MAS3587F */
14#define HAVE_MAS3587F
15
16/* Define this if you have charging control */
17#define HAVE_CHARGE_CTRL
18
19/* Define this if you have ATA power-off control */
20#define HAVE_ATA_POWER_OFF
21
22/* Define this if you have a FM Recorder key system */
23#define HAVE_FMADC 1
24
25/* Define this if you have a LiIon battery */
26#define HAVE_LIION
27
28/* Define this to the CPU frequency */
29#define CPU_FREQ 11059200
30
31/* Battery scale factor (?) */
32#define BATTERY_SCALE_FACTOR 6465
33
34/* Define this if you control power on PBDR (instead of PADR) */
35#define HAVE_POWEROFF_ON_PBDR
36
37/* Offset ( in the firmware file's header ) to the file length */
38#define FIRMWARE_OFFSET_FILE_LENGTH 20
39
40/* Offset ( in the firmware file's header ) to the file CRC */
41#define FIRMWARE_OFFSET_FILE_CRC 6
42
43/* Offset ( in the firmware file's header ) to the real data */
44#define FIRMWARE_OFFSET_FILE_DATA 24
diff --git a/firmware/export/config-player.h b/firmware/export/config-player.h
new file mode 100644
index 0000000000..d9a713d368
--- /dev/null
+++ b/firmware/export/config-player.h
@@ -0,0 +1,33 @@
1/* define this if you have a charcell LCD display */
2#define HAVE_LCD_CHARCELLS 1
3
4/* define this if you have the Player's keyboard */
5#define HAVE_PLAYER_KEYPAD 1
6
7/* Define this if you have a MAS3507D */
8#define HAVE_MAS3507D
9
10/* Define this if you have a DAC3550A */
11#define HAVE_DAC3550A
12
13/* Define this to the CPU frequency */
14#define CPU_FREQ 12000000 /* cycle time ~83.3ns */
15
16/* Battery scale factor (?) */
17#define BATTERY_SCALE_FACTOR 6546
18
19/* Define this if you must discharge the data line by driving it low
20 and then set it to input to see if it stays low or goes high */
21#define HAVE_I2C_LOW_FIRST
22
23/* Define this if you control power on PADR (instead of PBDR) */
24#define HAVE_POWEROFF_ON_PADR
25
26/* Offset ( in the firmware file's header ) to the file length */
27#define FIRMWARE_OFFSET_FILE_LENGTH 0
28
29/* Offset ( in the firmware file's header ) to the file CRC */
30#define FIRMWARE_OFFSET_FILE_CRC 4
31
32/* Offset ( in the firmware file's header ) to the real data */
33#define FIRMWARE_OFFSET_FILE_DATA 6
diff --git a/firmware/export/config-recorder.h b/firmware/export/config-recorder.h
new file mode 100644
index 0000000000..33e40b7790
--- /dev/null
+++ b/firmware/export/config-recorder.h
@@ -0,0 +1,38 @@
1/* define this if you have recording possibility */
2#define HAVE_RECORDING 1
3
4/* define this if you have a bitmap LCD display */
5#define HAVE_LCD_BITMAP 1
6
7/* define this if you have the Recorder's 10-key keyboard */
8#define HAVE_RECORDER_KEYPAD 1
9
10/* define this if you have a real-time clock */
11#define HAVE_RTC 1
12
13/* Define this if you have a MAS3587F */
14#define HAVE_MAS3587F
15
16/* Define this if you have charging control */
17#define HAVE_CHARGE_CTRL
18
19/* Define this if you have ATA power-off control */
20#define HAVE_ATA_POWER_OFF
21
22/* Define this to the CPU frequency */
23#define CPU_FREQ 11059200
24
25/* Battery scale factor (?) */
26#define BATTERY_SCALE_FACTOR 6465
27
28/* Define this if you control power on PBDR (instead of PADR) */
29#define HAVE_POWEROFF_ON_PBDR
30
31/* Offset ( in the firmware file's header ) to the file length */
32#define FIRMWARE_OFFSET_FILE_LENGTH 0
33
34/* Offset ( in the firmware file's header ) to the file CRC */
35#define FIRMWARE_OFFSET_FILE_CRC 4
36
37/* Offset ( in the firmware file's header ) to the real data */
38#define FIRMWARE_OFFSET_FILE_DATA 6
diff --git a/firmware/export/config.h b/firmware/export/config.h
new file mode 100644
index 0000000000..d4b6f9e25b
--- /dev/null
+++ b/firmware/export/config.h
@@ -0,0 +1,33 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Daniel 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
20#ifndef __CONFIG_H__
21#define __CONFIG_H__
22
23#if defined(ARCHOS_PLAYER)
24#include "config-player.h"
25#elif defined(ARCHOS_RECORDER)
26#include "config-recorder.h"
27#elif defined(ARCHOS_FMRECORDER)
28#include "config-fmrecorder.h"
29#else
30/* no known platform */
31#endif
32
33#endif
diff --git a/firmware/export/debug.h b/firmware/export/debug.h
new file mode 100644
index 0000000000..f8aa7d4113
--- /dev/null
+++ b/firmware/export/debug.h
@@ -0,0 +1,51 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
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 DEBUG_H
20#define DEBUG_H
21
22extern void debug_init(void);
23extern void debugf(char* fmt,...);
24extern void ldebugf(char* file, int line, char *fmt, ...);
25
26#ifdef __GNUC__
27
28/* */
29#if defined(SIMULATOR)
30#define DEBUGF debugf
31#define LDEBUGF(...) ldebugf(__FILE__, __LINE__, __VA_ARGS__)
32#else
33#if defined(DEBUG)
34#define DEBUGF debugf
35#define LDEBUGF debugf
36#else
37#define DEBUGF(...)
38#define LDEBUGF(...)
39#endif
40#endif
41
42
43#else
44
45#define DEBUGF debugf
46#define LDEBUGF debugf
47
48#endif /* GCC */
49
50
51#endif
diff --git a/firmware/export/disk.h b/firmware/export/disk.h
new file mode 100644
index 0000000000..865b7bb4b4
--- /dev/null
+++ b/firmware/export/disk.h
@@ -0,0 +1,35 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by 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 _DISK_H_
20#define _DISK_H_
21
22struct partinfo {
23 unsigned long start; /* first sector (LBA) */
24 unsigned long size; /* number of sectors */
25 unsigned char type;
26};
27
28#define PARTITION_TYPE_FAT32 0x0b
29#define PARTITION_TYPE_FAT32_LBA 0x0c
30
31/* returns a pointer to an array of 8 partinfo structs */
32struct partinfo* disk_init(void);
33struct partinfo* disk_partinfo(int partition);
34
35#endif
diff --git a/firmware/export/font.h b/firmware/export/font.h
new file mode 100644
index 0000000000..b45fccbbde
--- /dev/null
+++ b/firmware/export/font.h
@@ -0,0 +1,116 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (c) 2002 by Greg Haerr <greg@censoft.com>
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/*
20 * Incore font and image definitions
21 */
22#include "config.h"
23
24#if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR)
25
26/* max static loadable fonts buffer*/
27#ifndef MAX_FONT_SIZE
28#define MAX_FONT_SIZE 9000 /* max total fontsize allocation*/
29#endif
30
31/*
32 * Fonts are specified by number, and used for display
33 * of menu information as well as mp3 filename data.
34 * At system startup, up to MAXFONTS fonts are initialized,
35 * either by being compiled-in, or loaded from disk.
36 * If the font asked for does not exist, then the
37 * system uses the next lower font number. Font 0
38 * must be available at system startup.
39 * Fonts are specified in firmware/font.c.
40 */
41enum {
42 FONT_SYSFIXED, /* system fixed pitch font*/
43 FONT_UI, /* system porportional font*/
44 MAXFONTS
45};
46
47/*
48 * .fnt loadable font file format definition
49 *
50 * format len description
51 * ------------------------- ---- ------------------------------
52 * UCHAR version[4] 4 magic number and version bytes
53 * UCHAR name[64] 64 font name, space padded
54 * UCHAR copyright[256] 256 copyright info, space padded
55 * USHORT maxwidth 2 font max width in pixels
56 * USHORT height 2 font height in pixels
57 * USHORT ascent 2 font ascent (baseline) in pixels
58 * USHORT pad 2 unused, pad to 32-bit boundary
59 * ULONG firstchar 4 first character code in font
60 * ULONG defaultchar 4 default character code in font
61 * ULONG size 4 # characters in font
62 * ULONG nbits 4 # words imagebits data in file
63 * ULONG noffset 4 # longs offset data in file
64 * ULONG nwidth 4 # bytes width data in file
65 * MWIMAGEBITS bits nbits*2 image bits variable data
66 * [MWIMAGEBITS padded to 32-bit boundary]
67 * ULONG offset noffset*4 offset variable data
68 * UCHAR width nwidth*1 width variable data
69 */
70
71/* loadable font magic and version #*/
72#define VERSION "RB11"
73
74typedef unsigned short bitmap_t; /* bitmap image unit size*/
75
76/* bitmap_t helper macros*/
77#define BITMAP_WORDS(x) (((x)+15)/16) /* image size in words*/
78#define BITMAP_BYTES(x) (BITMAP_WORDS(x)*sizeof(bitmap_t))
79#define BITMAP_BITSPERIMAGE (sizeof(bitmap_t) * 8)
80#define BITMAP_BITVALUE(n) ((bitmap_t) (((bitmap_t) 1) << (n)))
81#define BITMAP_FIRSTBIT (BITMAP_BITVALUE(BITMAP_BITSPERIMAGE - 1))
82#define BITMAP_TESTBIT(m) ((m) & BITMAP_FIRSTBIT)
83#define BITMAP_SHIFTBIT(m) ((bitmap_t) ((m) << 1))
84
85/* builtin C-based proportional/fixed font structure */
86/* based on The Microwindows Project http://microwindows.org */
87struct font {
88 char * name; /* font name*/
89 int maxwidth; /* max width in pixels*/
90 unsigned int height; /* height in pixels*/
91 int ascent; /* ascent (baseline) height*/
92 int firstchar; /* first character in bitmap*/
93 int size; /* font size in glyphs*/
94 bitmap_t *bits; /* 16-bit right-padded bitmap data*/
95 unsigned long *offset; /* offsets into bitmap data*/
96 unsigned char *width; /* character widths or NULL if fixed*/
97 int defaultchar; /* default char (not glyph index)*/
98 long bits_size; /* # words of bitmap_t bits*/
99};
100
101/* font routines*/
102void font_init(void);
103struct font* font_load(char *path);
104struct font* font_get(int font);
105void font_reset(void);
106
107#else /* HAVE_LCD_BITMAP */
108
109#define font_init()
110#define font_load(x)
111
112#endif
113
114/* -----------------------------------------------------------------
115 * vim: et sw=4 ts=8 sts=4 tw=78
116 */
diff --git a/firmware/export/hwcompat.h b/firmware/export/hwcompat.h
new file mode 100644
index 0000000000..52d831222f
--- /dev/null
+++ b/firmware/export/hwcompat.h
@@ -0,0 +1,37 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
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 HWCOMPAT_H
20#define HWCOMPAT_H
21
22#include <stdbool.h>
23#include "config.h"
24
25/* Bit mask values for HW compatibility */
26#define ATA_ADDRESS_200 0x0100
27#define USB_ACTIVE_HIGH 0x0100
28#define PR_ACTIVE_HIGH 0x0100
29
30int read_rom_version(void);
31int read_hw_mask(void);
32
33#ifdef HAVE_LCD_CHARCELLS
34bool has_new_lcd(void);
35#endif
36
37#endif
diff --git a/firmware/export/id3.h b/firmware/export/id3.h
new file mode 100644
index 0000000000..55ce002c2e
--- /dev/null
+++ b/firmware/export/id3.h
@@ -0,0 +1,76 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Daniel 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 ID3_H
20#define ID3_H
21
22#include "file.h"
23
24struct mp3entry {
25 char path[MAX_PATH];
26 char *title;
27 char *artist;
28 char *album;
29 int tracknum;
30 int version;
31 int layer;
32 int year;
33 unsigned char id3version;
34 unsigned char genre;
35 unsigned int bitrate;
36 unsigned int frequency;
37 unsigned int id3v2len;
38 unsigned int id3v1len;
39 unsigned int first_frame_offset; /* Byte offset to first real MP3 frame.
40 Used for skipping leading garbage to
41 avoid gaps between tracks. */
42 unsigned int filesize; /* in bytes */
43 unsigned int length; /* song length */
44 unsigned int elapsed; /* ms played */
45 long bpf; /* bytes per frame */
46 long tpf; /* time per frame */
47
48 /* Xing VBR fields */
49 bool vbr;
50 unsigned char vbrflags;
51 unsigned char toc[100];/* table of contents */
52
53 /* these following two fields are used for local buffering */
54 char id3v2buf[300];
55 char id3v1buf[3][32];
56
57 /* resume related */
58 int offset; /* bytes played */
59 int index; /* playlist index */
60};
61
62#define VBR_FRAMES_FLAG 0x01
63#define VBR_BYTES_FLAG 0x02
64#define VBR_TOC_FLAG 0x04
65
66enum {
67 ID3_VER_1_0 = 1,
68 ID3_VER_1_1,
69 ID3_VER_2_2,
70 ID3_VER_2_3,
71 ID3_VER_2_4
72};
73
74bool mp3info(struct mp3entry *entry, char *filename);
75
76#endif
diff --git a/firmware/include/kernel.h b/firmware/export/kernel.h
index 0f69f43ec0..0f69f43ec0 100644
--- a/firmware/include/kernel.h
+++ b/firmware/export/kernel.h
diff --git a/firmware/export/mpeg.h b/firmware/export/mpeg.h
new file mode 100644
index 0000000000..75ec710a37
--- /dev/null
+++ b/firmware/export/mpeg.h
@@ -0,0 +1,116 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
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 _MPEG_H_
20#define _MPEG_H_
21
22#include <stdbool.h>
23
24#define MPEG_SWAP_CHUNKSIZE 0x2000
25#define MPEG_HIGH_WATER 2 /* We leave 2 bytes empty because otherwise we
26 wouldn't be able to see the difference between
27 an empty buffer and a full one. */
28#define MPEG_LOW_WATER 0x60000
29#define MPEG_LOW_WATER_CHUNKSIZE 0x40000
30#define MPEG_LOW_WATER_SWAP_CHUNKSIZE 0x10000
31#define MPEG_PLAY_PENDING_THRESHOLD 0x10000
32#define MPEG_PLAY_PENDING_SWAPSIZE 0x10000
33
34struct mpeg_debug
35{
36 int mp3buflen;
37 int mp3buf_write;
38 int mp3buf_swapwrite;
39 int mp3buf_read;
40
41 int last_dma_chunk_size;
42
43 bool dma_on;
44 bool playing;
45 bool play_pending;
46 bool is_playing;
47 bool filling;
48 bool dma_underrun;
49
50 int unplayed_space;
51 int playable_space;
52 int unswapped_space;
53
54 int low_watermark_level;
55 int lowest_watermark_level;
56};
57
58void mpeg_init(int volume, int bass, int treble, int balance,
59 int loudness, int bass_boost, int avc);
60void mpeg_play(int offset);
61void mpeg_stop(void);
62void mpeg_pause(void);
63void mpeg_resume(void);
64void mpeg_next(void);
65void mpeg_prev(void);
66void mpeg_ff_rewind(int change);
67void mpeg_flush_and_reload_tracks(void);
68void mpeg_sound_set(int setting, int value);
69int mpeg_sound_min(int setting);
70int mpeg_sound_max(int setting);
71int mpeg_sound_default(int setting);
72void mpeg_sound_channel_config(int configuration);
73int mpeg_val2phys(int setting, int value);
74int mpeg_phys2val(int setting, int value);
75char *mpeg_sound_unit(int setting);
76int mpeg_sound_numdecimals(int setting);
77struct mp3entry* mpeg_current_track(void);
78bool mpeg_has_changed_track(void);
79int mpeg_status(void);
80#if defined(HAVE_MAS3587F) || defined(SIMULATOR)
81void mpeg_set_pitch(int percent);
82void mpeg_init_recording(void);
83void mpeg_init_playback(void);
84void mpeg_record(char *filename);
85void mpeg_set_recording_options(int frequency, int quality,
86 int source, int channel_mode);
87void mpeg_set_recording_gain(int left, int right, int mic);
88unsigned long mpeg_num_recorded_frames(void);
89unsigned long mpeg_num_recorded_bytes(void);
90#endif
91void mpeg_get_debugdata(struct mpeg_debug *dbgdata);
92void mpeg_set_buffer_margin(int seconds);
93
94#define SOUND_VOLUME 0
95#define SOUND_BASS 1
96#define SOUND_TREBLE 2
97#define SOUND_BALANCE 3
98#define SOUND_LOUDNESS 4
99#define SOUND_SUPERBASS 5
100#define SOUND_AVC 6
101#define SOUND_CHANNELS 7
102#define SOUND_LEFT_GAIN 8
103#define SOUND_RIGHT_GAIN 9
104#define SOUND_MIC_GAIN 10
105#define SOUND_NUMSETTINGS 11
106
107#define MPEG_SOUND_STEREO 0
108#define MPEG_SOUND_MONO 1
109#define MPEG_SOUND_MONO_LEFT 2
110#define MPEG_SOUND_MONO_RIGHT 3
111
112#define MPEG_STATUS_PLAY 1
113#define MPEG_STATUS_PAUSE 2
114#define MPEG_STATUS_RECORD 4
115
116#endif
diff --git a/firmware/export/panic.h b/firmware/export/panic.h
new file mode 100644
index 0000000000..585f827927
--- /dev/null
+++ b/firmware/export/panic.h
@@ -0,0 +1,25 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by wavey@wavey.org
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
20#ifndef __PANIC_H__
21#define __PANIC_H__
22
23void panicf( char *fmt, ... );
24
25#endif /* __PANIC_H__ */
diff --git a/firmware/export/powermgmt.h b/firmware/export/powermgmt.h
new file mode 100644
index 0000000000..a3e212b63a
--- /dev/null
+++ b/firmware/export/powermgmt.h
@@ -0,0 +1,101 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Heikki Hannikainen, Uwe Freese
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 _POWERMGMT_H_
20#define _POWERMGMT_H_
21
22#ifndef SIMULATOR
23
24#ifdef HAVE_LIION /* FM Recorder, LiIon */
25#define BATTERY_LEVEL_SHUTDOWN 260 /* 2.60V */
26#define BATTERY_LEVEL_EMPTY 265 /* 2.65V */
27#define BATTERY_LEVEL_DANGEROUS 280 /* 2.80V */
28#define BATTERY_LEVEL_FULL 400 /* 4.00V */
29
30#else /* Recorder, NiMH */
31#define BATTERY_LEVEL_SHUTDOWN 450 /* 4.50V */
32#define BATTERY_LEVEL_EMPTY 465 /* 4.65V */
33#define BATTERY_LEVEL_DANGEROUS 475 /* 4.75V */
34#define BATTERY_LEVEL_FULL 585 /* 5.85V */
35#endif
36
37#define BATTERY_RANGE (BATTERY_LEVEL_FULL - BATTERY_LEVEL_EMPTY)
38#define BATTERY_CAPACITY_MAX 2400 /* max. capacity that can be selected in settings menu, min. is always 1500 */
39
40#define POWER_HISTORY_LEN 2*60 /* 2 hours of samples, one per minute */
41#define POWER_AVG_N 4 /* how many samples to take for each measurement */
42#define POWER_AVG_SLEEP 9 /* how long do we sleep between each measurement */
43
44#define CHARGE_END_NEGD 6 /* stop when N minutes have passed with
45 * avg delta being < -0.05 V */
46#define CHARGE_END_ZEROD 50 /* stop when N minutes have passed with
47 * avg delta being < 0.005 V */
48
49#ifdef HAVE_CHARGE_CTRL
50#define POWER_MESSAGE_LEN 32 /* power thread status message */
51#define CHARGE_MAX_TIME_1500 450 /* minutes: maximum charging time for 1500 mAh batteries */
52 /* actual max time depends also on BATTERY_CAPACITY! */
53#define CHARGE_MIN_TIME 10 /* minutes: minimum charging time */
54#define CHARGE_RESTART_HI 85 /* %: when to restart charging in 'charge' mode */
55 /* attention: if set too high, normal charging is started in trickle mode */
56#define CHARGE_RESTART_LO 10 /* %: when to restart charging in 'discharge' mode */
57#define CHARGE_PAUSE_LEN 60 /* how many minutes to pause between charging cycles */
58#define TOPOFF_MAX_TIME 90 /* After charging, go to top off charge. How long should top off charge be? */
59#define TOPOFF_VOLTAGE 565 /* which voltage is best? (centivolts) */
60#define TRICKLE_MAX_TIME 12*60 /* After top off charge, go to trickle charge. How long should trickle charge be? */
61#define TRICKLE_VOLTAGE 545 /* which voltage is best? (centivolts) */
62
63extern char power_message[POWER_MESSAGE_LEN];
64extern char charge_restart_level;
65
66extern int powermgmt_last_cycle_startstop_min; /* how many minutes ago was the charging started or stopped? */
67extern int powermgmt_last_cycle_level; /* which level had the batteries at this time? */
68
69extern int battery_lazyness[20]; /* how does the battery react when plugging in/out the charger */
70void enable_trickle_charge(bool on);
71extern int trickle_sec; /* trickle charge: How many seconds per minute are we charging actually? */
72extern int charge_state; /* tells what the charger is doing (for info display): 0: decharging/charger off, 1: charge, 2: top-off, 3: trickle */
73
74#endif /* HAVE_CHARGE_CTRL */
75
76#define CURRENT_NORMAL 145 /* usual current in mA when using the AJB including some disk/backlight/... activity */
77#define CURRENT_USB 500 /* usual current in mA in USB mode */
78#define CURRENT_BACKLIGHT 30 /* additional current when backlight is always on */
79#define CURRENT_CHARGING 300 /* charging current */
80
81extern unsigned short power_history[POWER_HISTORY_LEN];
82
83/* Start up power management thread */
84void power_init(void);
85
86#endif /* SIMULATOR */
87
88/* Returns battery level in percent */
89int battery_level(void);
90int battery_time(void); /* minutes */
91
92/* Tells if the battery level is safe for disk writes */
93bool battery_level_safe(void);
94
95void set_poweroff_timeout(int timeout);
96void set_battery_capacity(int capacity); /* set local battery capacity value */
97
98void set_sleep_timer(int seconds);
99int get_sleep_timer(void);
100
101#endif
diff --git a/firmware/export/rolo.h b/firmware/export/rolo.h
new file mode 100644
index 0000000000..e2dd814c1a
--- /dev/null
+++ b/firmware/export/rolo.h
@@ -0,0 +1,24 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 Randy D. Wood
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 __ROLO_H__
20#define __ROLO_H__
21
22void rolo_load(char* file);
23
24#endif
diff --git a/firmware/export/system.h b/firmware/export/system.h
new file mode 100644
index 0000000000..d5f1b4ba97
--- /dev/null
+++ b/firmware/export/system.h
@@ -0,0 +1,267 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Alan Korr
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
20#ifndef __SYSTEM_H__
21#define __SYSTEM_H__
22
23#include "sh7034.h"
24#include "config.h"
25
26#define FREQ CPU_FREQ
27#define BAUDRATE 9600
28
29#ifndef NULL
30#define NULL ((void*)0)
31#endif
32
33#ifndef MIN
34#define MIN(a, b) (((a)<(b))?(a):(b))
35#endif
36
37#ifndef MAX
38#define MAX(a, b) (((a)>(b))?(a):(b))
39#endif
40
41#ifdef LITTLE_ENDIAN
42#define SWAB16(x) (x)
43#define SWAB32(x) (x)
44#endif
45
46#define nop \
47 asm volatile ("nop")
48
49#define __set_mask_constant(mask,address) \
50 asm \
51 ("or.b\t%0,@(r0,gbr)" \
52 : \
53 : /* %0 */ "I"((char)(mask)), \
54 /* %1 */ "z"(address-GBR))
55
56#define __clear_mask_constant(mask,address) \
57 asm \
58 ("and.b\t%0,@(r0,gbr)" \
59 : \
60 : /* %0 */ "I"((char)~(mask)), \
61 /* %1 */ "z"(address-GBR))
62
63#define __toggle_mask_constant(mask,address) \
64 asm \
65 ("xor.b\t%0,@(r0,gbr)" \
66 : \
67 : /* %0 */ "I"((char)(mask)), \
68 /* %1 */ "z"(address-GBR))
69
70#define __test_mask_constant(mask,address) \
71 ({ \
72 int result; \
73 asm \
74 ("tst.b\t%1,@(r0,gbr)\n\tmovt\t%0" \
75 : "=r"(result) \
76 : "I"((char)(mask)),"z"(address-GBR)); \
77 result; \
78 })
79
80#define __set_bit_constant(bit,address) \
81 asm \
82 ("or.b\t%0,@(r0,gbr)" \
83 : \
84 : /* %0 */ "I"((char)(1<<(bit))), \
85 /* %1 */ "z"(address-GBR))
86
87#define __clear_bit_constant(bit,address) \
88 asm \
89 ("and.b\t%0,@(r0,gbr)" \
90 : \
91 : /* %0 */ "I"((char)~(1<<(bit))), \
92 /* %1 */ "z"(address-GBR))
93
94#define __toggle_bit_constant(bit,address) \
95 asm \
96 ("xor.b\t%0,@(r0,gbr)" \
97 : \
98 : /* %0 */ "I"((char)(1<<(bit))), \
99 /* %1 */ "z"(address-GBR))
100
101#define __test_bit_constant(bit,address) \
102 ({ \
103 int result; \
104 asm \
105 ("tst.b\t%1,@(r0,gbr)\n\tmovt\t%0" \
106 : "=r"(result) \
107 : "I"((char)(1<<(bit))),"z"(address-GBR)); \
108 result; \
109 })
110
111#define __set_mask(mask,address) /* FIXME */
112#define __test_mask(mask,address) 0 /* FIXME */
113#define __clear_mask(mask,address) /* FIXME */
114#define __toggle_mask(mask,address) /* FIXME */
115
116#define __set_bit(bit,address) /* FIXME */
117#define __test_bit(bit,address) 0 /* FIXME */
118#define __clear_bit(bit,address) /* FIXME */
119#define __toggle_bit(bit,address) /* FIXME */
120
121#define set_mask(mask,address) \
122 if (__builtin_constant_p (mask)) \
123 __set_mask_constant (mask,address); \
124 else \
125 __set_mask (mask,address)
126
127#define clear_mask(mask,address) \
128 if (__builtin_constant_p (mask)) \
129 __clear_mask_constant (mask,address); \
130 else \
131 __clear_mask (mask,address)
132
133#define toggle_mask(mask,address) \
134 if (__builtin_constant_p (mask)) \
135 __toggle_mask_constant (mask,address); \
136 else \
137 __toggle_mask (mask,address)
138
139#define test_mask(mask,address) \
140 ( \
141 (__builtin_constant_p (mask)) \
142 ? (int)__test_mask_constant (mask,address) \
143 : (int)__test_mask (mask,address) \
144 )
145
146
147#define set_bit(bit,address) \
148 if (__builtin_constant_p (bit)) \
149 __set_bit_constant (bit,address); \
150 else \
151 __set_bit (bit,address)
152
153#define clear_bit(bit,address) \
154 if (__builtin_constant_p (bit)) \
155 __clear_bit_constant (bit,address); \
156 else \
157 __clear_bit (bit,address)
158
159#define toggle_bit(bit,address) \
160 if (__builtin_constant_p (bit)) \
161 __toggle_bit_constant (bit,address); \
162 else \
163 __toggle_bit (bit,address)
164
165#define test_bit(bit,address) \
166 ( \
167 (__builtin_constant_p (bit)) \
168 ? (int)__test_bit_constant (bit,address) \
169 : (int)__test_bit (bit,address) \
170 )
171
172
173extern char __swap_bit[256];
174
175#define swap_bit(byte) \
176 __swap_bit[byte]
177
178#ifndef SIMULATOR
179
180static inline short SWAB16(short value)
181 /*
182 result[15..8] = value[ 7..0];
183 result[ 7..0] = value[15..8];
184 */
185{
186 short result;
187 asm volatile ("swap.b\t%1,%0" : "=r"(result) : "r"(value));
188 return result;
189}
190
191static inline long SWAW32(long value)
192 /*
193 result[31..16] = value[15.. 0];
194 result[15.. 0] = value[31..16];
195 */
196{
197 long result;
198 asm volatile ("swap.w\t%1,%0" : "=r"(result) : "r"(value));
199 return result;
200}
201
202static inline long SWAB32(long value)
203 /*
204 result[31..24] = value[ 7.. 0];
205 result[23..16] = value[15.. 8];
206 result[15.. 8] = value[23..16];
207 result[ 7.. 0] = value[31..24];
208 */
209{
210 asm volatile ("swap.b\t%0,%0\n"
211 "swap.w\t%0,%0\n"
212 "swap.b\t%0,%0\n" : "+r"(value));
213 return value;
214}
215
216/* Test And Set - UNTESTED */
217static inline int tas (volatile int *pointer)
218 {
219 int result;
220 asm volatile ("tas.b\t@%1;movt\t%0" : "=t"(result) : "r"((char *)pointer) : "memory");
221 return result;
222 }
223
224static inline void sti (void)
225 {
226 asm volatile ("ldc\t%0,sr" : : "r"(0<<4));
227 }
228
229static inline void cli (void)
230 {
231 asm volatile ("ldc\t%0,sr" : : "r"(15<<4));
232 }
233
234/* Compare And Swap */
235static inline int cas (volatile int *pointer,int requested_value,int new_value)
236 {
237 cli();
238 if (*pointer == requested_value)
239 {
240 *pointer = new_value;
241 sti ();
242 return 1;
243 }
244 sti ();
245 return 0;
246 }
247
248static inline int cas2 (volatile int *pointer1,volatile int *pointer2,int requested_value1,int requested_value2,int new_value1,int new_value2)
249 {
250 cli();
251 if (*pointer1 == requested_value1 && *pointer2 == requested_value2)
252 {
253 *pointer1 = new_value1;
254 *pointer2 = new_value2;
255 sti ();
256 return 1;
257 }
258 sti ();
259 return 0;
260 }
261
262#endif
263
264extern void system_reboot (void);
265extern void system_init(void);
266
267#endif
diff --git a/firmware/export/thread.h b/firmware/export/thread.h
new file mode 100644
index 0000000000..7940ddfcf6
--- /dev/null
+++ b/firmware/export/thread.h
@@ -0,0 +1,30 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Ulf Ralberg
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 THREAD_H
20#define THREAD_H
21
22#define MAXTHREADS 16
23#define DEFAULT_STACK_SIZE 0x400 /* Bytes */
24
25int create_thread(void* function, void* stack, int stack_size, char *name);
26void switch_thread(void);
27void init_threads(void);
28int thread_stack_usage(int threadnum);
29
30#endif
diff --git a/firmware/export/usb.h b/firmware/export/usb.h
new file mode 100644
index 0000000000..089b0f23e6
--- /dev/null
+++ b/firmware/export/usb.h
@@ -0,0 +1,31 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
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 _USB_H_
20#define _USB_H_
21
22#include "kernel.h"
23
24void usb_init(void);
25void usb_start_monitoring(void);
26void usb_acknowledge(int id);
27void usb_wait_for_disconnect(struct event_queue *q);
28int usb_wait_for_disconnect_w_tmo(struct event_queue *q, int ticks);
29bool usb_inserted(void);
30
31#endif
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index 503fe6dc1f..0ed52ed6cb 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -24,7 +24,7 @@
24#include "mpeg.h" 24#include "mpeg.h"
25#include "ata.h" 25#include "ata.h"
26#include "string.h" 26#include "string.h"
27#include "kernel.h" 27#include <kernel.h>
28#include "thread.h" 28#include "thread.h"
29#ifndef SIMULATOR 29#ifndef SIMULATOR
30#include "i2c.h" 30#include "i2c.h"