Mercurial > sdl-ios-xcode
annotate src/audio/mint/SDL_mintaudio_xbios.c @ 962:176240cf4405
Forgot to disable debug messages
author | Patrice Mandin <patmandin@gmail.com> |
---|---|
date | Fri, 29 Oct 2004 11:19:03 +0000 |
parents | 185acc07127a |
children | f10892fa2e48 |
rev | line source |
---|---|
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
1 /* |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
769
b8d311d90021
Updated copyright information for 2004 (Happy New Year!)
Sam Lantinga <slouken@libsdl.org>
parents:
704
diff
changeset
|
3 Copyright (C) 1997-2004 Sam Lantinga |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
4 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Library General Public |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
8 version 2 of the License, or (at your option) any later version. |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
9 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
13 Library General Public License for more details. |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
14 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Library General Public |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
18 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
19 Sam Lantinga |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
20 slouken@libsdl.org |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
21 */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
22 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
23 /* |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
24 MiNT audio driver |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
25 using XBIOS functions (Falcon) |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
26 |
961
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
27 Patrice Mandin, Didier Méquignon |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
28 */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
29 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
30 #include <stdlib.h> |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
31 #include <stdio.h> |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
32 #include <string.h> |
961
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
33 #include <unistd.h> |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
34 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
35 /* Mint includes */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
36 #include <mint/osbind.h> |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
37 #include <mint/falcon.h> |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
38 #include <mint/cookie.h> |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
39 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
40 #include "SDL_endian.h" |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
41 #include "SDL_audio.h" |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
42 #include "SDL_audio_c.h" |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
43 #include "SDL_audiomem.h" |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
44 #include "SDL_sysaudio.h" |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
45 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
46 #include "SDL_atarimxalloc_c.h" |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
47 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
48 #include "SDL_mintaudio.h" |
961
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
49 #include "SDL_mintaudio_dma8.h" |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
50 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
51 /*--- Defines ---*/ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
52 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
53 #define MINT_AUDIO_DRIVER_NAME "mint_xbios" |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
54 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
55 /* Debug print info */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
56 #define DEBUG_NAME "audio:xbios: " |
962
176240cf4405
Forgot to disable debug messages
Patrice Mandin <patmandin@gmail.com>
parents:
961
diff
changeset
|
57 #if 0 |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
58 #define DEBUG_PRINT(what) \ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
59 { \ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
60 printf what; \ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
61 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
62 #else |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
63 #define DEBUG_PRINT(what) |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
64 #endif |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
65 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
66 /*--- Static variables ---*/ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
67 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
68 static unsigned long cookie_snd; |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
69 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
70 /*--- Audio driver functions ---*/ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
71 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
72 static void Mint_CloseAudio(_THIS); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
73 static int Mint_OpenAudio(_THIS, SDL_AudioSpec *spec); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
74 static void Mint_LockAudio(_THIS); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
75 static void Mint_UnlockAudio(_THIS); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
76 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
77 /* To check/init hardware audio */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
78 static int Mint_CheckAudio(_THIS, SDL_AudioSpec *spec); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
79 static void Mint_InitAudio(_THIS, SDL_AudioSpec *spec); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
80 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
81 /*--- Audio driver bootstrap functions ---*/ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
82 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
83 static int Audio_Available(void) |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
84 { |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
85 const char *envr = getenv("SDL_AUDIODRIVER"); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
86 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
87 /* Check if user asked a different audio driver */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
88 if ((envr) && (strcmp(envr, MINT_AUDIO_DRIVER_NAME)!=0)) { |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
89 DEBUG_PRINT((DEBUG_NAME "user asked a different audio driver\n")); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
90 return(0); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
91 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
92 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
93 /* Cookie _SND present ? if not, assume ST machine */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
94 if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) { |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
95 cookie_snd = SND_PSG; |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
96 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
97 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
98 /* Check if we have 16 bits audio */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
99 if ((cookie_snd & SND_16BIT)==0) { |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
100 DEBUG_PRINT((DEBUG_NAME "no 16 bits sound\n")); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
101 return(0); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
102 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
103 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
104 /* Check if audio is lockable */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
105 if (Locksnd()!=1) { |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
106 DEBUG_PRINT((DEBUG_NAME "audio locked by other application\n")); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
107 return(0); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
108 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
109 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
110 Unlocksnd(); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
111 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
112 DEBUG_PRINT((DEBUG_NAME "XBIOS audio available!\n")); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
113 return(1); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
114 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
115 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
116 static void Audio_DeleteDevice(SDL_AudioDevice *device) |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
117 { |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
118 free(device->hidden); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
119 free(device); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
120 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
121 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
122 static SDL_AudioDevice *Audio_CreateDevice(int devindex) |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
123 { |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
124 SDL_AudioDevice *this; |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
125 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
126 /* Initialize all variables that we clean on shutdown */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
127 this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
128 if ( this ) { |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
129 memset(this, 0, (sizeof *this)); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
130 this->hidden = (struct SDL_PrivateAudioData *) |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
131 malloc((sizeof *this->hidden)); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
132 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
133 if ( (this == NULL) || (this->hidden == NULL) ) { |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
134 SDL_OutOfMemory(); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
135 if ( this ) { |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
136 free(this); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
137 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
138 return(0); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
139 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
140 memset(this->hidden, 0, (sizeof *this->hidden)); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
141 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
142 /* Set the function pointers */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
143 this->OpenAudio = Mint_OpenAudio; |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
144 this->CloseAudio = Mint_CloseAudio; |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
145 this->LockAudio = Mint_LockAudio; |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
146 this->UnlockAudio = Mint_UnlockAudio; |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
147 this->free = Audio_DeleteDevice; |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
148 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
149 return this; |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
150 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
151 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
152 AudioBootStrap MINTAUDIO_XBIOS_bootstrap = { |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
153 MINT_AUDIO_DRIVER_NAME, "MiNT XBIOS audio driver", |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
154 Audio_Available, Audio_CreateDevice |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
155 }; |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
156 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
157 static void Mint_LockAudio(_THIS) |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
158 { |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
159 /* Stop replay */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
160 Buffoper(0); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
161 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
162 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
163 static void Mint_UnlockAudio(_THIS) |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
164 { |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
165 /* Restart replay */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
166 Buffoper(SB_PLA_ENA|SB_PLA_RPT); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
167 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
168 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
169 static void Mint_CloseAudio(_THIS) |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
170 { |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
171 /* Stop replay */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
172 Buffoper(0); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
173 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
174 /* Uninstall interrupt */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
175 Jdisint(MFP_DMASOUND); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
176 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
177 /* Wait if currently playing sound */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
178 while (SDL_MintAudio_mutex != 0) { |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
179 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
180 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
181 /* Clear buffers */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
182 if (SDL_MintAudio_audiobuf[0]) { |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
183 Mfree(SDL_MintAudio_audiobuf[0]); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
184 SDL_MintAudio_audiobuf[0] = SDL_MintAudio_audiobuf[1] = NULL; |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
185 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
186 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
187 /* Unlock sound system */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
188 Unlocksnd(); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
189 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
190 |
961
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
191 /* Falcon XBIOS implementation of Devconnect() is buggy with external clock */ |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
192 static void Devconnect2(int src, int dst, int sclk, int pre) |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
193 { |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
194 static const unsigned short MASK1[3] = { 0, 0x6000, 0 }; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
195 static const unsigned short MASK2[4] = { 0xFFF0, 0xFF8F, 0xF0FF, 0x0FFF }; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
196 static const unsigned short INDEX1[4] = { 1, 3, 5, 7 }; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
197 static const unsigned short INDEX2[4] = { 0, 2, 4, 6 }; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
198 unsigned short sync_div,dev_ctrl,dest_ctrl; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
199 void *oldstack; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
200 |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
201 if (dst==0) { |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
202 return; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
203 } |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
204 |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
205 oldstack=(void *)Super(0); |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
206 |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
207 dev_ctrl = DMAAUDIO_IO.dev_ctrl; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
208 dest_ctrl = DMAAUDIO_IO.dest_ctrl; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
209 dev_ctrl &= MASK2[src]; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
210 |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
211 if (src==ADC) { |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
212 dev_ctrl |= MASK1[sclk]; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
213 } else { |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
214 dev_ctrl |= (INDEX1[sclk] << (src<<4)); |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
215 } |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
216 |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
217 if (dst & DMAREC) { |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
218 dest_ctrl &= 0xFFF0; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
219 dest_ctrl |= INDEX1[src]; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
220 } |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
221 |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
222 if (dst & DSPRECV) { |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
223 dest_ctrl &= 0xFF8F; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
224 dest_ctrl |= (INDEX1[src]<<4); |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
225 } |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
226 |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
227 if (dst & EXTOUT) { |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
228 dest_ctrl &= 0xF0FF; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
229 dest_ctrl |= (INDEX1[src]<<8); |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
230 } |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
231 |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
232 if (dst & DAC) { |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
233 dev_ctrl &= 0x0FFF; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
234 dev_ctrl |= MASK1[sclk]; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
235 dest_ctrl &= 0x0FFF; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
236 dest_ctrl |= (INDEX2[src]<<12); |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
237 } |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
238 |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
239 sync_div = DMAAUDIO_IO.sync_div; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
240 if (sclk==CLKEXT) { |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
241 pre<<=8; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
242 sync_div &= 0xF0FF; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
243 } else { |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
244 sync_div &= 0xFFF0; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
245 } |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
246 sync_div |= pre; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
247 |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
248 DMAAUDIO_IO.dev_ctrl = dev_ctrl; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
249 DMAAUDIO_IO.dest_ctrl = dest_ctrl; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
250 DMAAUDIO_IO.sync_div = sync_div; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
251 |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
252 Super(oldstack); |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
253 } |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
254 |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
255 static Uint32 Mint_CheckExternalClock(void) |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
256 { |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
257 #define SIZE_BUF_CLOCK_MEASURE (44100/10) |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
258 |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
259 unsigned long cookie_snd; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
260 Uint32 masterclock; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
261 char *buffer; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
262 int i; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
263 |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
264 /* DSP present with its GPIO port ? */ |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
265 if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) { |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
266 return 0; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
267 } |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
268 if ((cookie_snd & SND_DSP)==0) { |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
269 return 0; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
270 } |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
271 |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
272 buffer = Atari_SysMalloc(SIZE_BUF_CLOCK_MEASURE, MX_STRAM); |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
273 if (buffer==NULL) { |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
274 DEBUG_PRINT((DEBUG_NAME "Not enough memory for the measure\n")); |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
275 return 0; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
276 } |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
277 memset(buffer, 0, SIZE_BUF_CLOCK_MEASURE); |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
278 |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
279 masterclock=0; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
280 |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
281 Buffoper(0); |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
282 Settracks(0,0); |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
283 Setmontracks(0); |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
284 Setmode(MONO8); |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
285 Jdisint(MFP_TIMERA); |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
286 |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
287 for (i=0; i<2; i++) { |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
288 Gpio(GPIO_SET,7); /* DSP port gpio outputs */ |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
289 Gpio(GPIO_WRITE,2+i); /* 22.5792/24.576 MHz for 44.1/48KHz */ |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
290 Devconnect2(DMAPLAY, DAC, CLKEXT, CLK50K); /* Matrix and clock source */ |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
291 Setbuffer(0, buffer, buffer + SIZE_BUF_CLOCK_MEASURE); /* Set buffer */ |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
292 Xbtimer(XB_TIMERA, 5, 38, SDL_MintAudio_XbiosInterruptMeasureClock); /* delay mode timer A, prediv /64, 1KHz */ |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
293 Jenabint(MFP_TIMERA); |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
294 SDL_MintAudio_clocktics = 0; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
295 Buffoper(SB_PLA_ENA); |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
296 usleep(110000); |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
297 |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
298 if((Buffoper(-1) & 1)==0) { |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
299 if (SDL_MintAudio_clocktics) { |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
300 unsigned long khz; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
301 |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
302 khz = ((SIZE_BUF_CLOCK_MEASURE/SDL_MintAudio_clocktics) +1) & 0xFFFFFFFE; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
303 DEBUG_PRINT((DEBUG_NAME "measure %d: freq=%lu KHz\n", i+1, khz)); |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
304 |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
305 if (i==0) { |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
306 if(khz==44) { |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
307 masterclock = MASTERCLOCK_44K; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
308 } |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
309 } else { |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
310 if(khz==48) { |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
311 masterclock = MASTERCLOCK_48K; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
312 } |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
313 } |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
314 } else { |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
315 DEBUG_PRINT((DEBUG_NAME "No measure\n")); |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
316 } |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
317 } else { |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
318 DEBUG_PRINT((DEBUG_NAME "No SDMA clock\n")); |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
319 } |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
320 |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
321 Buffoper(0); /* stop */ |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
322 Jdisint(MFP_TIMERA); /* Uninstall interrupt */ |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
323 if (masterclock == 0) |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
324 break; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
325 } |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
326 |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
327 Mfree(buffer); |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
328 return masterclock; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
329 } |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
330 |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
331 static int Mint_CheckAudio(_THIS, SDL_AudioSpec *spec) |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
332 { |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
333 int i; |
961
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
334 Uint32 extclock; |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
335 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
336 DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ",spec->format & 0x00ff)); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
337 DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000)!=0))); |
704 | 338 DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000)!=0))); |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
339 DEBUG_PRINT(("channels=%d, ", spec->channels)); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
340 DEBUG_PRINT(("freq=%d\n", spec->freq)); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
341 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
342 spec->format |= 0x8000; /* Audio is always signed */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
343 if ((spec->format & 0x00ff)==16) { |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
344 spec->format |= 0x1000; /* Audio is always big endian */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
345 spec->channels=2; /* 16 bits always stereo */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
346 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
347 |
961
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
348 extclock=Mint_CheckExternalClock(); |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
349 |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
350 /* Standard clocks */ |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
351 MINTAUDIO_freqcount=0; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
352 for (i=1;i<12;i++) { |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
353 /* Remove unusable Falcon codec predivisors */ |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
354 if ((i==6) || (i==8) || (i==10)) { |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
355 continue; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
356 } |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
357 SDL_MintAudio_AddFrequency(this, MASTERCLOCK_FALCON1/(MASTERPREDIV_FALCON*(i+1)), MASTERCLOCK_FALCON1, i); |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
358 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
359 |
961
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
360 if (extclock>0) { |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
361 for (i=1; i<4; i++) { |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
362 SDL_MintAudio_AddFrequency(this, extclock/(MASTERPREDIV_FALCON*(1<<i)), extclock, (1<<i)-1); |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
363 } |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
364 } |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
365 |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
366 #if 1 |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
367 for (i=0; i<MINTAUDIO_freqcount; i++) { |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
368 DEBUG_PRINT((DEBUG_NAME "freq %d: %lu Hz, clock %lu, prediv %d\n", |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
369 i, MINTAUDIO_frequencies[i].frequency, MINTAUDIO_frequencies[i].masterclock, |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
370 MINTAUDIO_frequencies[i].predivisor |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
371 )); |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
372 } |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
373 #endif |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
374 |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
375 MINTAUDIO_numfreq=SDL_MintAudio_SearchFrequency(this, spec->freq); |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
376 spec->freq=MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency; |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
377 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
378 DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ",spec->format & 0x00ff)); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
379 DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000)!=0))); |
704 | 380 DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000)!=0))); |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
381 DEBUG_PRINT(("channels=%d, ", spec->channels)); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
382 DEBUG_PRINT(("freq=%d\n", spec->freq)); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
383 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
384 return 0; |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
385 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
386 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
387 static void Mint_InitAudio(_THIS, SDL_AudioSpec *spec) |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
388 { |
961
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
389 int channels_mode, dmaclock, prediv; |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
390 void *buffer; |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
391 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
392 /* Stop currently playing sound */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
393 Buffoper(0); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
394 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
395 /* Set replay tracks */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
396 Settracks(0,0); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
397 Setmontracks(0); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
398 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
399 /* Select replay format */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
400 channels_mode=STEREO16; |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
401 switch (spec->format & 0xff) { |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
402 case 8: |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
403 if (spec->channels==2) { |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
404 channels_mode=STEREO8; |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
405 } else { |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
406 channels_mode=MONO8; |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
407 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
408 break; |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
409 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
410 if (Setmode(channels_mode)<0) { |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
411 DEBUG_PRINT((DEBUG_NAME "Setmode() failed\n")); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
412 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
413 |
961
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
414 dmaclock = MINTAUDIO_frequencies[MINTAUDIO_numfreq].masterclock; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
415 prediv = MINTAUDIO_frequencies[MINTAUDIO_numfreq].predivisor; |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
416 if (dmaclock != MASTERCLOCK_FALCON1) { |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
417 Gpio(GPIO_SET,7); /* DSP port gpio outputs */ |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
418 if (dmaclock == MASTERCLOCK_44K) { |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
419 Gpio(GPIO_WRITE,2); /* 22.5792 MHz for 44.1KHz */ |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
420 } else { |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
421 Gpio(GPIO_WRITE,3); /* 24.576 MHz for 48KHz */ |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
422 } |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
423 Devconnect2(DMAPLAY, DAC, CLKEXT, prediv); |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
424 } else { |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
425 Devconnect(DMAPLAY, DAC, CLK25M, prediv, 1); |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
426 } |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
427 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
428 /* Set buffer */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
429 buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf]; |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
430 if (Setbuffer(0, buffer, buffer + spec->size)<0) { |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
431 DEBUG_PRINT((DEBUG_NAME "Setbuffer() failed\n")); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
432 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
433 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
434 /* Install interrupt */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
435 Jdisint(MFP_DMASOUND); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
436 Xbtimer(XB_TIMERA, 8, 1, SDL_MintAudio_XbiosInterrupt); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
437 Jenabint(MFP_DMASOUND); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
438 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
439 if (Setinterrupt(SI_TIMERA, SI_PLAY)<0) { |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
440 DEBUG_PRINT((DEBUG_NAME "Setinterrupt() failed\n")); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
441 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
442 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
443 /* Go */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
444 Buffoper(SB_PLA_ENA|SB_PLA_RPT); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
445 DEBUG_PRINT((DEBUG_NAME "hardware initialized\n")); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
446 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
447 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
448 static int Mint_OpenAudio(_THIS, SDL_AudioSpec *spec) |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
449 { |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
450 /* Lock sound system */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
451 if (Locksnd()!=1) { |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
452 SDL_SetError("Mint_OpenAudio: Audio system already in use"); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
453 return(-1); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
454 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
455 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
456 SDL_MintAudio_device = this; |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
457 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
458 /* Check audio capabilities */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
459 if (Mint_CheckAudio(this, spec)==-1) { |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
460 return -1; |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
461 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
462 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
463 SDL_CalculateAudioSpec(spec); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
464 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
465 /* Allocate memory for audio buffers in DMA-able RAM */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
466 DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", spec->size)); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
467 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
468 SDL_MintAudio_audiobuf[0] = Atari_SysMalloc(spec->size *2, MX_STRAM); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
469 if (SDL_MintAudio_audiobuf[0]==NULL) { |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
470 SDL_SetError("MINT_OpenAudio: Not enough memory for audio buffer"); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
471 return (-1); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
472 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
473 SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + spec->size ; |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
474 SDL_MintAudio_numbuf=0; |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
475 memset(SDL_MintAudio_audiobuf[0], spec->silence, spec->size *2); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
476 SDL_MintAudio_audiosize = spec->size; |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
477 SDL_MintAudio_mutex = 0; |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
478 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
479 DEBUG_PRINT((DEBUG_NAME "buffer 0 at 0x%08x\n", SDL_MintAudio_audiobuf[0])); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
480 DEBUG_PRINT((DEBUG_NAME "buffer 1 at 0x%08x\n", SDL_MintAudio_audiobuf[1])); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
481 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
482 /* Setup audio hardware */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
483 Mint_InitAudio(this, spec); |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
484 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
485 return(1); /* We don't use threaded audio */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
486 } |