melody.c revision 1.2
1/* $NetBSD: melody.c,v 1.2 1998/01/12 10:39:58 thorpej Exp $ */ 2 3/*- 4 * Copyright (c) 1997 Ignatios Souvatzis. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. Neither the name of the author nor the names of contributors 15 * may be used to endorse or promote products derived from this software 16 * without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 */ 30 31/* 32 * Melody audio driver. 33 * 34 * Currently, only minimum support for audio output. For audio/video 35 * synchronization, more is needed. 36 */ 37 38#include <sys/types.h> 39#include <sys/param.h> 40#include <sys/systm.h> 41#include <sys/kernel.h> 42#include <sys/device.h> 43 44#include <dev/ic/tms320av110reg.h> 45#include <dev/ic/tms320av110var.h> 46 47#include <machine/bus.h> 48 49#include <amiga/dev/zbusvar.h> 50#include <amiga/amiga/isr.h> 51 52struct melody_softc { 53 struct tav_softc sc_tav; 54 struct bus_space_tag sc_bst_leftbyte; 55 struct isr sc_isr; 56 caddr_t sc_intack; 57}; 58 59int melody_match __P((struct device *, struct cfdata *, void *)); 60void melody_attach __P((struct device *, struct device *, void *)); 61void melody_intack __P((struct tav_softc *)); 62 63struct cfattach melody_ca = { 64 sizeof(struct melody_softc), melody_match, melody_attach 65}; 66 67int 68melody_match(parent, cfp, aux) 69 struct device *parent; 70 struct cfdata *cfp; 71 void *aux; 72{ 73 struct zbus_args *zap; 74 75 zap = aux; 76 if (zap->manid != 2145) 77 return (0); 78 79 if (zap->prodid != 128) 80 return (0); 81 82 return (1); 83} 84 85void 86melody_attach(parent, self, aux) 87 struct device *parent, *self; 88 void *aux; 89{ 90 struct melody_softc *sc; 91 struct zbus_args *zap; 92 bus_space_tag_t iot; 93 bus_space_handle_t ioh; 94 95 sc = (struct melody_softc *)self; 96 zap = aux; 97 98 sc->sc_bst_leftbyte.base = (u_long)zap->va + 0; 99 sc->sc_bst_leftbyte.stride = 1; 100 sc->sc_intack = zap->va + 0xc000; 101 102 /* set up board specific part in sc_tav */ 103 104 iot = &sc->sc_bst_leftbyte; 105 106 if (bus_space_map(iot, 0, 128, 0, &ioh)) { 107 panic("melody: cant bus_space_map"); 108 /* NOTREACHED */ 109 } 110 sc->sc_tav.sc_iot = iot; 111 sc->sc_tav.sc_ioh = ioh; 112 sc->sc_tav.sc_pcm_ord = 0; 113 sc->sc_tav.sc_pcm_18 = 0; 114 sc->sc_tav.sc_dif = 0; 115 sc->sc_tav.sc_pcm_div = 12; 116 117 /* 118 * Attach option boards now. They might provide additional 119 * functionality to our audio part. 120 */ 121 122 /* attach our audio driver */ 123 124 printf(" #%d", zap->serno); 125 tms320av110_attach_mi(&sc->sc_tav); 126 sc->sc_isr.isr_ipl = 6; 127 sc->sc_isr.isr_arg = &sc->sc_tav; 128 sc->sc_isr.isr_intr = tms320av110_intr; 129 add_isr(&sc->sc_isr); 130} 131 132void 133melody_intack(p) 134 struct tav_softc *p; 135{ 136 struct melody_softc *sc; 137 138 sc = (struct melody_softc *)p; 139 *sc->sc_intack = 0; 140} 141