1 | /* $Id: ossidc.cpp,v 1.4 2003/08/08 15:09:03 vladest Exp $ */
|
---|
2 | /*
|
---|
3 | * OS/2 IDC services (callback to 16 bits MMPM2 driver)
|
---|
4 | *
|
---|
5 | * (C) 2000-2002 InnoTek Systemberatung GmbH
|
---|
6 | * (C) 2000-2001 Sander van Leeuwen (sandervl@xs4all.nl)
|
---|
7 | *
|
---|
8 | * This program is free software; you can redistribute it and/or
|
---|
9 | * modify it under the terms of the GNU General Public License as
|
---|
10 | * published by the Free Software Foundation; either version 2 of
|
---|
11 | * the License, or (at your option) any later version.
|
---|
12 | *
|
---|
13 | * This program is distributed in the hope that it will be useful,
|
---|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
16 | * GNU General Public License for more details.
|
---|
17 | *
|
---|
18 | * You should have received a copy of the GNU General Public
|
---|
19 | * License along with this program; if not, write to the Free
|
---|
20 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
|
---|
21 | * USA.
|
---|
22 | *
|
---|
23 | */
|
---|
24 |
|
---|
25 | #define INCL_NOPMAPI
|
---|
26 | #define INCL_DOSERRORS // for ERROR_INVALID_FUNCTION
|
---|
27 | #include <os2.h>
|
---|
28 | #include <ossdefos2.h>
|
---|
29 | #include <ossidc32.h>
|
---|
30 | #include <dbgos2.h>
|
---|
31 | #include <devhelp.h>
|
---|
32 | #include <unicard.h>
|
---|
33 | #include <version.h>
|
---|
34 | #ifdef KEE
|
---|
35 | #include <kee.h>
|
---|
36 | #endif
|
---|
37 | #include "initcall.h"
|
---|
38 |
|
---|
39 | extern DWORD TimerHandler16; //drv32\strategy.asm
|
---|
40 | extern int OSS32_ProcessMIDIIRQ(int bytes);
|
---|
41 | extern int OSS32_CloseUNI16(void);
|
---|
42 |
|
---|
43 | //******************************************************************************
|
---|
44 | //******************************************************************************
|
---|
45 | BOOL CallOSS16(ULONG cmd, ULONG param1, ULONG param2)
|
---|
46 | {
|
---|
47 | BOOL rc;
|
---|
48 |
|
---|
49 | if(idc16_PddHandler == 0) {
|
---|
50 | return FALSE;
|
---|
51 | }
|
---|
52 |
|
---|
53 | rc = CallPDD16(idc16_PddHandler, cmd, param1, param2);
|
---|
54 | return rc;
|
---|
55 | }
|
---|
56 | //******************************************************************************
|
---|
57 | exitcall_t fnCardExitCall[OSS32_MAX_AUDIOCARDS] = {0};
|
---|
58 |
|
---|
59 | /* this table should be discarded after init time */
|
---|
60 |
|
---|
61 | typedef struct cardcalls_t {
|
---|
62 | int card_id;
|
---|
63 | initcall_t *cinitcall;
|
---|
64 | exitcall_t *cexitcall;
|
---|
65 | }cardcalls_t;
|
---|
66 |
|
---|
67 | cardcalls_t cardcalls[CARDS_NUM] = {
|
---|
68 | { CARD_ICH, &name_module_init(intel8x0_driver_init), &name_module_exit(intel8x0_driver_exit) },
|
---|
69 | { CARD_VIA82XX, &name_module_init(via82xx_driver_init), &name_module_exit(via82xx_driver_exit) },
|
---|
70 | { CARD_SBLIVE, &name_module_init(emu10k1_driver_init), &name_module_exit(emu10k1_driver_exit) },
|
---|
71 | { CARD_CMEDIA, &name_module_init(cmipci_driver_init), &name_module_exit(cmipci_driver_exit) },
|
---|
72 | { CARD_ALS4000, &name_module_init(als4000_driver_init), &name_module_exit(als4000_driver_exit) },
|
---|
73 | { CARD_CS4281, &name_module_init(cs4281_driver_init), &name_module_exit(cs4281_driver_exit) },
|
---|
74 | { CARD_CS46XX, &name_module_init(cs46xx_driver_init), &name_module_exit(cs46xx_driver_exit) },
|
---|
75 | { CARD_CS5535, &name_module_init(cs5535audio_driver_init), &name_module_exit(cs5535audio_driver_exit) },
|
---|
76 | { CARD_ESS1938, &name_module_init(es1938_driver_init), &name_module_exit(es1938_driver_exit) },
|
---|
77 | { CARD_ENSONIQ0, &name_module_init(ens137x_driver_init), &name_module_exit(ens137x_driver_exit) },
|
---|
78 | { CARD_ENSONIQ1, NULL, NULL },
|
---|
79 | { CARD_YAMAHA, &name_module_init(ymfpci_driver_init), &name_module_exit(ymfpci_driver_exit) },
|
---|
80 | { CARD_MAESTRO, &name_module_init(es1968_driver_init), &name_module_exit(es1968_driver_exit) },
|
---|
81 | { CARD_MAESTRO3, &name_module_init(m3_driver_init), &name_module_exit(m3_driver_exit) },
|
---|
82 | { CARD_ALI5451, &name_module_init(ali5451_driver_init), &name_module_exit(ali5451_driver_exit) },
|
---|
83 | { CARD_TRIDENT, &name_module_init(trident_driver_init), &name_module_exit(trident_driver_exit) },
|
---|
84 | #ifdef VORTEX
|
---|
85 | { CARD_VORTEX, &name_module_init(vortex_driver_init), &name_module_exit(vortex_driver_exit) },
|
---|
86 | #else
|
---|
87 | { CARD_VORTEX, NULL, NULL },
|
---|
88 | #endif
|
---|
89 | { CARD_NEOMAGIC, &name_module_init(nm256_driver_init), &name_module_exit(nm256_driver_exit) },
|
---|
90 | { CARD_FM801, &name_module_init(fm801_driver_init), &name_module_exit(fm801_driver_exit) },
|
---|
91 | { CARD_ATIIXP, &name_module_init(atiixp_driver_init), &name_module_exit(atiixp_driver_exit) },
|
---|
92 | { CARD_AUDIGYLS, &name_module_init(ca0106_driver_init), &name_module_exit(ca0106_driver_exit) },
|
---|
93 | { CARD_AZX, &name_module_init(azx_driver_init), &name_module_exit(azx_driver_exit) },
|
---|
94 | { CARD_BT87X, &name_module_init(alsa_card_bt87x_init), &name_module_exit(alsa_card_bt87x_exit) },
|
---|
95 | };
|
---|
96 |
|
---|
97 | int nrCardsDetected = 0;
|
---|
98 | int fStrategyInit = FALSE;
|
---|
99 | void pcm_info(void);
|
---|
100 | void FillCaps(ULONG deviceid);
|
---|
101 |
|
---|
102 | //******************************************************************************
|
---|
103 | // This routine should be discarded after init time
|
---|
104 | OSSRET OSS32_Initialize(void)
|
---|
105 | {
|
---|
106 | short sI, iTmp;
|
---|
107 |
|
---|
108 | fStrategyInit = TRUE;
|
---|
109 |
|
---|
110 | if(DevSetTimer(TimerHandler16) != 0) {
|
---|
111 | rprintf(("DevSetTimer failed!!"));
|
---|
112 | DebugInt3();
|
---|
113 | return OSSERR_INIT_FAILED;
|
---|
114 | }
|
---|
115 | dprintf(("OSS32_Initialize: Start address: %X", OffsetBeginCS32));
|
---|
116 |
|
---|
117 | if(call_module_init(alsa_sound_init) != 0) return OSSERR_INIT_FAILED;
|
---|
118 | if(call_module_init(alsa_seq_device_init) != 0) return OSSERR_INIT_FAILED;
|
---|
119 | dprintf(("OSS32_Initialize1: Start address: %X", OffsetBeginCS32));
|
---|
120 | if(call_module_init(alsa_pcm_init) != 0) return OSSERR_INIT_FAILED;
|
---|
121 | if(call_module_init(alsa_hwdep_init) != 0) return OSSERR_INIT_FAILED;
|
---|
122 | if(call_module_init(alsa_timer_init) != 0) return OSSERR_INIT_FAILED;
|
---|
123 |
|
---|
124 | if(call_module_init(alsa_rawmidi_init) != 0) return OSSERR_INIT_FAILED;
|
---|
125 | if(call_module_init(alsa_seq_init) != 0) return OSSERR_INIT_FAILED;
|
---|
126 | // if(call_module_init(alsa_opl3_init) != 0) return OSSERR_INIT_FAILED;
|
---|
127 | // if(call_module_init(alsa_mpu401_uart_init) != 0) return OSSERR_INIT_FAILED;
|
---|
128 | call_module_init(opl3_seq_driver_init);
|
---|
129 | // call_module_init(ac97_bus_init);
|
---|
130 | call_module_init(regmap_initcall);
|
---|
131 | #if 1
|
---|
132 | /* Init functions for HDA audio */
|
---|
133 | call_module_init(hda_bus_init);
|
---|
134 | call_module_init(generic_driver_init);
|
---|
135 | call_module_init(analog_driver_init);
|
---|
136 | call_module_init(ca0110_driver_init);
|
---|
137 | call_module_init(cirrus_driver_init);
|
---|
138 | call_module_init(cmedia_driver_init);
|
---|
139 | call_module_init(conexant_driver_init);
|
---|
140 | // call_module_init(hdmi_driver_init);
|
---|
141 | call_module_init(realtek_driver_init);
|
---|
142 | call_module_init(sigmatel_driver_init);
|
---|
143 | call_module_init(via_driver_init);
|
---|
144 | #endif
|
---|
145 | //dprintf(("OSS32_Initialize: ForceCard=%d", ForceCard));
|
---|
146 |
|
---|
147 | for (sI=0; sI<CARDS_NUM; sI++) {
|
---|
148 | //if ((ForceCard != CARD_NONE) && (ForceCard != cardcalls[sI].card_id)) continue;
|
---|
149 | //dprintf(("calling: %x at %x", cardcalls[sI].card_id, cardcalls[sI].cinitcall));
|
---|
150 | if (cardcalls[sI].cinitcall == NULL) continue;
|
---|
151 | if (*cardcalls[sI].cinitcall == NULL) continue;
|
---|
152 | iTmp = (*cardcalls[sI].cinitcall)();
|
---|
153 | if (iTmp <= 0) continue;
|
---|
154 | while (iTmp) {
|
---|
155 | fnCardExitCall[nrCardsDetected++] = *cardcalls[sI].cexitcall;
|
---|
156 | iTmp--;
|
---|
157 | if (nrCardsDetected >= OSS32_MAX_AUDIOCARDS) break;
|
---|
158 | }
|
---|
159 | if (nrCardsDetected >= OSS32_MAX_AUDIOCARDS) break;
|
---|
160 | }
|
---|
161 |
|
---|
162 | fStrategyInit = FALSE;
|
---|
163 |
|
---|
164 | if(nrCardsDetected != 0) {
|
---|
165 | pcm_info();
|
---|
166 | for(int i=0;i<nrCardsDetected;i++) {
|
---|
167 | FillCaps(i);
|
---|
168 | }
|
---|
169 | rprintf(("OSS32_Initialize: SUCCESS. Cards=%d", nrCardsDetected));
|
---|
170 | return OSSERR_SUCCESS;
|
---|
171 | }
|
---|
172 | rprintf(("OSS32_Initialize: FAILED"));
|
---|
173 | return OSSERR_INIT_FAILED;
|
---|
174 | }
|
---|
175 | //******************************************************************************
|
---|
176 | //Called during OS/2 shutdown
|
---|
177 | //******************************************************************************
|
---|
178 | OSSRET OSS32_Shutdown(void)
|
---|
179 | {
|
---|
180 | CallOSS16(IDC16_EXIT, 0, 0);
|
---|
181 |
|
---|
182 | for(int i=0;i<nrCardsDetected;i++) {
|
---|
183 | if(fnCardExitCall[i]) fnCardExitCall[i]();
|
---|
184 | }
|
---|
185 |
|
---|
186 | // call_module_exit(alsa_mpu401_uart_exit);
|
---|
187 | call_module_exit(opl3_seq_driver_exit);
|
---|
188 | // call_module_exit(alsa_opl3_exit);
|
---|
189 | call_module_exit(alsa_seq_exit);
|
---|
190 | call_module_exit(alsa_rawmidi_exit);
|
---|
191 | call_module_exit(alsa_timer_exit);
|
---|
192 | call_module_exit(alsa_hwdep_exit);
|
---|
193 | call_module_exit(alsa_pcm_exit);
|
---|
194 | call_module_exit(alsa_sound_exit);
|
---|
195 |
|
---|
196 | return OSSERR_SUCCESS;
|
---|
197 | }
|
---|
198 |
|
---|
199 | //******************************************************************************
|
---|
200 | int OSS32_ProcessIRQ(void)
|
---|
201 | {
|
---|
202 | return CallOSS16(IDC16_PROCESS, 0, 0);
|
---|
203 | }
|
---|
204 |
|
---|
205 | int OSS32_ProcessMIDIIRQ(int bytes)
|
---|
206 | {
|
---|
207 | return CallOSS16(IDC16_MIDI_IRQ, bytes, 0);
|
---|
208 | }
|
---|
209 |
|
---|
210 | int OSS32_CloseUNI16(void)
|
---|
211 | {
|
---|
212 | return CallOSS16(IDC16_CLOSE_UNI16, 0, 0);
|
---|
213 | }
|
---|
214 |
|
---|
215 | //******************************************************************************
|
---|
216 | int MyDevBlock(ULONG id, ULONG tout, char flag)
|
---|
217 | {
|
---|
218 | return DevBlock(id,tout, flag);
|
---|
219 | }
|
---|
220 |
|
---|
221 | int OSS32_DebugString(char *buffer, ULONG size)
|
---|
222 | {
|
---|
223 | rprintf(("U16: %s", buffer));
|
---|
224 | return size;
|
---|
225 | }
|
---|