opl_sb.c revision 1.6
11.5Sriastrad/* $NetBSD: opl_sb.c,v 1.6 2002/09/27 20:38:45 thorpej Exp $ */ 21.1Selad 31.4Sjym/* 41.1Selad * Copyright (c) 1998 The NetBSD Foundation, Inc. 51.1Selad * All rights reserved. 61.1Selad * 71.1Selad * This code is derived from software contributed to The NetBSD Foundation 81.1Selad * by Lennart Augustsson (augustss@netbsd.org). 91.1Selad * 101.1Selad * Redistribution and use in source and binary forms, with or without 111.1Selad * modification, are permitted provided that the following conditions 121.1Selad * are met: 131.1Selad * 1. Redistributions of source code must retain the above copyright 141.2Selad * notice, this list of conditions and the following disclaimer. 151.1Selad * 2. Redistributions in binary form must reproduce the above copyright 161.1Selad * notice, this list of conditions and the following disclaimer in the 171.1Selad * documentation and/or other materials provided with the distribution. 181.1Selad * 3. All advertising materials mentioning features or use of this software 191.1Selad * must display the following acknowledgement: 201.1Selad * This product includes software developed by the NetBSD 211.1Selad * Foundation, Inc. and its contributors. 221.1Selad * 4. Neither the name of The NetBSD Foundation nor the names of its 231.1Selad * contributors may be used to endorse or promote products derived 241.1Selad * from this software without specific prior written permission. 251.1Selad * 261.1Selad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 271.1Selad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 281.1Selad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 291.1Selad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 301.1Selad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 311.1Selad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 321.5Sriastrad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 331.5Sriastrad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 341.4Sjym * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 351.1Selad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 361.4Sjym * POSSIBILITY OF SUCH DAMAGE. 371.4Sjym */ 381.4Sjym 391.4Sjym#include <sys/cdefs.h> 401.4Sjym__KERNEL_RCSID(0, "$NetBSD: opl_sb.c,v 1.6 2002/09/27 20:38:45 thorpej Exp $"); 411.4Sjym 421.4Sjym#include <sys/param.h> 431.4Sjym#include <sys/systm.h> 441.4Sjym#include <sys/kernel.h> 451.4Sjym#include <sys/errno.h> 461.4Sjym#include <sys/device.h> 471.4Sjym#include <sys/malloc.h> 481.4Sjym#include <sys/proc.h> 491.4Sjym#include <sys/conf.h> 501.4Sjym#include <sys/select.h> 511.4Sjym#include <sys/audioio.h> 521.4Sjym#include <sys/midiio.h> 531.4Sjym 541.4Sjym#include <machine/bus.h> 551.4Sjym 561.4Sjym#include <dev/audio_if.h> 571.4Sjym#include <dev/midi_if.h> 581.4Sjym#include <dev/ic/oplreg.h> 591.4Sjym#include <dev/ic/oplvar.h> 601.4Sjym 611.4Sjym#include <dev/isa/isavar.h> 621.4Sjym#include <dev/isa/sbdspvar.h> 631.4Sjym 641.4Sjymint opl_sb_match __P((struct device *, struct cfdata *, void *)); 651.1Seladvoid opl_sb_attach __P((struct device *, struct device *, void *)); 66 67const struct cfattach opl_sb_ca = { 68 sizeof (struct opl_softc), opl_sb_match, opl_sb_attach 69}; 70 71int 72opl_sb_match(parent, match, aux) 73 struct device *parent; 74 struct cfdata *match; 75 void *aux; 76{ 77 struct audio_attach_args *aa = (struct audio_attach_args *)aux; 78 struct sbdsp_softc *ssc = (struct sbdsp_softc *)parent; 79 struct opl_softc sc; 80 81 if (aa->type != AUDIODEV_TYPE_OPL) 82 return (0); 83 memset(&sc, 0, sizeof sc); 84 sc.ioh = ssc->sc_ioh; 85 sc.iot = ssc->sc_iot; 86 return (opl_find(&sc)); 87} 88 89void 90opl_sb_attach(parent, self, aux) 91 struct device *parent; 92 struct device *self; 93 void *aux; 94{ 95 struct sbdsp_softc *ssc = (struct sbdsp_softc *)parent; 96 struct opl_softc *sc = (struct opl_softc *)self; 97 98 sc->ioh = ssc->sc_ioh; 99 sc->iot = ssc->sc_iot; 100 sc->offs = 0; 101 sc->spkrctl = sbdsp_speaker_ctl; 102 sc->spkrarg = ssc; 103 strcpy(sc->syn.name, "SB "); 104 105 opl_attach(sc); 106} 107