/data/common/Makefile.main |
---|
131,7 → 131,6 |
drivers/emu10k1x.obj:DRIVERS/EMU10K1X.OBJ:$(KERNEL)/drivers/emu10k1x.asm \ |
drivers/fm801.obj:DRIVERS/FM801.OBJ:$(KERNEL)/drivers/fm801.asm \ |
drivers/infinity.obj:DRIVERS/INFINITY.OBJ:$(KERNEL)/drivers/infinity.asm \ |
drivers/sb16.obj:DRIVERS/SB16.OBJ:$(KERNEL)/drivers/sb16/sb16.asm \ |
drivers/sound.obj:DRIVERS/SOUND.OBJ:$(KERNEL)/drivers/sound.asm \ |
drivers/intelac97.obj:DRIVERS/INTELAC97.OBJ:$(KERNEL)/drivers/intelac97.asm \ |
drivers/vt823x.obj:DRIVERS/VT823X.OBJ:$(KERNEL)/drivers/vt823x.asm \ |
230,6 → 229,7 |
drivers/ps2mouse.sys:DRIVERS/PS2MOUSE.SYS:$(REPOSITORY)/drivers/mouse/ps2mouse4d/trunk/ps2mouse.asm \ |
drivers/tmpdisk.sys:DRIVERS/TMPDISK.SYS:$(REPOSITORY)/drivers/disk/tmpdisk.asm \ |
drivers/intel_hda.sys:DRIVERS/intel_hda.sys:$(REPOSITORY)/drivers/audio/intel_hda/intel_hda.asm \ |
drivers/sb16.sys:DRIVERS/SB16.SYS:$(REPOSITORY)/drivers/audio/sb16/sb16.asm \ |
# end of list |
# The list of all FASM programs with one main FASM file for CD image. |
# Format of an item is exactly the same as in the previous list. |
/drivers/audio/sb16/CONFIG.INC |
---|
0,0 → 1,45 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;flags------------------------------------------------------------ |
DEBUG equ 1 ;show messages at debug board |
use_cli_sti equ 1 ;driver become more stable (theoretically) |
;constants-------------------------------------------------------- |
API_VERSION equ 0 ;debug |
sb_irq_num equ 5 ;default values for SB16, may be overrided by autodetect |
sb_dma_num equ 5 ;default values for SB16, may be overrided by autodetect |
small_buffer equ 32768 |
full_buffer equ 65536 |
sb_buffer_size equ small_buffer ; FIX ring buffer overlapped events issue; full_buffer |
__supported_buffer_sizes fix <small_buffer, full_buffer> |
if ~(sb_buffer_size in __supported_buffer_sizes) |
display 13,10,'unsupported buffer size was selected, check config.inc',13,10 |
stop |
end if |
sb_out_rate equ 48000 |
;time constant for cards older than SB16 |
sb_tc equ (256-(1000000/(sb_out_rate*2))) |
SRV_GETVERSION equ 0 |
DEV_PLAY equ 1 |
DEV_STOP equ 2 |
DEV_CALLBACK equ 3 |
DEV_SET_BUFF equ 4 |
DEV_NOTIFY equ 5 |
DEV_SET_MASTERVOL equ 6 |
DEV_GET_MASTERVOL equ 7 |
DEV_GET_INFO equ 8 |
DRV_ENTRY equ 1 |
DRV_EXIT equ -1 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/drivers/audio/sb16/SB16.INC |
---|
0,0 → 1,313 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;-------------------------------- |
; program dma |
;-------------------------------- |
sb_set_dma: |
mov ebx, [sound_dma] |
lea eax, [ebx+4];mask required channel |
cmp bl, 4 |
ja .use_second_dma_controller |
jb @f |
.dma_setup_error: |
if DEBUG |
mov esi, msgErrDMAsetup |
invoke SysMsgBoardStr |
end if |
mov dword[esp], START.stop |
ret |
@@: |
if use_cli_sti |
cli ;here to minimize time with disabled ints |
end if |
out 0xA, al;mask required channel |
xor eax, eax |
out 0xC, al;clear byte pointer flip-flop register |
lea eax, [ebx+0x58];auto-init mode for channel (ebx) |
out 0xB, al;DMA channel 0-3 mode register |
mov eax, [SB16Buffer] |
invoke GetPhysAddr |
mov ecx, eax |
shr eax, 16 |
movzx edx, byte[ebx+dma_table];page register |
out dx, al |
lea edx, [ebx*2];DMA channel 0-3 base address |
mov al, cl;LSB |
out dx, al |
mov al, ch;MSB |
out dx, al |
inc edx ;DMA channel 0-3 byte count |
mov al, ((sb_buffer_size-1) and 0xff) |
out dx, al |
mov al, ((sb_buffer_size-1) shr 8);it is the same |
out dx, al |
mov eax, ebx;unmask DMA channel |
out 0xA, al |
if use_cli_sti |
sti |
end if |
ret |
.use_second_dma_controller: |
cmp bl, 7 |
ja .dma_setup_error |
sub bl, 4 |
sub al, 4 |
if use_cli_sti |
cli ;here to minimize time with disabled ints |
end if |
out 0xD4, al;mask required channel |
xor eax, eax |
out 0xD8, al;clear byte pointer flip-flop register |
lea eax, [ebx+0x58];auto-init mode for channel (ebx+4) |
out 0xD6, al;DMA channel 4-7 mode register |
mov eax, [SB16Buffer] |
invoke GetPhysAddr |
mov ecx, eax |
shr eax, 16 |
shr ecx, 1 ; 16-bit DMA takes offset in words |
movzx edx, byte[ebx+dma_table+4];page register |
out dx, al |
lea edx, [ebx*4+0xC0];DMA channel 4-7 base address |
mov al, cl;LSB;for 16bit DMA this contains |
out dx, al;A1-A8 lines of address bus, A0 is zero |
mov al, ch;MSB;for 16bit DMA this contains |
out dx, al;A9-A16 lines of address bus |
inc edx |
inc edx ;DMA channel 4-7 16bit word count |
mov al, (((sb_buffer_size/2)-1) and 0xff) |
out dx, al |
mov al, (((sb_buffer_size/2)-1) shr 8) |
out dx, al |
mov eax, ebx;unmask DMA channel |
out 0xD4, al |
if use_cli_sti |
sti |
end if |
ret |
;------------------------------------------------------------------------------- |
; out byte to SB DSP's write port |
;------------------------------------------------------------------------------- |
macro sb_out data_to_out { |
@@: |
in al, dx |
test al, al;is DSP busy? |
js @b ;it's busy |
mov al, data_to_out;it's free |
out dx, al |
} |
;------------------------------------------------------------------------------- |
; stop playing |
;------------------------------------------------------------------------------- |
proc sb_stop |
mov edx, [sb_base_port] |
add dl, 0xC |
sb_out 0xD3 ;turn the speaker off |
sb_out 0xDA ;exit 8bit DMA |
sb_out 0xD9 ;exit 16bit DMA |
ret |
endp |
;------------------------------------------------------------------------------- |
; start playing |
;------------------------------------------------------------------------------- |
proc sb_play |
and [int_flip_flop], 0 |
mov edx, [sb_base_port] |
add dl, 0xC |
sb_out 0xD1 ;turn speaker on |
; sb_out 0x48 ;set DSP transfer size ;for older cards, not supported |
; ;in this version |
; mov ax,32767 ;(64k)/2-1 |
;@@: ;out the low byte... |
; in al,dx |
; test al,al ;is DSP busy? |
; js @b ;it's busy |
; out dx,al |
; mov al,ah ;...then the high byte |
;@@: |
; in al,dx |
; test al,al ;is DSP busy? |
; js @b ;it's busy |
; out dx,al |
; sb_out 0x1C ;auto-init 8bit playback |
; 0xBXh - 16 bit DMA mode |
; |||| |
sb_out 10110110b ;bCommand |
; |||| |
; |||+-reserved |
; ||+--turn FIFO on (0 for off) |
; |+---auto-init mode on (0 for off) |
; +----A/D: 0-output, 1-input |
; +------stereo on |
; |+-----unsigned (1 for signed) |
; || |
sb_out 00110000b ;bMode |
; || |||| |
; ---------reserved |
;wSize is a number of 16bit samples less 1. For auto-init mode each half |
;buffer is (64k)/2 bytes long and, obviously, contains ((64k)/2)/2 samples |
sb_out (((sb_buffer_size/2/2)-1) and 0xFF) ;wSize.LowByte |
sb_out (((sb_buffer_size/2/2)-1) shr 8) ;wSize.HighByte |
ret |
endp |
;------------------------------------------------------------------------------- |
; reset DSP |
;------------------------------------------------------------------------------- |
proc sb_reset |
and [int_flip_flop], 0 |
mov edx, [sb_base_port] |
add dl, 6 |
mov al, 1;start DSP reset |
if use_cli_sti |
cli ;here to minimize time with disabled ints |
end if |
out dx, al |
mov ecx, 40;wait at least 3 microsec. |
@@: |
in al, dx |
loop @b |
xor eax, eax;stop DSP reset |
if use_cli_sti |
sti |
end if |
out dx, al |
ret |
endp |
;------------------------------------------------------------------------------- |
; set the rate for playing, enable stereo |
;------------------------------------------------------------------------------- |
proc sb_setup |
mov edx, [sb_base_port] |
add dl, 0xC |
sb_out 40h ;set time constant, this is for old cards |
sb_out sb_tc |
sb_out 41h ;set sound rate, this can only SB16 |
sb_out (sb_out_rate shr 8) ;first high byte (MSB) |
sb_out (sb_out_rate and 0xff) ;then low byte (LSB) |
; mov al,0xE ;for older cards, not supported in this version |
; sub dl,(0xC-4) ;talk to SB's mixer |
; out dx,al ;select this register of the mixer |
; mov ecx,6 ;wait for the chip |
;@@: |
; in al,dx |
; loop @b |
; inc edx ;now read the data port |
; in al,dx |
; or al,22h ;turn on stereo |
; mov ah,al |
; mov al,0xE |
; dec edx ;talk to SB's mixer |
; out dx,al ;select this register of the mixer |
; mov ecx,6 ;wait for the chip |
;@@: |
; in al,dx |
; loop @b |
; inc edx ;now send data to the data port |
; mov al,ah |
; out dx,al |
; dec edx |
; mov ecx,35 ;wait for the chip |
;@@: |
; in al,dx |
; loop @b |
ret |
endp |
;------------------------------------------------------------------------------- |
; set master volume of SB mixer, note, not only SB16 but SBPro and older |
; this is the first step to more full support for hardware |
;------------------------------------------------------------------------------- |
;in: eax in range [-10000;0] - master volume for _both_ channels |
;note that x*3*17/2000 and x*3/2000*17 are not the same numbers, |
;because we count in integers |
proc sb_set_master_vol |
mov [sb_master_vol], eax |
add eax, 10000;SB sound level rise from 0 to MAX_LEVEL |
lea eax, [eax+eax*2];*3 |
mov ebx, 2000;divisor |
xor edx, edx |
cmp byte[sb_DSP_version_int], 4 |
jae @f ;SBPro's MAX_LEVEL is 15, but we *11 because |
;volume byte looks like that: 0xLR, where L - left |
;channel volume, R - right, 0<=R,L<=15 |
div ebx |
imul eax, 17 |
mov edx, [sb_base_port] |
push eax ;here for optimisation |
add dl, 4 |
mov al, 0x22;write mixer register 0x22 |
out dx, al |
in al, dx;wait for the chip ;6 |
in al, dx;wait for the chip ;5 |
in al, dx;wait for the chip ;4 |
in al, dx;wait for the chip ;3 |
in al, dx;wait for the chip ;2 |
in al, dx;wait for the chip ;1 |
pop eax ;go! |
inc edx |
out dx, al |
ret |
@@: ;SB16's MAX_LEVEL is 255 |
imul eax, 17 |
div ebx |
mov edx, [sb_base_port] |
push eax ;here for optimisation |
add dl, 4 |
mov al, 0x30;left speaker |
out dx, al |
pop eax ;<--+ |
inc edx ; \/ |
push eax ;here for optimisation |
out dx, al;write |
dec edx |
mov al, 0x31;right speaker |
out dx, al |
pop eax |
inc edx |
out dx, al;write |
ret |
endp |
;------------------------------------------------------------------------------- |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/drivers/audio/sb16/sb16.asm |
---|
0,0 → 1,382 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
format PE DLL native 0.05 |
entry START |
include 'CONFIG.INC' |
section '.flat' code readable writable executable |
include '..\..\struct.inc' |
include '..\..\macros.inc' |
include '..\..\proc32.inc' |
include '..\..\peimport.inc' |
include 'SB16.INC' |
;------------------------------------------------------------------------------- |
proc START c uses ebx esi edi, state:dword, cmdline:dword |
cmp [state], 1 |
jne .stop |
.entry: |
if DEBUG |
mov esi, msgInit |
invoke SysMsgBoardStr |
end if |
call detect ;returns DSP version or zero if |
test eax, eax ;SB card not found |
jz .exit |
if DEBUG |
movzx eax, al ;major version |
mov esi, sb_DSP_description |
dec eax |
jz .sb_say_about_found_dsp |
mov dword[esi], '2.x ' |
dec eax |
jz .sb_say_about_found_dsp |
mov dword[esi], 'Pro ' |
dec eax |
jz .sb_say_about_found_dsp |
mov dword[esi], '16 ' |
.sb_say_about_found_dsp: |
mov esi, msgDSPFound |
invoke SysMsgBoardStr |
end if |
xor ebx, ebx |
mov ecx, [sb_base_port] |
lea edx, [ecx+0xF] |
invoke ReservePortArea ;these ports must be mine ! |
dec eax |
jnz @f |
if DEBUG |
mov esi, msgErrRsrvPorts |
invoke SysMsgBoardStr |
end if |
jmp .exit |
@@: |
invoke AllocDMA24, sb_buffer_size |
test eax, eax |
jz .exit |
mov [SB16Buffer], eax |
call sb_setup ;clock it, etc |
invoke AttachIntHandler, sb_irq_num, sb_irq, 0 |
if DEBUG |
test eax, eax |
jnz @f |
mov esi, msgErrAtchIRQ |
invoke SysMsgBoardStr |
; stdcall GetIntHandler, sb_irq_num |
; call SysMsgBoardNum |
jmp .stop |
@@: |
mov esi, msgSucAtchIRQ |
invoke SysMsgBoardStr |
end if |
invoke RegService, my_service, service_proc |
ret |
.stop: |
call sb_reset |
.exit: |
if DEBUG |
mov esi, msgExit |
invoke SysMsgBoardStr |
end if |
xor eax, eax |
ret |
endp |
;------------------------------------------------------------------------------- |
proc service_proc stdcall uses ebx esi edi, ioctl:dword |
mov edi, [ioctl] |
mov eax, [edi+IOCTL.io_code] |
cmp eax, SRV_GETVERSION |
jne @F |
mov eax, [edi+IOCTL.output] |
cmp [edi+IOCTL.out_size], 4 |
jne .fail |
mov [eax], dword API_VERSION |
xor eax, eax |
ret |
@@: |
cmp eax, DEV_PLAY |
jne @f |
if DEBUG |
mov esi, msgPlay |
invoke SysMsgBoardStr |
end if |
call sb_stop ;to play smth new we must stop smth old |
call pre_fill_data ;fill first and second half of the buffer |
call pre_fill_data ; |
call sb_set_dma ;is it really needed here? Paranoia. |
call sb_play |
xor eax, eax ;set maximum volume |
call sb_set_master_vol |
xor eax, eax |
ret |
;@@: ;all this commented stuff in service proc |
; cmp eax,DEV_STOP ;is never used. Mixer do this virtually, |
; jne @f ;e.g. instead of stopping driver it |
;if DEBUG ;outputs silence |
; mov esi,msgStop |
; call SysMsgBoardStr |
;end if |
; call sb_stop |
; xor eax,eax |
; ret |
@@: |
cmp eax, DEV_CALLBACK |
jne @f |
if DEBUG |
mov esi, msgCallback |
invoke SysMsgBoardStr |
end if |
mov edi, [edi+IOCTL.input] |
mov eax, [edi] |
mov [callback], eax |
if DEBUG |
call SysMsgBoardNum |
end if |
xor eax, eax |
ret |
@@: |
cmp eax, DEV_SET_MASTERVOL;Serge asked me to unlock |
jne @F ;DEV_SET(GET)_MASTERVOL, although mixer doesn't use it. |
;It doesn't use it _in current version_ - but in the future... |
if DEBUG |
mov esi, msgSetVol |
invoke SysMsgBoardStr |
end if |
mov eax, [edi+IOCTL.input] |
mov eax, [eax] |
call sb_set_master_vol |
xor eax, eax |
ret |
@@: |
cmp eax, DEV_GET_MASTERVOL |
jne @F |
if DEBUG |
mov esi, msgGetVol |
invoke SysMsgBoardStr |
end if |
mov eax, [edi+IOCTL.output] |
mov edx, [sb_master_vol] |
mov [eax], edx |
xor eax, eax |
ret |
.fail: |
or eax, -1 |
ret |
endp |
;------------------------------------------------------------------------------- |
proc sb_irq |
mov edx, [sb_base_port];tell the DSP that we have processed IRQ |
add dl, 0xF ;0xF for 16 bit sound, 0xE for 8 bit sound |
in al, dx ;for non-stop sound |
pre_fill_data: |
mov eax, int_flip_flop |
not dword[eax] |
mov eax, [eax] |
test eax, eax |
jns .fill_second_half |
if sb_buffer_size eq small_buffer |
mov eax, [SB16Buffer] |
stdcall [callback], eax ;for 32k buffer |
else if sb_buffer_size eq full_buffer |
mov eax, [SB16Buffer] |
push eax |
stdcall [callback], eax ;for 64k buffer |
pop eax |
add eax, 16384 |
stdcall [callback], eax ;for 64k buffer |
end if |
xor eax, eax |
not eax |
ret |
.fill_second_half: |
if sb_buffer_size eq small_buffer |
mov eax, [SB16Buffer] |
add eax, 16384 |
stdcall [callback], eax ;for 32k buffer |
else if sb_buffer_size eq full_buffer |
mov eax, [SB16Buffer] |
add eax, 32768 |
push eax |
stdcall [callback], eax ;for 64k buffer |
pop eax |
add eax, 16384 |
stdcall [callback], eax ;for 64k buffer |
end if |
xor eax, eax |
not eax |
ret |
endp |
;------------------------------------------------------------------------------- |
align 4 |
proc detect |
.sb_detect_next_port: |
if DEBUG |
inc dword[port_second_digit_num] |
end if |
mov edx, sb_base_port |
add byte[edx], 10h |
cmp byte[edx], 80h |
jbe .sb_try_to_detect_at_specified_port |
;error - no SB card detected |
.sb_not_found_err: |
xor eax, eax |
ret |
.sb_try_to_detect_at_specified_port: |
call sb_reset |
add dl, 8 |
mov ecx, 100 |
.sb_check_port: |
in al, dx |
test al, al ;is DSP port ready to be read? |
jns .sb_port_not_ready |
sub dl, 4 |
in al, dx ;check for AAh response |
add dl, 4 |
cmp al, 0xAA |
jne .sb_port_not_ready |
.sb_card_found: |
and dl, 0xF0 |
add dl, 0xC |
sb_out 0xE1 ;get DSP version |
add dl, 2 |
@@: |
in al, dx |
test al, al ;is DSP port ready to be read? |
jns @b |
sub dl, 4 |
in al, dx ;get major version |
ror eax, 16 |
add dl, 4 |
@@: |
in al, dx |
test al, al ;is DSP port ready to be read? |
jns @b |
sub dl, 4 |
in al, dx ;get minor version |
xor edx, edx |
mov dl, 10 |
div dl |
ror eax, 16 |
xor ah, ah |
mov [sb_DSP_version_int], eax;for internal usage |
if DEBUG |
add [sb_DSP_version], eax |
end if |
ret |
.sb_port_not_ready: |
loop .sb_check_port ;100 retries (~100 microsec.) |
jmp .sb_detect_next_port |
endp |
;------------------------------------------------------------------------------- |
if DEBUG |
proc SysMsgBoardNum ;warning: destroys eax,ebx,ecx,esi |
mov ebx, eax |
mov ecx, 8 |
mov esi, (number_to_out+1) |
.1: |
mov eax, ebx |
and eax, 0xF |
add al, '0' |
cmp al, (10+'0') |
jb @f |
add al, ('A'-'0'-10) |
@@: |
mov [esi+ecx], al |
shr ebx, 4 |
loop .1 |
dec esi |
invoke SysMsgBoardStr |
ret |
endp |
end if |
;all initialized data place here |
align 4 |
sb_base_port: |
dd 200h ;don't ask me why - see the code&docs |
sound_dma dd sb_dma_num |
;note that 4th DMA channel doesn't exist, it is used for cascade |
;plugging the first DMA controler to the second |
dma_table db 0x87,0x83,0x81,0x82,0xFF,0x8B,0x89,0x8A |
my_service db 'SOUND',0 ;max 16 chars include zero |
if DEBUG |
number_to_out db '0x00000000',13,10,0 |
msgInit db 'detecting hardware...',13,10,0 |
msgExit db 'exiting... May be some problems found?',13,10,0 |
msgPlay db 'start play',13,10,0 |
;msgStop db 'stop play',13,10,0 |
msgCallback db 'set_callback received from the mixer!',13,10 |
db 'callback handler is: ',0 |
msgErrAtchIRQ db 'failed to attach IRQ',(sb_irq_num+'0'),13,10 |
db 'owner',39,'s handler: ',0 |
msgSucAtchIRQ db 'succesfully attached IRQ',(sb_irq_num+'0') |
db ' as hardcoded',13,10,0 |
msgErrRsrvPorts db 'failed to reserve needed ports.',13,10,0 |
msgSetVol db 'DEV_SET_MASTERVOL call came',13,10,0 |
msgGetVol db 'DEV_GET_MASTERVOL call came',13,10,0 |
msgErrDMAsetup db 'failed to setup DMA - bad channel',13,10,0 |
;------------------------------------------------------------------------------- |
msgDSPFound db 'DSP found at port 2' |
label port_second_digit_num dword at $ |
db '00h',13,10,'DSP version ' |
sb_DSP_version: |
db '0.00 - SB' |
sb_DSP_description: |
db 32,32,32,32,13,10,0 |
;------------------------------------------------------------------------------- |
end if |
align 4 |
data fixups |
end data |
align 4 |
SB16Buffer rd 1 |
callback rd 1 |
int_flip_flop rd 1 |
sb_master_vol rd 1 |
sb_DSP_version_int rd 1 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/drivers/audio/sb16/README.TXT |
---|
0,0 → 1,72 |
Nable 21.05.2008. |
This driver is my contribution (or donation) to KolibriOS. This is provided |
AS IS in hope it'll be useful, but WITHOUT ANY WARRANTY! No responcibility |
for any hardware damage or data loss. Use at your own risk! |
;------------------------------------------------------------------------------- |
;Changelog: |
;------------------------------------------------------------------------------- |
v0.2 - DEV_SET(GET)_MASTERVOL functions are unlocked and implemented. |
v0.1 - first release. |
;------------------------------------------------------------------------------- |
;Tiny FAQ for sound driver by Nable for SB16 sound card. |
;------------------------------------------------------------------------------- |
;What is it?-------------------------------------------------------------------- |
As you may know there is a sound subsystem ('INFINITY') in KolibriOS. |
This subsystem includes mixer and separate interface for soundplayer |
program and driver, so player application don't need to know what soundcard |
is installed and how to cope with it, all work with card do the driver. |
Before this time there were drivers only for AC97 integrated sound, but I |
don't have such at home and if I would upgrade my computer with a newest |
hardware, with 100% probability integrated sound will be HD Codec, nowadays |
AC97 is not actual (2008 year is at calendar). But I'm not planning to upgrade |
my computer so much now (and in next 5-6 years), writing the driver for my PCI |
ESS Maestro1 card is difficult for me (may be some time later), so I decided |
to write a driver for SB16. At first it is easy, there are many working |
examples for DOS, there are heaps of good documentation and as an ISA device |
SB16 can be programmed through I/O ports (about 5 ports are used), that is |
more easy than PCI access. Now, enough lirics, lets go to physics :-) |
If you still don't understand what stuff is it, I'll tell this in brief: |
with this driver you can play MP3 and WAV music (using AC97SND player) and |
sounds (some games and DOSBOX can produce sound output through sound |
subsystem) in KolibriOS. |
;Yeah! I need sound in Kolibri and I have SB16 card. Whats then?---------------- |
At first copy my SOUND.OBJ to /sys/drivers at your Kolibri system. Note, |
that if you have AC97 card and it's driver started - then new driver won't |
run until reboot. Then run BOARD and go to 'user' tab. Then try to run |
AC97SND player. At BOARD you will see the following (if you had a proper |
card): |
|----------------------------| |
|detecting hardware... | <- detector startup message |
|DSP found at port 220h | <- if you have a proper card, it'll be |
|DSP version 4.13 - SB16 | autodetected. Numbers may be different. |
|failed to attach IRQ5 | <- don't mention. Old kernels reserve IRQ5 |
|owner's handler: 0x80D74284 | see below how to fix it. |
|----------------------------| |
At first, note that DSP version must be 4.xx or higher. Older cards are not |
supported in this first release, maybe some time later. If nothing detected |
but PNP/BIOS or some other OS detects your card - I'm sorry, it's perverted |
PNP card like OPTi16, that is like HD Codec - until you init it through |
PCI->ISA bridge (HD Codec of course through PCI->PCI bridge), map it, etc, |
you can't use it in any way. I'd rather write a PCI device driver, than |
for this extreme perversion. If your card detected and has a proper version |
but you see 'failed to attach IRQ' - delete stroke 'mov [irq_owner+4*5],1' from the |
file kernel.asm of your kernel source, save it, rebuild kernel, copy new |
kernel to /sys/ (did you rename 'kernel' to 'kernel.mnt'? You should do it), |
restart kernel (Ctrl+Alt+F12, Home). THE EASIER WAY IS TO USE A NEWER KERNEL, |
since SVN802 it's fixed. |
Now everything should be OK. |
;It works for a part of the second and then stops, but system doesn't hang------ |
Go to 'config.inc' of my driver and change 'sb_irq_num' value from 5 to 7. |
Then save, rebuild driver (compile 'sound.asm'), put 'sound' to /sys/drivers/ |
(you need to rename file 'sound' to 'sound.obj'), restart kernel and try again |
to produce sound. |
;------------------------------------------------------------------------------- |
Ask your questions at KolibriOS forum: board.kolibrios.org |
I'll try to answer you if possible. |
/drivers/peimport.inc |
---|
96,6 → 96,7 |
Kmalloc,\ |
Kfree,\ |
CreateRingBuffer,\ |
AllocDMA24,\ |
\ |
GetPid,\ |
CreateThread,\ |
/kernel/trunk/blkdev/rd.inc |
---|
22,11 → 22,6 |
.size = $ - ramdisk_functions |
endg |
; See memmap.inc. |
; Currently size of memory allocated for the ramdisk is fixed. |
; This should be revisited when/if memory map would become more dynamic. |
RAMDISK_CAPACITY = 2880 ; in sectors |
iglobal |
align 4 |
ramdisk_actual_size dd RAMDISK_CAPACITY |
/kernel/trunk/const.inc |
---|
228,10 → 228,6 |
CLEAN_ZONE equ (_CLEAN_ZONE-OS_BASE) |
IDE_DMA equ (_IDE_DMA-OS_BASE) |
; unused? |
SB16Buffer equ (OS_BASE+0x02A0000) |
SB16_Status equ (OS_BASE+0x02B0000) |
UPPER_KERNEL_PAGES equ (OS_BASE+0x0400000) |
virtual at (OS_BASE+0x05FFF80) |
/kernel/trunk/core/exports.inc |
---|
48,6 → 48,7 |
get_phys_addr, 'GetPhysAddr', \ ; eax |
map_space, 'MapSpace', \ |
release_pages, 'ReleasePages', \ |
alloc_dma24, 'AllocDMA24', \ ; stdcall |
\ |
mutex_init, 'MutexInit', \ ; gcc fastcall |
mutex_lock, 'MutexLock', \ ; gcc fastcall |
/kernel/trunk/core/memory.inc |
---|
350,6 → 350,31 |
ret |
endp |
uglobal |
sb16_buffer_allocated db 0 |
endg |
; Allocates [.size] bytes so that the target memory block |
; is inside one 64K page for 24-bit DMA controller, |
; that is, somewhere between 00xx0000h and 00xxFFFFh. |
proc alloc_dma24 |
; Implementation note. |
; The only user of that function is SB16 driver, |
; so just return a statically allocated buffer. |
virtual at esp |
dd ? ; return address |
.size dd ? |
end virtual |
cmp [sb16_buffer_allocated], 0 |
jnz .fail |
inc [sb16_buffer_allocated] |
mov eax, SB16Buffer |
ret 4 |
.fail: |
xor eax, eax |
ret 4 |
endp |
; Allocates a physical page for master page table |
; that duplicates first Mb of OS_BASE at address 0; |
; used for starting APs and for shutting down, |
/kernel/trunk/data32.inc |
---|
523,16 → 523,21 |
org (OS_BASE+0x0100000) |
RAMDISK: rb 2880*512 |
rb 2856*4 ; not used |
; Currently size of memory allocated for the ramdisk is fixed. |
; This should be revisited when/if memory map would become more dynamic. |
RAMDISK_CAPACITY = 2880 ; in sectors |
RAMDISK: rb RAMDISK_CAPACITY*512 |
_CLEAN_ZONE: |
BgrAuxTable rb 32768 |
align 65536 |
SB16Buffer rb 65536 |
align 4096 |
_IDE_DMA rb 16*512 |
BgrAuxTable rb 32768 |
BUTTON_INFO rb 64*1024 |
RESERVED_PORTS: rb 64*1024 |
FLOPPY_BUFF: rb 18*512 ;one track |
sys_pgmap: rb 1024*1024/8 |
/kernel/trunk/drivers/sb16/sb16.asm |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/kernel/trunk/drivers/sb16/README.TXT |
---|
File deleted |
\ No newline at end of file |
/kernel/trunk/drivers/sb16/CONFIG.INC |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/kernel/trunk/drivers/sb16/SB16.INC |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |