comparison src/audio/mint/SDL_mintaudio_dma8.c @ 961:185acc07127a

Date: Fri, 29 Oct 2004 11:47:09 +0200 From: Patrice Mandin Subject: Reworked audio drivers for Atari platform These are reworked audio drivers for the Atari platform. Previous drivers were missing some features: - Test external clock plugged to DSP port on Atari Falcon 030. - Ability to select internal or external clock. So now, I generate a list of frequencies available, with the master clock and predivisor to use. One big caveat to this: I do not have an external clock, so I hope it works.
author Patrice Mandin <patmandin@gmail.com>
date Fri, 29 Oct 2004 09:56:53 +0000
parents b8d311d90021
children 176240cf4405
comparison
equal deleted inserted replaced
960:eec28a5278be 961:185acc07127a
51 51
52 #define MINT_AUDIO_DRIVER_NAME "mint_dma8" 52 #define MINT_AUDIO_DRIVER_NAME "mint_dma8"
53 53
54 /* Debug print info */ 54 /* Debug print info */
55 #define DEBUG_NAME "audio:dma8: " 55 #define DEBUG_NAME "audio:dma8: "
56 #if 0 56 #if 1
57 #define DEBUG_PRINT(what) \ 57 #define DEBUG_PRINT(what) \
58 { \ 58 { \
59 printf what; \ 59 printf what; \
60 } 60 }
61 #else 61 #else
98 if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) { 98 if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) {
99 cookie_snd = SND_PSG; 99 cookie_snd = SND_PSG;
100 } 100 }
101 101
102 /* Check if we have 8 bits audio */ 102 /* Check if we have 8 bits audio */
103 /*
103 if ((cookie_snd & SND_8BIT)==0) { 104 if ((cookie_snd & SND_8BIT)==0) {
104 DEBUG_PRINT((DEBUG_NAME "no 8 bits sound\n")); 105 DEBUG_PRINT((DEBUG_NAME "no 8 bits sound\n"));
105 return(0); 106 return(0);
106 } 107 }
107 108 */
108 if ((cookie_mch>>16)>MCH_F30) { 109 if ((cookie_mch>>16)>MCH_F30) {
109 DEBUG_PRINT((DEBUG_NAME "unknown 8 bits audio chip\n")); 110 DEBUG_PRINT((DEBUG_NAME "unknown 8 bits audio chip\n"));
110 return 0; 111 return 0;
111 } 112 }
112 113
216 DEBUG_PRINT((DEBUG_NAME "closeaudio: buffers freed\n")); 217 DEBUG_PRINT((DEBUG_NAME "closeaudio: buffers freed\n"));
217 } 218 }
218 219
219 static int Mint_CheckAudio(_THIS, SDL_AudioSpec *spec) 220 static int Mint_CheckAudio(_THIS, SDL_AudioSpec *spec)
220 { 221 {
221 int i, masterprediv; 222 int i, masterprediv, sfreq;
222 unsigned long masterclock; 223 unsigned long masterclock;
223 224
224 DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ",spec->format & 0x00ff)); 225 DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ",spec->format & 0x00ff));
225 DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000)!=0))); 226 DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000)!=0)));
226 DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000)!=0))); 227 DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000)!=0)));
229 230
230 /* Check formats available */ 231 /* Check formats available */
231 spec->format = AUDIO_S8; 232 spec->format = AUDIO_S8;
232 233
233 /* Calculate and select the closest frequency */ 234 /* Calculate and select the closest frequency */
234 MINTAUDIO_nfreq=4; 235 sfreq=0;
235 MINTAUDIO_sfreq=0;
236 masterclock=MASTERCLOCK_STE; 236 masterclock=MASTERCLOCK_STE;
237 masterprediv=MASTERPREDIV_STE; 237 masterprediv=MASTERPREDIV_STE;
238 switch(cookie_mch>>16) { 238 switch(cookie_mch>>16) {
239 /* 239 /*
240 case MCH_STE: 240 case MCH_STE:
246 masterclock=MASTERCLOCK_TT; 246 masterclock=MASTERCLOCK_TT;
247 masterprediv=MASTERPREDIV_TT; 247 masterprediv=MASTERPREDIV_TT;
248 break; 248 break;
249 case MCH_F30: 249 case MCH_F30:
250 masterclock=MASTERCLOCK_FALCON1; 250 masterclock=MASTERCLOCK_FALCON1;
251 masterprediv=MASTERPREDIV_FALCON<<1; 251 masterprediv=MASTERPREDIV_FALCON;
252 MINTAUDIO_nfreq=3; 252 sfreq=1;
253 MINTAUDIO_sfreq=1;
254 break; 253 break;
255 } 254 }
256 for (i=MINTAUDIO_sfreq;i<MINTAUDIO_nfreq;i++) { 255
257 MINTAUDIO_hardfreq[i]=masterclock/(masterprediv*(1<<i)); 256 MINTAUDIO_freqcount=0;
258 DEBUG_PRINT((DEBUG_NAME "calc:freq(%d)=%lu\n", i, MINTAUDIO_hardfreq[i])); 257 for (i=sfreq;i<4;i++) {
259 } 258 SDL_MintAudio_AddFrequency(this, masterclock/(masterprediv*(1<<i)), masterclock, i-sfreq);
260 259 }
261 MINTAUDIO_numfreq=SDL_MintAudio_SearchFrequency(this, 0, spec->freq); 260
262 spec->freq=MINTAUDIO_hardfreq[MINTAUDIO_numfreq]; 261 #if 1
262 for (i=0; i<MINTAUDIO_freqcount; i++) {
263 DEBUG_PRINT((DEBUG_NAME "freq %d: %lu Hz, clock %lu, prediv %d\n",
264 i, MINTAUDIO_frequencies[i].frequency, MINTAUDIO_frequencies[i].masterclock,
265 MINTAUDIO_frequencies[i].predivisor
266 ));
267 }
268 #endif
269
270 MINTAUDIO_numfreq=SDL_MintAudio_SearchFrequency(this, spec->freq);
271 spec->freq=MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency;
263 272
264 DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ",spec->format & 0x00ff)); 273 DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ",spec->format & 0x00ff));
265 DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000)!=0))); 274 DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000)!=0)));
266 DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000)!=0))); 275 DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000)!=0)));
267 DEBUG_PRINT(("channels=%d, ", spec->channels)); 276 DEBUG_PRINT(("channels=%d, ", spec->channels));
296 buffer += SDL_MintAudio_audiosize; 305 buffer += SDL_MintAudio_audiosize;
297 DMAAUDIO_IO.end_high = (buffer>>16) & 255; 306 DMAAUDIO_IO.end_high = (buffer>>16) & 255;
298 DMAAUDIO_IO.end_mid = (buffer>>8) & 255; 307 DMAAUDIO_IO.end_mid = (buffer>>8) & 255;
299 DMAAUDIO_IO.end_low = buffer & 255; 308 DMAAUDIO_IO.end_low = buffer & 255;
300 309
301 mode = 3-MINTAUDIO_numfreq; 310 mode = 3-MINTAUDIO_frequencies[MINTAUDIO_numfreq].predivisor;
302 if (spec->channels==1) { 311 if (spec->channels==1) {
303 mode |= 1<<7; 312 mode |= 1<<7;
304 } 313 }
305 DMAAUDIO_IO.mode = mode; 314 DMAAUDIO_IO.sound_ctrl = mode;
306 315
307 /* Set interrupt */ 316 /* Set interrupt */
308 Jdisint(MFP_DMASOUND); 317 Jdisint(MFP_DMASOUND);
309 Xbtimer(XB_TIMERA, 8, 1, SDL_MintAudio_Dma8Interrupt); 318 Xbtimer(XB_TIMERA, 8, 1, SDL_MintAudio_Dma8Interrupt);
310 Jenabint(MFP_DMASOUND); 319 Jenabint(MFP_DMASOUND);