summaryrefslogtreecommitdiff
path: root/firmware/target/arm/tms320dm320/dsp-dm320.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/tms320dm320/dsp-dm320.c')
-rw-r--r--firmware/target/arm/tms320dm320/dsp-dm320.c109
1 files changed, 18 insertions, 91 deletions
diff --git a/firmware/target/arm/tms320dm320/dsp-dm320.c b/firmware/target/arm/tms320dm320/dsp-dm320.c
index fea7ecbbe9..aad2941254 100644
--- a/firmware/target/arm/tms320dm320/dsp-dm320.c
+++ b/firmware/target/arm/tms320dm320/dsp-dm320.c
@@ -133,7 +133,7 @@ static void dsp_load(const struct dsp_section *im)
133 133
134static signed short *the_rover = (signed short *)0x1900000; 134static signed short *the_rover = (signed short *)0x1900000;
135static unsigned int index_rover = 0; 135static unsigned int index_rover = 0;
136static signed short __attribute__((aligned (16))) pcm_buffer[PCM_SIZE / 2]; 136#define ARM_BUFFER_SIZE (PCM_SIZE)
137 137
138void dsp_init(void) 138void dsp_init(void)
139{ 139{
@@ -141,7 +141,6 @@ void dsp_init(void)
141 int fd; 141 int fd;
142 int bytes; 142 int bytes;
143 143
144
145 IO_INTC_IRQ0 = 1 << 11; 144 IO_INTC_IRQ0 = 1 << 11;
146 IO_INTC_EINT0 |= 1 << 11; 145 IO_INTC_EINT0 |= 1 << 11;
147 146
@@ -151,47 +150,18 @@ void dsp_init(void)
151 dsp_load(dsp_image); 150 dsp_load(dsp_image);
152 151
153 /* Initialize codec. */ 152 /* Initialize codec. */
154 sdem_addr = (unsigned long)pcm_buffer - CONFIG_SDRAM_START; 153 sdem_addr = (unsigned long)the_rover - CONFIG_SDRAM_START;
155 DEBUGF("pcm_sdram at 0x%08lx, sdem_addr 0x%08lx", 154 DEBUGF("pcm_sdram at 0x%08lx, sdem_addr 0x%08lx",
156 (unsigned long)pcm_buffer, (unsigned long)sdem_addr); 155 (unsigned long)the_rover, (unsigned long)sdem_addr);
157 DSP_(_sdem_addrl) = sdem_addr & 0xffff; 156 DSP_(_sdem_addrl) = sdem_addr & 0xffff;
158 DSP_(_sdem_addrh) = sdem_addr >> 16; 157 DSP_(_sdem_addrh) = sdem_addr >> 16;
159 158 DSP_(_sdem_dsp_size) = ARM_BUFFER_SIZE;
159
160 fd = open("/test.raw", O_RDONLY); 160 fd = open("/test.raw", O_RDONLY);
161 bytes = read(fd, the_rover, 4*1024*1024); 161 bytes = read(fd, the_rover, 4*1024*1024);
162 close(fd); 162 close(fd);
163 163
164 DEBUGF("read %d rover bytes", bytes); 164 DEBUGF("read %d rover bytes", bytes);
165
166 #if 0
167 {
168 unsigned int i;
169 memset(pcm_buffer, 0x80, PCM_SIZE);
170 for (i = 0; i < 8192; i++) {
171 signed short val = 0;
172 /*if (i < PCM_SIZE/4/2) {
173 val = 128*(i%256);
174 } else {
175 val = 2*128*128-128*(i%256);
176 }*/
177 val = 128*(i%256);
178 pcm_buffer[2*i] = pcm_buffer[2*i+1] = val;
179 }
180 clean_dcache();
181
182
183 {
184 unsigned int i;
185 volatile signed short *pdata = &DSP_(_data);
186 DEBUGF("dsp__data at %08x", pdata);
187 for (i = 0; i < 4096; i++) {
188 pdata[2*i]=pdata[2*i+1]=(i&1)*32767;
189 }
190 for (i = 4096; i < 8192; i++) {
191 pdata[2*i]=pdata[2*i+1]=0;
192 }
193 }
194 #endif
195 165
196#ifdef IPC_SIZES 166#ifdef IPC_SIZES
197 DEBUGF("dsp_message at 0x%08x", &dsp_message); 167 DEBUGF("dsp_message at 0x%08x", &dsp_message);
@@ -199,7 +169,7 @@ void dsp_init(void)
199 sizeof(struct ipc_message), (int)&((struct ipc_message*)0)->payload); 169 sizeof(struct ipc_message), (int)&((struct ipc_message*)0)->payload);
200#endif 170#endif
201 171
202#ifdef INIT_MSG 172#if 0//def INIT_MSG
203 /* Prepare init message. */ 173 /* Prepare init message. */
204 174
205 /* DSP accesses MUST be done a word at a time. */ 175 /* DSP accesses MUST be done a word at a time. */
@@ -221,15 +191,12 @@ void dsp_init(void)
221 191
222void DSPHINT(void) 192void DSPHINT(void)
223{ 193{
194 unsigned long sdem_addr;
224 unsigned int i; 195 unsigned int i;
225 char buffer[80]; 196 char buffer[80];
226
227 unsigned short *pcm_topbottom;
228 197
229
230 IO_INTC_IRQ0 = 1 << 11; 198 IO_INTC_IRQ0 = 1 << 11;
231 199
232
233 switch (dsp_message.msg) 200 switch (dsp_message.msg)
234 { 201 {
235 case MSG_DEBUGF: 202 case MSG_DEBUGF:
@@ -245,61 +212,21 @@ void DSPHINT(void)
245 DEBUGF("DSP: %s", buffer); 212 DEBUGF("DSP: %s", buffer);
246 break; 213 break;
247 case MSG_REFILL: 214 case MSG_REFILL:
248 DEBUGF("DSP: DMA0 with topbottom=%u (fill at %04lx)", 215 sdem_addr = (unsigned long)the_rover + index_rover - CONFIG_SDRAM_START;
249 dsp_message.payload.refill.topbottom, 216
250 (unsigned long)pcm_buffer + 217 DSP_(_sdem_addrl) = sdem_addr & 0xffff;
251 dsp_message.payload.refill.topbottom); 218 DSP_(_sdem_addrh) = sdem_addr >> 16;
252 pcm_topbottom = pcm_buffer + dsp_message.payload.refill.topbottom / 2; 219 DSP_(_sdem_dsp_size) = ARM_BUFFER_SIZE;
253 220
254 /* 221 index_rover += ARM_BUFFER_SIZE;
255 i = 0; 222 if (index_rover >= 4*1024*1024)
256 while (i < PCM_SIZE/4) { 223 {
257 unsigned int j;
258 for (j = 0; j < level; j++) {
259 pcm_topbottom[i+j] = -32768;
260 }
261 for (j = level; j < 2*level; j++) {
262 pcm_topbottom[i+j] = 32767;
263 }
264 i += 2*level;
265 }
266
267 level += 2;
268 if (level > 256) {
269 level = 2;
270 }*/
271
272 memcpy(pcm_topbottom, the_rover + index_rover, PCM_SIZE/2);
273 index_rover += PCM_SIZE/4;
274 if (index_rover >= 2*1024*1024) {
275 index_rover = 0; 224 index_rover = 0;
276 } 225 }
277 226
278 /* 227 DEBUGF("pcm_sdram at 0x%08lx, sdem_addr 0x%08lx",
279 pcm_topbottom = &p_pcm_sdram[dsp_message.payload.refill.topbottom/2]; 228 (unsigned long)the_rover, (unsigned long)sdem_addr);
280 DEBUGF("DSP: tofill begins: %04x %04x %04x %04x",
281 pcm_topbottom[0],
282 pcm_topbottom[1],
283 pcm_topbottom[2],
284 pcm_topbottom[3]
285 );
286 pcm_topbottom_end = &p_pcm_sdram[(dsp_message.payload.refill.topbottom+PCM_SIZE/2)/2];
287 DEBUGF("DSP: tofill ends: %04x %04x %04x %04x",
288 pcm_topbottom_end[-4],
289 pcm_topbottom_end[-3],
290 pcm_topbottom_end[-2],
291 pcm_topbottom_end[-1]
292 );
293 */
294 229
295 /*
296 DEBUGF("DSP: DMA0: SD %04x:%04x -> DSP %04x:%04x, TRG %04x",
297 dsp_message.payload.refill._SDEM_ADDRH,
298 dsp_message.payload.refill._SDEM_ADDRL,
299 dsp_message.payload.refill._DSP_ADDRH,
300 dsp_message.payload.refill._DSP_ADDRL,
301 dsp_message.payload.refill._DMA_TRG);
302 */
303 break; 230 break;
304 default: 231 default:
305 DEBUGF("DSP: unknown msg 0x%04x", dsp_message.msg); 232 DEBUGF("DSP: unknown msg 0x%04x", dsp_message.msg);