diff options
Diffstat (limited to 'firmware/target/arm/tms320dm320/dsp/dma.c')
-rw-r--r-- | firmware/target/arm/tms320dm320/dsp/dma.c | 70 |
1 files changed, 37 insertions, 33 deletions
diff --git a/firmware/target/arm/tms320dm320/dsp/dma.c b/firmware/target/arm/tms320dm320/dsp/dma.c index 62c108ec6f..cf1e324a1f 100644 --- a/firmware/target/arm/tms320dm320/dsp/dma.c +++ b/firmware/target/arm/tms320dm320/dsp/dma.c | |||
@@ -54,6 +54,7 @@ unsigned short last_size; | |||
54 | /* This tells us which half of the DSP buffer (data) is free */ | 54 | /* This tells us which half of the DSP buffer (data) is free */ |
55 | unsigned short dma0_unlocked; | 55 | unsigned short dma0_unlocked; |
56 | 56 | ||
57 | int waiting=0; | ||
57 | /* rebuffer sets up the next SDRAM to SARAM transfer and tells the ARM when it | 58 | /* rebuffer sets up the next SDRAM to SARAM transfer and tells the ARM when it |
58 | * is done with a buffer. | 59 | * is done with a buffer. |
59 | */ | 60 | */ |
@@ -76,45 +77,49 @@ void rebuffer(void) | |||
76 | sdem_level=0; | 77 | sdem_level=0; |
77 | 78 | ||
78 | /* Get a new buffer (location and size) from ARM */ | 79 | /* Get a new buffer (location and size) from ARM */ |
79 | status.msg = MSG_REFILL; | 80 | status.msg = MSG_REFILL; |
80 | int_arm(); | 81 | waiting=1; |
82 | startack(); | ||
81 | } | 83 | } |
82 | 84 | ||
83 | /* Size is in bytes (but forced 32 bit transfers */ | 85 | if(!waiting) |
84 | if( (dsp_level + (sdem_dsp_size - sdem_level) ) > DSP_BUFFER_SIZE) | ||
85 | { | ||
86 | last_size = DSP_BUFFER_SIZE-dsp_level; | ||
87 | } | ||
88 | else | ||
89 | { | 86 | { |
90 | last_size = sdem_dsp_size-sdem_level; | 87 | /* Size is in bytes (but forced 32 bit transfers */ |
91 | } | 88 | if( (dsp_level + (sdem_dsp_size - sdem_level) ) > DSP_BUFFER_SIZE) |
89 | { | ||
90 | last_size = DSP_BUFFER_SIZE-dsp_level; | ||
91 | } | ||
92 | else | ||
93 | { | ||
94 | last_size = sdem_dsp_size-sdem_level; | ||
95 | } | ||
92 | 96 | ||
93 | /* DSP addresses are 16 bit (word) */ | 97 | /* DSP addresses are 16 bit (word) */ |
94 | DSP_ADDRL = (unsigned short)data + (dma0_unlocked >> 1) + (dsp_level>>1); | 98 | DSP_ADDRL = (unsigned short)data + (dma0_unlocked >> 1) + (dsp_level>>1); |
95 | DSP_ADDRH = 0; | 99 | DSP_ADDRH = 0; |
96 | 100 | ||
97 | /* SDRAM addresses are 8 bit (byte) | 101 | /* SDRAM addresses are 8 bit (byte) |
98 | * Warning: These addresses are forced to 32 bit alignment! | 102 | * Warning: These addresses are forced to 32 bit alignment! |
99 | */ | 103 | */ |
100 | sdem_addr = ((unsigned long)sdem_addrh << 16 | sdem_addrl) + sdem_level; | 104 | sdem_addr = ((unsigned long)sdem_addrh << 16 | sdem_addrl) + sdem_level; |
101 | SDEM_ADDRL = sdem_addr & 0xffff; | 105 | SDEM_ADDRL = sdem_addr & 0xffff; |
102 | SDEM_ADDRH = sdem_addr >> 16; | 106 | SDEM_ADDRH = sdem_addr >> 16; |
103 | 107 | ||
104 | /* Set the size of the SDRAM to SARAM transfer (demac transfer) */ | 108 | /* Set the size of the SDRAM to SARAM transfer (demac transfer) */ |
105 | DMA_SIZE = last_size; | 109 | DMA_SIZE = last_size; |
106 | 110 | ||
107 | DMA_CTRL = 0; | 111 | DMA_CTRL = 0; |
108 | 112 | ||
109 | /* These are just debug signals that are not used/needed right now */ | 113 | /* These are just debug signals that are not used/needed right now */ |
110 | status.payload.refill._DMA_TRG = DMA_TRG; | 114 | status.payload.refill._DMA_TRG = DMA_TRG; |
111 | status.payload.refill._SDEM_ADDRH = SDEM_ADDRH; | 115 | status.payload.refill._SDEM_ADDRH = SDEM_ADDRH; |
112 | status.payload.refill._SDEM_ADDRL = SDEM_ADDRL; | 116 | status.payload.refill._SDEM_ADDRL = SDEM_ADDRL; |
113 | status.payload.refill._DSP_ADDRH = DSP_ADDRH; | 117 | status.payload.refill._DSP_ADDRH = DSP_ADDRH; |
114 | status.payload.refill._DSP_ADDRL = DSP_ADDRL; | 118 | status.payload.refill._DSP_ADDRL = DSP_ADDRL; |
115 | 119 | ||
116 | /* Start the demac transfer */ | 120 | /* Start the demac transfer */ |
117 | DMA_TRG = 1; | 121 | DMA_TRG = 1; |
122 | } | ||
118 | } | 123 | } |
119 | 124 | ||
120 | /* This interupt handler is for the SARAM (on DSP) to McBSP IIS DMA transfer. | 125 | /* This interupt handler is for the SARAM (on DSP) to McBSP IIS DMA transfer. |
@@ -146,8 +151,7 @@ interrupt void handle_dma0(void) | |||
146 | * (dsp_level), the SDRAM buffer level (sdem_level) and to rebuffer if the dsp | 151 | * (dsp_level), the SDRAM buffer level (sdem_level) and to rebuffer if the dsp |
147 | * buffer is not full. | 152 | * buffer is not full. |
148 | */ | 153 | */ |
149 | interrupt void handle_dmac(void) { | 154 | interrupt void handle_dmac(void) { |
150 | unsigned long sdem_addr; | ||
151 | IFR = 1 << 11; | 155 | IFR = 1 << 11; |
152 | 156 | ||
153 | dsp_level+=last_size; | 157 | dsp_level+=last_size; |