Index: apps/plugins/plugin.lds =================================================================== --- apps/plugins/plugin.lds (revision 19276) +++ apps/plugins/plugin.lds (working copy) @@ -37,6 +37,8 @@ #include "imx31l.h" /* Reserve 1mb for LCD buffer/TTB as in app.lds */ #define DRAMSIZE (MEMORYSIZE * 0x100000 - 0x100000) - PLUGIN_BUFFER_SIZE - STUBOFFSET - CODEC_SIZE +#elif CONFIG_CPU==AS3525 +#define DRAMSIZE (MEMORYSIZE * 0x100000) - PLUGIN_BUFFER_SIZE - STUBOFFSET #else #define DRAMSIZE (MEMORYSIZE * 0x100000) - PLUGIN_BUFFER_SIZE - STUBOFFSET - CODEC_SIZE #endif @@ -87,17 +89,27 @@ #define IRAM DRAM #define IRAMSIZE 0 #elif CONFIG_CPU==AS3525 -#define IRAMORIG 0x0 -#define IRAMSIZE 0x50000 +//#define IRAMORIG 0x8000 +//#define IRAMSIZE 0x8000 +#define IRAMSIZE 0 #define DRAMORIG 0x30000000 + +#define CODEC_ORIGIN (0x10000) +#define PLUGIN_ORIGIN (DRAMORIG + DRAMSIZE) + #else #define DRAMORIG 0x09000000 + STUBOFFSET #endif #define PLUGIN_LENGTH PLUGIN_BUFFER_SIZE +#ifndef CODEC_ORIGIN /* targets can specify another origin */ #define CODEC_ORIGIN (DRAMORIG + (DRAMSIZE)) +#endif + +#ifndef PLUGIN_ORIGIN /* targets can specify another origin */ #define PLUGIN_ORIGIN (CODEC_ORIGIN + CODEC_SIZE) +#endif #ifdef CODEC #define THIS_LENGTH CODEC_SIZE Index: apps/plugins/SOURCES =================================================================== --- apps/plugins/SOURCES (revision 19276) +++ apps/plugins/SOURCES (working copy) @@ -1,4 +1,5 @@ /* plugins common to all models */ +test_codec.c battery_bench.c chessclock.c credits.c Index: apps/playback.c =================================================================== --- apps/playback.c (revision 19276) +++ apps/playback.c (working copy) @@ -2328,7 +2328,10 @@ filebuflen &= ~15; /* Subtract whatever the pcm buffer says it used plus the guard buffer */ - filebuflen -= pcmbuf_init(filebuf + filebuflen) + GUARD_BUFSIZE; + size_t pcmbuf_size = pcmbuf_init(filebuf + filebuflen) + GUARD_BUFSIZE; + if(pcmbuf_size > filebuflen) + panicf("Not enough memory for pcmbuf_init()"); + filebuflen -= pcmbuf_size; /* Make sure filebuflen is a longword multiple after adjustment - filebuf will already be line aligned */ Index: firmware/export/config-clip.h =================================================================== --- firmware/export/config-clip.h (revision 19276) +++ firmware/export/config-clip.h (working copy) @@ -95,10 +95,10 @@ #define HAVE_FAT16SUPPORT /* The number of bytes reserved for loadable codecs */ -#define CODEC_SIZE 0x80000 /* TODO : check if we can use IRAM */ +#define CODEC_SIZE 0x40000 /* TODO : check if we can use IRAM */ /* The number of bytes reserved for loadable plugins */ -#define PLUGIN_BUFFER_SIZE 0x80000 +#define PLUGIN_BUFFER_SIZE 0x60000 #define AB_REPEAT_ENABLE 1 Index: firmware/target/arm/as3525/pcm-as3525.c =================================================================== --- firmware/target/arm/as3525/pcm-as3525.c (revision 19276) +++ firmware/target/arm/as3525/pcm-as3525.c (working copy) @@ -21,7 +21,12 @@ #include "system.h" #include "audio.h" #include "string.h" - +#include "as3525.h" +#include "pl081.h" +#include "dma-target.h" +#include "panic.h" +#include "as3514.h" +#include "audiohw.h" /* TODO */ void pcm_play_lock(void) @@ -32,8 +37,52 @@ { } +static unsigned char *dma_start_addr; +static size_t dma_size; /* in 4*32 bits */ + +static void dma_callback(void) +{ + size_t size; + + if(!dma_size) + { + register pcm_more_callback_type get_more = pcm_callback_for_more; + if(get_more) + get_more(&dma_start_addr, &dma_size); + } + + if(!dma_size) + { + /*lcd_puts(0,3,"pcm : end"); + lcd_update();*/ + return; + } + + size = dma_size; + if(size > 0x1ffc) + size = 0x1ffc; + + dma_enable_channel(1, (void*)dma_start_addr, (void*)I2SOUT_DATA, + DMA_PERI_I2SOUT, DMAC_FLOWCTRL_DMAC_MEM_TO_PERI, true, false, size / 4, + DMA_S1, dma_callback); + + dma_size -= size; + dma_start_addr += size; +} + void pcm_play_dma_start(const void *addr, size_t size) { + dma_size = size; + + if(size > 0x1ffc) + size = 0x1ffc; + + dma_enable_channel(1, (void*)addr, (void*)I2SOUT_DATA, DMA_PERI_I2SOUT, + DMAC_FLOWCTRL_DMAC_MEM_TO_PERI, true, false, size / 4, DMA_S1, + dma_callback); + + dma_size -= size; + dma_start_addr += size; } void pcm_play_dma_stop(void) @@ -44,17 +93,23 @@ { } -unsigned long physical_address(void *p) +void pcm_play_dma_init(void) { - return 0; -} + CGU_PERI |= CGU_I2SOUT_APB_CLOCK_ENABLE; + CGU_AUDIO = (1<<11) | ((55-1)<<2) | (1<<0); /* enable I2SO_MCLK */ -void pcm_play_dma_init(void) -{ + I2SOUT_CONTROL |= (1<<6) ; /* enable dma */ + I2SOUT_CONTROL |= (1<<3) ; /* stereo */ + I2SOUT_CONTROL &= ~(1<<2); /* 16 bit samples */ + + audiohw_preinit(); } void pcm_postinit(void) { + audiohw_postinit(); + pcm_apply_settings(); + } void pcm_set_frequency(unsigned int frequency) @@ -67,11 +122,12 @@ size_t pcm_get_bytes_waiting(void) { - return 0; + return dma_size; } const void * pcm_play_dma_get_peak_buffer(int *count) { + panicf("pcm_play_dma_get_peak_buffer %x",*count); return NULL; } Index: firmware/target/arm/as3525/dma-pl081.c =================================================================== --- firmware/target/arm/as3525/dma-pl081.c (revision 19276) +++ firmware/target/arm/as3525/dma-pl081.c (working copy) @@ -27,6 +27,7 @@ #include "kernel.h" static struct wakeup transfer_completion_signal[2]; /* 2 channels */ +static void (*dma_callback[2])(void); /* 2 channels */ inline void dma_wait_transfer(int channel) { @@ -47,8 +48,10 @@ void dma_enable_channel(int channel, void *src, void *dst, int peri, int flow_controller, bool src_inc, bool dst_inc, - size_t size, int nwords) + size_t size, int nwords, void (*callback)(void)) { + dma_callback[channel] = callback; + int control = 0; DMAC_CH_SRC_ADDR(channel) = (int)src; @@ -99,5 +102,8 @@ DMAC_INT_TC_CLEAR |= (1< IRAM AT> DRAM + .codec CODECORIG (NOLOAD) : + { + codecbuf = .; + _codecbuf = .; + } > CODEC_IRAM + _iramcopy = LOADADDR(.iram); .audiobuf (NOLOAD) : @@ -129,15 +138,9 @@ _audiobufend = .; } > DRAM - .codec ENDAUDIOADDR (NOLOAD) : - { - codecbuf = .; - _codecbuf = .; - } - .plugin ENDADDR (NOLOAD) : { _pluginbuf = .; pluginbuf = .; - } + } > DRAM } Index: firmware/target/arm/as3525/dma-target.h =================================================================== --- firmware/target/arm/as3525/dma-target.h (revision 19276) +++ firmware/target/arm/as3525/dma-target.h (working copy) @@ -34,6 +34,6 @@ void dma_init(void); void dma_enable_channel(int channel, void *src, void *dst, int peri, int flow_controller, bool src_inc, bool dst_inc, - size_t size, int nwords); + size_t size, int nwords, void (*callback)(void)); inline void dma_wait_transfer(int channel); Index: firmware/target/arm/as3525/ata_sd_as3525.c =================================================================== --- firmware/target/arm/as3525/ata_sd_as3525.c (revision 19276) +++ firmware/target/arm/as3525/ata_sd_as3525.c (working copy) @@ -95,7 +95,7 @@ #define MIN_YIELD_PERIOD 5 /* ticks */ static long next_yield = 0; -static long sd_stack [(DEFAULT_STACK_SIZE*2 + 0x200)/sizeof(long)]; +static long sd_stack [(DEFAULT_STACK_SIZE*2 + 0x800)/sizeof(long)]; static const char sd_thread_name[] = "ata/sd"; static struct mutex sd_mtx SHAREDBSS_ATTR; static struct event_queue sd_queue; @@ -541,12 +541,12 @@ if(write) dma_enable_channel(0, buf, MCI_FIFO(drive), - (drive == INTERNAL_AS3525) ? DMA_PERI_SD : DMA_PERI_SD_SLOT, - DMAC_FLOWCTRL_PERI_MEM_TO_PERI, true, false, 0, DMA_S8); + (drive == INTERNAL_AS3525) ? DMA_PERI_SD : DMA_PERI_SD_SLOT, + DMAC_FLOWCTRL_PERI_MEM_TO_PERI, true, false, 0, DMA_S8, NULL); else dma_enable_channel(0, MCI_FIFO(drive), buf, - (drive == INTERNAL_AS3525) ? DMA_PERI_SD : DMA_PERI_SD_SLOT, - DMAC_FLOWCTRL_PERI_PERI_TO_MEM, false, true, 0, DMA_S8); + (drive == INTERNAL_AS3525) ? DMA_PERI_SD : DMA_PERI_SD_SLOT, + DMAC_FLOWCTRL_PERI_PERI_TO_MEM, false, true, 0, DMA_S8, NULL); MCI_DATA_TIMER(drive) = 0x1000000; /* FIXME: arbitrary */ MCI_DATA_LENGTH(drive) = transfer * card_info[drive].block_size; Index: firmware/drivers/audio/as3514.c =================================================================== --- firmware/drivers/audio/as3514.c (revision 19276) +++ firmware/drivers/audio/as3514.c (working copy) @@ -194,7 +194,10 @@ /* wait until outputs have stabilized */ sleep(HZ/4); +/* TODO do other targets really need this? Sansa clip needs HPCM */ +#ifndef SANSA_CLIP as3514_write(AS3514_AUDIOSET3, AUDIOSET3_HPCM_off); +#endif #ifdef CPU_PP ascodec_suppressor_on(false);