summaryrefslogtreecommitdiff
path: root/firmware/target/arm/tms320dm320/dsp-dm320.c
diff options
context:
space:
mode:
authorKarl Kurbjun <kkurbjun@gmail.com>2009-02-26 21:23:10 +0000
committerKarl Kurbjun <kkurbjun@gmail.com>2009-02-26 21:23:10 +0000
commit1e3f52992110d75f1df8c2256d7d6759e9f997fd (patch)
tree40b2f77ffea1ef6c2884f5515c7a30d40b15639a /firmware/target/arm/tms320dm320/dsp-dm320.c
parent38436038a9e50e8314967672fb5e7b9a5009a4be (diff)
Get the M:Robe 500 main build booting again, fix a bug and commit the rest of Cat's work to get sound working. The code is messy right now, but it plays a file (test.raw) in a normal build when you go into the debug ports screen. Take 2.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20116 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/tms320dm320/dsp-dm320.c')
-rw-r--r--firmware/target/arm/tms320dm320/dsp-dm320.c167
1 files changed, 162 insertions, 5 deletions
diff --git a/firmware/target/arm/tms320dm320/dsp-dm320.c b/firmware/target/arm/tms320dm320/dsp-dm320.c
index bc05eff24f..20391baf56 100644
--- a/firmware/target/arm/tms320dm320/dsp-dm320.c
+++ b/firmware/target/arm/tms320dm320/dsp-dm320.c
@@ -23,7 +23,9 @@
#include "system.h"
#include "debug.h"
#include "string.h"
+#include "file.h"
#include "dsp-target.h"
+#include "dsp/ipc.h"
/* A "DSP image" is an array of these, terminated by raw_data_size_half = 0. */
struct dsp_section {
@@ -33,7 +35,9 @@ struct dsp_section {
};
/* Must define struct dsp_section before including the image. */
-#include "dsp_image_helloworld.h"
+#include "dsp/dsp-image.h"
+
+#define dsp_message (*(volatile struct ipc_message *)&DSP_(_status))
#ifdef DEBUG
static void dsp_status(void)
@@ -127,27 +131,180 @@ static void dsp_load(const struct dsp_section *im)
}
}
+static signed short *the_rover = (signed short *)0x1900000;
+static unsigned int index_rover = 0;
+static signed short __attribute__((aligned (16))) pcm_buffer[PCM_SIZE / 2];
+
void dsp_init(void)
{
+ unsigned long sdem_addr;
+ int fd;
+ int bytes;
+
+
IO_INTC_IRQ0 = 1 << 11;
IO_INTC_EINT0 |= 1 << 11;
IO_DSPC_HPIB_CONTROL = 1 << 10 | 1 << 9 | 1 << 8 | 1 << 7 | 1 << 3 | 1 << 0;
dsp_reset();
- dsp_load(dsp_image_helloworld);
+ dsp_load(dsp_image);
+
+ /* Initialize codec. */
+ sdem_addr = (unsigned long)pcm_buffer - CONFIG_SDRAM_START;
+ DEBUGF("pcm_sdram at 0x%08lx, sdem_addr 0x%08lx",
+ (unsigned long)pcm_buffer, (unsigned long)sdem_addr);
+ DSP_(_sdem_addrl) = sdem_addr & 0xffff;
+ DSP_(_sdem_addrh) = sdem_addr >> 16;
+
+ fd = open("/test.raw", O_RDONLY);
+ bytes = read(fd, the_rover, 4*1024*1024);
+ close(fd);
+
+ DEBUGF("read %d rover bytes", bytes);
+
+ #if 0
+ {
+ unsigned int i;
+ memset(pcm_buffer, 0x80, PCM_SIZE);
+ for (i = 0; i < 8192; i++) {
+ signed short val = 0;
+ /*if (i < PCM_SIZE/4/2) {
+ val = 128*(i%256);
+ } else {
+ val = 2*128*128-128*(i%256);
+ }*/
+ val = 128*(i%256);
+ pcm_buffer[2*i] = pcm_buffer[2*i+1] = val;
+ }
+ clean_dcache();
+
+
+ {
+ unsigned int i;
+ volatile signed short *pdata = &DSP_(_data);
+ DEBUGF("dsp__data at %08x", pdata);
+ for (i = 0; i < 4096; i++) {
+ pdata[2*i]=pdata[2*i+1]=(i&1)*32767;
+ }
+ for (i = 4096; i < 8192; i++) {
+ pdata[2*i]=pdata[2*i+1]=0;
+ }
+ }
+ #endif
+
+#ifdef IPC_SIZES
+ DEBUGF("dsp_message at 0x%08x", &dsp_message);
+ DEBUGF("sizeof(ipc_message)=%uB offset(ipc_message.payload)=%uB",
+ sizeof(struct ipc_message), (int)&((struct ipc_message*)0)->payload);
+#endif
+
+#ifdef INIT_MSG
+ /* Prepare init message. */
+
+ /* DSP accesses MUST be done a word at a time. */
+ dsp_message.msg = MSG_INIT;
+
+ sdem_addr = (unsigned long)pcm_sdram - CONFIG_SDRAM_START;
+ DEBUGF("pcm_sdram at 0x%08x, sdem_addr 0x%08x", pcm_sdram, sdem_addr);
+ dsp_message.payload.init.sdem_addrl = sdem_addr & 0xffff;
+ dsp_message.payload.init.sdem_addrh = sdem_addr >> 16;
+
+ DEBUGF("dsp_message: %04x %04x %04x %04x",
+ ((unsigned short *)&dsp_message)[0],
+ ((unsigned short *)&dsp_message)[1],
+ ((unsigned short *)&dsp_message)[2],
+ ((unsigned short *)&dsp_message)[3]);
+#endif
+
}
void DSPHINT(void)
{
unsigned int i;
char buffer[80];
+ static unsigned short level = 2;
+
+ unsigned short *pcm_topbottom, *pcm_topbottom_end;
+
IO_INTC_IRQ0 = 1 << 11;
- /* DSP stores one character per word. */
- for (i = 0; i < sizeof(buffer); i++) {
- buffer[i] = (&DSP_(_status))[i];
+
+ switch (dsp_message.msg)
+ {
+ case MSG_DEBUGF:
+ /* DSP stores one character per word. */
+ for (i = 0; i < sizeof(buffer); i++)
+ {
+ buffer[i] = dsp_message.payload.debugf.buffer[i];
+ }
+
+ /* Release shared area to DSP. */
+ dsp_wake();
+
+ DEBUGF("DSP: %s", buffer);
+ break;
+ case MSG_REFILL:
+ DEBUGF("DSP: DMA0 with topbottom=%u (fill at %04lx)",
+ dsp_message.payload.refill.topbottom,
+ (unsigned long)pcm_buffer +
+ dsp_message.payload.refill.topbottom);
+ pcm_topbottom = pcm_buffer + dsp_message.payload.refill.topbottom / 2;
+
+ /*
+ i = 0;
+ while (i < PCM_SIZE/4) {
+ unsigned int j;
+ for (j = 0; j < level; j++) {
+ pcm_topbottom[i+j] = -32768;
+ }
+ for (j = level; j < 2*level; j++) {
+ pcm_topbottom[i+j] = 32767;
+ }
+ i += 2*level;
+ }
+
+ level += 2;
+ if (level > 256) {
+ level = 2;
+ }*/
+
+ memcpy(pcm_topbottom, the_rover + index_rover, PCM_SIZE/2);
+ index_rover += PCM_SIZE/4;
+ if (index_rover >= 2*1024*1024) {
+ index_rover = 0;
+ }
+
+ /*
+ pcm_topbottom = &p_pcm_sdram[dsp_message.payload.refill.topbottom/2];
+ DEBUGF("DSP: tofill begins: %04x %04x %04x %04x",
+ pcm_topbottom[0],
+ pcm_topbottom[1],
+ pcm_topbottom[2],
+ pcm_topbottom[3]
+ );
+ pcm_topbottom_end = &p_pcm_sdram[(dsp_message.payload.refill.topbottom+PCM_SIZE/2)/2];
+ DEBUGF("DSP: tofill ends: %04x %04x %04x %04x",
+ pcm_topbottom_end[-4],
+ pcm_topbottom_end[-3],
+ pcm_topbottom_end[-2],
+ pcm_topbottom_end[-1]
+ );
+ */
+
+ /*
+ DEBUGF("DSP: DMA0: SD %04x:%04x -> DSP %04x:%04x, TRG %04x",
+ dsp_message.payload.refill._SDEM_ADDRH,
+ dsp_message.payload.refill._SDEM_ADDRL,
+ dsp_message.payload.refill._DSP_ADDRH,
+ dsp_message.payload.refill._DSP_ADDRL,
+ dsp_message.payload.refill._DMA_TRG);
+ */
+ break;
+ default:
+ DEBUGF("DSP: unknown msg 0x%04x", dsp_message.msg);
+ break;
}
/* Release shared area to DSP. */