summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/ata.c14
-rw-r--r--firmware/drivers/button.c8
-rw-r--r--firmware/drivers/fmradio.c2
-rw-r--r--firmware/drivers/mas.c6
-rw-r--r--firmware/drivers/serial.c2
-rw-r--r--firmware/export/button.h10
-rw-r--r--firmware/export/config-fmrecorder.h8
-rw-r--r--firmware/export/config-h100.h2
-rw-r--r--firmware/export/config-ondiofm.h8
-rw-r--r--firmware/export/config-ondiosp.h8
-rw-r--r--firmware/export/config-player.h6
-rw-r--r--firmware/export/config-recorder.h6
-rw-r--r--firmware/export/config-recorderv2.h8
-rw-r--r--firmware/export/config.h21
-rw-r--r--firmware/export/mas.h8
-rw-r--r--firmware/export/mp3_playback.h4
-rw-r--r--firmware/export/mpeg.h2
-rw-r--r--firmware/mp3_playback.c76
-rw-r--r--firmware/mpeg.c64
-rw-r--r--firmware/powermgmt.c4
20 files changed, 144 insertions, 123 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index 1e889a3339..4ba5829f56 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -33,7 +33,7 @@
33/* skip whole file for an MMC-based system, FIXME in makefile */ 33/* skip whole file for an MMC-based system, FIXME in makefile */
34#ifndef HAVE_MMC 34#ifndef HAVE_MMC
35 35
36#ifdef HAVE_SCF5249 36#if CONFIG_CPU == SCF5249
37 37
38/* don't use sh7034 assembler routines */ 38/* don't use sh7034 assembler routines */
39#define PREFER_C_READING 39#define PREFER_C_READING
@@ -43,7 +43,7 @@
43#define ATA_DATA (*((volatile unsigned short*)ATA_IOBASE)) 43#define ATA_DATA (*((volatile unsigned short*)ATA_IOBASE))
44#define ATA_CONTROL (*((volatile unsigned short*)ATA_IOBASE + 0xe)) 44#define ATA_CONTROL (*((volatile unsigned short*)ATA_IOBASE + 0xe))
45 45
46#elif defined HAVE_SH7034 46#elif CONFIG_CPU == SH7034
47 47
48#define ATA_IOBASE 0x06100100 48#define ATA_IOBASE 0x06100100
49#define ATA_DATA (*((volatile unsigned short*)0x06104100)) 49#define ATA_DATA (*((volatile unsigned short*)0x06104100))
@@ -879,7 +879,7 @@ int ata_hard_reset(void)
879{ 879{
880 int ret; 880 int ret;
881 881
882#ifdef HAVE_SH7034 882#if CONFIG_CPU == SH7034
883 /* state HRR0 */ 883 /* state HRR0 */
884 and_b(~0x02, &PADRH); /* assert _RESET */ 884 and_b(~0x02, &PADRH); /* assert _RESET */
885 sleep(1); /* > 25us */ 885 sleep(1); /* > 25us */
@@ -979,7 +979,7 @@ static int master_slave_detect(void)
979 return 0; 979 return 0;
980} 980}
981 981
982#ifdef HAVE_SH7034 /* special archos quirk */ 982#if CONFIG_CPU == SH7034 /* special archos quirk */
983static int io_address_detect(void) 983static int io_address_detect(void)
984{ /* now, use the HW mask instead of probing */ 984{ /* now, use the HW mask instead of probing */
985 if (read_hw_mask() & ATA_ADDRESS_200) 985 if (read_hw_mask() & ATA_ADDRESS_200)
@@ -1001,7 +1001,7 @@ static int io_address_detect(void)
1001 1001
1002void ata_enable(bool on) 1002void ata_enable(bool on)
1003{ 1003{
1004#ifdef HAVE_SH7034 1004#if CONFIG_CPU == SH7034
1005 if(on) 1005 if(on)
1006 and_b(~0x80, &PADRL); /* enable ATA */ 1006 and_b(~0x80, &PADRL); /* enable ATA */
1007 else 1007 else
@@ -1129,7 +1129,7 @@ int ata_init(void)
1129 1129
1130 led(false); 1130 led(false);
1131 1131
1132#ifdef HAVE_SH7034 1132#if CONFIG_CPU == SH7034
1133 /* Port A setup */ 1133 /* Port A setup */
1134 or_b(0x02, &PAIORH); /* output for ATA reset */ 1134 or_b(0x02, &PAIORH); /* output for ATA reset */
1135 or_b(0x02, &PADRH); /* release ATA reset */ 1135 or_b(0x02, &PADRH); /* release ATA reset */
@@ -1159,7 +1159,7 @@ int ata_init(void)
1159 if (rc) 1159 if (rc)
1160 return -10 + rc; 1160 return -10 + rc;
1161 1161
1162#ifdef HAVE_SH7034 1162#if CONFIG_CPU == SH7034
1163 rc = io_address_detect(); 1163 rc = io_address_detect();
1164 if (rc) 1164 if (rc)
1165 return -20 + rc; 1165 return -20 + rc;
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index ebe3389454..d05f81bb45 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -36,7 +36,7 @@
36struct event_queue button_queue; 36struct event_queue button_queue;
37 37
38static int lastbtn; /* Last valid button status */ 38static int lastbtn; /* Last valid button status */
39#if defined(HAVE_RECORDER_KEYPAD) || defined(HAVE_ONDIO_KEYPAD) 39#if (CONFIG_KEYPAD == RECORDER_PAD) || (CONFIG_KEYPAD == ONDIO_PAD)
40static int last_read; /* Last button status, for debouncing/filtering */ 40static int last_read; /* Last button status, for debouncing/filtering */
41static bool flipped; /* bottons can be flipped to match the LCD flip */ 41static bool flipped; /* bottons can be flipped to match the LCD flip */
42#endif 42#endif
@@ -179,7 +179,7 @@ int button_get_w_tmo(int ticks)
179 return (ev.id != SYS_TIMEOUT)? ev.id: BUTTON_NONE; 179 return (ev.id != SYS_TIMEOUT)? ev.id: BUTTON_NONE;
180} 180}
181 181
182#ifdef HAVE_RECORDER_KEYPAD 182#if CONFIG_KEYPAD == RECORDER_PAD
183 183
184/* AJBR buttons are connected to the CPU as follows: 184/* AJBR buttons are connected to the CPU as follows:
185 * 185 *
@@ -348,7 +348,7 @@ static int button_read(void)
348 return retval; 348 return retval;
349} 349}
350 350
351#elif defined(HAVE_PLAYER_KEYPAD) 351#elif CONFIG_KEYPAD == PLAYER_PAD
352 352
353/* The player has two buttons on port pins: 353/* The player has two buttons on port pins:
354 354
@@ -397,7 +397,7 @@ static int button_read(void)
397 return btn; 397 return btn;
398} 398}
399 399
400#elif defined HAVE_ONDIO_KEYPAD 400#elif CONFIG_KEYPAD == ONDIO_PAD
401 401
402/* 402/*
403 * helper function to swap UP/DOWN, LEFT/RIGHT 403 * helper function to swap UP/DOWN, LEFT/RIGHT
diff --git a/firmware/drivers/fmradio.c b/firmware/drivers/fmradio.c
index 604005b884..a0394b2a57 100644
--- a/firmware/drivers/fmradio.c
+++ b/firmware/drivers/fmradio.c
@@ -23,7 +23,7 @@
23#include "debug.h" 23#include "debug.h"
24#include "system.h" 24#include "system.h"
25 25
26#ifdef HAVE_FMRADIO 26#ifdef CONFIG_TUNER
27 27
28/* Signals: 28/* Signals:
29 DI (Data In) - PB0 (doubles as data pin for the LCD) 29 DI (Data In) - PB0 (doubles as data pin for the LCD)
diff --git a/firmware/drivers/mas.c b/firmware/drivers/mas.c
index a6fd1d1a21..9f6e0943c7 100644
--- a/firmware/drivers/mas.c
+++ b/firmware/drivers/mas.c
@@ -132,7 +132,7 @@ int mas_writemem(int bank, int addr, const unsigned long* src, int len)
132 132
133 j = 0; 133 j = 0;
134 while(len--) { 134 while(len--) {
135#ifdef HAVE_MAS3587F 135#if CONFIG_HWCODEC == MAS3587F
136 buf[i++] = 0; 136 buf[i++] = 0;
137 buf[i++] = ptr[j+1]; 137 buf[i++] = ptr[j+1];
138 buf[i++] = ptr[j+2]; 138 buf[i++] = ptr[j+2];
@@ -232,7 +232,7 @@ static int mas_devread(unsigned long *dest, int len)
232 if (i2c_getack()) { 232 if (i2c_getack()) {
233 for (i=0;len;i++) { 233 for (i=0;len;i++) {
234 len--; 234 len--;
235#ifdef HAVE_MAS3587F 235#if CONFIG_HWCODEC == MAS3587F
236 i2c_inb(0); /* Dummy read */ 236 i2c_inb(0); /* Dummy read */
237 ptr[i*4+0] = 0; 237 ptr[i*4+0] = 0;
238 ptr[i*4+1] = i2c_inb(0) & 0x0f; 238 ptr[i*4+1] = i2c_inb(0) & 0x0f;
@@ -266,7 +266,7 @@ static int mas_devread(unsigned long *dest, int len)
266 return ret; 266 return ret;
267} 267}
268 268
269#ifdef HAVE_MAS3587F 269#if CONFIG_HWCODEC == MAS3587F
270void mas_reset(void) 270void mas_reset(void)
271{ 271{
272 or_b(0x01, &PAIORH); 272 or_b(0x01, &PAIORH);
diff --git a/firmware/drivers/serial.c b/firmware/drivers/serial.c
index bf2b26b866..8a16cfb3b5 100644
--- a/firmware/drivers/serial.c
+++ b/firmware/drivers/serial.c
@@ -87,7 +87,7 @@ int remote_control_rx(void)
87 } 87 }
88 else 88 else
89 { 89 {
90#ifndef HAVE_ONDIO_KEYPAD 90#if CONFIG_KEYPAD != ONDIO_PAD
91 switch (btn) 91 switch (btn)
92 { 92 {
93 case STOP: 93 case STOP:
diff --git a/firmware/export/button.h b/firmware/export/button.h
index 50a9b1d8fd..562344ea44 100644
--- a/firmware/export/button.h
+++ b/firmware/export/button.h
@@ -30,7 +30,7 @@ int button_get (bool block);
30int button_get_w_tmo(int ticks); 30int button_get_w_tmo(int ticks);
31int button_status(void); 31int button_status(void);
32void button_clear_queue(void); 32void button_clear_queue(void);
33#if defined(HAVE_RECORDER_KEYPAD) || defined(HAVE_ONDIO_KEYPAD) 33#if CONFIG_KEYPAD == RECORDER_PAD || CONFIG_KEYPAD == ONDIO_PAD
34void button_set_flip(bool flip); /* turn 180 degrees */ 34void button_set_flip(bool flip); /* turn 180 degrees */
35#endif 35#endif
36 36
@@ -51,7 +51,7 @@ void button_set_flip(bool flip); /* turn 180 degrees */
51#define BUTTON_RC_LEFT (BUTTON_LEFT | BUTTON_REMOTE) 51#define BUTTON_RC_LEFT (BUTTON_LEFT | BUTTON_REMOTE)
52#define BUTTON_RC_RIGHT (BUTTON_RIGHT| BUTTON_REMOTE) 52#define BUTTON_RC_RIGHT (BUTTON_RIGHT| BUTTON_REMOTE)
53 53
54#ifdef HAVE_RECORDER_KEYPAD 54#if CONFIG_KEYPAD == RECORDER_PAD
55 55
56/* Recorder specific button codes */ 56/* Recorder specific button codes */
57#define BUTTON_ON 0x0001 57#define BUTTON_ON 0x0001
@@ -66,7 +66,7 @@ void button_set_flip(bool flip); /* turn 180 degrees */
66#define BUTTON_RC_PLAY (BUTTON_PLAY | BUTTON_REMOTE) 66#define BUTTON_RC_PLAY (BUTTON_PLAY | BUTTON_REMOTE)
67#define BUTTON_RC_STOP (BUTTON_OFF | BUTTON_REMOTE) 67#define BUTTON_RC_STOP (BUTTON_OFF | BUTTON_REMOTE)
68 68
69#elif defined(HAVE_PLAYER_KEYPAD) 69#elif CONFIG_KEYPAD == PLAYER_PAD
70 70
71/* Jukebox 6000 and Studio specific button codes */ 71/* Jukebox 6000 and Studio specific button codes */
72#define BUTTON_ON 0x0001 72#define BUTTON_ON 0x0001
@@ -77,7 +77,7 @@ void button_set_flip(bool flip); /* turn 180 degrees */
77#define BUTTON_RC_PLAY (BUTTON_PLAY | BUTTON_REMOTE) 77#define BUTTON_RC_PLAY (BUTTON_PLAY | BUTTON_REMOTE)
78#define BUTTON_RC_STOP (BUTTON_STOP | BUTTON_REMOTE) 78#define BUTTON_RC_STOP (BUTTON_STOP | BUTTON_REMOTE)
79 79
80#elif defined HAVE_ONDIO_KEYPAD 80#elif CONFIG_KEYPAD == ONDIO_PAD
81 81
82/* Ondio specific button codes */ 82/* Ondio specific button codes */
83#define BUTTON_OFF 0x0002 83#define BUTTON_OFF 0x0002
@@ -85,7 +85,7 @@ void button_set_flip(bool flip); /* turn 180 degrees */
85#define BUTTON_DOWN 0x0020 85#define BUTTON_DOWN 0x0020
86#define BUTTON_MENU 0x0100 86#define BUTTON_MENU 0x0100
87 87
88#endif /* HAVE_RECORDER/PLAYER/ONDIO_KEYPAD */ 88#endif /* RECORDER/PLAYER/ONDIO KEYPAD */
89 89
90#endif /* _BUTTON_H_ */ 90#endif /* _BUTTON_H_ */
91 91
diff --git a/firmware/export/config-fmrecorder.h b/firmware/export/config-fmrecorder.h
index 4f9decf74b..af7ca91315 100644
--- a/firmware/export/config-fmrecorder.h
+++ b/firmware/export/config-fmrecorder.h
@@ -9,7 +9,7 @@
9#define LCD_HEIGHT 64 9#define LCD_HEIGHT 64
10 10
11/* define this if you have a Recorder style 10-key keyboard */ 11/* define this if you have a Recorder style 10-key keyboard */
12#define HAVE_RECORDER_KEYPAD 1 12#define CONFIG_KEYPAD RECORDER_PAD
13 13
14/* define this if you have a real-time clock */ 14/* define this if you have a real-time clock */
15#define HAVE_RTC 1 15#define HAVE_RTC 1
@@ -17,10 +17,10 @@
17#ifndef SIMULATOR 17#ifndef SIMULATOR
18 18
19/* Define this if you have a MAS3587F */ 19/* Define this if you have a MAS3587F */
20#define HAVE_MAS3587F 20#define CONFIG_HWCODEC MAS3587F
21 21
22/* Define this if you have a SH7034 */ 22/* Define this if you have a SH7034 */
23#define HAVE_SH7034 23#define CONFIG_CPU SH7034
24 24
25/* Define this if you have a FM Recorder key system */ 25/* Define this if you have a FM Recorder key system */
26#define HAVE_FMADC 1 26#define HAVE_FMADC 1
@@ -56,7 +56,7 @@
56#define HAVE_ALARM_MOD 1 56#define HAVE_ALARM_MOD 1
57 57
58/* Define this if you have an FM Radio */ 58/* Define this if you have an FM Radio */
59#define HAVE_FMRADIO 1 59#define CONFIG_TUNER S1A0903X01
60 60
61/* How to detect USB */ 61/* How to detect USB */
62#define USB_FMRECORDERSTYLE 1 62#define USB_FMRECORDERSTYLE 1
diff --git a/firmware/export/config-h100.h b/firmware/export/config-h100.h
index 9917b63e68..6343ebd9e2 100644
--- a/firmware/export/config-h100.h
+++ b/firmware/export/config-h100.h
@@ -9,7 +9,7 @@
9#define LCD_HEIGHT 128 9#define LCD_HEIGHT 128
10 10
11/* define this if you have the Recorder's 10-key keyboard */ 11/* define this if you have the Recorder's 10-key keyboard */
12#define HAVE_RECORDER_KEYPAD 1 12#define CONFIG_KEYPAD RECORDER_PAD
13 13
14#ifndef SIMULATOR 14#ifndef SIMULATOR
15 15
diff --git a/firmware/export/config-ondiofm.h b/firmware/export/config-ondiofm.h
index 36fd095507..d27444840b 100644
--- a/firmware/export/config-ondiofm.h
+++ b/firmware/export/config-ondiofm.h
@@ -9,15 +9,15 @@
9#define LCD_HEIGHT 64 9#define LCD_HEIGHT 64
10 10
11/* define this if you have an Ondio style 6-key keyboard */ 11/* define this if you have an Ondio style 6-key keyboard */
12#define HAVE_ONDIO_KEYPAD 12#define CONFIG_KEYPAD ONDIO_PAD
13 13
14#ifndef SIMULATOR 14#ifndef SIMULATOR
15 15
16/* Define this if you have a SH7034 */ 16/* Define this if you have a SH7034 */
17#define HAVE_SH7034 17#define CONFIG_CPU SH7034
18 18
19/* Define this if you have a MAS3587F */ 19/* Define this if you have a MAS3587F */
20#define HAVE_MAS3587F 20#define CONFIG_HWCODEC MAS3587F
21 21
22/* Define this if you have a LiIon battery */ 22/* Define this if you have a LiIon battery */
23/* #define HAVE_LIION */ 23/* #define HAVE_LIION */
@@ -50,7 +50,7 @@
50/* #define HAVE_ALARM_MOD 1 */ 50/* #define HAVE_ALARM_MOD 1 */
51 51
52/* Define this if you have an FM Radio */ 52/* Define this if you have an FM Radio */
53#define HAVE_FMRADIO 1 53#define CONFIG_TUNER TEA5767
54 54
55/* How to detect USB */ 55/* How to detect USB */
56#define USB_FMRECORDERSTYLE 1 /* like FM, on AN1 */ 56#define USB_FMRECORDERSTYLE 1 /* like FM, on AN1 */
diff --git a/firmware/export/config-ondiosp.h b/firmware/export/config-ondiosp.h
index 4b276db54f..0a270e8ae5 100644
--- a/firmware/export/config-ondiosp.h
+++ b/firmware/export/config-ondiosp.h
@@ -9,15 +9,15 @@
9#define LCD_HEIGHT 64 9#define LCD_HEIGHT 64
10 10
11/* define this if you have an Ondio style 6-key keyboard */ 11/* define this if you have an Ondio style 6-key keyboard */
12#define HAVE_ONDIO_KEYPAD 12#define CONFIG_KEYPAD ONDIO_PAD
13 13
14#ifndef SIMULATOR 14#ifndef SIMULATOR
15 15
16/* Define this if you have a SH7034 */ 16/* Define this if you have a SH7034 */
17#define HAVE_SH7034 17#define CONFIG_CPU SH7034
18 18
19/* Define this if you have a MAS3587F */ 19/* Define this if you have a MAS3539F */
20#define HAVE_MAS3587F 20#define CONFIG_HWCODEC MAS3587F /* will be MAS3539F once prepared */
21 21
22/* Define this if you have a LiIon battery */ 22/* Define this if you have a LiIon battery */
23/* #define HAVE_LIION */ 23/* #define HAVE_LIION */
diff --git a/firmware/export/config-player.h b/firmware/export/config-player.h
index 99d5a61240..8bd63c42e6 100644
--- a/firmware/export/config-player.h
+++ b/firmware/export/config-player.h
@@ -6,15 +6,15 @@
6#define LCD_HEIGHT (4*16+2*24) /* 4*char + 2*icons */ 6#define LCD_HEIGHT (4*16+2*24) /* 4*char + 2*icons */
7 7
8/* define this if you have the Player's keyboard */ 8/* define this if you have the Player's keyboard */
9#define HAVE_PLAYER_KEYPAD 1 9#define CONFIG_KEYPAD PLAYER_PAD
10 10
11#ifndef SIMULATOR 11#ifndef SIMULATOR
12 12
13/* Define this if you have a SH7034 */ 13/* Define this if you have a SH7034 */
14#define HAVE_SH7034 14#define CONFIG_CPU SH7034
15 15
16/* Define this if you have a MAS3507D */ 16/* Define this if you have a MAS3507D */
17#define HAVE_MAS3507D 17#define CONFIG_HWCODEC MAS3507D
18 18
19/* Define this if you have a DAC3550A */ 19/* Define this if you have a DAC3550A */
20#define HAVE_DAC3550A 20#define HAVE_DAC3550A
diff --git a/firmware/export/config-recorder.h b/firmware/export/config-recorder.h
index 704e9e6d8d..89e19f32f6 100644
--- a/firmware/export/config-recorder.h
+++ b/firmware/export/config-recorder.h
@@ -9,7 +9,7 @@
9#define LCD_HEIGHT 64 9#define LCD_HEIGHT 64
10 10
11/* define this if you have the Recorder's 10-key keyboard */ 11/* define this if you have the Recorder's 10-key keyboard */
12#define HAVE_RECORDER_KEYPAD 1 12#define CONFIG_KEYPAD RECORDER_PAD
13 13
14/* define this if you have a real-time clock */ 14/* define this if you have a real-time clock */
15#define HAVE_RTC 1 15#define HAVE_RTC 1
@@ -17,10 +17,10 @@
17#ifndef SIMULATOR 17#ifndef SIMULATOR
18 18
19/* Define this if you have a MAS3587F */ 19/* Define this if you have a MAS3587F */
20#define HAVE_MAS3587F 20#define CONFIG_HWCODEC MAS3587F
21 21
22/* Define this if you have a SH7034 */ 22/* Define this if you have a SH7034 */
23#define HAVE_SH7034 23#define CONFIG_CPU SH7034
24 24
25/* Define this if you have charging control */ 25/* Define this if you have charging control */
26#define HAVE_CHARGE_CTRL 26#define HAVE_CHARGE_CTRL
diff --git a/firmware/export/config-recorderv2.h b/firmware/export/config-recorderv2.h
index efec9c20d1..56967cfa10 100644
--- a/firmware/export/config-recorderv2.h
+++ b/firmware/export/config-recorderv2.h
@@ -9,7 +9,7 @@
9#define LCD_HEIGHT 64 9#define LCD_HEIGHT 64
10 10
11/* define this if you have a Recorder style 10-key keyboard */ 11/* define this if you have a Recorder style 10-key keyboard */
12#define HAVE_RECORDER_KEYPAD 1 12#define CONFIG_KEYPAD RECORDER_PAD
13 13
14/* define this if you have a real-time clock */ 14/* define this if you have a real-time clock */
15#define HAVE_RTC 1 15#define HAVE_RTC 1
@@ -17,10 +17,10 @@
17#ifndef SIMULATOR 17#ifndef SIMULATOR
18 18
19/* Define this if you have a SH7034 */ 19/* Define this if you have a SH7034 */
20#define HAVE_SH7034 20#define CONFIG_CPU SH7034
21 21
22/* Define this if you have a MAS3587F */ 22/* Define this if you have a MAS3587F */
23#define HAVE_MAS3587F 23#define CONFIG_HWCODEC MAS3587F
24 24
25/* Define this if you have a FM Recorder key system */ 25/* Define this if you have a FM Recorder key system */
26#define HAVE_FMADC 1 26#define HAVE_FMADC 1
@@ -56,7 +56,7 @@
56#define HAVE_ALARM_MOD 1 56#define HAVE_ALARM_MOD 1
57 57
58/* Define this if you have an FM Radio */ 58/* Define this if you have an FM Radio */
59#define HAVE_FMRADIO 1 59#define CONFIG_TUNER S1A0903X01
60 60
61/* How to detect USB */ 61/* How to detect USB */
62#define USB_FMRECORDERSTYLE 1 62#define USB_FMRECORDERSTYLE 1
diff --git a/firmware/export/config.h b/firmware/export/config.h
index 49306d4e81..524a2249d3 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -20,6 +20,27 @@
20#ifndef __CONFIG_H__ 20#ifndef __CONFIG_H__
21#define __CONFIG_H__ 21#define __CONFIG_H__
22 22
23/* symbolic names for multiple choice configurations: */
24
25/* CONFIG_TUNER */
26#define S1A0903X01 0 /* Samsung */
27#define TEA5767 1 /* Philips */
28
29/* CONFIG_HWCODEC */
30#define MAS3587F 3587
31#define MAS3507D 3507
32#define MAS3539F 3539
33
34/* CONFIG_CPU */
35#define SH7034 7034
36#define SCF5249 5249
37
38/* CONFIG_KEYPAD */
39#define PLAYER_PAD 0
40#define RECORDER_PAD 1
41#define ONDIO_PAD 2
42
43/* now go and pick yours */
23#if defined(ARCHOS_PLAYER) 44#if defined(ARCHOS_PLAYER)
24#include "config-player.h" 45#include "config-player.h"
25#elif defined(ARCHOS_RECORDER) 46#elif defined(ARCHOS_RECORDER)
diff --git a/firmware/export/mas.h b/firmware/export/mas.h
index 8a60389ade..dac946ea63 100644
--- a/firmware/export/mas.h
+++ b/firmware/export/mas.h
@@ -27,7 +27,7 @@
27/* 27/*
28 MAS I2C defs 28 MAS I2C defs
29*/ 29*/
30#ifdef HAVE_MAS3587F 30#if CONFIG_HWCODEC == MAS3587F
31#define MAS_ADR 0x3c 31#define MAS_ADR 0x3c
32#define MAS_DEV_WRITE (MAS_ADR | 0x00) 32#define MAS_DEV_WRITE (MAS_ADR | 0x00)
33#define MAS_DEV_READ (MAS_ADR | 0x01) 33#define MAS_DEV_READ (MAS_ADR | 0x01)
@@ -38,7 +38,7 @@
38#endif 38#endif
39 39
40/* registers..*/ 40/* registers..*/
41#ifdef HAVE_MAS3587F 41#if CONFIG_HWCODEC == MAS3587F
42#define MAS_DATA_WRITE 0x68 42#define MAS_DATA_WRITE 0x68
43#define MAS_DATA_READ 0x69 43#define MAS_DATA_READ 0x69
44#define MAS_CODEC_WRITE 0x6c 44#define MAS_CODEC_WRITE 0x6c
@@ -62,7 +62,7 @@
62#define MAS_REG_KPRESCALE 0xe7 62#define MAS_REG_KPRESCALE 0xe7
63#define MAS_REG_KBASS 0x6b 63#define MAS_REG_KBASS 0x6b
64#define MAS_REG_KTREBLE 0x6f 64#define MAS_REG_KTREBLE 0x6f
65#ifdef HAVE_MAS3587F 65#if CONFIG_HWCODEC == MAS3587F
66#define MAS_REG_KMDB_SWITCH 0x21 66#define MAS_REG_KMDB_SWITCH 0x21
67#define MAS_REG_KMDB_STR 0x22 67#define MAS_REG_KMDB_STR 0x22
68#define MAS_REG_KMDB_HAR 0x23 68#define MAS_REG_KMDB_HAR 0x23
@@ -78,7 +78,7 @@
78/* 78/*
79 * MAS commands 79 * MAS commands
80 */ 80 */
81#ifdef HAVE_MAS3587F 81#if CONFIG_HWCODEC == MAS3587F
82#define MAS_CMD_READ_ANCILLARY 0x50 82#define MAS_CMD_READ_ANCILLARY 0x50
83#define MAS_CMD_FAST_PRG_DL 0x60 83#define MAS_CMD_FAST_PRG_DL 0x60
84#define MAS_CMD_READ_IC_VER 0x70 84#define MAS_CMD_READ_IC_VER 0x70
diff --git a/firmware/export/mp3_playback.h b/firmware/export/mp3_playback.h
index 12ef734bfe..dd56940c37 100644
--- a/firmware/export/mp3_playback.h
+++ b/firmware/export/mp3_playback.h
@@ -39,13 +39,13 @@ int mpeg_val2phys(int setting, int value);
39const char *mpeg_sound_unit(int setting); 39const char *mpeg_sound_unit(int setting);
40int mpeg_sound_numdecimals(int setting); 40int mpeg_sound_numdecimals(int setting);
41int mpeg_sound_steps(int setting); 41int mpeg_sound_steps(int setting);
42#if defined(HAVE_MAS3587F) || defined(SIMULATOR) 42#if CONFIG_HWCODEC == MAS3587F || defined(SIMULATOR)
43void mpeg_set_pitch(int percent); 43void mpeg_set_pitch(int percent);
44#endif 44#endif
45 45
46 46
47/* exported just for mpeg.c, to keep the recording there */ 47/* exported just for mpeg.c, to keep the recording there */
48#ifdef HAVE_MAS3587F 48#if CONFIG_HWCODEC == MAS3587F
49void demand_irq_enable(bool on); 49void demand_irq_enable(bool on);
50#endif 50#endif
51 51
diff --git a/firmware/export/mpeg.h b/firmware/export/mpeg.h
index 3088dc5ffd..66e6ad950c 100644
--- a/firmware/export/mpeg.h
+++ b/firmware/export/mpeg.h
@@ -74,7 +74,7 @@ struct mp3entry* mpeg_current_track(void);
74struct mp3entry* mpeg_next_track(void); 74struct mp3entry* mpeg_next_track(void);
75bool mpeg_has_changed_track(void); 75bool mpeg_has_changed_track(void);
76int mpeg_status(void); 76int mpeg_status(void);
77#if defined(HAVE_MAS3587F) || defined(SIMULATOR) 77#if (CONFIG_HWCODEC == MAS3587F) || defined(SIMULATOR)
78void mpeg_init_recording(void); 78void mpeg_init_recording(void);
79void mpeg_init_playback(void); 79void mpeg_init_playback(void);
80void mpeg_record(const char *filename); 80void mpeg_record(const char *filename);
diff --git a/firmware/mp3_playback.c b/firmware/mp3_playback.c
index 7f96ee075a..fae8377c4b 100644
--- a/firmware/mp3_playback.c
+++ b/firmware/mp3_playback.c
@@ -35,7 +35,7 @@
35#endif 35#endif
36 36
37/* hacking into mpeg.c, recording is still there */ 37/* hacking into mpeg.c, recording is still there */
38#ifdef HAVE_MAS3587F 38#if CONFIG_HWCODEC == MAS3587F
39enum 39enum
40{ 40{
41 MPEG_DECODER, 41 MPEG_DECODER,
@@ -44,7 +44,7 @@ enum
44 44
45extern unsigned long shadow_7f1; 45extern unsigned long shadow_7f1;
46 46
47#endif /* #ifdef HAVE_MAS3587F */ 47#endif /* #ifdef MAS3587F */
48 48
49/**** globals ****/ 49/**** globals ****/
50 50
@@ -124,7 +124,7 @@ static const int steps[] =
124static const int minval[] = 124static const int minval[] =
125{ 125{
126 0, /* Volume */ 126 0, /* Volume */
127#ifdef HAVE_MAS3587F 127#if CONFIG_HWCODEC == MAS3587F
128 -12, /* Bass */ 128 -12, /* Bass */
129 -12, /* Treble */ 129 -12, /* Treble */
130#else 130#else
@@ -149,7 +149,7 @@ static const int minval[] =
149static const int maxval[] = 149static const int maxval[] =
150{ 150{
151 100, /* Volume */ 151 100, /* Volume */
152#ifdef HAVE_MAS3587F 152#if CONFIG_HWCODEC == MAS3587F
153 12, /* Bass */ 153 12, /* Bass */
154 12, /* Treble */ 154 12, /* Treble */
155#else 155#else
@@ -174,7 +174,7 @@ static const int maxval[] =
174static const int defaultval[] = 174static const int defaultval[] =
175{ 175{
176 70, /* Volume */ 176 70, /* Volume */
177#ifdef HAVE_MAS3587F 177#if CONFIG_HWCODEC == MAS3587F
178 6, /* Bass */ 178 6, /* Bass */
179 6, /* Treble */ 179 6, /* Treble */
180#else 180#else
@@ -238,7 +238,7 @@ static bool mpeg_is_initialized = false;
238 238
239unsigned long mas_version_code; 239unsigned long mas_version_code;
240 240
241#ifdef HAVE_MAS3507D 241#if CONFIG_HWCODEC == MAS3507D
242 242
243static const unsigned int bass_table[] = 243static const unsigned int bass_table[] =
244{ 244{
@@ -333,7 +333,7 @@ static const unsigned int prescale_table[] =
333 333
334bool dma_on; /* The DMA is active */ 334bool dma_on; /* The DMA is active */
335 335
336#ifdef HAVE_MAS3507D 336#if CONFIG_HWCODEC == MAS3507D
337static void mas_poll_start(int interval_in_ms) 337static void mas_poll_start(int interval_in_ms)
338{ 338{
339 unsigned int count; 339 unsigned int count;
@@ -393,7 +393,7 @@ static void postpone_dma_tick(void)
393#endif 393#endif
394 394
395 395
396#ifdef HAVE_MAS3587F 396#if CONFIG_HWCODEC == MAS3587F
397void demand_irq_enable(bool on) 397void demand_irq_enable(bool on)
398{ 398{
399 int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL); 399 int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL);
@@ -408,7 +408,7 @@ void demand_irq_enable(bool on)
408 408
409 set_irq_level(oldlevel); 409 set_irq_level(oldlevel);
410} 410}
411#endif /* #ifdef HAVE_MAS3587F */ 411#endif /* #if CONFIG_HWCODEC == MAS3587F */
412 412
413 413
414void play_tick(void) 414void play_tick(void)
@@ -455,10 +455,10 @@ void IMIA1(void) /* Timer 1 interrupt */
455 if(playing) 455 if(playing)
456 play_tick(); 456 play_tick();
457 TSR1 &= ~0x01; 457 TSR1 &= ~0x01;
458#ifdef HAVE_MAS3587F 458#if CONFIG_HWCODEC == MAS3587F
459 /* Disable interrupt */ 459 /* Disable interrupt */
460 IPRC &= ~0x000f; 460 IPRC &= ~0x000f;
461#endif /* #ifdef HAVE_MAS3587F */ 461#endif /* #if CONFIG_HWCODEC == MAS3587F */
462} 462}
463 463
464#pragma interrupt 464#pragma interrupt
@@ -467,7 +467,7 @@ void IRQ6(void) /* PB14: MAS stop demand IRQ */
467 SCR0 &= ~0x80; 467 SCR0 &= ~0x80;
468} 468}
469 469
470#ifdef HAVE_MAS3587F 470#if CONFIG_HWCODEC == MAS3587F
471#pragma interrupt 471#pragma interrupt
472void IRQ3(void) /* PA15: MAS demand IRQ */ 472void IRQ3(void) /* PA15: MAS demand IRQ */
473{ 473{
@@ -479,7 +479,7 @@ void IRQ3(void) /* PA15: MAS demand IRQ */
479 else 479 else
480 postpone_dma_tick(); 480 postpone_dma_tick();
481} 481}
482#endif /* #ifdef HAVE_MAS3587F */ 482#endif /* #if CONFIG_HWCODEC == MAS3587F */
483 483
484static void setup_sci0(void) 484static void setup_sci0(void)
485{ 485{
@@ -519,7 +519,7 @@ static void setup_sci0(void)
519} 519}
520#endif /* SIMULATOR */ 520#endif /* SIMULATOR */
521 521
522#ifdef HAVE_MAS3587F 522#if CONFIG_HWCODEC == MAS3587F
523static void init_playback(void) 523static void init_playback(void)
524{ 524{
525 unsigned long val; 525 unsigned long val;
@@ -577,10 +577,10 @@ static void init_playback(void)
577 577
578 DEBUGF("MAS Decoding application started\n"); 578 DEBUGF("MAS Decoding application started\n");
579} 579}
580#endif /* #ifdef HAVE_MAS3587F */ 580#endif /* #if CONFIG_HWCODEC == MAS3587F */
581 581
582#ifndef SIMULATOR 582#ifndef SIMULATOR
583#ifdef HAVE_MAS3507D 583#if CONFIG_HWCODEC == MAS3507D
584int current_left_volume = 0; /* all values in tenth of dB */ 584int current_left_volume = 0; /* all values in tenth of dB */
585int current_right_volume = 0; /* all values in tenth of dB */ 585int current_right_volume = 0; /* all values in tenth of dB */
586int current_treble = 0; 586int current_treble = 0;
@@ -613,10 +613,10 @@ void set_prescaled_volume(void)
613 613
614 dac_volume(tenthdb2reg(l), tenthdb2reg(r), false); 614 dac_volume(tenthdb2reg(l), tenthdb2reg(r), false);
615} 615}
616#endif /* HAVE_MAS3507D */ 616#endif /* MAS3507D */
617#endif /* !SIMULATOR */ 617#endif /* !SIMULATOR */
618 618
619#ifdef HAVE_MAS3587F 619#if CONFIG_HWCODEC == MAS3587F
620unsigned long mdb_shape_shadow = 0; 620unsigned long mdb_shape_shadow = 0;
621unsigned long loudness_shadow = 0; 621unsigned long loudness_shadow = 0;
622#endif 622#endif
@@ -626,7 +626,7 @@ void mpeg_sound_set(int setting, int value)
626#ifdef SIMULATOR 626#ifdef SIMULATOR
627 setting = value; 627 setting = value;
628#else 628#else
629#ifdef HAVE_MAS3507D 629#if CONFIG_HWCODEC == MAS3507D
630 int l, r; 630 int l, r;
631#else 631#else
632 int tmp; 632 int tmp;
@@ -638,7 +638,7 @@ void mpeg_sound_set(int setting, int value)
638 switch(setting) 638 switch(setting)
639 { 639 {
640 case SOUND_VOLUME: 640 case SOUND_VOLUME:
641#ifdef HAVE_MAS3587F 641#if CONFIG_HWCODEC == MAS3587F
642 tmp = 0x7f00 * value / 100; 642 tmp = 0x7f00 * value / 100;
643 mas_codec_writereg(0x10, tmp & 0xff00); 643 mas_codec_writereg(0x10, tmp & 0xff00);
644#else 644#else
@@ -671,7 +671,7 @@ void mpeg_sound_set(int setting, int value)
671 break; 671 break;
672 672
673 case SOUND_BALANCE: 673 case SOUND_BALANCE:
674#ifdef HAVE_MAS3587F 674#if CONFIG_HWCODEC == MAS3587F
675 tmp = ((value * 127 / 100) & 0xff) << 8; 675 tmp = ((value * 127 / 100) & 0xff) << 8;
676 mas_codec_writereg(0x11, tmp & 0xff00); 676 mas_codec_writereg(0x11, tmp & 0xff00);
677#else 677#else
@@ -680,7 +680,7 @@ void mpeg_sound_set(int setting, int value)
680 break; 680 break;
681 681
682 case SOUND_BASS: 682 case SOUND_BASS:
683#ifdef HAVE_MAS3587F 683#if CONFIG_HWCODEC == MAS3587F
684 tmp = ((value * 8) & 0xff) << 8; 684 tmp = ((value * 8) & 0xff) << 8;
685 mas_codec_writereg(0x14, tmp & 0xff00); 685 mas_codec_writereg(0x14, tmp & 0xff00);
686#else 686#else
@@ -691,7 +691,7 @@ void mpeg_sound_set(int setting, int value)
691 break; 691 break;
692 692
693 case SOUND_TREBLE: 693 case SOUND_TREBLE:
694#ifdef HAVE_MAS3587F 694#if CONFIG_HWCODEC == MAS3587F
695 tmp = ((value * 8) & 0xff) << 8; 695 tmp = ((value * 8) & 0xff) << 8;
696 mas_codec_writereg(0x15, tmp & 0xff00); 696 mas_codec_writereg(0x15, tmp & 0xff00);
697#else 697#else
@@ -701,7 +701,7 @@ void mpeg_sound_set(int setting, int value)
701#endif 701#endif
702 break; 702 break;
703 703
704#ifdef HAVE_MAS3587F 704#if CONFIG_HWCODEC == MAS3587F
705 case SOUND_LOUDNESS: 705 case SOUND_LOUDNESS:
706 loudness_shadow = (loudness_shadow & 0x04) | 706 loudness_shadow = (loudness_shadow & 0x04) |
707 (MAX(MIN(value * 4, 0x44), 0) << 8); 707 (MAX(MIN(value * 4, 0x44), 0) << 8);
@@ -771,7 +771,7 @@ void mpeg_sound_set(int setting, int value)
771 771
772int mpeg_val2phys(int setting, int value) 772int mpeg_val2phys(int setting, int value)
773{ 773{
774#ifdef HAVE_MAS3587F 774#if CONFIG_HWCODEC == MAS3587F
775 int result = 0; 775 int result = 0;
776 776
777 switch(setting) 777 switch(setting)
@@ -858,7 +858,7 @@ void mpeg_sound_channel_config(int configuration)
858 break; 858 break;
859 } 859 }
860 860
861#ifdef HAVE_MAS3587F 861#if CONFIG_HWCODEC == MAS3587F
862 mas_writemem(MAS_BANK_D0, 0x7fc, &val_ll, 1); /* LL */ 862 mas_writemem(MAS_BANK_D0, 0x7fc, &val_ll, 1); /* LL */
863 mas_writemem(MAS_BANK_D0, 0x7fd, &val_lr, 1); /* LR */ 863 mas_writemem(MAS_BANK_D0, 0x7fd, &val_lr, 1); /* LR */
864 mas_writemem(MAS_BANK_D0, 0x7fe, &val_rl, 1); /* RL */ 864 mas_writemem(MAS_BANK_D0, 0x7fe, &val_rl, 1); /* RL */
@@ -872,7 +872,7 @@ void mpeg_sound_channel_config(int configuration)
872#endif 872#endif
873} 873}
874 874
875#ifdef HAVE_MAS3587F 875#if CONFIG_HWCODEC == MAS3587F
876/* This function works by telling the decoder that we have another 876/* This function works by telling the decoder that we have another
877 crystal frequency than we actually have. It will adjust its internal 877 crystal frequency than we actually have. It will adjust its internal
878 parameters and the result is that the audio is played at another pitch. 878 parameters and the result is that the audio is played at another pitch.
@@ -918,7 +918,7 @@ void mp3_init(int volume, int bass, int treble, int balance, int loudness,
918 (void)mdb_enable; 918 (void)mdb_enable;
919 (void)superbass; 919 (void)superbass;
920#else 920#else
921#ifdef HAVE_MAS3507D 921#if CONFIG_HWCODEC == MAS3507D
922 unsigned long val; 922 unsigned long val;
923 (void)loudness; 923 (void)loudness;
924 (void)avc; 924 (void)avc;
@@ -932,7 +932,7 @@ void mp3_init(int volume, int bass, int treble, int balance, int loudness,
932 932
933 setup_sci0(); 933 setup_sci0();
934 934
935#ifdef HAVE_MAS3587F 935#if CONFIG_HWCODEC == MAS3587F
936 or_b(0x08, &PAIORH); /* output for /PR */ 936 or_b(0x08, &PAIORH); /* output for /PR */
937 init_playback(); 937 init_playback();
938 938
@@ -946,7 +946,7 @@ void mp3_init(int volume, int bass, int treble, int balance, int loudness,
946 dac_init(); 946 dac_init();
947#endif 947#endif
948 948
949#ifdef HAVE_MAS3507D 949#if CONFIG_HWCODEC == MAS3507D
950 and_b(~0x20, &PBDRL); 950 and_b(~0x20, &PBDRL);
951 sleep(HZ/5); 951 sleep(HZ/5);
952 or_b(0x20, &PBDRL); 952 or_b(0x20, &PBDRL);
@@ -992,7 +992,7 @@ void mp3_init(int volume, int bass, int treble, int balance, int loudness,
992 992
993#endif 993#endif
994 994
995#ifdef HAVE_MAS3507D 995#if CONFIG_HWCODEC == MAS3507D
996 mas_poll_start(1); 996 mas_poll_start(1);
997 997
998 mas_writereg(MAS_REG_KPRESCALE, 0xe9400); 998 mas_writereg(MAS_REG_KPRESCALE, 0xe9400);
@@ -1001,7 +1001,7 @@ void mp3_init(int volume, int bass, int treble, int balance, int loudness,
1001 mpeg_sound_channel_config(channel_config); 1001 mpeg_sound_channel_config(channel_config);
1002#endif 1002#endif
1003 1003
1004#ifdef HAVE_MAS3587F 1004#if CONFIG_HWCODEC == MAS3587F
1005 ICR &= ~0x0010; /* IRQ3 level sensitive */ 1005 ICR &= ~0x0010; /* IRQ3 level sensitive */
1006 PACR1 = (PACR1 & 0x3fff) | 0x4000; /* PA15 is IRQ3 */ 1006 PACR1 = (PACR1 & 0x3fff) | 0x4000; /* PA15 is IRQ3 */
1007#endif 1007#endif
@@ -1014,7 +1014,7 @@ void mp3_init(int volume, int bass, int treble, int balance, int loudness,
1014 mpeg_sound_set(SOUND_BALANCE, balance); 1014 mpeg_sound_set(SOUND_BALANCE, balance);
1015 mpeg_sound_set(SOUND_VOLUME, volume); 1015 mpeg_sound_set(SOUND_VOLUME, volume);
1016 1016
1017#ifdef HAVE_MAS3587F 1017#if CONFIG_HWCODEC == MAS3587F
1018 mpeg_sound_channel_config(channel_config); 1018 mpeg_sound_channel_config(channel_config);
1019 mpeg_sound_set(SOUND_LOUDNESS, loudness); 1019 mpeg_sound_set(SOUND_LOUDNESS, loudness);
1020 mpeg_sound_set(SOUND_AVC, avc); 1020 mpeg_sound_set(SOUND_AVC, avc);
@@ -1034,12 +1034,12 @@ void mp3_init(int volume, int bass, int treble, int balance, int loudness,
1034void mp3_shutdown(void) 1034void mp3_shutdown(void)
1035{ 1035{
1036#ifndef SIMULATOR 1036#ifndef SIMULATOR
1037#ifdef HAVE_MAS3587F 1037#if CONFIG_HWCODEC == MAS3587F
1038 unsigned long val = 1; 1038 unsigned long val = 1;
1039 mas_writemem(MAS_BANK_D0, 0x7f9, &val, 1); /* Mute */ 1039 mas_writemem(MAS_BANK_D0, 0x7f9, &val, 1); /* Mute */
1040#endif 1040#endif
1041 1041
1042#ifdef HAVE_MAS3507D 1042#if CONFIG_HWCODEC == MAS3507D
1043 dac_volume(0, 0, false); 1043 dac_volume(0, 0, false);
1044#endif 1044#endif
1045 1045
@@ -1052,7 +1052,7 @@ void mp3_shutdown(void)
1052 1052
1053void mp3_play_init(void) 1053void mp3_play_init(void)
1054{ 1054{
1055#ifdef HAVE_MAS3587F 1055#if CONFIG_HWCODEC == MAS3587F
1056 init_playback(); 1056 init_playback();
1057#endif 1057#endif
1058 playing = false; 1058 playing = false;
@@ -1081,7 +1081,7 @@ void mp3_play_data(const unsigned char* start, int size,
1081 1081
1082 CHCR3 |= 0x0001; /* Enable DMA IRQ */ 1082 CHCR3 |= 0x0001; /* Enable DMA IRQ */
1083 1083
1084#ifdef HAVE_MAS3587F 1084#if CONFIG_HWCODEC == MAS3587F
1085 demand_irq_enable(true); 1085 demand_irq_enable(true);
1086#endif 1086#endif
1087} 1087}
@@ -1107,7 +1107,7 @@ void mp3_play_stop(void)
1107 playing = false; 1107 playing = false;
1108 mp3_play_pause(false); 1108 mp3_play_pause(false);
1109 CHCR3 &= ~0x0001; /* Disable the DMA interrupt */ 1109 CHCR3 &= ~0x0001; /* Disable the DMA interrupt */
1110#ifdef HAVE_MAS3587F 1110#if CONFIG_HWCODEC == MAS3587F
1111 demand_irq_enable(false); 1111 demand_irq_enable(false);
1112#endif 1112#endif
1113} 1113}
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index e6d59176f7..df9e77a305 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -44,7 +44,7 @@
44 44
45#include "bitswap.h" 45#include "bitswap.h"
46 46
47#ifdef HAVE_MAS3587F 47#if CONFIG_HWCODEC == MAS3587F
48static void init_recording(void); 48static void init_recording(void);
49static void start_prerecording(void); 49static void start_prerecording(void);
50static void start_recording(void); 50static void start_recording(void);
@@ -52,7 +52,7 @@ static void stop_recording(void);
52static int get_unsaved_space(void); 52static int get_unsaved_space(void);
53static void pause_recording(void); 53static void pause_recording(void);
54static void resume_recording(void); 54static void resume_recording(void);
55#endif /* #ifdef HAVE_MAS3587F */ 55#endif /* #if CONFIG_HWCODEC == MAS3587F */
56 56
57#ifndef SIMULATOR 57#ifndef SIMULATOR
58static int get_unplayed_space(void); 58static int get_unplayed_space(void);
@@ -79,13 +79,13 @@ static int get_unswapped_space(void);
79#define MPEG_SAVE_DATA 102 79#define MPEG_SAVE_DATA 102
80#define MPEG_STOP_DONE 103 80#define MPEG_STOP_DONE 103
81 81
82#ifdef HAVE_MAS3587F 82#if CONFIG_HWCODEC == MAS3587F
83extern enum /* from mp3_playback.c */ 83extern enum /* from mp3_playback.c */
84{ 84{
85 MPEG_DECODER, 85 MPEG_DECODER,
86 MPEG_ENCODER 86 MPEG_ENCODER
87} mpeg_mode; 87} mpeg_mode;
88#endif /* #ifdef HAVE_MAS3587F */ 88#endif /* #if CONFIG_HWCODEC == MAS3587F */
89 89
90extern char* playlist_peek(int steps); 90extern char* playlist_peek(int steps);
91extern bool playlist_check(int steps); 91extern bool playlist_check(int steps);
@@ -326,7 +326,7 @@ unsigned long mpeg_get_last_header(void)
326 326
327 /* Read the frame data from the MAS and reconstruct it with the 327 /* Read the frame data from the MAS and reconstruct it with the
328 frame sync and all */ 328 frame sync and all */
329#ifdef HAVE_MAS3587F 329#if CONFIG_HWCODEC == MAS3587F
330 mas_readmem(MAS_BANK_D0, 0xfd1, tmp, 2); 330 mas_readmem(MAS_BANK_D0, 0xfd1, tmp, 2);
331#else 331#else
332 mas_readmem(MAS_BANK_D0, 0x301, tmp, 2); 332 mas_readmem(MAS_BANK_D0, 0x301, tmp, 2);
@@ -368,7 +368,7 @@ static int low_watermark; /* Dynamic low watermark level */
368static int low_watermark_margin; /* Extra time in seconds for watermark */ 368static int low_watermark_margin; /* Extra time in seconds for watermark */
369static int lowest_watermark_level; /* Debug value to observe the buffer 369static int lowest_watermark_level; /* Debug value to observe the buffer
370 usage */ 370 usage */
371#ifdef HAVE_MAS3587F 371#if CONFIG_HWCODEC == MAS3587F
372static bool is_recording; /* We are recording */ 372static bool is_recording; /* We are recording */
373static bool stop_pending; 373static bool stop_pending;
374unsigned long record_start_time; /* Value of current_tick when recording 374unsigned long record_start_time; /* Value of current_tick when recording
@@ -399,15 +399,15 @@ unsigned long shadow_7f1 = 0;
399unsigned long shadow_7f6 = 0; 399unsigned long shadow_7f6 = 0;
400unsigned long shadow_7f9 = 0; 400unsigned long shadow_7f9 = 0;
401 401
402#endif /* #ifdef HAVE_MAS3587F */ 402#endif /* #if CONFIG_HWCODEC == MAS3587F */
403 403
404static int mpeg_file; 404static int mpeg_file;
405 405
406/* Synchronization variables */ 406/* Synchronization variables */
407#ifdef HAVE_MAS3587F 407#if CONFIG_HWCODEC == MAS3587F
408static bool init_recording_done; 408static bool init_recording_done;
409static bool init_playback_done; 409static bool init_playback_done;
410#endif /* #ifdef HAVE_MAS3587F */ 410#endif /* #if CONFIG_HWCODEC == MAS3587F */
411static bool mpeg_stop_done; 411static bool mpeg_stop_done;
412 412
413static void recalculate_watermark(int bitrate) 413static void recalculate_watermark(int bitrate)
@@ -533,7 +533,7 @@ static int get_unswapped_space(void)
533 return space; 533 return space;
534} 534}
535 535
536#ifdef HAVE_MAS3587F 536#if CONFIG_HWCODEC == MAS3587F
537static int get_unsaved_space(void) 537static int get_unsaved_space(void)
538{ 538{
539 int space = mp3buf_write - mp3buf_read; 539 int space = mp3buf_write - mp3buf_read;
@@ -541,9 +541,9 @@ static int get_unsaved_space(void)
541 space += mp3buflen; 541 space += mp3buflen;
542 return space; 542 return space;
543} 543}
544#endif /* #ifdef HAVE_MAS3587F */ 544#endif /* #if CONFIG_HWCODEC == MAS3587F */
545 545
546#ifdef HAVE_MAS3587F 546#if CONFIG_HWCODEC == MAS3587F
547#ifdef DEBUG 547#ifdef DEBUG
548static long timing_info_index = 0; 548static long timing_info_index = 0;
549static long timing_info[1024]; 549static long timing_info[1024];
@@ -584,12 +584,12 @@ static void drain_dma_buffer(void)
584 ); 584 );
585} 585}
586 586
587#endif /* #ifdef HAVE_MAS3587F */ 587#endif /* #if CONFIG_HWCODEC == MAS3587F */
588 588
589void rec_tick (void) __attribute__ ((section (".icode"))); 589void rec_tick (void) __attribute__ ((section (".icode")));
590void rec_tick(void) 590void rec_tick(void)
591{ 591{
592#ifdef HAVE_MAS3587F 592#if CONFIG_HWCODEC == MAS3587F
593 int i; 593 int i;
594 int num_bytes; 594 int num_bytes;
595 if(is_recording && (PBDR & 0x4000)) 595 if(is_recording && (PBDR & 0x4000))
@@ -694,7 +694,7 @@ void rec_tick(void)
694 } 694 }
695 } 695 }
696 } 696 }
697#endif /* #ifdef HAVE_MAS3587F */ 697#endif /* #if CONFIG_HWCODEC == MAS3587F */
698} 698}
699 699
700void playback_tick(void) 700void playback_tick(void)
@@ -927,10 +927,10 @@ static void track_change(void)
927{ 927{
928 DEBUGF("Track change\n"); 928 DEBUGF("Track change\n");
929 929
930#ifdef HAVE_MAS3587F 930#if CONFIG_HWCODEC == MAS3587F
931 /* Reset the AVC */ 931 /* Reset the AVC */
932 mpeg_sound_set(SOUND_AVC, -1); 932 mpeg_sound_set(SOUND_AVC, -1);
933#endif /* #ifdef HAVE_MAS3587F */ 933#endif /* #if CONFIG_HWCODEC == MAS3587F */
934 remove_current_tag(); 934 remove_current_tag();
935 935
936 update_playlist(); 936 update_playlist();
@@ -1049,7 +1049,7 @@ static void mpeg_thread(void)
1049 int amount_to_read; 1049 int amount_to_read;
1050 int t1, t2; 1050 int t1, t2;
1051 int start_offset; 1051 int start_offset;
1052#ifdef HAVE_MAS3587F 1052#if CONFIG_HWCODEC == MAS3587F
1053 int amount_to_save; 1053 int amount_to_save;
1054 int writelen; 1054 int writelen;
1055 int framelen; 1055 int framelen;
@@ -1058,7 +1058,7 @@ static void mpeg_thread(void)
1058 int rc; 1058 int rc;
1059 int offset; 1059 int offset;
1060 int countdown; 1060 int countdown;
1061#endif /* #ifdef HAVE_MAS3587F */ 1061#endif /* #if CONFIG_HWCODEC == MAS3587F */
1062 1062
1063 is_playing = false; 1063 is_playing = false;
1064 play_pending = false; 1064 play_pending = false;
@@ -1067,10 +1067,10 @@ static void mpeg_thread(void)
1067 1067
1068 while(1) 1068 while(1)
1069 { 1069 {
1070#ifdef HAVE_MAS3587F 1070#if CONFIG_HWCODEC == MAS3587F
1071 if(mpeg_mode == MPEG_DECODER) 1071 if(mpeg_mode == MPEG_DECODER)
1072 { 1072 {
1073#endif /* #ifdef HAVE_MAS3587F */ 1073#endif /* #if CONFIG_HWCODEC == MAS3587F */
1074 yield(); 1074 yield();
1075 1075
1076 /* Swap if necessary, and don't block on the queue_wait() */ 1076 /* Swap if necessary, and don't block on the queue_wait() */
@@ -1092,11 +1092,11 @@ static void mpeg_thread(void)
1092 case MPEG_PLAY: 1092 case MPEG_PLAY:
1093 DEBUGF("MPEG_PLAY\n"); 1093 DEBUGF("MPEG_PLAY\n");
1094 1094
1095#ifdef HAVE_FMRADIO 1095#ifdef CONFIG_TUNER
1096 /* Silence the A/D input, it may be on because the radio 1096 /* Silence the A/D input, it may be on because the radio
1097 may be playing */ 1097 may be playing */
1098 mas_codec_writereg(6, 0x0000); 1098 mas_codec_writereg(6, 0x0000);
1099#endif /* #ifdef HAVE_FMRADIO */ 1099#endif /* #ifdef CONFIG_TUNER */
1100 1100
1101 /* Stop the current stream */ 1101 /* Stop the current stream */
1102 play_pending = false; 1102 play_pending = false;
@@ -1589,14 +1589,14 @@ static void mpeg_thread(void)
1589 break; 1589 break;
1590#endif /* #ifndef USB_NONE */ 1590#endif /* #ifndef USB_NONE */
1591 1591
1592#ifdef HAVE_MAS3587F 1592#if CONFIG_HWCODEC == MAS3587F
1593 case MPEG_INIT_RECORDING: 1593 case MPEG_INIT_RECORDING:
1594 init_recording(); 1594 init_recording();
1595 init_recording_done = true; 1595 init_recording_done = true;
1596 break; 1596 break;
1597#endif /* #ifdef HAVE_MAS3587F */ 1597#endif /* #if CONFIG_HWCODEC == MAS3587F */
1598 } 1598 }
1599#ifdef HAVE_MAS3587F 1599#if CONFIG_HWCODEC == MAS3587F
1600 } 1600 }
1601 else 1601 else
1602 { 1602 {
@@ -1996,7 +1996,7 @@ static void mpeg_thread(void)
1996 break; 1996 break;
1997 } 1997 }
1998 } 1998 }
1999#endif /* #ifdef HAVE_MAS3587F */ 1999#endif /* #if CONFIG_HWCODEC == MAS3587F */
2000 } 2000 }
2001} 2001}
2002#endif /* SIMULATOR */ 2002#endif /* SIMULATOR */
@@ -2044,7 +2044,7 @@ bool mpeg_has_changed_track(void)
2044 return false; 2044 return false;
2045} 2045}
2046 2046
2047#ifdef HAVE_MAS3587F 2047#if CONFIG_HWCODEC == MAS3587F
2048void mpeg_init_playback(void) 2048void mpeg_init_playback(void)
2049{ 2049{
2050 init_playback_done = false; 2050 init_playback_done = false;
@@ -2617,13 +2617,13 @@ int mpeg_status(void)
2617 if(paused) 2617 if(paused)
2618 ret |= MPEG_STATUS_PAUSE; 2618 ret |= MPEG_STATUS_PAUSE;
2619 2619
2620#ifdef HAVE_MAS3587F 2620#if CONFIG_HWCODEC == MAS3587F
2621 if(is_recording && !is_prerecording) 2621 if(is_recording && !is_prerecording)
2622 ret |= MPEG_STATUS_RECORD; 2622 ret |= MPEG_STATUS_RECORD;
2623 2623
2624 if(is_prerecording) 2624 if(is_prerecording)
2625 ret |= MPEG_STATUS_PRERECORD; 2625 ret |= MPEG_STATUS_PRERECORD;
2626#endif /* #ifdef HAVE_MAS3587F */ 2626#endif /* #if CONFIG_HWCODEC == MAS3587F */
2627 2627
2628 if(mpeg_errno) 2628 if(mpeg_errno)
2629 ret |= MPEG_STATUS_ERROR; 2629 ret |= MPEG_STATUS_ERROR;
@@ -2677,12 +2677,12 @@ void mpeg_init(void)
2677 memset(id3tags, sizeof(id3tags), 0); 2677 memset(id3tags, sizeof(id3tags), 0);
2678 memset(_id3tags, sizeof(id3tags), 0); 2678 memset(_id3tags, sizeof(id3tags), 0);
2679 2679
2680#ifdef HAVE_MAS3587F 2680#if CONFIG_HWCODEC == MAS3587F
2681 if(read_hw_mask() & PR_ACTIVE_HIGH) 2681 if(read_hw_mask() & PR_ACTIVE_HIGH)
2682 and_b(~0x08, &PADRH); 2682 and_b(~0x08, &PADRH);
2683 else 2683 else
2684 or_b(0x08, &PADRH); 2684 or_b(0x08, &PADRH);
2685#endif /* #ifdef HAVE_MAS3587F */ 2685#endif /* #if CONFIG_HWCODEC == MAS3587F */
2686 2686
2687#ifdef DEBUG 2687#ifdef DEBUG
2688 dbg_timer_start(); 2688 dbg_timer_start();
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c
index 6a72a2c613..155d11e609 100644
--- a/firmware/powermgmt.c
+++ b/firmware/powermgmt.c
@@ -34,7 +34,7 @@
34#include "usb.h" 34#include "usb.h"
35#include "powermgmt.h" 35#include "powermgmt.h"
36#include "backlight.h" 36#include "backlight.h"
37#ifdef HAVE_FMRADIO 37#ifdef CONFIG_TUNER
38#include "fmradio.h" 38#include "fmradio.h"
39#endif 39#endif
40 40
@@ -315,7 +315,7 @@ static void handle_auto_poweroff(void)
315 charger_was_inserted = charger_is_inserted; 315 charger_was_inserted = charger_is_inserted;
316 316
317 if(timeout && 317 if(timeout &&
318#ifdef HAVE_FMRADIO 318#ifdef CONFIG_TUNER
319 !fmradio_get_status() && 319 !fmradio_get_status() &&
320#endif 320#endif
321 !usb_inserted() && 321 !usb_inserted() &&