Include File Cleanup And Move-Around Party 2003.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3213 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Daniel Stenberg 2003-02-07 09:41:57 +00:00
parent 850f597f95
commit f9b4490066
21 changed files with 1093 additions and 3 deletions

View file

@ -13,7 +13,7 @@ AR = sh-elf-ar
AS = sh-elf-as AS = sh-elf-as
OC = sh-elf-objcopy OC = sh-elf-objcopy
INCLUDES=-Iinclude -I. -Icommon -Idrivers INCLUDES=-Iinclude -I. -Iexport -Icommon -Idrivers
TOOLSDIR = ../tools TOOLSDIR = ../tools
@ -69,7 +69,7 @@ clean:
rm -rf $(OBJDIR)/$(DEPS) rm -rf $(OBJDIR)/$(DEPS)
# Special targets # Special targets
$(OBJDIR)/thread.o: thread.c thread.h $(OBJDIR)/thread.o: thread.c export/thread.h
$(CC) -c -O -fomit-frame-pointer $(CFLAGS) $< -o $@ $(CC) -c -O -fomit-frame-pointer $(CFLAGS) $< -o $@
$(OBJDIR)/sysfont.o: fonts/clR6x8.bdf $(OBJDIR)/sysfont.o: fonts/clR6x8.bdf

View file

@ -669,6 +669,8 @@ void lcd_puts_scroll(int x, int y, unsigned char* string)
int index; int index;
int free_index=0; int free_index=0;
DEBUGF("puts_scroll: %s\n", string);
for (index = 0; index < SCROLLABLE_LINES; index++) { for (index = 0; index < SCROLLABLE_LINES; index++) {
s = &scroll[index]; s = &scroll[index];

View file

@ -0,0 +1,31 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 by Daniel 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 BACKLIGHT_H
#define BACKLIGHT_H
void backlight_init(void);
void backlight_on(void);
void backlight_off(void);
void backlight_tick(void);
int backlight_get_timeout(void);
void backlight_set_timeout(int seconds);
bool backlight_get_on_when_charging(void);
void backlight_set_on_when_charging(bool yesno);
#endif

View file

@ -0,0 +1,44 @@
/* define this if you have recording possibility */
#define HAVE_RECORDING 1
/* define this if you have a bitmap LCD display */
#define HAVE_LCD_BITMAP 1
/* define this if you have a Recorder style 10-key keyboard */
#define HAVE_RECORDER_KEYPAD 1
/* define this if you have a real-time clock */
#define HAVE_RTC 1
/* Define this if you have a MAS3587F */
#define HAVE_MAS3587F
/* Define this if you have charging control */
#define HAVE_CHARGE_CTRL
/* Define this if you have ATA power-off control */
#define HAVE_ATA_POWER_OFF
/* Define this if you have a FM Recorder key system */
#define HAVE_FMADC 1
/* Define this if you have a LiIon battery */
#define HAVE_LIION
/* Define this to the CPU frequency */
#define CPU_FREQ 11059200
/* Battery scale factor (?) */
#define BATTERY_SCALE_FACTOR 6465
/* Define this if you control power on PBDR (instead of PADR) */
#define HAVE_POWEROFF_ON_PBDR
/* Offset ( in the firmware file's header ) to the file length */
#define FIRMWARE_OFFSET_FILE_LENGTH 20
/* Offset ( in the firmware file's header ) to the file CRC */
#define FIRMWARE_OFFSET_FILE_CRC 6
/* Offset ( in the firmware file's header ) to the real data */
#define FIRMWARE_OFFSET_FILE_DATA 24

View file

@ -0,0 +1,33 @@
/* define this if you have a charcell LCD display */
#define HAVE_LCD_CHARCELLS 1
/* define this if you have the Player's keyboard */
#define HAVE_PLAYER_KEYPAD 1
/* Define this if you have a MAS3507D */
#define HAVE_MAS3507D
/* Define this if you have a DAC3550A */
#define HAVE_DAC3550A
/* Define this to the CPU frequency */
#define CPU_FREQ 12000000 /* cycle time ~83.3ns */
/* Battery scale factor (?) */
#define BATTERY_SCALE_FACTOR 6546
/* Define this if you must discharge the data line by driving it low
and then set it to input to see if it stays low or goes high */
#define HAVE_I2C_LOW_FIRST
/* Define this if you control power on PADR (instead of PBDR) */
#define HAVE_POWEROFF_ON_PADR
/* Offset ( in the firmware file's header ) to the file length */
#define FIRMWARE_OFFSET_FILE_LENGTH 0
/* Offset ( in the firmware file's header ) to the file CRC */
#define FIRMWARE_OFFSET_FILE_CRC 4
/* Offset ( in the firmware file's header ) to the real data */
#define FIRMWARE_OFFSET_FILE_DATA 6

View file

@ -0,0 +1,38 @@
/* define this if you have recording possibility */
#define HAVE_RECORDING 1
/* define this if you have a bitmap LCD display */
#define HAVE_LCD_BITMAP 1
/* define this if you have the Recorder's 10-key keyboard */
#define HAVE_RECORDER_KEYPAD 1
/* define this if you have a real-time clock */
#define HAVE_RTC 1
/* Define this if you have a MAS3587F */
#define HAVE_MAS3587F
/* Define this if you have charging control */
#define HAVE_CHARGE_CTRL
/* Define this if you have ATA power-off control */
#define HAVE_ATA_POWER_OFF
/* Define this to the CPU frequency */
#define CPU_FREQ 11059200
/* Battery scale factor (?) */
#define BATTERY_SCALE_FACTOR 6465
/* Define this if you control power on PBDR (instead of PADR) */
#define HAVE_POWEROFF_ON_PBDR
/* Offset ( in the firmware file's header ) to the file length */
#define FIRMWARE_OFFSET_FILE_LENGTH 0
/* Offset ( in the firmware file's header ) to the file CRC */
#define FIRMWARE_OFFSET_FILE_CRC 4
/* Offset ( in the firmware file's header ) to the real data */
#define FIRMWARE_OFFSET_FILE_DATA 6

33
firmware/export/config.h Normal file
View file

@ -0,0 +1,33 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 by Daniel 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 __CONFIG_H__
#define __CONFIG_H__
#if defined(ARCHOS_PLAYER)
#include "config-player.h"
#elif defined(ARCHOS_RECORDER)
#include "config-recorder.h"
#elif defined(ARCHOS_FMRECORDER)
#include "config-fmrecorder.h"
#else
/* no known platform */
#endif
#endif

51
firmware/export/debug.h Normal file
View file

@ -0,0 +1,51 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 by Linus Nielsen Feltzing
*
* 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 DEBUG_H
#define DEBUG_H
extern void debug_init(void);
extern void debugf(char* fmt,...);
extern void ldebugf(char* file, int line, char *fmt, ...);
#ifdef __GNUC__
/* */
#if defined(SIMULATOR)
#define DEBUGF debugf
#define LDEBUGF(...) ldebugf(__FILE__, __LINE__, __VA_ARGS__)
#else
#if defined(DEBUG)
#define DEBUGF debugf
#define LDEBUGF debugf
#else
#define DEBUGF(...)
#define LDEBUGF(...)
#endif
#endif
#else
#define DEBUGF debugf
#define LDEBUGF debugf
#endif /* GCC */
#endif

35
firmware/export/disk.h Normal file
View file

@ -0,0 +1,35 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 by Bjö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 _DISK_H_
#define _DISK_H_
struct partinfo {
unsigned long start; /* first sector (LBA) */
unsigned long size; /* number of sectors */
unsigned char type;
};
#define PARTITION_TYPE_FAT32 0x0b
#define PARTITION_TYPE_FAT32_LBA 0x0c
/* returns a pointer to an array of 8 partinfo structs */
struct partinfo* disk_init(void);
struct partinfo* disk_partinfo(int partition);
#endif

116
firmware/export/font.h Normal file
View file

@ -0,0 +1,116 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (c) 2002 by Greg Haerr <greg@censoft.com>
*
* 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.
*
****************************************************************************/
/*
* Incore font and image definitions
*/
#include "config.h"
#if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR)
/* max static loadable fonts buffer*/
#ifndef MAX_FONT_SIZE
#define MAX_FONT_SIZE 9000 /* max total fontsize allocation*/
#endif
/*
* Fonts are specified by number, and used for display
* of menu information as well as mp3 filename data.
* At system startup, up to MAXFONTS fonts are initialized,
* either by being compiled-in, or loaded from disk.
* If the font asked for does not exist, then the
* system uses the next lower font number. Font 0
* must be available at system startup.
* Fonts are specified in firmware/font.c.
*/
enum {
FONT_SYSFIXED, /* system fixed pitch font*/
FONT_UI, /* system porportional font*/
MAXFONTS
};
/*
* .fnt loadable font file format definition
*
* format len description
* ------------------------- ---- ------------------------------
* UCHAR version[4] 4 magic number and version bytes
* UCHAR name[64] 64 font name, space padded
* UCHAR copyright[256] 256 copyright info, space padded
* USHORT maxwidth 2 font max width in pixels
* USHORT height 2 font height in pixels
* USHORT ascent 2 font ascent (baseline) in pixels
* USHORT pad 2 unused, pad to 32-bit boundary
* ULONG firstchar 4 first character code in font
* ULONG defaultchar 4 default character code in font
* ULONG size 4 # characters in font
* ULONG nbits 4 # words imagebits data in file
* ULONG noffset 4 # longs offset data in file
* ULONG nwidth 4 # bytes width data in file
* MWIMAGEBITS bits nbits*2 image bits variable data
* [MWIMAGEBITS padded to 32-bit boundary]
* ULONG offset noffset*4 offset variable data
* UCHAR width nwidth*1 width variable data
*/
/* loadable font magic and version #*/
#define VERSION "RB11"
typedef unsigned short bitmap_t; /* bitmap image unit size*/
/* bitmap_t helper macros*/
#define BITMAP_WORDS(x) (((x)+15)/16) /* image size in words*/
#define BITMAP_BYTES(x) (BITMAP_WORDS(x)*sizeof(bitmap_t))
#define BITMAP_BITSPERIMAGE (sizeof(bitmap_t) * 8)
#define BITMAP_BITVALUE(n) ((bitmap_t) (((bitmap_t) 1) << (n)))
#define BITMAP_FIRSTBIT (BITMAP_BITVALUE(BITMAP_BITSPERIMAGE - 1))
#define BITMAP_TESTBIT(m) ((m) & BITMAP_FIRSTBIT)
#define BITMAP_SHIFTBIT(m) ((bitmap_t) ((m) << 1))
/* builtin C-based proportional/fixed font structure */
/* based on The Microwindows Project http://microwindows.org */
struct font {
char * name; /* font name*/
int maxwidth; /* max width in pixels*/
unsigned int height; /* height in pixels*/
int ascent; /* ascent (baseline) height*/
int firstchar; /* first character in bitmap*/
int size; /* font size in glyphs*/
bitmap_t *bits; /* 16-bit right-padded bitmap data*/
unsigned long *offset; /* offsets into bitmap data*/
unsigned char *width; /* character widths or NULL if fixed*/
int defaultchar; /* default char (not glyph index)*/
long bits_size; /* # words of bitmap_t bits*/
};
/* font routines*/
void font_init(void);
struct font* font_load(char *path);
struct font* font_get(int font);
void font_reset(void);
#else /* HAVE_LCD_BITMAP */
#define font_init()
#define font_load(x)
#endif
/* -----------------------------------------------------------------
* vim: et sw=4 ts=8 sts=4 tw=78
*/

View file

@ -0,0 +1,37 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 by Linus Nielsen Feltzing
*
* 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 HWCOMPAT_H
#define HWCOMPAT_H
#include <stdbool.h>
#include "config.h"
/* Bit mask values for HW compatibility */
#define ATA_ADDRESS_200 0x0100
#define USB_ACTIVE_HIGH 0x0100
#define PR_ACTIVE_HIGH 0x0100
int read_rom_version(void);
int read_hw_mask(void);
#ifdef HAVE_LCD_CHARCELLS
bool has_new_lcd(void);
#endif
#endif

76
firmware/export/id3.h Normal file
View file

@ -0,0 +1,76 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 by Daniel 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 ID3_H
#define ID3_H
#include "file.h"
struct mp3entry {
char path[MAX_PATH];
char *title;
char *artist;
char *album;
int tracknum;
int version;
int layer;
int year;
unsigned char id3version;
unsigned char genre;
unsigned int bitrate;
unsigned int frequency;
unsigned int id3v2len;
unsigned int id3v1len;
unsigned int first_frame_offset; /* Byte offset to first real MP3 frame.
Used for skipping leading garbage to
avoid gaps between tracks. */
unsigned int filesize; /* in bytes */
unsigned int length; /* song length */
unsigned int elapsed; /* ms played */
long bpf; /* bytes per frame */
long tpf; /* time per frame */
/* Xing VBR fields */
bool vbr;
unsigned char vbrflags;
unsigned char toc[100];/* table of contents */
/* these following two fields are used for local buffering */
char id3v2buf[300];
char id3v1buf[3][32];
/* resume related */
int offset; /* bytes played */
int index; /* playlist index */
};
#define VBR_FRAMES_FLAG 0x01
#define VBR_BYTES_FLAG 0x02
#define VBR_TOC_FLAG 0x04
enum {
ID3_VER_1_0 = 1,
ID3_VER_1_1,
ID3_VER_2_2,
ID3_VER_2_3,
ID3_VER_2_4
};
bool mp3info(struct mp3entry *entry, char *filename);
#endif

116
firmware/export/mpeg.h Normal file
View file

@ -0,0 +1,116 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 by Linus Nielsen Feltzing
*
* 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 _MPEG_H_
#define _MPEG_H_
#include <stdbool.h>
#define MPEG_SWAP_CHUNKSIZE 0x2000
#define MPEG_HIGH_WATER 2 /* We leave 2 bytes empty because otherwise we
wouldn't be able to see the difference between
an empty buffer and a full one. */
#define MPEG_LOW_WATER 0x60000
#define MPEG_LOW_WATER_CHUNKSIZE 0x40000
#define MPEG_LOW_WATER_SWAP_CHUNKSIZE 0x10000
#define MPEG_PLAY_PENDING_THRESHOLD 0x10000
#define MPEG_PLAY_PENDING_SWAPSIZE 0x10000
struct mpeg_debug
{
int mp3buflen;
int mp3buf_write;
int mp3buf_swapwrite;
int mp3buf_read;
int last_dma_chunk_size;
bool dma_on;
bool playing;
bool play_pending;
bool is_playing;
bool filling;
bool dma_underrun;
int unplayed_space;
int playable_space;
int unswapped_space;
int low_watermark_level;
int lowest_watermark_level;
};
void mpeg_init(int volume, int bass, int treble, int balance,
int loudness, int bass_boost, int avc);
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 change);
void mpeg_flush_and_reload_tracks(void);
void mpeg_sound_set(int setting, int value);
int mpeg_sound_min(int setting);
int mpeg_sound_max(int setting);
int mpeg_sound_default(int setting);
void mpeg_sound_channel_config(int configuration);
int mpeg_val2phys(int setting, int value);
int mpeg_phys2val(int setting, int value);
char *mpeg_sound_unit(int setting);
int mpeg_sound_numdecimals(int setting);
struct mp3entry* mpeg_current_track(void);
bool mpeg_has_changed_track(void);
int mpeg_status(void);
#if defined(HAVE_MAS3587F) || defined(SIMULATOR)
void mpeg_set_pitch(int percent);
void mpeg_init_recording(void);
void mpeg_init_playback(void);
void mpeg_record(char *filename);
void mpeg_set_recording_options(int frequency, int quality,
int source, int channel_mode);
void mpeg_set_recording_gain(int left, int right, int mic);
unsigned long mpeg_num_recorded_frames(void);
unsigned long mpeg_num_recorded_bytes(void);
#endif
void mpeg_get_debugdata(struct mpeg_debug *dbgdata);
void mpeg_set_buffer_margin(int seconds);
#define SOUND_VOLUME 0
#define SOUND_BASS 1
#define SOUND_TREBLE 2
#define SOUND_BALANCE 3
#define SOUND_LOUDNESS 4
#define SOUND_SUPERBASS 5
#define SOUND_AVC 6
#define SOUND_CHANNELS 7
#define SOUND_LEFT_GAIN 8
#define SOUND_RIGHT_GAIN 9
#define SOUND_MIC_GAIN 10
#define SOUND_NUMSETTINGS 11
#define MPEG_SOUND_STEREO 0
#define MPEG_SOUND_MONO 1
#define MPEG_SOUND_MONO_LEFT 2
#define MPEG_SOUND_MONO_RIGHT 3
#define MPEG_STATUS_PLAY 1
#define MPEG_STATUS_PAUSE 2
#define MPEG_STATUS_RECORD 4
#endif

25
firmware/export/panic.h Normal file
View file

@ -0,0 +1,25 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 by wavey@wavey.org
*
* 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 __PANIC_H__
#define __PANIC_H__
void panicf( char *fmt, ... );
#endif /* __PANIC_H__ */

101
firmware/export/powermgmt.h Normal file
View file

@ -0,0 +1,101 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 by Heikki Hannikainen, Uwe Freese
*
* 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 _POWERMGMT_H_
#define _POWERMGMT_H_
#ifndef SIMULATOR
#ifdef HAVE_LIION /* FM Recorder, LiIon */
#define BATTERY_LEVEL_SHUTDOWN 260 /* 2.60V */
#define BATTERY_LEVEL_EMPTY 265 /* 2.65V */
#define BATTERY_LEVEL_DANGEROUS 280 /* 2.80V */
#define BATTERY_LEVEL_FULL 400 /* 4.00V */
#else /* Recorder, NiMH */
#define BATTERY_LEVEL_SHUTDOWN 450 /* 4.50V */
#define BATTERY_LEVEL_EMPTY 465 /* 4.65V */
#define BATTERY_LEVEL_DANGEROUS 475 /* 4.75V */
#define BATTERY_LEVEL_FULL 585 /* 5.85V */
#endif
#define BATTERY_RANGE (BATTERY_LEVEL_FULL - BATTERY_LEVEL_EMPTY)
#define BATTERY_CAPACITY_MAX 2400 /* max. capacity that can be selected in settings menu, min. is always 1500 */
#define POWER_HISTORY_LEN 2*60 /* 2 hours of samples, one per minute */
#define POWER_AVG_N 4 /* how many samples to take for each measurement */
#define POWER_AVG_SLEEP 9 /* how long do we sleep between each measurement */
#define CHARGE_END_NEGD 6 /* stop when N minutes have passed with
* avg delta being < -0.05 V */
#define CHARGE_END_ZEROD 50 /* stop when N minutes have passed with
* avg delta being < 0.005 V */
#ifdef HAVE_CHARGE_CTRL
#define POWER_MESSAGE_LEN 32 /* power thread status message */
#define CHARGE_MAX_TIME_1500 450 /* minutes: maximum charging time for 1500 mAh batteries */
/* actual max time depends also on BATTERY_CAPACITY! */
#define CHARGE_MIN_TIME 10 /* minutes: minimum charging time */
#define CHARGE_RESTART_HI 85 /* %: when to restart charging in 'charge' mode */
/* attention: if set too high, normal charging is started in trickle mode */
#define CHARGE_RESTART_LO 10 /* %: when to restart charging in 'discharge' mode */
#define CHARGE_PAUSE_LEN 60 /* how many minutes to pause between charging cycles */
#define TOPOFF_MAX_TIME 90 /* After charging, go to top off charge. How long should top off charge be? */
#define TOPOFF_VOLTAGE 565 /* which voltage is best? (centivolts) */
#define TRICKLE_MAX_TIME 12*60 /* After top off charge, go to trickle charge. How long should trickle charge be? */
#define TRICKLE_VOLTAGE 545 /* which voltage is best? (centivolts) */
extern char power_message[POWER_MESSAGE_LEN];
extern char charge_restart_level;
extern int powermgmt_last_cycle_startstop_min; /* how many minutes ago was the charging started or stopped? */
extern int powermgmt_last_cycle_level; /* which level had the batteries at this time? */
extern int battery_lazyness[20]; /* how does the battery react when plugging in/out the charger */
void enable_trickle_charge(bool on);
extern int trickle_sec; /* trickle charge: How many seconds per minute are we charging actually? */
extern int charge_state; /* tells what the charger is doing (for info display): 0: decharging/charger off, 1: charge, 2: top-off, 3: trickle */
#endif /* HAVE_CHARGE_CTRL */
#define CURRENT_NORMAL 145 /* usual current in mA when using the AJB including some disk/backlight/... activity */
#define CURRENT_USB 500 /* usual current in mA in USB mode */
#define CURRENT_BACKLIGHT 30 /* additional current when backlight is always on */
#define CURRENT_CHARGING 300 /* charging current */
extern unsigned short power_history[POWER_HISTORY_LEN];
/* Start up power management thread */
void power_init(void);
#endif /* SIMULATOR */
/* Returns battery level in percent */
int battery_level(void);
int battery_time(void); /* minutes */
/* Tells if the battery level is safe for disk writes */
bool battery_level_safe(void);
void set_poweroff_timeout(int timeout);
void set_battery_capacity(int capacity); /* set local battery capacity value */
void set_sleep_timer(int seconds);
int get_sleep_timer(void);
#endif

24
firmware/export/rolo.h Normal file
View file

@ -0,0 +1,24 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 Randy D. Wood
*
* 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 __ROLO_H__
#define __ROLO_H__
void rolo_load(char* file);
#endif

267
firmware/export/system.h Normal file
View file

@ -0,0 +1,267 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 by Alan Korr
*
* 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 __SYSTEM_H__
#define __SYSTEM_H__
#include "sh7034.h"
#include "config.h"
#define FREQ CPU_FREQ
#define BAUDRATE 9600
#ifndef NULL
#define NULL ((void*)0)
#endif
#ifndef MIN
#define MIN(a, b) (((a)<(b))?(a):(b))
#endif
#ifndef MAX
#define MAX(a, b) (((a)>(b))?(a):(b))
#endif
#ifdef LITTLE_ENDIAN
#define SWAB16(x) (x)
#define SWAB32(x) (x)
#endif
#define nop \
asm volatile ("nop")
#define __set_mask_constant(mask,address) \
asm \
("or.b\t%0,@(r0,gbr)" \
: \
: /* %0 */ "I"((char)(mask)), \
/* %1 */ "z"(address-GBR))
#define __clear_mask_constant(mask,address) \
asm \
("and.b\t%0,@(r0,gbr)" \
: \
: /* %0 */ "I"((char)~(mask)), \
/* %1 */ "z"(address-GBR))
#define __toggle_mask_constant(mask,address) \
asm \
("xor.b\t%0,@(r0,gbr)" \
: \
: /* %0 */ "I"((char)(mask)), \
/* %1 */ "z"(address-GBR))
#define __test_mask_constant(mask,address) \
({ \
int result; \
asm \
("tst.b\t%1,@(r0,gbr)\n\tmovt\t%0" \
: "=r"(result) \
: "I"((char)(mask)),"z"(address-GBR)); \
result; \
})
#define __set_bit_constant(bit,address) \
asm \
("or.b\t%0,@(r0,gbr)" \
: \
: /* %0 */ "I"((char)(1<<(bit))), \
/* %1 */ "z"(address-GBR))
#define __clear_bit_constant(bit,address) \
asm \
("and.b\t%0,@(r0,gbr)" \
: \
: /* %0 */ "I"((char)~(1<<(bit))), \
/* %1 */ "z"(address-GBR))
#define __toggle_bit_constant(bit,address) \
asm \
("xor.b\t%0,@(r0,gbr)" \
: \
: /* %0 */ "I"((char)(1<<(bit))), \
/* %1 */ "z"(address-GBR))
#define __test_bit_constant(bit,address) \
({ \
int result; \
asm \
("tst.b\t%1,@(r0,gbr)\n\tmovt\t%0" \
: "=r"(result) \
: "I"((char)(1<<(bit))),"z"(address-GBR)); \
result; \
})
#define __set_mask(mask,address) /* FIXME */
#define __test_mask(mask,address) 0 /* FIXME */
#define __clear_mask(mask,address) /* FIXME */
#define __toggle_mask(mask,address) /* FIXME */
#define __set_bit(bit,address) /* FIXME */
#define __test_bit(bit,address) 0 /* FIXME */
#define __clear_bit(bit,address) /* FIXME */
#define __toggle_bit(bit,address) /* FIXME */
#define set_mask(mask,address) \
if (__builtin_constant_p (mask)) \
__set_mask_constant (mask,address); \
else \
__set_mask (mask,address)
#define clear_mask(mask,address) \
if (__builtin_constant_p (mask)) \
__clear_mask_constant (mask,address); \
else \
__clear_mask (mask,address)
#define toggle_mask(mask,address) \
if (__builtin_constant_p (mask)) \
__toggle_mask_constant (mask,address); \
else \
__toggle_mask (mask,address)
#define test_mask(mask,address) \
( \
(__builtin_constant_p (mask)) \
? (int)__test_mask_constant (mask,address) \
: (int)__test_mask (mask,address) \
)
#define set_bit(bit,address) \
if (__builtin_constant_p (bit)) \
__set_bit_constant (bit,address); \
else \
__set_bit (bit,address)
#define clear_bit(bit,address) \
if (__builtin_constant_p (bit)) \
__clear_bit_constant (bit,address); \
else \
__clear_bit (bit,address)
#define toggle_bit(bit,address) \
if (__builtin_constant_p (bit)) \
__toggle_bit_constant (bit,address); \
else \
__toggle_bit (bit,address)
#define test_bit(bit,address) \
( \
(__builtin_constant_p (bit)) \
? (int)__test_bit_constant (bit,address) \
: (int)__test_bit (bit,address) \
)
extern char __swap_bit[256];
#define swap_bit(byte) \
__swap_bit[byte]
#ifndef SIMULATOR
static inline short SWAB16(short value)
/*
result[15..8] = value[ 7..0];
result[ 7..0] = value[15..8];
*/
{
short result;
asm volatile ("swap.b\t%1,%0" : "=r"(result) : "r"(value));
return result;
}
static inline long SWAW32(long value)
/*
result[31..16] = value[15.. 0];
result[15.. 0] = value[31..16];
*/
{
long result;
asm volatile ("swap.w\t%1,%0" : "=r"(result) : "r"(value));
return result;
}
static inline long SWAB32(long value)
/*
result[31..24] = value[ 7.. 0];
result[23..16] = value[15.. 8];
result[15.. 8] = value[23..16];
result[ 7.. 0] = value[31..24];
*/
{
asm volatile ("swap.b\t%0,%0\n"
"swap.w\t%0,%0\n"
"swap.b\t%0,%0\n" : "+r"(value));
return value;
}
/* Test And Set - UNTESTED */
static inline int tas (volatile int *pointer)
{
int result;
asm volatile ("tas.b\t@%1;movt\t%0" : "=t"(result) : "r"((char *)pointer) : "memory");
return result;
}
static inline void sti (void)
{
asm volatile ("ldc\t%0,sr" : : "r"(0<<4));
}
static inline void cli (void)
{
asm volatile ("ldc\t%0,sr" : : "r"(15<<4));
}
/* Compare And Swap */
static inline int cas (volatile int *pointer,int requested_value,int new_value)
{
cli();
if (*pointer == requested_value)
{
*pointer = new_value;
sti ();
return 1;
}
sti ();
return 0;
}
static inline int cas2 (volatile int *pointer1,volatile int *pointer2,int requested_value1,int requested_value2,int new_value1,int new_value2)
{
cli();
if (*pointer1 == requested_value1 && *pointer2 == requested_value2)
{
*pointer1 = new_value1;
*pointer2 = new_value2;
sti ();
return 1;
}
sti ();
return 0;
}
#endif
extern void system_reboot (void);
extern void system_init(void);
#endif

30
firmware/export/thread.h Normal file
View file

@ -0,0 +1,30 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 by Ulf Ralberg
*
* 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 THREAD_H
#define THREAD_H
#define MAXTHREADS 16
#define DEFAULT_STACK_SIZE 0x400 /* Bytes */
int create_thread(void* function, void* stack, int stack_size, char *name);
void switch_thread(void);
void init_threads(void);
int thread_stack_usage(int threadnum);
#endif

31
firmware/export/usb.h Normal file
View file

@ -0,0 +1,31 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 by Linus Nielsen Feltzing
*
* 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 _USB_H_
#define _USB_H_
#include "kernel.h"
void usb_init(void);
void usb_start_monitoring(void);
void usb_acknowledge(int id);
void usb_wait_for_disconnect(struct event_queue *q);
int usb_wait_for_disconnect_w_tmo(struct event_queue *q, int ticks);
bool usb_inserted(void);
#endif

View file

@ -24,7 +24,7 @@
#include "mpeg.h" #include "mpeg.h"
#include "ata.h" #include "ata.h"
#include "string.h" #include "string.h"
#include "kernel.h" #include <kernel.h>
#include "thread.h" #include "thread.h"
#ifndef SIMULATOR #ifndef SIMULATOR
#include "i2c.h" #include "i2c.h"