Changeset 518
- Timestamp:
- Jul 20, 2010, 5:46:55 PM (15 years ago)
- Location:
- GPL/trunk
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk/alsa-kernel/core/sgbuf.c
r484 r518 118 118 struct page **pgtable; 119 119 120 #ifdef DEBUG 121 dprintf(("snd_malloc_sgbuf_pages. size %x",size)); 122 #endif 120 dprintf(("snd_malloc_sgbuf_pages. size %x", size)); 123 121 124 122 dmab->area = NULL; -
GPL/trunk/drv32/init.c
r502 r518 218 218 } 219 219 if (!HeapInit(HEAP_SIZE)) { 220 dprintf(("HeapInit failed!"));220 rprintf(("HeapInit failed!")); 221 221 } 222 222 -
GPL/trunk/drv32/irq.cpp
r458 r518 67 67 BYTE LowIRQ; 68 68 BYTE HighIRQ; 69 BYTE Pin; 69 BYTE Pin; 70 70 } sISRHigh[8]; //FIX me to MAX_DEVICES or same 71 71 … … 136 136 ULONG ulIrqNo; 137 137 138 // enable interrupts that have higher priority we should 138 // enable interrupts that have higher priority we should 139 139 // allow higher priority interrupts 140 sti(); 140 sti(); 141 141 if( process_interrupt(ulSlotNo, &ulIrqNo) ) { 142 // We've cleared all service requests. 143 // Clear (disable) Interrupts, Send EOI 142 // We've cleared all service requests. 143 // Clear (disable) Interrupts, Send EOI 144 144 // and clear the carry flag (tells OS/2 kernel that Int was handled). 145 // Note carry flag is handled in setup.asm 145 // Note carry flag is handled in setup.asm 146 146 cli(); 147 147 DevEOI( (WORD16)ulIrqNo ); -
GPL/trunk/drv32/rmhelp.cpp
r421 r518 150 150 //****************************************************************************** 151 151 //PS+++ see to irq.cpp 152 #ifdef ACPI 152 #ifdef ACPI 153 153 #ifdef __cplusplus 154 154 extern "C" { … … 159 159 BYTE LowIRQ; 160 160 BYTE HighIRQ; 161 BYTE Pin; 161 BYTE Pin; 162 162 }; 163 163 extern struct SaveIRQForSlot sISRHigh[]; -
GPL/trunk/drv32/strategy.c
r501 r518 24 24 25 25 #define INCL_NOPMAPI 26 #define INCL_DOSINFOSEG 26 #define INCL_DOSINFOSEG // Need Global info seg in rm.cpp algorithms 27 27 #include <os2.h> 28 28 … … 51 51 } 52 52 numOS2Opens++; 53 53 return RPDONE; 54 54 } 55 55 //****************************************************************************** … … 66 66 ULONG StratInit(RP __far* _rp) 67 67 { 68 69 70 71 72 73 68 ULONG rc; 69 70 RPInit __far* rp = (RPInit __far*)_rp; 71 rc = DiscardableInit(rp); 72 dprintf(("StratInit End rc=%d", rc)); 73 return rc; 74 74 } 75 75 //****************************************************************************** … … 77 77 #ifdef ACPI 78 78 // See desription in irq.cpp 79 #include "irqos2.h" 79 #include "irqos2.h" //PS+++ 80 80 #ifdef __cplusplus 81 81 extern "C" { 82 82 #endif 83 ULONG InitCompleteWas = 0; 83 ULONG InitCompleteWas = 0; //PS+++ Indication of InitComplete call 84 84 struct SaveIRQForSlot 85 85 { 86 87 88 89 86 ULONG ulSlotNo; 87 BYTE LowIRQ; 88 BYTE HighIRQ; 89 BYTE Pin; 90 90 }; 91 91 extern struct SaveIRQForSlot sISRHigh[]; 92 extern int 92 extern int SaveIRQCounter; 93 93 #ifdef __cplusplus 94 94 } … … 102 102 #ifdef ACPI 103 103 //PS+++ Begin 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 104 ULONG i, rc = 0; 105 106 InitCompleteWas = 1; 107 for (i = 0; i < SaveIRQCounter; i++) 108 { 109 dprintf(("Close IRQ%d - Open IRQ%d",(ULONG)sISRHigh[i].LowIRQ,(ULONG)sISRHigh[i].HighIRQ)); 110 if (sISRHigh[i].HighIRQ) 111 { 112 ALSA_FreeIrq(sISRHigh[i].LowIRQ); 113 if (!ALSA_SetIrq(sISRHigh[i].HighIRQ, sISRHigh[i].ulSlotNo, 1)) 114 { 115 return (RPERR_COMMAND | RPDONE); 116 } 117 } 118 } 119 119 #endif 120 120 //PS++ End 121 #ifdef DEBUG 122 dprintf(("StratInitComplete")); 123 #endif 121 dprintf(("StratInitComplete")); 124 122 return(RPDONE); 125 123 } … … 130 128 #pragma on (unreferenced) 131 129 { 132 RPShutdown __far *rp = (RPShutdown __far *)_rp; 133 134 #ifdef DEBUG 135 dprintf(("StratShutdown %d", rp->Function)); 136 #endif 137 if(rp->Function == 1) {//end of shutdown 138 OSS32_Shutdown(); 139 } 130 RPShutdown __far *rp = (RPShutdown __far *)_rp; 131 132 dprintf(("StratShutdown Start %d", rp->Function)); 133 if(rp->Function == 1) {//end of shutdown 134 OSS32_Shutdown(); 135 } 136 dprintf(("StratShutdown End")); 140 137 return(RPDONE); 141 138 } … … 155 152 RPHandler StratDispatch[] = 156 153 { 157 StratInit, 158 StratError, 159 StratError, 160 StratError, 161 StratRead, 162 StratError, 163 StratError, 164 StratError, 165 StratWrite, 166 StratError, 167 StratError, 168 StratError, 169 StratError, 170 StratOpen, 171 StratClose, 172 StratError, 173 StratIOCtl, 174 StratError, 175 StratError, 176 StratError, 177 StratError, 178 StratError, 179 StratError, 180 StratError, 181 StratError, 182 StratError, 183 StratError, 184 StratError, 185 StratShutdown, 186 StratError, 187 StratError, 188 StratInitComplete 154 StratInit, // 00 (BC): Initialization 155 StratError, // 01 (B ): Media check 156 StratError, // 02 (B ): Build BIOS parameter block 157 StratError, // 03 ( ): Unused 158 StratRead, // 04 (BC): Read 159 StratError, // 05 ( C): Nondestructive read with no wait 160 StratError, // 06 ( C): Input status 161 StratError, // 07 ( C): Input flush 162 StratWrite, // 08 (BC): Write 163 StratError, // 09 (BC): Write verify 164 StratError, // 0A ( C): Output status 165 StratError, // 0B ( C): Output flush 166 StratError, // 0C ( ): Unused 167 StratOpen, // 0D (BC): Open 168 StratClose, // 0E (BC): Close 169 StratError, // 0F (B ): Removable media check 170 StratIOCtl, // 10 (BC): IO Control 171 StratError, // 11 (B ): Reset media 172 StratError, // 12 (B ): Get logical unit 173 StratError, // 13 (B ): Set logical unit 174 StratError, // 14 ( C): Deinstall character device driver 175 StratError, // 15 ( ): Unused 176 StratError, // 16 (B ): Count partitionable fixed disks 177 StratError, // 17 (B ): Get logical unit mapping of fixed disk 178 StratError, // 18 ( ): Unused 179 StratError, // 19 ( ): Unused 180 StratError, // 1A ( ): Unused 181 StratError, // 1B ( ): Unused 182 StratShutdown, // 1C (BC): Notify start or end of system shutdown 183 StratError, // 1D (B ): Get driver capabilities 184 StratError, // 1E ( ): Unused 185 StratInitComplete // 1F (BC): Notify end of initialization 189 186 }; 190 187 //****************************************************************************** … … 199 196 { 200 197 if (rp->Command < sizeof(StratDispatch)/sizeof(StratDispatch[0])) 201 198 return(StratDispatch[rp->Command](rp)); 202 199 else return(RPERR_COMMAND | RPDONE); 203 200 } -
GPL/trunk/include/dbgos2.h
r501 r518 32 32 extern int wrOffset; 33 33 extern char *szprintBuf; 34 //void _cdecl DP D(int level,char *x, ...) ; /* not debugging: nothing */35 void _cdecl DPE(char *x, ...) ; /* not debugging: nothing */ 34 //void _cdecl DPE(char *x, ...) ; /* not debugging: nothing */ 35 int _cdecl printk(const char * fmt, ...); 36 36 #ifdef __cplusplus 37 37 } 38 38 #endif 39 39 40 40 41 /* rprintf always prints to the log buffer, and to SIO if enabled */ 41 #define rprintf(a) DPEa42 #define rprintf(a) printk a 42 43 43 44 /* the dprintf functions only print if DEBUG is defined */ 44 45 #ifdef DEBUG 45 46 #define DBG_MAX_BUF_SIZE 0x100000 46 #define dprintf(a) DPEa47 #define dprintf1(a) if(DebugLevel > 0) DPEa48 #define dprintf2(a) if(DebugLevel > 1) DPEa49 #define dprintf3(a) if(DebugLevel > 2) DPEa47 #define dprintf(a) printk a 48 #define dprintf1(a) if(DebugLevel > 0) printk a 49 #define dprintf2(a) if(DebugLevel > 1) printk a 50 #define dprintf3(a) if(DebugLevel > 2) printk a 50 51 #define DebugInt3() ; //_asm int 3 51 52 //#define DebInt3() _asm int 3; -
GPL/trunk/include/proto.h
r479 r518 4 4 extern int _snd_pcm_hw_param_set(struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var, unsigned int val, int dir); 5 5 extern int in_interrupt(void); 6 extern int in_atomic(void); 6 7 /* 7 8 * Uniaud API support -
GPL/trunk/include/unicard.h
r455 r518 51 51 #define CARD_CS5535 21 52 52 53 #define CARDS_NUM 2 153 #define CARDS_NUM 22 54 54 55 55 #define CARD_STRING_SBLIVE "SBLIVE" -
GPL/trunk/lib32/debug.c
r501 r518 250 250 } 251 251 252 char BuildString[1024];253 254 #if 0255 //------------------------- PrintfOut -256 void _cdecl DPD(int level, char *DbgStr, ...)257 {258 char *BuildPtr=BuildString;259 char *pStr=(char *) DbgStr;260 char *SubStr;261 union {262 void *VoidPtr;263 USHORT *WordPtr;264 ULONG *LongPtr;265 ULONG *StringPtr;266 } Parm;267 USHORT wBuildOption;268 269 Parm.VoidPtr=(void *) &DbgStr;270 Parm.StringPtr++; // skip size of string pointer271 272 while (*pStr)273 {274 // don't overflow target275 if (BuildPtr >= (char *) &BuildString[1024-2])276 break;277 278 switch (*pStr)279 {280 case '%':281 wBuildOption=0;282 pStr++;283 if (*pStr=='0')284 {285 wBuildOption|=LEADING_ZEROES;286 pStr++;287 }288 if (*pStr=='u') // always unsigned289 pStr++;290 if (*pStr=='#')291 pStr++;292 293 switch(*pStr)294 {295 case 'x':296 case 'X':297 case 'p':298 case 'P':299 BuildPtr=HexLongToASCII(BuildPtr, *Parm.LongPtr++,wBuildOption);300 pStr++;301 continue;302 303 case 'd':304 BuildPtr=DecLongToASCII(BuildPtr, *Parm.LongPtr++,wBuildOption);305 pStr++;306 continue;307 308 case 's':309 SubStr=(char *)*Parm.StringPtr;310 while (*BuildPtr++ = *SubStr++);311 Parm.StringPtr++;312 BuildPtr--; // remove the \0313 pStr++;314 continue;315 316 case 'l':317 pStr++;318 switch (*pStr)319 {320 case 'x':321 case 'X':322 BuildPtr=HexLongToASCII(BuildPtr, *Parm.LongPtr++,wBuildOption);323 pStr++;324 continue;325 326 case 'd':327 BuildPtr=DecLongToASCII(BuildPtr, *Parm.LongPtr++,wBuildOption);328 pStr++;329 continue;330 } // end switch331 continue; // dunno what he wants332 333 case 0:334 continue;335 } // end switch336 break;337 338 case '\\':339 pStr++;340 switch (*pStr)341 {342 case 'n':343 *BuildPtr++=LF;344 pStr++;345 continue;346 347 case 'r':348 *BuildPtr++=CR;349 pStr++;350 continue;351 352 case 0:353 continue;354 break;355 } // end switch356 357 break;358 } // end switch359 360 *BuildPtr++=*pStr++;361 } // end while362 363 *BuildPtr=0; // cauterize the string364 StringOut((char *) BuildString);365 }366 #endif367 368 void _cdecl DPE(char *DbgStr, ...)369 {370 char *BuildPtr=BuildString;371 char *pStr = (char *) DbgStr;372 char *SubStr;373 union {374 void *VoidPtr;375 USHORT *WordPtr;376 ULONG *LongPtr;377 ULONG *StringPtr;378 } Parm;379 USHORT wBuildOption;380 381 Parm.VoidPtr=(void *) &DbgStr;382 Parm.StringPtr++; // skip size of string pointer383 384 while (*pStr)385 {386 // don't overflow target387 if (BuildPtr >= (char *) &BuildString[1024-2])388 break;389 390 switch (*pStr)391 {392 case '%':393 wBuildOption=0;394 pStr++;395 if (*pStr=='0')396 {397 wBuildOption|=LEADING_ZEROES;398 pStr++;399 }400 // if (*pStr=='u') // always unsigned401 // pStr++;402 403 switch(*pStr)404 {405 case 'x':406 case 'X':407 case 'p':408 case 'P':409 BuildPtr=HexLongToASCII(BuildPtr, *Parm.LongPtr++,wBuildOption);410 pStr++;411 continue;412 413 case 'd':414 case 'u':415 BuildPtr=DecLongToASCII(BuildPtr, *Parm.LongPtr++,wBuildOption);416 pStr++;417 continue;418 419 case 's':420 SubStr=(char *)*Parm.StringPtr;421 while (*BuildPtr++ = *SubStr++);422 Parm.StringPtr++;423 BuildPtr--; // remove the \0424 pStr++;425 continue;426 427 case 'c':428 *BuildPtr++ = (char)*Parm.LongPtr;429 Parm.LongPtr++;430 pStr++;431 continue;432 433 case 'l':434 pStr++;435 switch (*pStr)436 {437 case 'x':438 case 'X':439 BuildPtr=HexLongToASCII(BuildPtr, *Parm.LongPtr++,wBuildOption);440 pStr++;441 continue;442 443 case 'd':444 BuildPtr=DecLongToASCII(BuildPtr, *Parm.LongPtr++,wBuildOption);445 pStr++;446 continue;447 } // end switch448 continue; // dunno what he wants449 450 case 0:451 continue;452 } // end switch453 break;454 455 case '\\':456 pStr++;457 switch (*pStr)458 {459 case 'n':460 *BuildPtr++=LF;461 pStr++;462 continue;463 464 case 'r':465 *BuildPtr++=CR;466 pStr++;467 continue;468 469 case 0:470 continue;471 break;472 } // end switch473 474 break;475 } // end switch476 477 *BuildPtr++=*pStr++;478 } // end while479 480 *BuildPtr=0; // cauterize the string481 StringOut((char *) BuildString);482 }483 484 252 struct snd_info_buffer { 485 253 char *buffer; /* pointer to begin of buffer */ -
GPL/trunk/lib32/fminstrload.c
r305 r518 42 42 #include "instrfm.h" 43 43 44 #define assert(a) 44 #define assert(a) 45 45 46 46 typedef struct sbi_header … … 101 101 { 102 102 midihandle *pHandle = (midihandle *)streamid; 103 103 104 104 if(pHandle == NULL || pHandle->magic != MAGIC_MIDI_ALSA32) { 105 105 DebugInt3(); … … 119 119 //load drums 120 120 load_sb(pHandle, drumsopl3, sizeof(drumsopl3), 128); 121 121 122 122 return OSSERR_SUCCESS; 123 123 } … … 226 226 * Parse standard .sb or .o3 file 227 227 */ 228 static void load_sb (midihandle *pHandle, char *pFile, int filesize, int bank) 228 static void load_sb (midihandle *pHandle, char *pFile, int filesize, int bank) 229 229 { 230 230 int len, i, offset = 0; … … 245 245 if (!strncmp (sbi_instr.header.key, "SBI\032", 4) || !strncmp (sbi_instr.header.key, "2OP\032", 4)) { 246 246 fm_instr_type = FM_PATCH_OPL2; 247 } 248 else 247 } 248 else 249 249 if (!strncmp (sbi_instr.header.key, "4OP\032", 4)) { 250 250 fm_instr_type = FM_PATCH_OPL3; 251 } 251 } 252 252 else { 253 253 fm_instr_type = 0; … … 374 374 memset(*ptr, 0, sizeof(snd_instr_header_t) + len); 375 375 (*ptr)->len = len; 376 376 377 377 return 0; 378 378 } -
GPL/trunk/lib32/ioctl.c
r479 r518 284 284 if(pcminfo == NULL) { 285 285 DebugInt3(); 286 printk("GetUniaudPcmCaps: out of memory\n");286 rprintf(("GetUniaudPcmCaps: out of memory")); 287 287 return OSSERR_OUT_OF_MEMORY; 288 288 } … … 302 302 if(ret != OSSERR_SUCCESS) 303 303 { 304 printk("GetUniaudPcmCaps: wave open error %i %s at pcm %i\n", ret,305 (j == 0) ?"PLAY":"REC", i) ;304 rprintf(("GetUniaudPcmCaps: wave open error %i %s at pcm %i", ret, 305 (j == 0) ?"PLAY":"REC", i)); 306 306 continue; 307 307 // goto fail; … … 309 309 pHandle = (soundhandle *)streamid; 310 310 if(pHandle == NULL || pHandle->magic != MAGIC_WAVE_ALSA32) { 311 printk("GetUniaudPcmCaps: invalid stream id \n");311 rprintf(("GetUniaudPcmCaps: invalid stream id")); 312 312 ret = OSSERR_INVALID_STREAMID; 313 313 // goto fail; … … 317 317 pHandle->file.f_flags = O_NONBLOCK; 318 318 319 printk("GetUniaudPcmCaps: cp1. phandle %x\n", pHandle);319 dprintf(("GetUniaudPcmCaps: cp1. phandle %x", pHandle)); 320 320 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_INFO, (ULONG)pcminfo); 321 321 if(ret != 0) { 322 printk("GetUniaudPcmCaps: SNDRV_PCM_IOCTL_INFO error %i\n", ret);322 rprintf(("GetUniaudPcmCaps: SNDRV_PCM_IOCTL_INFO error %i", ret)); 323 323 ret = UNIXToOSSError(ret); 324 324 continue; … … 335 335 pWaveCaps->nrStreams = pcminfo->subdevices_count; 336 336 337 printk("GetUniaudPcmCaps: cp2. nr of streams: %i\n", pWaveCaps->nrStreams);337 dprintf(("GetUniaudPcmCaps: cp2. nr of streams: %i", pWaveCaps->nrStreams)); 338 338 //get all hardware parameters 339 339 _snd_pcm_hw_params_any(params); 340 340 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)params); 341 341 if(ret != 0) { 342 printk("GetUniaudPcmCaps: SNDRV_PCM_IOCTL_HW_REFINE error %i\n", ret);342 rprintf(("GetUniaudPcmCaps: SNDRV_PCM_IOCTL_HW_REFINE error %i", ret)); 343 343 ret = UNIXToOSSError(ret); 344 344 //goto fail; 345 345 continue; 346 346 } 347 printk("GetUniaudPcmCaps: cp3\n");347 //dprintf("GetUniaudPcmCaps: cp3")); 348 348 349 349 pWaveCaps->ulMinChannels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS)->min; 350 350 pWaveCaps->ulMaxChannels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS)->max; 351 printk("chan: from %i to %i\n", pWaveCaps->ulMinChannels,pWaveCaps->ulMaxChannels);351 dprintf(("chan: from %i to %i\n", pWaveCaps->ulMinChannels,pWaveCaps->ulMaxChannels)); 352 352 pWaveCaps->ulChanFlags = 0; 353 353 if(pWaveCaps->ulMinChannels == 1) { … … 368 368 369 369 mask = hw_param_mask(params, SNDRV_PCM_HW_PARAM_RATE_MASK); 370 //mask = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);370 //mask = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); 371 371 pWaveCaps->ulRateFlags = mask->bits[0]; 372 372 … … 403 403 pcms = pcm_instances(deviceid); 404 404 405 printk("pcms = %i\n", pcms); //uncommented405 dprintf(("FillCaps: pcms=%i\n", pcms)); 406 406 if (!pcmcaps[deviceid]) 407 407 { -
GPL/trunk/lib32/irq.c
r501 r518 87 87 { 88 88 if(RMRequestIRQ(/*hResMgr,*/ irq , (x0 & SA_SHIRQ) != 0) == FALSE) { 89 dprintf(("RMRequestIRQ failed for irq %d", irq));89 rprintf(("RMRequestIRQ failed for irq %d", irq)); 90 90 // return 0; 91 91 } … … 113 113 } 114 114 115 dprintf(("request_irq: Unable to register irq handler for irq %d\n", irq & 0xff ));115 rprintf(("request_irq: Unable to register irq handler for irq %d\n", irq & 0xff )); 116 116 return 1; 117 117 } -
GPL/trunk/lib32/malloc.cpp
r502 r518 415 415 for (pmb=pmbFree->pmbNext; pmb; pmb=pmb->pmbNext) { 416 416 if (after(pmb) == pmbFree) { 417 // d dprintf("HEAP: compact found pointer %p (size=%ui) before pmbFree %p\n", (void __far *) pmb, pmb->uSize, (void __far *) pmbFree);417 // dprintf(("HEAP: compact found pointer %p (size=%ui) before pmbFree %p\n", (void __far *) pmb, pmb->uSize, (void __far *) pmbFree)); 418 418 pmb->ulSize += HDR_SIZE + pmbFree->ulSize; 419 419 remove(pmbFree); 420 420 if (++sFreed == 2) break; 421 421 } else if (after(pmbFree) == pmb) { 422 // d dprintf("HEAP: compact found pointer %p (size=%ui) after pmbFree %p\n", (void __far *) pmb, pmb->uSize, (void __far *) pmbFree);422 // dprintf(("HEAP: compact found pointer %p (size=%ui) after pmbFree %p\n", (void __far *) pmb, pmb->uSize, (void __far *) pmbFree); 423 423 pmbFree->ulSize += HDR_SIZE + pmb->ulSize; 424 424 remove(pmb); -
GPL/trunk/lib32/memory.cpp
r501 r518 264 264 //oops, this didn't work, fail 265 265 VMFree((LINEAR)addr); 266 dprintf(("get_free_dma_pages failed %x size:%x st:%x end:%x, trying wasteful method instead", physaddr,size,startpage,endpage));266 dprintf(("get_free_dma_pages failed %x size:%x st:%x end:%x, trying wasteful method instead", physaddr, size, startpage, endpage)); 267 267 return 0; 268 268 } … … 279 279 //only done to save size of memory block 280 280 AddBaseAddress(addr, addr, size); 281 dprintf(("get_free_dma_pages %d -> %x (phys %x)", size, (ULONG)addr, virt_to_phys((void *)addr)));282 281 ulget_free_pagesMemUsed += size; 283 dprintf(("get_free_dma_pages: total alloc size %d", ulget_free_pagesMemUsed)); 282 dprintf(("get_free_dma_pages: size=%x adr=%x (phys %x) total alloc size=%x", 283 size, (ULONG)addr, virt_to_phys((void *)addr), ulget_free_pagesMemUsed)); 284 284 } 285 285 … … 354 354 } 355 355 if(addr) { 356 dprintf(("get_free_pages %d (%d) -> %x (phys %x)", allocsize, size, (ULONG)addr, virt_to_phys((void *)addr)));356 //dprintf(("get_free_pages %d (%d) -> %x (phys %x)", allocsize, size, (ULONG)addr, virt_to_phys((void *)addr))); 357 357 ulget_free_pagesMemUsed += allocsize; 358 dprintf(("get_free_pages: total alloc size %d", ulget_free_pagesMemUsed));358 //dprintf(("get_free_pages: total alloc size %d", ulget_free_pagesMemUsed)); 359 359 } 360 360 return (void *)addr; … … 373 373 } 374 374 else { 375 dprintf(("free_pages %x size %d", (ULONG)addr, size));375 //dprintf(("free_pages %x size %d", (ULONG)addr, size)); 376 376 ulget_free_pagesMemUsed -= size; 377 dprintf(("free_pages: total alloc size %d", ulget_free_pagesMemUsed));377 //dprintf(("free_pages: total alloc size %d", ulget_free_pagesMemUsed)); 378 378 } 379 379 //dprintf(("free_pages %x", addr)); -
GPL/trunk/lib32/misc.c
r505 r518 40 40 #include <dbgos2.h> 41 41 42 void StringOut(char *DbgStr); 43 42 44 struct new_utsname system_utsname = {0}; 43 45 struct resource ioport_resource = {NULL, 0, 0, IORESOURCE_IO, NULL, NULL, NULL}; … … 75 77 } 76 78 77 dprintf( (pszLastALSAError) ); 79 StringOut(pszLastALSAError); 80 // rprintf( (pszLastALSAError) ); 78 81 if(++iLastError > 1) { 79 82 iLastError = 0; … … 406 409 //****************************************************************************** 407 410 //****************************************************************************** 411 #define del_timer_sync(t) del_timer(t) /* FIXME: not quite correct on SMP */ 412 int cancel_delayed_work(struct delayed_work *dwork) 413 { 414 struct work_struct *work = &dwork->work; 415 int ret; 416 417 ret = del_timer_sync(&work->timer); 418 if (ret) 419 clear_bit(0, &work->pending); 420 return ret; 421 } 422 //****************************************************************************** 423 //****************************************************************************** 424 int schedule_work(struct work_struct *works) 425 { 426 #ifndef TARGET_OS2 427 return kernel_thread(work_caller, works, 0) >= 0; 428 #else 429 return 1; 430 #endif 431 } 432 //****************************************************************************** 433 //****************************************************************************** 434 static void delayed_work_timer_fn(unsigned long __data) 435 { 436 struct work_struct *work = (struct work_struct *)__data; 437 struct workqueue_struct *wq = work->wq_data; 438 439 if (wq) 440 __x_queue_work(wq, work); 441 else 442 schedule_work(work); 443 } 444 //****************************************************************************** 445 //****************************************************************************** 446 int queue_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork, unsigned long delay) 447 { 448 struct work_struct *work = &dwork->work; 449 struct timer_list *timer = &work->timer; 450 451 if (!test_and_set_bit(0, &work->pending)) { 452 work->wq_data = wq; 453 timer->expires = jiffies + delay; 454 timer->data = (unsigned long)work; 455 timer->function = delayed_work_timer_fn; 456 add_timer(timer); 457 return 1; 458 } 459 return 0; 460 } 461 //****************************************************************************** 462 //****************************************************************************** 463 /* Greatest common divisor */ 464 unsigned long gcd(unsigned long a, unsigned long b) 465 { 466 unsigned long r; 467 if (a < b) { 468 r = a; 469 a = b; 470 b = r; 471 } 472 while ((r = a % b) != 0) { 473 a = b; 474 b = r; 475 } 476 return b; 477 } 478 479 //****************************************************************************** 480 //****************************************************************************** 481 int strict_strtoul(const char *cp, unsigned int base, unsigned long *res) 482 { 483 char *tail; 484 unsigned long val; 485 size_t len; 486 487 *res = 0; 488 len = strlen(cp); 489 if (len == 0) 490 return -EINVAL; 491 492 val = simple_strtoul(cp, &tail, base); 493 if (tail == cp) 494 return -EINVAL; 495 496 if ((*tail == '\0') || 497 ((len == (size_t)(tail - cp) + 1) && (*tail == '\n'))) { 498 *res = val; 499 return 0; 500 } 501 502 return -EINVAL; 503 } -
GPL/trunk/lib32/ossidc.cpp
r501 r518 24 24 25 25 #define INCL_NOPMAPI 26 #define INCL_DOSERRORS 26 #define INCL_DOSERRORS // for ERROR_INVALID_FUNCTION 27 27 #include <os2.h> 28 28 #include <ossdefos2.h> … … 45 45 BOOL CallOSS16(ULONG cmd, ULONG param1, ULONG param2) 46 46 { 47 BOOLrc;48 49 50 51 52 53 54 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 55 } 56 56 //****************************************************************************** 57 57 exitcall_t fnCardExitCall[OSS32_MAX_AUDIOCARDS] = {0}; 58 58 extern "C" { 59 #if 0 60 61 typedef int (initcall_tt)(void); 62 typedef void (exitcall_tt)(void); 59 60 /* this table should be discarded after init time */ 63 61 64 62 typedef struct cardcalls_t { 65 66 initcall_tt *cinitcall;67 exitcall_tt *cexitcall;63 int card_id; 64 initcall_t *cinitcall; 65 exitcall_t *cexitcall; 68 66 }cardcalls_t; 69 67 70 cardcalls_t cardcalls[1] = { 71 // { CARD_SBLIVE, name_module(alsa_card_emu10k1, _init, _exit) }, 72 { CARD_SBLIVE, __initcall_alsa_card_emu10k1_init, __exitcall_alsa_card_emu10k1_exit }, 73 /* 74 { CARD_CMEDIA, name_module(alsa_card_cmipci, _init, _exit) }, 75 { CARD_ALS4000, name_module(alsa_card_als4000, _init, _exit) }, 76 { CARD_CS4281, name_module(alsa_card_cs4281, _init, _exit) }, 77 { CARD_ICH, name_module(alsa_card_intel8x0, _init, _exit) }, 78 { CARD_CS46XX, name_module(alsa_card_cs46xx, _init, _exit) }, 79 { CARD_VIA82XX, name_module(alsa_card_via82xx, _init, _exit) }, 80 { CARD_ESS1938, name_module(alsa_card_es1938, _init, _exit) }, 81 // { CARD_VORTEX, name_module(alsa_card_vortex, _init, _exit) }, 82 { CARD_ENSONIQ, name_module(alsa_card_ens137x, _init, _exit) }, 83 { CARD_YAMAHA, name_module(alsa_card_ymfpci, _init, _exit) }, 84 { CARD_MAESTRO, name_module(alsa_card_es1968, _init, _exit) }, 85 { CARD_MAESTRO3, name_module(alsa_card_m3, _init, _exit) }, 86 { CARD_ALI5451, name_module(alsa_card_ali, _init, _exit) }, 87 { CARD_TRIDENT, name_module(alsa_card_trident, _init, _exit) }, 88 { CARD_NEOMAGIC, name_module(alsa_card_nm256, _init, _exit) }, 89 { CARD_ATIIXP, name_module(alsa_card_atiixp, _init, _exit) }, 90 { CARD_FM801, name_module(alsa_card_fm801, _init, _exit) }, 91 { CARD_AUDIGYLS, name_module(alsa_card_ca0106, _init, _exit) }, 92 { CARD_BT87X, name_module(alsa_card_bt87x, _init, _exit) }, 93 { CARD_AZX, name_module(alsa_card_azx, _init, _exit) }*/ 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) }, 94 95 }; 95 #endif 96 97 int nrCardsDetected = 0; 98 int fStrategyInit = FALSE; 96 97 int nrCardsDetected = 0; 98 int fStrategyInit = FALSE; 99 99 void pcm_info(void); 100 100 void FillCaps(ULONG deviceid); 101 101 }; 102 102 //****************************************************************************** 103 // This routine should be discarded after init time 103 104 OSSRET OSS32_Initialize(void) 104 105 { 105 fStrategyInit = TRUE; 106 107 if(DevSetTimer(TimerHandler16) != 0) { 108 dprintf(("DevSetTimer failed!!")); 109 DebugInt3(); 110 return OSSERR_INIT_FAILED; 111 } 112 rprintf(("\nUniaud version %s\n",UNIAUD_VERSION)); 113 dprintf(("OSS32_Initialize. Start address: %X", OffsetBeginCS32)); 114 //DebugInt3(); 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 dprintf(("OSS32_Initialize: ForceCard: %d",ForceCard)); 138 #if 0 139 int i; 140 141 if (ForceCard != CARD_NONE) 142 { 143 if (cardcalls[ForceCard].cinitcall() == 0) 144 fnCardExitCall[nrCardsDetected] = cardcalls[ForceCard].cexitcall; 145 for (i=0; i < CARDS_NUM; i++) 146 { 147 if (i==ForceCard) continue; 148 if (cardcalls[i].cinitcall() == 0) 149 fnCardExitCall[nrCardsDetected] = cardcalls[i].cexitcall; 150 if (nrCardsDetected >= OSS32_MAX_AUDIOCARDS) 151 break; 152 } 153 } else 154 { 155 for (i=0; i < CARDS_NUM; i++) 156 { 157 dprintf(("calling: %X at %X", i, cardcalls[i].cinitcall)); 158 if (cardcalls[i].cinitcall() == 0) 159 fnCardExitCall[nrCardsDetected] = cardcalls[i].cexitcall; 160 if (nrCardsDetected >= OSS32_MAX_AUDIOCARDS) 161 break; 162 } 163 } 164 #else 165 //Check for SoundBlaster Live! 166 if((ForceCard == CARD_NONE || ForceCard == CARD_ICH) && 167 nrCardsDetected < (OSS32_MAX_AUDIOCARDS-1) && call_module_init(alsa_card_intel8x0_init) == 0) 168 { 169 fnCardExitCall[nrCardsDetected] = name_module_exit(alsa_card_intel8x0_exit); 170 } 171 if((ForceCard == CARD_NONE || ForceCard == CARD_VIA82XX) && 172 nrCardsDetected < (OSS32_MAX_AUDIOCARDS-1) && call_module_init(alsa_card_via82xx_init) == 0) 173 { 174 fnCardExitCall[nrCardsDetected] = name_module_exit(alsa_card_via82xx_exit); 175 } 176 177 178 if((ForceCard == CARD_NONE || ForceCard == CARD_SBLIVE) && 179 nrCardsDetected < (OSS32_MAX_AUDIOCARDS-1) && call_module_init(alsa_card_emu10k1_init) == 0) 180 { 181 fnCardExitCall[nrCardsDetected] = name_module_exit(alsa_card_emu10k1_exit); 182 } 183 184 if((ForceCard == CARD_NONE || ForceCard == CARD_CMEDIA) && 185 nrCardsDetected < (OSS32_MAX_AUDIOCARDS-1) && call_module_init(alsa_card_cmipci_init) == 0) 186 { 187 fnCardExitCall[nrCardsDetected] = name_module_exit(alsa_card_cmipci_exit); 188 } 189 if((ForceCard == CARD_NONE || ForceCard == CARD_ALS4000) && 190 nrCardsDetected < (OSS32_MAX_AUDIOCARDS-1) && call_module_init(alsa_card_als4000_init) == 0) 191 { 192 fnCardExitCall[nrCardsDetected] = name_module_exit(alsa_card_als4000_exit); 193 } 194 if((ForceCard == CARD_NONE || ForceCard == CARD_CS4281) && 195 nrCardsDetected < (OSS32_MAX_AUDIOCARDS-1) && call_module_init(alsa_card_cs4281_init) == 0) 196 { 197 fnCardExitCall[nrCardsDetected] = name_module_exit(alsa_card_cs4281_exit); 198 } 199 if((ForceCard == CARD_NONE || ForceCard == CARD_CS46XX) && 200 nrCardsDetected < (OSS32_MAX_AUDIOCARDS-1) && call_module_init(alsa_card_cs46xx_init) == 0) 201 { 202 fnCardExitCall[nrCardsDetected] = name_module_exit(alsa_card_cs46xx_exit); 203 } 204 if((ForceCard == CARD_NONE || ForceCard == CARD_CS5535) && 205 nrCardsDetected < (OSS32_MAX_AUDIOCARDS-1) && call_module_init(alsa_card_cs5535audio_init) == 0) 206 { 207 fnCardExitCall[nrCardsDetected] = name_module_exit(alsa_card_cs5535audio_exit); 208 } 209 if((ForceCard == CARD_NONE || ForceCard == CARD_ESS1938) && 210 nrCardsDetected < (OSS32_MAX_AUDIOCARDS-1) && call_module_init(alsa_card_es1938_init) == 0) 211 { 212 fnCardExitCall[nrCardsDetected] = name_module_exit(alsa_card_es1938_exit); 213 } 214 if((ForceCard == CARD_NONE || ForceCard == CARD_ENSONIQ) && 215 nrCardsDetected < (OSS32_MAX_AUDIOCARDS-1) && call_module_init(alsa_card_ens137x_init) == 0) 216 { 217 fnCardExitCall[nrCardsDetected] = name_module_exit(alsa_card_ens137x_exit); 218 } 219 if((ForceCard == CARD_NONE || ForceCard == CARD_YAMAHA) && 220 nrCardsDetected < (OSS32_MAX_AUDIOCARDS-1) && call_module_init(alsa_card_ymfpci_init) == 0) 221 { 222 fnCardExitCall[nrCardsDetected] = name_module_exit(alsa_card_ymfpci_exit); 223 } 224 if((ForceCard == CARD_NONE || ForceCard == CARD_MAESTRO) && 225 nrCardsDetected < (OSS32_MAX_AUDIOCARDS-1) && call_module_init(alsa_card_es1968_init) == 0) 226 { 227 fnCardExitCall[nrCardsDetected] = name_module_exit(alsa_card_es1968_exit); 228 } 229 if((ForceCard == CARD_NONE || ForceCard == CARD_MAESTRO3) && 230 nrCardsDetected < (OSS32_MAX_AUDIOCARDS-1) && call_module_init(alsa_card_m3_init) == 0) 231 { 232 fnCardExitCall[nrCardsDetected] = name_module_exit(alsa_card_m3_exit); 233 } 234 if((ForceCard == CARD_NONE || ForceCard == CARD_ALI5451) && 235 nrCardsDetected < (OSS32_MAX_AUDIOCARDS-1) && call_module_init(alsa_card_ali_init) == 0) 236 { 237 fnCardExitCall[nrCardsDetected] = name_module_exit(alsa_card_ali_exit); 238 } 239 if((ForceCard == CARD_NONE || ForceCard == CARD_TRIDENT) && 240 nrCardsDetected < (OSS32_MAX_AUDIOCARDS-1) && call_module_init(alsa_card_trident_init) == 0) 241 { 242 fnCardExitCall[nrCardsDetected] = name_module_exit(alsa_card_trident_exit); 243 } 244 #ifdef VORTEX 245 if((ForceCard == CARD_NONE || ForceCard == CARD_VORTEX) && 246 nrCardsDetected < (OSS32_MAX_AUDIOCARDS-1) && call_module_init(alsa_card_vortex_init) == 0) 247 { 248 fnCardExitCall[nrCardsDetected] = name_module_exit(alsa_card_vortex_exit); 249 } 250 #endif 251 if((ForceCard == CARD_NONE || ForceCard == CARD_NEOMAGIC) && 252 nrCardsDetected < (OSS32_MAX_AUDIOCARDS-1) && call_module_init(alsa_card_nm256_init) == 0) 253 { 254 fnCardExitCall[nrCardsDetected] = name_module_exit(alsa_card_nm256_exit); 255 } 256 if((ForceCard == CARD_NONE || ForceCard == CARD_FM801) && 257 nrCardsDetected < (OSS32_MAX_AUDIOCARDS-1) && call_module_init(alsa_card_fm801_init) == 0) 258 { 259 fnCardExitCall[nrCardsDetected] = name_module_exit(alsa_card_fm801_exit); 260 } 261 if((ForceCard == CARD_NONE || ForceCard == CARD_ATIIXP) && 262 nrCardsDetected < (OSS32_MAX_AUDIOCARDS-1) && call_module_init(alsa_card_atiixp_init) == 0) 263 { 264 fnCardExitCall[nrCardsDetected] = name_module_exit(alsa_card_atiixp_exit); 265 } 266 if((ForceCard == CARD_NONE || ForceCard == CARD_AUDIGYLS) && 267 nrCardsDetected < (OSS32_MAX_AUDIOCARDS-1) && call_module_init(alsa_card_ca0106_init) == 0) 268 { 269 fnCardExitCall[nrCardsDetected] = name_module_exit(alsa_card_ca0106_exit); 270 } 271 if((ForceCard == CARD_NONE || ForceCard == CARD_AZX) && 272 nrCardsDetected < (OSS32_MAX_AUDIOCARDS-1) && call_module_init(alsa_card_azx_init) == 0) 273 { 274 fnCardExitCall[nrCardsDetected] = name_module_exit(alsa_card_azx_exit); 275 } 276 if((ForceCard == CARD_NONE || ForceCard == CARD_BT87X) && 277 nrCardsDetected < (OSS32_MAX_AUDIOCARDS-1) && call_module_init(alsa_card_bt87x_init) == 0) 278 { 279 fnCardExitCall[nrCardsDetected] = name_module_exit(alsa_card_bt87x_exit); 280 } 281 #endif 282 fStrategyInit = FALSE; 283 284 if(nrCardsDetected != 0) { 285 pcm_info(); 286 for(int i=0;i<nrCardsDetected;i++) { 287 FillCaps(i); 288 } 289 dprintf(("OSS32_Initialize: SUCCESS. Cards=%d", nrCardsDetected)); 290 return OSSERR_SUCCESS; 291 } 292 dprintf(("OSS32_Initialize. FAILED")); 293 return OSSERR_INIT_FAILED; 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 rprintf(("\nUniaud version %s\n",UNIAUD_VERSION)); 116 dprintf(("OSS32_Initialize. Start address: %X", OffsetBeginCS32)); 117 118 if(call_module_init(alsa_sound_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_opl3_seq_init) != 0) return OSSERR_INIT_FAILED; 128 129 if(call_module_init(alsa_mpu401_uart_init) != 0) return OSSERR_INIT_FAILED; 130 131 /* Init functions for HDA audio */ 132 call_module_init(patch_analog_init); 133 call_module_init(patch_atihdmi_init); 134 call_module_init(patch_cmedia_init); 135 call_module_init(patch_conexant_init); 136 call_module_init(patch_realtek_init); 137 call_module_init(patch_sigmatel_init); 138 call_module_init(patch_via_init); 139 140 dprintf(("OSS32_Initialize: ForceCard=%d", ForceCard)); 141 142 for (sI=0; sI<CARDS_NUM; sI++) { 143 if ((ForceCard != CARD_NONE) && (ForceCard != cardcalls[sI].card_id)) continue; 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 dprintf(("OSS32_Initialize: SUCCESS. Cards=%d", nrCardsDetected)); 165 return OSSERR_SUCCESS; 166 } 167 rprintf(("OSS32_Initialize. FAILED")); 168 return OSSERR_INIT_FAILED; 294 169 } 295 170 //****************************************************************************** … … 298 173 OSSRET OSS32_Shutdown() 299 174 { 300 CallOSS16(IDC16_EXIT, 0, 0); 301 302 for(int i=0;i<nrCardsDetected;i++) { 303 if(fnCardExitCall[i]) fnCardExitCall[i](); 304 } 305 306 call_module_exit(alsa_mpu401_uart_exit); 307 call_module_exit(alsa_opl3_seq_exit); 308 call_module_exit(alsa_opl3_exit); 309 call_module_exit(alsa_seq_exit); 310 call_module_exit(alsa_rawmidi_exit); 311 call_module_exit(alsa_timer_exit); 312 call_module_exit(alsa_hwdep_exit); 313 call_module_exit(alsa_pcm_exit); 314 call_module_exit(alsa_sound_exit); 315 316 return OSSERR_SUCCESS; 175 dprintf(("OSS32_Shutdown 1")); 176 CallOSS16(IDC16_EXIT, 0, 0); 177 dprintf(("OSS32_Shutdown 2")); 178 179 for(int i=0;i<nrCardsDetected;i++) { 180 if(fnCardExitCall[i]) fnCardExitCall[i](); 181 } 182 183 dprintf(("OSS32_Shutdown 3")); 184 call_module_exit(alsa_mpu401_uart_exit); 185 dprintf(("OSS32_Shutdown 4")); 186 call_module_exit(alsa_opl3_seq_exit); 187 dprintf(("OSS32_Shutdown 5")); 188 call_module_exit(alsa_opl3_exit); 189 dprintf(("OSS32_Shutdown 6")); 190 call_module_exit(alsa_seq_exit); 191 dprintf(("OSS32_Shutdown 7")); 192 call_module_exit(alsa_rawmidi_exit); 193 dprintf(("OSS32_Shutdown 8")); 194 call_module_exit(alsa_timer_exit); 195 dprintf(("OSS32_Shutdown 9")); 196 call_module_exit(alsa_hwdep_exit); 197 dprintf(("OSS32_Shutdown 10")); 198 call_module_exit(alsa_pcm_exit); 199 dprintf(("OSS32_Shutdown 11")); 200 call_module_exit(alsa_sound_exit); 201 dprintf(("OSS32_Shutdown 12")); 202 203 return OSSERR_SUCCESS; 317 204 } 318 205 //****************************************************************************** … … 320 207 int OSS32_ProcessIRQ() 321 208 { 322 209 return CallOSS16(IDC16_PROCESS, 0, 0); 323 210 } 324 211 325 212 int OSS32_ProcessMIDIIRQ(int bytes) 326 213 { 327 214 return CallOSS16(IDC16_MIDI_IRQ, bytes, 0); 328 215 } 329 216 330 217 int OSS32_CloseUNI16(void) 331 218 { 332 219 return CallOSS16(IDC16_CLOSE_UNI16, 0, 0); 333 220 } 334 221 //****************************************************************************** … … 336 223 int MyDevBlock(ULONG id, ULONG tout, char flag) 337 224 { 338 225 return DevBlock(id,tout, flag); 339 226 } 340 227 341 228 int OSS32_DebugString(char *buffer, ULONG size) 342 229 { 343 344 345 } 230 rprintf(("U16: %s", buffer)); 231 return size; 232 } -
GPL/trunk/lib32/pci.c
r458 r518 47 47 struct pci_bus pci_busses[MAX_PCI_BUSSES] = {0}; 48 48 49 BOOL 49 BOOL fSuspended = FALSE; 50 50 extern int nrCardsDetected; 51 51 52 52 53 #define PCI_CONFIG_ENABLE 54 #define PCI_CONFIG_ADDRESS 55 #define PCI_CONFIG_DATA 56 57 #ifdef ACPI 58 APIRET APIENTRY ACPIFindPCIDevice(ULONG Bus, ULONG Dev, ULONG Fun, ULONG *PicIRQ, ULONG *ApicIRQ, ULONG *Hdl, char *Component); 59 #endif 53 #define PCI_CONFIG_ENABLE 0x80000000 54 #define PCI_CONFIG_ADDRESS 0xCF8 55 #define PCI_CONFIG_DATA 0xCFC 56 57 #ifdef ACPI 58 APIRET APIENTRY ACPIFindPCIDevice(ULONG Bus, ULONG Dev, ULONG Fun, ULONG *PicIRQ, ULONG *ApicIRQ, ULONG *Hdl, char *Component); 59 #endif 60 60 61 61 //****************************************************************************** 62 62 #define CONFIG_CMD(dev, where) \ 63 63 (PCI_CONFIG_ENABLE | (dev->bus->number<<16) | (dev->devfn<<8) | (where & ~3)) 64 64 //****************************************************************************** 65 65 int pci_read_config_byte(struct pci_dev *dev, int where, u8 *value) 66 66 { 67 68 69 67 outl(CONFIG_CMD(dev,where), PCI_CONFIG_ADDRESS); 68 *value = inb(PCI_CONFIG_DATA + (where&3)); 69 return PCIBIOS_SUCCESSFUL; 70 70 } 71 71 //****************************************************************************** … … 73 73 int pci_read_config_word(struct pci_dev *dev, int where, u16 *value) 74 74 { 75 76 77 75 outl(CONFIG_CMD(dev,where), PCI_CONFIG_ADDRESS); 76 *value = inw(PCI_CONFIG_DATA + (where&2)); 77 return PCIBIOS_SUCCESSFUL; 78 78 } 79 79 //****************************************************************************** … … 81 81 int pci_read_config_dword(struct pci_dev *dev, int where, u32 *value) 82 82 { 83 84 85 83 outl(CONFIG_CMD(dev,where), PCI_CONFIG_ADDRESS); 84 *value = inl(PCI_CONFIG_DATA); 85 return PCIBIOS_SUCCESSFUL; 86 86 } 87 87 //****************************************************************************** … … 89 89 int pci_write_config_byte(struct pci_dev *dev, int where, u8 value) 90 90 { 91 92 93 91 outl(CONFIG_CMD(dev,where), PCI_CONFIG_ADDRESS); 92 outb(value, PCI_CONFIG_DATA + (where&3)); 93 return PCIBIOS_SUCCESSFUL; 94 94 } 95 95 //****************************************************************************** … … 97 97 int pci_write_config_word(struct pci_dev *dev, int where, u16 value) 98 98 { 99 100 101 99 outl(CONFIG_CMD(dev,where), PCI_CONFIG_ADDRESS); 100 outw(value, PCI_CONFIG_DATA + (where&2)); 101 return PCIBIOS_SUCCESSFUL; 102 102 } 103 103 //****************************************************************************** … … 105 105 int pci_write_config_dword(struct pci_dev *dev, int where, u32 value) 106 106 { 107 108 109 107 outl(CONFIG_CMD(dev,where), PCI_CONFIG_ADDRESS); 108 outl(value, PCI_CONFIG_DATA); 109 return PCIBIOS_SUCCESSFUL; 110 110 } 111 111 //****************************************************************************** … … 113 113 int pcidev_prepare(struct pci_dev *dev) 114 114 { 115 116 115 dprintf(("pcidev_prepare %x not implemented", dev)); 116 return 1; //todo: correct return value?? 117 117 } 118 118 //****************************************************************************** … … 120 120 int pcidev_activate(struct pci_dev *dev) 121 121 { 122 123 122 dprintf(("pcidev_activate %x not implemented", dev)); 123 return 1; //todo: correct return value?? 124 124 } 125 125 //****************************************************************************** … … 127 127 int pcidev_deactivate(struct pci_dev *dev) 128 128 { 129 130 131 } 132 133 134 135 //****************************************************************************** 136 //****************************************************************************** 137 #ifdef ACPI 129 dprintf(("pcidev_deactivate %x not implemented", dev)); 130 return 1; //todo: correct return value?? 131 } 132 133 134 135 //****************************************************************************** 136 //****************************************************************************** 137 #ifdef ACPI 138 138 struct SaveIRQForSlot 139 139 { 140 141 142 143 BYTE Pin; 140 ULONG ulSlotNo; 141 BYTE LowIRQ; 142 BYTE HighIRQ; 143 BYTE Pin; 144 144 }; 145 145 extern struct SaveIRQForSlot sISRHigh[]; 146 extern int 146 extern int SaveIRQCounter; 147 147 #endif 148 148 149 static int pci_query_device(unsigned int vendor, unsigned int device, 150 struct pci_dev near *pcidev, int idx)151 { 152 #ifdef ACPI 153 APIRET rc; 154 # endif155 int resNo, addr, found = 0;156 u32 devNr, busNr, funcNr, detectedId, pciId, cfgaddrreg, temp, temp2; 157 # ifdef ACPI158 ULONG temp1,temp3; //PS++ 159 #endif 160 u8 headerType;161 162 pciId = (device << 16) | vendor;163 164 cfgaddrreg = inl(PCI_CONFIG_ADDRESS); 165 for(busNr=0;busNr<MAX_PCI_BUSSES;busNr++) //BusNumber<255 166 { 167 for(devNr=0;devNr<32;devNr++) 168 169 for(funcNr=0;funcNr<8;funcNr++) 170 { 171 headerType = 0;172 temp = PCI_CONFIG_ENABLE | (busNr<<16) | (devNr<<11) | (funcNr<<8);173 outl(temp, PCI_CONFIG_ADDRESS); 174 detectedId = inl(PCI_CONFIG_DATA); 175 if( detectedId != 0xffffffff ) 176 { 177 outl(temp | (PCI_HEADER_TYPE & ~3), PCI_CONFIG_ADDRESS); 178 headerType = inb(PCI_CONFIG_DATA + (PCI_HEADER_TYPE & 3)); 179 } 180 // printk("det: %x (%x), need: %x\n", detectedId, headerType, pciId); 181 182 if( detectedId == pciId && 183 (headerType & 0x7f) == PCI_HEADER_TYPE_NORMAL ) 184 185 if( found++ == idx ) 186 187 memset((void near *)pcidev, 0, sizeof(struct pci_dev));188 189 pcidev->vendor = vendor; 190 pcidev->device = device;191 pcidev->bus = &pci_busses[busNr];192 pcidev->bus->number = busNr; 193 pcidev->devfn = (devNr << 3) | funcNr;194 pcidev->hdr_type = headerType & 0x7f;195 196 pcidev->prepare = pcidev_prepare;197 pcidev->activate = pcidev_activate; 198 pcidev->deactivate = pcidev_deactivate;199 pcidev->active = 1; 200 pcidev->ro = 0;201 pcidev->sibling = NULL;202 pcidev->next = NULL;203 pcidev->dma_mask = 0xFFFFFFFF;204 205 // Subsystem ID 206 pci_read_config_word(pcidev, PCI_SUBSYSTEM_VENDOR_ID, 207 &pcidev->subsystem_vendor);208 pci_read_config_word(pcidev, PCI_SUBSYSTEM_ID, 209 &pcidev->subsystem_device);210 211 // I/O and MEM 212 resNo = 0;213 for( addr = PCI_BASE_ADDRESS_0; addr <= PCI_BASE_ADDRESS_5; addr += 4 ) 214 { 215 pci_read_config_dword(pcidev, addr, &temp); 216 if( temp != 0 && temp != 0xffffffff ) 217 { 218 pci_write_config_dword(pcidev, addr, 0xffffffff);219 pci_read_config_dword(pcidev, addr, &temp2); 220 pci_write_config_dword(pcidev, addr, temp); 221 222 if( temp & PCI_BASE_ADDRESS_SPACE_IO ) 223 { 224 pcidev->resource[resNo].flags = IORESOURCE_IO | PCI_BASE_ADDRESS_SPACE_IO; 225 pcidev->resource[resNo].start = temp & PCI_BASE_ADDRESS_IO_MASK;226 pcidev->resource[resNo].end = pcidev->resource[resNo].start + 227 ~(temp2 & PCI_BASE_ADDRESS_IO_MASK) + 1;228 } 229 else 230 { 231 pcidev->resource[resNo].flags = IORESOURCE_MEM | IORESOURCE_MEM_WRITEABLE;232 pcidev->resource[resNo].start = temp & PCI_BASE_ADDRESS_MEM_MASK; 233 pcidev->resource[resNo].end = pcidev->resource[resNo].start + 234 ~(temp2 & PCI_BASE_ADDRESS_MEM_MASK) + 1; 235 } 236 237 resNo++;238 239 } 240 } 241 242 // IRQ and PIN 243 pci_read_config_dword(pcidev, PCI_INTERRUPT_LINE, &temp);244 #ifdef ACPI 245 sISRHigh[SaveIRQCounter].Pin = (temp >> 8) & 0xf; 246 temp2 = temp3 = 0; 247 rc = ACPIFindPCIDevice( (ULONG)busNr, // Bus 248 (ULONG)devNr, // Dev 249 (ULONG)(pcidev->devfn >> 8) & 7, // Function 250 &temp1, // PIC IRQ 251 &temp3, // APIC IRQ 252 NULL, // ACPI handle to finding device 253 "Uniaud32"); // Name for acpi log 254 if (!rc) 255 { 256 // Check APIC IRQ, if we have /SMP /APIC, must be set 257 if (temp1) 258 temp = (temp & (~0xff)) | (temp1 & 0xff); 259 // Check PIC IRQ 260 else if (temp3) 261 temp = (temp & (~0xff)) | (temp3 & 0xff); 262 dprintf(("pci_query_device: IRQs ACPI PIC%d APIC%d", temp1, temp3)); 263 sISRHigh[SaveIRQCounter].LowIRQ = temp1; 264 sISRHigh[SaveIRQCounter].HighIRQ = temp3;265 } 266 #endif /* ACPI */ 267 if( (u8)temp && (u8)temp != 0xff ) 268 { 269 pcidev->irq_resource[0].flags = IORESOURCE_IRQ; 270 pcidev->irq_resource[0].start = 271 pcidev->irq_resource[0].end = temp & 0xffff;272 pcidev->irq = (u8)temp;273 } 274 275 return 1; 276 } 277 } 278 279 // don't need to check more, if function 0 not present or single 280 if( funcNr == 0 && !(headerType & 0x80) ) break;281 282 } 283 } 284 outl(cfgaddrreg, PCI_CONFIG_ADDRESS); 285 return 0; 286 287 } 288 289 // ******************************************************************************290 // ******************************************************************************149 //Find the next matching PCI device starting with the device specified by pcidev 150 static ULONG pci_query_device(const struct pci_device_id *id_table, struct pci_dev near *pcidev, ULONG ulLast) 151 { 152 int resNo, addr; 153 u32 devNr, busNr, funcNr, detectedId, cfgaddrreg, temp, temp2; 154 #ifdef ACPI 155 APIRET rc; 156 ULONG temp1,temp3; //PS++ 157 #endif 158 u8 headerType; 159 160 busNr = (ulLast >> 8) & 0x1f; 161 devNr = PCI_SLOT(ulLast); 162 funcNr = PCI_FUNC(ulLast); 163 if (ulLast) funcNr++; 164 165 cfgaddrreg = inl(PCI_CONFIG_ADDRESS); 166 for(;busNr<MAX_PCI_BUSSES;busNr++) { //BusNumber<255 167 for(;devNr<32;devNr++) { 168 for(;funcNr<8;funcNr++) { 169 headerType = 0; 170 temp = PCI_CONFIG_ENABLE | (busNr<<16) | (devNr<<11) | (funcNr<<8); 171 outl(temp, PCI_CONFIG_ADDRESS); 172 detectedId = inl(PCI_CONFIG_DATA); 173 174 if ( detectedId == 0xffffffff ) { 175 if ( funcNr == 0 ) break; /* if func 0 isn't there, the others aren't either */ 176 continue; 177 } 178 179 outl(temp + PCI_CLASS_REVISION, PCI_CONFIG_ADDRESS); 180 temp2 = inl(PCI_CONFIG_DATA) >> 8; /* get class */ 181 182 //dprintf(("det=%x(%x) %x need=%x%x %x", detectedId, headerType, temp2, id_table->device&0xffff, id_table->vendor, id_table->class)); 183 184 if ( id_table->class ) { 185 if ( (temp2 & id_table->class_mask) != id_table->class ) continue; 186 } else { 187 if ( (id_table->device == PCI_ANY_ID) && ((temp2 >> 8) != PCI_CLASS_MULTIMEDIA_AUDIO) ) continue; 188 } 189 190 if (id_table->vendor != (detectedId & 0xffff)) continue; 191 if ( (id_table->device != PCI_ANY_ID) && (id_table->device != (detectedId >> 16)) ) continue; 192 193 outl(temp | (PCI_HEADER_TYPE & ~3), PCI_CONFIG_ADDRESS); 194 headerType = inb(PCI_CONFIG_DATA + (PCI_HEADER_TYPE & 3)); 195 196 if ( (headerType & 0x7f) != PCI_HEADER_TYPE_NORMAL ) continue; 197 198 memset((void near *)pcidev, 0, sizeof(struct pci_dev)); 199 200 pcidev->vendor = detectedId & 0xffff; 201 pcidev->device = detectedId >> 16; 202 pcidev->bus = &pci_busses[busNr]; 203 pcidev->bus->number = busNr; 204 pcidev->devfn = PCI_DEVFN(devNr, funcNr); 205 pcidev->hdr_type = headerType & 0x7f; 206 207 pcidev->prepare = pcidev_prepare; 208 pcidev->activate = pcidev_activate; 209 pcidev->deactivate = pcidev_deactivate; 210 pcidev->active = 1; 211 pcidev->ro = 0; 212 pcidev->sibling = NULL; 213 pcidev->next = NULL; 214 pcidev->dma_mask = 0xFFFFFFFF; 215 216 // Subsystem ID 217 pci_read_config_word(pcidev, PCI_SUBSYSTEM_VENDOR_ID, &pcidev->subsystem_vendor); 218 pci_read_config_word(pcidev, PCI_SUBSYSTEM_ID, &pcidev->subsystem_device); 219 220 // I/O and MEM 221 resNo = 0; 222 for( addr = PCI_BASE_ADDRESS_0; addr <= PCI_BASE_ADDRESS_5; addr += 4 ) { 223 pci_read_config_dword(pcidev, addr, &temp); 224 if( temp != 0 && temp != 0xffffffff ) { 225 pci_write_config_dword(pcidev, addr, 0xffffffff); 226 pci_read_config_dword(pcidev, addr, &temp2); 227 pci_write_config_dword(pcidev, addr, temp); 228 229 if( temp & PCI_BASE_ADDRESS_SPACE_IO ) { 230 pcidev->resource[resNo].flags = IORESOURCE_IO | PCI_BASE_ADDRESS_SPACE_IO; 231 pcidev->resource[resNo].start = temp & PCI_BASE_ADDRESS_IO_MASK; 232 pcidev->resource[resNo].end = pcidev->resource[resNo].start + 233 ~(temp2 & PCI_BASE_ADDRESS_IO_MASK) + 1; 234 } 235 else 236 { 237 pcidev->resource[resNo].flags = IORESOURCE_MEM | IORESOURCE_MEM_WRITEABLE; 238 pcidev->resource[resNo].start = temp & PCI_BASE_ADDRESS_MEM_MASK; 239 pcidev->resource[resNo].end = pcidev->resource[resNo].start + 240 ~(temp2 & PCI_BASE_ADDRESS_MEM_MASK) + 1; 241 } 242 243 resNo++; 244 245 } 246 } 247 248 // IRQ and PIN 249 pci_read_config_dword(pcidev, PCI_INTERRUPT_LINE, &temp); 250 #ifdef ACPI 251 sISRHigh[SaveIRQCounter].Pin = (temp >> 8) & 0xf; 252 temp2 = temp3 = 0; 253 rc = ACPIFindPCIDevice( (ULONG)busNr, // Bus 254 (ULONG)devNr, // Dev 255 (ULONG)(pcidev->devfn >> 8) & 7, // Function 256 &temp1, // PIC IRQ 257 &temp3, // APIC IRQ 258 NULL, // ACPI handle to finding device 259 "Uniaud32"); // Name for acpi log 260 if (!rc) { 261 // Check APIC IRQ, if we have /SMP /APIC, must be set 262 if (temp1) temp = (temp & (~0xff)) | (temp1 & 0xff); 263 // Check PIC IRQ 264 else if (temp3) temp = (temp & (~0xff)) | (temp3 & 0xff); 265 dprintf(("pci_query_device: IRQs ACPI PIC%d APIC%d", temp1, temp3)); 266 sISRHigh[SaveIRQCounter].LowIRQ = temp1; 267 sISRHigh[SaveIRQCounter].HighIRQ = temp3; 268 } 269 #endif /* ACPI */ 270 if( (u8)temp && (u8)temp != 0xff ) { 271 pcidev->irq_resource[0].flags = IORESOURCE_IRQ; 272 pcidev->irq_resource[0].start = pcidev->irq_resource[0].end = temp & 0xffff; 273 pcidev->irq = (u8)temp; 274 } 275 276 return (0x8000 | (busNr << 8) | PCI_DEVFN(devNr, funcNr)); 277 } /* for funcNr */ 278 funcNr = 0; 279 } /* for devNr */ 280 devNr = 0; 281 } 282 outl(cfgaddrreg, PCI_CONFIG_ADDRESS); 283 return 0; 284 } 285 286 //****************************************************************************** 287 //****************************************************************************** 288 // Called from: 289 //if from==NULL search pci bus 290 //if from!=NULL only search already found devices starting with from 291 291 struct pci_dev *pci_find_device (unsigned int vendor, unsigned int device, struct pci_dev *from) 292 292 { 293 int i, idx; 294 295 if((int)from < 8) { 296 idx = (int)from; // dirty hack 297 // return 0; 298 } else 299 idx = 0; 300 301 for(i=0;i<MAX_PCI_DEVICES;i++) 302 { 303 if(pci_devices[i].devfn == 0) 304 { 305 if( pci_query_device(vendor, device, (struct pci_dev near *)&pci_devices[i], idx) ) 306 return &pci_devices[i]; 307 else 308 break; 309 } 310 } 311 312 return NULL; 293 int i; 294 struct pci_device_id id_table; 295 296 for(i=0;i<MAX_PCI_DEVICES;i++) { 297 if ( pci_devices[i].devfn && (pci_devices[i].vendor == vendor) && (pci_devices[i].device == device) ) return &pci_devices[i]; 298 } 299 300 for(i=0;i<MAX_PCI_DEVICES;i++) { 301 if(pci_devices[i].devfn == 0) { 302 memset(&id_table, 0, sizeof(id_table)); 303 id_table.vendor = vendor; 304 id_table.device = device; 305 if( pci_query_device(&id_table, (struct pci_dev near *)&pci_devices[i], 0) ) return &pci_devices[i]; 306 else break; 307 } 308 } 309 310 return NULL; 313 311 } 314 312 //****************************************************************************** 315 313 //****************************************************************************** 316 314 struct resource * __request_region(struct resource *a, unsigned long start, 317 318 { 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 resource->name= name;338 339 resource->end= start + n; // - 1;340 341 342 343 344 345 346 347 348 315 unsigned long n, const char *name) 316 { 317 struct resource *resource; 318 319 if(a->flags & IORESOURCE_MEM) { 320 if(RMRequestMem(/*hResMgr,*/ start, n) == FALSE) { 321 printk("RMRequestIO failed for io %x, length %x\n", start, n); 322 return NULL; 323 } 324 } 325 else if(a->flags & IORESOURCE_IO) { 326 if(RMRequestIO(/*hResMgr,*/ start, n) == FALSE) { 327 printk("RMRequestIO failed for io %x, length %x\n", start, n); 328 return NULL; 329 } 330 } 331 332 resource = kmalloc(sizeof(struct resource), GFP_KERNEL); 333 if (resource == NULL) 334 return NULL; 335 resource->name = name; 336 resource->start = start; 337 resource->end = start + n; // - 1; 338 resource->flags = a->flags; 339 resource->parent = 340 resource->child = NULL; 341 342 // insert in list 343 resource->sibling = a->sibling; 344 a->sibling = resource; 345 346 return resource; 349 347 } 350 348 //****************************************************************************** 351 349 //****************************************************************************** 352 350 void __release_region(struct resource *a, 353 354 { 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 351 unsigned long start, unsigned long n) 352 { 353 struct resource *resource; 354 struct resource **ppres = &a->sibling; 355 unsigned long end = start + n; // - 1; 356 357 while( *ppres ) 358 { 359 resource = *ppres; 360 361 if( resource->start == start && resource->end == end ) 362 { 363 // remove from list 364 *ppres = resource->sibling; 365 kfree(resource); 366 return; 367 } 368 369 ppres = &resource->sibling; 370 } 373 371 } 374 372 //****************************************************************************** … … 376 374 int pci_get_flags (struct pci_dev *dev, int n_base) 377 375 { 378 379 380 381 382 376 if(n_base >= DEVICE_COUNT_RESOURCE || !dev->resource[n_base].flags) { 377 DebugInt3(); 378 return 0; 379 } 380 return dev->resource[n_base].flags; 383 381 } 384 382 //****************************************************************************** … … 386 384 int pcibios_present(void) 387 385 { 388 389 386 printk("pcibios_present -> pretend BIOS present\n"); 387 return 1; 390 388 } 391 389 //****************************************************************************** … … 393 391 struct pci_dev *pci_find_slot (unsigned int bus, unsigned int devfn) 394 392 { 395 396 397 393 printk("pci_find_slot %d %x not implemented!!\n", bus, devfn); 394 DebugInt3(); 395 return NULL; 398 396 } 399 397 //****************************************************************************** … … 401 399 int pci_dma_supported(struct pci_dev *dev, unsigned long mask) 402 400 { 403 404 401 printk("pci_dma_supported: return TRUE\n"); 402 return 1; 405 403 } 406 404 //****************************************************************************** … … 408 406 int pci_find_capability(struct pci_dev *dev, int cap) 409 407 { 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 408 u16 status; 409 u8 pos, id; 410 int ttl = 48; 411 412 pci_read_config_word(dev, PCI_STATUS, &status); 413 if (!(status & PCI_STATUS_CAP_LIST)) 414 return 0; 415 pci_read_config_byte(dev, PCI_CAPABILITY_LIST, &pos); 416 while (ttl-- && pos >= 0x40) { 417 pos &= ~3; 418 pci_read_config_byte(dev, pos + PCI_CAP_LIST_ID, &id); 419 if (id == 0xff) 420 break; 421 if (id == cap) 422 return pos; 423 pci_read_config_byte(dev, pos + PCI_CAP_LIST_NEXT, &pos); 424 } 425 return 0; 428 426 } 429 427 //****************************************************************************** 430 428 /* 431 * 432 * 433 * 429 * Set power management state of a device. For transitions from state D3 430 * it isn't as straightforward as one could assume since many devices forget 431 * their configuration space during wakeup. Returns old power state. 434 432 */ 435 433 //****************************************************************************** 436 434 int pci_set_power_state(struct pci_dev *dev, int new_state) 437 435 { 438 439 440 u8pci_latency, pci_cacheline;441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 436 u32 base[5], romaddr; 437 u16 pci_command, pwr_command; 438 u8 pci_latency, pci_cacheline; 439 int i, old_state; 440 int pm = pci_find_capability(dev, PCI_CAP_ID_PM); 441 442 if (!pm) 443 return 0; 444 pci_read_config_word(dev, pm + PCI_PM_CTRL, &pwr_command); 445 old_state = pwr_command & PCI_PM_CTRL_STATE_MASK; 446 if (old_state == new_state) 447 return old_state; 448 if (old_state == 3) { 449 pci_read_config_word(dev, PCI_COMMAND, &pci_command); 450 pci_write_config_word(dev, PCI_COMMAND, pci_command & ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY)); 451 for (i = 0; i < 5; i++) 452 pci_read_config_dword(dev, PCI_BASE_ADDRESS_0 + i*4, &base[i]); 453 pci_read_config_dword(dev, PCI_ROM_ADDRESS, &romaddr); 454 pci_read_config_byte(dev, PCI_LATENCY_TIMER, &pci_latency); 455 pci_read_config_byte(dev, PCI_CACHE_LINE_SIZE, &pci_cacheline); 456 pci_write_config_word(dev, pm + PCI_PM_CTRL, new_state); 457 for (i = 0; i < 5; i++) 458 pci_write_config_dword(dev, PCI_BASE_ADDRESS_0 + i*4, base[i]); 459 pci_write_config_dword(dev, PCI_ROM_ADDRESS, romaddr); 460 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq); 461 pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, pci_cacheline); 462 pci_write_config_byte(dev, PCI_LATENCY_TIMER, pci_latency); 463 pci_write_config_word(dev, PCI_COMMAND, pci_command); 464 } else 465 pci_write_config_word(dev, pm + PCI_PM_CTRL, (pwr_command & ~PCI_PM_CTRL_STATE_MASK) | new_state); 466 return old_state; 469 467 } 470 468 //****************************************************************************** 471 469 /* 472 * 473 * 474 * 470 * Initialize device before it's used by a driver. Ask low-level code 471 * to enable I/O and memory. Wake up the device if it was suspended. 472 * Beware, this function can fail. 475 473 */ 476 474 //****************************************************************************** 477 475 int pci_enable_device(struct pci_dev *dev) 478 476 { 479 480 481 printk("pci_enable_device %x\n", dev);482 483 484 485 486 477 u16 pci_command; 478 479 dprintf(("pci_enable_device %x\n", dev)); 480 481 pci_read_config_word(dev, PCI_COMMAND, &pci_command); 482 pci_write_config_word(dev, PCI_COMMAND, pci_command | (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)); 483 pci_set_power_state(dev, 0); 484 return 0; 487 485 } 488 486 //****************************************************************************** … … 490 488 int pci_register_driver(struct pci_driver *driver) 491 489 { 492 int i, j, dev_num; 493 struct pci_dev *pcidev; 494 495 for( i = 0; driver->id_table[i].vendor; i++) 496 { 497 dev_num = 0; 498 while( (pcidev = pci_find_device(driver->id_table[i].vendor, 499 driver->id_table[i].device, 500 (struct pci_dev *)dev_num)) != NULL ) 501 { 502 RMInit(); 503 if( driver->probe) { 504 printk("found: %x, id: %x idx %i\n",driver->id_table[i].vendor, driver->id_table[i].device, dev_num); 505 506 if(driver->probe(pcidev, &driver->id_table[i]) == 0) { 507 pcidev->pcidriver = (void *)driver; 508 pcidev->current_state = 4; 509 510 // create adapter 511 RMDone((driver->id_table[i].device << 16) | driver->id_table[i].vendor); 512 nrCardsDetected++; 513 } 514 else pcidev->devfn = 0; 515 } 516 517 RMDone(0); 518 519 dev_num++; 520 521 } 522 } 523 if (nrCardsDetected >=1) 524 return 1; 525 526 return 0; 490 int iTableIx, iNumCards, iTmp; 491 ULONG ulLast; 492 struct pci_dev *pcidev; 493 494 if (!driver->probe) return 0; 495 496 iNumCards = 0; 497 498 /* find an empty slot */ 499 for (iTmp=0; iTmp<MAX_PCI_DEVICES; iTmp++) { 500 if (pci_devices[iTmp].devfn == 0) break; 501 } 502 if (iTmp >= MAX_PCI_DEVICES) return 0; 503 pcidev = &pci_devices[iTmp]; 504 505 for( iTableIx = 0; driver->id_table[iTableIx].vendor; iTableIx++) { 506 ulLast = 0; 507 while( (ulLast = pci_query_device(&driver->id_table[iTableIx], pcidev, ulLast)) ) { 508 509 510 RMInit(); 511 dprintf(("pci_register_driver: found=%x:%x searching for %x:%x\n", 512 pcidev->vendor, pcidev->device, driver->id_table[iTableIx].vendor, driver->id_table[iTableIx].device)); 513 514 if(driver->probe(pcidev, &driver->id_table[iTableIx]) == 0) { 515 pcidev->pcidriver = (void *)driver; 516 pcidev->current_state = 4; 517 518 // create adapter 519 RMDone((pcidev->device << 16) | pcidev->vendor); 520 iNumCards++; 521 522 /* find another empty slot */ 523 for (iTmp=0; iTmp<MAX_PCI_DEVICES; iTmp++) { 524 if (pci_devices[iTmp].devfn == 0) break; 525 } 526 if (iTmp >= MAX_PCI_DEVICES) break; 527 pcidev = &pci_devices[iTmp]; 528 } else pcidev->devfn = 0; 529 530 RMDone(0); 531 } 532 } 533 534 return iNumCards; 527 535 } 528 536 //****************************************************************************** … … 530 538 int pci_module_init(struct pci_driver *drv) 531 539 { 532 int res = pci_register_driver(drv); 533 if (res < 0) 534 return res; 535 if (res == 0) 536 return -ENODEV; 537 return 0; 540 int res = pci_register_driver(drv); 541 if (res == 0) return -ENODEV; 542 return res; 538 543 } 539 544 //****************************************************************************** … … 541 546 int pci_unregister_driver(struct pci_driver *driver) 542 547 { 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 548 struct pci_dev *pcidev; 549 int i = 0, j; 550 551 while(driver->id_table[i].vendor) 552 { 553 for(j=0;j<MAX_PCI_DEVICES;j++) 554 { 555 if(pci_devices[j].vendor == driver->id_table[i].vendor && 556 pci_devices[j].device == driver->id_table[i].device) 557 { 558 if(driver->remove) { 559 driver->remove(&pci_devices[j]); 560 } 561 } 562 } 563 i++; 564 } 565 return 0; 561 566 } 562 567 //****************************************************************************** … … 564 569 void pci_set_master(struct pci_dev *dev) 565 570 { 566 567 568 569 570 571 572 573 574 571 u16 cmd; 572 573 pci_read_config_word(dev, PCI_COMMAND, &cmd); 574 if (! (cmd & PCI_COMMAND_MASTER)) { 575 dprintf(("pci_set_master %x", dev)); 576 cmd |= PCI_COMMAND_MASTER; 577 pci_write_config_word(dev, PCI_COMMAND, cmd); 578 } 579 return; 575 580 } 576 581 //****************************************************************************** … … 579 584 struct pm_dev *pm_register(pm_dev_t type, unsigned long id, pm_callback callback) 580 585 { 581 582 583 586 dprintf(("pm_register STUB")); 587 DebugInt3(); 588 return NULL; 584 589 } 585 590 //****************************************************************************** … … 588 593 void pm_unregister(struct pm_dev *dev) 589 594 { 590 595 dprintf(("pm_unregister STUB")); 591 596 } 592 597 //****************************************************************************** … … 594 599 int __compat_get_order(unsigned long size) 595 600 { 596 597 598 599 600 601 602 603 604 601 int order; 602 603 size = (size-1) >> (PAGE_SHIFT-1); 604 order = -1; 605 do { 606 size >>= 1; 607 order++; 608 } while (size); 609 return order; 605 610 } 606 611 //****************************************************************************** 607 612 //****************************************************************************** 608 613 void *pci_alloc_consistent(struct pci_dev *hwdev, 609 long size, dma_addr_t *dma_handle) 610 { 611 void *ret = NULL; 612 int gfp = GFP_ATOMIC; 613 int order; 614 #ifdef DEBUG 615 dprintf(("pci_alloc_consistent %d mask %x", size, (hwdev) ? hwdev->dma_mask : 0)); 616 #endif 617 if (hwdev == NULL || hwdev->dma_mask != 0xffffffff) { 618 //try not to exhaust low memory (< 16mb) so allocate from the high region first 619 //if that doesn't satisfy the dma mask requirement, then get it from the low 620 //regino anyway 621 if(hwdev->dma_mask > 0x00ffffff) { 622 order = __compat_get_order(size); 623 ret = (void *)__get_free_pages(gfp|GFP_DMAHIGHMEM, order); 624 *dma_handle = virt_to_bus(ret); 625 if(*dma_handle > hwdev->dma_mask) { 626 free_pages((unsigned long)ret, __compat_get_order(size)); 627 //be sure and allocate below 16 mb 628 gfp |= GFP_DMA; 629 ret = NULL; 630 } 631 } 632 else { //must always allocate below 16 mb 633 gfp |= GFP_DMA; 634 } 635 } 636 if(ret == NULL) { 637 ret = (void *)__get_free_pages(gfp, __compat_get_order(size)); 638 } 639 640 if (ret != NULL) { 641 memset(ret, 0, size); 642 *dma_handle = virt_to_bus(ret); 643 } 644 return ret; 614 long size, dma_addr_t *dma_handle) 615 { 616 void *ret = NULL; 617 int gfp = GFP_ATOMIC; 618 int order; 619 dprintf(("pci_alloc_consistent %d mask %x", size, (hwdev) ? hwdev->dma_mask : 0)); 620 if (hwdev == NULL || hwdev->dma_mask != 0xffffffff) { 621 //try not to exhaust low memory (< 16mb) so allocate from the high region first 622 //if that doesn't satisfy the dma mask requirement, then get it from the low 623 //regino anyway 624 if(hwdev->dma_mask > 0x00ffffff) { 625 order = __compat_get_order(size); 626 ret = (void *)__get_free_pages(gfp|GFP_DMAHIGHMEM, order); 627 *dma_handle = virt_to_bus(ret); 628 if(*dma_handle > hwdev->dma_mask) { 629 free_pages((unsigned long)ret, __compat_get_order(size)); 630 //be sure and allocate below 16 mb 631 gfp |= GFP_DMA; 632 ret = NULL; 633 } 634 } 635 else { //must always allocate below 16 mb 636 gfp |= GFP_DMA; 637 } 638 } 639 if(ret == NULL) { 640 ret = (void *)__get_free_pages(gfp, __compat_get_order(size)); 641 } 642 643 if (ret != NULL) { 644 memset(ret, 0, size); 645 *dma_handle = virt_to_bus(ret); 646 } 647 return ret; 645 648 } 646 649 //****************************************************************************** 647 650 //****************************************************************************** 648 651 void pci_free_consistent(struct pci_dev *hwdev, long size, 649 650 { 651 652 void *vaddr, dma_addr_t dma_handle) 653 { 654 free_pages((unsigned long)vaddr, __compat_get_order(size)); 652 655 } 653 656 //****************************************************************************** … … 655 658 void pci_set_driver_data (struct pci_dev *dev, void *driver_data) 656 659 { 657 658 660 if (dev) 661 dev->driver_data = driver_data; 659 662 } 660 663 //****************************************************************************** … … 662 665 void *pci_get_driver_data (struct pci_dev *dev) 663 666 { 664 665 666 667 if (dev) 668 return dev->driver_data; 669 return 0; 667 670 } 668 671 //****************************************************************************** … … 670 673 unsigned long pci_get_dma_mask (struct pci_dev *dev) 671 674 { 672 673 674 675 if (dev) 676 return dev->dma_mask; 677 return 0; 675 678 } 676 679 //****************************************************************************** … … 678 681 int release_resource(struct resource *newres) 679 682 { 680 683 return 0; 681 684 } 682 685 … … 685 688 int pci_set_latency_time(struct pci_dev *dev, int latency) 686 689 { 687 688 690 pci_write_config_byte(dev, PCI_LATENCY_TIMER, latency); 691 return 0; 689 692 } 690 693 … … 701 704 int pci_orig_save_state(struct pci_dev *dev, u32 *buffer) 702 705 { 703 704 705 706 707 708 709 706 int i; 707 if (buffer) { 708 /* XXX: 100% dword access ok here? */ 709 for (i = 0; i < 16; i++) 710 pci_read_config_dword(dev, i * 4,&buffer[i]); 711 } 712 return 0; 710 713 } 711 714 … … 719 722 pci_orig_restore_state(struct pci_dev *dev, u32 *buffer) 720 723 { 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 724 int i; 725 726 if (buffer) { 727 for (i = 0; i < 16; i++) 728 pci_write_config_dword(dev,i * 4, buffer[i]); 729 } 730 /* 731 * otherwise, write the context information we know from bootup. 732 * This works around a problem where warm-booting from Windows 733 * combined with a D3(hot)->D0 transition causes PCI config 734 * header data to be forgotten. 735 */ 736 else { 737 for (i = 0; i < 6; i ++) 738 pci_write_config_dword(dev, 739 PCI_BASE_ADDRESS_0 + (i * 4), 740 dev->resource[i].start); 741 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq); 742 } 743 return 0; 741 744 } 742 745 743 746 struct saved_config_tbl { 744 745 747 struct pci_dev *pci; 748 u32 config[16]; 746 749 }; 747 750 static struct saved_config_tbl saved_tbl[16]; … … 749 752 int pci_save_state(struct pci_dev *pci) 750 753 { 751 752 753 754 755 756 757 758 759 760 761 754 int i; 755 /* FIXME: mutex needed for race? */ 756 for (i = 0; i < ARRAY_SIZE(saved_tbl); i++) { 757 if (! saved_tbl[i].pci) { 758 saved_tbl[i].pci = pci; 759 pci_orig_save_state(pci, saved_tbl[i].config); 760 return 1; 761 } 762 } 763 printk(KERN_DEBUG "snd: no pci config space found!\n"); 764 return 0; 762 765 } 763 766 764 767 int pci_restore_state(struct pci_dev *pci) 765 768 { 766 767 768 769 770 771 772 773 774 775 776 769 int i; 770 /* FIXME: mutex needed for race? */ 771 for (i = 0; i < ARRAY_SIZE(saved_tbl); i++) { 772 if (saved_tbl[i].pci == pci) { 773 saved_tbl[i].pci = NULL; 774 pci_orig_restore_state(pci, saved_tbl[i].config); 775 return 0; 776 } 777 } 778 printk(KERN_DEBUG "snd: no saved pci config!\n"); 779 return 1; 777 780 } 778 781 779 782 void pci_disable_device(struct pci_dev *dev) 780 783 { 781 782 783 784 785 786 787 784 u16 pci_command; 785 786 pci_read_config_word(dev, PCI_COMMAND, &pci_command); 787 if (pci_command & PCI_COMMAND_MASTER) { 788 pci_command &= ~PCI_COMMAND_MASTER; 789 pci_write_config_word(dev, PCI_COMMAND, pci_command); 790 } 788 791 } 789 792 790 793 int pci_request_region(struct pci_dev *pdev, int bar, char *res_name) 791 794 { 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 795 int flags; 796 797 if (pci_resource_len(pdev, bar) == 0) 798 return 0; 799 flags = pci_get_flags(pdev, bar); 800 if (flags & IORESOURCE_IO) { 801 if (check_region(pci_resource_start(pdev, bar), pci_resource_len(pdev, bar))) 802 goto err_out; 803 request_region(pci_resource_start(pdev, bar), 804 pci_resource_len(pdev, bar), res_name); 805 } 806 else if (flags & IORESOURCE_MEM) { 807 if (check_mem_region(pci_resource_start(pdev, bar), pci_resource_len(pdev, bar))) 808 goto err_out; 809 request_mem_region(pci_resource_start(pdev, bar), 810 pci_resource_len(pdev, bar), res_name); 811 } 812 813 return 0; 811 814 812 815 err_out: 813 814 815 816 817 818 816 printk(KERN_WARNING "PCI: Unable to reserve %s region #%d:%lx@%lx for device %s\n", 817 flags & IORESOURCE_IO ? "I/O" : "mem", 818 bar + 1, /* PCI BAR # */ 819 pci_resource_len(pdev, bar), pci_resource_start(pdev, bar), 820 res_name); 821 return -EBUSY; 819 822 } 820 823 821 824 void pci_release_region(struct pci_dev *pdev, int bar) 822 825 { 823 824 825 826 827 828 829 830 831 832 833 834 835 826 int flags; 827 828 if (pci_resource_len(pdev, bar) == 0) 829 return; 830 flags = pci_get_flags(pdev, bar); 831 if (flags & IORESOURCE_IO) { 832 release_region(pci_resource_start(pdev, bar), 833 pci_resource_len(pdev, bar)); 834 } 835 else if (flags & IORESOURCE_MEM) { 836 release_mem_region(pci_resource_start(pdev, bar), 837 pci_resource_len(pdev, bar)); 838 } 836 839 } 837 840 838 841 int pci_request_regions(struct pci_dev *pdev, char *res_name) 839 842 { 840 841 842 843 844 845 846 847 848 849 843 int i; 844 845 for (i = 0; i < 6; i++) 846 if (pci_request_region(pdev, i, res_name)) 847 goto err; 848 return 0; 849 err: 850 while (--i >= 0) 851 pci_release_region(pdev, i); 852 return -EBUSY; 850 853 } 851 854 852 855 void pci_release_regions(struct pci_dev *pdev) 853 856 { 854 855 856 857 int i; 858 for (i = 0; i < 6; i++) 859 pci_release_region(pdev, i); 857 860 } 858 861 859 862 const struct pci_device_id * pci_match_device(const struct pci_device_id *ids, struct pci_dev *dev) 860 863 { 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 864 u16 subsystem_vendor, subsystem_device; 865 866 pci_read_config_word(dev, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vendor); 867 pci_read_config_word(dev, PCI_SUBSYSTEM_ID, &subsystem_device); 868 869 while (ids->vendor || ids->subvendor || ids->class_mask) { 870 if ((ids->vendor == PCI_ANY_ID || ids->vendor == dev->vendor) && 871 (ids->device == PCI_ANY_ID || ids->device == dev->device) && 872 (ids->subvendor == PCI_ANY_ID || ids->subvendor == subsystem_vendor) && 873 (ids->subdevice == PCI_ANY_ID || ids->subdevice == subsystem_device) && 874 !((ids->class ^ dev->_class) & ids->class_mask)) 875 return ids; 876 ids++; 877 } 878 return NULL; 876 879 } 877 880 878 881 int snd_pci_dev_present(const struct pci_device_id *ids) 879 882 { 880 881 882 883 884 885 883 while (ids->vendor || ids->subvendor) { 884 if (pci_find_device(ids->vendor, ids->subvendor, NULL)) 885 return 1; 886 ids++; 887 } 888 return 0; 886 889 } 887 890 888 891 struct pci_driver_mapping { 889 890 891 892 893 892 struct pci_dev *dev; 893 struct pci_driver *drv; 894 unsigned long dma_mask; 895 void *driver_data; 896 u32 saved_config[16]; 894 897 }; 895 898 … … 900 903 static struct pci_driver_mapping *get_pci_driver_mapping(struct pci_dev *dev) 901 904 { 902 903 904 905 906 907 905 int i; 906 907 for (i = 0; i < PCI_MAX_MAPPINGS; i++) 908 if (drvmap[i].dev == dev) 909 return &drvmap[i]; 910 return NULL; 908 911 } 909 912 910 913 struct pci_driver *snd_pci_compat_get_pci_driver(struct pci_dev *dev) 911 914 { 912 913 914 915 915 struct pci_driver_mapping *map = get_pci_driver_mapping(dev); 916 if (map) 917 return map->drv; 918 return NULL; 916 919 } 917 920 #if 0 918 921 void * pci_get_drvdata (struct pci_dev *dev) 919 922 { 920 921 922 923 923 struct pci_driver_mapping *map = get_pci_driver_mapping(dev); 924 if (map) 925 return map->driver_data; 926 return NULL; 924 927 } 925 928 … … 927 930 void pci_set_drvdata (struct pci_dev *dev, void *driver_data) 928 931 { 929 930 931 932 struct pci_driver_mapping *map = get_pci_driver_mapping(dev); 933 if (map) 934 map->driver_data = driver_data; 932 935 } 933 936 #endif … … 938 941 OSSRET OSS32_APMResume() 939 942 { 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 943 int i; 944 struct pci_driver *driver; 945 946 dprintf(("OSS32_APMResume")); 947 948 fSuspended = FALSE; 949 950 for(i=0;i<MAX_PCI_DEVICES;i++) 951 { 952 if(pci_devices[i].devfn) 953 { 954 driver = pci_devices[i].pcidriver; 955 if(driver && driver->resume) { 956 driver->resume(&pci_devices[i]); 957 } 958 } 959 } 960 961 return OSSERR_SUCCESS; 959 962 } 960 963 //****************************************************************************** … … 962 965 OSSRET OSS32_APMSuspend() 963 966 { 964 int i; 965 struct pci_driver *driver; 966 967 dprintf(("OSS32_APMSuspend")); 968 969 fSuspended = TRUE; 970 971 for(i=0;i<MAX_PCI_DEVICES;i++) 972 { 973 if(pci_devices[i].devfn) 974 { 975 driver = pci_devices[i].pcidriver; 976 if(driver && driver->suspend) { 977 driver->suspend(&pci_devices[i], SNDRV_CTL_POWER_D3cold); 978 } 979 } 980 } 981 982 return OSSERR_SUCCESS; 983 } 984 967 int i; 968 struct pci_driver *driver; 969 970 dprintf(("OSS32_APMSuspend 1")); 971 972 fSuspended = TRUE; 973 974 for(i=0;i<MAX_PCI_DEVICES;i++) 975 { 976 if(pci_devices[i].devfn) 977 { 978 driver = pci_devices[i].pcidriver; 979 if(driver && driver->suspend) { 980 driver->suspend(&pci_devices[i], SNDRV_CTL_POWER_D3cold); 981 } 982 } 983 } 984 985 dprintf(("OSS32_APMSuspend 2")); 986 return OSSERR_SUCCESS; 987 } 988 -
GPL/trunk/lib32/sound.c
r501 r518 37 37 #include <stdlib.h> 38 38 #include <proto.h> 39 //#include <dbgos2.h> 39 40 #include "soundoss.h" 40 41 41 42 #undef samples_to_bytes 42 43 #undef bytes_to_samples 43 #define samples_to_bytes(a) 44 #define samples_to_bytes(a) ((a*pHandle->doublesamplesize)/2) 44 45 #define bytes_to_samples(a) (pHandle->doublesamplesize ? ((a*2)/pHandle->doublesamplesize) : a) 45 46 int GetMaxChannels(ULONG deviceid, int type); … … 57 58 //OSS32 to ALSA datatype conversion table 58 59 static int OSSToALSADataType[OSS32_PCM_MAX_FORMATS] = { 59 /* OSS32_PCM_FORMAT_S8 */ SNDRV_PCM_FORMAT_S8,//signed 8 bits sample60 /* OSS32_PCM_FORMAT_U8 */ SNDRV_PCM_FORMAT_U8,//unsigned 8 bits sample61 /* OSS32_PCM_FORMAT_S16_LE */ SNDRV_PCM_FORMAT_S16_LE, 62 /* OSS32_PCM_FORMAT_S16_BE */ SNDRV_PCM_FORMAT_S16_BE, 63 /* OSS32_PCM_FORMAT_U16_LE */ SNDRV_PCM_FORMAT_U16_LE, 64 /* OSS32_PCM_FORMAT_U16_BE */ SNDRV_PCM_FORMAT_U16_BE, 65 /* OSS32_PCM_FORMAT_S24_LE */ SNDRV_PCM_FORMAT_S24_LE, 66 /* OSS32_PCM_FORMAT_S24_BE */ SNDRV_PCM_FORMAT_S24_BE, 67 /* OSS32_PCM_FORMAT_U24_LE */ SNDRV_PCM_FORMAT_U24_LE, 68 /* OSS32_PCM_FORMAT_U24_BE */ SNDRV_PCM_FORMAT_U24_BE, 69 /* OSS32_PCM_FORMAT_S32_LE */ SNDRV_PCM_FORMAT_S32_LE, 70 /* OSS32_PCM_FORMAT_S32_BE */ SNDRV_PCM_FORMAT_S32_BE, 71 /* OSS32_PCM_FORMAT_U32_LE */ SNDRV_PCM_FORMAT_U32_LE, 72 /* OSS32_PCM_FORMAT_U32_BE */ SNDRV_PCM_FORMAT_U32_BE, 73 /* OSS32_PCM_FORMAT_MULAW */ SNDRV_PCM_FORMAT_MU_LAW, 74 /* OSS32_PCM_FORMAT_ALAW */ SNDRV_PCM_FORMAT_A_LAW, 75 /* OSS32_PCM_FORMAT_ADPCM */ SNDRV_PCM_FORMAT_IMA_ADPCM, 76 /* OSS32_PCM_FORMAT_MPEG */ SNDRV_PCM_FORMAT_MPEG, 60 /* OSS32_PCM_FORMAT_S8 */ SNDRV_PCM_FORMAT_S8, //signed 8 bits sample 61 /* OSS32_PCM_FORMAT_U8 */ SNDRV_PCM_FORMAT_U8, //unsigned 8 bits sample 62 /* OSS32_PCM_FORMAT_S16_LE */ SNDRV_PCM_FORMAT_S16_LE, //signed 16 bits sample (little endian/Intel) 63 /* OSS32_PCM_FORMAT_S16_BE */ SNDRV_PCM_FORMAT_S16_BE, //signed 16 bits sample (big endian/Motorola) 64 /* OSS32_PCM_FORMAT_U16_LE */ SNDRV_PCM_FORMAT_U16_LE, //unsigned 16 bits sample (little endian/Intel) 65 /* OSS32_PCM_FORMAT_U16_BE */ SNDRV_PCM_FORMAT_U16_BE, //unsigned 16 bits sample (big endian/Motorola) 66 /* OSS32_PCM_FORMAT_S24_LE */ SNDRV_PCM_FORMAT_S24_LE, //signed 24 bits sample (little endian/Intel) 67 /* OSS32_PCM_FORMAT_S24_BE */ SNDRV_PCM_FORMAT_S24_BE, //signed 24 bits sample (big endian/Motorola) 68 /* OSS32_PCM_FORMAT_U24_LE */ SNDRV_PCM_FORMAT_U24_LE, //unsigned 24 bits sample (little endian/Intel) 69 /* OSS32_PCM_FORMAT_U24_BE */ SNDRV_PCM_FORMAT_U24_BE, //unsigned 24 bits sample (big endian/Motorola) 70 /* OSS32_PCM_FORMAT_S32_LE */ SNDRV_PCM_FORMAT_S32_LE, //signed 32 bits sample (little endian/Intel) 71 /* OSS32_PCM_FORMAT_S32_BE */ SNDRV_PCM_FORMAT_S32_BE, //signed 32 bits sample (big endian/Motorola) 72 /* OSS32_PCM_FORMAT_U32_LE */ SNDRV_PCM_FORMAT_U32_LE, //unsigned 32 bits sample (little endian/Intel) 73 /* OSS32_PCM_FORMAT_U32_BE */ SNDRV_PCM_FORMAT_U32_BE, //unsigned 32 bits sample (big endian/Motorola) 74 /* OSS32_PCM_FORMAT_MULAW */ SNDRV_PCM_FORMAT_MU_LAW, //8 bps (compressed 16 bits sample) 75 /* OSS32_PCM_FORMAT_ALAW */ SNDRV_PCM_FORMAT_A_LAW, //8 bps (compressed 16 bits sample) 76 /* OSS32_PCM_FORMAT_ADPCM */ SNDRV_PCM_FORMAT_IMA_ADPCM, //4 bps (compressed 16 bits sample) 77 /* OSS32_PCM_FORMAT_MPEG */ SNDRV_PCM_FORMAT_MPEG, //AC3? 77 78 }; 78 79 … … 82 83 { 83 84 if(!strcmp(name, "alsa")) { 84 85 alsa_fops = fsop; 85 86 } 86 87 return 0; … … 91 92 { 92 93 if(!strcmp(name, "alsa")) { 93 94 alsa_fops = NULL; 94 95 } 95 96 return 0; … … 99 100 int register_sound_special(struct file_operations *fops, int unit) 100 101 { 101 102 103 104 102 if(fops == NULL) return -1; 103 104 memcpy(&oss_devices[OSS32_SPECIALID], fops, sizeof(struct file_operations)); 105 return OSS32_SPECIALID; 105 106 } 106 107 //****************************************************************************** … … 108 109 int register_sound_mixer(struct file_operations *fops, int dev) 109 110 { 110 111 112 113 111 if(fops == NULL) return -1; 112 113 memcpy(&oss_devices[OSS32_MIXERID], fops, sizeof(struct file_operations)); 114 return OSS32_MIXERID; 114 115 } 115 116 //****************************************************************************** … … 117 118 int register_sound_midi(struct file_operations *fops, int dev) 118 119 { 119 120 121 122 120 if(fops == NULL) return -1; 121 122 memcpy(&oss_devices[OSS32_MIDIID], fops, sizeof(struct file_operations)); 123 return OSS32_MIDIID; 123 124 } 124 125 //****************************************************************************** … … 126 127 int register_sound_dsp(struct file_operations *fops, int dev) 127 128 { 128 129 130 131 129 if(fops == NULL) return -1; 130 131 memcpy(&oss_devices[OSS32_DSPID], fops, sizeof(struct file_operations)); 132 return OSS32_DSPID; 132 133 } 133 134 //****************************************************************************** … … 135 136 int register_sound_synth(struct file_operations *fops, int dev) 136 137 { 137 138 139 140 138 if(fops == NULL) return -1; 139 140 memcpy(&oss_devices[OSS32_SYNTHID], fops, sizeof(struct file_operations)); 141 return OSS32_SYNTHID; 141 142 } 142 143 //****************************************************************************** … … 144 145 void unregister_sound_special(int unit) 145 146 { 146 147 memset(&oss_devices[OSS32_SPECIALID], 0, sizeof(struct file_operations)); 147 148 } 148 149 //****************************************************************************** … … 150 151 void unregister_sound_mixer(int unit) 151 152 { 152 153 memset(&oss_devices[OSS32_MIXERID], 0, sizeof(struct file_operations)); 153 154 } 154 155 //****************************************************************************** … … 156 157 void unregister_sound_midi(int unit) 157 158 { 158 159 memset(&oss_devices[OSS32_MIDIID], 0, sizeof(struct file_operations)); 159 160 } 160 161 //****************************************************************************** … … 162 163 void unregister_sound_dsp(int unit) 163 164 { 164 165 memset(&oss_devices[OSS32_DSPID], 0, sizeof(struct file_operations)); 165 166 } 166 167 //****************************************************************************** … … 168 169 void unregister_sound_synth(int unit) 169 170 { 170 171 memset(&oss_devices[OSS32_SYNTHID], 0, sizeof(struct file_operations)); 171 172 } 172 173 //****************************************************************************** … … 174 175 OSSRET UNIXToOSSError(int unixerror) 175 176 { 176 177 178 179 180 181 182 183 184 185 186 187 return OSSERR_AGAIN;//????188 189 190 191 192 193 194 195 196 197 198 199 200 177 switch(unixerror) { 178 case 0: 179 return OSSERR_SUCCESS; 180 case -ENOMEM: 181 return OSSERR_OUT_OF_MEMORY; 182 case -ENODEV: 183 return OSSERR_NO_DEVICE_AVAILABLE; 184 case -ENOTTY: 185 case -EINVAL: 186 return OSSERR_INVALID_PARAMETER; 187 case -EAGAIN: 188 return OSSERR_AGAIN; //???? 189 case -ENXIO: 190 return OSSERR_IO_ERROR; 191 case -EBUSY: 192 return OSSERR_BUSY; 193 case -EPERM: 194 return OSSERR_ACCESS_DENIED; //?? 195 case -EPIPE: 196 case -EBADFD: 197 return OSSERR_ACCESS_DENIED; //?? 198 default: 199 dprintf(("Unknown error %d", (unixerror > 0) ? unixerror : -unixerror)); 200 return OSSERR_UNKNOWN; 201 } 201 202 } 202 203 //****************************************************************************** … … 205 206 int ALSAToOSSDataType(ULONG ALSADataType) 206 207 { 207 208 209 210 return OSS32_CAPS_PCM_FORMAT_S8;//signed 8 bits sample211 212 return OSS32_CAPS_PCM_FORMAT_U8;//unsigned 8 bits sample213 214 return OSS32_CAPS_PCM_FORMAT_S16_LE;//signed 16 bits sample (little endian/Intel)215 216 return OSS32_CAPS_PCM_FORMAT_S16_BE;//signed 16 bits sample (big endian/Motorola)217 218 return OSS32_CAPS_PCM_FORMAT_U16_LE;//unsigned 16 bits sample (little endian/Intel)219 220 return OSS32_CAPS_PCM_FORMAT_U16_BE;//unsigned 16 bits sample (big endian/Motorola)221 222 return OSS32_CAPS_PCM_FORMAT_S24_LE;//signed 24 bits sample (little endian/Intel)223 224 return OSS32_CAPS_PCM_FORMAT_S24_BE;//signed 24 bits sample (big endian/Motorola)225 226 return OSS32_CAPS_PCM_FORMAT_U24_LE;//unsigned 24 bits sample (little endian/Intel)227 228 return OSS32_CAPS_PCM_FORMAT_U24_BE;//unsigned 16 bits sample (big endian/Motorola)229 230 return OSS32_CAPS_PCM_FORMAT_S32_LE;//signed 32 bits sample (little endian/Intel)231 232 return OSS32_CAPS_PCM_FORMAT_S32_BE;//signed 32 bits sample (big endian/Motorola)233 234 return OSS32_CAPS_PCM_FORMAT_U32_LE;//unsigned 32 bits sample (little endian/Intel)235 236 return OSS32_CAPS_PCM_FORMAT_U32_BE;//unsigned 32 bits sample (big endian/Motorola)237 238 return OSS32_CAPS_PCM_FORMAT_MULAW;//8 bps (compressed 16 bits sample)239 240 return OSS32_CAPS_PCM_FORMAT_ALAW;//8 bps (compressed 16 bits sample)241 242 return OSS32_CAPS_PCM_FORMAT_ADPCM;//4 bps (compressed 16 bits sample)243 244 return OSS32_CAPS_PCM_FORMAT_MPEG;//AC3?245 246 247 248 208 switch(ALSADataType) 209 { 210 case SNDRV_PCM_FORMAT_S8: 211 return OSS32_CAPS_PCM_FORMAT_S8; //signed 8 bits sample 212 case SNDRV_PCM_FORMAT_U8: 213 return OSS32_CAPS_PCM_FORMAT_U8; //unsigned 8 bits sample 214 case SNDRV_PCM_FORMAT_S16_LE: 215 return OSS32_CAPS_PCM_FORMAT_S16_LE; //signed 16 bits sample (little endian/Intel) 216 case SNDRV_PCM_FORMAT_S16_BE: 217 return OSS32_CAPS_PCM_FORMAT_S16_BE; //signed 16 bits sample (big endian/Motorola) 218 case SNDRV_PCM_FORMAT_U16_LE: 219 return OSS32_CAPS_PCM_FORMAT_U16_LE; //unsigned 16 bits sample (little endian/Intel) 220 case SNDRV_PCM_FORMAT_U16_BE: 221 return OSS32_CAPS_PCM_FORMAT_U16_BE; //unsigned 16 bits sample (big endian/Motorola) 222 case SNDRV_PCM_FORMAT_S24_LE: 223 return OSS32_CAPS_PCM_FORMAT_S24_LE; //signed 24 bits sample (little endian/Intel) 224 case SNDRV_PCM_FORMAT_S24_BE: 225 return OSS32_CAPS_PCM_FORMAT_S24_BE; //signed 24 bits sample (big endian/Motorola) 226 case SNDRV_PCM_FORMAT_U24_LE: 227 return OSS32_CAPS_PCM_FORMAT_U24_LE; //unsigned 24 bits sample (little endian/Intel) 228 case SNDRV_PCM_FORMAT_U24_BE: 229 return OSS32_CAPS_PCM_FORMAT_U24_BE; //unsigned 16 bits sample (big endian/Motorola) 230 case SNDRV_PCM_FORMAT_S32_LE: 231 return OSS32_CAPS_PCM_FORMAT_S32_LE; //signed 32 bits sample (little endian/Intel) 232 case SNDRV_PCM_FORMAT_S32_BE: 233 return OSS32_CAPS_PCM_FORMAT_S32_BE; //signed 32 bits sample (big endian/Motorola) 234 case SNDRV_PCM_FORMAT_U32_LE: 235 return OSS32_CAPS_PCM_FORMAT_U32_LE; //unsigned 32 bits sample (little endian/Intel) 236 case SNDRV_PCM_FORMAT_U32_BE: 237 return OSS32_CAPS_PCM_FORMAT_U32_BE; //unsigned 32 bits sample (big endian/Motorola) 238 case SNDRV_PCM_FORMAT_MU_LAW: 239 return OSS32_CAPS_PCM_FORMAT_MULAW; //8 bps (compressed 16 bits sample) 240 case SNDRV_PCM_FORMAT_A_LAW: 241 return OSS32_CAPS_PCM_FORMAT_ALAW; //8 bps (compressed 16 bits sample) 242 case SNDRV_PCM_FORMAT_IMA_ADPCM: 243 return OSS32_CAPS_PCM_FORMAT_ADPCM; //4 bps (compressed 16 bits sample) 244 case SNDRV_PCM_FORMAT_MPEG: 245 return OSS32_CAPS_PCM_FORMAT_MPEG; //AC3? 246 default: 247 DebugInt3(); 248 return -1; 249 } 249 250 } 250 251 //****************************************************************************** … … 252 253 ULONG ALSAToOSSRateFlags(ULONG fuRates) 253 254 { 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 printk("HDA audio detected - don't support 5512 - 32000 Hz audio sample rates\n");283 284 285 286 287 288 289 255 ULONG fuOSSRates = 0; 256 257 char szMixerName[64]; 258 char szDeviceName[128]; 259 OSS32_QueryNames(OSS32_DEFAULT_DEVICE, szDeviceName, 260 sizeof(szDeviceName),szMixerName, 261 sizeof(szMixerName), TRUE); 262 if (strncmp(szDeviceName,"HDA",3) != 0){ 263 /* non-HDA audio - support 5512 - 32000 Hz sample rates */ 264 if(fuRates & SNDRV_PCM_RATE_5512) { 265 fuOSSRates |= OSS32_CAPS_PCM_RATE_5512; 266 } 267 if(fuRates & SNDRV_PCM_RATE_8000) { 268 fuOSSRates |= OSS32_CAPS_PCM_RATE_8000; 269 } 270 if(fuRates & SNDRV_PCM_RATE_11025) { 271 fuOSSRates |= OSS32_CAPS_PCM_RATE_11025; 272 } 273 if(fuRates & SNDRV_PCM_RATE_16000) { 274 fuOSSRates |= OSS32_CAPS_PCM_RATE_16000; 275 } 276 if(fuRates & SNDRV_PCM_RATE_22050) { 277 fuOSSRates |= OSS32_CAPS_PCM_RATE_22050; 278 } 279 if(fuRates & SNDRV_PCM_RATE_32000) { 280 fuOSSRates |= OSS32_CAPS_PCM_RATE_32000; 281 } 282 } else { 283 dprintf(("HDA audio detected - don't support 5512 - 32000 Hz audio sample rates\n")); 284 } 285 if(fuRates & SNDRV_PCM_RATE_44100) { 286 fuOSSRates |= OSS32_CAPS_PCM_RATE_44100; 287 } 288 if(fuRates & SNDRV_PCM_RATE_48000) { 289 fuOSSRates |= OSS32_CAPS_PCM_RATE_48000; 290 } 290 291 #if 0 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 292 if(fuRates & SNDRV_PCM_RATE_64000) { 293 fuOSSRates |= OSS32_CAPS_PCM_RATE_64000; 294 } 295 if(fuRates & SNDRV_PCM_RATE_88200) { 296 fuOSSRates |= OSS32_CAPS_PCM_RATE_88200; 297 } 298 if(fuRates & SNDRV_PCM_RATE_96000) { 299 fuOSSRates |= OSS32_CAPS_PCM_RATE_96000; 300 } 301 if(fuRates & SNDRV_PCM_RATE_176400) { 302 fuOSSRates |= OSS32_CAPS_PCM_RATE_176400; 303 } 304 if(fuRates & SNDRV_PCM_RATE_192000) { 305 fuOSSRates |= OSS32_CAPS_PCM_RATE_192000; 306 } 306 307 #endif 307 308 309 310 311 312 313 314 308 if(fuRates & SNDRV_PCM_RATE_CONTINUOUS) { 309 fuOSSRates |= OSS32_CAPS_PCM_RATE_CONTINUOUS; 310 } 311 312 //TODO: 313 if(fuRates & SNDRV_PCM_RATE_KNOT) { 314 DebugInt3(); 315 } 315 316 //#define OSS32_CAPS_PCM_RATE_KNOT (1<<31) /* supports more non-continuos rates */ 316 317 317 318 return fuOSSRates; 318 319 } 319 320 //****************************************************************************** … … 321 322 OSSRET OSS32_QueryDevCaps(ULONG deviceid, POSS32_DEVCAPS pDevCaps) 322 323 { 323 OSSSTREAMID streamid = 0; 324 soundhandle *pHandle; 325 struct snd_pcm_info *pcminfo = NULL; 326 struct snd_pcm_hw_params *params; 327 int ret, fmt, i; 328 ULONG format_mask; 329 struct snd_mask *mask; 330 int max_ch; 331 332 #ifdef DEBUG 333 dprintf(("OSS32_QueryDevCaps")); 334 #endif 335 // max_ch = GetMaxChannels(deviceid, OSS32_CAPS_WAVE_PLAYBACK); 336 337 //these structures are too big to put on the stack 338 pcminfo = (struct snd_pcm_info *)kmalloc(sizeof(struct snd_pcm_info)+sizeof(struct snd_pcm_hw_params), GFP_KERNEL); 339 if(pcminfo == NULL) { 340 DebugInt3(); 341 printk("OSS32_QueryDevCaps: out of memory\n"); 342 return OSSERR_OUT_OF_MEMORY; 343 } 344 params = (struct snd_pcm_hw_params *)(pcminfo+1); 345 346 printk("Number of cards: %i",nrCardsDetected); 347 printk("dev id: %i",deviceid); 348 pDevCaps->nrDevices = 1;//nrCardsDetected; 349 // pDevCaps->nrDevices = nrCardsDetected; 350 pDevCaps->ulCaps = OSS32_CAPS_WAVE_PLAYBACK | OSS32_CAPS_WAVE_CAPTURE; 351 352 //query wave in & out caps 353 for(i=0;i<2;i++) 354 { 355 PWAVE_CAPS pWaveCaps = (i == 0) ? &pDevCaps->waveOutCaps : &pDevCaps->waveInCaps; 356 357 ret = OSS32_WaveOpen(deviceid, (i == 0) ? OSS32_STREAM_WAVEOUT : OSS32_STREAM_WAVEIN, &streamid, 0, 0); 358 if(ret != OSSERR_SUCCESS) 359 { 360 printk("OSS32_QueryDevCaps: wave open error %i\n", ret); 361 DebugInt3(); 362 goto fail; 363 } 364 pHandle = (soundhandle *)streamid; 365 if(pHandle == NULL || pHandle->magic != MAGIC_WAVE_ALSA32) { 366 printk("OSS32_QueryDevCaps: invalid stream id \n"); 367 ret = OSSERR_INVALID_STREAMID; 368 goto fail; 369 } 370 //set operation to non-blocking 371 pHandle->file.f_flags = O_NONBLOCK; 372 373 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_INFO, (ULONG)pcminfo); 374 if(ret != 0) { 375 printk("OSS32_QueryDevCaps: SNDRV_PCM_IOCTL_INFO error %i\n", ret); 376 ret = UNIXToOSSError(ret); 377 goto fail; 378 } 379 if(i == 0) {//only need to do this once 380 if(pcminfo->name[0]) { 381 strncpy(pDevCaps->szDeviceName, pcminfo->name, sizeof(pDevCaps->szDeviceName)); 382 } 383 else strncpy(pDevCaps->szDeviceName, pcminfo->id, sizeof(pDevCaps->szDeviceName)); 384 } 385 printk("Device name: %s", pDevCaps->szDeviceName); 386 pWaveCaps->nrStreams = pcminfo->subdevices_count; 387 388 //get all hardware parameters 389 _snd_pcm_hw_params_any(params); 390 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)params); 391 if(ret != 0) { 392 printk("OSS32_QueryDevCaps: SNDRV_PCM_IOCTL_HW_REFINE error %i\n", ret); 393 ret = UNIXToOSSError(ret); 394 goto fail; 395 } 396 397 pWaveCaps->ulMinChannels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS)->min; 398 pWaveCaps->ulMaxChannels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS)->max; 399 pWaveCaps->ulChanFlags = 0; 400 if(pWaveCaps->ulMinChannels == 1) { 401 pWaveCaps->ulChanFlags |= OSS32_CAPS_PCM_CHAN_MONO; 402 } 403 if(pWaveCaps->ulMaxChannels >= 2) { 404 pWaveCaps->ulChanFlags |= OSS32_CAPS_PCM_CHAN_STEREO; 405 } 406 if(pWaveCaps->ulMaxChannels >= 4) { 407 pWaveCaps->ulChanFlags |= OSS32_CAPS_PCM_CHAN_QUAD; 408 } 409 if(pWaveCaps->ulMaxChannels >= 6) { 410 pWaveCaps->ulChanFlags |= OSS32_CAPS_PCM_CHAN_5_1; 411 } 412 413 pWaveCaps->ulMinRate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE)->min; 414 pWaveCaps->ulMaxRate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE)->max; 415 416 mask = hw_param_mask(params, SNDRV_PCM_HW_PARAM_RATE_MASK); 417 418 pWaveCaps->ulRateFlags = mask->bits[0]; 419 420 pWaveCaps->ulRateFlags = ALSAToOSSRateFlags(pWaveCaps->ulRateFlags); 421 422 pWaveCaps->ulDataFormats = 0; 423 424 mask = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); 425 format_mask = mask->bits[0]; 426 for(fmt=0;fmt<32;fmt++) 427 { 428 if(format_mask & (1 << fmt)) 429 { 430 int f = ALSAToOSSDataType(fmt); 431 if (f >= 0) 432 pWaveCaps->ulDataFormats |= f; 433 } 434 } 435 436 OSS32_WaveClose(streamid); 437 streamid = 0; 438 439 } 440 441 //Check support for MPU401, FM & Wavetable MIDI 442 if(OSS32_MidiOpen(deviceid, OSS32_STREAM_MPU401_MIDIOUT, &streamid) == OSSERR_SUCCESS) 443 { 444 pDevCaps->ulCaps |= OSS32_CAPS_MPU401_PLAYBACK; 445 OSS32_MidiClose(streamid); 446 streamid = 0; 447 } 448 if(OSS32_MidiOpen(deviceid, OSS32_STREAM_MPU401_MIDIIN, &streamid) == OSSERR_SUCCESS) 449 { 450 pDevCaps->ulCaps |= OSS32_CAPS_MPU401_CAPTURE; 451 OSS32_MidiClose(streamid); 452 streamid = 0; 453 } 454 if(OSS32_MidiOpen(deviceid, OSS32_STREAM_FM_MIDIOUT, &streamid) == OSSERR_SUCCESS) 455 { 456 pDevCaps->ulCaps |= OSS32_CAPS_FMSYNTH_PLAYBACK; 457 OSS32_MidiClose(streamid); 458 streamid = 0; 459 } 460 if(OSS32_MidiOpen(deviceid, OSS32_STREAM_WAVETABLE_MIDIOUT, &streamid) == OSSERR_SUCCESS) 461 { 462 pDevCaps->ulCaps |= OSS32_CAPS_WAVETABLE_PLAYBACK; 463 OSS32_MidiClose(streamid); 464 streamid = 0; 465 } 466 467 if(OSS32_MixQueryName(deviceid, &pDevCaps->szMixerName, sizeof(pDevCaps->szMixerName)) != OSSERR_SUCCESS) { 468 DebugInt3(); 469 printk("OSS32_QueryDevCaps: OSS32_MixQueryName error\n"); 470 goto fail; 471 } 472 printk("OSS32_QueryDevCaps: devname: [%s]\n", pDevCaps->szDeviceName); 473 kfree(pcminfo); 474 streamid = 0; 475 476 477 return OSSERR_SUCCESS; 324 OSSSTREAMID streamid = 0; 325 soundhandle *pHandle; 326 struct snd_pcm_info *pcminfo = NULL; 327 struct snd_pcm_hw_params *params; 328 int ret, fmt, i; 329 ULONG format_mask; 330 struct snd_mask *mask; 331 int max_ch; 332 333 dprintf(("OSS32_QueryDevCaps")); 334 // max_ch = GetMaxChannels(deviceid, OSS32_CAPS_WAVE_PLAYBACK); 335 336 //these structures are too big to put on the stack 337 pcminfo = (struct snd_pcm_info *)kmalloc(sizeof(struct snd_pcm_info)+sizeof(struct snd_pcm_hw_params), GFP_KERNEL); 338 if(pcminfo == NULL) { 339 DebugInt3(); 340 rprintf(("OSS32_QueryDevCaps: out of memory\n")); 341 return OSSERR_OUT_OF_MEMORY; 342 } 343 params = (struct snd_pcm_hw_params *)(pcminfo+1); 344 345 dprintf(("Number of cards=%i dev id=%i", nrCardsDetected, deviceid)); 346 pDevCaps->nrDevices = 1;//nrCardsDetected; 347 // pDevCaps->nrDevices = nrCardsDetected; 348 pDevCaps->ulCaps = OSS32_CAPS_WAVE_PLAYBACK | OSS32_CAPS_WAVE_CAPTURE; 349 350 //query wave in & out caps 351 for(i=0;i<2;i++) 352 { 353 PWAVE_CAPS pWaveCaps = (i == 0) ? &pDevCaps->waveOutCaps : &pDevCaps->waveInCaps; 354 355 ret = OSS32_WaveOpen(deviceid, (i == 0) ? OSS32_STREAM_WAVEOUT : OSS32_STREAM_WAVEIN, &streamid, 0, 0); 356 if(ret != OSSERR_SUCCESS) 357 { 358 rprintf(("OSS32_QueryDevCaps: wave open error %i\n", ret)); 359 DebugInt3(); 360 goto fail; 361 } 362 pHandle = (soundhandle *)streamid; 363 if(pHandle == NULL || pHandle->magic != MAGIC_WAVE_ALSA32) { 364 rprintf(("OSS32_QueryDevCaps: invalid stream id \n")); 365 ret = OSSERR_INVALID_STREAMID; 366 goto fail; 367 } 368 //set operation to non-blocking 369 pHandle->file.f_flags = O_NONBLOCK; 370 371 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_INFO, (ULONG)pcminfo); 372 if(ret != 0) { 373 rprintf(("OSS32_QueryDevCaps: SNDRV_PCM_IOCTL_INFO error %i\n", ret)); 374 ret = UNIXToOSSError(ret); 375 goto fail; 376 } 377 if(i == 0) {//only need to do this once 378 if(pcminfo->name[0]) { 379 strncpy(pDevCaps->szDeviceName, pcminfo->name, sizeof(pDevCaps->szDeviceName)); 380 } 381 else strncpy(pDevCaps->szDeviceName, pcminfo->id, sizeof(pDevCaps->szDeviceName)); 382 } 383 dprintf(("Device name: %s", pDevCaps->szDeviceName)); 384 pWaveCaps->nrStreams = pcminfo->subdevices_count; 385 386 //get all hardware parameters 387 _snd_pcm_hw_params_any(params); 388 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)params); 389 if(ret != 0) { 390 rprintf(("OSS32_QueryDevCaps: SNDRV_PCM_IOCTL_HW_REFINE error %i\n", ret)); 391 ret = UNIXToOSSError(ret); 392 goto fail; 393 } 394 395 pWaveCaps->ulMinChannels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS)->min; 396 pWaveCaps->ulMaxChannels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS)->max; 397 pWaveCaps->ulChanFlags = 0; 398 if(pWaveCaps->ulMinChannels == 1) { 399 pWaveCaps->ulChanFlags |= OSS32_CAPS_PCM_CHAN_MONO; 400 } 401 if(pWaveCaps->ulMaxChannels >= 2) { 402 pWaveCaps->ulChanFlags |= OSS32_CAPS_PCM_CHAN_STEREO; 403 } 404 if(pWaveCaps->ulMaxChannels >= 4) { 405 pWaveCaps->ulChanFlags |= OSS32_CAPS_PCM_CHAN_QUAD; 406 } 407 if(pWaveCaps->ulMaxChannels >= 6) { 408 pWaveCaps->ulChanFlags |= OSS32_CAPS_PCM_CHAN_5_1; 409 } 410 411 pWaveCaps->ulMinRate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE)->min; 412 pWaveCaps->ulMaxRate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE)->max; 413 414 mask = hw_param_mask(params, SNDRV_PCM_HW_PARAM_RATE_MASK); 415 416 pWaveCaps->ulRateFlags = mask->bits[0]; 417 418 pWaveCaps->ulRateFlags = ALSAToOSSRateFlags(pWaveCaps->ulRateFlags); 419 420 pWaveCaps->ulDataFormats = 0; 421 422 mask = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); 423 format_mask = mask->bits[0]; 424 for(fmt=0;fmt<32;fmt++) 425 { 426 if(format_mask & (1 << fmt)) 427 { 428 int f = ALSAToOSSDataType(fmt); 429 if (f >= 0) 430 pWaveCaps->ulDataFormats |= f; 431 } 432 } 433 434 OSS32_WaveClose(streamid); 435 streamid = 0; 436 437 } 438 439 //Check support for MPU401, FM & Wavetable MIDI 440 if(OSS32_MidiOpen(deviceid, OSS32_STREAM_MPU401_MIDIOUT, &streamid) == OSSERR_SUCCESS) 441 { 442 pDevCaps->ulCaps |= OSS32_CAPS_MPU401_PLAYBACK; 443 OSS32_MidiClose(streamid); 444 streamid = 0; 445 } 446 if(OSS32_MidiOpen(deviceid, OSS32_STREAM_MPU401_MIDIIN, &streamid) == OSSERR_SUCCESS) 447 { 448 pDevCaps->ulCaps |= OSS32_CAPS_MPU401_CAPTURE; 449 OSS32_MidiClose(streamid); 450 streamid = 0; 451 } 452 if(OSS32_MidiOpen(deviceid, OSS32_STREAM_FM_MIDIOUT, &streamid) == OSSERR_SUCCESS) 453 { 454 pDevCaps->ulCaps |= OSS32_CAPS_FMSYNTH_PLAYBACK; 455 OSS32_MidiClose(streamid); 456 streamid = 0; 457 } 458 if(OSS32_MidiOpen(deviceid, OSS32_STREAM_WAVETABLE_MIDIOUT, &streamid) == OSSERR_SUCCESS) 459 { 460 pDevCaps->ulCaps |= OSS32_CAPS_WAVETABLE_PLAYBACK; 461 OSS32_MidiClose(streamid); 462 streamid = 0; 463 } 464 465 if(OSS32_MixQueryName(deviceid, &pDevCaps->szMixerName, sizeof(pDevCaps->szMixerName)) != OSSERR_SUCCESS) { 466 DebugInt3(); 467 rprintf(("OSS32_QueryDevCaps: OSS32_MixQueryName error\n")); 468 goto fail; 469 } 470 dprintf(("OSS32_QueryDevCaps: devname: [%s]\n", pDevCaps->szDeviceName)); 471 kfree(pcminfo); 472 streamid = 0; 473 474 475 return OSSERR_SUCCESS; 478 476 479 477 fail: 480 printk("OSS32_QueryDevCaps failed\n");481 482 483 484 485 478 rprintf(("OSS32_QueryDevCaps failed\n")); 479 DebugInt3(); 480 if(streamid) OSS32_WaveClose(streamid); 481 if(pcminfo) kfree(pcminfo); 482 483 return ret; 486 484 } 487 485 //****************************************************************************** … … 489 487 OSSRET OSS32_WaveOpen(ULONG deviceid, ULONG streamtype, OSSSTREAMID *pStreamId, int pcm, USHORT fileid) 490 488 { 491 soundhandle *pHandle; 492 int ret,i; 493 494 if (pStreamId) 495 *pStreamId = 0; 496 else 497 { 498 printk("ERROR: invalid stream id pointer passed\n"); 499 return OSSERR_OUT_OF_MEMORY; 500 } 501 502 if(alsa_fops == NULL) { 503 DebugInt3(); 504 #ifdef DEBUG 505 dprintf(("OSS32_WaveOpen: no devices")); 506 #endif 507 printk("OSS32_WaveOpen: no devices\n"); 508 509 return OSSERR_NO_DEVICE_AVAILABLE; 510 } 511 512 // printk("dev id: %i\n",deviceid); 513 514 pHandle = kmalloc(sizeof(soundhandle), GFP_KERNEL); 515 if(pHandle == NULL) { 516 DebugInt3(); 517 printk("OSS32_WaveOpen: out of memory\n"); 518 return OSSERR_OUT_OF_MEMORY; 519 } 520 memset(pHandle, 0, sizeof(soundhandle)); 521 522 //set operation to non-blocking 523 pHandle->file.f_flags = O_NONBLOCK; 524 525 //setup pointers in file structure (used internally by ALSA) 526 pHandle->file.f_dentry = &pHandle->d_entry; 527 pHandle->file.f_dentry->d_inode = &pHandle->inode; 528 529 switch(streamtype) { 530 case OSS32_STREAM_WAVEOUT: 531 pHandle->file.f_mode = FMODE_WRITE; 532 pHandle->inode.i_rdev = SNDRV_MINOR(deviceid, SNDRV_MINOR_PCM_PLAYBACK) + pcm; 533 break; 534 case OSS32_STREAM_WAVEIN: 535 pHandle->file.f_mode = FMODE_READ; 536 pHandle->inode.i_rdev = SNDRV_MINOR(deviceid, SNDRV_MINOR_PCM_CAPTURE) + pcm; 537 break; 538 default: 539 DebugInt3(); 540 kfree(pHandle); 541 printk("OSS32_WaveOpen: invalid parameter\n"); 542 return OSSERR_INVALID_PARAMETER; 543 } 544 545 ret = alsa_fops->open(&pHandle->inode, &pHandle->file); 546 printk("OSS32_WaveOpen. ret: %i\n", ret); 547 /* check if PCM already opened (stupid uniaud16.sys doesnt closes it) */ 548 if (ret == -16) 549 { 550 for (i=0; i < 8*256; i++) 551 { 552 if (opened_handles[i].handle != 0) 553 { 554 ret = 0; 555 if (pStreamId) 556 *pStreamId = (ULONG)opened_handles[i].handle; 557 opened_handles[i].reuse = 1; /* try to reuse */ 558 if (OSS32_WaveClose((OSSSTREAMID)opened_handles[i].handle) == 0) 559 { 560 if (!opened_handles[i].reuse) 561 { 562 //opened_handles[i].handle = 0; 563 kfree(opened_handles[i].handle); //free handle data 564 ret = alsa_fops->open(&pHandle->inode, &pHandle->file); 565 printk("OSS32_WaveOpen. Reopen ret: %i\n", ret); 566 } 567 else 568 { 569 kfree(pHandle); 570 pHandle = opened_handles[i].handle; 571 } 572 break; 573 } 574 } 575 } 576 } 577 else if (ret == 0) 578 { 579 for (i=0; i < 8*256; i++) 580 { 581 if (opened_handles[i].handle == 0) 582 { 583 opened_handles[i].handle = pHandle; 584 opened_handles[i].FileId = fileid; 585 break; 586 } 587 } 588 } 589 590 if(ret) { 591 kfree(pHandle); 592 DebugInt3(); 593 printk("OSS32_WaveOpen: open error: %i\n",ret); 594 return UNIXToOSSError(ret); 595 } 596 pHandle->magic = MAGIC_WAVE_ALSA32; 597 if (pStreamId) 598 *pStreamId = (ULONG)pHandle; 599 // filling opened handles table 600 printk("OSS32_WaveOpen. streamid %X\n",(ULONG)pHandle); 601 return OSSERR_SUCCESS; 489 soundhandle *pHandle; 490 int ret,i; 491 492 if (pStreamId) 493 *pStreamId = 0; 494 else 495 { 496 rprintf(("ERROR: invalid stream id pointer\n")); 497 return OSSERR_OUT_OF_MEMORY; 498 } 499 500 if(alsa_fops == NULL) { 501 DebugInt3(); 502 rprintf(("OSS32_WaveOpen: no devices")); 503 504 return OSSERR_NO_DEVICE_AVAILABLE; 505 } 506 507 //dprintf(("dev id: %i\n",deviceid)); 508 509 pHandle = kmalloc(sizeof(soundhandle), GFP_KERNEL); 510 if(pHandle == NULL) { 511 DebugInt3(); 512 rprintf(("OSS32_WaveOpen: out of memory\n")); 513 return OSSERR_OUT_OF_MEMORY; 514 } 515 memset(pHandle, 0, sizeof(soundhandle)); 516 517 //set operation to non-blocking 518 pHandle->file.f_flags = O_NONBLOCK; 519 520 //setup pointers in file structure (used internally by ALSA) 521 pHandle->file.f_dentry = &pHandle->d_entry; 522 pHandle->file.f_dentry->d_inode = &pHandle->inode; 523 524 switch(streamtype) { 525 case OSS32_STREAM_WAVEOUT: 526 pHandle->file.f_mode = FMODE_WRITE; 527 pHandle->inode.i_rdev = SNDRV_MINOR(deviceid, SNDRV_MINOR_PCM_PLAYBACK) + pcm; 528 break; 529 case OSS32_STREAM_WAVEIN: 530 pHandle->file.f_mode = FMODE_READ; 531 pHandle->inode.i_rdev = SNDRV_MINOR(deviceid, SNDRV_MINOR_PCM_CAPTURE) + pcm; 532 break; 533 default: 534 DebugInt3(); 535 kfree(pHandle); 536 rprintf(("OSS32_WaveOpen: invalid parameter\n")); 537 return OSSERR_INVALID_PARAMETER; 538 } 539 540 ret = alsa_fops->open(&pHandle->inode, &pHandle->file); 541 //dprintf(("OSS32_WaveOpen. ret: %i\n", ret)); 542 /* check if PCM already opened (stupid uniaud16.sys doesnt closes it) */ 543 if (ret == -16) 544 { 545 for (i=0; i < 8*256; i++) 546 { 547 if (opened_handles[i].handle != 0) 548 { 549 ret = 0; 550 if (pStreamId) 551 *pStreamId = (ULONG)opened_handles[i].handle; 552 opened_handles[i].reuse = 1; /* try to reuse */ 553 if (OSS32_WaveClose((OSSSTREAMID)opened_handles[i].handle) == 0) 554 { 555 if (!opened_handles[i].reuse) 556 { 557 //opened_handles[i].handle = 0; 558 kfree(opened_handles[i].handle); //free handle data 559 ret = alsa_fops->open(&pHandle->inode, &pHandle->file); 560 dprintf(("OSS32_WaveOpen. Reopen ret: %i\n", ret)); 561 } 562 else 563 { 564 kfree(pHandle); 565 pHandle = opened_handles[i].handle; 566 } 567 break; 568 } 569 } 570 } 571 } 572 else if (ret == 0) 573 { 574 for (i=0; i < 8*256; i++) 575 { 576 if (opened_handles[i].handle == 0) 577 { 578 opened_handles[i].handle = pHandle; 579 opened_handles[i].FileId = fileid; 580 break; 581 } 582 } 583 } 584 585 if(ret) { 586 kfree(pHandle); 587 DebugInt3(); 588 rprintf(("OSS32_WaveOpen: open error: %i\n",ret)); 589 return UNIXToOSSError(ret); 590 } 591 pHandle->magic = MAGIC_WAVE_ALSA32; 592 if (pStreamId) 593 *pStreamId = (ULONG)pHandle; 594 // filling opened handles table 595 dprintf(("OSS32_WaveOpen. streamid %X\n",(ULONG)pHandle)); 596 return OSSERR_SUCCESS; 602 597 } 603 598 //****************************************************************************** … … 606 601 OSSRET OSS32_WaveClose(OSSSTREAMID streamid) 607 602 { 608 609 intret = 0, i;610 611 612 613 printk("OSS32_WaveClose. invalid streamid %X\n",(ULONG)pHandle);614 615 616 617 618 619 620 621 622 623 624 printk("Found phandle for closing: %x reuse flag: %i\n", pHandle, opened_handles[i].reuse);625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 printk("phandle %x not found\n", pHandle);645 // 646 647 648 649 650 printk("Error closing wave. rc = %i\n", ret);651 652 653 654 printk("OSS32_WaveClose. streamid %X\n",(ULONG)pHandle);655 603 soundhandle *pHandle = (soundhandle *)streamid; 604 int ret = 0, i; 605 606 if(pHandle == NULL || pHandle->magic != MAGIC_WAVE_ALSA32) { 607 DebugInt3(); 608 rprintf(("OSS32_WaveClose. invalid streamid %X\n",(ULONG)pHandle)); 609 return OSSERR_INVALID_STREAMID; 610 } 611 612 //set operation to non-blocking 613 pHandle->file.f_flags = O_NONBLOCK; 614 615 for (i=0; i < 8*256; i++) 616 { 617 if (opened_handles[i].handle == pHandle) 618 { 619 dprintf(("Found phandle for closing: %x reuse flag: %i\n", pHandle, opened_handles[i].reuse)); 620 if (!opened_handles[i].reuse) 621 { 622 ret = pHandle->file.f_op->release(&pHandle->inode, &pHandle->file); 623 opened_handles[i].handle = 0; 624 kfree(pHandle); //free handle data 625 OSS32_CloseUNI16(); /* say to UNIAUD16 that we closing now */ 626 } else 627 { 628 /* prepare for reuse */ 629 pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_RESET, 0); 630 pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0); 631 } 632 break; 633 } 634 } 635 636 if (i >= 8*256) 637 { 638 //all already closed 639 dprintf(("phandle %x not found\n", pHandle)); 640 // return OSSERR_SUCCESS; 641 } 642 643 644 if(ret) { 645 dprintf(("Error closing wave. rc = %i\n", ret)); 646 DebugInt3(); 647 return UNIXToOSSError(ret); 648 } 649 dprintf(("OSS32_WaveClose. streamid %X\n", (ULONG)pHandle)); 650 return OSSERR_SUCCESS; 656 651 } 657 652 //****************************************************************************** … … 659 654 OSSRET OSS32_WavePrepare(OSSSTREAMID streamid) 660 655 { 661 soundhandle *pHandle = (soundhandle *)streamid; 662 int ret; 663 664 #ifdef DEBUG 665 dprintf(("OSS32_WavePrepare")); 666 #endif 667 668 if(pHandle == NULL || pHandle->magic != MAGIC_WAVE_ALSA32) { 669 DebugInt3(); 670 //#ifdef DEBUG 671 printk("vladest: OSS32_WavePrepare: invalid streamID\n"); 672 //#endif 673 674 return OSSERR_INVALID_STREAMID; 675 } 676 //set operation to non-blocking 677 pHandle->file.f_flags = O_NONBLOCK; 678 679 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0); 680 if (ret) 681 printk("Wave prepare ret = %i, streamid %X\n",ret,(ULONG)pHandle); 682 683 return UNIXToOSSError(ret);; 656 soundhandle *pHandle = (soundhandle *)streamid; 657 int ret; 658 659 dprintf(("OSS32_WavePrepare")); 660 661 if(pHandle == NULL || pHandle->magic != MAGIC_WAVE_ALSA32) { 662 DebugInt3(); 663 rprintf(("vladest: OSS32_WavePrepare: invalid streamID\n")); 664 665 return OSSERR_INVALID_STREAMID; 666 } 667 //set operation to non-blocking 668 pHandle->file.f_flags = O_NONBLOCK; 669 670 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0); 671 if (ret) 672 rprintf(("Wave prepare ret = %i, streamid %X\n",ret,(ULONG)pHandle)); 673 674 return UNIXToOSSError(ret);; 684 675 } 685 676 //****************************************************************************** … … 687 678 OSSRET OSS32_WaveStart(OSSSTREAMID streamid) 688 679 { 689 690 intret;691 692 693 694 695 696 697 698 699 700 printk("Wave start ret = %i, streamid %X\n",ret,(ULONG)pHandle);701 702 680 soundhandle *pHandle = (soundhandle *)streamid; 681 int ret; 682 683 if(pHandle == NULL || pHandle->magic != MAGIC_WAVE_ALSA32) { 684 DebugInt3(); 685 return OSSERR_INVALID_STREAMID; 686 } 687 //set operation to non-blocking 688 pHandle->file.f_flags = O_NONBLOCK; 689 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_START, 0); 690 if (ret) 691 rprintf(("Wave start ret = %i, streamid %X\n",ret,(ULONG)pHandle)); 692 693 return UNIXToOSSError(ret);; 703 694 } 704 695 //****************************************************************************** … … 706 697 OSSRET OSS32_WaveStop(OSSSTREAMID streamid) 707 698 { 708 709 intret;710 711 712 713 714 715 716 717 718 719 720 printk("Wave stop ret = %i. streamid %X\n",ret,(ULONG)pHandle);721 722 699 soundhandle *pHandle = (soundhandle *)streamid; 700 int ret; 701 702 if(pHandle == NULL || pHandle->magic != MAGIC_WAVE_ALSA32) { 703 DebugInt3(); 704 return OSSERR_INVALID_STREAMID; 705 } 706 //set operation to non-blocking 707 pHandle->file.f_flags = O_NONBLOCK; 708 709 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_DROP, 0); 710 if (ret) 711 rprintf(("Wave stop ret = %i. streamid %X\n",ret,(ULONG)pHandle)); 712 713 return UNIXToOSSError(ret);; 723 714 } 724 715 //****************************************************************************** … … 726 717 OSSRET OSS32_WavePause(OSSSTREAMID streamid) 727 718 { 728 729 intret;730 731 732 733 734 735 736 737 738 739 740 printk("Wave pause ret = %i, streamid %X\n",ret,(ULONG)pHandle);741 742 719 soundhandle *pHandle = (soundhandle *)streamid; 720 int ret; 721 722 if(pHandle == NULL || pHandle->magic != MAGIC_WAVE_ALSA32) { 723 DebugInt3(); 724 return OSSERR_INVALID_STREAMID; 725 } 726 //set operation to non-blocking 727 pHandle->file.f_flags = O_NONBLOCK; 728 729 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_PAUSE, 0); 730 if (ret) 731 rprintf(("Wave pause ret = %i, streamid %X\n",ret,(ULONG)pHandle)); 732 733 return UNIXToOSSError(ret);; 743 734 } 744 735 //****************************************************************************** … … 746 737 OSSRET OSS32_WaveResume(OSSSTREAMID streamid) 747 738 { 748 749 intret;750 751 752 753 754 755 756 757 758 759 760 printk("Wave resume ret = %i, streamid %X\n",ret,(ULONG)pHandle);761 762 739 soundhandle *pHandle = (soundhandle *)streamid; 740 int ret; 741 742 if(pHandle == NULL || pHandle->magic != MAGIC_WAVE_ALSA32) { 743 DebugInt3(); 744 return OSSERR_INVALID_STREAMID; 745 } 746 //set operation to non-blocking 747 pHandle->file.f_flags = O_NONBLOCK; 748 749 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_PAUSE, 1); 750 if (ret) 751 rprintf(("Wave resume ret = %i, streamid %X\n",ret,(ULONG)pHandle)); 752 753 return UNIXToOSSError(ret);; 763 754 } 764 755 765 756 static unsigned rates[] = { 766 767 768 757 /* ATTENTION: these values depend on the definition in pcm.h! */ 758 5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000, 759 64000, 88200, 96000, 176400, 192000 769 760 }; 770 761 … … 773 764 OSSRET OSS32_WaveSetHwParams(OSSSTREAMID streamid, OSS32_HWPARAMS *pHwParams) 774 765 { 775 soundhandle*pHandle = (soundhandle *)streamid;776 777 778 struct snd_pcm_statusstatus;779 780 intret, nrperiods, minnrperiods, maxnrperiods, samplesize,i;781 ULONGbufsize, periodsize, minperiodsize, maxperiodsize;782 ULONGperiodbytes, minperiodbytes, maxperiodbytes;783 BOOLfTryAgain = FALSE;784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 printk("OSS32_WaveSetHwParams error. Invalid number of channels: %i\n", pHwParams->ulNumChannels);803 804 805 766 soundhandle *pHandle = (soundhandle *)streamid; 767 struct snd_pcm_hw_params params; 768 struct snd_pcm_sw_params swparams; 769 struct snd_pcm_status status; 770 771 int ret, nrperiods, minnrperiods, maxnrperiods, samplesize,i; 772 ULONG bufsize, periodsize, minperiodsize, maxperiodsize; 773 ULONG periodbytes, minperiodbytes, maxperiodbytes; 774 BOOL fTryAgain = FALSE; 775 ULONG ulMinRate, ulMaxRate; 776 777 if(pHandle == NULL || pHandle->magic != MAGIC_WAVE_ALSA32) { 778 779 DebugInt3(); 780 return OSSERR_INVALID_STREAMID; 781 } 782 if(pHwParams == NULL) { 783 784 DebugInt3(); 785 return OSSERR_INVALID_PARAMETER; 786 } 787 if(pHwParams->ulDataType >= OSS32_PCM_MAX_FORMATS) { 788 789 DebugInt3(); 790 return OSSERR_INVALID_PARAMETER; 791 } 792 if ((int)pHwParams->ulNumChannels <= 0) { 793 rprintf(("OSS32_WaveSetHwParams error. Invalid number of channels: %i\n", pHwParams->ulNumChannels)); 794 DebugInt3(); 795 return OSSERR_INVALID_PARAMETER; 796 } 806 797 tryagain: 807 808 809 810 811 812 813 814 815 periodsize= bytes_to_samples(periodbytes);816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 dprintf(("invalid format %lx\n", OSSToALSADataType[pHwParams->ulDataType]));842 843 844 845 846 847 848 dprintf(("invalid number of sample bits %d\n", pHwParams->ulBitsPerSample));849 850 851 852 853 854 855 dprintf(("invalid number of frame bits %d\n", pHwParams->ulBitsPerSample*pHwParams->ulNumChannels));856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 dprintf(("32_WSetHwPms (first pass) error %d bps:%d fmt: %d ch: %d sr: %d\n",873 874 875 876 877 878 879 //printk("will set to nearest\n");880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 798 //set operation to non-blocking 799 pHandle->file.f_flags = O_NONBLOCK; 800 801 //size of two samples (adpcm sample can be as small as 4 bits (mono), so take two) 802 samplesize = snd_pcm_format_size(OSSToALSADataType[pHwParams->ulDataType], 1); 803 pHandle->doublesamplesize = samplesize * 2; 804 pHandle->doublesamplesize *= pHwParams->ulNumChannels; 805 periodbytes = pHwParams->ulPeriodSize; 806 periodsize = bytes_to_samples(periodbytes); 807 // checking number of channels 808 809 dprintf(("channels: %ld, period size: %lx",pHwParams->ulNumChannels, periodbytes)); 810 811 _snd_pcm_hw_params_any(¶ms); 812 do { 813 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_ACCESS, 814 SNDRV_PCM_ACCESS_RW_INTERLEAVED, 0); 815 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_CHANNELS, 816 pHwParams->ulNumChannels, 0); 817 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)__Stack32ToFlat(¶ms)); 818 if (ret == 0) break; 819 pHwParams->ulNumChannels--; 820 } while(ret < 0 && pHwParams->ulNumChannels > 1); 821 822 dprintf(("channels selected: %d",pHwParams->ulNumChannels)); 823 824 //get all hardware parameters 825 _snd_pcm_hw_params_any(¶ms); 826 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_ACCESS, 827 SNDRV_PCM_ACCESS_RW_INTERLEAVED, 0); 828 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_FORMAT, 829 OSSToALSADataType[pHwParams->ulDataType], 0); 830 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)__Stack32ToFlat(¶ms)); 831 if(ret != 0) { 832 rprintf(("invalid format %lx\n", OSSToALSADataType[pHwParams->ulDataType])); 833 return UNIXToOSSError(ret); 834 } 835 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_SAMPLE_BITS, 836 pHwParams->ulBitsPerSample, 0); 837 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)__Stack32ToFlat(¶ms)); 838 if(ret != 0) { 839 rprintf(("invalid number of sample bits %d\n", pHwParams->ulBitsPerSample)); 840 return UNIXToOSSError(ret); 841 } 842 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_FRAME_BITS, 843 pHwParams->ulBitsPerSample*pHwParams->ulNumChannels, 0); 844 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)__Stack32ToFlat(¶ms)); 845 if(ret != 0) { 846 rprintf(("invalid number of frame bits %d\n", pHwParams->ulBitsPerSample*pHwParams->ulNumChannels)); 847 return UNIXToOSSError(ret); 848 } 849 850 //_snd_pcm_hw_params_any(¶ms); 851 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_SAMPLE_BITS, 852 pHwParams->ulBitsPerSample, 0); 853 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_FRAME_BITS, 854 pHwParams->ulBitsPerSample*pHwParams->ulNumChannels, 0); 855 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_FORMAT, 856 OSSToALSADataType[pHwParams->ulDataType], 0); 857 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_CHANNELS, 858 pHwParams->ulNumChannels, 0); 859 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_RATE, 860 pHwParams->ulSampleRate, 0); 861 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)__Stack32ToFlat(¶ms)); 862 if(ret != 0) { 863 rprintf(("32_WSetHwPms (first pass) error %d bps:%d fmt: %d ch: %d sr: %d\n", 864 ret, 865 pHwParams->ulBitsPerSample, 866 OSSToALSADataType[pHwParams->ulDataType], 867 pHwParams->ulNumChannels, 868 pHwParams->ulSampleRate)); 869 //printk("OSS32_WaveSetHwParams invalid sample rate %i\n", pHwParams->ulSampleRate); 870 // printk("will set to nearest\n"); 871 _snd_pcm_hw_params_any(¶ms); 872 for (i=0; i<(sizeof(rates)/sizeof(unsigned))-1;i++) 873 { 874 if (pHwParams->ulSampleRate >= rates[i] && 875 pHwParams->ulSampleRate <= rates[i+1]) 876 { 877 pHwParams->ulSampleRate = rates[i]; 878 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_RATE, 879 pHwParams->ulSampleRate, 0); 880 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)__Stack32ToFlat(¶ms)); 881 if(ret == 0) 882 { 883 _snd_pcm_hw_params_any(¶ms); 884 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_SAMPLE_BITS, 885 pHwParams->ulBitsPerSample, 0); 886 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_FRAME_BITS, 887 pHwParams->ulBitsPerSample*pHwParams->ulNumChannels, 0); 888 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_FORMAT, 889 OSSToALSADataType[pHwParams->ulDataType], 0); 890 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_CHANNELS, 891 pHwParams->ulNumChannels, 0); 892 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_RATE, 893 pHwParams->ulSampleRate, 0); 894 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)__Stack32ToFlat(¶ms)); 895 goto __next; 896 } 897 } 898 } 899 DebugInt3(); 900 return UNIXToOSSError(ret); 901 } 911 902 __next: 912 903 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 dprintf(("32_WSHwPrms error. Invalid periodsize (=0). closing file\n"));949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 dprintf(("32_WSHwPrms error. Invalid Num periods(=1). closing file\n"));966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 dprintf((" Error -77 from first IOCTL HW Parms"));1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 periodsize= maxperiodsize;1019 1020 1021 1022 1023 1024 1025 dprintf(("Error %ld second time.. Bailing", ret));1026 1027 1028 1029 1030 1031 1032 swparams.avail_min= periodsize;1033 swparams.period_step= 1;1034 1035 1036 1037 1038 1039 1040 1041 swparams.sleep_min= 0;1042 1043 1044 swparams.tstamp_mode= SNDRV_PCM_TSTAMP_NONE;1045 swparams.xfer_align= periodsize;1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 dprintf(("Device is not in proper state: %lx. Calling prepare\n", status.state));1058 1059 1060 904 //check period size against lower and upper boundaries 905 minperiodbytes = hw_param_interval((¶ms), SNDRV_PCM_HW_PARAM_PERIOD_BYTES)->min; 906 maxperiodbytes = hw_param_interval((¶ms), SNDRV_PCM_HW_PARAM_PERIOD_BYTES)->max; 907 if(periodbytes < minperiodbytes) { 908 periodbytes = minperiodbytes; 909 } 910 else 911 if(periodbytes > maxperiodbytes) { 912 periodbytes = maxperiodbytes; 913 } 914 915 minperiodsize = hw_param_interval((¶ms), SNDRV_PCM_HW_PARAM_PERIOD_SIZE)->min; 916 maxperiodsize = hw_param_interval((¶ms), SNDRV_PCM_HW_PARAM_PERIOD_SIZE)->max; 917 if(periodsize < minperiodsize) { 918 periodsize = minperiodsize; 919 } 920 else 921 if(periodsize > maxperiodsize) { 922 periodsize = maxperiodsize; 923 } 924 925 if(samples_to_bytes(periodsize) < periodbytes) { 926 periodbytes = samples_to_bytes(periodsize); 927 } 928 else 929 if(bytes_to_samples(periodbytes) < periodsize) { 930 periodsize = bytes_to_samples(periodbytes); 931 } 932 933 //make sure period size is a whole fraction of the buffer size 934 bufsize = hw_param_interval((¶ms), SNDRV_PCM_HW_PARAM_BUFFER_BYTES)->max; 935 if(periodsize) { 936 nrperiods = bufsize/periodbytes; 937 } 938 else { 939 rprintf(("32_WSHwPrms error. Invalid periodsize (=0). closing file\n")); 940 DebugInt3(); 941 return OSSERR_INVALID_PARAMETER; 942 } 943 //check nr of periods against lower and upper boundaries 944 minnrperiods = hw_param_interval((¶ms), SNDRV_PCM_HW_PARAM_PERIODS)->min; 945 maxnrperiods = hw_param_interval((¶ms), SNDRV_PCM_HW_PARAM_PERIODS)->max; 946 if(nrperiods < minnrperiods) { 947 nrperiods = minnrperiods; 948 } 949 else 950 if(nrperiods > maxnrperiods) { 951 nrperiods = maxnrperiods; 952 } 953 //an odd nr of periods is not always a good thing (CMedia -> clicks during 8 bps playback), 954 //so we make sure it's an even number. 955 if(nrperiods == 1) { 956 rprintf(("32_WSHwPrms error. Invalid Num periods(=1). closing file\n")); 957 DebugInt3(); 958 return OSSERR_INVALID_PARAMETER; 959 } 960 nrperiods &= ~1; 961 962 //initialize parameter block & set sample rate, nr of channels and sample format, nr of periods, 963 //period size and buffer size 964 965 _snd_pcm_hw_params_any(¶ms); 966 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_ACCESS, 967 SNDRV_PCM_ACCESS_RW_INTERLEAVED, 0); 968 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_SAMPLE_BITS, 969 pHwParams->ulBitsPerSample, 0); 970 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_FRAME_BITS, 971 pHwParams->ulBitsPerSample*pHwParams->ulNumChannels, 0); 972 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_FORMAT, 973 OSSToALSADataType[pHwParams->ulDataType], 0); 974 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_CHANNELS, 975 pHwParams->ulNumChannels, 0); 976 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_RATE, 977 pHwParams->ulSampleRate, 0); 978 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 979 periodsize, 0); 980 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 981 periodbytes, 0); 982 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_PERIODS, 983 nrperiods, 0); 984 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 985 periodsize*nrperiods, 0); 986 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 987 periodbytes*nrperiods, 0); 988 989 990 dprintf(("HWP: SR rate %ld, BPS %ld, CH %ld, PRSZ %lx, periods %lx", 991 pHwParams->ulSampleRate, pHwParams->ulBitsPerSample, pHwParams->ulNumChannels, periodsize, nrperiods)); 992 993 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_HW_PARAMS, (ULONG)__Stack32ToFlat(¶ms)); 994 if (ret == -77 && fTryAgain == FALSE) 995 { 996 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0); 997 fTryAgain = TRUE; 998 rprintf((" Error -77 from first IOCTL HW Parms")); 999 goto tryagain; 1000 } 1001 1002 if(ret) { 1003 if(fTryAgain == FALSE) { 1004 minperiodsize = hw_param_interval((¶ms), SNDRV_PCM_HW_PARAM_PERIOD_SIZE)->min; 1005 maxperiodsize = hw_param_interval((¶ms), SNDRV_PCM_HW_PARAM_PERIOD_SIZE)->max; 1006 dprintf(("Period size min=%lx max=%lx", minperiodsize, maxperiodsize)); 1007 if(minperiodsize > maxperiodsize) { 1008 //ALSA doesn't like the period size; try suggested one 1009 periodsize = maxperiodsize; 1010 periodbytes = samples_to_bytes(periodsize); 1011 dprintf((" Peroid size error IOCTL HW Parms")); 1012 fTryAgain = TRUE; 1013 goto tryagain; 1014 } 1015 } 1016 rprintf(("Error %ld second time.. Bailing", ret)); 1017 return UNIXToOSSError(ret); 1018 } 1019 1020 //set silence threshold (all sizes in frames) (only needed for playback) 1021 if(pHandle->file.f_mode == FMODE_WRITE) 1022 { 1023 swparams.avail_min = periodsize; 1024 swparams.period_step = 1; 1025 if(nrperiods <= 2) { 1026 swparams.silence_size = (periodsize/2); 1027 } 1028 else { 1029 swparams.silence_size = periodsize; 1030 } 1031 swparams.silence_threshold = swparams.silence_size; 1032 swparams.sleep_min = 0; 1033 swparams.start_threshold = 1; 1034 swparams.stop_threshold = periodsize*nrperiods; 1035 swparams.tstamp_mode = SNDRV_PCM_TSTAMP_NONE; 1036 swparams.xfer_align = periodsize; 1037 1038 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_SW_PARAMS, (ULONG)__Stack32ToFlat(&swparams)); 1039 } 1040 1041 total = 0; 1042 per_bytes = periodbytes; 1043 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_STATUS, (ULONG)__Stack32ToFlat(&status)); 1044 if ( ((status.state != SNDRV_PCM_STATE_PREPARED) && 1045 (status.state != SNDRV_PCM_STATE_SETUP) && 1046 (status.state != SNDRV_PCM_STATE_RUNNING) && 1047 (status.state != SNDRV_PCM_STATE_DRAINING))) { 1048 rprintf(("Device is not in proper state: %lx. Calling prepare\n", status.state)); 1049 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0); 1050 } 1051 return UNIXToOSSError(ret); 1061 1052 } 1062 1053 … … 1065 1056 ULONG CountWv=0; 1066 1057 ULONG LockAdd=0; 1067 extern 1058 extern ULONG xchg( ULONG *p, ULONG x); 1068 1059 #pragma aux xchg = "xchg [esi],eax" parm [ESI][EAX] value [EAX]; 1069 1060 //****************************************************************************** 1070 OSSRET OSS32_WaveAddBuffer(OSSSTREAMID streamid, ULONG buffer, ULONG size, ULONG *pTransferred, int pcm)1071 { 1072 soundhandle*pHandle = (soundhandle *)streamid;1073 struct snd_pcm_statusstatus;1074 int ret, align, size1, ret1;1075 LONG transferred;1076 ULONG position,i,j;1077 char*buf;1078 1079 // 1080 1081 1082 1083 1084 1085 if(pTransferred == NULL || buffer == 0 || size == 0) {1086 1087 1088 1089 1090 1091 1061 OSSRET OSS32_WaveAddBuffer(OSSSTREAMID streamid, ULONG ulBuffer, ULONG ulReqSize, ULONG *pulTransferred, int pcm) 1062 { 1063 soundhandle *pHandle = (soundhandle *)streamid; 1064 struct snd_pcm_status status; 1065 int iRet, align, iRet1; 1066 LONG ulTransferred; 1067 ULONG ulPosition, ulI, ulJ, ulSize; 1068 char *buf; 1069 1070 // return OSSERR_SUCCESS; 1071 1072 if(pHandle == NULL || pHandle->magic != MAGIC_WAVE_ALSA32) { 1073 DebugInt3(); 1074 return OSSERR_INVALID_STREAMID; 1075 } 1076 if(pulTransferred == NULL || ulBuffer == 0 || ulReqSize == 0) { 1077 DebugInt3(); 1078 return OSSERR_INVALID_PARAMETER; 1079 } 1080 1081 //set operation to non-blocking 1082 pHandle->file.f_flags = O_NONBLOCK; 1092 1083 1093 1084 /* get the status of the circular dma buffer */ 1094 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_STATUS, (ULONG)__Stack32ToFlat(&status));1095 1096 if( ret) {1097 DebugInt3(); 1098 return UNIXToOSSError( ret);1085 iRet = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_STATUS, (ULONG)__Stack32ToFlat(&status)); 1086 1087 if(iRet) { 1088 DebugInt3(); 1089 return UNIXToOSSError(iRet); 1099 1090 } 1100 1091 1101 1092 CountWv++; 1102 transferred = 0;1103 *pTransferred = 0;1104 ret = -11; 1105 switch(SNDRV_MINOR_DEVICE(MINOR(pHandle->inode.i_rdev-pcm))) 1106 { 1107 case SNDRV_MINOR_PCM_PLAYBACK: 1108 1093 ulTransferred = 0; 1094 *pulTransferred = 0; 1095 switch(SNDRV_MINOR_DEVICE(MINOR(pHandle->inode.i_rdev-pcm))) 1096 { 1097 case SNDRV_MINOR_PCM_PLAYBACK: 1098 1099 #if 1 1109 1100 //first check how much room is left in the circular dma buffer 1110 1101 //this is done to make sure we don't block inside ALSA while trying to write 1111 1102 //more data than fits in the internal dma buffer. 1112 size1 = size; 1113 size = min(size, samples_to_bytes(status.avail)); 1114 1115 #ifdef DEBUG 1103 ulSize = min(ulReqSize, samples_to_bytes(status.avail)); 1104 1105 if (ulSize == 0) { 1106 rprintf(("OSS32_WaveAddBuffer: no room left in hardware buffer!!\n")); 1107 rprintf(("state=%x avail=%x ReqSize=%x\n", status.state, status.avail, ulReqSize)); 1108 *pulTransferred = 0; 1109 return OSSERR_BUFFER_FULL; 1110 } 1111 1112 if (status.state == SNDRV_PCM_STATE_XRUN) { 1113 rprintf(("Internal Error: Xrun\n")); 1114 } 1115 1116 iRet = pHandle->file.f_op->write(&pHandle->file, (char *)ulBuffer, ulSize, &pHandle->file.f_pos); 1117 1118 if (iRet < 0 ) break; 1119 ulTransferred = iRet; 1120 #else 1121 //first check how much room is left in the circular dma buffer 1122 //this is done to make sure we don't block inside ALSA while trying to write 1123 //more data than fits in the internal dma buffer. 1124 ulSize = min(ulReqSize, samples_to_bytes(status.avail)); 1125 1116 1126 //printk("OSS32_WaveAddBuffer N:%d hw=%x app=%x avail=%x req size=%x size=%x\n", 1117 // CountWv, samples_to_bytes(status.hw_ptr), samples_to_bytes(status.appl_ptr), samples_to_bytes(status.avail), size1, size); 1118 #endif 1119 1120 if (size == 0) { 1121 #ifdef DEBUG_PK 1122 printk("OSS32_WaveAddBuffer: no room left in hardware buffer!!\n"); 1123 printk("state = %i\n",status.state); 1124 printk("avail = %i\n",status.avail); 1125 printk("size req = %i\n",size1); 1126 #endif 1127 *pTransferred = 0; 1128 return OSSERR_BUFFER_FULL; 1129 } 1127 // CountWv, samples_to_bytes(status.hw_ptr), samples_to_bytes(status.appl_ptr), samples_to_bytes(status.avail), ulSize, ulReqSize); 1128 1129 if (ulSize == 0) { 1130 rprintf(("OSS32_WaveAddBuffer: no room left in hardware buffer!!\n")); 1131 rprintf(("state=%x avail=%x SizeReq=%x\n", status.state, status.avail, ulReqSize)); 1132 *pulTransferred = 0; 1133 return OSSERR_BUFFER_FULL; 1134 } 1130 1135 1131 1136 // size should be aligned to channels number * samplesize //PS+++ what is it and why?!?!?! 1132 j = 10; // 10 try if error 1133 while (size && j && ret) 1137 ulJ = 10; // 10 try if error 1138 iRet = -11; 1139 while (ulSize && ulJ && iRet) 1134 1140 { 1135 for ( i=0; i < 1000; i++)1141 for (ulI=0; ulI < 1000; ulI++) 1136 1142 { 1137 ret1 = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_STATUS, (ULONG)__Stack32ToFlat(&status));1143 iRet1 = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_STATUS, (ULONG)__Stack32ToFlat(&status)); 1138 1144 // If here any state and have free buffer to any byte 1139 1145 if ((status.state != SNDRV_PCM_STATE_XRUN ) && samples_to_bytes(status.avail) ) break; 1140 if (i > 998) { 1146 if (status.state == SNDRV_PCM_STATE_XRUN) { 1147 rprintf(("Internal Error: Xrun\n")); 1148 } 1149 if (ulI > 998) { 1141 1150 // printk("timeout stat %x avail:%d hw:%d app:%d\n",status.state,samples_to_bytes(status.avail),samples_to_bytes(status.hw_ptr), samples_to_bytes(status.appl_ptr)); 1142 ret1 = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0);1151 iRet1 = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0); 1143 1152 } 1144 1153 } 1145 1154 1146 if ( ret1 < 0) {1147 // printk("Status Error ret1:%i trans: %i need %d tot:%d\n",ret1,transferred, size,size1);1148 break; 1155 if (iRet1 < 0) { 1156 // printk("Status Error iRet1:%i trans: %i need %d tot:%d\n",iRet1,ulTransferred, ulReqSize,ulSize); 1157 break; // We have any global error, don't try more 1149 1158 } 1150 1159 1151 ret = pHandle->file.f_op->write(&pHandle->file, (char *)buffer, size, &pHandle->file.f_pos);1152 1153 if ( ret < 0 ) { // We have any error, don't try more1154 j--;1155 if ( ret != -11 )1156 ret1 = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0);1157 // printk("Error ret:%i ret1:%i trans: %d need %d tot:%d\n", ret,ret1,transferred, size,size1);1160 iRet = pHandle->file.f_op->write(&pHandle->file, (char *)ulBuffer, ulSize, &pHandle->file.f_pos); 1161 1162 if (iRet < 0 ) { // We have any error, don't try more 1163 ulJ--; 1164 if ( iRet != -11 ) 1165 iRet1 = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0); 1166 // printk("Error ret:%i ret1:%i trans: %d need %d tot:%d\n",iRet,iRet1,ulTransferred, ulReqSize,ulSize); 1158 1167 continue; 1159 1168 } 1160 if (ret == 0) continue; 1161 transferred += ret; 1162 // printk("written: now: %d, trans: %d need %d tot:%d\n", ret, transferred, size,size1); 1163 buffer += ret; 1164 if (size > ret) 1165 size -= ret; 1166 else 1167 size = 0; 1168 } 1169 break; 1170 case SNDRV_MINOR_PCM_CAPTURE: 1171 #ifdef DEBUG 1169 if (iRet == 0) continue; 1170 ulTransferred += iRet; 1171 // printk("written: now: %d, trans: %d need %d tot:%d\n", iRet, ulTransferred, ulReqSize,ulSize); 1172 ulBuffer += iRet; 1173 if (ulSize > iRet) ulSize -= iRet; 1174 else ulSize = 0; 1175 } 1176 #endif 1177 break; 1178 case SNDRV_MINOR_PCM_CAPTURE: 1172 1179 //printk("OSS32_WaveAddBuffer N:%d state=%x hw=%x app=%x avail=%x size=%x\n", 1173 // CountWv, status.state, samples_to_bytes(status.hw_ptr), samples_to_bytes(status.appl_ptr), samples_to_bytes(status.avail), size); 1174 #endif 1180 // CountWv, status.state, samples_to_bytes(status.hw_ptr), samples_to_bytes(status.appl_ptr), samples_to_bytes(status.avail), ulReqSize); 1175 1181 // Need to handle overrun condition when reading 1176 1182 // if (status.state == SNDRV_PCM_STATE_XRUN) { 1177 // *pTransferred = 0;1183 // *pulTransferred = 0; 1178 1184 // return OSSERR_BUFFER_FULL; 1179 1185 // } 1180 transferred = pHandle->file.f_op->read(&pHandle->file, (char *)buffer, size, &pHandle->file.f_pos);1181 if ( transferred< 0) {1182 *pTransferred = 0;1186 iRet = pHandle->file.f_op->read(&pHandle->file, (char *)ulBuffer, ulReqSize, &pHandle->file.f_pos); 1187 if (iRet < 0) { 1188 *pulTransferred = 0; 1183 1189 return OSSERR_BUFFER_FULL; 1184 1190 } 1185 break; 1186 default: 1187 DebugInt3(); 1188 return OSSERR_INVALID_PARAMETER; 1189 } 1190 1191 total += transferred; 1192 *pTransferred = transferred; 1193 prev_size = transferred; 1194 // if (*pTransferred < size1) 1195 // { 1196 // printk("warning: transferred [%d] less than requested [%d]\n", *pTransferred, size1); 1197 // ret1 = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0); 1198 // } 1199 1200 return OSSERR_SUCCESS; 1191 ulTransferred = iRet; 1192 break; 1193 default: 1194 DebugInt3(); 1195 return OSSERR_INVALID_PARAMETER; 1196 } 1197 1198 total += ulTransferred; 1199 *pulTransferred = ulTransferred; 1200 prev_size = ulTransferred; 1201 // if (*pulTransferred < ulSize) 1202 // { 1203 // printk("warning: ulTransferred [%d] less than requested [%d]\n", *pulTransferred, ulSize); 1204 // iRet1 = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0); 1205 // } 1206 1207 return OSSERR_SUCCESS; 1201 1208 } 1202 1209 //****************************************************************************** … … 1204 1211 OSSRET OSS32_WaveGetPosition(ULONG streamid, ULONG *pPosition) 1205 1212 { 1206 soundhandle*pHandle = (soundhandle *)streamid;1207 struct snd_pcm_statusstatus;1208 intret;1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1213 soundhandle *pHandle = (soundhandle *)streamid; 1214 struct snd_pcm_status status; 1215 int ret; 1216 1217 if(pHandle == NULL || pHandle->magic != MAGIC_WAVE_ALSA32) { 1218 DebugInt3(); 1219 return OSSERR_INVALID_STREAMID; 1220 } 1221 if(pPosition == NULL) { 1222 DebugInt3(); 1223 return OSSERR_INVALID_PARAMETER; 1224 } 1225 1226 //set operation to non-blocking 1227 pHandle->file.f_flags = O_NONBLOCK; 1228 1229 //Get the status of the stream 1230 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_STATUS, (ULONG)__Stack32ToFlat(&status)); 1231 1232 if(ret) { 1233 DebugInt3(); 1234 return UNIXToOSSError(ret); 1235 } 1236 1237 dprintf2(("OSS32_WaveGetPosition: hardware %x application %x", samples_to_bytes(status.hw_ptr), samples_to_bytes(status.appl_ptr))); 1238 *pPosition = samples_to_bytes(status.hw_ptr); //return new hardware position 1239 return OSSERR_SUCCESS; 1233 1240 } 1234 1241 //****************************************************************************** … … 1236 1243 OSSRET OSS32_WaveGetSpace(ULONG streamid, ULONG *pBytesAvail) 1237 1244 { 1238 soundhandle*pHandle = (soundhandle *)streamid;1239 struct snd_pcm_statusstatus;1240 intret;1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1245 soundhandle *pHandle = (soundhandle *)streamid; 1246 struct snd_pcm_status status; 1247 int ret; 1248 1249 if(pHandle == NULL || pHandle->magic != MAGIC_WAVE_ALSA32) { 1250 DebugInt3(); 1251 return OSSERR_INVALID_STREAMID; 1252 } 1253 if(pBytesAvail == NULL) { 1254 DebugInt3(); 1255 return OSSERR_INVALID_PARAMETER; 1256 } 1257 1258 //set operation to non-blocking 1259 pHandle->file.f_flags = O_NONBLOCK; 1260 1261 //Get the nr of bytes left in the audio buffer 1262 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_STATUS, (ULONG)__Stack32ToFlat(&status)); 1263 1264 if(ret) { 1265 DebugInt3(); 1266 return UNIXToOSSError(ret); 1267 } 1268 ret = samples_to_bytes(status.avail); 1269 1270 *pBytesAvail = ret; 1271 return OSSERR_SUCCESS; 1265 1272 } 1266 1273 //****************************************************************************** … … 1268 1275 OSSRET OSS32_WaveGetHwPtr(ULONG streamid, ULONG *pPosition) 1269 1276 { 1270 soundhandle*pHandle = (soundhandle *)streamid;1271 struct snd_pcm_statusstatus;1272 intret;1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1277 soundhandle *pHandle = (soundhandle *)streamid; 1278 struct snd_pcm_status status; 1279 int ret; 1280 1281 if(pHandle == NULL || pHandle->magic != MAGIC_WAVE_ALSA32) { 1282 DebugInt3(); 1283 return OSSERR_INVALID_STREAMID; 1284 } 1285 if(pPosition == NULL) { 1286 DebugInt3(); 1287 return OSSERR_INVALID_PARAMETER; 1288 } 1289 1290 //set operation to non-blocking 1291 pHandle->file.f_flags = O_NONBLOCK; 1292 1293 //Get the status of the stream 1294 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_STATUS, (ULONG)__Stack32ToFlat(&status)); 1295 1296 if(ret) { 1297 DebugInt3(); 1298 return UNIXToOSSError(ret); 1299 } 1300 1301 *pPosition = samples_to_bytes(status.appl_ptr); //return new hardware position 1302 return OSSERR_SUCCESS; 1296 1303 } 1297 1304 //****************************************************************************** … … 1299 1306 OSSRET OSS32_WaveGetStatus(ULONG streamid, ULONG *pStatus) 1300 1307 { 1301 soundhandle*pHandle = (soundhandle *)streamid;1302 struct snd_pcm_statusstatus;1303 intret;1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1308 soundhandle *pHandle = (soundhandle *)streamid; 1309 struct snd_pcm_status status; 1310 int ret; 1311 1312 if(pHandle == NULL || pHandle->magic != MAGIC_WAVE_ALSA32) { 1313 DebugInt3(); 1314 return OSSERR_INVALID_STREAMID; 1315 } 1316 if(pStatus == NULL) { 1317 DebugInt3(); 1318 return OSSERR_INVALID_PARAMETER; 1319 } 1320 1321 //set operation to non-blocking 1322 pHandle->file.f_flags = O_NONBLOCK; 1323 1324 //Get the status of the stream 1325 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_STATUS, (ULONG)__Stack32ToFlat(&status)); 1326 1327 if(ret) { 1328 DebugInt3(); 1329 return UNIXToOSSError(ret); 1330 } 1331 1332 *pStatus = status.state; 1333 return OSSERR_SUCCESS; 1327 1334 } 1328 1335 //****************************************************************************** … … 1330 1337 OSSRET OSS32_WaveSetVolume(OSSSTREAMID streamid, ULONG volume) 1331 1338 { 1332 1333 intret;1334 intleftvol, rightvol;1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 pcm_volume.volume[SNDRV_PCM_VOL_REAR_LEFT]= leftvol;1351 1352 1353 1354 1355 1356 } 1357 //****************************************************************************** 1358 1339 soundhandle *pHandle = (soundhandle *)streamid; 1340 int ret; 1341 int leftvol, rightvol; 1342 struct snd_pcm_volume pcm_volume; 1343 1344 if(pHandle == NULL || pHandle->magic != MAGIC_WAVE_ALSA32) { 1345 DebugInt3(); 1346 return OSSERR_INVALID_STREAMID; 1347 } 1348 //set operation to non-blocking 1349 pHandle->file.f_flags = O_NONBLOCK; 1350 1351 leftvol = GET_VOLUME_L(volume); 1352 rightvol = GET_VOLUME_R(volume); 1353 1354 pcm_volume.nrchannels = 4; 1355 pcm_volume.volume[SNDRV_PCM_VOL_FRONT_LEFT] = leftvol; 1356 pcm_volume.volume[SNDRV_PCM_VOL_FRONT_RIGHT] = rightvol; 1357 pcm_volume.volume[SNDRV_PCM_VOL_REAR_LEFT] = leftvol; 1358 pcm_volume.volume[SNDRV_PCM_VOL_REAR_RIGHT] = rightvol; 1359 1360 dprintf(("OSS32_WaveSetVolume %x to (%d,%d)", streamid, leftvol, rightvol)); 1361 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_SETVOLUME, (ULONG)__Stack32ToFlat(&pcm_volume)); 1362 return UNIXToOSSError(ret); 1363 } 1364 //****************************************************************************** 1365 -
GPL/trunk/lib32/soundmidi.c
r305 r518 108 108 ret = alsa_fops->open(&pHandle->inode, &pHandle->file); 109 109 if(ret) { 110 dprintf(("Midi Open %d failed with error %d", streamtype, ret));110 rprintf(("Midi Open %d failed with error %d", streamtype, ret)); 111 111 kfree(pHandle); 112 112 return UNIXToOSSError(ret); … … 116 116 117 117 pHandle->state |= MIDISTATE_OPENED; 118 printk("Opened MIDI %x\n",(ULONG)pHandle);119 if(streamtype == OSS32_STREAM_FM_MIDIOUT) 118 dprintf(("Opened MIDI %x\n",(ULONG)pHandle)); 119 if(streamtype == OSS32_STREAM_FM_MIDIOUT) 120 120 { 121 121 //get the client id 122 122 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_SEQ_IOCTL_CLIENT_ID, (ULONG)&pHandle->clientid); 123 123 if(ret) { 124 dprintf(("Get client id failed with error %d", ret));124 rprintf(("Get client id failed with error %d", ret)); 125 125 kfree(pHandle); 126 126 return UNIXToOSSError(ret); 127 127 } 128 128 129 129 //find the FM device 130 for(i=64;i<64+((deviceid+1)<<3);i++) 130 for(i=64;i<64+((deviceid+1)<<3);i++) 131 131 { 132 132 memset((PVOID)__Stack32ToFlat(&clientinfo), 0, sizeof(clientinfo)); … … 143 143 } 144 144 if(i == 64+((deviceid+1)<<3)) { 145 dprintf(("Couldn't find OPL3 device"));145 rprintf(("Couldn't find OPL3 device")); 146 146 ret = pHandle->file.f_op->release(&pHandle->inode, &pHandle->file); 147 147 kfree(pHandle); … … 159 159 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_SEQ_IOCTL_CREATE_PORT, (ULONG)__Stack32ToFlat(&portinfo)); 160 160 if(ret) { 161 dprintf(("subscribe error %d", ret));161 rprintf(("subscribe error %d", ret)); 162 162 kfree(pHandle); 163 163 return UNIXToOSSError(ret); … … 165 165 pHandle->clientport = portinfo.addr.port; 166 166 pHandle->state |= MIDISTATE_PORTCREATED; 167 167 168 168 //subscribe to FM device port 169 169 memset(&subs, 0, sizeof(subs)); … … 174 174 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_SEQ_IOCTL_SUBSCRIBE_PORT, (ULONG)__Stack32ToFlat(&subs)); 175 175 if(ret) { 176 dprintf(("subscribe error %d", ret));176 rprintf(("subscribe error %d", ret)); 177 177 kfree(pHandle); 178 178 return UNIXToOSSError(ret); 179 179 } 180 180 pHandle->state |= MIDISTATE_SUBSCRIBED; 181 181 182 182 #if 0 183 183 //Load FM instruments (only done once) … … 200 200 return OSSERR_INVALID_STREAMID; 201 201 } 202 printk("Closing MIDI %x\n",(ULONG)streamid);202 dprintf(("Closing MIDI %x\n",(ULONG)streamid)); 203 203 204 204 //set operation to non-blocking … … 214 214 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_SEQ_IOCTL_UNSUBSCRIBE_PORT, (ULONG)__Stack32ToFlat(&subs)); 215 215 if(ret) { 216 dprintf(("unsubscribe error %d", ret));216 rprintf(("unsubscribe error %d", ret)); 217 217 DebugInt3(); 218 218 } 219 219 } 220 220 221 221 //delete port 222 222 if(pHandle->state & MIDISTATE_SUBSCRIBED) { 223 223 struct snd_seq_port_info portinfo; 224 224 225 225 memset(&portinfo, 0, sizeof(portinfo)); 226 226 strcpy(portinfo.name, "Unamed port"); … … 248 248 OSSRET OSS32_MidiWrite(OSSSTREAMID streamid, ULONG midiByte) 249 249 { 250 printk("MIDI write %x\n",(ULONG)streamid);250 dprintf(("MIDI write %x\n",(ULONG)streamid)); 251 251 return OSSERR_INVALID_STREAMID; 252 252 } … … 269 269 if (ret > 0) 270 270 { 271 printk("MIDI read %i bytes from %x. first byte is: %x\n",ret, (ULONG)streamid, (char*)buffer[0]);271 dprintf(("MIDI read %i bytes from %x. first byte is: %x\n",ret, (ULONG)streamid, (char*)buffer[0])); 272 272 *pTransferred = ret; 273 273 return OSSERR_SUCCESS; … … 279 279 OSSRET OSS32_MidiQueryCaps(OSSSTREAMID streamid, POSS32_MIDICAPS pCaps) 280 280 { 281 printk("MIDI query caps %x\n",(ULONG)streamid);281 dprintf(("MIDI query caps %x\n",(ULONG)streamid)); 282 282 return OSSERR_INVALID_STREAMID; 283 283 } … … 295 295 return OSSERR_INVALID_STREAMID; 296 296 } 297 printk("MIDI command %x\n",(ULONG)streamid);297 dprintf(("MIDI command %x\n",(ULONG)streamid)); 298 298 299 299 //set operation to non-blocking … … 334 334 335 335 if(transferred < 0) { 336 dprintf(("OSS32_MidiNoteOn failed!!"));336 rprintf(("OSS32_MidiNoteOn failed!!")); 337 337 DebugInt3(); 338 338 return UNIXToOSSError(transferred); -
GPL/trunk/lib32/soundmixer.c
r485 r518 474 474 } 475 475 if(idx == -1) { 476 dprintf(("Unknown control %d", line));476 rprintf(("Unknown control %d", line)); 477 477 ret = OSSERR_INVALID_PARAMETER; 478 478 goto fail; … … 512 512 } 513 513 514 printk("OSS32_MixSetVolume of %s streamid %X to (%d,%d)(%d,%d) caps %d\n",514 dprintf(("OSS32_MixSetVolume of %s streamid %X to (%d,%d)(%d,%d) caps %d", 515 515 pHandle->pids[idx].name, (ULONG)pHandle, 516 GET_VOLUME_L(volume), GET_VOLUME_R(volume), lVol, rVol, pElemInfo->value.integer.max); 517 516 GET_VOLUME_L(volume), GET_VOLUME_R(volume), lVol, rVol, pElemInfo->value.integer.max)); 517 518 #if 1 519 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_CTL_IOCTL_ELEM_WRITE, (ULONG)pElem); 520 #else 518 521 // looking for more, then one opened streams to prevent of muting active stream 519 522 cnt = 0; … … 522 525 cnt++; 523 526 527 dprintf(("OSS32_MixSetVolume old cnt=%X line=%x lVol=%x rVol=%x", cnt, line, lVol, rVol)); 524 528 // if (((cnt == 1 && (lVol==0 && rVol==0)) || (lVol>0 && rVol>0)) || 525 529 if (cnt == 1 || line != OSS32_MIX_VOLUME_PCM) 526 530 { 531 dprintf(("OSS32_MixSetVolume Ioctl")); 527 532 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_CTL_IOCTL_ELEM_WRITE, (ULONG)pElem); 528 533 … … 534 539 pElem->value.integer.value[0] = FALSE; //switch, not mute control (inversed) 535 540 pElem->value.integer.value[1] = FALSE; 541 dprintf(("OSS32_MixSetVolume Ioctl mute")); 536 542 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_CTL_IOCTL_ELEM_WRITE, (ULONG)pElem); 537 543 } 538 544 } 545 #endif 539 546 540 547 kfree(pElem); 541 548 pElem = NULL; 542 549 if(ret) { 543 printk("ret = %i\n", ret);550 rprintf(("OSS32_MixSetVolume ret=%x", ret)); 544 551 DebugInt3(); 545 552 return UNIXToOSSError(ret); -
GPL/trunk/uniaud.inc
r505 r518 13 13 # ex RC3 GA FIXPACK2 beta_47 14 14 # Comment out to avoid a fixpack line in bldlevel 15 FIXPACK = SVN r 49315 FIXPACK = SVN r518 16 16 17 17 # ALSA BUILD VERSION
Note:
See TracChangeset
for help on using the changeset viewer.