summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/debug_menu.c12
-rw-r--r--apps/plugin.c4
-rw-r--r--apps/plugin.h4
-rw-r--r--apps/plugins/splitedit.c8
-rw-r--r--apps/recorder/recording.c5
-rw-r--r--apps/settings.c4
-rw-r--r--firmware/drivers/mas.c6
-rw-r--r--firmware/export/config-ondiosp.h4
-rw-r--r--firmware/export/mas.h77
-rw-r--r--firmware/export/mp3_playback.h4
-rw-r--r--firmware/mp3_playback.c103
-rw-r--r--firmware/mpeg.c96
12 files changed, 195 insertions, 132 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 7a1c2a3df8..57554d8c6f 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -790,7 +790,7 @@ bool dbg_mas(void)
return false;
}
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
bool dbg_mas_codec(void)
{
char buf[32];
@@ -1050,22 +1050,22 @@ bool dbg_mas_info(void)
snprintf(buf, 32, "6f: %05x ", mas_readreg(0x6f) & 0xfffff);
break;
case 8:
- mas_readmem(MAS_BANK_D0, 0x300, &val, 1);
+ mas_readmem(MAS_BANK_D0, MAS_D0_MPEG_FRAME_COUNT, &val, 1);
lcd_puts(0, 0, "Frame Count");
snprintf(buf, 32, "0/300: %04x", val & 0xffff);
break;
case 9:
- mas_readmem(MAS_BANK_D0, 0x301, &val, 1);
+ mas_readmem(MAS_BANK_D0, MAS_D0_MPEG_STATUS_1, &val, 1);
lcd_puts(0, 0, "Status1 ");
snprintf(buf, 32, "0/301: %04x", val & 0xffff);
break;
case 10:
- mas_readmem(MAS_BANK_D0, 0x302, &val, 1);
+ mas_readmem(MAS_BANK_D0, MAS_D0_MPEG_STATUS_2, &val, 1);
lcd_puts(0, 0, "Status2 ");
snprintf(buf, 32, "0/302: %04x", val & 0xffff);
break;
case 11:
- mas_readmem(MAS_BANK_D0, 0x303, &val, 1);
+ mas_readmem(MAS_BANK_D0, MAS_D0_CRC_ERROR_COUNT, &val, 1);
lcd_puts(0, 0, "CRC Count ");
snprintf(buf, 32, "0/303: %04x", val & 0xffff);
break;
@@ -1539,7 +1539,7 @@ bool debug_menu(void)
{ "View MAS info", dbg_mas_info },
#endif
{ "View MAS regs", dbg_mas },
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
{ "View MAS codec", dbg_mas_codec },
#endif
#ifdef HAVE_LCD_BITMAP
diff --git a/apps/plugin.c b/apps/plugin.c
index 51f7a610dd..24a9dd4da6 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -211,7 +211,7 @@ static const struct plugin_api rockbox_api = {
mas_writemem,
mas_readreg,
mas_writereg,
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
mas_codec_writereg,
mas_codec_readreg,
#endif
@@ -244,7 +244,7 @@ static const struct plugin_api rockbox_api = {
/* new stuff at the end, sort into place next time
the API gets incompatible */
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
mpeg_set_pitch,
peak_meter_scale_value,
diff --git a/apps/plugin.h b/apps/plugin.h
index 445427ffd5..52a060d428 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -239,7 +239,7 @@ struct plugin_api {
int (*mas_writemem)(int bank, int addr, const unsigned long* src, int len);
int (*mas_readreg)(int reg);
int (*mas_writereg)(int reg, unsigned int val);
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
int (*mas_codec_writereg)(int reg, unsigned int val);
int (*mas_codec_readreg)(int reg);
#endif
@@ -277,7 +277,7 @@ struct plugin_api {
/* new stuff at the end, sort into place next time
the API gets incompatible */
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
void (*mpeg_set_pitch)(int pitch);
unsigned short (*peak_meter_scale_value)(unsigned short val,
diff --git a/apps/plugins/splitedit.c b/apps/plugins/splitedit.c
index b76a08cb80..24b2b6939f 100644
--- a/apps/plugins/splitedit.c
+++ b/apps/plugins/splitedit.c
@@ -230,7 +230,7 @@ static void update_icons(void)
LCD_WIDTH/3 + LCD_WIDTH/3 / 2 - BMPWIDTH/2, LCD_HEIGHT - BMPHEIGHT,
BMPWIDTH, BMPHEIGHT, true);
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
/* The scale icon */
rb->lcd_bitmap(SCALE_BMP[rb->peak_meter_get_use_dbfs()],
2 *LCD_WIDTH/3 + LCD_WIDTH/3 / 2 - BMPWIDTH/2, LCD_HEIGHT - BMPHEIGHT,
@@ -849,7 +849,7 @@ unsigned long splitedit_editor(struct mp3entry * mp3_to_split,
{
/* read volume info */
unsigned short volume;
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
volume = rb->mas_codec_readreg(0x0c);
volume += rb->mas_codec_readreg(0x0d);
volume = volume / 2;
@@ -1003,7 +1003,7 @@ unsigned long splitedit_editor(struct mp3entry * mp3_to_split,
lastx = time_to_xpos(mp3->elapsed);
break;
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
case BUTTON_ON | BUTTON_RIGHT:
rb->mpeg_set_pitch(1500);
splitedit_invalidate_osci();
@@ -1060,7 +1060,7 @@ unsigned long splitedit_editor(struct mp3entry * mp3_to_split,
break;
case BUTTON_F3:
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
rb->peak_meter_set_use_dbfs(rb->peak_meter_get_use_dbfs() +1);
#endif
splitedit_invalidate_osci();
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index 98c2b27008..8bec6e81de 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -49,6 +49,8 @@
#include "errno.h"
#include "talk.h"
+#ifdef HAVE_RECORDING
+
bool f2_rec_screen(void);
bool f3_rec_screen(void);
@@ -539,7 +541,7 @@ bool recording_screen(void)
{
gain = MAX(global_settings.rec_left_gain,
global_settings.rec_right_gain);
-
+
snprintf(buf, 32, "%s: %s", str(LANG_RECORDING_GAIN),
fmt_gain(SOUND_LEFT_GAIN, gain,
buf2, sizeof(buf2)));
@@ -819,3 +821,4 @@ bool f3_rec_screen(void)
return false;
}
#endif
+#endif /* HAVE_RECORDING */
diff --git a/apps/settings.c b/apps/settings.c
index a13abecfc7..b3b9ef1db8 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -164,7 +164,7 @@ static const struct bit_entry rtc_bits[] =
{8 | SIGNED, S_O(balance), 0, "balance", NULL }, /* -100...100 */
{5 | SIGNED, S_O(bass), 0, "bass", NULL }, /* -15..+15 / -12..+12 */
{5 | SIGNED, S_O(treble), 0, "treble", NULL }, /* -15..+15 / -12..+12 */
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
{5, S_O(loudness), 0, "loudness", NULL }, /* 0...17 */
{3, S_O(avc), 0, "auto volume", "off,20ms,2,4,8" },
{1, S_O(superbass), false, "superbass", off_on },
@@ -710,7 +710,7 @@ void sound_settings_apply(void)
mpeg_sound_set(SOUND_BALANCE, global_settings.balance);
mpeg_sound_set(SOUND_VOLUME, global_settings.volume);
mpeg_sound_set(SOUND_CHANNELS, global_settings.channel_config);
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
mpeg_sound_set(SOUND_LOUDNESS, global_settings.loudness);
mpeg_sound_set(SOUND_AVC, global_settings.avc);
mpeg_sound_set(SOUND_MDB_STRENGTH, global_settings.mdb_strength);
diff --git a/firmware/drivers/mas.c b/firmware/drivers/mas.c
index 9f6e0943c7..52a91c5e40 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)
j = 0;
while(len--) {
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
buf[i++] = 0;
buf[i++] = ptr[j+1];
buf[i++] = ptr[j+2];
@@ -232,7 +232,7 @@ static int mas_devread(unsigned long *dest, int len)
if (i2c_getack()) {
for (i=0;len;i++) {
len--;
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
i2c_inb(0); /* Dummy read */
ptr[i*4+0] = 0;
ptr[i*4+1] = i2c_inb(0) & 0x0f;
@@ -266,7 +266,7 @@ static int mas_devread(unsigned long *dest, int len)
return ret;
}
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
void mas_reset(void)
{
or_b(0x01, &PAIORH);
diff --git a/firmware/export/config-ondiosp.h b/firmware/export/config-ondiosp.h
index 0a270e8ae5..e3fe6c718f 100644
--- a/firmware/export/config-ondiosp.h
+++ b/firmware/export/config-ondiosp.h
@@ -1,5 +1,5 @@
/* define this if you have recording possibility */
-#define HAVE_RECORDING 1
+/* #define HAVE_RECORDING */
/* define this if you have a bitmap LCD display */
#define HAVE_LCD_BITMAP 1
@@ -17,7 +17,7 @@
#define CONFIG_CPU SH7034
/* Define this if you have a MAS3539F */
-#define CONFIG_HWCODEC MAS3587F /* will be MAS3539F once prepared */
+#define CONFIG_HWCODEC MAS3539F
/* Define this if you have a LiIon battery */
/* #define HAVE_LIION */
diff --git a/firmware/export/mas.h b/firmware/export/mas.h
index dac946ea63..f682fc676e 100644
--- a/firmware/export/mas.h
+++ b/firmware/export/mas.h
@@ -27,7 +27,7 @@
/*
MAS I2C defs
*/
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
#define MAS_ADR 0x3c
#define MAS_DEV_WRITE (MAS_ADR | 0x00)
#define MAS_DEV_READ (MAS_ADR | 0x01)
@@ -38,18 +38,18 @@
#endif
/* registers..*/
-#if CONFIG_HWCODEC == MAS3587F
-#define MAS_DATA_WRITE 0x68
-#define MAS_DATA_READ 0x69
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
+#define MAS_DATA_WRITE 0x68
+#define MAS_DATA_READ 0x69
#define MAS_CODEC_WRITE 0x6c
#define MAS_CODEC_READ 0x6d
-#define MAS_CONTROL 0x6a
-#define MAS_DCCF 0x76
-#define MAS_DCFR 0x77
+#define MAS_CONTROL 0x6a
+#define MAS_DCCF 0x76
+#define MAS_DCFR 0x77
#else
-#define MAS_DATA_WRITE 0x68
-#define MAS_DATA_READ 0x69
-#define MAS_CONTROL 0x6a
+#define MAS_DATA_WRITE 0x68
+#define MAS_DATA_READ 0x69
+#define MAS_CONTROL 0x6a
#endif
/*
@@ -62,15 +62,15 @@
#define MAS_REG_KPRESCALE 0xe7
#define MAS_REG_KBASS 0x6b
#define MAS_REG_KTREBLE 0x6f
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
#define MAS_REG_KMDB_SWITCH 0x21
#define MAS_REG_KMDB_STR 0x22
#define MAS_REG_KMDB_HAR 0x23
#define MAS_REG_KMDB_FC 0x24
#define MAS_REG_KLOUDNESS 0x1e
#define MAS_REG_QPEAK_L 0x0a
-#define MAS_REG_QPEAK_R 0x0b
-#define MAS_REG_DQPEAK_L 0x0c
+#define MAS_REG_QPEAK_R 0x0b
+#define MAS_REG_DQPEAK_L 0x0c
#define MAS_REG_DQPEAK_R 0x0d
#define MAS_REG_KAVC 0x12
#endif
@@ -78,7 +78,7 @@
/*
* MAS commands
*/
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
#define MAS_CMD_READ_ANCILLARY 0x50
#define MAS_CMD_FAST_PRG_DL 0x60
#define MAS_CMD_READ_IC_VER 0x70
@@ -98,6 +98,55 @@
#define MAS_CMD_READ_D1_MEM 0xf0
#endif
+/*
+ * MAS D0 memory cells (MAS3587F / MAS3539F)
+ */
+#if CONFIG_HWCODEC == MAS3587F
+#define MAS_D0_APP_SELECT 0x7f6
+#define MAS_D0_APP_RUNNING 0x7f7
+#define MAS_D0_ENCODER_CONTROL 0x7f0
+#define MAS_D0_IO_CONTROL_MAIN 0x7f1
+#define MAS_D0_INTERFACE_CONTROL 0x7f2
+#define MAS_D0_OFREQ_CONTROL 0x7f3
+#define MAS_D0_OUT_CLK_CONFIG 0x7f4
+#define MAS_D0_SPD_OUT_BITS 0x7f8
+#define MAS_D0_SOFT_MUTE 0x7f9
+#define MAS_D0_OUT_LL 0x7fc
+#define MAS_D0_OUT_LR 0x7fd
+#define MAS_D0_OUT_RL 0x7fe
+#define MAS_D0_OUT_RR 0x7ff
+#define MAS_D0_MPEG_FRAME_COUNT 0xfd0
+#define MAS_D0_MPEG_STATUS_1 0xfd1
+#define MAS_D0_MPEG_STATUS_2 0xfd2
+#define MAS_D0_CRC_ERROR_COUNT 0xfd3
+
+#elif CONFIG_HWCODEC == MAS3539F
+#define MAS_D0_APP_SELECT 0x34b
+#define MAS_D0_APP_RUNNING 0x34c
+/* no encoder :( */
+#define MAS_D0_IO_CONTROL_MAIN 0x346
+#define MAS_D0_INTERFACE_CONTROL 0x347
+#define MAS_D0_OFREQ_CONTROL 0x348
+#define MAS_D0_OUT_CLK_CONFIG 0x349
+#define MAS_D0_SPD_OUT_BITS 0x351
+#define MAS_D0_SOFT_MUTE 0x350
+#define MAS_D0_OUT_LL 0x354
+#define MAS_D0_OUT_LR 0x355
+#define MAS_D0_OUT_RL 0x356
+#define MAS_D0_OUT_RR 0x357
+#define MAS_D0_MPEG_FRAME_COUNT 0xfd0
+#define MAS_D0_MPEG_STATUS_1 0xfd1
+#define MAS_D0_MPEG_STATUS_2 0xfd2
+#define MAS_D0_CRC_ERROR_COUNT 0xfd3
+
+#else /* MAS3507D */
+#define MAS_D0_MPEG_FRAME_COUNT 0x300
+#define MAS_D0_MPEG_STATUS_1 0x301
+#define MAS_D0_MPEG_STATUS_2 0x302
+#define MAS_D0_CRC_ERROR_COUNT 0x303
+
+#endif
+
int mas_default_read(unsigned short *buf);
int mas_run(unsigned short address);
int mas_readmem(int bank, int addr, unsigned long* dest, int len);
diff --git a/firmware/export/mp3_playback.h b/firmware/export/mp3_playback.h
index dd56940c37..456569342b 100644
--- a/firmware/export/mp3_playback.h
+++ b/firmware/export/mp3_playback.h
@@ -39,13 +39,13 @@ int mpeg_val2phys(int setting, int value);
const char *mpeg_sound_unit(int setting);
int mpeg_sound_numdecimals(int setting);
int mpeg_sound_steps(int setting);
-#if CONFIG_HWCODEC == MAS3587F || defined(SIMULATOR)
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) || defined(SIMULATOR)
void mpeg_set_pitch(int percent);
#endif
/* exported just for mpeg.c, to keep the recording there */
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
void demand_irq_enable(bool on);
#endif
diff --git a/firmware/mp3_playback.c b/firmware/mp3_playback.c
index fae8377c4b..4f1d16f9d3 100644
--- a/firmware/mp3_playback.c
+++ b/firmware/mp3_playback.c
@@ -41,11 +41,12 @@ enum
MPEG_DECODER,
MPEG_ENCODER
} mpeg_mode;
-
-extern unsigned long shadow_7f1;
-
#endif /* #ifdef MAS3587F */
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
+extern unsigned long shadow_io_control_main;
+#endif
+
/**** globals ****/
/* own version, independent of mpeg.c */
@@ -124,7 +125,7 @@ static const int steps[] =
static const int minval[] =
{
0, /* Volume */
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
-12, /* Bass */
-12, /* Treble */
#else
@@ -149,7 +150,7 @@ static const int minval[] =
static const int maxval[] =
{
100, /* Volume */
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
12, /* Bass */
12, /* Treble */
#else
@@ -174,7 +175,7 @@ static const int maxval[] =
static const int defaultval[] =
{
70, /* Volume */
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
6, /* Bass */
6, /* Treble */
#else
@@ -393,7 +394,7 @@ static void postpone_dma_tick(void)
#endif
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
void demand_irq_enable(bool on)
{
int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL);
@@ -408,7 +409,7 @@ void demand_irq_enable(bool on)
set_irq_level(oldlevel);
}
-#endif /* #if CONFIG_HWCODEC == MAS3587F */
+#endif /* #if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) */
void play_tick(void)
@@ -455,10 +456,10 @@ void IMIA1(void) /* Timer 1 interrupt */
if(playing)
play_tick();
TSR1 &= ~0x01;
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
/* Disable interrupt */
IPRC &= ~0x000f;
-#endif /* #if CONFIG_HWCODEC == MAS3587F */
+#endif
}
#pragma interrupt
@@ -467,19 +468,21 @@ void IRQ6(void) /* PB14: MAS stop demand IRQ */
SCR0 &= ~0x80;
}
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
#pragma interrupt
void IRQ3(void) /* PA15: MAS demand IRQ */
{
/* Begin with setting the IRQ to edge sensitive */
ICR |= 0x0010;
-
+
+#if CONFIG_HWCODEC == MAS3587F
if(mpeg_mode == MPEG_ENCODER)
rec_tick();
else
+#endif
postpone_dma_tick();
}
-#endif /* #if CONFIG_HWCODEC == MAS3587F */
+#endif /* #if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) */
static void setup_sci0(void)
{
@@ -519,7 +522,7 @@ static void setup_sci0(void)
}
#endif /* SIMULATOR */
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
static void init_playback(void)
{
unsigned long val;
@@ -536,10 +539,10 @@ static void init_playback(void)
/* Stop the current application */
val = 0;
- mas_writemem(MAS_BANK_D0,0x7f6,&val,1);
+ mas_writemem(MAS_BANK_D0, MAS_D0_APP_SELECT, &val, 1);
do
{
- mas_readmem(MAS_BANK_D0, 0x7f7, &val, 1);
+ mas_readmem(MAS_BANK_D0, MAS_D0_APP_RUNNING, &val, 1);
} while(val);
/* Enable the D/A Converter */
@@ -551,23 +554,25 @@ static void init_playback(void)
/* Disable SDO and SDI */
val = 0x0d;
- mas_writemem(MAS_BANK_D0,0x7f2,&val,1);
+ mas_writemem(MAS_BANK_D0, MAS_D0_INTERFACE_CONTROL, &val, 1);
/* Set Demand mode and validate all settings */
- shadow_7f1 = 0x25;
- mas_writemem(MAS_BANK_D0,0x7f1,&shadow_7f1,1);
+ shadow_io_control_main = 0x25;
+ mas_writemem(MAS_BANK_D0, MAS_D0_IO_CONTROL_MAIN, &shadow_io_control_main, 1);
/* Start the Layer2/3 decoder applications */
val = 0x0c;
- mas_writemem(MAS_BANK_D0,0x7f6,&val,1);
+ mas_writemem(MAS_BANK_D0, MAS_D0_APP_SELECT, &val, 1);
do
{
- mas_readmem(MAS_BANK_D0, 0x7f7, &val, 1);
+ mas_readmem(MAS_BANK_D0, MAS_D0_APP_RUNNING, &val, 1);
} while((val & 0x0c) != 0x0c);
mpeg_sound_channel_config(MPEG_SOUND_STEREO);
+#if CONFIG_HWCODEC == MAS3587F
mpeg_mode = MPEG_DECODER;
+#endif
/* set IRQ6 to edge detect */
ICR |= 0x02;
@@ -577,7 +582,7 @@ static void init_playback(void)
DEBUGF("MAS Decoding application started\n");
}
-#endif /* #if CONFIG_HWCODEC == MAS3587F */
+#endif /* #if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) */
#ifndef SIMULATOR
#if CONFIG_HWCODEC == MAS3507D
@@ -616,7 +621,7 @@ void set_prescaled_volume(void)
#endif /* MAS3507D */
#endif /* !SIMULATOR */
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
unsigned long mdb_shape_shadow = 0;
unsigned long loudness_shadow = 0;
#endif
@@ -638,7 +643,7 @@ void mpeg_sound_set(int setting, int value)
switch(setting)
{
case SOUND_VOLUME:
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
tmp = 0x7f00 * value / 100;
mas_codec_writereg(0x10, tmp & 0xff00);
#else
@@ -671,7 +676,7 @@ void mpeg_sound_set(int setting, int value)
break;
case SOUND_BALANCE:
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
tmp = ((value * 127 / 100) & 0xff) << 8;
mas_codec_writereg(0x11, tmp & 0xff00);
#else
@@ -680,7 +685,7 @@ void mpeg_sound_set(int setting, int value)
break;
case SOUND_BASS:
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
tmp = ((value * 8) & 0xff) << 8;
mas_codec_writereg(0x14, tmp & 0xff00);
#else
@@ -691,7 +696,7 @@ void mpeg_sound_set(int setting, int value)
break;
case SOUND_TREBLE:
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
tmp = ((value * 8) & 0xff) << 8;
mas_codec_writereg(0x15, tmp & 0xff00);
#else
@@ -701,7 +706,7 @@ void mpeg_sound_set(int setting, int value)
#endif
break;
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
case SOUND_LOUDNESS:
loudness_shadow = (loudness_shadow & 0x04) |
(MAX(MIN(value * 4, 0x44), 0) << 8);
@@ -771,7 +776,7 @@ void mpeg_sound_set(int setting, int value)
int mpeg_val2phys(int setting, int value)
{
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
int result = 0;
switch(setting)
@@ -858,11 +863,11 @@ void mpeg_sound_channel_config(int configuration)
break;
}
-#if CONFIG_HWCODEC == MAS3587F
- mas_writemem(MAS_BANK_D0, 0x7fc, &val_ll, 1); /* LL */
- mas_writemem(MAS_BANK_D0, 0x7fd, &val_lr, 1); /* LR */
- mas_writemem(MAS_BANK_D0, 0x7fe, &val_rl, 1); /* RL */
- mas_writemem(MAS_BANK_D0, 0x7ff, &val_rr, 1); /* RR */
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
+ mas_writemem(MAS_BANK_D0, MAS_D0_OUT_LL, &val_ll, 1); /* LL */
+ mas_writemem(MAS_BANK_D0, MAS_D0_OUT_LR, &val_lr, 1); /* LR */
+ mas_writemem(MAS_BANK_D0, MAS_D0_OUT_RL, &val_rl, 1); /* RL */
+ mas_writemem(MAS_BANK_D0, MAS_D0_OUT_RR, &val_rr, 1); /* RR */
#else
mas_writemem(MAS_BANK_D1, 0x7f8, &val_ll, 1); /* LL */
mas_writemem(MAS_BANK_D1, 0x7f9, &val_lr, 1); /* LR */
@@ -872,7 +877,7 @@ void mpeg_sound_channel_config(int configuration)
#endif
}
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
/* This function works by telling the decoder that we have another
crystal frequency than we actually have. It will adjust its internal
parameters and the result is that the audio is played at another pitch.
@@ -889,11 +894,11 @@ void mpeg_set_pitch(int pitch)
/* Calculate the new (bogus) frequency */
val = 18432*pitch/1000;
- mas_writemem(MAS_BANK_D0,0x7f3,&val,1);
+ mas_writemem(MAS_BANK_D0, MAS_D0_OFREQ_CONTROL, &val, 1);
/* We must tell the MAS that the frequency has changed.
This will unfortunately cause a short silence. */
- mas_writemem(MAS_BANK_D0,0x7f1,&shadow_7f1,1);
+ mas_writemem(MAS_BANK_D0, MAS_D0_IO_CONTROL_MAIN, &shadow_io_control_main, 1);
}
#endif
@@ -940,6 +945,14 @@ void mp3_init(int volume, int bass, int treble, int balance, int loudness,
DEBUGF("MAS3587 derivate %d, version %c%d\n",
(mas_version_code & 0xf000) >> 12,
'A' + ((mas_version_code & 0x0f00) >> 8), mas_version_code & 0xff);
+#elif CONFIG_HW_CODEC == MAS3539F
+ or_b(0x08, &PAIORH); /* output for /PR */
+ init_playback();
+
+ mas_version_code = mas_readver();
+ DEBUGF("MAS3539 derivate %d, version %c%d\n",
+ (mas_version_code & 0xf000) >> 12,
+ 'A' + ((mas_version_code & 0x0f00) >> 8), mas_version_code & 0xff);
#endif
#ifdef HAVE_DAC3550A
@@ -1001,20 +1014,20 @@ void mp3_init(int volume, int bass, int treble, int balance, int loudness,
mpeg_sound_channel_config(channel_config);
#endif
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
ICR &= ~0x0010; /* IRQ3 level sensitive */
PACR1 = (PACR1 & 0x3fff) | 0x4000; /* PA15 is IRQ3 */
#endif
/* Must be done before calling mpeg_sound_set() */
mpeg_is_initialized = true;
-
+
mpeg_sound_set(SOUND_BASS, bass);
mpeg_sound_set(SOUND_TREBLE, treble);
mpeg_sound_set(SOUND_BALANCE, balance);
mpeg_sound_set(SOUND_VOLUME, volume);
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
mpeg_sound_channel_config(channel_config);
mpeg_sound_set(SOUND_LOUDNESS, loudness);
mpeg_sound_set(SOUND_AVC, avc);
@@ -1034,9 +1047,9 @@ void mp3_init(int volume, int bass, int treble, int balance, int loudness,
void mp3_shutdown(void)
{
#ifndef SIMULATOR
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
unsigned long val = 1;
- mas_writemem(MAS_BANK_D0, 0x7f9, &val, 1); /* Mute */
+ mas_writemem(MAS_BANK_D0, MAS_D0_SOFT_MUTE, &val, 1); /* Mute */
#endif
#if CONFIG_HWCODEC == MAS3507D
@@ -1052,7 +1065,7 @@ void mp3_shutdown(void)
void mp3_play_init(void)
{
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
init_playback();
#endif
playing = false;
@@ -1081,7 +1094,7 @@ void mp3_play_data(const unsigned char* start, int size,
CHCR3 |= 0x0001; /* Enable DMA IRQ */
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
demand_irq_enable(true);
#endif
}
@@ -1107,7 +1120,7 @@ void mp3_play_stop(void)
playing = false;
mp3_play_pause(false);
CHCR3 &= ~0x0001; /* Disable the DMA interrupt */
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
demand_irq_enable(false);
#endif
}
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index df9e77a305..0eea71228c 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -326,11 +326,7 @@ unsigned long mpeg_get_last_header(void)
/* Read the frame data from the MAS and reconstruct it with the
frame sync and all */
-#if CONFIG_HWCODEC == MAS3587F
- mas_readmem(MAS_BANK_D0, 0xfd1, tmp, 2);
-#else
- mas_readmem(MAS_BANK_D0, 0x301, tmp, 2);
-#endif
+ mas_readmem(MAS_BANK_D0, MAS_D0_MPEG_STATUS_1, tmp, 2);
return 0xffe00000 | ((tmp[0] & 0x7c00) << 6) | (tmp[1] & 0xffff);
#endif
}
@@ -394,13 +390,15 @@ static int prerecord_count; /* Number of seconds in the prerecord buffer */
static int prerecord_timeout; /* The tick count of the next prerecord data store */
/* Shadow MAS registers */
-unsigned long shadow_7f0 = 0;
-unsigned long shadow_7f1 = 0;
-unsigned long shadow_7f6 = 0;
-unsigned long shadow_7f9 = 0;
-
+unsigned long shadow_encoder_control = 0;
#endif /* #if CONFIG_HWCODEC == MAS3587F */
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
+unsigned long shadow_io_control_main = 0;
+unsigned long shadow_app_select = 0;
+unsigned long shadow_soft_mute = 0;
+#endif
+
static int mpeg_file;
/* Synchronization variables */
@@ -927,10 +925,10 @@ static void track_change(void)
{
DEBUGF("Track change\n");
-#if CONFIG_HWCODEC == MAS3587F
+#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
/* Reset the AVC */
mpeg_sound_set(SOUND_AVC, -1);
-#endif /* #if CONFIG_HWCODEC == MAS3587F */
+#endif /* #if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) */
remove_current_tag();
update_playlist();
@@ -2100,10 +2098,10 @@ static void init_recording(void)
/* Stop the current application */
val = 0;
- mas_writemem(MAS_BANK_D0,0x7f6,&val,1);
+ mas_writemem(MAS_BANK_D0, MAS_D0_APP_SELECT, &val, 1);
do
{
- mas_readmem(MAS_BANK_D0, 0x7f7, &val, 1);
+ mas_readmem(MAS_BANK_D0, MAS_D0_APP_RUNNING, &val, 1);
} while(val);
/* Perform black magic as described by the data sheet */
@@ -2130,19 +2128,19 @@ static void init_recording(void)
mas_codec_writereg(7, 0x4000);
/* No mute */
- shadow_7f9 = 0;
- mas_writemem(MAS_BANK_D0, 0x7f9, &shadow_7f9, 1);
+ shadow_soft_mute = 0;
+ mas_writemem(MAS_BANK_D0, MAS_D0_SOFT_MUTE, &shadow_soft_mute, 1);
/* Set Demand mode, monitoring OFF and validate all settings */
- shadow_7f1 = 0x125;
- mas_writemem(MAS_BANK_D0, 0x7f1, &shadow_7f1, 1);
+ shadow_io_control_main = 0x125;
+ mas_writemem(MAS_BANK_D0, MAS_D0_IO_CONTROL_MAIN, &shadow_io_control_main, 1);
/* Start the encoder application */
val = 0x40;
- mas_writemem(MAS_BANK_D0, 0x7f6, &val, 1);
+ mas_writemem(MAS_BANK_D0, MAS_D0_APP_SELECT, &val, 1);
do
{
- mas_readmem(MAS_BANK_D0, 0x7f7, &val, 1);
+ mas_readmem(MAS_BANK_D0, MAS_D0_APP_RUNNING, &val, 1);
} while(!(val & 0x40));
#if 1
@@ -2154,13 +2152,13 @@ static void init_recording(void)
sleep(20);
/* Now set it to Monitoring mode as default, saves power */
- shadow_7f1 = 0x525;
- mas_writemem(MAS_BANK_D0, 0x7f1, &shadow_7f1, 1);
+ shadow_io_control_main = 0x525;
+ mas_writemem(MAS_BANK_D0, MAS_D0_IO_CONTROL_MAIN, &shadow_io_control_main, 1);
/* Wait until the DSP has accepted the settings */
do
{
- mas_readmem(MAS_BANK_D0, 0x7f1, &val,1);
+ mas_readmem(MAS_BANK_D0, MAS_D0_IO_CONTROL_MAIN, &val,1);
} while(val & 1);
drain_dma_buffer();
@@ -2209,14 +2207,14 @@ static void start_prerecording(void)
is_prerecording = true;
/* Stop monitoring and start the encoder */
- shadow_7f1 &= ~(1 << 10);
- mas_writemem(MAS_BANK_D0, 0x7f1, &shadow_7f1, 1);
- DEBUGF("mas_writemem(MAS_BANK_D0, 0x7f1, %x)\n", shadow_7f1);
+ shadow_io_control_main &= ~(1 << 10);
+ mas_writemem(MAS_BANK_D0, MAS_D0_IO_CONTROL_MAIN, &shadow_io_control_main, 1);
+ DEBUGF("mas_writemem(MAS_BANK_D0, IO_CONTROL_MAIN, %x)\n", shadow_io_control_main);
/* Wait until the DSP has accepted the settings */
do
{
- mas_readmem(MAS_BANK_D0, 0x7f1, &val,1);
+ mas_readmem(MAS_BANK_D0, MAS_D0_IO_CONTROL_MAIN, &val,1);
} while(val & 1);
is_recording = true;
@@ -2243,14 +2241,14 @@ static void start_recording(void)
{
/* If prerecording is off, we need to stop the monitoring
and start the encoder */
- shadow_7f1 &= ~(1 << 10);
- mas_writemem(MAS_BANK_D0, 0x7f1, &shadow_7f1, 1);
- DEBUGF("mas_writemem(MAS_BANK_D0, 0x7f1, %x)\n", shadow_7f1);
+ shadow_io_control_main &= ~(1 << 10);
+ mas_writemem(MAS_BANK_D0, MAS_D0_IO_CONTROL_MAIN, &shadow_io_control_main, 1);
+ DEBUGF("mas_writemem(MAS_BANK_D0, IO_CONTROL_MAIN, %x)\n", shadow_io_control_main);
/* Wait until the DSP has accepted the settings */
do
{
- mas_readmem(MAS_BANK_D0, 0x7f1, &val,1);
+ mas_readmem(MAS_BANK_D0, MAS_D0_IO_CONTROL_MAIN, &val,1);
} while(val & 1);
}
@@ -2275,8 +2273,8 @@ static void pause_recording(void)
pause_start_time = current_tick;
/* Set the pause bit */
- shadow_7f9 |= 2;
- mas_writemem(MAS_BANK_D0, 0x7f9, &shadow_7f9, 1);
+ shadow_soft_mute |= 2;
+ mas_writemem(MAS_BANK_D0, MAS_D0_SOFT_MUTE, &shadow_soft_mute, 1);
paused = true;
}
@@ -2286,8 +2284,8 @@ static void resume_recording(void)
paused = false;
/* Clear the pause bit */
- shadow_7f9 &= ~2;
- mas_writemem(MAS_BANK_D0, 0x7f9, &shadow_7f9, 1);
+ shadow_soft_mute &= ~2;
+ mas_writemem(MAS_BANK_D0, MAS_D0_SOFT_MUTE, &shadow_soft_mute, 1);
/* Compensate for the time we have been paused */
if(pause_start_time)
@@ -2313,17 +2311,17 @@ static void stop_recording(void)
is_prerecording = false;
/* Read the number of frames recorded */
- mas_readmem(MAS_BANK_D0, 0xfd0, &num_recorded_frames, 1);
+ mas_readmem(MAS_BANK_D0, MAS_D0_MPEG_FRAME_COUNT, &num_recorded_frames, 1);
/* Start monitoring */
- shadow_7f1 |= (1 << 10);
- mas_writemem(MAS_BANK_D0, 0x7f1, &shadow_7f1, 1);
- DEBUGF("mas_writemem(MAS_BANK_D0, 0x7f1, %x)\n", shadow_7f1);
+ shadow_io_control_main |= (1 << 10);
+ mas_writemem(MAS_BANK_D0, MAS_D0_IO_CONTROL_MAIN, &shadow_io_control_main, 1);
+ DEBUGF("mas_writemem(MAS_BANK_D0, IO_CONTROL_MAIN, %x)\n", shadow_io_control_main);
/* Wait until the DSP has accepted the settings */
do
{
- mas_readmem(MAS_BANK_D0, 0x7f1, &val,1);
+ mas_readmem(MAS_BANK_D0, MAS_D0_IO_CONTROL_MAIN, &val,1);
} while(val & 1);
resume_recording();
@@ -2340,30 +2338,30 @@ void mpeg_set_recording_options(int frequency, int quality,
rec_version_index = is_mpeg1?3:2;
rec_frequency_index = frequency % 3;
- shadow_7f0 = (quality << 17) |
+ shadow_encoder_control = (quality << 17) |
(rec_frequency_index << 10) |
((is_mpeg1?1:0) << 9) |
(((channel_mode * 2 + 1) & 3) << 6) |
(1 << 5) /* MS-stereo */ |
(1 << 2) /* Is an original */;
- mas_writemem(MAS_BANK_D0, 0x7f0, &shadow_7f0,1);
+ mas_writemem(MAS_BANK_D0, MAS_D0_ENCODER_CONTROL, &shadow_encoder_control,1);
- DEBUGF("mas_writemem(MAS_BANK_D0, 0x7f0, %x)\n", shadow_7f0);
+ DEBUGF("mas_writemem(MAS_BANK_D0, ENCODER_CONTROL, %x)\n", shadow_encoder_control);
- shadow_7f9 = editable?4:0;
- mas_writemem(MAS_BANK_D0, 0x7f9, &shadow_7f9,1);
+ shadow_soft_mute = editable?4:0;
+ mas_writemem(MAS_BANK_D0, MAS_D0_SOFT_MUTE, &shadow_soft_mute,1);
- DEBUGF("mas_writemem(MAS_BANK_D0, 0x7f9, %x)\n", shadow_7f9);
+ DEBUGF("mas_writemem(MAS_BANK_D0, SOFT_MUTE, %x)\n", shadow_soft_mute);
- shadow_7f1 = ((1 << 10) | /* Monitoring ON */
+ shadow_io_control_main = ((1 << 10) | /* Monitoring ON */
((source < 2)?1:2) << 8) | /* Input select */
(1 << 5) | /* SDO strobe invert */
((is_mpeg1?0:1) << 3) |
(1 << 2) | /* Inverted SIBC clock signal */
1; /* Validate */
- mas_writemem(MAS_BANK_D0, 0x7f1, &shadow_7f1,1);
+ mas_writemem(MAS_BANK_D0, MAS_D0_IO_CONTROL_MAIN, &shadow_io_control_main,1);
- DEBUGF("mas_writemem(MAS_BANK_D0, 0x7f1, %x)\n", shadow_7f1);
+ DEBUGF("mas_writemem(MAS_BANK_D0, IO_CONTROL_MAIN, %x)\n", shadow_io_control_main);
if(source == 0) /* Mic */
{