version 1.23, 2009/04/10 10:18:50 |
version 1.23.14.1, 2011/11/19 21:49:38 |
|
|
/* $NetBSD$ */ |
/* $NetBSD$ */ |
|
|
/* |
/* |
* Copyright (c) 1998 The NetBSD Foundation, Inc. |
* Copyright (c) 1998, 2008 The NetBSD Foundation, Inc. |
* All rights reserved. |
* All rights reserved. |
* |
* |
* This code is derived from software contributed to The NetBSD Foundation |
* This code is derived from software contributed to The NetBSD Foundation |
* by Lennart Augustsson (augustss@NetBSD.org). |
* by Lennart Augustsson (augustss@NetBSD.org), and by Andrew Doran. |
* |
* |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* modification, are permitted provided that the following conditions |
Line 37 __KERNEL_RCSID(0, "$NetBSD$"); |
|
Line 37 __KERNEL_RCSID(0, "$NetBSD$"); |
|
#include <sys/kernel.h> |
#include <sys/kernel.h> |
#include <sys/errno.h> |
#include <sys/errno.h> |
#include <sys/device.h> |
#include <sys/device.h> |
#include <sys/malloc.h> |
|
#include <sys/proc.h> |
#include <sys/proc.h> |
#include <sys/conf.h> |
#include <sys/conf.h> |
#include <sys/select.h> |
#include <sys/select.h> |
#include <sys/audioio.h> |
#include <sys/audioio.h> |
#include <sys/midiio.h> |
#include <sys/midiio.h> |
|
#include <sys/tty.h> |
#include <sys/bus.h> |
#include <sys/bus.h> |
|
|
#include <dev/isa/pcppivar.h> |
#include <dev/isa/pcppivar.h> |
Line 64 static int midi_pcppi_match(device_t, cf |
|
Line 63 static int midi_pcppi_match(device_t, cf |
|
static void midi_pcppi_attach(device_t, device_t, void *); |
static void midi_pcppi_attach(device_t, device_t, void *); |
static int midi_pcppi_detach(device_t, int); |
static int midi_pcppi_detach(device_t, int); |
|
|
void midi_pcppi_on (midisyn *, uint_fast16_t, midipitch_t, int16_t); |
static void midi_pcppi_on (midisyn *, uint_fast16_t, midipitch_t, int16_t); |
void midi_pcppi_off (midisyn *, uint_fast16_t, uint_fast8_t); |
static void midi_pcppi_off (midisyn *, uint_fast16_t, uint_fast8_t); |
void midi_pcppi_close(midisyn *); |
static void midi_pcppi_close(midisyn *); |
static void midi_pcppi_repitchv(midisyn *, uint_fast16_t, midipitch_t); |
static void midi_pcppi_repitchv(midisyn *, uint_fast16_t, midipitch_t); |
|
|
CFATTACH_DECL3_NEW(midi_pcppi, sizeof(struct midi_pcppi_softc), |
CFATTACH_DECL3_NEW(midi_pcppi, sizeof(struct midi_pcppi_softc), |
midi_pcppi_match, midi_pcppi_attach, midi_pcppi_detach, NULL, NULL, NULL, |
midi_pcppi_match, midi_pcppi_attach, midi_pcppi_detach, NULL, NULL, NULL, |
DVF_DETACH_SHUTDOWN); |
DVF_DETACH_SHUTDOWN); |
|
|
struct midisyn_methods midi_pcppi_hw = { |
static struct midisyn_methods midi_pcppi_hw = { |
.close = midi_pcppi_close, |
.close = midi_pcppi_close, |
.attackv = midi_pcppi_on, |
.attackv = midi_pcppi_on, |
.releasev = midi_pcppi_off, |
.releasev = midi_pcppi_off, |
Line 101 midi_pcppi_attach(device_t parent, devic |
|
Line 100 midi_pcppi_attach(device_t parent, devic |
|
strcpy(ms->name, "PC speaker"); |
strcpy(ms->name, "PC speaker"); |
ms->nvoice = 1; |
ms->nvoice = 1; |
ms->data = pa->pa_cookie; |
ms->data = pa->pa_cookie; |
|
ms->lock = &tty_lock; |
|
|
midi_pcppi_attached++; |
midi_pcppi_attached++; |
|
|
Line 121 midi_pcppi_detach(device_t self, int fla |
|
Line 121 midi_pcppi_detach(device_t self, int fla |
|
return mididetach(self, flags); |
return mididetach(self, flags); |
} |
} |
|
|
void |
static void |
midi_pcppi_on(midisyn *ms, |
midi_pcppi_on(midisyn *ms, |
uint_fast16_t voice, midipitch_t mp, int16_t level) |
uint_fast16_t voice, midipitch_t mp, int16_t level) |
{ |
{ |
pcppi_tag_t t = ms->data; |
pcppi_tag_t t = ms->data; |
|
|
pcppi_bell(t, |
KASSERT(mutex_owned(&tty_lock)); |
MIDIHZ18_TO_HZ(MIDIPITCH_TO_HZ18(mp)), |
|
MAX_DURATION * hz, 0); |
pcppi_bell_locked(t, MIDIHZ18_TO_HZ(MIDIPITCH_TO_HZ18(mp)), |
|
MAX_DURATION * hz, 0); |
} |
} |
|
|
void |
static void |
midi_pcppi_off(midisyn *ms, uint_fast16_t voice, uint_fast8_t vel) |
midi_pcppi_off(midisyn *ms, uint_fast16_t voice, uint_fast8_t vel) |
{ |
{ |
pcppi_tag_t t = ms->data; |
pcppi_tag_t t = ms->data; |
|
|
|
KASSERT(mutex_owned(&tty_lock)); |
|
|
/*printf("OFF %p %d\n", t, note >> 16);*/ |
/*printf("OFF %p %d\n", t, note >> 16);*/ |
pcppi_bell(t, 0, 0, 0); |
pcppi_bell_locked(t, 0, 0, 0); |
} |
} |
|
|
void |
static void |
midi_pcppi_close(midisyn *ms) |
midi_pcppi_close(midisyn *ms) |
{ |
{ |
pcppi_tag_t t = ms->data; |
pcppi_tag_t t = ms->data; |
|
|
|
KASSERT(mutex_owned(&tty_lock)); |
|
|
/* Make sure we are quiet. */ |
/* Make sure we are quiet. */ |
pcppi_bell(t, 0, 0, 0); |
pcppi_bell_locked(t, 0, 0, 0); |
} |
} |
|
|
static void |
static void |
midi_pcppi_repitchv(midisyn *ms, uint_fast16_t voice, midipitch_t newpitch) |
midi_pcppi_repitchv(midisyn *ms, uint_fast16_t voice, midipitch_t newpitch) |
{ |
{ |
|
KASSERT(mutex_owned(&tty_lock)); |
|
|
midi_pcppi_on(ms, voice, newpitch, 64); |
midi_pcppi_on(ms, voice, newpitch, 64); |
} |
} |