2000-12-29 01:59:06 +03:00
|
|
|
/* $NetBSD: eap.c,v 1.42 2000/12/28 22:59:12 sommerfeld Exp $ */
|
1999-10-27 17:20:34 +04:00
|
|
|
/* $OpenBSD: eap.c,v 1.6 1999/10/05 19:24:42 csapuntz Exp $ */
|
1998-05-02 01:54:33 +04:00
|
|
|
|
|
|
|
/*
|
1999-02-18 00:44:55 +03:00
|
|
|
* Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
|
1998-05-02 01:54:33 +04:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
1998-11-26 01:17:06 +03:00
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
1999-02-18 00:44:55 +03:00
|
|
|
* by Lennart Augustsson <augustss@netbsd.org> and Charles M. Hannum.
|
1998-05-02 01:54:33 +04:00
|
|
|
*
|
|
|
|
* 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 the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``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 FOUNDATION OR CONTRIBUTORS
|
|
|
|
* 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.
|
|
|
|
*/
|
1999-02-18 00:44:55 +03:00
|
|
|
|
1998-11-26 01:17:06 +03:00
|
|
|
/*
|
|
|
|
* Debugging: Andreas Gustafsson <gson@araneus.fi>
|
|
|
|
* Testing: Chuck Cranor <chuck@maria.wustl.edu>
|
|
|
|
* Phil Nelson <phil@cs.wwu.edu>
|
1999-11-02 08:40:59 +03:00
|
|
|
*
|
|
|
|
* ES1371/AC97: Ezra Story <ezy@panix.com>
|
1998-11-26 01:17:06 +03:00
|
|
|
*/
|
1998-05-02 01:54:33 +04:00
|
|
|
|
|
|
|
/*
|
1999-11-02 08:40:59 +03:00
|
|
|
* Ensoniq ES1370 + AK4531 and ES1371/ES1373 + AC97
|
1999-10-27 17:20:34 +04:00
|
|
|
*
|
1999-11-02 08:40:59 +03:00
|
|
|
* Documentation links:
|
|
|
|
*
|
2000-06-01 13:58:19 +04:00
|
|
|
* ftp://ftp.alsa-project.org/pub/manuals/ensoniq/
|
1999-11-02 08:40:59 +03:00
|
|
|
* ftp://ftp.alsa-project.org/pub/manuals/asahi_kasei/4531.pdf
|
2000-03-19 20:11:50 +03:00
|
|
|
* ftp://download.intel.com/ial/scalableplatforms/audio/ac97r21.pdf
|
1998-05-02 01:54:33 +04:00
|
|
|
*/
|
|
|
|
|
1999-10-30 03:03:18 +04:00
|
|
|
#include "midi.h"
|
|
|
|
|
1998-05-02 01:54:33 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
1999-10-30 03:03:18 +04:00
|
|
|
#include <sys/fcntl.h>
|
1998-05-02 01:54:33 +04:00
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/device.h>
|
2000-05-01 01:59:58 +04:00
|
|
|
#include <sys/proc.h>
|
1998-05-02 01:54:33 +04:00
|
|
|
|
|
|
|
#include <dev/pci/pcidevs.h>
|
|
|
|
#include <dev/pci/pcivar.h>
|
|
|
|
|
|
|
|
#include <sys/audioio.h>
|
|
|
|
#include <dev/audio_if.h>
|
1999-10-30 03:03:18 +04:00
|
|
|
#include <dev/midi_if.h>
|
1998-05-02 01:54:33 +04:00
|
|
|
#include <dev/mulaw.h>
|
|
|
|
#include <dev/auconv.h>
|
2000-05-15 05:27:44 +04:00
|
|
|
#include <dev/ic/ac97var.h>
|
1998-05-02 01:54:33 +04:00
|
|
|
|
|
|
|
#include <machine/bus.h>
|
|
|
|
|
2000-03-19 20:11:50 +03:00
|
|
|
#include <dev/pci/eapreg.h>
|
1998-05-02 01:54:33 +04:00
|
|
|
|
2000-03-19 20:11:50 +03:00
|
|
|
#define PCI_CBIO 0x10
|
1999-10-30 03:03:18 +04:00
|
|
|
|
1999-10-27 17:20:34 +04:00
|
|
|
/* Debug */
|
1998-05-02 01:54:33 +04:00
|
|
|
#ifdef AUDIO_DEBUG
|
|
|
|
#define DPRINTF(x) if (eapdebug) printf x
|
|
|
|
#define DPRINTFN(n,x) if (eapdebug>(n)) printf x
|
|
|
|
int eapdebug = 0;
|
|
|
|
#else
|
|
|
|
#define DPRINTF(x)
|
|
|
|
#define DPRINTFN(n,x)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int eap_match __P((struct device *, struct cfdata *, void *));
|
|
|
|
void eap_attach __P((struct device *, struct device *, void *));
|
|
|
|
int eap_intr __P((void *));
|
|
|
|
|
|
|
|
struct eap_dma {
|
|
|
|
bus_dmamap_t map;
|
1998-08-10 00:32:34 +04:00
|
|
|
caddr_t addr;
|
|
|
|
bus_dma_segment_t segs[1];
|
|
|
|
int nsegs;
|
|
|
|
size_t size;
|
|
|
|
struct eap_dma *next;
|
1998-05-02 01:54:33 +04:00
|
|
|
};
|
2000-03-19 20:11:50 +03:00
|
|
|
|
1999-02-18 10:59:30 +03:00
|
|
|
#define DMAADDR(p) ((p)->map->dm_segs[0].ds_addr)
|
|
|
|
#define KERNADDR(p) ((void *)((p)->addr))
|
1998-05-02 01:54:33 +04:00
|
|
|
|
|
|
|
struct eap_softc {
|
|
|
|
struct device sc_dev; /* base device */
|
|
|
|
void *sc_ih; /* interrupt vectoring */
|
|
|
|
bus_space_tag_t iot;
|
|
|
|
bus_space_handle_t ioh;
|
|
|
|
bus_dma_tag_t sc_dmatag; /* DMA tag */
|
|
|
|
|
1998-08-10 00:32:34 +04:00
|
|
|
struct eap_dma *sc_dmas;
|
1998-05-02 01:54:33 +04:00
|
|
|
|
|
|
|
void (*sc_pintr)(void *); /* dma completion intr handler */
|
|
|
|
void *sc_parg; /* arg for sc_intr() */
|
1998-08-10 00:32:34 +04:00
|
|
|
#ifdef DIAGNOSTIC
|
1998-05-02 01:54:33 +04:00
|
|
|
char sc_prun;
|
1998-08-10 00:32:34 +04:00
|
|
|
#endif
|
1998-05-02 01:54:33 +04:00
|
|
|
|
|
|
|
void (*sc_rintr)(void *); /* dma completion intr handler */
|
|
|
|
void *sc_rarg; /* arg for sc_intr() */
|
1998-08-10 00:32:34 +04:00
|
|
|
#ifdef DIAGNOSTIC
|
1998-05-02 01:54:33 +04:00
|
|
|
char sc_rrun;
|
1998-08-10 00:32:34 +04:00
|
|
|
#endif
|
1998-05-02 01:54:33 +04:00
|
|
|
|
1999-10-30 03:03:18 +04:00
|
|
|
#if NMIDI > 0
|
|
|
|
void (*sc_iintr)(void *, int); /* midi input ready handler */
|
|
|
|
void (*sc_ointr)(void *); /* midi output ready handler */
|
|
|
|
void *sc_arg;
|
|
|
|
#endif
|
|
|
|
|
2000-03-19 20:11:50 +03:00
|
|
|
u_short sc_port[AK_NPORTS]; /* mirror of the hardware setting */
|
1998-05-02 01:54:33 +04:00
|
|
|
u_int sc_record_source; /* recording source mask */
|
1998-07-06 15:12:21 +04:00
|
|
|
u_int sc_output_source; /* output source mask */
|
1998-08-12 22:47:43 +04:00
|
|
|
u_int sc_mic_preamp;
|
2000-05-01 01:59:58 +04:00
|
|
|
char sc_1371; /* Using ES1371/AC97 codec */
|
1999-10-27 17:20:34 +04:00
|
|
|
|
|
|
|
struct ac97_codec_if *codec_if;
|
|
|
|
struct ac97_host_if host_if;
|
1998-05-02 01:54:33 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
int eap_allocmem __P((struct eap_softc *, size_t, size_t, struct eap_dma *));
|
|
|
|
int eap_freemem __P((struct eap_softc *, struct eap_dma *));
|
|
|
|
|
1999-10-30 03:03:18 +04:00
|
|
|
#define EWRITE1(sc, r, x) bus_space_write_1((sc)->iot, (sc)->ioh, (r), (x))
|
1998-05-02 01:54:33 +04:00
|
|
|
#define EWRITE2(sc, r, x) bus_space_write_2((sc)->iot, (sc)->ioh, (r), (x))
|
|
|
|
#define EWRITE4(sc, r, x) bus_space_write_4((sc)->iot, (sc)->ioh, (r), (x))
|
1999-10-30 03:03:18 +04:00
|
|
|
#define EREAD1(sc, r) bus_space_read_1((sc)->iot, (sc)->ioh, (r))
|
1998-05-02 01:54:33 +04:00
|
|
|
#define EREAD2(sc, r) bus_space_read_2((sc)->iot, (sc)->ioh, (r))
|
|
|
|
#define EREAD4(sc, r) bus_space_read_4((sc)->iot, (sc)->ioh, (r))
|
|
|
|
|
|
|
|
struct cfattach eap_ca = {
|
|
|
|
sizeof(struct eap_softc), eap_match, eap_attach
|
|
|
|
};
|
|
|
|
|
|
|
|
int eap_open __P((void *, int));
|
|
|
|
void eap_close __P((void *));
|
|
|
|
int eap_query_encoding __P((void *, struct audio_encoding *));
|
|
|
|
int eap_set_params __P((void *, int, int, struct audio_params *, struct audio_params *));
|
|
|
|
int eap_round_blocksize __P((void *, int));
|
1998-08-10 00:32:34 +04:00
|
|
|
int eap_trigger_output __P((void *, void *, void *, int, void (*)(void *),
|
|
|
|
void *, struct audio_params *));
|
|
|
|
int eap_trigger_input __P((void *, void *, void *, int, void (*)(void *),
|
|
|
|
void *, struct audio_params *));
|
|
|
|
int eap_halt_output __P((void *));
|
|
|
|
int eap_halt_input __P((void *));
|
2000-03-19 20:11:50 +03:00
|
|
|
void eap1370_write_codec __P((struct eap_softc *, int, int));
|
1998-05-02 01:54:33 +04:00
|
|
|
int eap_getdev __P((void *, struct audio_device *));
|
2000-03-19 20:11:50 +03:00
|
|
|
int eap1370_mixer_set_port __P((void *, mixer_ctrl_t *));
|
|
|
|
int eap1370_mixer_get_port __P((void *, mixer_ctrl_t *));
|
1999-10-27 17:20:34 +04:00
|
|
|
int eap1371_mixer_set_port __P((void *, mixer_ctrl_t *));
|
|
|
|
int eap1371_mixer_get_port __P((void *, mixer_ctrl_t *));
|
2000-03-19 20:11:50 +03:00
|
|
|
int eap1370_query_devinfo __P((void *, mixer_devinfo_t *));
|
1999-02-17 05:37:38 +03:00
|
|
|
void *eap_malloc __P((void *, int, size_t, int, int));
|
1998-05-02 01:54:33 +04:00
|
|
|
void eap_free __P((void *, void *, int));
|
1999-02-17 05:37:38 +03:00
|
|
|
size_t eap_round_buffersize __P((void *, int, size_t));
|
2000-06-26 08:55:19 +04:00
|
|
|
paddr_t eap_mappage __P((void *, void *, off_t, int));
|
1998-05-02 01:54:33 +04:00
|
|
|
int eap_get_props __P((void *));
|
2000-03-19 20:11:50 +03:00
|
|
|
void eap1370_set_mixer __P((struct eap_softc *sc, int a, int d));
|
2000-05-01 01:59:58 +04:00
|
|
|
u_int32_t eap1371_src_wait __P((struct eap_softc *sc));
|
1999-10-27 17:20:34 +04:00
|
|
|
void eap1371_set_adc_rate __P((struct eap_softc *sc, int rate));
|
|
|
|
void eap1371_set_dac_rate __P((struct eap_softc *sc, int rate, int which));
|
|
|
|
int eap1371_src_read __P((struct eap_softc *sc, int a));
|
|
|
|
void eap1371_src_write __P((struct eap_softc *sc, int a, int d));
|
|
|
|
int eap1371_query_devinfo __P((void *addr, mixer_devinfo_t *dip));
|
|
|
|
|
|
|
|
int eap1371_attach_codec __P((void *sc, struct ac97_codec_if *));
|
|
|
|
int eap1371_read_codec __P((void *sc, u_int8_t a, u_int16_t *d));
|
|
|
|
int eap1371_write_codec __P((void *sc, u_int8_t a, u_int16_t d));
|
|
|
|
void eap1371_reset_codec __P((void *sc));
|
|
|
|
int eap1371_get_portnum_by_name __P((struct eap_softc *, char *, char *,
|
|
|
|
char *));
|
1999-10-30 03:03:18 +04:00
|
|
|
#if NMIDI > 0
|
|
|
|
void eap_midi_close __P((void *));
|
|
|
|
void eap_midi_getinfo __P((void *, struct midi_info *));
|
|
|
|
int eap_midi_open __P((void *, int, void (*)(void *, int),
|
|
|
|
void (*)(void *), void *));
|
|
|
|
int eap_midi_output __P((void *, int));
|
|
|
|
#endif
|
1998-05-02 01:54:33 +04:00
|
|
|
|
1999-11-02 08:40:59 +03:00
|
|
|
struct audio_hw_if eap1370_hw_if = {
|
1998-05-02 01:54:33 +04:00
|
|
|
eap_open,
|
|
|
|
eap_close,
|
|
|
|
NULL,
|
|
|
|
eap_query_encoding,
|
|
|
|
eap_set_params,
|
|
|
|
eap_round_blocksize,
|
|
|
|
NULL,
|
1998-08-10 00:32:34 +04:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
eap_halt_output,
|
|
|
|
eap_halt_input,
|
1998-05-02 01:54:33 +04:00
|
|
|
NULL,
|
|
|
|
eap_getdev,
|
|
|
|
NULL,
|
2000-03-19 20:11:50 +03:00
|
|
|
eap1370_mixer_set_port,
|
|
|
|
eap1370_mixer_get_port,
|
|
|
|
eap1370_query_devinfo,
|
1998-05-02 01:54:33 +04:00
|
|
|
eap_malloc,
|
|
|
|
eap_free,
|
1999-02-17 05:37:38 +03:00
|
|
|
eap_round_buffersize,
|
1998-05-02 01:54:33 +04:00
|
|
|
eap_mappage,
|
|
|
|
eap_get_props,
|
1998-08-10 00:32:34 +04:00
|
|
|
eap_trigger_output,
|
|
|
|
eap_trigger_input,
|
1998-05-02 01:54:33 +04:00
|
|
|
};
|
|
|
|
|
1999-11-02 08:40:59 +03:00
|
|
|
struct audio_hw_if eap1371_hw_if = {
|
|
|
|
eap_open,
|
|
|
|
eap_close,
|
|
|
|
NULL,
|
|
|
|
eap_query_encoding,
|
|
|
|
eap_set_params,
|
|
|
|
eap_round_blocksize,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
eap_halt_output,
|
|
|
|
eap_halt_input,
|
|
|
|
NULL,
|
|
|
|
eap_getdev,
|
|
|
|
NULL,
|
|
|
|
eap1371_mixer_set_port,
|
|
|
|
eap1371_mixer_get_port,
|
|
|
|
eap1371_query_devinfo,
|
|
|
|
eap_malloc,
|
|
|
|
eap_free,
|
|
|
|
eap_round_buffersize,
|
|
|
|
eap_mappage,
|
|
|
|
eap_get_props,
|
|
|
|
eap_trigger_output,
|
|
|
|
eap_trigger_input,
|
|
|
|
};
|
|
|
|
|
1999-10-30 03:03:18 +04:00
|
|
|
#if NMIDI > 0
|
|
|
|
struct midi_hw_if eap_midi_hw_if = {
|
|
|
|
eap_midi_open,
|
|
|
|
eap_midi_close,
|
|
|
|
eap_midi_output,
|
|
|
|
eap_midi_getinfo,
|
|
|
|
0, /* ioctl */
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
1998-05-02 01:54:33 +04:00
|
|
|
struct audio_device eap_device = {
|
|
|
|
"Ensoniq AudioPCI",
|
|
|
|
"",
|
|
|
|
"eap"
|
|
|
|
};
|
|
|
|
|
|
|
|
int
|
|
|
|
eap_match(parent, match, aux)
|
|
|
|
struct device *parent;
|
|
|
|
struct cfdata *match;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct pci_attach_args *pa = (struct pci_attach_args *) aux;
|
|
|
|
|
2000-05-01 01:59:58 +04:00
|
|
|
switch (PCI_VENDOR(pa->pa_id)) {
|
|
|
|
case PCI_VENDOR_CREATIVELABS:
|
|
|
|
switch (PCI_PRODUCT(pa->pa_id)) {
|
|
|
|
case PCI_PRODUCT_CREATIVELABS_EV1938:
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PCI_VENDOR_ENSONIQ:
|
|
|
|
switch (PCI_PRODUCT(pa->pa_id)) {
|
|
|
|
case PCI_PRODUCT_ENSONIQ_AUDIOPCI:
|
|
|
|
case PCI_PRODUCT_ENSONIQ_AUDIOPCI97:
|
|
|
|
case PCI_PRODUCT_ENSONIQ_CT5880:
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
1998-05-02 01:54:33 +04:00
|
|
|
|
1999-10-27 17:20:34 +04:00
|
|
|
return (0);
|
1998-05-02 01:54:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-03-19 20:11:50 +03:00
|
|
|
eap1370_write_codec(sc, a, d)
|
1998-05-02 01:54:33 +04:00
|
|
|
struct eap_softc *sc;
|
|
|
|
int a, d;
|
|
|
|
{
|
1999-11-01 21:12:19 +03:00
|
|
|
int icss, to;
|
1999-10-27 17:20:34 +04:00
|
|
|
|
1999-11-01 21:12:19 +03:00
|
|
|
to = EAP_WRITE_TIMEOUT;
|
1998-05-02 01:54:33 +04:00
|
|
|
do {
|
1998-08-10 00:32:34 +04:00
|
|
|
icss = EREAD4(sc, EAP_ICSS);
|
1998-05-02 01:54:33 +04:00
|
|
|
DPRINTFN(5,("eap: codec %d prog: icss=0x%08x\n", a, icss));
|
2000-05-01 01:59:58 +04:00
|
|
|
if (!to--) {
|
|
|
|
printf("eap: timeout writing to codec\n");
|
|
|
|
return;
|
|
|
|
}
|
1999-11-01 21:12:19 +03:00
|
|
|
} while(icss & EAP_CWRIP); /* XXX could use CSTAT here */
|
2000-05-01 01:59:58 +04:00
|
|
|
EWRITE4(sc, EAP_CODEC, EAP_SET_CODEC(a, d));
|
1999-10-27 17:20:34 +04:00
|
|
|
}
|
|
|
|
|
2000-05-01 01:59:58 +04:00
|
|
|
/*
|
|
|
|
* Reading and writing the CODEC is very convoluted. This mimics the
|
2000-05-01 21:15:41 +04:00
|
|
|
* FreeBSD and Linux drivers.
|
2000-05-01 01:59:58 +04:00
|
|
|
*/
|
|
|
|
|
2000-05-01 21:15:41 +04:00
|
|
|
static __inline void eap1371_ready_codec
|
|
|
|
__P((struct eap_softc *sc, u_int8_t a, u_int32_t wd));
|
|
|
|
static __inline void
|
|
|
|
eap1371_ready_codec(sc, a, wd)
|
|
|
|
struct eap_softc *sc;
|
1999-10-27 17:20:34 +04:00
|
|
|
u_int8_t a;
|
2000-05-01 21:15:41 +04:00
|
|
|
u_int32_t wd;
|
1999-10-27 17:20:34 +04:00
|
|
|
{
|
2000-05-01 21:15:41 +04:00
|
|
|
int to, s;
|
2000-05-01 01:59:58 +04:00
|
|
|
u_int32_t src, t;
|
|
|
|
|
|
|
|
for (to = 0; to < EAP_WRITE_TIMEOUT; to++) {
|
|
|
|
if (!(EREAD4(sc, E1371_CODEC) & E1371_CODEC_WIP))
|
|
|
|
break;
|
2000-05-01 21:15:41 +04:00
|
|
|
delay(1);
|
2000-05-01 01:59:58 +04:00
|
|
|
}
|
2000-05-01 21:15:41 +04:00
|
|
|
if (to > EAP_WRITE_TIMEOUT)
|
|
|
|
printf("%s: eap1371_ready_codec timeout 1\n",
|
|
|
|
sc->sc_dev.dv_xname);
|
2000-05-01 01:59:58 +04:00
|
|
|
|
|
|
|
s = splaudio();
|
|
|
|
src = eap1371_src_wait(sc) & E1371_SRC_CTLMASK;
|
|
|
|
EWRITE4(sc, E1371_SRC, src | E1371_SRC_STATE_OK);
|
|
|
|
|
|
|
|
for (to = 0; to < EAP_READ_TIMEOUT; to++) {
|
|
|
|
t = EREAD4(sc, E1371_SRC);
|
|
|
|
if ((t & E1371_SRC_STATE_MASK) == 0)
|
|
|
|
break;
|
|
|
|
delay(1);
|
|
|
|
}
|
2000-05-01 21:15:41 +04:00
|
|
|
if (to > EAP_WRITE_TIMEOUT)
|
|
|
|
printf("%s: eap1371_ready_codec timeout 2\n",
|
|
|
|
sc->sc_dev.dv_xname);
|
|
|
|
|
2000-05-01 01:59:58 +04:00
|
|
|
for (to = 0; to < EAP_READ_TIMEOUT; to++) {
|
|
|
|
t = EREAD4(sc, E1371_SRC);
|
|
|
|
if ((t & E1371_SRC_STATE_MASK) == E1371_SRC_STATE_OK)
|
|
|
|
break;
|
|
|
|
delay(1);
|
|
|
|
}
|
2000-05-01 21:15:41 +04:00
|
|
|
if (to > EAP_WRITE_TIMEOUT)
|
|
|
|
printf("%s: eap1371_ready_codec timeout 3\n",
|
|
|
|
sc->sc_dev.dv_xname);
|
2000-05-01 01:59:58 +04:00
|
|
|
|
2000-05-01 21:15:41 +04:00
|
|
|
EWRITE4(sc, E1371_CODEC, wd);
|
2000-05-01 01:59:58 +04:00
|
|
|
|
1999-10-27 17:20:34 +04:00
|
|
|
eap1371_src_wait(sc);
|
2000-05-01 01:59:58 +04:00
|
|
|
EWRITE4(sc, E1371_SRC, src);
|
|
|
|
|
|
|
|
splx(s);
|
2000-05-01 21:15:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
eap1371_read_codec(sc_, a, d)
|
|
|
|
void *sc_;
|
|
|
|
u_int8_t a;
|
|
|
|
u_int16_t *d;
|
|
|
|
{
|
|
|
|
struct eap_softc *sc = sc_;
|
|
|
|
int to;
|
|
|
|
u_int32_t t;
|
|
|
|
|
|
|
|
eap1371_ready_codec(sc, a, E1371_SET_CODEC(a, 0) | E1371_CODEC_READ);
|
1999-10-27 17:20:34 +04:00
|
|
|
|
|
|
|
for (to = 0; to < EAP_WRITE_TIMEOUT; to++) {
|
2000-05-01 01:59:58 +04:00
|
|
|
if (!(EREAD4(sc, E1371_CODEC) & E1371_CODEC_WIP))
|
1999-10-27 17:20:34 +04:00
|
|
|
break;
|
|
|
|
}
|
2000-05-01 21:15:41 +04:00
|
|
|
if (to > EAP_WRITE_TIMEOUT)
|
|
|
|
printf("%s: eap1371_read_codec timeout 1\n",
|
|
|
|
sc->sc_dev.dv_xname);
|
1999-10-27 17:20:34 +04:00
|
|
|
|
2000-05-01 01:59:58 +04:00
|
|
|
for (to = 0; to < EAP_WRITE_TIMEOUT; to++) {
|
|
|
|
t = EREAD4(sc, E1371_CODEC);
|
|
|
|
if (t & E1371_CODEC_VALID)
|
|
|
|
break;
|
1999-10-27 17:20:34 +04:00
|
|
|
}
|
2000-05-01 21:15:41 +04:00
|
|
|
if (to > EAP_WRITE_TIMEOUT)
|
|
|
|
printf("%s: eap1371_read_codec timeout 2\n",
|
|
|
|
sc->sc_dev.dv_xname);
|
1999-10-27 17:20:34 +04:00
|
|
|
|
2000-05-01 01:59:58 +04:00
|
|
|
*d = (u_int16_t)t;
|
1999-10-27 17:20:34 +04:00
|
|
|
|
2000-05-01 01:59:58 +04:00
|
|
|
DPRINTFN(10, ("eap1371: reading codec (%x) = %x\n", a, *d));
|
1999-10-27 17:20:34 +04:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
eap1371_write_codec(sc_, a, d)
|
2000-05-01 01:59:58 +04:00
|
|
|
void *sc_;
|
1999-10-27 17:20:34 +04:00
|
|
|
u_int8_t a;
|
|
|
|
u_int16_t d;
|
|
|
|
{
|
|
|
|
struct eap_softc *sc = sc_;
|
2000-05-01 01:59:58 +04:00
|
|
|
|
2000-05-01 21:15:41 +04:00
|
|
|
eap1371_ready_codec(sc, a, E1371_SET_CODEC(a, d));
|
2000-05-01 01:59:58 +04:00
|
|
|
|
1999-10-27 17:20:34 +04:00
|
|
|
DPRINTFN(10, ("eap1371: writing codec %x --> %x\n", d, a));
|
|
|
|
|
2000-05-01 01:59:58 +04:00
|
|
|
return (0);
|
1999-10-27 17:20:34 +04:00
|
|
|
}
|
|
|
|
|
2000-05-01 01:59:58 +04:00
|
|
|
u_int32_t
|
1999-10-27 17:20:34 +04:00
|
|
|
eap1371_src_wait(sc)
|
|
|
|
struct eap_softc *sc;
|
|
|
|
{
|
2000-05-01 01:59:58 +04:00
|
|
|
int to;
|
|
|
|
u_int32_t src;
|
|
|
|
|
|
|
|
for (to = 0; to < EAP_READ_TIMEOUT; to++) {
|
|
|
|
src = EREAD4(sc, E1371_SRC);
|
|
|
|
if (!(src & E1371_SRC_RBUSY))
|
|
|
|
return (src);
|
|
|
|
delay(1);
|
|
|
|
}
|
2000-05-01 21:15:41 +04:00
|
|
|
printf("%s: eap1371_src_wait timeout\n", sc->sc_dev.dv_xname);
|
2000-05-01 01:59:58 +04:00
|
|
|
return (src);
|
1999-10-27 17:20:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
eap1371_src_read(sc, a)
|
|
|
|
struct eap_softc *sc;
|
|
|
|
int a;
|
|
|
|
{
|
2000-05-01 01:59:58 +04:00
|
|
|
int to;
|
|
|
|
u_int32_t src, t;
|
1999-10-27 17:20:34 +04:00
|
|
|
|
2000-05-01 01:59:58 +04:00
|
|
|
src = eap1371_src_wait(sc) & E1371_SRC_CTLMASK;
|
|
|
|
src |= E1371_SRC_ADDR(a);
|
|
|
|
EWRITE4(sc, E1371_SRC, src | E1371_SRC_STATE_OK);
|
|
|
|
|
|
|
|
for (to = 0; to < EAP_READ_TIMEOUT; to++) {
|
|
|
|
t = EREAD4(sc, E1371_SRC);
|
|
|
|
if ((t & E1371_SRC_STATE_MASK) == E1371_SRC_STATE_OK)
|
|
|
|
break;
|
|
|
|
delay(1);
|
|
|
|
}
|
|
|
|
EWRITE4(sc, E1371_SRC, src);
|
|
|
|
|
|
|
|
return t & E1371_SRC_DATAMASK;
|
1999-10-27 17:20:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
eap1371_src_write(sc, a, d)
|
|
|
|
struct eap_softc *sc;
|
|
|
|
int a,d;
|
|
|
|
{
|
2000-05-01 01:59:58 +04:00
|
|
|
u_int32_t r;
|
1999-10-27 17:20:34 +04:00
|
|
|
|
2000-05-01 01:59:58 +04:00
|
|
|
r = eap1371_src_wait(sc) & E1371_SRC_CTLMASK;
|
1999-10-27 17:20:34 +04:00
|
|
|
r |= E1371_SRC_RAMWE | E1371_SRC_ADDR(a) | E1371_SRC_DATA(d);
|
|
|
|
EWRITE4(sc, E1371_SRC, r);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
eap1371_set_adc_rate(sc, rate)
|
|
|
|
struct eap_softc *sc;
|
|
|
|
int rate;
|
|
|
|
{
|
|
|
|
int freq, n, truncm;
|
|
|
|
int out;
|
2000-05-01 01:59:58 +04:00
|
|
|
int s;
|
|
|
|
|
|
|
|
/* Whatever, it works, so I'll leave it :) */
|
|
|
|
|
|
|
|
if (rate > 48000)
|
|
|
|
rate = 48000;
|
|
|
|
if (rate < 4000)
|
|
|
|
rate = 4000;
|
|
|
|
n = rate / 3000;
|
|
|
|
if ((1 << n) & SRC_MAGIC)
|
|
|
|
n--;
|
|
|
|
truncm = ((21 * n) - 1) | 1;
|
|
|
|
freq = ((48000 << 15) / rate) * n;
|
|
|
|
if (rate >= 24000) {
|
|
|
|
if (truncm > 239)
|
|
|
|
truncm = 239;
|
1999-10-27 17:20:34 +04:00
|
|
|
out = ESRC_SET_TRUNC((239 - truncm) / 2);
|
2000-05-01 01:59:58 +04:00
|
|
|
} else {
|
|
|
|
if (truncm > 119)
|
|
|
|
truncm = 119;
|
1999-10-27 17:20:34 +04:00
|
|
|
out = ESRC_SMF | ESRC_SET_TRUNC((119 - truncm) / 2);
|
2000-05-01 01:59:58 +04:00
|
|
|
}
|
1999-10-27 17:20:34 +04:00
|
|
|
out |= ESRC_SET_N(n);
|
2000-05-01 01:59:58 +04:00
|
|
|
s = splaudio();
|
|
|
|
eap1371_src_write(sc, ESRC_ADC+ESRC_TRUNC_N, out);
|
1999-10-27 17:20:34 +04:00
|
|
|
|
|
|
|
|
2000-05-01 01:59:58 +04:00
|
|
|
out = eap1371_src_read(sc, ESRC_ADC+ESRC_IREGS) & 0xff;
|
|
|
|
eap1371_src_write(sc, ESRC_ADC+ESRC_IREGS, out |
|
1999-10-27 17:20:34 +04:00
|
|
|
ESRC_SET_VFI(freq >> 15));
|
2000-05-01 01:59:58 +04:00
|
|
|
eap1371_src_write(sc, ESRC_ADC+ESRC_VFF, freq & 0x7fff);
|
|
|
|
eap1371_src_write(sc, ESRC_ADC_VOLL, ESRC_SET_ADC_VOL(n));
|
|
|
|
eap1371_src_write(sc, ESRC_ADC_VOLR, ESRC_SET_ADC_VOL(n));
|
|
|
|
splx(s);
|
1999-10-27 17:20:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
eap1371_set_dac_rate(sc, rate, which)
|
|
|
|
struct eap_softc *sc;
|
|
|
|
int rate;
|
|
|
|
int which;
|
|
|
|
{
|
2000-05-01 01:59:58 +04:00
|
|
|
int dac = which == 1 ? ESRC_DAC1 : ESRC_DAC2;
|
1999-10-27 17:20:34 +04:00
|
|
|
int freq, r;
|
2000-05-01 01:59:58 +04:00
|
|
|
int s;
|
1999-10-27 17:20:34 +04:00
|
|
|
|
2000-05-01 01:59:58 +04:00
|
|
|
/* Whatever, it works, so I'll leave it :) */
|
|
|
|
|
|
|
|
if (rate > 48000)
|
|
|
|
rate = 48000;
|
|
|
|
if (rate < 4000)
|
|
|
|
rate = 4000;
|
|
|
|
freq = (rate << 15) / 3000;
|
|
|
|
|
|
|
|
s = splaudio();
|
|
|
|
eap1371_src_wait(sc);
|
|
|
|
r = EREAD4(sc, E1371_SRC) & (E1371_SRC_DISABLE |
|
|
|
|
E1371_SRC_DISP2 | E1371_SRC_DISP1 | E1371_SRC_DISREC);
|
|
|
|
r |= (which == 1) ? E1371_SRC_DISP1 : E1371_SRC_DISP2;
|
|
|
|
EWRITE4(sc, E1371_SRC, r);
|
|
|
|
r = eap1371_src_read(sc, dac + ESRC_IREGS) & 0x00ff;
|
|
|
|
eap1371_src_write(sc, dac + ESRC_IREGS, r | ((freq >> 5) & 0xfc00));
|
|
|
|
eap1371_src_write(sc, dac + ESRC_VFF, freq & 0x7fff);
|
|
|
|
r = EREAD4(sc, E1371_SRC) & (E1371_SRC_DISABLE |
|
|
|
|
E1371_SRC_DISP2 | E1371_SRC_DISP1 | E1371_SRC_DISREC);
|
|
|
|
r &= ~(which == 1 ? E1371_SRC_DISP1 : E1371_SRC_DISP2);
|
|
|
|
EWRITE4(sc, E1371_SRC, r);
|
|
|
|
splx(s);
|
1998-05-02 01:54:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
eap_attach(parent, self, aux)
|
|
|
|
struct device *parent;
|
|
|
|
struct device *self;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct eap_softc *sc = (struct eap_softc *)self;
|
|
|
|
struct pci_attach_args *pa = (struct pci_attach_args *)aux;
|
|
|
|
pci_chipset_tag_t pc = pa->pa_pc;
|
1999-11-02 08:40:59 +03:00
|
|
|
struct audio_hw_if *eap_hw_if;
|
1998-05-02 01:54:33 +04:00
|
|
|
char const *intrstr;
|
|
|
|
pci_intr_handle_t ih;
|
|
|
|
pcireg_t csr;
|
1999-11-01 21:12:19 +03:00
|
|
|
char devinfo[256];
|
1998-05-02 01:54:33 +04:00
|
|
|
mixer_ctrl_t ctl;
|
1999-10-27 17:20:34 +04:00
|
|
|
int i;
|
2000-05-01 01:59:58 +04:00
|
|
|
int revision, ct5880;
|
|
|
|
const char *revstr = "";
|
|
|
|
|
|
|
|
/* Flag if we're "creative" */
|
|
|
|
sc->sc_1371 = !(PCI_VENDOR(pa->pa_id) == PCI_VENDOR_ENSONIQ &&
|
|
|
|
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_ENSONIQ_AUDIOPCI);
|
1999-10-27 17:20:34 +04:00
|
|
|
|
1999-11-01 21:12:19 +03:00
|
|
|
pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo);
|
2000-04-24 21:55:24 +04:00
|
|
|
revision = PCI_REVISION(pa->pa_class);
|
2000-05-01 01:59:58 +04:00
|
|
|
if (sc->sc_1371) {
|
|
|
|
ct5880 = 0;
|
|
|
|
if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_ENSONIQ &&
|
|
|
|
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_ENSONIQ_CT5880)
|
|
|
|
ct5880 = 1;
|
|
|
|
switch (revision) {
|
|
|
|
case EAP_EV1938_A: revstr = "EV1938A "; break;
|
|
|
|
case EAP_CT5880_C: revstr = "CT5880C "; ct5880 = 1; break;
|
|
|
|
case EAP_ES1373_A: revstr = "ES1373A "; break;
|
|
|
|
case EAP_ES1373_B: revstr = "ES1373B "; break;
|
|
|
|
case EAP_CT5880_A: revstr = "CT5880A "; ct5880 = 1; break;
|
|
|
|
case EAP_ES1371_B: revstr = "ES1371B "; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf(": %s %s(rev. 0x%02x)\n", devinfo, revstr, revision);
|
1998-05-02 01:54:33 +04:00
|
|
|
|
|
|
|
/* Map I/O register */
|
|
|
|
if (pci_mapreg_map(pa, PCI_CBIO, PCI_MAPREG_TYPE_IO, 0,
|
1999-11-01 21:12:19 +03:00
|
|
|
&sc->iot, &sc->ioh, NULL, NULL)) {
|
1998-05-02 01:54:33 +04:00
|
|
|
printf("%s: can't map i/o space\n", sc->sc_dev.dv_xname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sc->sc_dmatag = pa->pa_dmat;
|
|
|
|
|
|
|
|
/* Enable the device. */
|
|
|
|
csr = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);
|
|
|
|
pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG,
|
|
|
|
csr | PCI_COMMAND_MASTER_ENABLE);
|
|
|
|
|
|
|
|
/* Map and establish the interrupt. */
|
2000-12-29 01:59:06 +03:00
|
|
|
if (pci_intr_map(pa, &ih)) {
|
1998-05-02 01:54:33 +04:00
|
|
|
printf("%s: couldn't map interrupt\n", sc->sc_dev.dv_xname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
intrstr = pci_intr_string(pc, ih);
|
|
|
|
sc->sc_ih = pci_intr_establish(pc, ih, IPL_AUDIO, eap_intr, sc);
|
|
|
|
if (sc->sc_ih == NULL) {
|
|
|
|
printf("%s: couldn't establish interrupt",
|
1999-11-01 21:12:19 +03:00
|
|
|
sc->sc_dev.dv_xname);
|
1998-05-02 01:54:33 +04:00
|
|
|
if (intrstr != NULL)
|
|
|
|
printf(" at %s", intrstr);
|
|
|
|
printf("\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
printf("%s: interrupting at %s\n", sc->sc_dev.dv_xname, intrstr);
|
|
|
|
|
1999-10-27 17:20:34 +04:00
|
|
|
if (!sc->sc_1371) {
|
|
|
|
/* Enable interrupts and looping mode. */
|
|
|
|
/* enable the parts we need */
|
|
|
|
EWRITE4(sc, EAP_SIC, EAP_P2_INTR_EN | EAP_R1_INTR_EN);
|
|
|
|
EWRITE4(sc, EAP_ICSC, EAP_CDC_EN);
|
|
|
|
|
|
|
|
/* reset codec */
|
|
|
|
/* normal operation */
|
|
|
|
/* select codec clocks */
|
2000-03-19 20:11:50 +03:00
|
|
|
eap1370_write_codec(sc, AK_RESET, AK_PD);
|
|
|
|
eap1370_write_codec(sc, AK_RESET, AK_PD | AK_NRST);
|
|
|
|
eap1370_write_codec(sc, AK_CS, 0x0);
|
1999-10-27 17:20:34 +04:00
|
|
|
|
1999-11-02 08:40:59 +03:00
|
|
|
eap_hw_if = &eap1370_hw_if;
|
1999-10-27 17:20:34 +04:00
|
|
|
|
|
|
|
/* Enable all relevant mixer switches. */
|
|
|
|
ctl.dev = EAP_OUTPUT_SELECT;
|
|
|
|
ctl.type = AUDIO_MIXER_SET;
|
|
|
|
ctl.un.mask = 1 << EAP_VOICE_VOL | 1 << EAP_FM_VOL |
|
|
|
|
1 << EAP_CD_VOL | 1 << EAP_LINE_VOL | 1 << EAP_AUX_VOL |
|
|
|
|
1 << EAP_MIC_VOL;
|
1999-11-02 08:40:59 +03:00
|
|
|
eap_hw_if->set_port(sc, &ctl);
|
1999-10-27 17:20:34 +04:00
|
|
|
|
|
|
|
ctl.type = AUDIO_MIXER_VALUE;
|
|
|
|
ctl.un.value.num_channels = 1;
|
|
|
|
for (ctl.dev = EAP_MASTER_VOL; ctl.dev < EAP_MIC_VOL;
|
|
|
|
ctl.dev++) {
|
|
|
|
ctl.un.value.level[AUDIO_MIXER_LEVEL_MONO] = VOL_0DB;
|
1999-11-02 08:40:59 +03:00
|
|
|
eap_hw_if->set_port(sc, &ctl);
|
1999-10-27 17:20:34 +04:00
|
|
|
}
|
|
|
|
ctl.un.value.level[AUDIO_MIXER_LEVEL_MONO] = 0;
|
1999-11-02 08:40:59 +03:00
|
|
|
eap_hw_if->set_port(sc, &ctl);
|
1999-10-27 17:20:34 +04:00
|
|
|
ctl.dev = EAP_MIC_PREAMP;
|
|
|
|
ctl.type = AUDIO_MIXER_ENUM;
|
|
|
|
ctl.un.ord = 0;
|
1999-11-02 08:40:59 +03:00
|
|
|
eap_hw_if->set_port(sc, &ctl);
|
1999-10-27 17:20:34 +04:00
|
|
|
ctl.dev = EAP_RECORD_SOURCE;
|
|
|
|
ctl.type = AUDIO_MIXER_SET;
|
|
|
|
ctl.un.mask = 1 << EAP_MIC_VOL;
|
1999-11-02 08:40:59 +03:00
|
|
|
eap_hw_if->set_port(sc, &ctl);
|
1999-10-27 17:20:34 +04:00
|
|
|
} else {
|
2000-05-01 01:59:58 +04:00
|
|
|
/* clean slate */
|
|
|
|
|
|
|
|
EWRITE4(sc, EAP_SIC, 0);
|
|
|
|
EWRITE4(sc, EAP_ICSC, 0);
|
|
|
|
EWRITE4(sc, E1371_LEGACY, 0);
|
2000-03-06 06:18:11 +03:00
|
|
|
|
2000-05-01 01:59:58 +04:00
|
|
|
if (ct5880) {
|
|
|
|
EWRITE4(sc, EAP_ICSS, EAP_CT5880_AC97_RESET);
|
|
|
|
/* Let codec wake up */
|
|
|
|
tsleep(sc, PRIBIO, "eapcdc", hz / 20);
|
2000-03-06 06:18:11 +03:00
|
|
|
}
|
|
|
|
|
2000-05-01 01:59:58 +04:00
|
|
|
/* Reset from es1371's perspective */
|
|
|
|
EWRITE4(sc, EAP_ICSC, E1371_SYNC_RES);
|
|
|
|
delay(20);
|
1999-10-27 17:20:34 +04:00
|
|
|
EWRITE4(sc, EAP_ICSC, 0);
|
2000-05-01 01:59:58 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Must properly reprogram sample rate converter,
|
|
|
|
* or it locks up. Set some defaults for the life of the
|
|
|
|
* machine, and set up a sb default sample rate.
|
|
|
|
*/
|
|
|
|
EWRITE4(sc, E1371_SRC, E1371_SRC_DISABLE);
|
|
|
|
for (i = 0; i < 0x80; i++)
|
|
|
|
eap1371_src_write(sc, i, 0);
|
1999-10-27 17:20:34 +04:00
|
|
|
eap1371_src_write(sc, ESRC_DAC1+ESRC_TRUNC_N, ESRC_SET_N(16));
|
|
|
|
eap1371_src_write(sc, ESRC_DAC2+ESRC_TRUNC_N, ESRC_SET_N(16));
|
2000-05-01 01:59:58 +04:00
|
|
|
eap1371_src_write(sc, ESRC_DAC1+ESRC_IREGS, ESRC_SET_VFI(16));
|
|
|
|
eap1371_src_write(sc, ESRC_DAC2+ESRC_IREGS, ESRC_SET_VFI(16));
|
|
|
|
eap1371_src_write(sc, ESRC_ADC_VOLL, ESRC_SET_ADC_VOL(16));
|
|
|
|
eap1371_src_write(sc, ESRC_ADC_VOLR, ESRC_SET_ADC_VOL(16));
|
1999-10-27 17:20:34 +04:00
|
|
|
eap1371_src_write(sc, ESRC_DAC1_VOLL, ESRC_SET_DAC_VOLI(1));
|
|
|
|
eap1371_src_write(sc, ESRC_DAC1_VOLR, ESRC_SET_DAC_VOLI(1));
|
|
|
|
eap1371_src_write(sc, ESRC_DAC2_VOLL, ESRC_SET_DAC_VOLI(1));
|
|
|
|
eap1371_src_write(sc, ESRC_DAC2_VOLR, ESRC_SET_DAC_VOLI(1));
|
2000-05-01 01:59:58 +04:00
|
|
|
eap1371_set_adc_rate(sc, 22050);
|
|
|
|
eap1371_set_dac_rate(sc, 22050, 1);
|
|
|
|
eap1371_set_dac_rate(sc, 22050, 2);
|
|
|
|
|
|
|
|
EWRITE4(sc, E1371_SRC, 0);
|
1999-10-27 17:20:34 +04:00
|
|
|
|
2000-05-01 01:59:58 +04:00
|
|
|
/* Reset codec */
|
1999-10-27 17:20:34 +04:00
|
|
|
|
|
|
|
/* Interrupt enable */
|
|
|
|
sc->host_if.arg = sc;
|
|
|
|
sc->host_if.attach = eap1371_attach_codec;
|
|
|
|
sc->host_if.read = eap1371_read_codec;
|
|
|
|
sc->host_if.write = eap1371_write_codec;
|
|
|
|
sc->host_if.reset = eap1371_reset_codec;
|
|
|
|
|
1999-11-01 21:12:19 +03:00
|
|
|
if (ac97_attach(&sc->host_if) == 0) {
|
1999-10-27 17:20:34 +04:00
|
|
|
/* Interrupt enable */
|
|
|
|
EWRITE4(sc, EAP_SIC, EAP_P2_INTR_EN | EAP_R1_INTR_EN);
|
|
|
|
} else
|
|
|
|
return;
|
|
|
|
|
1999-11-02 08:40:59 +03:00
|
|
|
eap_hw_if = &eap1371_hw_if;
|
1999-10-27 17:20:34 +04:00
|
|
|
|
|
|
|
/* Just enable the DAC and master volumes by default */
|
|
|
|
ctl.type = AUDIO_MIXER_ENUM;
|
|
|
|
ctl.un.ord = 0; /* off */
|
|
|
|
ctl.dev = eap1371_get_portnum_by_name(sc, AudioCoutputs,
|
|
|
|
AudioNmaster, AudioNmute);
|
|
|
|
eap1371_mixer_set_port(sc, &ctl);
|
|
|
|
ctl.dev = eap1371_get_portnum_by_name(sc, AudioCinputs,
|
|
|
|
AudioNdac, AudioNmute);
|
|
|
|
eap1371_mixer_set_port(sc, &ctl);
|
|
|
|
ctl.dev = eap1371_get_portnum_by_name(sc, AudioCrecord,
|
|
|
|
AudioNvolume, AudioNmute);
|
|
|
|
eap1371_mixer_set_port(sc, &ctl);
|
|
|
|
|
|
|
|
ctl.dev = eap1371_get_portnum_by_name(sc, AudioCrecord,
|
|
|
|
AudioNsource, NULL);
|
|
|
|
ctl.type = AUDIO_MIXER_ENUM;
|
|
|
|
ctl.un.ord = 0;
|
|
|
|
eap1371_mixer_set_port(sc, &ctl);
|
|
|
|
|
2000-05-01 01:59:58 +04:00
|
|
|
}
|
1998-05-02 01:54:33 +04:00
|
|
|
|
1999-11-02 08:40:59 +03:00
|
|
|
audio_attach_mi(eap_hw_if, sc, &sc->sc_dev);
|
1999-10-30 03:03:18 +04:00
|
|
|
|
|
|
|
#if NMIDI > 0
|
|
|
|
midi_attach_mi(&eap_midi_hw_if, sc, &sc->sc_dev);
|
|
|
|
#endif
|
1998-05-02 01:54:33 +04:00
|
|
|
}
|
|
|
|
|
1999-10-27 17:20:34 +04:00
|
|
|
int
|
|
|
|
eap1371_attach_codec(sc_, codec_if)
|
|
|
|
void *sc_;
|
|
|
|
struct ac97_codec_if *codec_if;
|
|
|
|
{
|
|
|
|
struct eap_softc *sc = sc_;
|
|
|
|
|
|
|
|
sc->codec_if = codec_if;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
eap1371_reset_codec(sc_)
|
|
|
|
void *sc_;
|
|
|
|
{
|
|
|
|
struct eap_softc *sc = sc_;
|
2000-05-01 01:59:58 +04:00
|
|
|
u_int32_t icsc;
|
|
|
|
int s;
|
2000-03-19 20:11:50 +03:00
|
|
|
|
2000-05-01 01:59:58 +04:00
|
|
|
s = splaudio();
|
|
|
|
icsc = EREAD4(sc, EAP_ICSC);
|
1999-10-27 17:20:34 +04:00
|
|
|
EWRITE4(sc, EAP_ICSC, icsc | E1371_SYNC_RES);
|
2000-03-19 20:11:50 +03:00
|
|
|
delay(20);
|
1999-10-27 17:20:34 +04:00
|
|
|
EWRITE4(sc, EAP_ICSC, icsc & ~E1371_SYNC_RES);
|
1999-11-02 20:48:01 +03:00
|
|
|
delay(1);
|
2000-05-01 01:59:58 +04:00
|
|
|
splx(s);
|
1999-10-27 17:20:34 +04:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1998-05-02 01:54:33 +04:00
|
|
|
int
|
|
|
|
eap_intr(p)
|
|
|
|
void *p;
|
|
|
|
{
|
|
|
|
struct eap_softc *sc = p;
|
|
|
|
u_int32_t intr, sic;
|
|
|
|
|
1998-08-10 00:32:34 +04:00
|
|
|
intr = EREAD4(sc, EAP_ICSS);
|
|
|
|
if (!(intr & EAP_INTR))
|
|
|
|
return (0);
|
1998-05-02 01:54:33 +04:00
|
|
|
sic = EREAD4(sc, EAP_SIC);
|
|
|
|
DPRINTFN(5, ("eap_intr: ICSS=0x%08x, SIC=0x%08x\n", intr, sic));
|
1998-08-10 00:32:34 +04:00
|
|
|
if (intr & EAP_I_ADC) {
|
|
|
|
/*
|
|
|
|
* XXX This is a hack!
|
|
|
|
* The EAP chip sometimes generates the recording interrupt
|
|
|
|
* while it is still transferring the data. To make sure
|
|
|
|
* it has all arrived we busy wait until the count is right.
|
|
|
|
* The transfer we are waiting for is 8 longwords.
|
|
|
|
*/
|
|
|
|
int s, nw, n;
|
|
|
|
EWRITE4(sc, EAP_MEMPAGE, EAP_ADC_PAGE);
|
|
|
|
s = EREAD4(sc, EAP_ADC_CSR);
|
|
|
|
nw = ((s & 0xffff) + 1) >> 2; /* # of words in DMA */
|
|
|
|
n = 0;
|
|
|
|
while (((EREAD4(sc, EAP_ADC_SIZE) >> 16) + 8) % nw == 0) {
|
|
|
|
delay(10);
|
|
|
|
if (++n > 100) {
|
|
|
|
printf("eapintr: dma fix timeout");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Continue with normal interrupt handling. */
|
1998-05-02 01:54:33 +04:00
|
|
|
EWRITE4(sc, EAP_SIC, sic & ~EAP_R1_INTR_EN);
|
|
|
|
EWRITE4(sc, EAP_SIC, sic);
|
1998-08-10 00:32:34 +04:00
|
|
|
if (sc->sc_rintr)
|
|
|
|
sc->sc_rintr(sc->sc_rarg);
|
|
|
|
}
|
|
|
|
if (intr & EAP_I_DAC2) {
|
1998-05-02 01:54:33 +04:00
|
|
|
EWRITE4(sc, EAP_SIC, sic & ~EAP_P2_INTR_EN);
|
|
|
|
EWRITE4(sc, EAP_SIC, sic);
|
1998-08-10 00:32:34 +04:00
|
|
|
if (sc->sc_pintr)
|
|
|
|
sc->sc_pintr(sc->sc_parg);
|
|
|
|
}
|
1999-10-30 03:03:18 +04:00
|
|
|
#if NMIDI > 0
|
2000-04-24 21:55:24 +04:00
|
|
|
if ((intr & EAP_I_UART) && sc->sc_iintr != NULL) {
|
1999-10-30 03:03:18 +04:00
|
|
|
u_int32_t data;
|
|
|
|
|
|
|
|
if (EREAD1(sc, EAP_UART_STATUS) & EAP_US_RXINT) {
|
|
|
|
while (EREAD1(sc, EAP_UART_STATUS) & EAP_US_RXRDY) {
|
|
|
|
data = EREAD1(sc, EAP_UART_DATA);
|
2000-04-24 21:55:24 +04:00
|
|
|
sc->sc_iintr(sc->sc_arg, data);
|
1999-10-30 03:03:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
1998-05-02 01:54:33 +04:00
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
eap_allocmem(sc, size, align, p)
|
|
|
|
struct eap_softc *sc;
|
|
|
|
size_t size;
|
|
|
|
size_t align;
|
1998-08-10 00:32:34 +04:00
|
|
|
struct eap_dma *p;
|
1998-05-02 01:54:33 +04:00
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
|
|
|
p->size = size;
|
|
|
|
error = bus_dmamem_alloc(sc->sc_dmatag, p->size, align, 0,
|
|
|
|
p->segs, sizeof(p->segs)/sizeof(p->segs[0]),
|
|
|
|
&p->nsegs, BUS_DMA_NOWAIT);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
error = bus_dmamem_map(sc->sc_dmatag, p->segs, p->nsegs, p->size,
|
|
|
|
&p->addr, BUS_DMA_NOWAIT|BUS_DMA_COHERENT);
|
|
|
|
if (error)
|
|
|
|
goto free;
|
|
|
|
|
|
|
|
error = bus_dmamap_create(sc->sc_dmatag, p->size, 1, p->size,
|
|
|
|
0, BUS_DMA_NOWAIT, &p->map);
|
|
|
|
if (error)
|
|
|
|
goto unmap;
|
|
|
|
|
|
|
|
error = bus_dmamap_load(sc->sc_dmatag, p->map, p->addr, p->size, NULL,
|
|
|
|
BUS_DMA_NOWAIT);
|
|
|
|
if (error)
|
|
|
|
goto destroy;
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
destroy:
|
|
|
|
bus_dmamap_destroy(sc->sc_dmatag, p->map);
|
|
|
|
unmap:
|
|
|
|
bus_dmamem_unmap(sc->sc_dmatag, p->addr, p->size);
|
|
|
|
free:
|
|
|
|
bus_dmamem_free(sc->sc_dmatag, p->segs, p->nsegs);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
eap_freemem(sc, p)
|
|
|
|
struct eap_softc *sc;
|
1998-08-10 00:32:34 +04:00
|
|
|
struct eap_dma *p;
|
1998-05-02 01:54:33 +04:00
|
|
|
{
|
|
|
|
bus_dmamap_unload(sc->sc_dmatag, p->map);
|
|
|
|
bus_dmamap_destroy(sc->sc_dmatag, p->map);
|
|
|
|
bus_dmamem_unmap(sc->sc_dmatag, p->addr, p->size);
|
|
|
|
bus_dmamem_free(sc->sc_dmatag, p->segs, p->nsegs);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
eap_open(addr, flags)
|
|
|
|
void *addr;
|
|
|
|
int flags;
|
|
|
|
{
|
1998-08-10 00:32:34 +04:00
|
|
|
return (0);
|
1998-05-02 01:54:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Close function is called at splaudio().
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
eap_close(addr)
|
|
|
|
void *addr;
|
|
|
|
{
|
|
|
|
struct eap_softc *sc = addr;
|
|
|
|
|
1998-08-10 00:32:34 +04:00
|
|
|
eap_halt_output(sc);
|
|
|
|
eap_halt_input(sc);
|
1998-05-02 01:54:33 +04:00
|
|
|
|
1998-08-10 00:32:34 +04:00
|
|
|
sc->sc_pintr = 0;
|
|
|
|
sc->sc_rintr = 0;
|
1998-05-02 01:54:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
eap_query_encoding(addr, fp)
|
|
|
|
void *addr;
|
|
|
|
struct audio_encoding *fp;
|
|
|
|
{
|
|
|
|
switch (fp->index) {
|
|
|
|
case 0:
|
|
|
|
strcpy(fp->name, AudioEulinear);
|
|
|
|
fp->encoding = AUDIO_ENCODING_ULINEAR;
|
|
|
|
fp->precision = 8;
|
|
|
|
fp->flags = 0;
|
|
|
|
return (0);
|
|
|
|
case 1:
|
|
|
|
strcpy(fp->name, AudioEmulaw);
|
|
|
|
fp->encoding = AUDIO_ENCODING_ULAW;
|
|
|
|
fp->precision = 8;
|
|
|
|
fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
|
|
|
|
return (0);
|
|
|
|
case 2:
|
|
|
|
strcpy(fp->name, AudioEalaw);
|
|
|
|
fp->encoding = AUDIO_ENCODING_ALAW;
|
|
|
|
fp->precision = 8;
|
|
|
|
fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
|
|
|
|
return (0);
|
|
|
|
case 3:
|
|
|
|
strcpy(fp->name, AudioEslinear);
|
|
|
|
fp->encoding = AUDIO_ENCODING_SLINEAR;
|
|
|
|
fp->precision = 8;
|
|
|
|
fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
|
|
|
|
return (0);
|
1998-08-10 00:32:34 +04:00
|
|
|
case 4:
|
1998-05-02 01:54:33 +04:00
|
|
|
strcpy(fp->name, AudioEslinear_le);
|
|
|
|
fp->encoding = AUDIO_ENCODING_SLINEAR_LE;
|
|
|
|
fp->precision = 16;
|
|
|
|
fp->flags = 0;
|
|
|
|
return (0);
|
|
|
|
case 5:
|
|
|
|
strcpy(fp->name, AudioEulinear_le);
|
|
|
|
fp->encoding = AUDIO_ENCODING_ULINEAR_LE;
|
|
|
|
fp->precision = 16;
|
|
|
|
fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
|
|
|
|
return (0);
|
|
|
|
case 6:
|
|
|
|
strcpy(fp->name, AudioEslinear_be);
|
|
|
|
fp->encoding = AUDIO_ENCODING_SLINEAR_BE;
|
|
|
|
fp->precision = 16;
|
|
|
|
fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
|
|
|
|
return (0);
|
|
|
|
case 7:
|
|
|
|
strcpy(fp->name, AudioEulinear_be);
|
|
|
|
fp->encoding = AUDIO_ENCODING_ULINEAR_BE;
|
|
|
|
fp->precision = 16;
|
|
|
|
fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
|
|
|
|
return (0);
|
|
|
|
default:
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-08-10 00:32:34 +04:00
|
|
|
eap_set_params(addr, setmode, usemode, play, rec)
|
1998-05-02 01:54:33 +04:00
|
|
|
void *addr;
|
|
|
|
int setmode, usemode;
|
1998-08-10 00:32:34 +04:00
|
|
|
struct audio_params *play, *rec;
|
1998-05-02 01:54:33 +04:00
|
|
|
{
|
|
|
|
struct eap_softc *sc = addr;
|
1998-08-10 00:32:34 +04:00
|
|
|
struct audio_params *p;
|
1999-02-18 02:55:18 +03:00
|
|
|
int mode;
|
|
|
|
u_int32_t div;
|
1998-08-10 00:32:34 +04:00
|
|
|
|
|
|
|
/*
|
1999-10-27 17:20:34 +04:00
|
|
|
* The es1370 only has one clock, so make the sample rates match.
|
1998-08-10 00:32:34 +04:00
|
|
|
*/
|
1999-10-27 17:20:34 +04:00
|
|
|
if (!sc->sc_1371) {
|
|
|
|
if (play->sample_rate != rec->sample_rate &&
|
|
|
|
usemode == (AUMODE_PLAY | AUMODE_RECORD)) {
|
|
|
|
if (setmode == AUMODE_PLAY) {
|
|
|
|
rec->sample_rate = play->sample_rate;
|
|
|
|
setmode |= AUMODE_RECORD;
|
1998-08-10 05:27:34 +04:00
|
|
|
} else if (setmode == AUMODE_RECORD) {
|
1999-10-27 17:20:34 +04:00
|
|
|
play->sample_rate = rec->sample_rate;
|
|
|
|
setmode |= AUMODE_PLAY;
|
1998-08-10 05:27:34 +04:00
|
|
|
} else
|
1999-10-27 17:20:34 +04:00
|
|
|
return (EINVAL);
|
|
|
|
}
|
1998-08-10 00:32:34 +04:00
|
|
|
}
|
1998-05-02 01:54:33 +04:00
|
|
|
|
1998-08-10 00:32:34 +04:00
|
|
|
for (mode = AUMODE_RECORD; mode != -1;
|
|
|
|
mode = mode == AUMODE_RECORD ? AUMODE_PLAY : -1) {
|
|
|
|
if ((setmode & mode) == 0)
|
|
|
|
continue;
|
1998-05-02 01:54:33 +04:00
|
|
|
|
1998-08-10 00:32:34 +04:00
|
|
|
p = mode == AUMODE_PLAY ? play : rec;
|
1998-05-02 01:54:33 +04:00
|
|
|
|
1999-10-27 17:20:34 +04:00
|
|
|
if (p->sample_rate < 4000 || p->sample_rate > 48000 ||
|
1998-08-10 00:32:34 +04:00
|
|
|
(p->precision != 8 && p->precision != 16) ||
|
|
|
|
(p->channels != 1 && p->channels != 2))
|
|
|
|
return (EINVAL);
|
|
|
|
|
|
|
|
p->factor = 1;
|
|
|
|
p->sw_code = 0;
|
|
|
|
switch (p->encoding) {
|
|
|
|
case AUDIO_ENCODING_SLINEAR_BE:
|
|
|
|
if (p->precision == 16)
|
|
|
|
p->sw_code = swap_bytes;
|
|
|
|
else
|
|
|
|
p->sw_code = change_sign8;
|
|
|
|
break;
|
|
|
|
case AUDIO_ENCODING_SLINEAR_LE:
|
|
|
|
if (p->precision != 16)
|
|
|
|
p->sw_code = change_sign8;
|
|
|
|
break;
|
|
|
|
case AUDIO_ENCODING_ULINEAR_BE:
|
1998-08-25 08:56:01 +04:00
|
|
|
if (p->precision == 16) {
|
1998-08-10 00:32:34 +04:00
|
|
|
if (mode == AUMODE_PLAY)
|
1999-11-01 21:12:19 +03:00
|
|
|
p->sw_code = swap_bytes_change_sign16_le;
|
1998-08-10 00:32:34 +04:00
|
|
|
else
|
1999-11-01 21:12:19 +03:00
|
|
|
p->sw_code = change_sign16_swap_bytes_le;
|
1998-08-25 08:56:01 +04:00
|
|
|
}
|
1998-08-10 00:32:34 +04:00
|
|
|
break;
|
|
|
|
case AUDIO_ENCODING_ULINEAR_LE:
|
|
|
|
if (p->precision == 16)
|
1999-11-01 21:12:19 +03:00
|
|
|
p->sw_code = change_sign16_le;
|
1998-08-10 00:32:34 +04:00
|
|
|
break;
|
|
|
|
case AUDIO_ENCODING_ULAW:
|
|
|
|
if (mode == AUMODE_PLAY) {
|
|
|
|
p->factor = 2;
|
1999-11-01 21:12:19 +03:00
|
|
|
p->sw_code = mulaw_to_slinear16_le;
|
1998-08-10 00:32:34 +04:00
|
|
|
} else
|
|
|
|
p->sw_code = ulinear8_to_mulaw;
|
|
|
|
break;
|
|
|
|
case AUDIO_ENCODING_ALAW:
|
|
|
|
if (mode == AUMODE_PLAY) {
|
|
|
|
p->factor = 2;
|
1999-11-01 21:12:19 +03:00
|
|
|
p->sw_code = alaw_to_slinear16_le;
|
1998-08-10 00:32:34 +04:00
|
|
|
} else
|
|
|
|
p->sw_code = ulinear8_to_alaw;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-05-01 01:59:58 +04:00
|
|
|
if (sc->sc_1371) {
|
1999-10-27 17:20:34 +04:00
|
|
|
eap1371_set_dac_rate(sc, play->sample_rate, 1);
|
|
|
|
eap1371_set_dac_rate(sc, play->sample_rate, 2);
|
|
|
|
eap1371_set_adc_rate(sc, rec->sample_rate);
|
|
|
|
} else {
|
2000-05-01 01:59:58 +04:00
|
|
|
/* Set the speed */
|
|
|
|
DPRINTFN(2, ("eap_set_params: old ICSC = 0x%08x\n",
|
|
|
|
EREAD4(sc, EAP_ICSC)));
|
|
|
|
div = EREAD4(sc, EAP_ICSC) & ~EAP_PCLKBITS;
|
|
|
|
/*
|
|
|
|
* XXX
|
|
|
|
* The -2 isn't documented, but seemed to make the wall
|
|
|
|
* time match
|
|
|
|
* what I expect. - mycroft
|
|
|
|
*/
|
|
|
|
if (usemode == AUMODE_RECORD)
|
|
|
|
div |= EAP_SET_PCLKDIV(EAP_XTAL_FREQ /
|
|
|
|
rec->sample_rate - 2);
|
|
|
|
else
|
|
|
|
div |= EAP_SET_PCLKDIV(EAP_XTAL_FREQ /
|
|
|
|
play->sample_rate - 2);
|
|
|
|
div |= EAP_CCB_INTRM;
|
|
|
|
EWRITE4(sc, EAP_ICSC, div);
|
|
|
|
DPRINTFN(2, ("eap_set_params: set ICSC = 0x%08x\n", div));
|
|
|
|
}
|
1998-05-02 01:54:33 +04:00
|
|
|
|
1998-08-10 00:32:34 +04:00
|
|
|
return (0);
|
1998-05-02 01:54:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
eap_round_blocksize(addr, blk)
|
|
|
|
void *addr;
|
|
|
|
int blk;
|
|
|
|
{
|
1998-05-26 17:28:03 +04:00
|
|
|
return (blk & -32); /* keep good alignment */
|
1998-05-02 01:54:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-08-10 00:32:34 +04:00
|
|
|
eap_trigger_output(addr, start, end, blksize, intr, arg, param)
|
1998-05-02 01:54:33 +04:00
|
|
|
void *addr;
|
1998-08-10 00:32:34 +04:00
|
|
|
void *start, *end;
|
|
|
|
int blksize;
|
|
|
|
void (*intr) __P((void *));
|
|
|
|
void *arg;
|
|
|
|
struct audio_params *param;
|
1998-05-02 01:54:33 +04:00
|
|
|
{
|
|
|
|
struct eap_softc *sc = addr;
|
|
|
|
struct eap_dma *p;
|
1999-02-18 08:46:38 +03:00
|
|
|
u_int32_t icsc, sic;
|
1998-08-10 00:32:34 +04:00
|
|
|
int sampshift;
|
1998-05-02 01:54:33 +04:00
|
|
|
|
1998-08-10 00:32:34 +04:00
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (sc->sc_prun)
|
|
|
|
panic("eap_trigger_output: already running");
|
1998-08-10 02:11:48 +04:00
|
|
|
sc->sc_prun = 1;
|
1998-08-10 00:32:34 +04:00
|
|
|
#endif
|
1998-05-02 01:54:33 +04:00
|
|
|
|
1999-10-27 17:20:34 +04:00
|
|
|
DPRINTFN(1, ("eap_trigger_output: sc=%p start=%p end=%p "
|
2000-05-01 01:59:58 +04:00
|
|
|
"blksize=%d intr=%p(%p)\n", addr, start, end, blksize, intr, arg));
|
1998-08-10 00:32:34 +04:00
|
|
|
sc->sc_pintr = intr;
|
|
|
|
sc->sc_parg = arg;
|
1998-05-02 01:54:33 +04:00
|
|
|
|
1999-02-18 08:46:38 +03:00
|
|
|
icsc = EREAD4(sc, EAP_ICSC);
|
|
|
|
EWRITE4(sc, EAP_ICSC, icsc & ~EAP_DAC2_EN);
|
|
|
|
|
|
|
|
sic = EREAD4(sc, EAP_SIC);
|
|
|
|
sic &= ~(EAP_P2_S_EB | EAP_P2_S_MB | EAP_INC_BITS);
|
|
|
|
sic |= EAP_SET_P2_ST_INC(0) | EAP_SET_P2_END_INC(param->precision * param->factor / 8);
|
1998-08-10 00:32:34 +04:00
|
|
|
sampshift = 0;
|
|
|
|
if (param->precision * param->factor == 16) {
|
1999-02-18 08:46:38 +03:00
|
|
|
sic |= EAP_P2_S_EB;
|
1998-08-10 00:32:34 +04:00
|
|
|
sampshift++;
|
|
|
|
}
|
|
|
|
if (param->channels == 2) {
|
1999-02-18 08:46:38 +03:00
|
|
|
sic |= EAP_P2_S_MB;
|
1998-08-10 00:32:34 +04:00
|
|
|
sampshift++;
|
|
|
|
}
|
1999-02-18 08:46:38 +03:00
|
|
|
EWRITE4(sc, EAP_SIC, sic);
|
1998-08-10 00:32:34 +04:00
|
|
|
|
|
|
|
for (p = sc->sc_dmas; p && KERNADDR(p) != start; p = p->next)
|
1998-05-02 01:54:33 +04:00
|
|
|
;
|
|
|
|
if (!p) {
|
1998-08-10 00:32:34 +04:00
|
|
|
printf("eap_trigger_output: bad addr %p\n", start);
|
1998-05-02 01:54:33 +04:00
|
|
|
return (EINVAL);
|
|
|
|
}
|
1998-08-10 00:32:34 +04:00
|
|
|
|
|
|
|
DPRINTF(("eap_trigger_output: DAC2_ADDR=0x%x, DAC2_SIZE=0x%x\n",
|
1999-01-08 22:22:34 +03:00
|
|
|
(int)DMAADDR(p),
|
|
|
|
EAP_SET_SIZE(0, (((char *)end - (char *)start) >> 2) - 1)));
|
1998-05-02 01:54:33 +04:00
|
|
|
EWRITE4(sc, EAP_MEMPAGE, EAP_DAC_PAGE);
|
|
|
|
EWRITE4(sc, EAP_DAC2_ADDR, DMAADDR(p));
|
1999-01-08 22:22:34 +03:00
|
|
|
EWRITE4(sc, EAP_DAC2_SIZE,
|
|
|
|
EAP_SET_SIZE(0, (((char *)end - (char *)start) >> 2) - 1));
|
1998-05-02 01:54:33 +04:00
|
|
|
|
1998-08-10 00:32:34 +04:00
|
|
|
EWRITE2(sc, EAP_DAC2_CSR, (blksize >> sampshift) - 1);
|
1999-02-18 08:46:38 +03:00
|
|
|
|
|
|
|
EWRITE4(sc, EAP_ICSC, icsc | EAP_DAC2_EN);
|
|
|
|
|
|
|
|
DPRINTFN(1, ("eap_trigger_output: set ICSC = 0x%08x\n", icsc));
|
1998-05-02 01:54:33 +04:00
|
|
|
|
1998-08-10 00:32:34 +04:00
|
|
|
return (0);
|
1998-05-02 01:54:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-08-10 00:32:34 +04:00
|
|
|
eap_trigger_input(addr, start, end, blksize, intr, arg, param)
|
1998-05-02 01:54:33 +04:00
|
|
|
void *addr;
|
1998-08-10 00:32:34 +04:00
|
|
|
void *start, *end;
|
|
|
|
int blksize;
|
1998-05-02 01:54:33 +04:00
|
|
|
void (*intr) __P((void *));
|
|
|
|
void *arg;
|
1998-08-10 00:32:34 +04:00
|
|
|
struct audio_params *param;
|
1998-05-02 01:54:33 +04:00
|
|
|
{
|
|
|
|
struct eap_softc *sc = addr;
|
1998-08-10 00:32:34 +04:00
|
|
|
struct eap_dma *p;
|
1999-02-18 08:46:38 +03:00
|
|
|
u_int32_t icsc, sic;
|
1998-08-10 00:32:34 +04:00
|
|
|
int sampshift;
|
1998-05-02 01:54:33 +04:00
|
|
|
|
1998-08-10 00:32:34 +04:00
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (sc->sc_rrun)
|
|
|
|
panic("eap_trigger_input: already running");
|
1998-08-10 02:11:48 +04:00
|
|
|
sc->sc_rrun = 1;
|
1998-08-10 00:32:34 +04:00
|
|
|
#endif
|
|
|
|
|
1998-08-10 02:11:48 +04:00
|
|
|
DPRINTFN(1, ("eap_trigger_input: sc=%p start=%p end=%p blksize=%d intr=%p(%p)\n",
|
|
|
|
addr, start, end, blksize, intr, arg));
|
1998-05-02 01:54:33 +04:00
|
|
|
sc->sc_rintr = intr;
|
|
|
|
sc->sc_rarg = arg;
|
1998-08-10 00:32:34 +04:00
|
|
|
|
1999-02-18 08:46:38 +03:00
|
|
|
icsc = EREAD4(sc, EAP_ICSC);
|
|
|
|
EWRITE4(sc, EAP_ICSC, icsc & ~EAP_ADC_EN);
|
|
|
|
|
|
|
|
sic = EREAD4(sc, EAP_SIC);
|
|
|
|
sic &= ~(EAP_R1_S_EB | EAP_R1_S_MB);
|
1998-08-10 00:32:34 +04:00
|
|
|
sampshift = 0;
|
|
|
|
if (param->precision * param->factor == 16) {
|
1999-02-18 08:46:38 +03:00
|
|
|
sic |= EAP_R1_S_EB;
|
1998-08-10 00:32:34 +04:00
|
|
|
sampshift++;
|
|
|
|
}
|
|
|
|
if (param->channels == 2) {
|
1999-02-18 08:46:38 +03:00
|
|
|
sic |= EAP_R1_S_MB;
|
1998-08-10 00:32:34 +04:00
|
|
|
sampshift++;
|
|
|
|
}
|
1999-02-18 08:46:38 +03:00
|
|
|
EWRITE4(sc, EAP_SIC, sic);
|
1998-08-10 00:32:34 +04:00
|
|
|
|
|
|
|
for (p = sc->sc_dmas; p && KERNADDR(p) != start; p = p->next)
|
|
|
|
;
|
|
|
|
if (!p) {
|
|
|
|
printf("eap_trigger_input: bad addr %p\n", start);
|
|
|
|
return (EINVAL);
|
1998-05-02 01:54:33 +04:00
|
|
|
}
|
1998-08-10 00:32:34 +04:00
|
|
|
|
|
|
|
DPRINTF(("eap_trigger_input: ADC_ADDR=0x%x, ADC_SIZE=0x%x\n",
|
1999-01-08 22:22:34 +03:00
|
|
|
(int)DMAADDR(p),
|
|
|
|
EAP_SET_SIZE(0, (((char *)end - (char *)start) >> 2) - 1)));
|
1998-08-10 00:32:34 +04:00
|
|
|
EWRITE4(sc, EAP_MEMPAGE, EAP_ADC_PAGE);
|
|
|
|
EWRITE4(sc, EAP_ADC_ADDR, DMAADDR(p));
|
1999-01-08 22:22:34 +03:00
|
|
|
EWRITE4(sc, EAP_ADC_SIZE,
|
|
|
|
EAP_SET_SIZE(0, (((char *)end - (char *)start) >> 2) - 1));
|
1998-08-10 00:32:34 +04:00
|
|
|
|
|
|
|
EWRITE2(sc, EAP_ADC_CSR, (blksize >> sampshift) - 1);
|
1999-02-18 08:46:38 +03:00
|
|
|
|
|
|
|
EWRITE4(sc, EAP_ICSC, icsc | EAP_ADC_EN);
|
|
|
|
|
|
|
|
DPRINTFN(1, ("eap_trigger_input: set ICSC = 0x%08x\n", icsc));
|
1998-08-10 00:32:34 +04:00
|
|
|
|
|
|
|
return (0);
|
1998-05-02 01:54:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-08-10 00:32:34 +04:00
|
|
|
eap_halt_output(addr)
|
1998-05-02 01:54:33 +04:00
|
|
|
void *addr;
|
|
|
|
{
|
|
|
|
struct eap_softc *sc = addr;
|
1999-02-18 08:46:38 +03:00
|
|
|
u_int32_t icsc;
|
1998-05-02 01:54:33 +04:00
|
|
|
|
1998-08-10 00:32:34 +04:00
|
|
|
DPRINTF(("eap: eap_halt_output\n"));
|
1999-02-18 08:46:38 +03:00
|
|
|
icsc = EREAD4(sc, EAP_ICSC);
|
|
|
|
EWRITE4(sc, EAP_ICSC, icsc & ~EAP_DAC2_EN);
|
1998-08-10 00:32:34 +04:00
|
|
|
#ifdef DIAGNOSTIC
|
1998-05-02 01:54:33 +04:00
|
|
|
sc->sc_prun = 0;
|
1998-08-10 00:32:34 +04:00
|
|
|
#endif
|
|
|
|
return (0);
|
1998-05-02 01:54:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-08-10 00:32:34 +04:00
|
|
|
eap_halt_input(addr)
|
1998-05-02 01:54:33 +04:00
|
|
|
void *addr;
|
|
|
|
{
|
|
|
|
struct eap_softc *sc = addr;
|
1999-02-18 08:46:38 +03:00
|
|
|
u_int32_t icsc;
|
1998-05-02 01:54:33 +04:00
|
|
|
|
1998-08-10 00:32:34 +04:00
|
|
|
DPRINTF(("eap: eap_halt_input\n"));
|
1999-02-18 08:46:38 +03:00
|
|
|
icsc = EREAD4(sc, EAP_ICSC);
|
|
|
|
EWRITE4(sc, EAP_ICSC, icsc & ~EAP_ADC_EN);
|
1998-08-10 00:32:34 +04:00
|
|
|
#ifdef DIAGNOSTIC
|
1998-05-02 01:54:33 +04:00
|
|
|
sc->sc_rrun = 0;
|
1998-08-10 00:32:34 +04:00
|
|
|
#endif
|
|
|
|
return (0);
|
1998-05-02 01:54:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
eap_getdev(addr, retp)
|
|
|
|
void *addr;
|
1998-08-10 00:32:34 +04:00
|
|
|
struct audio_device *retp;
|
1998-05-02 01:54:33 +04:00
|
|
|
{
|
|
|
|
*retp = eap_device;
|
1998-08-10 00:32:34 +04:00
|
|
|
return (0);
|
1998-05-02 01:54:33 +04:00
|
|
|
}
|
|
|
|
|
1999-10-27 17:20:34 +04:00
|
|
|
int
|
|
|
|
eap1371_mixer_set_port(addr, cp)
|
|
|
|
void *addr;
|
|
|
|
mixer_ctrl_t *cp;
|
|
|
|
{
|
|
|
|
struct eap_softc *sc = addr;
|
|
|
|
|
|
|
|
return (sc->codec_if->vtbl->mixer_set_port(sc->codec_if, cp));
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
eap1371_mixer_get_port(addr, cp)
|
|
|
|
void *addr;
|
|
|
|
mixer_ctrl_t *cp;
|
|
|
|
{
|
|
|
|
struct eap_softc *sc = addr;
|
|
|
|
|
|
|
|
return (sc->codec_if->vtbl->mixer_get_port(sc->codec_if, cp));
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
eap1371_query_devinfo(addr, dip)
|
|
|
|
void *addr;
|
|
|
|
mixer_devinfo_t *dip;
|
|
|
|
{
|
|
|
|
struct eap_softc *sc = addr;
|
|
|
|
|
|
|
|
return (sc->codec_if->vtbl->query_devinfo(sc->codec_if, dip));
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
eap1371_get_portnum_by_name(sc, class, device, qualifier)
|
|
|
|
struct eap_softc *sc;
|
|
|
|
char *class, *device, *qualifier;
|
|
|
|
{
|
|
|
|
return (sc->codec_if->vtbl->get_portnum_by_name(sc->codec_if, class,
|
2000-05-01 01:59:58 +04:00
|
|
|
device, qualifier));
|
1999-10-27 17:20:34 +04:00
|
|
|
}
|
|
|
|
|
1998-05-02 01:54:33 +04:00
|
|
|
void
|
2000-03-19 20:11:50 +03:00
|
|
|
eap1370_set_mixer(sc, a, d)
|
1998-05-02 01:54:33 +04:00
|
|
|
struct eap_softc *sc;
|
1998-08-10 00:32:34 +04:00
|
|
|
int a, d;
|
1998-05-02 01:54:33 +04:00
|
|
|
{
|
2000-03-19 20:11:50 +03:00
|
|
|
eap1370_write_codec(sc, a, d);
|
1998-05-02 01:54:33 +04:00
|
|
|
|
2000-05-01 01:59:58 +04:00
|
|
|
sc->sc_port[a] = d;
|
|
|
|
DPRINTFN(1, ("eap1370_mixer_set_port port 0x%02x = 0x%02x\n", a, d));
|
1999-10-27 17:20:34 +04:00
|
|
|
}
|
1998-05-02 01:54:33 +04:00
|
|
|
|
|
|
|
int
|
2000-03-19 20:11:50 +03:00
|
|
|
eap1370_mixer_set_port(addr, cp)
|
1998-05-02 01:54:33 +04:00
|
|
|
void *addr;
|
|
|
|
mixer_ctrl_t *cp;
|
|
|
|
{
|
|
|
|
struct eap_softc *sc = addr;
|
|
|
|
int lval, rval, l, r, la, ra;
|
1998-07-06 15:12:21 +04:00
|
|
|
int l1, r1, l2, r2, m, o1, o2;
|
1998-05-02 01:54:33 +04:00
|
|
|
|
|
|
|
if (cp->dev == EAP_RECORD_SOURCE) {
|
|
|
|
if (cp->type != AUDIO_MIXER_SET)
|
|
|
|
return (EINVAL);
|
|
|
|
m = sc->sc_record_source = cp->un.mask;
|
|
|
|
l1 = l2 = r1 = r2 = 0;
|
|
|
|
if (m & (1 << EAP_VOICE_VOL))
|
1998-07-06 15:12:21 +04:00
|
|
|
l2 |= AK_M_VOICE, r2 |= AK_M_VOICE;
|
1998-05-02 01:54:33 +04:00
|
|
|
if (m & (1 << EAP_FM_VOL))
|
|
|
|
l1 |= AK_M_FM_L, r1 |= AK_M_FM_R;
|
|
|
|
if (m & (1 << EAP_CD_VOL))
|
|
|
|
l1 |= AK_M_CD_L, r1 |= AK_M_CD_R;
|
|
|
|
if (m & (1 << EAP_LINE_VOL))
|
|
|
|
l1 |= AK_M_LINE_L, r1 |= AK_M_LINE_R;
|
|
|
|
if (m & (1 << EAP_AUX_VOL))
|
1998-07-06 15:12:21 +04:00
|
|
|
l2 |= AK_M2_AUX_L, r2 |= AK_M2_AUX_R;
|
1998-05-02 01:54:33 +04:00
|
|
|
if (m & (1 << EAP_MIC_VOL))
|
|
|
|
l2 |= AK_M_TMIC, r2 |= AK_M_TMIC;
|
2000-03-19 20:11:50 +03:00
|
|
|
eap1370_set_mixer(sc, AK_IN_MIXER1_L, l1);
|
|
|
|
eap1370_set_mixer(sc, AK_IN_MIXER1_R, r1);
|
|
|
|
eap1370_set_mixer(sc, AK_IN_MIXER2_L, l2);
|
|
|
|
eap1370_set_mixer(sc, AK_IN_MIXER2_R, r2);
|
1998-05-02 01:54:33 +04:00
|
|
|
return (0);
|
|
|
|
}
|
1998-07-06 15:12:21 +04:00
|
|
|
if (cp->dev == EAP_OUTPUT_SELECT) {
|
|
|
|
if (cp->type != AUDIO_MIXER_SET)
|
|
|
|
return (EINVAL);
|
|
|
|
m = sc->sc_output_source = cp->un.mask;
|
|
|
|
o1 = o2 = 0;
|
|
|
|
if (m & (1 << EAP_VOICE_VOL))
|
|
|
|
o2 |= AK_M_VOICE_L | AK_M_VOICE_R;
|
|
|
|
if (m & (1 << EAP_FM_VOL))
|
|
|
|
o1 |= AK_M_FM_L | AK_M_FM_R;
|
|
|
|
if (m & (1 << EAP_CD_VOL))
|
|
|
|
o1 |= AK_M_CD_L | AK_M_CD_R;
|
|
|
|
if (m & (1 << EAP_LINE_VOL))
|
|
|
|
o1 |= AK_M_LINE_L | AK_M_LINE_R;
|
|
|
|
if (m & (1 << EAP_AUX_VOL))
|
|
|
|
o2 |= AK_M_AUX_L | AK_M_AUX_R;
|
|
|
|
if (m & (1 << EAP_MIC_VOL))
|
|
|
|
o1 |= AK_M_MIC;
|
2000-03-19 20:11:50 +03:00
|
|
|
eap1370_set_mixer(sc, AK_OUT_MIXER1, o1);
|
|
|
|
eap1370_set_mixer(sc, AK_OUT_MIXER2, o2);
|
1998-07-06 15:12:21 +04:00
|
|
|
return (0);
|
|
|
|
}
|
1998-08-12 22:47:43 +04:00
|
|
|
if (cp->dev == EAP_MIC_PREAMP) {
|
|
|
|
if (cp->type != AUDIO_MIXER_ENUM)
|
|
|
|
return (EINVAL);
|
|
|
|
if (cp->un.ord != 0 && cp->un.ord != 1)
|
|
|
|
return (EINVAL);
|
|
|
|
sc->sc_mic_preamp = cp->un.ord;
|
2000-03-19 20:11:50 +03:00
|
|
|
eap1370_set_mixer(sc, AK_MGAIN, cp->un.ord);
|
1998-08-12 22:47:43 +04:00
|
|
|
return (0);
|
|
|
|
}
|
1998-05-02 01:54:33 +04:00
|
|
|
if (cp->type != AUDIO_MIXER_VALUE)
|
|
|
|
return (EINVAL);
|
|
|
|
if (cp->un.value.num_channels == 1)
|
|
|
|
lval = rval = cp->un.value.level[AUDIO_MIXER_LEVEL_MONO];
|
|
|
|
else if (cp->un.value.num_channels == 2) {
|
|
|
|
lval = cp->un.value.level[AUDIO_MIXER_LEVEL_LEFT];
|
|
|
|
rval = cp->un.value.level[AUDIO_MIXER_LEVEL_RIGHT];
|
|
|
|
} else
|
|
|
|
return (EINVAL);
|
|
|
|
ra = -1;
|
|
|
|
switch (cp->dev) {
|
|
|
|
case EAP_MASTER_VOL:
|
|
|
|
l = VOL_TO_ATT5(lval);
|
|
|
|
r = VOL_TO_ATT5(rval);
|
|
|
|
la = AK_MASTER_L;
|
|
|
|
ra = AK_MASTER_R;
|
|
|
|
break;
|
|
|
|
case EAP_MIC_VOL:
|
|
|
|
if (cp->un.value.num_channels != 1)
|
|
|
|
return (EINVAL);
|
|
|
|
la = AK_MIC;
|
|
|
|
goto lr;
|
|
|
|
case EAP_VOICE_VOL:
|
|
|
|
la = AK_VOICE_L;
|
|
|
|
ra = AK_VOICE_R;
|
|
|
|
goto lr;
|
|
|
|
case EAP_FM_VOL:
|
|
|
|
la = AK_FM_L;
|
|
|
|
ra = AK_FM_R;
|
|
|
|
goto lr;
|
|
|
|
case EAP_CD_VOL:
|
|
|
|
la = AK_CD_L;
|
|
|
|
ra = AK_CD_R;
|
|
|
|
goto lr;
|
|
|
|
case EAP_LINE_VOL:
|
|
|
|
la = AK_LINE_L;
|
|
|
|
ra = AK_LINE_R;
|
|
|
|
goto lr;
|
|
|
|
case EAP_AUX_VOL:
|
|
|
|
la = AK_AUX_L;
|
|
|
|
ra = AK_AUX_R;
|
|
|
|
lr:
|
|
|
|
l = VOL_TO_GAIN5(lval);
|
|
|
|
r = VOL_TO_GAIN5(rval);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
2000-03-19 20:11:50 +03:00
|
|
|
eap1370_set_mixer(sc, la, l);
|
1998-05-02 01:54:33 +04:00
|
|
|
if (ra >= 0) {
|
2000-03-19 20:11:50 +03:00
|
|
|
eap1370_set_mixer(sc, ra, r);
|
1998-05-02 01:54:33 +04:00
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2000-03-19 20:11:50 +03:00
|
|
|
eap1370_mixer_get_port(addr, cp)
|
1998-05-02 01:54:33 +04:00
|
|
|
void *addr;
|
|
|
|
mixer_ctrl_t *cp;
|
|
|
|
{
|
|
|
|
struct eap_softc *sc = addr;
|
|
|
|
int la, ra, l, r;
|
|
|
|
|
|
|
|
switch (cp->dev) {
|
|
|
|
case EAP_RECORD_SOURCE:
|
1998-08-12 22:55:03 +04:00
|
|
|
if (cp->type != AUDIO_MIXER_SET)
|
1998-08-12 22:47:43 +04:00
|
|
|
return (EINVAL);
|
1998-05-02 01:54:33 +04:00
|
|
|
cp->un.mask = sc->sc_record_source;
|
|
|
|
return (0);
|
1998-07-06 15:12:21 +04:00
|
|
|
case EAP_OUTPUT_SELECT:
|
1998-08-12 22:55:03 +04:00
|
|
|
if (cp->type != AUDIO_MIXER_SET)
|
1998-08-12 22:47:43 +04:00
|
|
|
return (EINVAL);
|
1998-08-10 00:32:34 +04:00
|
|
|
cp->un.mask = sc->sc_output_source;
|
|
|
|
return (0);
|
1998-08-12 22:47:43 +04:00
|
|
|
case EAP_MIC_PREAMP:
|
1998-08-12 22:55:03 +04:00
|
|
|
if (cp->type != AUDIO_MIXER_ENUM)
|
1998-08-12 22:47:43 +04:00
|
|
|
return (EINVAL);
|
|
|
|
cp->un.ord = sc->sc_mic_preamp;
|
|
|
|
return (0);
|
1998-05-02 01:54:33 +04:00
|
|
|
case EAP_MASTER_VOL:
|
1998-05-02 06:34:53 +04:00
|
|
|
l = ATT5_TO_VOL(sc->sc_port[AK_MASTER_L]);
|
|
|
|
r = ATT5_TO_VOL(sc->sc_port[AK_MASTER_R]);
|
1998-05-02 01:54:33 +04:00
|
|
|
break;
|
|
|
|
case EAP_MIC_VOL:
|
|
|
|
if (cp->un.value.num_channels != 1)
|
|
|
|
return (EINVAL);
|
|
|
|
la = ra = AK_MIC;
|
|
|
|
goto lr;
|
|
|
|
case EAP_VOICE_VOL:
|
|
|
|
la = AK_VOICE_L;
|
|
|
|
ra = AK_VOICE_R;
|
|
|
|
goto lr;
|
|
|
|
case EAP_FM_VOL:
|
|
|
|
la = AK_FM_L;
|
|
|
|
ra = AK_FM_R;
|
|
|
|
goto lr;
|
|
|
|
case EAP_CD_VOL:
|
|
|
|
la = AK_CD_L;
|
|
|
|
ra = AK_CD_R;
|
|
|
|
goto lr;
|
|
|
|
case EAP_LINE_VOL:
|
|
|
|
la = AK_LINE_L;
|
|
|
|
ra = AK_LINE_R;
|
|
|
|
goto lr;
|
|
|
|
case EAP_AUX_VOL:
|
|
|
|
la = AK_AUX_L;
|
|
|
|
ra = AK_AUX_R;
|
|
|
|
lr:
|
|
|
|
l = GAIN5_TO_VOL(sc->sc_port[la]);
|
|
|
|
r = GAIN5_TO_VOL(sc->sc_port[ra]);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
if (cp->un.value.num_channels == 1)
|
|
|
|
cp->un.value.level[AUDIO_MIXER_LEVEL_MONO] = (l+r) / 2;
|
|
|
|
else if (cp->un.value.num_channels == 2) {
|
|
|
|
cp->un.value.level[AUDIO_MIXER_LEVEL_LEFT] = l;
|
|
|
|
cp->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = r;
|
1998-08-12 22:47:43 +04:00
|
|
|
} else
|
|
|
|
return (EINVAL);
|
1998-05-02 01:54:33 +04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2000-03-19 20:11:50 +03:00
|
|
|
eap1370_query_devinfo(addr, dip)
|
1998-05-02 01:54:33 +04:00
|
|
|
void *addr;
|
|
|
|
mixer_devinfo_t *dip;
|
|
|
|
{
|
|
|
|
switch (dip->index) {
|
|
|
|
case EAP_MASTER_VOL:
|
|
|
|
dip->type = AUDIO_MIXER_VALUE;
|
|
|
|
dip->mixer_class = EAP_OUTPUT_CLASS;
|
|
|
|
dip->prev = dip->next = AUDIO_MIXER_LAST;
|
|
|
|
strcpy(dip->label.name, AudioNmaster);
|
|
|
|
dip->un.v.num_channels = 2;
|
|
|
|
strcpy(dip->un.v.units.name, AudioNvolume);
|
|
|
|
return (0);
|
|
|
|
case EAP_VOICE_VOL:
|
|
|
|
dip->type = AUDIO_MIXER_VALUE;
|
|
|
|
dip->mixer_class = EAP_INPUT_CLASS;
|
|
|
|
dip->prev = AUDIO_MIXER_LAST;
|
|
|
|
dip->next = AUDIO_MIXER_LAST;
|
|
|
|
strcpy(dip->label.name, AudioNdac);
|
|
|
|
dip->un.v.num_channels = 2;
|
|
|
|
strcpy(dip->un.v.units.name, AudioNvolume);
|
|
|
|
return (0);
|
|
|
|
case EAP_FM_VOL:
|
|
|
|
dip->type = AUDIO_MIXER_VALUE;
|
|
|
|
dip->mixer_class = EAP_INPUT_CLASS;
|
|
|
|
dip->prev = AUDIO_MIXER_LAST;
|
|
|
|
dip->next = AUDIO_MIXER_LAST;
|
|
|
|
strcpy(dip->label.name, AudioNfmsynth);
|
|
|
|
dip->un.v.num_channels = 2;
|
|
|
|
strcpy(dip->un.v.units.name, AudioNvolume);
|
|
|
|
return (0);
|
|
|
|
case EAP_CD_VOL:
|
|
|
|
dip->type = AUDIO_MIXER_VALUE;
|
|
|
|
dip->mixer_class = EAP_INPUT_CLASS;
|
|
|
|
dip->prev = AUDIO_MIXER_LAST;
|
|
|
|
dip->next = AUDIO_MIXER_LAST;
|
|
|
|
strcpy(dip->label.name, AudioNcd);
|
|
|
|
dip->un.v.num_channels = 2;
|
|
|
|
strcpy(dip->un.v.units.name, AudioNvolume);
|
|
|
|
return (0);
|
|
|
|
case EAP_LINE_VOL:
|
|
|
|
dip->type = AUDIO_MIXER_VALUE;
|
|
|
|
dip->mixer_class = EAP_INPUT_CLASS;
|
|
|
|
dip->prev = AUDIO_MIXER_LAST;
|
|
|
|
dip->next = AUDIO_MIXER_LAST;
|
|
|
|
strcpy(dip->label.name, AudioNline);
|
|
|
|
dip->un.v.num_channels = 2;
|
|
|
|
strcpy(dip->un.v.units.name, AudioNvolume);
|
|
|
|
return (0);
|
|
|
|
case EAP_AUX_VOL:
|
|
|
|
dip->type = AUDIO_MIXER_VALUE;
|
|
|
|
dip->mixer_class = EAP_INPUT_CLASS;
|
|
|
|
dip->prev = AUDIO_MIXER_LAST;
|
|
|
|
dip->next = AUDIO_MIXER_LAST;
|
|
|
|
strcpy(dip->label.name, AudioNaux);
|
|
|
|
dip->un.v.num_channels = 2;
|
|
|
|
strcpy(dip->un.v.units.name, AudioNvolume);
|
|
|
|
return (0);
|
|
|
|
case EAP_MIC_VOL:
|
|
|
|
dip->type = AUDIO_MIXER_VALUE;
|
|
|
|
dip->mixer_class = EAP_INPUT_CLASS;
|
|
|
|
dip->prev = AUDIO_MIXER_LAST;
|
1998-08-12 23:09:55 +04:00
|
|
|
dip->next = EAP_MIC_PREAMP;
|
1998-05-02 01:54:33 +04:00
|
|
|
strcpy(dip->label.name, AudioNmicrophone);
|
|
|
|
dip->un.v.num_channels = 1;
|
|
|
|
strcpy(dip->un.v.units.name, AudioNvolume);
|
|
|
|
return (0);
|
|
|
|
case EAP_RECORD_SOURCE:
|
|
|
|
dip->mixer_class = EAP_RECORD_CLASS;
|
|
|
|
dip->prev = dip->next = AUDIO_MIXER_LAST;
|
|
|
|
strcpy(dip->label.name, AudioNsource);
|
|
|
|
dip->type = AUDIO_MIXER_SET;
|
1998-07-06 15:12:21 +04:00
|
|
|
dip->un.s.num_mem = 6;
|
|
|
|
strcpy(dip->un.s.member[0].label.name, AudioNmicrophone);
|
|
|
|
dip->un.s.member[0].mask = 1 << EAP_MIC_VOL;
|
|
|
|
strcpy(dip->un.s.member[1].label.name, AudioNcd);
|
|
|
|
dip->un.s.member[1].mask = 1 << EAP_CD_VOL;
|
|
|
|
strcpy(dip->un.s.member[2].label.name, AudioNline);
|
|
|
|
dip->un.s.member[2].mask = 1 << EAP_LINE_VOL;
|
|
|
|
strcpy(dip->un.s.member[3].label.name, AudioNfmsynth);
|
|
|
|
dip->un.s.member[3].mask = 1 << EAP_FM_VOL;
|
|
|
|
strcpy(dip->un.s.member[4].label.name, AudioNaux);
|
|
|
|
dip->un.s.member[4].mask = 1 << EAP_AUX_VOL;
|
|
|
|
strcpy(dip->un.s.member[5].label.name, AudioNdac);
|
|
|
|
dip->un.s.member[5].mask = 1 << EAP_VOICE_VOL;
|
|
|
|
return (0);
|
|
|
|
case EAP_OUTPUT_SELECT:
|
|
|
|
dip->mixer_class = EAP_OUTPUT_CLASS;
|
|
|
|
dip->prev = dip->next = AUDIO_MIXER_LAST;
|
|
|
|
strcpy(dip->label.name, AudioNselect);
|
|
|
|
dip->type = AUDIO_MIXER_SET;
|
|
|
|
dip->un.s.num_mem = 6;
|
1998-05-02 01:54:33 +04:00
|
|
|
strcpy(dip->un.s.member[0].label.name, AudioNmicrophone);
|
|
|
|
dip->un.s.member[0].mask = 1 << EAP_MIC_VOL;
|
|
|
|
strcpy(dip->un.s.member[1].label.name, AudioNcd);
|
|
|
|
dip->un.s.member[1].mask = 1 << EAP_CD_VOL;
|
|
|
|
strcpy(dip->un.s.member[2].label.name, AudioNline);
|
|
|
|
dip->un.s.member[2].mask = 1 << EAP_LINE_VOL;
|
|
|
|
strcpy(dip->un.s.member[3].label.name, AudioNfmsynth);
|
|
|
|
dip->un.s.member[3].mask = 1 << EAP_FM_VOL;
|
|
|
|
strcpy(dip->un.s.member[4].label.name, AudioNaux);
|
|
|
|
dip->un.s.member[4].mask = 1 << EAP_AUX_VOL;
|
1998-07-06 15:12:21 +04:00
|
|
|
strcpy(dip->un.s.member[5].label.name, AudioNdac);
|
|
|
|
dip->un.s.member[5].mask = 1 << EAP_VOICE_VOL;
|
1998-05-02 01:54:33 +04:00
|
|
|
return (0);
|
1998-08-12 22:47:43 +04:00
|
|
|
case EAP_MIC_PREAMP:
|
|
|
|
dip->type = AUDIO_MIXER_ENUM;
|
1998-08-12 23:09:55 +04:00
|
|
|
dip->mixer_class = EAP_INPUT_CLASS;
|
|
|
|
dip->prev = EAP_MIC_VOL;
|
|
|
|
dip->next = AUDIO_MIXER_LAST;
|
1998-08-12 22:47:43 +04:00
|
|
|
strcpy(dip->label.name, AudioNpreamp);
|
|
|
|
dip->un.e.num_mem = 2;
|
|
|
|
strcpy(dip->un.e.member[0].label.name, AudioNoff);
|
|
|
|
dip->un.e.member[0].ord = 0;
|
|
|
|
strcpy(dip->un.e.member[1].label.name, AudioNon);
|
|
|
|
dip->un.e.member[1].ord = 1;
|
|
|
|
return (0);
|
1998-05-02 01:54:33 +04:00
|
|
|
case EAP_OUTPUT_CLASS:
|
|
|
|
dip->type = AUDIO_MIXER_CLASS;
|
|
|
|
dip->mixer_class = EAP_OUTPUT_CLASS;
|
|
|
|
dip->next = dip->prev = AUDIO_MIXER_LAST;
|
|
|
|
strcpy(dip->label.name, AudioCoutputs);
|
|
|
|
return (0);
|
|
|
|
case EAP_RECORD_CLASS:
|
|
|
|
dip->type = AUDIO_MIXER_CLASS;
|
|
|
|
dip->mixer_class = EAP_RECORD_CLASS;
|
|
|
|
dip->next = dip->prev = AUDIO_MIXER_LAST;
|
|
|
|
strcpy(dip->label.name, AudioCrecord);
|
|
|
|
return (0);
|
|
|
|
case EAP_INPUT_CLASS:
|
|
|
|
dip->type = AUDIO_MIXER_CLASS;
|
|
|
|
dip->mixer_class = EAP_INPUT_CLASS;
|
|
|
|
dip->next = dip->prev = AUDIO_MIXER_LAST;
|
|
|
|
strcpy(dip->label.name, AudioCinputs);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
return (ENXIO);
|
|
|
|
}
|
|
|
|
|
|
|
|
void *
|
1999-02-17 05:37:38 +03:00
|
|
|
eap_malloc(addr, direction, size, pool, flags)
|
1998-05-02 01:54:33 +04:00
|
|
|
void *addr;
|
1999-02-17 05:37:38 +03:00
|
|
|
int direction;
|
|
|
|
size_t size;
|
|
|
|
int pool, flags;
|
1998-05-02 01:54:33 +04:00
|
|
|
{
|
|
|
|
struct eap_softc *sc = addr;
|
1998-08-10 00:32:34 +04:00
|
|
|
struct eap_dma *p;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
p = malloc(sizeof(*p), pool, flags);
|
|
|
|
if (!p)
|
|
|
|
return (0);
|
|
|
|
error = eap_allocmem(sc, size, 16, p);
|
|
|
|
if (error) {
|
|
|
|
free(p, pool);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
p->next = sc->sc_dmas;
|
|
|
|
sc->sc_dmas = p;
|
1998-05-02 01:54:33 +04:00
|
|
|
return (KERNADDR(p));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
eap_free(addr, ptr, pool)
|
|
|
|
void *addr;
|
|
|
|
void *ptr;
|
|
|
|
int pool;
|
|
|
|
{
|
|
|
|
struct eap_softc *sc = addr;
|
1999-07-10 20:46:19 +04:00
|
|
|
struct eap_dma **pp, *p;
|
1998-08-10 00:32:34 +04:00
|
|
|
|
1999-07-10 20:46:19 +04:00
|
|
|
for (pp = &sc->sc_dmas; (p = *pp) != NULL; pp = &p->next) {
|
|
|
|
if (KERNADDR(p) == ptr) {
|
|
|
|
eap_freemem(sc, p);
|
|
|
|
*pp = p->next;
|
|
|
|
free(p, pool);
|
1998-08-10 00:32:34 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
1998-05-02 01:54:33 +04:00
|
|
|
}
|
|
|
|
|
1999-02-17 05:37:38 +03:00
|
|
|
size_t
|
|
|
|
eap_round_buffersize(addr, direction, size)
|
1998-05-02 01:54:33 +04:00
|
|
|
void *addr;
|
1999-02-17 05:37:38 +03:00
|
|
|
int direction;
|
|
|
|
size_t size;
|
1998-05-02 01:54:33 +04:00
|
|
|
{
|
|
|
|
return (size);
|
|
|
|
}
|
|
|
|
|
2000-06-26 08:55:19 +04:00
|
|
|
paddr_t
|
1998-05-02 01:54:33 +04:00
|
|
|
eap_mappage(addr, mem, off, prot)
|
|
|
|
void *addr;
|
1998-08-10 00:32:34 +04:00
|
|
|
void *mem;
|
2000-06-26 08:55:19 +04:00
|
|
|
off_t off;
|
1998-05-02 01:54:33 +04:00
|
|
|
int prot;
|
|
|
|
{
|
|
|
|
struct eap_softc *sc = addr;
|
1998-08-10 00:32:34 +04:00
|
|
|
struct eap_dma *p;
|
1998-05-02 01:54:33 +04:00
|
|
|
|
1998-11-19 18:38:20 +03:00
|
|
|
if (off < 0)
|
|
|
|
return (-1);
|
1998-08-10 00:32:34 +04:00
|
|
|
for (p = sc->sc_dmas; p && KERNADDR(p) != mem; p = p->next)
|
1998-05-02 01:54:33 +04:00
|
|
|
;
|
|
|
|
if (!p)
|
|
|
|
return (-1);
|
|
|
|
return (bus_dmamem_mmap(sc->sc_dmatag, p->segs, p->nsegs,
|
|
|
|
off, prot, BUS_DMA_WAITOK));
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
eap_get_props(addr)
|
|
|
|
void *addr;
|
|
|
|
{
|
1999-10-27 17:20:34 +04:00
|
|
|
return (AUDIO_PROP_MMAP | AUDIO_PROP_INDEPENDENT |
|
2000-05-01 01:59:58 +04:00
|
|
|
AUDIO_PROP_FULLDUPLEX);
|
1998-05-02 01:54:33 +04:00
|
|
|
}
|
1999-10-30 03:03:18 +04:00
|
|
|
|
|
|
|
#if NMIDI > 0
|
|
|
|
int
|
|
|
|
eap_midi_open(addr, flags, iintr, ointr, arg)
|
|
|
|
void *addr;
|
|
|
|
int flags;
|
|
|
|
void (*iintr)__P((void *, int));
|
|
|
|
void (*ointr)__P((void *));
|
|
|
|
void *arg;
|
|
|
|
{
|
|
|
|
struct eap_softc *sc = addr;
|
|
|
|
u_int32_t uctrl;
|
|
|
|
|
|
|
|
sc->sc_iintr = iintr;
|
|
|
|
sc->sc_ointr = ointr;
|
|
|
|
sc->sc_arg = arg;
|
|
|
|
|
|
|
|
EWRITE4(sc, EAP_ICSC, EREAD4(sc, EAP_ICSC) | EAP_UART_EN);
|
|
|
|
uctrl = 0;
|
|
|
|
if (flags & FREAD)
|
|
|
|
uctrl |= EAP_UC_RXINTEN;
|
|
|
|
#if 0
|
|
|
|
/* I don't understand ../midi.c well enough to use output interrupts */
|
|
|
|
if (flags & FWRITE)
|
|
|
|
uctrl |= EAP_UC_TXINTEN; */
|
|
|
|
#endif
|
|
|
|
EWRITE1(sc, EAP_UART_CONTROL, uctrl);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
eap_midi_close(addr)
|
|
|
|
void *addr;
|
|
|
|
{
|
|
|
|
struct eap_softc *sc = addr;
|
|
|
|
|
|
|
|
EWRITE1(sc, EAP_UART_CONTROL, 0);
|
|
|
|
EWRITE4(sc, EAP_ICSC, EREAD4(sc, EAP_ICSC) & ~EAP_UART_EN);
|
|
|
|
|
|
|
|
sc->sc_iintr = 0;
|
|
|
|
sc->sc_ointr = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
eap_midi_output(addr, d)
|
|
|
|
void *addr;
|
|
|
|
int d;
|
|
|
|
{
|
|
|
|
struct eap_softc *sc = addr;
|
|
|
|
int x;
|
|
|
|
|
|
|
|
for (x = 0; x != MIDI_BUSY_WAIT; x++) {
|
|
|
|
if (EREAD1(sc, EAP_UART_STATUS) & EAP_US_TXRDY) {
|
|
|
|
EWRITE1(sc, EAP_UART_DATA, d);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
delay(MIDI_BUSY_DELAY);
|
|
|
|
}
|
|
|
|
return (EIO);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
eap_midi_getinfo(addr, mi)
|
|
|
|
void *addr;
|
|
|
|
struct midi_info *mi;
|
|
|
|
{
|
|
|
|
mi->name = "AudioPCI MIDI UART";
|
|
|
|
mi->props = MIDI_PROP_CAN_INPUT;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|