melody.c revision 1.1
11.1Sis/*	$NetBSD: melody.c,v 1.1 1997/10/16 23:58:31 is 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.1Sisstruct cfdriver melody_cd = {
681.1Sis	NULL, "melody", DV_DULL
691.1Sis};
701.1Sis
711.1Sisint
721.1Sismelody_match(parent, cfp, aux)
731.1Sis	struct device *parent;
741.1Sis	struct cfdata *cfp;
751.1Sis	void *aux;
761.1Sis{
771.1Sis	struct zbus_args *zap;
781.1Sis
791.1Sis	zap = aux;
801.1Sis	if (zap->manid != 2145)
811.1Sis		return (0);
821.1Sis
831.1Sis	if (zap->prodid != 128)
841.1Sis		return (0);
851.1Sis
861.1Sis	return (1);
871.1Sis}
881.1Sis
891.1Sisvoid
901.1Sismelody_attach(parent, self, aux)
911.1Sis	struct device *parent, *self;
921.1Sis	void *aux;
931.1Sis{
941.1Sis	struct melody_softc *sc;
951.1Sis	struct zbus_args *zap;
961.1Sis	bus_space_tag_t iot;
971.1Sis	bus_space_handle_t ioh;
981.1Sis
991.1Sis	sc = (struct melody_softc *)self;
1001.1Sis	zap = aux;
1011.1Sis
1021.1Sis	sc->sc_bst_leftbyte.base = (u_long)zap->va + 0;
1031.1Sis	sc->sc_bst_leftbyte.stride = 1;
1041.1Sis	sc->sc_intack = zap->va + 0xc000;
1051.1Sis
1061.1Sis	/* set up board specific part in sc_tav */
1071.1Sis
1081.1Sis	iot = &sc->sc_bst_leftbyte;
1091.1Sis
1101.1Sis	if (bus_space_map(iot, 0, 128, 0, &ioh)) {
1111.1Sis		panic("melody: cant bus_space_map");
1121.1Sis		/* NOTREACHED */
1131.1Sis	}
1141.1Sis	sc->sc_tav.sc_iot = iot;
1151.1Sis	sc->sc_tav.sc_ioh = ioh;
1161.1Sis	sc->sc_tav.sc_pcm_ord = 0;
1171.1Sis	sc->sc_tav.sc_pcm_18 = 0;
1181.1Sis	sc->sc_tav.sc_dif = 0;
1191.1Sis	sc->sc_tav.sc_pcm_div = 12;
1201.1Sis
1211.1Sis	/*
1221.1Sis	 * Attach option boards now. They might provide additional
1231.1Sis	 * functionality to our audio part.
1241.1Sis	 */
1251.1Sis
1261.1Sis	/* attach our audio driver */
1271.1Sis
1281.1Sis	printf(" #%d", zap->serno);
1291.1Sis	tms320av110_attach_mi(&sc->sc_tav);
1301.1Sis	sc->sc_isr.isr_ipl = 6;
1311.1Sis	sc->sc_isr.isr_arg = &sc->sc_tav;
1321.1Sis	sc->sc_isr.isr_intr = tms320av110_intr;
1331.1Sis	add_isr(&sc->sc_isr);
1341.1Sis}
1351.1Sis
1361.1Sisvoid
1371.1Sismelody_intack(p)
1381.1Sis	struct tav_softc *p;
1391.1Sis{
1401.1Sis	struct melody_softc *sc;
1411.1Sis
1421.1Sis	sc = (struct melody_softc *)p;
1431.1Sis	*sc->sc_intack = 0;
1441.1Sis}
145