Subversion Repositories shark

Rev

Rev 1063 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
519 mauro 1
/*
2
 * Project: S.Ha.R.K.
3
 *
4
 * Coordinators:
5
 *   Giorgio Buttazzo    <giorgio@sssup.it>
6
 *   Paolo Gai           <pj@gandalf.sssup.it>
7
 *
8
 * Authors     :
9
 *   Mauro Marinoni      <mauro.marinoni@unipv.it>
10
 *   (see the web pages for full authors list)
11
 *
12
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
13
 *
14
 * http://www.sssup.it
15
 * http://retis.sssup.it
16
 * http://shark.sssup.it
17
 */
18
 
1063 tullio 19
/*
20
 * This program is free software; you can redistribute it and/or modify
21
 * it under the terms of the GNU General Public License as published by
22
 * the Free Software Foundation; either version 2 of the License, or
23
 * (at your option) any later version.
24
 *
25
 * This program is distributed in the hope that it will be useful,
26
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28
 * GNU General Public License for more details.
29
 *
30
 * You should have received a copy of the GNU General Public License
31
 * along with this program; if not, write to the Free Software
32
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
33
 *
34
 */
35
 
522 mauro 36
//#define __MOUSE_DEBUG__ 1
519 mauro 37
 
38
#include <kernel/kern.h>
39
 
40
#include "../include/drivers/shark_input26.h"
41
#include "../include/drivers/shark_spk26.h"
42
 
43
/* Devices */
44
extern int pcspkr_init(void);
45
extern int pcspkr_exit(void);
46
 
47
/* Handlers */
48
extern int  speaker_init(void);
49
extern void speaker_exit(void);
50
 
51
/* Functions */
52
extern void spk_mksound(unsigned int hz, unsigned int ticks);
53
extern void spk_nosound(unsigned long ignored);
54
 
549 mauro 55
static int speaker_installed;
519 mauro 56
 
57
/* User Functions */
58
void speaker_sound(unsigned int hz, unsigned int ticks)
59
{
60
        spk_mksound(hz, ticks);
61
}
62
 
63
void speaker_mute(void)
64
{
65
        spk_nosound(0);
66
}
67
 
68
/* Init the Linux Speaker Driver */
549 mauro 69
int SPEAK26_installed()
70
{
71
        return speaker_installed;
72
}
73
 
519 mauro 74
int SPEAK26_init()
75
{
76
        int ret;
77
 
549 mauro 78
        if (speaker_installed == TRUE) return 0;
79
 
80
        if (INPUT26_installed() == FALSE)
519 mauro 81
                if (INPUT26_init()) {
82
                        printk(KERN_ERR "Unable to open Input SubSystem.\n");
83
                        return -1;
84
                }
85
 
86
        ret = pcspkr_init();
87
        if (ret) {
88
                printk(KERN_ERR "PcSpkr_Init return: %d\n", ret);
89
                return -1;
90
        }
91
 
92
        ret = speaker_init();
93
        if (ret) {
94
                printk(KERN_ERR "Speaker_Init return: %d\n", ret);
95
                return -1;
96
        }
549 mauro 97
 
98
        speaker_installed = TRUE;
99
 
519 mauro 100
        return 0;
101
}
102
 
103
int SPEAK26_close()
104
{
549 mauro 105
        if (!speaker_installed)
106
                return -1;
107
 
519 mauro 108
        speaker_exit();
109
        pcspkr_exit();
549 mauro 110
 
111
        speaker_installed = TRUE;
112
 
519 mauro 113
        return 0;
114
}
115