[587] | 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 | #include "initcall.h"
|
---|
[675] | 35 | #include <u32ioctl.h>
|
---|
[587] | 36 |
|
---|
| 37 | extern DWORD TimerHandler16; //drv32\strategy.asm
|
---|
| 38 | extern int OSS32_ProcessMIDIIRQ(int bytes);
|
---|
| 39 | extern int OSS32_CloseUNI16(void);
|
---|
| 40 |
|
---|
| 41 | //******************************************************************************
|
---|
| 42 | //******************************************************************************
|
---|
| 43 | BOOL CallOSS16(ULONG cmd, ULONG param1, ULONG param2)
|
---|
| 44 | {
|
---|
| 45 | BOOL rc;
|
---|
| 46 |
|
---|
| 47 | if(idc16_PddHandler == 0) {
|
---|
| 48 | return FALSE;
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | rc = CallPDD16(idc16_PddHandler, cmd, param1, param2);
|
---|
| 52 | return rc;
|
---|
| 53 | }
|
---|
| 54 | //******************************************************************************
|
---|
| 55 | exitcall_t fnCardExitCall[OSS32_MAX_AUDIOCARDS] = {0};
|
---|
| 56 |
|
---|
| 57 | /* this table should be discarded after init time */
|
---|
| 58 |
|
---|
| 59 | typedef struct cardcalls_t {
|
---|
| 60 | int card_id;
|
---|
| 61 | initcall_t *cinitcall;
|
---|
| 62 | exitcall_t *cexitcall;
|
---|
| 63 | }cardcalls_t;
|
---|
| 64 |
|
---|
| 65 | cardcalls_t cardcalls[CARDS_NUM] = {
|
---|
[731] | 66 | { CARD_AZX, &name_module_init(azx_driver_init), &name_module_exit(azx_driver_exit) },
|
---|
[657] | 67 | { CARD_ICH, &name_module_init(intel8x0_driver_init), &name_module_exit(intel8x0_driver_exit) },
|
---|
| 68 | { CARD_VIA82XX, &name_module_init(via82xx_driver_init), &name_module_exit(via82xx_driver_exit) },
|
---|
| 69 | { CARD_SBLIVE, &name_module_init(emu10k1_driver_init), &name_module_exit(emu10k1_driver_exit) },
|
---|
[615] | 70 | { CARD_CMEDIA, &name_module_init(cmipci_driver_init), &name_module_exit(cmipci_driver_exit) },
|
---|
[657] | 71 | { CARD_ALS4000, &name_module_init(als4000_driver_init), &name_module_exit(als4000_driver_exit) },
|
---|
[615] | 72 | { CARD_CS4281, &name_module_init(cs4281_driver_init), &name_module_exit(cs4281_driver_exit) },
|
---|
| 73 | { CARD_CS46XX, &name_module_init(cs46xx_driver_init), &name_module_exit(cs46xx_driver_exit) },
|
---|
| 74 | { CARD_CS5535, &name_module_init(cs5535audio_driver_init), &name_module_exit(cs5535audio_driver_exit) },
|
---|
| 75 | { CARD_ESS1938, &name_module_init(es1938_driver_init), &name_module_exit(es1938_driver_exit) },
|
---|
[657] | 76 | { CARD_ENSONIQ0, &name_module_init(ens137x_driver_init), &name_module_exit(ens137x_driver_exit) },
|
---|
| 77 | { CARD_ENSONIQ1, NULL, NULL },
|
---|
[615] | 78 | { CARD_YAMAHA, &name_module_init(ymfpci_driver_init), &name_module_exit(ymfpci_driver_exit) },
|
---|
| 79 | { CARD_MAESTRO, &name_module_init(es1968_driver_init), &name_module_exit(es1968_driver_exit) },
|
---|
[657] | 80 | { CARD_MAESTRO3, &name_module_init(m3_driver_init), &name_module_exit(m3_driver_exit) },
|
---|
| 81 | { CARD_ALI5451, &name_module_init(ali5451_driver_init), &name_module_exit(ali5451_driver_exit) },
|
---|
| 82 | { CARD_TRIDENT, &name_module_init(trident_driver_init), &name_module_exit(trident_driver_exit) },
|
---|
[587] | 83 | #ifdef VORTEX
|
---|
[615] | 84 | { CARD_VORTEX, &name_module_init(vortex_driver_init), &name_module_exit(vortex_driver_exit) },
|
---|
[587] | 85 | #else
|
---|
[657] | 86 | { CARD_VORTEX, NULL, NULL },
|
---|
[587] | 87 | #endif
|
---|
[657] | 88 | { CARD_NEOMAGIC, &name_module_init(nm256_driver_init), &name_module_exit(nm256_driver_exit) },
|
---|
| 89 | { CARD_FM801, &name_module_init(fm801_driver_init), &name_module_exit(fm801_driver_exit) },
|
---|
[615] | 90 | { CARD_ATIIXP, &name_module_init(atiixp_driver_init), &name_module_exit(atiixp_driver_exit) },
|
---|
| 91 | { CARD_AUDIGYLS, &name_module_init(ca0106_driver_init), &name_module_exit(ca0106_driver_exit) },
|
---|
[657] | 92 | { CARD_BT87X, &name_module_init(alsa_card_bt87x_init), &name_module_exit(alsa_card_bt87x_exit) },
|
---|
[587] | 93 | };
|
---|
| 94 |
|
---|
| 95 | int nrCardsDetected = 0;
|
---|
| 96 | int fStrategyInit = FALSE;
|
---|
| 97 | void pcm_info(void);
|
---|
| 98 |
|
---|
| 99 | //******************************************************************************
|
---|
| 100 | // This routine should be discarded after init time
|
---|
| 101 | OSSRET OSS32_Initialize(void)
|
---|
| 102 | {
|
---|
| 103 | short sI, iTmp;
|
---|
| 104 |
|
---|
| 105 | fStrategyInit = TRUE;
|
---|
| 106 |
|
---|
| 107 | if(DevSetTimer(TimerHandler16) != 0) {
|
---|
| 108 | rprintf(("DevSetTimer failed!!"));
|
---|
| 109 | DebugInt3();
|
---|
| 110 | return OSSERR_INIT_FAILED;
|
---|
| 111 | }
|
---|
| 112 | dprintf(("OSS32_Initialize: Start address: %X", OffsetBeginCS32));
|
---|
| 113 |
|
---|
[657] | 114 | if(call_module_init(alsa_sound_init) != 0) return OSSERR_INIT_FAILED;
|
---|
| 115 | if(call_module_init(alsa_seq_device_init) != 0) return OSSERR_INIT_FAILED;
|
---|
[587] | 116 | dprintf(("OSS32_Initialize1: Start address: %X", OffsetBeginCS32));
|
---|
[657] | 117 | if(call_module_init(alsa_pcm_init) != 0) return OSSERR_INIT_FAILED;
|
---|
| 118 | if(call_module_init(alsa_hwdep_init) != 0) return OSSERR_INIT_FAILED;
|
---|
| 119 | if(call_module_init(alsa_timer_init) != 0) return OSSERR_INIT_FAILED;
|
---|
[587] | 120 |
|
---|
[657] | 121 | if(call_module_init(alsa_rawmidi_init) != 0) return OSSERR_INIT_FAILED;
|
---|
| 122 | if(call_module_init(alsa_seq_init) != 0) return OSSERR_INIT_FAILED;
|
---|
[615] | 123 | call_module_init(opl3_seq_driver_init);
|
---|
| 124 | call_module_init(regmap_initcall);
|
---|
[657] | 125 |
|
---|
[587] | 126 | /* Init functions for HDA audio */
|
---|
[615] | 127 | call_module_init(hda_bus_init);
|
---|
| 128 | call_module_init(generic_driver_init);
|
---|
| 129 | call_module_init(analog_driver_init);
|
---|
[620] | 130 | call_module_init(ca0110_driver_init);
|
---|
[688] | 131 | call_module_init(ca0132_driver_init);
|
---|
[626] | 132 | call_module_init(cirrus_driver_init);
|
---|
[615] | 133 | call_module_init(cmedia_driver_init);
|
---|
| 134 | call_module_init(conexant_driver_init);
|
---|
[708] | 135 | call_module_init(hdmi_driver_init);
|
---|
[615] | 136 | call_module_init(realtek_driver_init);
|
---|
| 137 | call_module_init(sigmatel_driver_init);
|
---|
| 138 | call_module_init(via_driver_init);
|
---|
[657] | 139 |
|
---|
[607] | 140 | //dprintf(("OSS32_Initialize: ForceCard=%d", ForceCard));
|
---|
[587] | 141 |
|
---|
| 142 | for (sI=0; sI<CARDS_NUM; sI++) {
|
---|
[607] | 143 | //if ((ForceCard != CARD_NONE) && (ForceCard != cardcalls[sI].card_id)) continue;
|
---|
[587] | 144 | //dprintf(("calling: %x at %x", cardcalls[sI].card_id, cardcalls[sI].cinitcall));
|
---|
| 145 | if (cardcalls[sI].cinitcall == NULL) continue;
|
---|
| 146 | if (*cardcalls[sI].cinitcall == NULL) continue;
|
---|
| 147 | iTmp = (*cardcalls[sI].cinitcall)();
|
---|
| 148 | if (iTmp <= 0) continue;
|
---|
| 149 | while (iTmp) {
|
---|
| 150 | fnCardExitCall[nrCardsDetected++] = *cardcalls[sI].cexitcall;
|
---|
| 151 | iTmp--;
|
---|
| 152 | if (nrCardsDetected >= OSS32_MAX_AUDIOCARDS) break;
|
---|
| 153 | }
|
---|
| 154 | if (nrCardsDetected >= OSS32_MAX_AUDIOCARDS) break;
|
---|
| 155 | }
|
---|
| 156 |
|
---|
| 157 | fStrategyInit = FALSE;
|
---|
| 158 |
|
---|
| 159 | if(nrCardsDetected != 0) {
|
---|
| 160 | pcm_info();
|
---|
| 161 | for(int i=0;i<nrCardsDetected;i++) {
|
---|
| 162 | FillCaps(i);
|
---|
| 163 | }
|
---|
| 164 | rprintf(("OSS32_Initialize: SUCCESS. Cards=%d", nrCardsDetected));
|
---|
| 165 | return OSSERR_SUCCESS;
|
---|
| 166 | }
|
---|
| 167 | rprintf(("OSS32_Initialize: FAILED"));
|
---|
| 168 | return OSSERR_INIT_FAILED;
|
---|
| 169 | }
|
---|
| 170 | //******************************************************************************
|
---|
| 171 | //Called during OS/2 shutdown
|
---|
| 172 | //******************************************************************************
|
---|
| 173 | OSSRET OSS32_Shutdown(void)
|
---|
| 174 | {
|
---|
| 175 | CallOSS16(IDC16_EXIT, 0, 0);
|
---|
| 176 |
|
---|
| 177 | for(int i=0;i<nrCardsDetected;i++) {
|
---|
| 178 | if(fnCardExitCall[i]) fnCardExitCall[i]();
|
---|
| 179 | }
|
---|
| 180 |
|
---|
[615] | 181 | call_module_exit(opl3_seq_driver_exit);
|
---|
[587] | 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);
|
---|
[657] | 187 | call_module_exit(alsa_seq_device_exit);
|
---|
[587] | 188 | call_module_exit(alsa_sound_exit);
|
---|
| 189 |
|
---|
| 190 | return OSSERR_SUCCESS;
|
---|
| 191 | }
|
---|
| 192 |
|
---|
| 193 | //******************************************************************************
|
---|
| 194 | int OSS32_ProcessIRQ(void)
|
---|
| 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 |
|
---|
| 211 | int OSS32_DebugString(char *buffer, ULONG size)
|
---|
| 212 | {
|
---|
| 213 | rprintf(("U16: %s", buffer));
|
---|
| 214 | return size;
|
---|
| 215 | }
|
---|