Subversion Repositories shark

Rev

Rev 547 | Rev 1063 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

/*
 * Project: S.Ha.R.K.
 *
 * Coordinators:
 *   Giorgio Buttazzo    <giorgio@sssup.it>
 *   Paolo Gai           <pj@gandalf.sssup.it>
 *
 * Authors     :
 *   Mauro Marinoni      <mauro.marinoni@unipv.it>
 *   (see the web pages for full authors list)
 *
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
 *
 * http://www.sssup.it
 * http://retis.sssup.it
 * http://shark.sssup.it
 */


//#define __MOUSE_DEBUG__ 1

#include <kernel/kern.h>

#include "../include/drivers/shark_input26.h"
#include "../include/drivers/shark_spk26.h"

/* Devices */
extern int pcspkr_init(void);
extern int pcspkr_exit(void);

/* Handlers */
extern int  speaker_init(void);
extern void speaker_exit(void);

/* Functions */
extern void spk_mksound(unsigned int hz, unsigned int ticks);
extern void spk_nosound(unsigned long ignored);

static int speaker_installed;

/* User Functions */
void speaker_sound(unsigned int hz, unsigned int ticks)
{
        spk_mksound(hz, ticks);
}

void speaker_mute(void)
{
        spk_nosound(0);
}

/* Init the Linux Speaker Driver */
int SPEAK26_installed()
{
        return speaker_installed;
}

int SPEAK26_init()
{
        int ret;

        if (speaker_installed == TRUE) return 0;

        if (INPUT26_installed() == FALSE)
                if (INPUT26_init()) {
                        printk(KERN_ERR "Unable to open Input SubSystem.\n");
                        return -1;
                }

        ret = pcspkr_init();
        if (ret) {
                printk(KERN_ERR "PcSpkr_Init return: %d\n", ret);
                return -1;
        }

        ret = speaker_init();
        if (ret) {
                printk(KERN_ERR "Speaker_Init return: %d\n", ret);
                return -1;
        }

        speaker_installed = TRUE;

        return 0;
}

int SPEAK26_close()
{
        if (!speaker_installed)
                return -1;

        speaker_exit();
        pcspkr_exit();

        speaker_installed = TRUE;

        return 0;
}