Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenwave.c
Go to the documentation of this file.
00001 /* 00002 * COPYRIGHT: See COPYING in the top level directory 00003 * PROJECT: ReactOS kernel 00004 * FILE: mkernel/modules/sound/sound.c 00005 * PURPOSE: SoundBlaster 16 Driver 00006 * PROGRAMMER: Snatched from David Welch (welch@mcmail.com) 00007 * Modified for Soundblaster by Robert Bergkvist (fragdance@hotmail.com) 00008 * UPDATE HISTORY: 00009 * ??/??/??: Created 00010 * 00011 */ 00012 00013 /* FUNCTIONS **************************************************************/ 00014 00015 #include <ntddk.h> 00016 #include <string.h> 00017 #include <devices.h> 00018 00019 #include "sb16.h" 00020 #include "dsp.h" 00021 #include "mixer.h" 00022 #include "in.h" 00023 #include "wave.h" 00024 00025 #define NDEBUG 00026 #include <debug.h> 00027 00028 SB16 sb16; 00029 00030 ULONG OldIRQ; 00031 PKINTERRUPT IrqObject; 00032 00033 static BOOLEAN NTAPI DMAOutputISR(PKINTERRUPT Interrupt, PVOID ServiceContext) 00034 { 00035 DPRINT1("interrupt\n"); 00036 return FALSE; 00037 } 00038 00039 void sb16_play(WAVE_HDR* wave) 00040 { 00041 ULONG MappedIrq; 00042 KIRQL Dirql; 00043 KAFFINITY Affinity; 00044 PKINTERRUPT IrqObject; 00045 unsigned int newmask; 00046 00047 unsigned int i; 00048 unsigned int tmp[255]; 00049 i=0; 00050 dump_wav(wave); 00051 do 00052 { 00053 // tmp[i++]=get_dma_page(0x0fffff); 00054 // DPRINT1("0x%x ",tmp[i-1]); 00055 } 00056 while((tmp[i-1]&0xffff)!=0); 00057 // free_page((tmp[0]),i-1); 00058 sb16.buffer=((unsigned char*)tmp[i-1]); 00059 00060 /* 00061 * Because this is used by alomost every subsystem including irqs it 00062 * must be atomic. The following code sequence disables interrupts after 00063 * saving the previous state of the interrupt flag 00064 */ 00065 00066 _disable(); 00067 00068 memcpy(sb16.buffer,(&wave->data),wave->dLen); 00069 00070 00071 MappedIrq = HalGetInterruptVector(Internal,0,0,8+sb16.irq,&Dirql,&Affinity); 00072 00073 00074 00075 IoConnectInterrupt(&IrqObject,DMAOutputISR,0,NULL,MappedIrq,Dirql,Dirql,0,FALSE,Affinity,FALSE); 00076 00077 // mask=inb(0x21); 00078 newmask=((int)1<<sb16.irq); 00079 // outb(0x21,(mask&~newmask)); 00080 00081 // Restore the interrupt flag 00082 _enable(); 00083 00084 00085 00086 // disable_dma(sb16.dma8); 00087 //outb(0x0a,5); 00088 // clear_dma_ff(1); 00089 //outb(0xc,0); 00090 // set_dma_count(1,wave->dLen); 00091 //set_dma_mode(1,DMA_MODE_WRITE); 00092 //outb(0xb,0x49); 00093 //outb(0x3,(wave->dLen)&0xff); 00094 //outb(0x3,((unsigned int)(wave->dLen)>>8)&0xff); 00095 //set_dma_addr(sb16.dma8,(unsigned int)sb16.buffer); 00096 //outb(0x83,(((unsigned int)(sb16.buffer-IDMAP_BASE)>>16))&0xf); 00097 //outb(0x2,((unsigned int)sb16.buffer&0xff)); 00098 //outb(0x2,(((unsigned int)(sb16.buffer-IDMAP_BASE)>>8))&0xff); 00099 //enable_dma(sb16.dma8); 00100 //outb(0xa,1); 00101 00102 write_dsp(sb16.base,0x00D1); 00103 00104 write_dsp(sb16.base,0x40); 00105 write_dsp(sb16.base,((unsigned char)256-(1000000/wave->nSamplesPerSec))); 00106 00107 // outb(sb16.base + 4, (int) 0xa); 00108 // outb(sb16.base + 5, (int) 0x00); 00109 00110 // outb(sb16.base + 4, (int) 4); 00111 // outb(sb16.base + 5, (int) 0xFF); 00112 00113 // outb(sb16.base + 4, (int) 0x22); 00114 // outb(sb16.base + 5, (int) 0xFF); 00115 00116 write_dsp(sb16.base,0x14); 00117 write_dsp(sb16.base,(wave->dLen&0x00ff)); 00118 write_dsp(sb16.base,((wave->dLen)&0xff00)>>8); 00119 00120 // write_dsp(sb16.base,0xc0); 00121 // write_dsp(sb16.base,0x0); 00122 // OldIRQ=HalGetInterruptVector(Internal,0,0,irq+8,&irql,&affinity); 00123 // DPRINT1("OldIRQ: 0x%x\n",OldIRQ); 00124 00125 // status=IoConnectInterrupt(&IrqObject,playRoutine,0,NULL,OldIRQ,irql,irql,0,FALSE,affinity,FALSE); 00126 // if(status!=STATUS_SUCCESS) DPRINT1("Couldn't set irq\n"); 00127 // else DPRINT1("IRQ set\n"); 00128 00129 } 00130 00131 void dump_wav(WAVE_HDR* wave) 00132 { 00133 DPRINT1("wave.rID: %c%c%c%c\n",wave->rID[0],wave->rID[1],wave->rID[2],wave->rID[3]); 00134 DPRINT1("wave.rLen: 0x%x\n",wave->rLen); 00135 DPRINT1("wave.wID: %c%c%c%c\n",wave->wID[0],wave->wID[1],wave->wID[2],wave->wID[3]); 00136 DPRINT1("wave.fID: %c%c%c%c\n",wave->fID[0],wave->fID[1],wave->fID[2],wave->fID[3]); 00137 DPRINT1("wave.fLen: 0x%x\n",wave->fLen); 00138 DPRINT1("wave.wFormatTag: 0x%x\n",wave->wFormatTag); 00139 DPRINT1("wave.nChannels: 0x%x\n",wave->nChannels); 00140 DPRINT1("wave.nSamplesPerSec: 0x%x\n",wave->nSamplesPerSec); 00141 DPRINT1("wave.nAvgBytesPerSec: 0x%x\n",wave->nAvgBytesPerSec); 00142 DPRINT1("wave.nBlockAlign: 0x%x\n",wave->nBlockAlign); 00143 DPRINT1("wave.FormatSpecific: 0x%x\n",wave->FormatSpecific); 00144 DPRINT1("wave.dID: %c%c%c%c\n",wave->dID[0],wave->dID[1],wave->dID[2],wave->dID[3]); 00145 DPRINT1("wave.dLen: 0x%x\n",wave->dLen); 00146 } 00147 00148 BOOLEAN playRoutine(PKINTERRUPT Interrupt,PVOID ServiceContext) 00149 { 00150 return FALSE; 00151 } Generated on Sun May 27 2012 04:24:43 for ReactOS by
1.7.6.1
|