1998-08-28 12:57:38 +04:00
|
|
|
/* $NetBSD: am7930_sparc.c,v 1.41 1998/08/28 08:57:38 pk Exp $ */
|
1995-06-28 08:30:30 +04:00
|
|
|
|
1995-04-26 00:05:32 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1995 Rolf Grossmann
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by Rolf Grossmann.
|
|
|
|
* 4. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "audio.h"
|
|
|
|
#if NAUDIO > 0
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/errno.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
|
1998-03-21 23:11:30 +03:00
|
|
|
#include <machine/bus.h>
|
1995-04-26 00:05:32 +04:00
|
|
|
#include <machine/autoconf.h>
|
|
|
|
#include <machine/cpu.h>
|
|
|
|
|
|
|
|
#include <sys/audioio.h>
|
|
|
|
#include <dev/audio_if.h>
|
|
|
|
|
1995-06-28 08:30:30 +04:00
|
|
|
#include <dev/ic/am7930reg.h>
|
1998-06-24 15:09:23 +04:00
|
|
|
#include <dev/ic/am7930var.h>
|
1995-04-26 00:05:32 +04:00
|
|
|
|
1997-08-28 02:42:23 +04:00
|
|
|
#define AUDIO_ROM_NAME "audio"
|
|
|
|
|
1995-07-19 23:50:16 +04:00
|
|
|
#ifdef AUDIO_DEBUG
|
1998-08-28 12:57:38 +04:00
|
|
|
#define DPRINTF(x) if (am7930debug) printf x
|
1995-04-26 00:05:32 +04:00
|
|
|
#else
|
|
|
|
#define DPRINTF(x)
|
1998-06-24 15:09:23 +04:00
|
|
|
#endif /* AUDIO_DEBUG */
|
1995-04-26 00:05:32 +04:00
|
|
|
|
|
|
|
|
|
|
|
/* interrupt interfaces */
|
|
|
|
#ifdef AUDIO_C_HANDLER
|
1998-06-24 15:09:23 +04:00
|
|
|
int am7930hwintr __P((void *));
|
1996-11-02 02:32:15 +03:00
|
|
|
#if defined(SUN4M)
|
|
|
|
#define AUDIO_SET_SWINTR do { \
|
|
|
|
if (CPU_ISSUN4M) \
|
|
|
|
raise(0, 4); \
|
|
|
|
else \
|
|
|
|
ienab_bis(IE_L4); \
|
|
|
|
} while(0);
|
|
|
|
#else
|
1995-04-26 00:05:32 +04:00
|
|
|
#define AUDIO_SET_SWINTR ienab_bis(IE_L4)
|
1996-11-02 02:32:15 +03:00
|
|
|
#endif /* defined(SUN4M) */
|
1995-04-26 00:05:32 +04:00
|
|
|
#else
|
|
|
|
struct auio *auiop;
|
1996-11-02 02:32:15 +03:00
|
|
|
#endif /* AUDIO_C_HANDLER */
|
1998-06-24 15:09:23 +04:00
|
|
|
int am7930swintr __P((void *));
|
1995-04-26 00:05:32 +04:00
|
|
|
|
|
|
|
/* forward declarations */
|
1998-06-24 15:09:23 +04:00
|
|
|
void am7930_sparc_onopen __P((struct am7930_softc *sc));
|
|
|
|
void am7930_sparc_onclose __P((struct am7930_softc *sc));
|
1995-04-26 00:05:32 +04:00
|
|
|
|
|
|
|
/* autoconfiguration driver */
|
1998-06-24 15:09:23 +04:00
|
|
|
void am7930attach_mainbus __P((struct device *, struct device *, void *));
|
|
|
|
int am7930match_mainbus __P((struct device *, struct cfdata *, void *));
|
|
|
|
void am7930attach_sbus __P((struct device *, struct device *, void *));
|
|
|
|
int am7930match_sbus __P((struct device *, struct cfdata *, void *));
|
|
|
|
|
|
|
|
void am7930_sparc_attach(struct am7930_softc *sc, int);
|
1995-04-26 00:05:32 +04:00
|
|
|
|
1998-03-21 23:11:30 +03:00
|
|
|
|
|
|
|
struct cfattach audioamd_mainbus_ca = {
|
1998-06-24 15:09:23 +04:00
|
|
|
sizeof(struct am7930_softc), am7930match_mainbus, am7930attach_mainbus
|
1998-03-21 23:11:30 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct cfattach audioamd_sbus_ca = {
|
1998-06-24 15:09:23 +04:00
|
|
|
sizeof(struct am7930_softc), am7930match_sbus, am7930attach_sbus
|
1995-04-26 00:05:32 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Define our interface to the higher level audio driver.
|
|
|
|
*/
|
1998-06-24 15:09:23 +04:00
|
|
|
int am7930_start_output __P((void *, void *, int, void (*)(void *),
|
1996-03-14 22:44:30 +03:00
|
|
|
void *));
|
1998-06-24 15:09:23 +04:00
|
|
|
int am7930_start_input __P((void *, void *, int, void (*)(void *),
|
1996-03-14 22:44:30 +03:00
|
|
|
void *));
|
1998-06-24 15:09:23 +04:00
|
|
|
int am7930_set_port __P((void *, mixer_ctrl_t *));
|
|
|
|
int am7930_get_port __P((void *, mixer_ctrl_t *));
|
|
|
|
int am7930_query_devinfo __P((void *, mixer_devinfo_t *));
|
1995-04-26 00:05:32 +04:00
|
|
|
|
1998-06-24 15:09:23 +04:00
|
|
|
void am7930_sparc_w16 __P((volatile struct am7930 *amd, u_int16_t val));
|
1995-04-26 00:05:32 +04:00
|
|
|
|
|
|
|
struct audio_hw_if sa_hw_if = {
|
1998-06-24 15:09:23 +04:00
|
|
|
am7930_open,
|
|
|
|
am7930_close,
|
1997-07-28 03:51:48 +04:00
|
|
|
0,
|
1998-06-24 15:09:23 +04:00
|
|
|
am7930_query_encoding,
|
|
|
|
am7930_set_params,
|
|
|
|
am7930_round_blocksize, /* XXX md? */
|
|
|
|
am7930_commit_settings,
|
1997-07-28 03:51:48 +04:00
|
|
|
0,
|
|
|
|
0,
|
1998-06-24 15:09:23 +04:00
|
|
|
am7930_start_output, /* XXX md? */
|
|
|
|
am7930_start_input, /* XXX md? */
|
|
|
|
am7930_halt_output, /* XXX md? */
|
|
|
|
am7930_halt_input, /* XXX md? */
|
1997-07-28 03:51:48 +04:00
|
|
|
0,
|
1998-06-24 15:09:23 +04:00
|
|
|
am7930_getdev,
|
1997-07-28 03:51:48 +04:00
|
|
|
0,
|
1998-06-24 15:09:23 +04:00
|
|
|
am7930_set_port,
|
|
|
|
am7930_get_port,
|
|
|
|
am7930_query_devinfo,
|
1997-07-27 05:16:32 +04:00
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
1997-07-29 00:56:05 +04:00
|
|
|
0,
|
1998-06-24 15:09:23 +04:00
|
|
|
am7930_get_props,
|
1995-04-26 00:05:32 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/* autoconfig routines */
|
|
|
|
|
1998-06-24 15:09:23 +04:00
|
|
|
|
1995-04-26 00:05:32 +04:00
|
|
|
int
|
1998-06-24 15:09:23 +04:00
|
|
|
am7930match_mainbus(parent, cf, aux)
|
1995-04-26 00:05:32 +04:00
|
|
|
struct device *parent;
|
1996-12-11 01:54:46 +03:00
|
|
|
struct cfdata *cf;
|
|
|
|
void *aux;
|
1995-04-26 00:05:32 +04:00
|
|
|
{
|
1998-03-21 23:11:30 +03:00
|
|
|
struct mainbus_attach_args *ma = aux;
|
1995-04-26 00:05:32 +04:00
|
|
|
|
1996-02-26 00:53:49 +03:00
|
|
|
if (CPU_ISSUN4)
|
1995-04-26 00:05:32 +04:00
|
|
|
return (0);
|
1998-03-21 23:11:30 +03:00
|
|
|
return (strcmp(AUDIO_ROM_NAME, ma->ma_name) == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-06-24 15:09:23 +04:00
|
|
|
am7930match_sbus(parent, cf, aux)
|
1998-03-21 23:11:30 +03:00
|
|
|
struct device *parent;
|
|
|
|
struct cfdata *cf;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct sbus_attach_args *sa = aux;
|
|
|
|
|
|
|
|
return (strcmp(AUDIO_ROM_NAME, sa->sa_name) == 0);
|
1995-04-26 00:05:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Audio chip found.
|
|
|
|
*/
|
|
|
|
void
|
1998-06-24 15:09:23 +04:00
|
|
|
am7930attach_mainbus(parent, self, aux)
|
1995-04-26 00:05:32 +04:00
|
|
|
struct device *parent, *self;
|
1998-03-21 23:11:30 +03:00
|
|
|
void *aux;
|
1995-04-26 00:05:32 +04:00
|
|
|
{
|
1998-03-21 23:11:30 +03:00
|
|
|
struct mainbus_attach_args *ma = aux;
|
1998-06-24 15:09:23 +04:00
|
|
|
struct am7930_softc *sc = (struct am7930_softc *)self;
|
1998-03-21 23:11:30 +03:00
|
|
|
bus_space_handle_t bh;
|
|
|
|
|
|
|
|
sc->sc_bustag = ma->ma_bustag;
|
|
|
|
|
1998-03-30 18:21:38 +04:00
|
|
|
if (bus_space_map2(
|
1998-03-21 23:11:30 +03:00
|
|
|
ma->ma_bustag,
|
|
|
|
ma->ma_iospace,
|
1998-03-30 18:21:38 +04:00
|
|
|
ma->ma_paddr,
|
1998-06-24 15:09:23 +04:00
|
|
|
sizeof(struct am7930),
|
1998-03-21 23:11:30 +03:00
|
|
|
BUS_SPACE_MAP_LINEAR,
|
|
|
|
0,
|
|
|
|
&bh) != 0) {
|
|
|
|
printf("%s: cannot map registers\n", self->dv_xname);
|
|
|
|
return;
|
|
|
|
}
|
1998-06-24 15:09:23 +04:00
|
|
|
sc->sc_amd = (volatile struct am7930 *)bh;
|
|
|
|
am7930_sparc_attach(sc, ma->ma_pri);
|
1998-03-21 23:11:30 +03:00
|
|
|
}
|
1995-04-26 00:05:32 +04:00
|
|
|
|
1998-03-21 23:11:30 +03:00
|
|
|
void
|
1998-06-24 15:09:23 +04:00
|
|
|
am7930attach_sbus(parent, self, aux)
|
1998-03-21 23:11:30 +03:00
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct sbus_attach_args *sa = aux;
|
1998-06-24 15:09:23 +04:00
|
|
|
struct am7930_softc *sc = (struct am7930_softc *)self;
|
1998-03-21 23:11:30 +03:00
|
|
|
bus_space_handle_t bh;
|
|
|
|
|
|
|
|
sc->sc_bustag = sa->sa_bustag;
|
|
|
|
|
|
|
|
if (sbus_bus_map(
|
|
|
|
sa->sa_bustag,
|
|
|
|
sa->sa_slot,
|
|
|
|
sa->sa_offset,
|
1998-06-24 15:09:23 +04:00
|
|
|
sizeof(struct am7930),
|
1998-03-21 23:11:30 +03:00
|
|
|
0, 0,
|
|
|
|
&bh) != 0) {
|
|
|
|
printf("%s: cannot map registers\n", self->dv_xname);
|
1995-04-26 00:05:32 +04:00
|
|
|
return;
|
|
|
|
}
|
1998-06-24 15:09:23 +04:00
|
|
|
sc->sc_amd = (volatile struct am7930 *)bh;
|
|
|
|
am7930_sparc_attach(sc, sa->sa_pri);
|
1998-03-21 23:11:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-06-24 15:09:23 +04:00
|
|
|
am7930_sparc_attach(sc, pri)
|
|
|
|
struct am7930_softc *sc;
|
1998-03-21 23:11:30 +03:00
|
|
|
int pri;
|
|
|
|
{
|
|
|
|
|
|
|
|
printf(" softpri %d\n", PIL_AUSOFT);
|
1995-04-26 00:05:32 +04:00
|
|
|
|
1998-06-24 15:09:23 +04:00
|
|
|
sc->sc_au.au_amd = sc->sc_amd;
|
|
|
|
am7930_init(sc);
|
1996-04-01 02:38:29 +04:00
|
|
|
|
1998-06-24 15:09:23 +04:00
|
|
|
sc->sc_wam16 = am7930_sparc_w16;
|
|
|
|
sc->sc_onopen = am7930_sparc_onopen;
|
|
|
|
sc->sc_onclose = am7930_sparc_onclose;
|
1995-04-26 00:05:32 +04:00
|
|
|
|
|
|
|
#ifndef AUDIO_C_HANDLER
|
|
|
|
auiop = &sc->sc_au;
|
1998-03-21 23:11:30 +03:00
|
|
|
(void)bus_intr_establish(sc->sc_bustag, pri,
|
|
|
|
BUS_INTR_ESTABLISH_FASTTRAP,
|
|
|
|
(int (*) __P((void *)))amd7930_trap, NULL);
|
1995-04-26 00:05:32 +04:00
|
|
|
#else
|
1998-03-21 23:11:30 +03:00
|
|
|
(void)bus_intr_establish(sc->sc_bustag, pri, 0,
|
1998-06-24 15:09:23 +04:00
|
|
|
am7930hwintr, &sc->sc_au);
|
1995-04-26 00:05:32 +04:00
|
|
|
#endif
|
1998-03-21 23:11:30 +03:00
|
|
|
(void)bus_intr_establish(sc->sc_bustag, PIL_AUSOFT,
|
|
|
|
BUS_INTR_ESTABLISH_SOFTINTR,
|
1998-06-24 15:09:23 +04:00
|
|
|
am7930swintr, sc);
|
1995-04-26 00:05:32 +04:00
|
|
|
|
1995-05-04 23:43:27 +04:00
|
|
|
evcnt_attach(&sc->sc_dev, "intr", &sc->sc_intrcnt);
|
|
|
|
|
1998-08-18 01:16:09 +04:00
|
|
|
audio_attach_mi(&sa_hw_if, sc, &sc->sc_dev);
|
1995-04-26 00:05:32 +04:00
|
|
|
}
|
|
|
|
|
1998-06-24 15:09:23 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 16-bit register write, big-endian mapping.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
am7930_sparc_w16(amd, val)
|
|
|
|
volatile struct am7930 *amd;
|
|
|
|
u_int16_t val;
|
1995-04-26 00:05:32 +04:00
|
|
|
{
|
1998-06-24 15:09:23 +04:00
|
|
|
amd->dr = val;
|
|
|
|
amd->dr = val >> 8;
|
1995-04-26 00:05:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-06-24 15:09:23 +04:00
|
|
|
/*
|
|
|
|
* MD attach-dependent middle layer:
|
|
|
|
* move bytes to/from MAP chip.
|
|
|
|
*/
|
1995-04-26 00:05:32 +04:00
|
|
|
|
1998-06-24 15:09:23 +04:00
|
|
|
void
|
|
|
|
am7930_sparc_onopen(sc)
|
|
|
|
struct am7930_softc *sc;
|
|
|
|
{
|
|
|
|
|
|
|
|
/* reset pdma state */
|
1995-04-26 00:05:32 +04:00
|
|
|
sc->sc_rintr = 0;
|
|
|
|
sc->sc_rarg = 0;
|
|
|
|
sc->sc_pintr = 0;
|
|
|
|
sc->sc_parg = 0;
|
|
|
|
|
|
|
|
sc->sc_au.au_rdata = 0;
|
|
|
|
sc->sc_au.au_pdata = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-06-24 15:09:23 +04:00
|
|
|
void
|
|
|
|
am7930_sparc_onclose(sc)
|
|
|
|
struct am7930_softc *sc;
|
1995-04-26 00:05:32 +04:00
|
|
|
{
|
1998-06-24 15:09:23 +04:00
|
|
|
/* On sparc, just do the chipset-level halt. */
|
|
|
|
am7930_halt_input(sc);
|
|
|
|
am7930_halt_output(sc);
|
1995-04-26 00:05:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-06-24 15:09:23 +04:00
|
|
|
am7930_start_output(addr, p, cc, intr, arg)
|
1995-04-26 00:05:32 +04:00
|
|
|
void *addr;
|
|
|
|
void *p;
|
|
|
|
int cc;
|
1996-03-14 22:44:30 +03:00
|
|
|
void (*intr) __P((void *));
|
1995-04-26 00:05:32 +04:00
|
|
|
void *arg;
|
|
|
|
{
|
1998-06-24 15:09:23 +04:00
|
|
|
register struct am7930_softc *sc = addr;
|
1995-04-26 00:05:32 +04:00
|
|
|
|
1995-07-19 23:50:16 +04:00
|
|
|
#ifdef AUDIO_DEBUG
|
1998-06-24 15:09:23 +04:00
|
|
|
if (am7930debug > 1)
|
1998-08-28 12:57:38 +04:00
|
|
|
printf("sa_start_output: cc=%d %p (%p)\n", cc, intr, arg);
|
1995-04-26 00:05:32 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!sc->sc_locked) {
|
1998-06-24 15:09:23 +04:00
|
|
|
register volatile struct am7930 *amd;
|
1995-04-26 00:05:32 +04:00
|
|
|
|
|
|
|
amd = sc->sc_au.au_amd;
|
|
|
|
amd->cr = AMDR_INIT;
|
|
|
|
amd->dr = AMD_INIT_PMS_ACTIVE;
|
|
|
|
sc->sc_locked = 1;
|
|
|
|
DPRINTF(("sa_start_output: started intrs.\n"));
|
|
|
|
}
|
|
|
|
sc->sc_pintr = intr;
|
|
|
|
sc->sc_parg = arg;
|
|
|
|
sc->sc_au.au_pdata = p;
|
1998-06-24 15:09:23 +04:00
|
|
|
sc->sc_au.au_pend = p + cc - 1;
|
1995-04-26 00:05:32 +04:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ARGSUSED */
|
|
|
|
int
|
1998-06-24 15:09:23 +04:00
|
|
|
am7930_start_input(addr, p, cc, intr, arg)
|
1995-04-26 00:05:32 +04:00
|
|
|
void *addr;
|
|
|
|
void *p;
|
|
|
|
int cc;
|
1996-03-14 22:44:30 +03:00
|
|
|
void (*intr) __P((void *));
|
1995-04-26 00:05:32 +04:00
|
|
|
void *arg;
|
|
|
|
{
|
1998-06-24 15:09:23 +04:00
|
|
|
register struct am7930_softc *sc = addr;
|
1995-04-26 00:05:32 +04:00
|
|
|
|
1995-07-19 23:50:16 +04:00
|
|
|
#ifdef AUDIO_DEBUG
|
1998-06-24 15:09:23 +04:00
|
|
|
if (am7930debug > 1)
|
1998-08-28 12:57:38 +04:00
|
|
|
printf("sa_start_input: cc=%d %p (%p)\n", cc, intr, arg);
|
1995-04-26 00:05:32 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!sc->sc_locked) {
|
1998-06-24 15:09:23 +04:00
|
|
|
register volatile struct am7930 *amd;
|
1995-04-26 00:05:32 +04:00
|
|
|
|
|
|
|
amd = sc->sc_au.au_amd;
|
|
|
|
amd->cr = AMDR_INIT;
|
|
|
|
amd->dr = AMD_INIT_PMS_ACTIVE;
|
|
|
|
sc->sc_locked = 1;
|
|
|
|
DPRINTF(("sa_start_input: started intrs.\n"));
|
|
|
|
}
|
|
|
|
sc->sc_rintr = intr;
|
|
|
|
sc->sc_rarg = arg;
|
|
|
|
sc->sc_au.au_rdata = p;
|
1998-06-24 15:09:23 +04:00
|
|
|
sc->sc_au.au_rend = p + cc -1;
|
1995-04-26 00:05:32 +04:00
|
|
|
return(0);
|
|
|
|
}
|
1998-08-28 12:57:38 +04:00
|
|
|
/*
|
|
|
|
* halt routines: on Sparc, just use MI chipset halt.
|
1998-06-24 15:09:23 +04:00
|
|
|
*/
|
1995-04-26 00:05:32 +04:00
|
|
|
|
|
|
|
|
1998-06-24 15:09:23 +04:00
|
|
|
/*
|
|
|
|
* Pseudo-DMA support: either C or locore assember.
|
|
|
|
*/
|
1995-04-26 00:05:32 +04:00
|
|
|
|
1998-06-24 15:09:23 +04:00
|
|
|
#ifdef AUDIO_C_HANDLER
|
1995-04-26 00:05:32 +04:00
|
|
|
int
|
1998-06-24 15:09:23 +04:00
|
|
|
am7930hwintr(au0)
|
|
|
|
void *au0;
|
1995-04-26 00:05:32 +04:00
|
|
|
{
|
1998-06-24 15:09:23 +04:00
|
|
|
register struct auio *au = au0;
|
|
|
|
register volatile struct am7930 *amd = au->au_amd;
|
|
|
|
register u_char *d, *e;
|
|
|
|
register int k;
|
1995-04-26 00:05:32 +04:00
|
|
|
|
1998-06-24 15:09:23 +04:00
|
|
|
k = amd->ir; /* clear interrupt */
|
1995-04-26 00:05:32 +04:00
|
|
|
|
1998-06-24 15:09:23 +04:00
|
|
|
/* receive incoming data */
|
|
|
|
d = au->au_rdata;
|
|
|
|
e = au->au_rend;
|
|
|
|
if (d && d <= e) {
|
|
|
|
*d = amd->bbrb;
|
|
|
|
au->au_rdata++;
|
|
|
|
if (d == e) {
|
|
|
|
#ifdef AUDIO_DEBUG
|
|
|
|
if (am7930debug > 1)
|
1998-08-28 12:57:38 +04:00
|
|
|
printf("am7930hwintr: swintr(r) requested");
|
1998-06-24 15:09:23 +04:00
|
|
|
#endif
|
|
|
|
AUDIO_SET_SWINTR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* send outgoing data */
|
|
|
|
d = au->au_pdata;
|
|
|
|
e = au->au_pend;
|
|
|
|
if (d && d <= e) {
|
|
|
|
amd->bbtb = *d;
|
|
|
|
au->au_pdata++;
|
|
|
|
if (d == e) {
|
|
|
|
#ifdef AUDIO_DEBUG
|
|
|
|
if (am7930debug > 1)
|
1998-08-28 12:57:38 +04:00
|
|
|
printf("am7930hwintr: swintr(p) requested");
|
1998-06-24 15:09:23 +04:00
|
|
|
#endif
|
|
|
|
AUDIO_SET_SWINTR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*(au->au_intrcnt)++;
|
|
|
|
return (1);
|
1995-04-26 00:05:32 +04:00
|
|
|
}
|
1998-06-24 15:09:23 +04:00
|
|
|
#endif /* AUDIO_C_HANDLER */
|
1995-04-26 00:05:32 +04:00
|
|
|
|
|
|
|
int
|
1998-06-24 15:09:23 +04:00
|
|
|
am7930swintr(sc0)
|
|
|
|
void *sc0;
|
1995-04-26 00:05:32 +04:00
|
|
|
{
|
1998-06-24 15:09:23 +04:00
|
|
|
register struct am7930_softc *sc = sc0;
|
|
|
|
register struct auio *au;
|
|
|
|
register int s, ret = 0;
|
|
|
|
|
|
|
|
#ifdef AUDIO_DEBUG
|
|
|
|
if (am7930debug > 1)
|
1998-08-28 12:57:38 +04:00
|
|
|
printf("audiointr: sc=%p\n", sc);
|
1998-06-24 15:09:23 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
au = &sc->sc_au;
|
|
|
|
s = splaudio();
|
|
|
|
if (au->au_rdata > au->au_rend && sc->sc_rintr != NULL) {
|
|
|
|
splx(s);
|
|
|
|
ret = 1;
|
|
|
|
(*sc->sc_rintr)(sc->sc_rarg);
|
|
|
|
s = splaudio();
|
|
|
|
}
|
|
|
|
if (au->au_pdata > au->au_pend && sc->sc_pintr != NULL) {
|
|
|
|
splx(s);
|
|
|
|
ret = 1;
|
|
|
|
(*sc->sc_pintr)(sc->sc_parg);
|
|
|
|
} else
|
|
|
|
splx(s);
|
|
|
|
return (ret);
|
1995-04-26 00:05:32 +04:00
|
|
|
}
|
|
|
|
|
1998-06-24 15:09:23 +04:00
|
|
|
/*
|
1998-08-28 12:57:38 +04:00
|
|
|
* Attach-dependent channel set/query
|
1998-06-24 15:09:23 +04:00
|
|
|
*/
|
1995-04-26 00:05:32 +04:00
|
|
|
int
|
1998-06-24 15:09:23 +04:00
|
|
|
am7930_set_port(addr, cp)
|
1995-04-26 00:05:32 +04:00
|
|
|
void *addr;
|
|
|
|
mixer_ctrl_t *cp;
|
|
|
|
{
|
1998-06-24 15:09:23 +04:00
|
|
|
register struct am7930_softc *sc = addr;
|
1995-04-26 00:05:32 +04:00
|
|
|
|
1998-06-24 15:09:23 +04:00
|
|
|
DPRINTF(("am7930_set_port: port=%d", cp->dev));
|
1995-04-26 00:05:32 +04:00
|
|
|
|
1997-12-06 06:20:56 +03:00
|
|
|
if (cp->dev == SUNAUDIO_SOURCE || cp->dev == SUNAUDIO_OUTPUT) {
|
|
|
|
if (cp->type != AUDIO_MIXER_ENUM)
|
|
|
|
return(EINVAL);
|
1998-08-28 12:57:38 +04:00
|
|
|
} else if (cp->type != AUDIO_MIXER_VALUE ||
|
1997-12-06 06:20:56 +03:00
|
|
|
cp->un.value.num_channels != 1) {
|
1995-04-26 00:05:32 +04:00
|
|
|
return(EINVAL);
|
1997-12-06 06:20:56 +03:00
|
|
|
}
|
1996-04-01 02:38:29 +04:00
|
|
|
|
1995-04-26 00:05:32 +04:00
|
|
|
switch(cp->dev) {
|
|
|
|
case SUNAUDIO_MIC_PORT:
|
|
|
|
sc->sc_rlevel = cp->un.value.level[AUDIO_MIXER_LEVEL_MONO];
|
|
|
|
break;
|
|
|
|
case SUNAUDIO_SPEAKER:
|
|
|
|
case SUNAUDIO_HEADPHONES:
|
|
|
|
sc->sc_plevel = cp->un.value.level[AUDIO_MIXER_LEVEL_MONO];
|
|
|
|
break;
|
|
|
|
case SUNAUDIO_MONITOR:
|
|
|
|
sc->sc_mlevel = cp->un.value.level[AUDIO_MIXER_LEVEL_MONO];
|
|
|
|
break;
|
1997-10-19 11:41:33 +04:00
|
|
|
case SUNAUDIO_SOURCE:
|
1997-10-20 00:34:54 +04:00
|
|
|
if (cp->un.ord != SUNAUDIO_MIC_PORT)
|
1997-10-19 11:41:33 +04:00
|
|
|
return EINVAL;
|
|
|
|
break;
|
|
|
|
case SUNAUDIO_OUTPUT:
|
1997-10-20 00:34:54 +04:00
|
|
|
if (cp->un.ord != SUNAUDIO_SPEAKER &&
|
|
|
|
cp->un.ord != SUNAUDIO_HEADPHONES)
|
1997-10-19 11:41:33 +04:00
|
|
|
return EINVAL;
|
1997-10-20 00:34:54 +04:00
|
|
|
sc->sc_out_port = cp->un.ord;
|
1997-10-19 11:41:33 +04:00
|
|
|
break;
|
1995-04-26 00:05:32 +04:00
|
|
|
default:
|
|
|
|
return(EINVAL);
|
|
|
|
/* NOTREACHED */
|
|
|
|
}
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-06-24 15:09:23 +04:00
|
|
|
am7930_get_port(addr, cp)
|
1995-04-26 00:05:32 +04:00
|
|
|
void *addr;
|
|
|
|
mixer_ctrl_t *cp;
|
|
|
|
{
|
1998-06-24 15:09:23 +04:00
|
|
|
register struct am7930_softc *sc = addr;
|
1995-04-26 00:05:32 +04:00
|
|
|
|
1998-06-24 15:09:23 +04:00
|
|
|
DPRINTF(("am7930_get_port: port=%d", cp->dev));
|
1995-04-26 00:05:32 +04:00
|
|
|
|
1997-12-06 06:20:56 +03:00
|
|
|
if (cp->dev == SUNAUDIO_SOURCE || cp->dev == SUNAUDIO_OUTPUT) {
|
|
|
|
if (cp->type != AUDIO_MIXER_ENUM)
|
|
|
|
return(EINVAL);
|
1998-08-28 12:57:38 +04:00
|
|
|
} else if (cp->type != AUDIO_MIXER_VALUE ||
|
1997-12-06 06:20:56 +03:00
|
|
|
cp->un.value.num_channels != 1) {
|
1995-04-26 00:05:32 +04:00
|
|
|
return(EINVAL);
|
1997-12-06 06:20:56 +03:00
|
|
|
}
|
1996-04-01 02:38:29 +04:00
|
|
|
|
1995-04-26 00:05:32 +04:00
|
|
|
switch(cp->dev) {
|
|
|
|
case SUNAUDIO_MIC_PORT:
|
|
|
|
cp->un.value.level[AUDIO_MIXER_LEVEL_MONO] = sc->sc_rlevel;
|
|
|
|
break;
|
|
|
|
case SUNAUDIO_SPEAKER:
|
|
|
|
case SUNAUDIO_HEADPHONES:
|
|
|
|
cp->un.value.level[AUDIO_MIXER_LEVEL_MONO] = sc->sc_plevel;
|
|
|
|
break;
|
|
|
|
case SUNAUDIO_MONITOR:
|
|
|
|
cp->un.value.level[AUDIO_MIXER_LEVEL_MONO] = sc->sc_mlevel;
|
|
|
|
break;
|
1997-10-19 11:41:33 +04:00
|
|
|
case SUNAUDIO_SOURCE:
|
1997-10-20 00:34:54 +04:00
|
|
|
cp->un.ord = SUNAUDIO_MIC_PORT;
|
1997-10-19 11:41:33 +04:00
|
|
|
break;
|
|
|
|
case SUNAUDIO_OUTPUT:
|
1997-10-20 00:34:54 +04:00
|
|
|
cp->un.ord = sc->sc_out_port;
|
1997-10-19 11:41:33 +04:00
|
|
|
break;
|
1995-04-26 00:05:32 +04:00
|
|
|
default:
|
|
|
|
return(EINVAL);
|
|
|
|
/* NOTREACHED */
|
|
|
|
}
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
1997-08-01 02:33:08 +04:00
|
|
|
|
1995-04-26 00:05:32 +04:00
|
|
|
int
|
1998-06-24 15:09:23 +04:00
|
|
|
am7930_query_devinfo(addr, dip)
|
1995-04-26 00:05:32 +04:00
|
|
|
void *addr;
|
|
|
|
register mixer_devinfo_t *dip;
|
|
|
|
{
|
|
|
|
switch(dip->index) {
|
|
|
|
case SUNAUDIO_MIC_PORT:
|
|
|
|
dip->type = AUDIO_MIXER_VALUE;
|
|
|
|
dip->mixer_class = SUNAUDIO_INPUT_CLASS;
|
|
|
|
dip->prev = dip->next = AUDIO_MIXER_LAST;
|
|
|
|
strcpy(dip->label.name, AudioNmicrophone);
|
|
|
|
dip->un.v.num_channels = 1;
|
|
|
|
strcpy(dip->un.v.units.name, AudioNvolume);
|
|
|
|
break;
|
|
|
|
case SUNAUDIO_SPEAKER:
|
|
|
|
dip->type = AUDIO_MIXER_VALUE;
|
|
|
|
dip->mixer_class = SUNAUDIO_OUTPUT_CLASS;
|
|
|
|
dip->prev = dip->next = AUDIO_MIXER_LAST;
|
|
|
|
strcpy(dip->label.name, AudioNspeaker);
|
|
|
|
dip->un.v.num_channels = 1;
|
|
|
|
strcpy(dip->un.v.units.name, AudioNvolume);
|
|
|
|
break;
|
|
|
|
case SUNAUDIO_HEADPHONES:
|
|
|
|
dip->type = AUDIO_MIXER_VALUE;
|
|
|
|
dip->mixer_class = SUNAUDIO_OUTPUT_CLASS;
|
|
|
|
dip->prev = dip->next = AUDIO_MIXER_LAST;
|
|
|
|
strcpy(dip->label.name, AudioNheadphone);
|
|
|
|
dip->un.v.num_channels = 1;
|
|
|
|
strcpy(dip->un.v.units.name, AudioNvolume);
|
|
|
|
break;
|
1997-12-06 06:20:56 +03:00
|
|
|
case SUNAUDIO_MONITOR:
|
|
|
|
dip->type = AUDIO_MIXER_VALUE;
|
|
|
|
dip->mixer_class = SUNAUDIO_MONITOR_CLASS;
|
|
|
|
dip->prev = dip->next = AUDIO_MIXER_LAST;
|
|
|
|
strcpy(dip->label.name, AudioNmonitor);
|
|
|
|
dip->un.v.num_channels = 1;
|
|
|
|
strcpy(dip->un.v.units.name, AudioNvolume);
|
|
|
|
break;
|
1997-10-19 11:41:33 +04:00
|
|
|
case SUNAUDIO_SOURCE:
|
|
|
|
dip->type = AUDIO_MIXER_ENUM;
|
|
|
|
dip->mixer_class = SUNAUDIO_RECORD_CLASS;
|
|
|
|
dip->next = dip->prev = AUDIO_MIXER_LAST;
|
|
|
|
strcpy(dip->label.name, AudioNsource);
|
|
|
|
dip->un.e.num_mem = 1;
|
|
|
|
strcpy(dip->un.e.member[0].label.name, AudioNmicrophone);
|
|
|
|
dip->un.e.member[0].ord = SUNAUDIO_MIC_PORT;
|
|
|
|
break;
|
|
|
|
case SUNAUDIO_OUTPUT:
|
|
|
|
dip->type = AUDIO_MIXER_ENUM;
|
|
|
|
dip->mixer_class = SUNAUDIO_MONITOR_CLASS;
|
|
|
|
dip->next = dip->prev = AUDIO_MIXER_LAST;
|
|
|
|
strcpy(dip->label.name, AudioNoutput);
|
|
|
|
dip->un.e.num_mem = 2;
|
|
|
|
strcpy(dip->un.e.member[0].label.name, AudioNspeaker);
|
|
|
|
dip->un.e.member[0].ord = SUNAUDIO_SPEAKER;
|
|
|
|
strcpy(dip->un.e.member[1].label.name, AudioNheadphone);
|
|
|
|
dip->un.e.member[1].ord = SUNAUDIO_HEADPHONES;
|
|
|
|
break;
|
1995-04-26 00:05:32 +04:00
|
|
|
case SUNAUDIO_INPUT_CLASS:
|
|
|
|
dip->type = AUDIO_MIXER_CLASS;
|
|
|
|
dip->mixer_class = SUNAUDIO_INPUT_CLASS;
|
|
|
|
dip->next = dip->prev = AUDIO_MIXER_LAST;
|
1997-10-11 16:43:51 +04:00
|
|
|
strcpy(dip->label.name, AudioCinputs);
|
1995-04-26 00:05:32 +04:00
|
|
|
break;
|
|
|
|
case SUNAUDIO_OUTPUT_CLASS:
|
|
|
|
dip->type = AUDIO_MIXER_CLASS;
|
|
|
|
dip->mixer_class = SUNAUDIO_OUTPUT_CLASS;
|
|
|
|
dip->next = dip->prev = AUDIO_MIXER_LAST;
|
1997-12-06 06:20:56 +03:00
|
|
|
strcpy(dip->label.name, AudioCoutputs);
|
1997-10-19 11:41:33 +04:00
|
|
|
break;
|
|
|
|
case SUNAUDIO_RECORD_CLASS:
|
|
|
|
dip->type = AUDIO_MIXER_CLASS;
|
|
|
|
dip->mixer_class = SUNAUDIO_RECORD_CLASS;
|
|
|
|
dip->next = dip->prev = AUDIO_MIXER_LAST;
|
1997-12-06 06:20:56 +03:00
|
|
|
strcpy(dip->label.name, AudioCrecord);
|
1995-04-26 00:05:32 +04:00
|
|
|
break;
|
1997-12-06 06:20:56 +03:00
|
|
|
case SUNAUDIO_MONITOR_CLASS:
|
1997-10-19 11:41:33 +04:00
|
|
|
dip->type = AUDIO_MIXER_CLASS;
|
|
|
|
dip->mixer_class = SUNAUDIO_MONITOR_CLASS;
|
|
|
|
dip->next = dip->prev = AUDIO_MIXER_LAST;
|
|
|
|
strcpy(dip->label.name, AudioCmonitor);
|
|
|
|
break;
|
1995-04-26 00:05:32 +04:00
|
|
|
default:
|
|
|
|
return ENXIO;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
|
|
|
DPRINTF(("AUDIO_MIXER_DEVINFO: name=%s\n", dip->label.name));
|
1996-04-01 02:38:29 +04:00
|
|
|
|
1995-04-26 00:05:32 +04:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* NAUDIO > 0 */
|