Subversion Repositories shark

Rev

Rev 1063 | Details | Compare with Previous | 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
 
1063 tullio 9
/*
10
 * This program is free software; you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by
12
 * the Free Software Foundation; either version 2 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program; if not, write to the Free Software
22
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
 *
24
 */
25
 
2 pj 26
/* Sound Blaster 16 low-level register access functions */
27
#include <kernel/kern.h>
28
#include "sbio.h"
29
 
30
/* Write in a SB16 mixer register */
31
void sbmixer_write(WORD base, BYTE index, BYTE c)
32
{
33
    ll_out(base + MIXERREGISTER, index);
34
    ll_out(base + MIXERDATA, c);
35
}
36
 
37
/* Read a byte from a SB16 mixer register */
38
BYTE sbmixer_read(WORD base, BYTE index)
39
{
40
    ll_out(base + MIXERREGISTER, index);
41
    return(ll_in(base + MIXERDATA));
42
}
43
 
44
/* Find a SB16 in the system: return the base I/O address or 0 if not found */
45
WORD sb_probe (void)
46
{
47
    WORD base;
48
    int done = 0;
49
 
50
    base = 0x0200;
51
    while ((!done) && (base < 0x0270)) {
52
        base += 0x10;
53
        done = sbdsp_reset(base);
54
    }
55
    if (done == 0) {
56
        base = 0;
57
    }
58
    return base;
59
}
60
 
61
/* Reset the SB16 DSP: return 1 if OK, 0 if fail */
62
BYTE sbdsp_reset(WORD base)
63
{
64
    int x;
65
 
66
    ll_in(base + DATAAVAILABLE);
67
    ll_out(base + RESET,0x01);
68
    ll_in(base + RESET);
69
    ll_in(base + RESET);
70
    ll_in(base + RESET);
71
    ll_in(base + RESET);
72
    ll_out(base + RESET,0x00);
73
    for(x = 0; x < 100; x++) {
74
        if(ll_in(base + DATAAVAILABLE)&0x80) {
75
            if(ll_in(base + READDATA) == 0xAA) break;
76
        }
77
    }
78
    if(x == 100)
79
        return 0;
80
    else return 1;
81
}
82
 
83
/* Write in SB16 DSP register */
84
void sbdsp_write (WORD base, BYTE c )
85
{
86
    while(ll_in(base + WRITEBUFFERSTATUS)&0x80);
87
    ll_out(base + WRITEBUFFERSTATUS,c);
88
}
89
 
90
/* Read a byte from SB16 DSP register */
91
BYTE sbdsp_read (WORD base)
92
{
93
    while(!(ll_in(base + DATAAVAILABLE)&0x80));
94
    return(ll_in(base + READDATA));
95
}