summaryrefslogtreecommitdiff
path: root/firmware/target/arm/tms320dm320/mrobe-500/pcm-mr500.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/tms320dm320/mrobe-500/pcm-mr500.c')
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/pcm-mr500.c62
1 files changed, 44 insertions, 18 deletions
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/pcm-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/pcm-mr500.c
index df88e16854..0542c6c2a9 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/pcm-mr500.c
+++ b/firmware/target/arm/tms320dm320/mrobe-500/pcm-mr500.c
@@ -29,15 +29,31 @@
29#include "dsp/ipc.h" 29#include "dsp/ipc.h"
30#include "mmu-arm.h" 30#include "mmu-arm.h"
31 31
32/* These are global to save some latency when pcm_play_dma_get_peak_buffer is
33 * called.
34 */
35static unsigned char *start;
36static size_t size;
37
32void pcm_postinit(void) 38void pcm_postinit(void)
33{ 39{
34 audiohw_postinit(); 40 audiohw_postinit();
35} 41}
36 42
43/* Return the current location in the SDRAM to SARAM transfer along with the
44 * number of bytes read in the current buffer (count). There is latency with
45 * this method equivalent to ~ the size of the SARAM buffer since there is
46 * another buffer between your ears and this calculation, but this works for
47 * key clicks and an approximate peak meter.
48 */
37const void * pcm_play_dma_get_peak_buffer(int *count) 49const void * pcm_play_dma_get_peak_buffer(int *count)
38{ 50{
39 (void) count; 51 int cnt = DSP_(_sdem_level);
40 return 0; 52
53 unsigned long addr = (unsigned long) start +cnt;
54
55 *count = (cnt & 0xFFFFF) >> 1;
56 return (void *)((addr + 2) & ~3);
41} 57}
42 58
43void pcm_play_dma_init(void) 59void pcm_play_dma_init(void)
@@ -49,6 +65,7 @@ void pcm_play_dma_init(void)
49 65
50 dsp_reset(); 66 dsp_reset();
51 dsp_load(dsp_image); 67 dsp_load(dsp_image);
68 dsp_wake();
52} 69}
53 70
54void pcm_dma_apply_settings(void) 71void pcm_dma_apply_settings(void)
@@ -56,6 +73,9 @@ void pcm_dma_apply_settings(void)
56 audiohw_set_frequency(pcm_fsel); 73 audiohw_set_frequency(pcm_fsel);
57} 74}
58 75
76/* Note that size is actually limited to the size of a short right now due to
77 * the implementation on the DSP side (and the way that we access it)
78 */
59void pcm_play_dma_start(const void *addr, size_t size) 79void pcm_play_dma_start(const void *addr, size_t size)
60{ 80{
61 unsigned long sdem_addr=(unsigned long)addr - CONFIG_SDRAM_START; 81 unsigned long sdem_addr=(unsigned long)addr - CONFIG_SDRAM_START;
@@ -63,12 +83,14 @@ void pcm_play_dma_start(const void *addr, size_t size)
63 DSP_(_sdem_addrl) = sdem_addr & 0xffff; 83 DSP_(_sdem_addrl) = sdem_addr & 0xffff;
64 DSP_(_sdem_addrh) = sdem_addr >> 16; 84 DSP_(_sdem_addrh) = sdem_addr >> 16;
65 DSP_(_sdem_dsp_size) = size; 85 DSP_(_sdem_dsp_size) = size;
86 DSP_(_dma0_stopped)=0;
87
66 dsp_wake(); 88 dsp_wake();
67} 89}
68 90
69void pcm_play_dma_stop(void) 91void pcm_play_dma_stop(void)
70{ 92{
71 93 DSP_(_dma0_stopped)=1;
72} 94}
73 95
74void pcm_play_lock(void) 96void pcm_play_lock(void)
@@ -83,7 +105,15 @@ void pcm_play_unlock(void)
83 105
84void pcm_play_dma_pause(bool pause) 106void pcm_play_dma_pause(bool pause)
85{ 107{
86 (void) pause; 108 if (pause)
109 {
110 DSP_(_dma0_stopped)=2;
111 }
112 else
113 {
114 DSP_(_dma0_stopped)=0;
115 dsp_wake();
116 }
87} 117}
88 118
89size_t pcm_get_bytes_waiting(void) 119size_t pcm_get_bytes_waiting(void)
@@ -93,8 +123,6 @@ size_t pcm_get_bytes_waiting(void)
93 123
94void DSPHINT(void) 124void DSPHINT(void)
95{ 125{
96 static unsigned char *start;
97 static size_t size;
98 register pcm_more_callback_type get_more; /* No stack for this */ 126 register pcm_more_callback_type get_more; /* No stack for this */
99 127
100 unsigned int i; 128 unsigned int i;
@@ -111,9 +139,6 @@ void DSPHINT(void)
111 buffer[i] = dsp_message.payload.debugf.buffer[i]; 139 buffer[i] = dsp_message.payload.debugf.buffer[i];
112 } 140 }
113 141
114 /* Release shared area to DSP. */
115 dsp_wake();
116
117 DEBUGF("DSP: %s", buffer); 142 DEBUGF("DSP: %s", buffer);
118 break; 143 break;
119 144
@@ -121,27 +146,28 @@ void DSPHINT(void)
121 /* Buffer empty. Try to get more. */ 146 /* Buffer empty. Try to get more. */
122 get_more = pcm_callback_for_more; 147 get_more = pcm_callback_for_more;
123 size = 0; 148 size = 0;
124 149
125 if (get_more == NULL || (get_more(&start, &size), size == 0)) 150 if (get_more == NULL || (get_more(&start, &size), size == 0))
126 { 151 {
127 /* Callback missing or no more DMA to do */ 152 /* Callback missing or no more DMA to do */
128 pcm_play_dma_stop(); 153 pcm_play_dma_stop();
129 pcm_play_dma_stopped_callback(); 154 pcm_play_dma_stopped_callback();
130 } 155 }
131 else 156
132 { 157 {
133 unsigned long sdem_addr=(unsigned long)start - CONFIG_SDRAM_START; 158 unsigned long sdem_addr=(unsigned long)start - CONFIG_SDRAM_START;
134 /* Flush any pending cache writes */ 159 /* Flush any pending cache writes */
135 clean_dcache_range(start, size); 160 clean_dcache_range(start, size);
136 161
137 /* set the new DMA values */ 162 /* set the new DMA values */
138 DSP_(_sdem_addrl) = sdem_addr & 0xffff; 163 DSP_(_sdem_addrl) = sdem_addr & 0xffff;
139 DSP_(_sdem_addrh) = sdem_addr >> 16; 164 DSP_(_sdem_addrh) = sdem_addr >> 16;
140 DSP_(_sdem_dsp_size) = size; 165 DSP_(_sdem_dsp_size) = size;
141 166
142 DEBUGF("pcm_sdram at 0x%08lx, sdem_addr 0x%08lx", 167 DEBUGF("pcm_sdram at 0x%08lx, sdem_addr 0x%08lx",
143 (unsigned long)start, (unsigned long)sdem_addr); 168 (unsigned long)start, (unsigned long)sdem_addr);
144 } 169 }
170
145 break; 171 break;
146 default: 172 default:
147 DEBUGF("DSP: unknown msg 0x%04x", dsp_message.msg); 173 DEBUGF("DSP: unknown msg 0x%04x", dsp_message.msg);