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 "C" DWORD TimerHandler16; //drv32\strategy.asm
|
---|
40 | extern "C" int OSS32_ProcessMIDIIRQ(int bytes);
|
---|
41 | extern "C" 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 | extern "C" {
|
---|
59 |
|
---|
60 | /* this table should be discarded after init time */
|
---|
61 |
|
---|
62 | typedef struct cardcalls_t {
|
---|
63 | int card_id;
|
---|
64 | initcall_t *cinitcall;
|
---|
65 | exitcall_t *cexitcall;
|
---|
66 | }cardcalls_t;
|
---|
67 |
|
---|
68 | cardcalls_t cardcalls[CARDS_NUM] = {
|
---|
69 | { CARD_ICH, &name_module_init(alsa_card_intel8x0_init), &name_module_exit(alsa_card_intel8x0_exit) },
|
---|
70 | { CARD_VIA82XX, &name_module_init(alsa_card_via82xx_init), &name_module_exit(alsa_card_via82xx_exit) },
|
---|
71 | { CARD_SBLIVE, &name_module_init(alsa_card_emu10k1_init), &name_module_exit(alsa_card_emu10k1_exit) },
|
---|
72 | { CARD_CMEDIA, &name_module_init(alsa_card_cmipci_init), &name_module_exit(alsa_card_cmipci_exit) },
|
---|
73 | { CARD_ALS4000, &name_module_init(alsa_card_als4000_init), &name_module_exit(alsa_card_als4000_exit) },
|
---|
74 | { CARD_CS4281, &name_module_init(alsa_card_cs4281_init), &name_module_exit(alsa_card_cs4281_exit) },
|
---|
75 | { CARD_CS46XX, &name_module_init(alsa_card_cs46xx_init), &name_module_exit(alsa_card_cs46xx_exit) },
|
---|
76 | { CARD_CS5535, &name_module_init(alsa_card_cs5535audio_init), &name_module_exit(alsa_card_cs5535audio_exit) },
|
---|
77 | { CARD_ESS1938, &name_module_init(alsa_card_es1938_init), &name_module_exit(alsa_card_es1938_exit) },
|
---|
78 | { CARD_ENSONIQ, &name_module_init(alsa_card_ens137x_init), &name_module_exit(alsa_card_ens137x_exit) },
|
---|
79 | { CARD_YAMAHA, &name_module_init(alsa_card_ymfpci_init), &name_module_exit(alsa_card_ymfpci_exit) },
|
---|
80 | { CARD_MAESTRO, &name_module_init(alsa_card_es1968_init), &name_module_exit(alsa_card_es1968_exit) },
|
---|
81 | { CARD_MAESTRO3, &name_module_init(alsa_card_m3_init), &name_module_exit(alsa_card_m3_exit) },
|
---|
82 | { CARD_ALI5451, &name_module_init(alsa_card_ali_init), &name_module_exit(alsa_card_ali_exit) },
|
---|
83 | { CARD_TRIDENT, &name_module_init(alsa_card_trident_init), &name_module_exit(alsa_card_trident_exit) },
|
---|
84 | #ifdef VORTEX
|
---|
85 | { CARD_VORTEX, &name_module_init(alsa_card_vortex_init), &name_module_exit(alsa_card_vortex_exit) },
|
---|
86 | #else
|
---|
87 | { CARD_VORTEX, NULL, NULL },
|
---|
88 | #endif
|
---|
89 | { CARD_NEOMAGIC, &name_module_init(alsa_card_nm256_init), &name_module_exit(alsa_card_nm256_exit) },
|
---|
90 | { CARD_FM801, &name_module_init(alsa_card_fm801_init), &name_module_exit(alsa_card_fm801_exit) },
|
---|
91 | { CARD_ATIIXP, &name_module_init(alsa_card_atiixp_init), &name_module_exit(alsa_card_atiixp_exit) },
|
---|
92 | { CARD_AUDIGYLS, &name_module_init(alsa_card_ca0106_init), &name_module_exit(alsa_card_ca0106_exit) },
|
---|
93 | { CARD_AZX, &name_module_init(alsa_card_azx_init), &name_module_exit(alsa_card_azx_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 | dprintf(("OSS32_Initialize1: Start address: %X", OffsetBeginCS32));
|
---|
119 | if(call_module_init(alsa_pcm_init) != 0) return OSSERR_INIT_FAILED;
|
---|
120 | if(call_module_init(alsa_hwdep_init) != 0) return OSSERR_INIT_FAILED;
|
---|
121 | if(call_module_init(alsa_timer_init) != 0) return OSSERR_INIT_FAILED;
|
---|
122 |
|
---|
123 | if(call_module_init(alsa_rawmidi_init) != 0) return OSSERR_INIT_FAILED;
|
---|
124 | if(call_module_init(alsa_seq_init) != 0) return OSSERR_INIT_FAILED;
|
---|
125 | if(call_module_init(alsa_opl3_init) != 0) return OSSERR_INIT_FAILED;
|
---|
126 | if(call_module_init(alsa_opl3_seq_init) != 0) return OSSERR_INIT_FAILED;
|
---|
127 |
|
---|
128 | if(call_module_init(alsa_mpu401_uart_init) != 0) return OSSERR_INIT_FAILED;
|
---|
129 |
|
---|
130 | /* Init functions for HDA audio */
|
---|
131 | call_module_init(patch_analog_init);
|
---|
132 | /* call_module_init(patch_hdmi_init);*/
|
---|
133 | call_module_init(patch_cmedia_init);
|
---|
134 | call_module_init(patch_conexant_init);
|
---|
135 | call_module_init(patch_realtek_init);
|
---|
136 | call_module_init(patch_sigmatel_init);
|
---|
137 | call_module_init(patch_via_init);
|
---|
138 |
|
---|
139 | dprintf(("OSS32_Initialize: ForceCard=%d", ForceCard));
|
---|
140 |
|
---|
141 | for (sI=0; sI<CARDS_NUM; sI++) {
|
---|
142 | if ((ForceCard != CARD_NONE) && (ForceCard != cardcalls[sI].card_id)) continue;
|
---|
143 | //dprintf(("calling: %x at %x", cardcalls[sI].card_id, cardcalls[sI].cinitcall));
|
---|
144 | if (cardcalls[sI].cinitcall == NULL) continue;
|
---|
145 | if (*cardcalls[sI].cinitcall == NULL) continue;
|
---|
146 | iTmp = (*cardcalls[sI].cinitcall)();
|
---|
147 | if (iTmp <= 0) continue;
|
---|
148 | while (iTmp) {
|
---|
149 | fnCardExitCall[nrCardsDetected++] = *cardcalls[sI].cexitcall;
|
---|
150 | iTmp--;
|
---|
151 | if (nrCardsDetected >= OSS32_MAX_AUDIOCARDS) break;
|
---|
152 | }
|
---|
153 | if (nrCardsDetected >= OSS32_MAX_AUDIOCARDS) break;
|
---|
154 | }
|
---|
155 |
|
---|
156 | fStrategyInit = FALSE;
|
---|
157 |
|
---|
158 | if(nrCardsDetected != 0) {
|
---|
159 | pcm_info();
|
---|
160 | for(int i=0;i<nrCardsDetected;i++) {
|
---|
161 | FillCaps(i);
|
---|
162 | }
|
---|
163 | rprintf(("OSS32_Initialize: SUCCESS. Cards=%d", nrCardsDetected));
|
---|
164 | return OSSERR_SUCCESS;
|
---|
165 | }
|
---|
166 | rprintf(("OSS32_Initialize: FAILED"));
|
---|
167 | return OSSERR_INIT_FAILED;
|
---|
168 | }
|
---|
169 | //******************************************************************************
|
---|
170 | //Called during OS/2 shutdown
|
---|
171 | //******************************************************************************
|
---|
172 | OSSRET OSS32_Shutdown()
|
---|
173 | {
|
---|
174 | CallOSS16(IDC16_EXIT, 0, 0);
|
---|
175 |
|
---|
176 | for(int i=0;i<nrCardsDetected;i++) {
|
---|
177 | if(fnCardExitCall[i]) fnCardExitCall[i]();
|
---|
178 | }
|
---|
179 |
|
---|
180 | call_module_exit(alsa_mpu401_uart_exit);
|
---|
181 | call_module_exit(alsa_opl3_seq_exit);
|
---|
182 | call_module_exit(alsa_opl3_exit);
|
---|
183 | call_module_exit(alsa_seq_exit);
|
---|
184 | call_module_exit(alsa_rawmidi_exit);
|
---|
185 | call_module_exit(alsa_timer_exit);
|
---|
186 | call_module_exit(alsa_hwdep_exit);
|
---|
187 | call_module_exit(alsa_pcm_exit);
|
---|
188 | call_module_exit(alsa_sound_exit);
|
---|
189 |
|
---|
190 | return OSSERR_SUCCESS;
|
---|
191 | }
|
---|
192 | //******************************************************************************
|
---|
193 | //******************************************************************************
|
---|
194 | int OSS32_ProcessIRQ()
|
---|
195 | {
|
---|
196 | return CallOSS16(IDC16_PROCESS, 0, 0);
|
---|
197 | }
|
---|
198 |
|
---|
199 | int OSS32_ProcessMIDIIRQ(int bytes)
|
---|
200 | {
|
---|
201 | return CallOSS16(IDC16_MIDI_IRQ, bytes, 0);
|
---|
202 | }
|
---|
203 |
|
---|
204 | int OSS32_CloseUNI16(void)
|
---|
205 | {
|
---|
206 | return CallOSS16(IDC16_CLOSE_UNI16, 0, 0);
|
---|
207 | }
|
---|
208 | //******************************************************************************
|
---|
209 | //******************************************************************************
|
---|
210 | int MyDevBlock(ULONG id, ULONG tout, char flag)
|
---|
211 | {
|
---|
212 | return DevBlock(id,tout, flag);
|
---|
213 | }
|
---|
214 |
|
---|
215 | int OSS32_DebugString(char *buffer, ULONG size)
|
---|
216 | {
|
---|
217 | rprintf(("U16: %s", buffer));
|
---|
218 | return size;
|
---|
219 | }
|
---|