ACPI frontend for Yamaha OPL3-SA[23].
Derived from PR kern/33991 by jasper at pointless dot net.
This commit is contained in:
parent
1a3062e81b
commit
cdb1835aff
@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: ym.4,v 1.15 2005/06/22 04:30:08 kent Exp $
|
||||
.\" $NetBSD: ym.4,v 1.16 2006/08/14 09:34:43 itohy Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
@ -41,6 +41,7 @@
|
||||
.Nm ym
|
||||
.Nd Yamaha OPL3-SA2 and OPL3-SA3 audio device driver
|
||||
.Sh SYNOPSIS
|
||||
.Cd "ym* at acpi?"
|
||||
.Cd "ym* at isapnp?"
|
||||
.Cd "ym* at pnpbios? index ?"
|
||||
.Cd "audio* at audiobus?"
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: GENERIC,v 1.775 2006/08/14 06:22:34 skrll Exp $
|
||||
# $NetBSD: GENERIC,v 1.776 2006/08/14 09:34:43 itohy Exp $
|
||||
#
|
||||
# GENERIC machine description file
|
||||
#
|
||||
@ -22,7 +22,7 @@ include "arch/i386/conf/std.i386"
|
||||
|
||||
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
|
||||
|
||||
#ident "GENERIC-$Revision: 1.775 $"
|
||||
#ident "GENERIC-$Revision: 1.776 $"
|
||||
|
||||
maxusers 32 # estimated number of users
|
||||
|
||||
@ -350,6 +350,7 @@ cpu* at mainbus?
|
||||
#pckbc* at acpi? # PC keyboard controller
|
||||
#pcppi* at acpi? # AT-style speaker sound
|
||||
#wss* at acpi? # NeoMagic 256AV in wss mode
|
||||
#ym* at acpi? # Yamaha OPL3-SA[23] audio
|
||||
|
||||
# Sony Vaio jog dial
|
||||
#spic* at acpi? # Sony Programmable I/O Controller
|
||||
@ -369,7 +370,7 @@ cpu* at mainbus?
|
||||
#ess* at pnpbios? index ? # ESS AudioDrive
|
||||
#sb* at pnpbios? index ? # NeoMagic 256AV in sb mode
|
||||
#wss* at pnpbios? index ? # NeoMagic 256AV in wss mode
|
||||
#ym* at pnpbios? index ? # OPL3-SA3
|
||||
#ym* at pnpbios? index ? # Yamaha OPL3-SA[23] audio
|
||||
|
||||
# com port
|
||||
# If enabled, consider changing "com0", "com1", and "com2" under "ISA Serial
|
||||
@ -1161,7 +1162,7 @@ ess* at isapnp? # ESS Tech ES1887, ES1888, ES888 audio
|
||||
guspnp* at isapnp? # Gravis Ultra Sound PnP audio
|
||||
sb* at isapnp? # SoundBlaster-compatible audio
|
||||
wss* at isapnp? # Windows Sound System
|
||||
ym* at isapnp? # Yamaha OPL3-SA3 audio
|
||||
ym* at isapnp? # Yamaha OPL3-SA[23] audio
|
||||
|
||||
# ISA audio devices
|
||||
# the "aria" probe might give false hits
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: GENERIC_LAPTOP,v 1.200 2006/08/14 06:22:34 skrll Exp $
|
||||
# $NetBSD: GENERIC_LAPTOP,v 1.201 2006/08/14 09:34:43 itohy Exp $
|
||||
# From: NetBSD: GENERIC,v 1.414 2001/07/30 19:59:05 ad Exp
|
||||
#
|
||||
# GENERIC_LAPTOP -- GENERIC with cardbus and some USB devices enabled
|
||||
@ -8,7 +8,7 @@ include "arch/i386/conf/std.i386"
|
||||
|
||||
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
|
||||
|
||||
#ident "GENERIC-$Revision: 1.200 $"
|
||||
#ident "GENERIC-$Revision: 1.201 $"
|
||||
|
||||
maxusers 32 # estimated number of users
|
||||
|
||||
@ -291,6 +291,7 @@ acpi0 at mainbus0
|
||||
#pckbc* at acpi? # PC keyboard controller
|
||||
#pcppi* at acpi? # AT-style speaker sound
|
||||
#wss* at acpi? # NeoMagic 256AV in wss mode
|
||||
#ym* at acpi? # Yamaha OPL3-SA[23] audio
|
||||
|
||||
# Sony Vaio jog dial
|
||||
#spic* at acpi? # Sony Programmable I/O Controller
|
||||
@ -307,7 +308,7 @@ acpi0 at mainbus0
|
||||
#ess* at pnpbios? index ? # ESS AudioDrive
|
||||
#sb* at pnpbios? index ? # NeoMagic 256AV in sb mode
|
||||
#wss* at pnpbios? index ? # NeoMagic 256AV in wss mode
|
||||
#ym* at pnpbios? index ? # OPL3-SA3
|
||||
#ym* at pnpbios? index ? # Yamaha OPL3-SA[23] audio
|
||||
|
||||
# com port
|
||||
# If enabled, consider changing "com0", "com1", and "com2" under "ISA Serial
|
||||
@ -805,7 +806,7 @@ ess* at isapnp? # ESS Tech ES1887, ES1888, ES888 audio
|
||||
guspnp* at isapnp? # Gravis Ultra Sound PnP audio
|
||||
sb* at isapnp? # SoundBlaster-compatible audio
|
||||
wss* at isapnp? # Windows Sound System
|
||||
ym* at isapnp? # Yamaha OPL3-SA3 audio
|
||||
ym* at isapnp? # Yamaha OPL3-SA[23] audio
|
||||
|
||||
# ISA audio devices
|
||||
# the "aria" probe might give false hits
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: files.acpi,v 1.39 2006/08/06 15:46:54 christos Exp $
|
||||
# $NetBSD: files.acpi,v 1.40 2006/08/14 09:34:43 itohy Exp $
|
||||
|
||||
include "dev/acpi/acpica/files.acpica"
|
||||
|
||||
@ -91,3 +91,7 @@ file dev/acpi/pcppi_acpi.c pcppi_acpi
|
||||
# AT Timer
|
||||
attach attimer at acpinodebus with attimer_acpi
|
||||
file dev/acpi/attimer_acpi.c attimer_acpi
|
||||
|
||||
# Yamaha OPL3-SAx
|
||||
attach ym at acpinodebus with ym_acpi
|
||||
file dev/acpi/ym_acpi.c ym_acpi
|
||||
|
212
sys/dev/acpi/ym_acpi.c
Normal file
212
sys/dev/acpi/ym_acpi.c
Normal file
@ -0,0 +1,212 @@
|
||||
/* $NetBSD: ym_acpi.c,v 1.1 2006/08/14 09:34:43 itohy Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006 Jasper Wallace <jasper@pointless.net>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2002 Jared D. McNeill <jmcneill@invisible.ca>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ym_acpi.c,v 1.1 2006/08/14 09:34:43 itohy Exp $");
|
||||
|
||||
#include "mpu_ym.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <machine/bus.h>
|
||||
|
||||
#include <dev/acpi/acpivar.h>
|
||||
|
||||
#include <dev/audio_if.h>
|
||||
|
||||
#include <dev/ic/ad1848reg.h>
|
||||
#include <dev/isa/ad1848var.h>
|
||||
|
||||
#include <dev/ic/opl3sa3reg.h>
|
||||
#include <dev/isa/wssreg.h>
|
||||
#include <dev/isa/ymvar.h>
|
||||
|
||||
|
||||
static int ym_acpi_match(struct device *, struct cfdata *, void *);
|
||||
static void ym_acpi_attach(struct device *, struct device *, void *);
|
||||
|
||||
CFATTACH_DECL(ym_acpi, sizeof(struct ym_softc), ym_acpi_match,
|
||||
ym_acpi_attach, NULL, NULL);
|
||||
|
||||
/*
|
||||
* ym_acpi_match: autoconf(9) match routine
|
||||
*/
|
||||
static int
|
||||
ym_acpi_match(struct device *parent, struct cfdata *match, void *aux)
|
||||
{
|
||||
struct acpi_attach_args *aa = aux;
|
||||
|
||||
if (aa->aa_node->ad_type != ACPI_TYPE_DEVICE)
|
||||
return 0;
|
||||
/* Yamaha OPL3-SA2 or OPL3-SA3 */
|
||||
if (strcmp("YMH0021", aa->aa_node->ad_devinfo->HardwareId.Value))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* ym_acpi_attach: autoconf(9) attach routine
|
||||
*/
|
||||
static void
|
||||
ym_acpi_attach(struct device *parent, struct device *self, void *aux)
|
||||
{
|
||||
struct ym_softc *sc = (struct ym_softc *)self;
|
||||
struct acpi_attach_args *aa = aux;
|
||||
struct acpi_resources res;
|
||||
struct acpi_io *sb_io, *codec_io, *opl_io, *control_io;
|
||||
#if NMPU_YM > 0
|
||||
struct acpi_io *mpu_io;
|
||||
#endif
|
||||
struct acpi_irq *irq;
|
||||
struct acpi_drq *playdrq, *recdrq;
|
||||
struct ad1848_softc *ac = &sc->sc_ad1848.sc_ad1848;
|
||||
ACPI_STATUS rv;
|
||||
|
||||
aprint_naive("\n");
|
||||
aprint_normal("\n");
|
||||
|
||||
/* Parse our resources */
|
||||
rv = acpi_resource_parse(&sc->sc_ad1848.sc_ad1848.sc_dev,
|
||||
aa->aa_node->ad_handle, "_CRS", &res,
|
||||
&acpi_resource_parse_ops_default);
|
||||
if (ACPI_FAILURE(rv))
|
||||
return;
|
||||
|
||||
/*
|
||||
* sc_sb_ioh @ 0
|
||||
* sc_ioh @ 1
|
||||
* sc_opl_ioh @ 2
|
||||
* sc_mpu_ioh @ 3
|
||||
* sc_controlioh @ 4
|
||||
*/
|
||||
|
||||
/* Find and map our i/o registers */
|
||||
sc->sc_iot = aa->aa_iot;
|
||||
sb_io = acpi_res_io(&res, 0);
|
||||
codec_io = acpi_res_io(&res, 1);
|
||||
opl_io = acpi_res_io(&res, 2);
|
||||
#if NMPU_YM > 0
|
||||
mpu_io = acpi_res_io(&res, 3);
|
||||
#endif
|
||||
control_io = acpi_res_io(&res, 4);
|
||||
|
||||
if (sb_io == NULL || codec_io == NULL || opl_io == NULL ||
|
||||
#if NMPU_YM > 0
|
||||
mpu_io == NULL ||
|
||||
#endif
|
||||
control_io == NULL) {
|
||||
aprint_error("%s: unable to find i/o registers resource\n",
|
||||
self->dv_xname);
|
||||
goto out;
|
||||
}
|
||||
if (bus_space_map(sc->sc_iot, sb_io->ar_base, sb_io->ar_length,
|
||||
0, &sc->sc_sb_ioh) != 0) {
|
||||
aprint_error("%s: unable to map i/o registers (sb)\n",
|
||||
self->dv_xname);
|
||||
goto out;
|
||||
}
|
||||
if (bus_space_map(sc->sc_iot, codec_io->ar_base, codec_io->ar_length,
|
||||
0, &sc->sc_ioh) != 0) {
|
||||
aprint_error("%s: unable to map i/o registers (codec)\n",
|
||||
self->dv_xname);
|
||||
goto out;
|
||||
}
|
||||
if (bus_space_map(sc->sc_iot, opl_io->ar_base, opl_io->ar_length,
|
||||
0, &sc->sc_opl_ioh) != 0) {
|
||||
aprint_error("%s: unable to map i/o registers (opl)\n",
|
||||
self->dv_xname);
|
||||
goto out;
|
||||
}
|
||||
#if NMPU_YM > 0
|
||||
if (bus_space_map(sc->sc_iot, mpu_io->ar_base, mpu_io->ar_length,
|
||||
0, &sc->sc_mpu_ioh) != 0) {
|
||||
aprint_error("%s: unable to map i/o registers (mpu)\n",
|
||||
self->dv_xname);
|
||||
goto out;
|
||||
}
|
||||
#endif
|
||||
if (bus_space_map(sc->sc_iot, control_io->ar_base,
|
||||
control_io->ar_length, 0, &sc->sc_controlioh) != 0) {
|
||||
aprint_error("%s: unable to map i/o registers (control)\n",
|
||||
self->dv_xname);
|
||||
goto out;
|
||||
}
|
||||
|
||||
sc->sc_ic = aa->aa_ic;
|
||||
|
||||
/* Find our IRQ */
|
||||
irq = acpi_res_irq(&res, 0);
|
||||
if (irq == NULL) {
|
||||
aprint_error("%s: unable to find irq resource\n",
|
||||
self->dv_xname);
|
||||
/* XXX bus_space_unmap */
|
||||
goto out;
|
||||
}
|
||||
sc->ym_irq = irq->ar_irq;
|
||||
|
||||
/* Find our playback and record DRQs */
|
||||
playdrq = acpi_res_drq(&res, 0);
|
||||
recdrq = acpi_res_drq(&res, 1);
|
||||
if (playdrq == NULL) {
|
||||
aprint_error("%s: unable to find drq resources\n",
|
||||
self->dv_xname);
|
||||
/* XXX bus_space_unmap */
|
||||
goto out;
|
||||
}
|
||||
if (recdrq == NULL) {
|
||||
/* half-duplex mode */
|
||||
sc->ym_recdrq = sc->ym_playdrq = playdrq->ar_drq;
|
||||
} else {
|
||||
sc->ym_playdrq = playdrq->ar_drq;
|
||||
sc->ym_recdrq = recdrq->ar_drq;
|
||||
}
|
||||
|
||||
ac->sc_iot = sc->sc_iot;
|
||||
if (bus_space_subregion(sc->sc_iot, sc->sc_ioh, WSS_CODEC,
|
||||
AD1848_NPORT, &ac->sc_ioh)) {
|
||||
aprint_error("%s: bus_space_subregion failed\n",
|
||||
self->dv_xname);
|
||||
/* XXX cleanup */
|
||||
goto out;
|
||||
}
|
||||
|
||||
aprint_normal("%s", self->dv_xname);
|
||||
|
||||
ac->mode = 2;
|
||||
ac->MCE_bit = MODE_CHANGE_ENABLE;
|
||||
|
||||
sc->sc_ad1848.sc_ic = sc->sc_ic;
|
||||
|
||||
/* Attach our ym device */
|
||||
ym_attach(sc);
|
||||
|
||||
out:
|
||||
acpi_resource_cleanup(&res);
|
||||
}
|
Loading…
Reference in New Issue
Block a user