Changeset 524 for OCO/branches/DAZ/drv16/strategy.cpp
- Timestamp:
- Jul 22, 2010, 8:20:48 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
OCO/branches/DAZ/drv16/strategy.cpp
r497 r524 3 3 /* SCCSID = %W% %E% */ 4 4 /**************************************************************************** 5 * 6 * Copyright (c) IBM Corporation 1994 - 1997. 7 * 8 * The following IBM OS/2 source code is provided to you solely for the 5 * * 6 * Copyright (c) IBM Corporation 1994 - 1997. * 7 * * 8 * The following IBM OS/2 source code is provided to you solely for the * 9 9 * the purpose of assisting you in your development of OS/2 device drivers. * 10 * You may use this code in accordance with the IBM License Agreement 11 * provided in the IBM Device Driver Source Kit for OS/2. 12 * 10 * You may use this code in accordance with the IBM License Agreement * 11 * provided in the IBM Device Driver Source Kit for OS/2. * 12 * * 13 13 ****************************************************************************/ 14 14 /**@internal %W% … … 17 17 * @version %I% 18 18 * @context Unless otherwise noted, all interfaces are Ring-0, 16-bit, 19 * 19 * kernel stack. 20 20 * @history 21 21 * 22 22 */ 23 extern "C" { 23 extern "C" { // 16-bit header files are not C++ aware 24 24 #define INCL_NOPMAPI 25 25 #define INCL_DOSINFOSEG … … 33 33 #include <devhelp.h> 34 34 #include "strategy.h" 35 #include "rtmidi.hpp" 35 #include "rtmidi.hpp" // Object definition 36 36 #include "end.h" 37 37 … … 84 84 extern "C" char szAZX[]; 85 85 86 static char *pszIntelICH 86 static char *pszIntelICH = (char *)szINTEL_ICH; 87 87 static char *pszSigmatel9721_23 = (char *)szSIGMATEL_9721_23; 88 static char *pszSBLive 89 static char *pszCMedia 90 static char *pszCrystal4281 91 static char *pszALS4000 92 static char *pszCrystal46XX 93 static char *pszVIA82XX 94 static char *pszESS1938 95 static char *pszVORTEX 96 static char *pszES1371 97 static char *pszES1370 98 static char *pszYAMAHA 99 static char *pszMAESTRO 100 static char *pszMAESTRO3 101 static char *pszALLEGRO 102 static char *pszALI5451 103 static char *pszSI7012 104 static char *pszALI5455 105 static char *pszNVIDIA 106 static char *pszAMD 107 static char *pszTRIDENT 108 static char *pszNEOMAGIC 109 static char *pszFM801 110 static char *pszATIIXP 111 static char *pszAUDIGYLS 112 static char *pszBT87X 113 static char *pszAZX 88 static char *pszSBLive = (char *)szSBLIVE; 89 static char *pszCMedia = (char *)szCMEDIA; 90 static char *pszCrystal4281 = (char *)szCS4281; 91 static char *pszALS4000 = (char *)szALS4000; 92 static char *pszCrystal46XX = (char *)szCS46XX; 93 static char *pszVIA82XX = (char *)szVIA82XX; 94 static char *pszESS1938 = (char *)szESS1938; 95 static char *pszVORTEX = (char *)szVORTEX; 96 static char *pszES1371 = (char *)szES1371; 97 static char *pszES1370 = (char *)szES1370; 98 static char *pszYAMAHA = (char *)szYAMAHA; 99 static char *pszMAESTRO = (char *)szMAESTRO; 100 static char *pszMAESTRO3 = (char *)szMAESTRO3; 101 static char *pszALLEGRO = (char *)szALLEGRO; 102 static char *pszALI5451 = (char *)szALI5451; 103 static char *pszSI7012 = (char *)szSI7012; 104 static char *pszALI5455 = (char *)szALI5455; 105 static char *pszNVIDIA = (char *)szNVIDIA; 106 static char *pszAMD = (char *)szAMD; 107 static char *pszTRIDENT = (char *)szTRIDENT; 108 static char *pszNEOMAGIC = (char *)szNEOMAGIC; 109 static char *pszFM801 = (char *)szFM801; 110 static char *pszATIIXP = (char *)szATIIXP; 111 static char *pszAUDIGYLS = (char *)szAUDIGYLS; 112 static char *pszBT87X = (char *)szBT87X; 113 static char *pszAZX = (char *)szAZX; 114 114 #endif /* ENABLE_HW_CERTIFICATION */ 115 115 116 BOOL fNoHardware= FALSE;116 BOOL fNoHardware = FALSE; 117 117 118 118 extern void DBGCALLCONV APM_Init(); … … 126 126 int d; 127 127 for (;;) 128 129 // 130 131 132 133 134 128 { 129 // d = (int)(unsigned char)*string1 - (int)(unsigned char)(*string2 ^ 0x81); 130 d = (int)(unsigned char)*string1 - (int)(unsigned char)*string2; 131 if (d != 0 || *string1 == 0 || *string2 == 0) 132 return d; 133 ++string1; ++string2; 134 } 135 135 } 136 136 //****************************************************************************** … … 141 141 142 142 while (count != 0) 143 144 //d = (int)(unsigned char)*string1 - (int)(unsigned char)(*string2 ^ 0x81);145 146 147 148 149 150 143 { 144 // d = (int)(unsigned char)*string1 - (int)(unsigned char)(*string2 ^ 0x81); 145 d = (int)(unsigned char)*string1 - (int)(unsigned char)*string2; 146 if (d != 0 || *string1 == 0 || *string2 == 0) 147 return d; 148 ++string1; ++string2; 149 --count; 150 } 151 151 return 0; 152 152 } … … 160 160 if(OSS16_AttachToPdd() != OSSERR_SUCCESS) 161 161 { 162 163 // 164 162 DebugInt3(); 163 // DevHelp_Beep(500, 100); 164 goto failure; 165 165 } 166 166 … … 168 168 if(OSS16_QueryDevCaps(current_device, &devCaps[0]) != OSSERR_SUCCESS) 169 169 { 170 171 //DevHelp_Beep(2000, 100);172 170 DebugInt3(); 171 // DevHelp_Beep(2000, 100); 172 goto failure; 173 173 } 174 174 dprintf(("Device 0 name: %s", (char FAR *)devCaps[0].szDeviceName)); 175 175 if(devCaps[0].nrDevices > OSS32_MAX_AUDIOCARDS) 176 176 { 177 178 177 DebugInt3(); 178 devCaps[0].nrDevices = OSS32_MAX_AUDIOCARDS; 179 179 } 180 180 //Get caps of other devices (if present) 181 181 for(i=1;i<devCaps[0].nrDevices;i++) 182 182 { 183 184 185 186 183 if(OSS16_QueryDevCaps(i, &devCaps[i]) != OSSERR_SUCCESS) { 184 DebugInt3(); 185 goto failure; 186 } 187 187 } 188 188 … … 191 191 //Check for certified audiocard/chipsets 192 192 if(!xorstrncmp(devCaps[0].szDeviceName, pszIntelICH, 6) || 193 194 195 196 197 { 198 193 !xorstrcmp(devCaps[0].szDeviceName, pszSI7012) || 194 !xorstrcmp(devCaps[0].szDeviceName, pszALI5455) || 195 !xorstrncmp(devCaps[0].szDeviceName, pszNVIDIA, 6) || 196 !xorstrcmp(devCaps[0].szDeviceName, pszAMD)) 197 { 198 soundCard = INTELICH; 199 199 } 200 200 else 201 201 if(!xorstrcmp(devCaps[0].szDeviceName, pszSBLive)) 202 202 { 203 203 soundCard = SBLIVE; 204 204 } 205 205 else 206 206 if(!xorstrncmp(devCaps[0].szDeviceName, pszCMedia, 11)) 207 207 { 208 208 soundCard = CMEDIA; 209 209 } 210 210 else 211 211 if(!xorstrcmp(devCaps[0].szDeviceName, pszCrystal4281)) 212 212 { 213 213 soundCard = CS4281; 214 214 } 215 215 else 216 216 if(!xorstrcmp(devCaps[0].szDeviceName, pszALS4000)) 217 217 { 218 219 220 221 222 218 //hardware not completely full duplex; sample rates must be identical if 219 //both playback & recording active 220 devCaps[0].waveInCaps.ulRateFlags |= OSS32_CAPS_PCM_RATE_HALFDUPLEX; 221 devCaps[0].waveOutCaps.ulRateFlags |= OSS32_CAPS_PCM_RATE_HALFDUPLEX; 222 soundCard = ALS4000; 223 223 } 224 224 else 225 225 if(!xorstrcmp(devCaps[0].szDeviceName, pszCrystal46XX)) 226 226 { 227 227 soundCard = CS46XX; 228 228 } 229 229 else 230 230 if(!xorstrncmp(devCaps[0].szDeviceName, pszVIA82XX, 6)) 231 231 { 232 232 soundCard = VIA82XX; 233 233 } 234 234 else 235 235 if(!xorstrcmp(devCaps[0].szDeviceName, pszESS1938)) 236 236 { 237 237 soundCard = ESS1938; 238 238 } 239 239 else 240 240 if(!xorstrncmp(devCaps[0].szDeviceName, pszVORTEX, 6)) 241 241 { 242 242 soundCard = VORTEX; 243 243 } 244 244 else 245 245 if(!xorstrncmp(devCaps[0].szDeviceName, pszYAMAHA,6)) 246 246 { 247 247 soundCard = YAMAHA; 248 248 } 249 249 else 250 250 if(!xorstrcmp(devCaps[0].szDeviceName, pszMAESTRO)) 251 251 { 252 253 } 254 else 255 256 257 { 258 259 } 260 else 261 262 263 { 264 252 soundCard = MAESTRO; 253 } 254 else 255 if(!xorstrcmp(devCaps[0].szDeviceName, pszMAESTRO3) || 256 !xorstrcmp(devCaps[0].szDeviceName, pszALLEGRO)) 257 { 258 soundCard = MAESTRO3; 259 } 260 else 261 if(!xorstrncmp(devCaps[0].szDeviceName, pszES1371, 6) || 262 !xorstrncmp(devCaps[0].szDeviceName, pszES1370, 6)) 263 { 264 soundCard = ENSONIQ; 265 265 } 266 266 else 267 267 if(!xorstrcmp(devCaps[0].szDeviceName, pszALI5451)) 268 268 { 269 269 soundCard = ALI5451; 270 270 } 271 271 else 272 272 if(!xorstrncmp(devCaps[0].szDeviceName, pszTRIDENT,7)) 273 273 { 274 274 soundCard = TRIDENT; 275 275 } 276 276 else 277 277 if(!xorstrncmp(devCaps[0].szDeviceName, pszNEOMAGIC,5)) 278 278 { 279 279 soundCard = NEOMAGIC; 280 280 } 281 281 else 282 282 if(!xorstrncmp(devCaps[0].szDeviceName, pszFM801,5)) 283 283 { 284 284 soundCard = FM801; 285 285 } 286 286 else 287 287 if(!xorstrncmp(devCaps[0].szDeviceName, pszATIIXP,7)) 288 288 { 289 289 soundCard = ATIIXP; 290 290 } 291 291 else 292 292 if(!xorstrncmp(devCaps[0].szDeviceName, pszAUDIGYLS,6)) 293 293 { 294 294 soundCard = AUDIGYLS; 295 295 } 296 296 else 297 297 if(!xorstrncmp(devCaps[0].szDeviceName, pszBT87X,5)) 298 298 { 299 299 soundCard = BT87X; 300 300 } 301 301 else 302 302 if(!xorstrncmp(devCaps[0].szDeviceName, pszAZX,9)) 303 303 { 304 304 soundCard = AZX; 305 305 } 306 306 else { 307 // printk("Soundcard %s not supported", (char FAR *)devCaps[0].szDeviceName); 308 dprintf(("Soundcard %s not supported", (char FAR *)devCaps[0].szDeviceName)); 309 // DevHelp_Beep(1000, 50); 310 DebugInt3(); 311 goto failure; 307 rprintf(("Soundcard %s not supported", (char FAR *)devCaps[0].szDeviceName)); 308 //DevHelp_Beep(1000, 50); 309 DebugInt3(); 310 goto failure; 312 311 } 313 312 #endif /* ENABLE_HW_CERTIFICATION */ … … 315 314 316 315 failure: 317 // 318 319 316 // DevHelp_Beep(1000, 50); 317 fNoHardware = TRUE; 318 return FALSE; 320 319 } 321 320 … … 329 328 { 330 329 if(InitializeAudio() == FALSE) { 331 330 return; 332 331 } 333 332 if(fNoHardware) return; … … 338 337 if(devCaps[0].ulCaps & OSS32_CAPS_FMSYNTH_PLAYBACK) 339 338 { 340 341 342 343 344 345 346 347 348 349 350 351 339 dprintf(("Creating FM Synthesizer device")); 340 341 // Build a FMSYNTH object. First create a timer, then the HW object. 342 TIMER* pFMSynthTimer = 343 new TIMER( NULL, MIDI_TimerInterval, STREAM_FMSYNTH_PLAY ); 344 if (pFMSynthTimer->eState() != TIMER_Disabled) 345 new FMSYNTH( pFMSynthTimer ); 346 347 SetHardwareType(AUDIOHW_FMSYNTH_PLAY, MIDI, OPERATION_PLAY, 1); 348 SetHardwareType(AUDIOHW_FMSYNTH_PLAY, DATATYPE_MIDI, OPERATION_PLAY, 1); 349 // MIDI on Warp 3 350 SetHardwareType(AUDIOHW_FMSYNTH_PLAY, DATATYPE_NULL, OPERATION_PLAY, 1); 352 351 } 353 352 354 353 if((devCaps[0].ulCaps & OSS32_CAPS_MPU401_PLAYBACK) && 355 356 { 357 358 359 360 361 // vladestnew TIMER(NULL, MIDI_TimerInterval, STREAM_MPU401_PLAY );362 363 364 365 366 367 // 368 // 369 370 371 372 373 354 (devCaps[0].ulCaps & OSS32_CAPS_MPU401_CAPTURE)) 355 { 356 dprintf(("Creating MPU401 device")); 357 358 // Build the MPU401 object. First create a timer, then the HW object. 359 TIMER* pMPUTimer = 360 // vladest new TIMER(NULL, MIDI_TimerInterval, STREAM_MPU401_PLAY ); 361 new TIMER(NULL, MIDI_TimerInterval, STREAM_MPU401_CAPTURE ); 362 363 if (pMPUTimer->eState() != TIMER_Disabled) 364 new MPU_401(pMPUTimer); 365 366 // SetHardwareType(AUDIOHW_MPU401_PLAY, MIDI, OPERATION_PLAY, 0); 367 // SetHardwareType(AUDIOHW_MPU401_PLAY, DATATYPE_MIDI, OPERATION_PLAY, 0); 368 369 SetHardwareType(AUDIOHW_MPU401_CAPTURE, MIDI, OPERATION_RECORD, 0); 370 SetHardwareType(AUDIOHW_MPU401_CAPTURE, DATATYPE_MIDI, OPERATION_RECORD, 0); 371 372 RTMIDI::vConnect(); 374 373 } 375 374 APM_Init(); … … 380 379 * Purpose: Worker rountine for the Strategy Open function. 381 380 * 382 * Notes: 383 * and the function is treated as a NOP.The first allocation of384 * 385 * 386 * 387 * 388 * 389 * 381 * Notes: The Strategy Open doesn't require allocation of any resources, 382 * and the function is treated as a NOP. The first allocation of 383 * resources happens at Strategy IOCtl time, in the handler for 384 * the AudioInit IOCtl. 385 * Check to see if the VDD has claimed the hardware and return with 386 * the busy bit on the the request packet. 387 * Increment the InUseCount so we know that an OS/2 app has an 388 * instance open and we don't let the VDD take the hardware.. 390 389 * 391 390 * … … 395 394 { 396 395 if (usVDDHasHardware) { 397 396 prp->usStatus = RPDONE | RPERR | RPBUSY; 398 397 } 399 398 else { 400 399 ++usInUseCount; 401 400 } 402 401 } … … 405 404 void StrategyClose(PREQPACKET prp) 406 405 { 407 408 409 410 411 412 dprintf(("Close NULL stream"));;//### Log unexpected condition.406 --usInUseCount; 407 PSTREAM pstream = FindStream_fromFile( prp->s.open_close.usSysFileNum ); 408 if (pstream) 409 delete pstream; 410 else 411 dprintf(("Close NULL stream"));; //### Log unexpected condition. 413 412 } 414 413 //****************************************************************************** … … 416 415 void StrategyDeinstall(PREQPACKET prp) 417 416 { 418 419 417 while (pAudioHWList->IsElements()) 418 pAudioHWList->DestroyElement(pAudioHWList->PopHead()); 420 419 } 421 420 //****************************************************************************** … … 423 422 void StrategyShutdown(PREQPACKET prp) 424 423 { 425 424 dprintf(("StrategyShutdown %d", prp->s.shutdown.Function)); 426 425 } 427 426 //****************************************************************************** … … 446 445 447 446 if(fNoHardware) { 448 449 447 prp->usStatus = RPDONE | RPERR | RPGENFAIL; 448 return; 450 449 } 451 450 … … 455 454 456 455 switch (prp->bCommand) { 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 dprintf(("Strategy Unk:0x%x", prp->bCommand));480 456 case STRATEGY_INIT: 457 StrategyInit(prp); 458 break; 459 case STRATEGY_OPEN: 460 StrategyOpen(prp); 461 break; 462 case STRATEGY_CLOSE: 463 StrategyClose(prp); 464 break; 465 case STRATEGY_GENIOCTL: 466 StrategyIoctl(prp, 0); 467 break; 468 case STRATEGY_DEINSTALL: 469 StrategyDeinstall(prp); 470 break; 471 case STRATEGY_INITCOMPLETE: 472 StrategyInitComplete(prp); 473 break; 474 case STRATEGY_SHUTDOWN: 475 StrategyShutdown(prp); 476 break; 477 default: 478 rprintf(("Strategy Unk:0x%x", prp->bCommand)); 479 prp->usStatus = RPDONE | RPERR | RPGENFAIL; 481 480 } 482 481 #ifdef DEBUG … … 493 492 494 493 if(fNoHardware) { 495 496 497 498 499 500 494 prp->usStatus = RPDONE | RPERR | RPGENFAIL; 495 if(prp->bCommand == STRATEGY_INIT) { 496 prp->s.init_out.usCodeEnd = 0; 497 prp->s.init_out.usDataEnd = 0; 498 } 499 return; 501 500 } 502 501 … … 506 505 507 506 switch (prp->bCommand) { 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 507 case STRATEGY_INIT: 508 prp->usStatus = RPDONE; 509 prp->s.init_out.usCodeEnd = (USHORT) &end_of_text; 510 prp->s.init_out.usDataEnd = (USHORT) &end_of_heap; 511 break; 512 case STRATEGY_OPEN: 513 StrategyOpen(prp); 514 break; 515 case STRATEGY_CLOSE: 516 StrategyClose(prp); 517 break; 518 case STRATEGY_GENIOCTL: 519 StrategyIoctl(prp, 1); 520 break; 521 case STRATEGY_DEINSTALL: 522 StrategyDeinstall(prp); 523 break; 524 case STRATEGY_INITCOMPLETE: 525 prp->usStatus = RPDONE; 526 break; 527 default: 528 prp->usStatus = RPDONE | RPERR | RPGENFAIL; 530 529 } 531 530 #ifdef DEBUG
Note:
See TracChangeset
for help on using the changeset viewer.