Get the sound driver compiling again......

No it still doesnt work.

svn path=/trunk/; revision=7783
This commit is contained in:
Steven Edwards 2004-01-20 00:29:48 +00:00
parent 1d8c431643
commit cc650c435b
7 changed files with 192 additions and 86 deletions

View file

@ -23,8 +23,8 @@
************************************/
unsigned char read_dsp(unsigned short base)
{
while((inb(base+0x0e)&0x80)==0); //Wait until there is something to read
return inb(base+0x0a);
// while((inb(base+0x0e)&0x80)==0); //Wait until there is something to read
// return inb(base+0x0a);
}
/************************************'
@ -54,24 +54,24 @@ sb_status detect_dsp(SB16* sb16)
**************************************/
sb_status reset_dsp(unsigned short base_address)
{
int delay;
// int delay;
outb(base_address+DSP_RESET_PORT,1);
for(delay=0;delay<0xffff;delay++);
// outb(base_address+DSP_RESET_PORT,1);
// for(delay=0;delay<0xffff;delay++);
outb(base_address+DSP_RESET_PORT,0);
for(delay=0;delay<0xffff;delay++);
// outb(base_address+DSP_RESET_PORT,0);
// for(delay=0;delay<0xffff;delay++);
if((inb(base_address+DSP_READ_STATUS_PORT)&0x80)==0) return SB_FALSE;
// if((inb(base_address+DSP_READ_STATUS_PORT)&0x80)==0) return SB_FALSE;
if(inb(base_address+DSP_READ_DATA_PORT)!=0xAA) return SB_FALSE;
// if(inb(base_address+DSP_READ_DATA_PORT)!=0xAA) return SB_FALSE;
return SB_TRUE;
}
void write_dsp(unsigned short base,unsigned char data)
{
while ((inb(base+DSP_WRITE_PORT) & 0x80) != 0);
outb(base+DSP_WRITE_PORT, data);
// while ((inb(base+DSP_WRITE_PORT) & 0x80) != 0);
// outb(base+DSP_WRITE_PORT, data);
}

View file

@ -1,28 +1,15 @@
#
#
#
# $Id: makefile,v 1.7 2004/01/20 00:29:48 sedwards Exp $
PATH_TO_TOP = ../../..
TARGET = sound
TARGET_TYPE = driver
OBJECTS = dsp.o mixer.o sb_waveout.o sound.o wave.o
TARGET_NAME = sb16
LIBS = $(PATH_TO_TOP)/ntoskrnl/ntoskrnl.a
TARGET_OBJECTS = sb16.o dsp.o mixer.o sb_waveout.o sound.o wave.o
all: $(TARGET).sys $(TARGET).sys.unstripped
.phony: all
clean:
- $(RM) *.o *.sym *.coff junk.tmp base.tmp temp.exp $(TARGET).sys $(TARGET).sys.unstripped
.phony: clean
install: $(FLOPPY_DIR)/drivers/$(TARGET).sys
$(FLOPPY_DIR)/drivers/$(TARGET).sys: $(TARGET).sys
$(CP) $(TARGET).sys $(FLOPPY_DIR)/drivers/$(TARGET).sys
$(TARGET).sys $(TARGET).sys.unstripped: $(OBJECTS) $(LIBS)
TARGET_CFLAGS = -Wall
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk

View file

@ -18,8 +18,8 @@
unsigned char read_mixer(unsigned short base,unsigned char reg)
{
outb(base+0x04,reg);
return inb(base+0x05);
// outb(base+0x04,reg);
// return inb(base+0x05);
}
unsigned char get_irq(SB16* sb16)

View file

@ -0,0 +1,58 @@
/* $Id: sb16.c,v 1.1 2004/01/20 00:29:48 sedwards Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: services/dd/sound/sb16.c
* PURPOSE: SB16 device driver
* PROGRAMMER: Steven Edwards
* UPDATE HISTORY:
* 19/01/04 Created
*
*/
/* INCLUDES ****************************************************************/
#include <ddk/ntddk.h>
#include <rosrtl/string.h>
#define NDEBUG
#include <debug.h>
NTSTATUS STDCALL
DriverEntry(PDRIVER_OBJECT DriverObject,
PUNICODE_STRING RegistryPath)
/*
* FUNCTION: Called by the system to initalize the driver
* ARGUMENTS:
* DriverObject = object describing this driver
* RegistryPath = path to our configuration entries
* RETURNS: Success or failure
*/
{
PDEVICE_OBJECT DeviceObject;
UNICODE_STRING DeviceName = ROS_STRING_INITIALIZER(L"\\Device\\SNDBLST");
UNICODE_STRING SymlinkName = ROS_STRING_INITIALIZER(L"\\??\\SNDBLST");
NTSTATUS Status;
DPRINT1("Sound Blaster 16 Driver 0.0.1\n");
DriverObject->Flags = 0;
Status = IoCreateDevice(DriverObject,
0,
&DeviceName,
FILE_DEVICE_BEEP,
0,
FALSE,
&DeviceObject);
if (!NT_SUCCESS(Status))
return Status;
/* Create the dos device link */
IoCreateSymbolicLink(&SymlinkName,
&DeviceName);
return(STATUS_SUCCESS);
}
/* EOF */

View file

@ -0,0 +1,39 @@
#include <defines.h>
#include <reactos/resource.h>
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
VS_VERSION_INFO VERSIONINFO
FILEVERSION RES_UINT_FV_MAJOR,RES_UINT_FV_MINOR,RES_UINT_FV_REVISION,RES_UINT_FV_BUILD
PRODUCTVERSION RES_UINT_PV_MAJOR,RES_UINT_PV_MINOR,RES_UINT_PV_REVISION,RES_UINT_PV_BUILD
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", RES_STR_COMPANY_NAME
VALUE "FileDescription", "ReactOS Boot Video\0"
VALUE "FileVersion", RES_STR_FILE_VERSION
VALUE "InternalName", "sb16\0"
VALUE "LegalCopyright", RES_STR_LEGAL_COPYRIGHT
VALUE "OriginalFilename", "sb16.sys\0"
VALUE "ProductName", RES_STR_PRODUCT_NAME
VALUE "ProductVersion", RES_STR_PRODUCT_VERSION
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END

View file

@ -4,7 +4,7 @@
* FILE: mkernel/modules/sound/sound.c
* PURPOSE: SoundBlaster 16 Driver
* PROGRAMMER: Snatched from David Welch (welch@mcmail.com)
* Modified for Soundblaster by Robert Bergkvist (fragdance@hotmail.com)
* Modified for Soundblaster by Robert Bergkvist (fragdance@hotmail.com)
* UPDATE HISTORY:
* ??/??/??: Created
*
@ -12,20 +12,16 @@
/* FUNCTIONS **************************************************************/
#include <internal/halio.h>
#include <ddk/ntddk.h>
#include <internal/hal/ddk.h>
#include <internal/dma.h>
#include <internal/mm.h>
#include <string.h>
#include <internal/string.h>
#include <devices.h>
#include "sb16.h"
#include "dsp.h"
#include "mixer.h"
#include "in.h"
#include "wave.h"
#define NDEBUG
#include <debug.h>
SB16 sb16;
sb_status sb16_getenvironment(void);
@ -45,7 +41,7 @@ NTSTATUS Dispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp)
switch (Stack->MajorFunction)
{
case IRP_MJ_CREATE:
printk("(SoundBlaster 16 Driver WaveOut) Creating\n");
DPRINT1("(SoundBlaster 16 Driver WaveOut) Creating\n");
reset_dsp(sb16.base);
status = STATUS_SUCCESS;
break;
@ -55,7 +51,7 @@ NTSTATUS Dispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp)
break;
case IRP_MJ_WRITE:
printk("(SoundBlaster 16 Driver) Writing %d bytes\n",Stack->Parameters.Write.Length);
DPRINT1("(SoundBlaster 16 Driver) Writing %d bytes\n",Stack->Parameters.Write.Length);
sb16_play((WAVE_HDR*)Irp->UserBuffer);
status = STATUS_SUCCESS;
break;
@ -84,10 +80,10 @@ NTSTATUS ModuleEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
PDEVICE_OBJECT DeviceObject;
NTSTATUS ret;
printk("SoundBlaster 16 Driver 0.0.1\n");
DPRINT1("SoundBlaster 16 Driver 0.0.1\n");
if(sb16_getenvironment()!=SB_TRUE)
{
printk("Soundblaster 16 not found\n");
DPRINT1("Soundblaster 16 not found\n");
return 0;
}
ret = IoCreateDevice(DriverObject,0,"\\Device\\WaveOut",FILE_DEVICE_WAVE_OUT,0,FALSE,&DeviceObject);
@ -108,17 +104,14 @@ sb_status sb16_getenvironment(void)
{
if(detect_dsp(&sb16)!=SB_TRUE)
{
printk("Detect DSP failed!!!\n");
DPRINT1("Detect DSP failed!!!\n");
return SB_FALSE;
}
printk("DSP base address 0x%x\n",sb16.base);
DPRINT1("DSP base address 0x%x\n",sb16.base);
get_irq(&sb16);
printk("IRQ: %d\n",sb16.irq);
DPRINT1("IRQ: %d\n",sb16.irq);
get_dma(&sb16);
printk("DMA8: 0x%x DMA16: 0x%x\n",sb16.dma8,sb16.dma16);
DPRINT1("DMA8: 0x%x DMA16: 0x%x\n",sb16.dma8,sb16.dma16);
return SB_TRUE;
}
#include "dsp.c"
#include "mixer.c"
#include "wave.c"

View file

@ -1,8 +1,37 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: mkernel/modules/sound/sound.c
* PURPOSE: SoundBlaster 16 Driver
* PROGRAMMER: Snatched from David Welch (welch@mcmail.com)
* Modified for Soundblaster by Robert Bergkvist (fragdance@hotmail.com)
* UPDATE HISTORY:
* ??/??/??: Created
*
*/
/* FUNCTIONS **************************************************************/
#include <ddk/ntddk.h>
#include <string.h>
#include <devices.h>
#include "sb16.h"
#include "dsp.h"
#include "mixer.h"
#include "in.h"
#include "wave.h"
#define NDEBUG
#include <debug.h>
SB16 sb16;
ULONG OldIRQ;
PKINTERRUPT IrqObject;
BOOLEAN DMAOutputISR(PKINTERRUPT Interrupt, PVOID ServiceContext)
{
printk("interrupt\n");
DPRINT1("interrupt\n");
return FALSE;
}
@ -21,11 +50,11 @@ void sb16_play(WAVE_HDR* wave)
dump_wav(wave);
do
{
tmp[i++]=get_dma_page(0x0fffff+IDMAP_BASE);
printk("0x%x ",tmp[i-1]);
// tmp[i++]=get_dma_page(0x0fffff);
// DPRINT1("0x%x ",tmp[i-1]);
}
while((tmp[i-1]&0xffff)!=0);
free_page((tmp[0])-IDMAP_BASE,i-1);
// free_page((tmp[0]),i-1);
sb16.buffer=((unsigned char*)tmp[i-1]);
/*
@ -47,9 +76,9 @@ void sb16_play(WAVE_HDR* wave)
IoConnectInterrupt(&IrqObject,DMAOutputISR,0,NULL,MappedIrq,Dirql,Dirql,0,FALSE,Affinity,FALSE);
mask=inb(0x21);
// mask=inb(0x21);
newmask=((int)1<<sb16.irq);
outb(0x21,(mask&~newmask));
// outb(0x21,(mask&~newmask));
// Restore the interrupt flag
__asm__("push %0\n\tpopf\n\t"
@ -58,20 +87,20 @@ void sb16_play(WAVE_HDR* wave)
disable_dma(sb16.dma8);
// disable_dma(sb16.dma8);
//outb(0x0a,5);
clear_dma_ff(1);
// clear_dma_ff(1);
//outb(0xc,0);
set_dma_count(1,wave->dLen);
set_dma_mode(1,DMA_MODE_WRITE);
// set_dma_count(1,wave->dLen);
//set_dma_mode(1,DMA_MODE_WRITE);
//outb(0xb,0x49);
//outb(0x3,(wave->dLen)&0xff);
//outb(0x3,((unsigned int)(wave->dLen)>>8)&0xff);
set_dma_addr(sb16.dma8,(unsigned int)sb16.buffer-IDMAP_BASE);
//set_dma_addr(sb16.dma8,(unsigned int)sb16.buffer);
//outb(0x83,(((unsigned int)(sb16.buffer-IDMAP_BASE)>>16))&0xf);
//outb(0x2,((unsigned int)sb16.buffer&0xff));
//outb(0x2,(((unsigned int)(sb16.buffer-IDMAP_BASE)>>8))&0xff);
enable_dma(sb16.dma8);
//enable_dma(sb16.dma8);
//outb(0xa,1);
write_dsp(sb16.base,0x00D1);
@ -79,14 +108,14 @@ void sb16_play(WAVE_HDR* wave)
write_dsp(sb16.base,0x40);
write_dsp(sb16.base,((unsigned char)256-(1000000/wave->nSamplesPerSec)));
outb(sb16.base + 4, (int) 0xa);
outb(sb16.base + 5, (int) 0x00);
// outb(sb16.base + 4, (int) 0xa);
// outb(sb16.base + 5, (int) 0x00);
outb(sb16.base + 4, (int) 4);
outb(sb16.base + 5, (int) 0xFF);
// outb(sb16.base + 4, (int) 4);
// outb(sb16.base + 5, (int) 0xFF);
outb(sb16.base + 4, (int) 0x22);
outb(sb16.base + 5, (int) 0xFF);
// outb(sb16.base + 4, (int) 0x22);
// outb(sb16.base + 5, (int) 0xFF);
write_dsp(sb16.base,0x14);
write_dsp(sb16.base,(wave->dLen&0x00ff));
@ -95,29 +124,29 @@ void sb16_play(WAVE_HDR* wave)
// write_dsp(sb16.base,0xc0);
// write_dsp(sb16.base,0x0);
// OldIRQ=HalGetInterruptVector(Internal,0,0,irq+8,&irql,&affinity);
// printk("OldIRQ: 0x%x\n",OldIRQ);
// DPRINT1("OldIRQ: 0x%x\n",OldIRQ);
// status=IoConnectInterrupt(&IrqObject,playRoutine,0,NULL,OldIRQ,irql,irql,0,FALSE,affinity,FALSE);
// if(status!=STATUS_SUCCESS) printk("Couldn't set irq\n");
// else printk("IRQ set\n");
// if(status!=STATUS_SUCCESS) DPRINT1("Couldn't set irq\n");
// else DPRINT1("IRQ set\n");
}
void dump_wav(WAVE_HDR* wave)
{
printk("wave.rID: %c%c%c%c\n",wave->rID[0],wave->rID[1],wave->rID[2],wave->rID[3]);
printk("wave.rLen: 0x%x\n",wave->rLen);
printk("wave.wID: %c%c%c%c\n",wave->wID[0],wave->wID[1],wave->wID[2],wave->wID[3]);
printk("wave.fID: %c%c%c%c\n",wave->fID[0],wave->fID[1],wave->fID[2],wave->fID[3]);
printk("wave.fLen: 0x%x\n",wave->fLen);
printk("wave.wFormatTag: 0x%x\n",wave->wFormatTag);
printk("wave.nChannels: 0x%x\n",wave->nChannels);
printk("wave.nSamplesPerSec: 0x%x\n",wave->nSamplesPerSec);
printk("wave.nAvgBytesPerSec: 0x%x\n",wave->nAvgBytesPerSec);
printk("wave.nBlockAlign: 0x%x\n",wave->nBlockAlign);
printk("wave.FormatSpecific: 0x%x\n",wave->FormatSpecific);
printk("wave.dID: %c%c%c%c\n",wave->dID[0],wave->dID[1],wave->dID[2],wave->dID[3]);
printk("wave.dLen: 0x%x\n",wave->dLen);
DPRINT1("wave.rID: %c%c%c%c\n",wave->rID[0],wave->rID[1],wave->rID[2],wave->rID[3]);
DPRINT1("wave.rLen: 0x%x\n",wave->rLen);
DPRINT1("wave.wID: %c%c%c%c\n",wave->wID[0],wave->wID[1],wave->wID[2],wave->wID[3]);
DPRINT1("wave.fID: %c%c%c%c\n",wave->fID[0],wave->fID[1],wave->fID[2],wave->fID[3]);
DPRINT1("wave.fLen: 0x%x\n",wave->fLen);
DPRINT1("wave.wFormatTag: 0x%x\n",wave->wFormatTag);
DPRINT1("wave.nChannels: 0x%x\n",wave->nChannels);
DPRINT1("wave.nSamplesPerSec: 0x%x\n",wave->nSamplesPerSec);
DPRINT1("wave.nAvgBytesPerSec: 0x%x\n",wave->nAvgBytesPerSec);
DPRINT1("wave.nBlockAlign: 0x%x\n",wave->nBlockAlign);
DPRINT1("wave.FormatSpecific: 0x%x\n",wave->FormatSpecific);
DPRINT1("wave.dID: %c%c%c%c\n",wave->dID[0],wave->dID[1],wave->dID[2],wave->dID[3]);
DPRINT1("wave.dLen: 0x%x\n",wave->dLen);
}
BOOLEAN playRoutine(PKINTERRUPT Interrupt,PVOID ServiceContext)