melody.c revision 1.8
1/*	$NetBSD: melody.c,v 1.8 2002/01/26 13:40:58 aymeric Exp $ */
2
3/*-
4 * Copyright (c) 1997 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(struct device *, struct cfdata *, void *);
68void melody_attach(struct device *, struct device *, void *);
69void melody_intack(struct tav_softc *);
70
71struct cfattach melody_ca = {
72        sizeof(struct melody_softc), melody_match, melody_attach
73};
74
75int
76melody_match(struct device *parent, struct cfdata *cfp, void *aux)
77{
78	struct zbus_args *zap;
79
80	zap = aux;
81	if (zap->manid != 2145)
82		return (0);
83
84	if (zap->prodid != 128)
85		return (0);
86
87	return (1);
88}
89
90void
91melody_attach(struct device *parent, struct device *self, void *aux)
92{
93	struct melody_softc *sc;
94	struct zbus_args *zap;
95	bus_space_tag_t iot;
96	bus_space_handle_t ioh;
97
98	sc = (struct melody_softc *)self;
99	zap = aux;
100
101	sc->sc_bst_leftbyte.base = (u_long)zap->va + 0;
102	sc->sc_bst_leftbyte.absm = &amiga_bus_stride_2;
103	sc->sc_intack = (caddr_t)zap->va + 0xc000;
104
105	/* set up board specific part in sc_tav */
106
107	iot = &sc->sc_bst_leftbyte;
108
109	if (bus_space_map(iot, 0, 128, 0, &ioh)) {
110		panic("melody: cant bus_space_map");
111		/* NOTREACHED */
112	}
113	sc->sc_tav.sc_iot = iot;
114	sc->sc_tav.sc_ioh = ioh;
115	sc->sc_tav.sc_pcm_ord = 0;
116	sc->sc_tav.sc_pcm_18 = 0;
117	sc->sc_tav.sc_dif = 0;
118	sc->sc_tav.sc_pcm_div = 12;
119
120	/*
121	 * Attach option boards now. They might provide additional
122	 * functionality to our audio part.
123	 */
124
125	/* attach our audio driver */
126
127	printf(" #%d", zap->serno);
128	tms320av110_attach_mi(&sc->sc_tav);
129	sc->sc_isr.isr_ipl = 6;
130	sc->sc_isr.isr_arg = &sc->sc_tav;
131	sc->sc_isr.isr_intr = tms320av110_intr;
132	add_isr(&sc->sc_isr);
133}
134
135void
136melody_intack(struct tav_softc *p)
137{
138	struct melody_softc *sc;
139
140	sc = (struct melody_softc *)p;
141	*sc->sc_intack = 0;
142}
143