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