Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
/* Project:     HARTIK 3.0 Sound Library                        */
2
/* Description: Hard Real TIme Kernel for 8086 compatible       */
3
/* Author:      Luca Abeni                                      */
4
/* Date:        5/12/1997                                       */
5
 
6
/* File:        Blaster.C                                       */
7
/* Revision:    3.0                                             */
8
 
9
/* Sound Blaster 16 low-level register access functions */
10
#include <kernel/kern.h>
11
#include "sbio.h"
12
 
13
/* Write in a SB16 mixer register */
14
void sbmixer_write(WORD base, BYTE index, BYTE c)
15
{
16
    ll_out(base + MIXERREGISTER, index);
17
    ll_out(base + MIXERDATA, c);
18
}
19
 
20
/* Read a byte from a SB16 mixer register */
21
BYTE sbmixer_read(WORD base, BYTE index)
22
{
23
    ll_out(base + MIXERREGISTER, index);
24
    return(ll_in(base + MIXERDATA));
25
}
26
 
27
/* Find a SB16 in the system: return the base I/O address or 0 if not found */
28
WORD sb_probe (void)
29
{
30
    WORD base;
31
    int done = 0;
32
 
33
    base = 0x0200;
34
    while ((!done) && (base < 0x0270)) {
35
        base += 0x10;
36
        done = sbdsp_reset(base);
37
    }
38
    if (done == 0) {
39
        base = 0;
40
    }
41
    return base;
42
}
43
 
44
/* Reset the SB16 DSP: return 1 if OK, 0 if fail */
45
BYTE sbdsp_reset(WORD base)
46
{
47
    int x;
48
 
49
    ll_in(base + DATAAVAILABLE);
50
    ll_out(base + RESET,0x01);
51
    ll_in(base + RESET);
52
    ll_in(base + RESET);
53
    ll_in(base + RESET);
54
    ll_in(base + RESET);
55
    ll_out(base + RESET,0x00);
56
    for(x = 0; x < 100; x++) {
57
        if(ll_in(base + DATAAVAILABLE)&0x80) {
58
            if(ll_in(base + READDATA) == 0xAA) break;
59
        }
60
    }
61
    if(x == 100)
62
        return 0;
63
    else return 1;
64
}
65
 
66
/* Write in SB16 DSP register */
67
void sbdsp_write (WORD base, BYTE c )
68
{
69
    while(ll_in(base + WRITEBUFFERSTATUS)&0x80);
70
    ll_out(base + WRITEBUFFERSTATUS,c);
71
}
72
 
73
/* Read a byte from SB16 DSP register */
74
BYTE sbdsp_read (WORD base)
75
{
76
    while(!(ll_in(base + DATAAVAILABLE)&0x80));
77
    return(ll_in(base + READDATA));
78
}