melody.c revision 1.3
11.3Stron/*	$NetBSD: melody.c,v 1.3 1999/01/10 12:37:17 tron Exp $	*/
21.1Sis
31.1Sis/*-
41.1Sis * Copyright (c) 1997 Ignatios Souvatzis. All rights reserved.
51.1Sis *
61.1Sis * Redistribution and use in source and binary forms, with or without
71.1Sis * modification, are permitted provided that the following conditions
81.1Sis * are met:
91.1Sis * 1. Redistributions of source code must retain the above copyright
101.1Sis *    notice, this list of conditions and the following disclaimer.
111.1Sis * 2. Redistributions in binary form must reproduce the above copyright
121.1Sis *    notice, this list of conditions and the following disclaimer in the
131.1Sis *    documentation and/or other materials provided with the distribution.
141.1Sis * 3. Neither the name of the author nor the names of contributors
151.1Sis *    may be used to endorse or promote products derived from this software
161.1Sis *    without specific prior written permission.
171.1Sis *
181.1Sis * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
191.1Sis * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
201.1Sis * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
211.1Sis * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
221.1Sis * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
231.1Sis * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
241.1Sis * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
251.1Sis * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
261.1Sis * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
271.1Sis * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
281.1Sis * SUCH DAMAGE.
291.1Sis */
301.1Sis
311.1Sis/*
321.1Sis * Melody audio driver.
331.1Sis *
341.1Sis * Currently, only minimum support for audio output. For audio/video
351.1Sis * synchronization, more is needed.
361.1Sis */
371.1Sis
381.1Sis#include <sys/types.h>
391.1Sis#include <sys/param.h>
401.1Sis#include <sys/systm.h>
411.1Sis#include <sys/kernel.h>
421.1Sis#include <sys/device.h>
431.1Sis
441.1Sis#include <dev/ic/tms320av110reg.h>
451.1Sis#include <dev/ic/tms320av110var.h>
461.1Sis
471.1Sis#include <machine/bus.h>
481.1Sis
491.1Sis#include <amiga/dev/zbusvar.h>
501.1Sis#include <amiga/amiga/isr.h>
511.1Sis
521.1Sisstruct melody_softc {
531.1Sis	struct tav_softc	sc_tav;
541.1Sis	struct bus_space_tag	sc_bst_leftbyte;
551.1Sis	struct isr		sc_isr;
561.1Sis	caddr_t			sc_intack;
571.1Sis};
581.1Sis
591.1Sisint melody_match __P((struct device *, struct cfdata *, void *));
601.1Sisvoid melody_attach __P((struct device *, struct device *, void *));
611.1Sisvoid melody_intack __P((struct tav_softc *));
621.1Sis
631.1Sisstruct cfattach melody_ca = {
641.1Sis        sizeof(struct melody_softc), melody_match, melody_attach
651.1Sis};
661.1Sis
671.1Sisint
681.1Sismelody_match(parent, cfp, aux)
691.1Sis	struct device *parent;
701.1Sis	struct cfdata *cfp;
711.1Sis	void *aux;
721.1Sis{
731.1Sis	struct zbus_args *zap;
741.1Sis
751.1Sis	zap = aux;
761.1Sis	if (zap->manid != 2145)
771.1Sis		return (0);
781.1Sis
791.1Sis	if (zap->prodid != 128)
801.1Sis		return (0);
811.1Sis
821.1Sis	return (1);
831.1Sis}
841.1Sis
851.1Sisvoid
861.1Sismelody_attach(parent, self, aux)
871.1Sis	struct device *parent, *self;
881.1Sis	void *aux;
891.1Sis{
901.1Sis	struct melody_softc *sc;
911.1Sis	struct zbus_args *zap;
921.1Sis	bus_space_tag_t iot;
931.1Sis	bus_space_handle_t ioh;
941.1Sis
951.1Sis	sc = (struct melody_softc *)self;
961.1Sis	zap = aux;
971.1Sis
981.1Sis	sc->sc_bst_leftbyte.base = (u_long)zap->va + 0;
991.1Sis	sc->sc_bst_leftbyte.stride = 1;
1001.3Stron	sc->sc_intack = (caddr_t)zap->va + 0xc000;
1011.1Sis
1021.1Sis	/* set up board specific part in sc_tav */
1031.1Sis
1041.1Sis	iot = &sc->sc_bst_leftbyte;
1051.1Sis
1061.1Sis	if (bus_space_map(iot, 0, 128, 0, &ioh)) {
1071.1Sis		panic("melody: cant bus_space_map");
1081.1Sis		/* NOTREACHED */
1091.1Sis	}
1101.1Sis	sc->sc_tav.sc_iot = iot;
1111.1Sis	sc->sc_tav.sc_ioh = ioh;
1121.1Sis	sc->sc_tav.sc_pcm_ord = 0;
1131.1Sis	sc->sc_tav.sc_pcm_18 = 0;
1141.1Sis	sc->sc_tav.sc_dif = 0;
1151.1Sis	sc->sc_tav.sc_pcm_div = 12;
1161.1Sis
1171.1Sis	/*
1181.1Sis	 * Attach option boards now. They might provide additional
1191.1Sis	 * functionality to our audio part.
1201.1Sis	 */
1211.1Sis
1221.1Sis	/* attach our audio driver */
1231.1Sis
1241.1Sis	printf(" #%d", zap->serno);
1251.1Sis	tms320av110_attach_mi(&sc->sc_tav);
1261.1Sis	sc->sc_isr.isr_ipl = 6;
1271.1Sis	sc->sc_isr.isr_arg = &sc->sc_tav;
1281.1Sis	sc->sc_isr.isr_intr = tms320av110_intr;
1291.1Sis	add_isr(&sc->sc_isr);
1301.1Sis}
1311.1Sis
1321.1Sisvoid
1331.1Sismelody_intack(p)
1341.1Sis	struct tav_softc *p;
1351.1Sis{
1361.1Sis	struct melody_softc *sc;
1371.1Sis
1381.1Sis	sc = (struct melody_softc *)p;
1391.1Sis	*sc->sc_intack = 0;
1401.1Sis}
141