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