1999-03-19 15:40:21 +03:00
|
|
|
/* $NetBSD: ess.c,v 1.44 1999/03/19 12:40:21 mycroft Exp $ */
|
1998-06-30 00:56:21 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 1997
|
|
|
|
* Digital Equipment Corporation. All rights reserved.
|
|
|
|
*
|
|
|
|
* This software is furnished under license and may be used and
|
|
|
|
* copied only in accordance with the following terms and conditions.
|
|
|
|
* Subject to these conditions, you may download, copy, install,
|
|
|
|
* use, modify and distribute this software in source and/or binary
|
|
|
|
* form. No title or ownership is transferred hereby.
|
|
|
|
*
|
|
|
|
* 1) Any source code used, modified or distributed must reproduce
|
|
|
|
* and retain this copyright notice and list of conditions as
|
|
|
|
* they appear in the source file.
|
|
|
|
*
|
|
|
|
* 2) No right is granted to use any trade name, trademark, or logo of
|
|
|
|
* Digital Equipment Corporation. Neither the "Digital Equipment
|
|
|
|
* Corporation" name nor any trademark or logo of Digital Equipment
|
|
|
|
* Corporation may be used to endorse or promote products derived
|
|
|
|
* from this software without the prior written permission of
|
|
|
|
* Digital Equipment Corporation.
|
|
|
|
*
|
|
|
|
* 3) This software is provided "AS-IS" and any express or implied
|
|
|
|
* warranties, including but not limited to, any implied warranties
|
|
|
|
* of merchantability, fitness for a particular purpose, or
|
|
|
|
* non-infringement are disclaimed. In no event shall DIGITAL be
|
|
|
|
* liable for any damages whatsoever, and in particular, DIGITAL
|
|
|
|
* shall not be liable for special, indirect, consequential, or
|
|
|
|
* incidental damages or damages for lost profits, loss of
|
|
|
|
* revenue or loss of use, whether such damages arise in contract,
|
|
|
|
* negligence, tort, under statute, in equity, at law or otherwise,
|
|
|
|
* even if advised of the possibility of such damage.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
**++
|
|
|
|
**
|
|
|
|
** ess.c
|
|
|
|
**
|
|
|
|
** FACILITY:
|
|
|
|
**
|
|
|
|
** DIGITAL Network Appliance Reference Design (DNARD)
|
|
|
|
**
|
|
|
|
** MODULE DESCRIPTION:
|
|
|
|
**
|
|
|
|
** This module contains the device driver for the ESS
|
|
|
|
** Technologies 1888/1887/888 sound chip. The code in sbdsp.c was
|
|
|
|
** used as a reference point when implementing this driver.
|
|
|
|
**
|
|
|
|
** AUTHORS:
|
|
|
|
**
|
|
|
|
** Blair Fidler Software Engineering Australia
|
|
|
|
** Gold Coast, Australia.
|
|
|
|
**
|
|
|
|
** CREATION DATE:
|
|
|
|
**
|
|
|
|
** March 10, 1997.
|
|
|
|
**
|
|
|
|
** MODIFICATION HISTORY:
|
|
|
|
**
|
1998-08-10 19:32:18 +04:00
|
|
|
** Heavily modified by Lennart Augustsson and Charles M. Hannum for
|
|
|
|
** bus_dma, changes to audio interface, and many bug fixes.
|
1999-03-16 16:06:35 +03:00
|
|
|
** ESS1788 support by Nathan J. Williams and Charles M. Hannum.
|
1998-06-30 00:56:21 +04:00
|
|
|
**--
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/errno.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/syslog.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/proc.h>
|
1999-03-18 07:31:36 +03:00
|
|
|
#include <sys/kernel.h>
|
1998-06-30 00:56:21 +04:00
|
|
|
|
|
|
|
#include <machine/cpu.h>
|
|
|
|
#include <machine/intr.h>
|
1998-08-04 17:14:42 +04:00
|
|
|
#include <machine/bus.h>
|
1998-06-30 00:56:21 +04:00
|
|
|
|
|
|
|
#include <sys/audioio.h>
|
|
|
|
#include <dev/audio_if.h>
|
|
|
|
#include <dev/auconv.h>
|
|
|
|
#include <dev/mulaw.h>
|
|
|
|
|
|
|
|
#include <dev/isa/isavar.h>
|
|
|
|
#include <dev/isa/isadmavar.h>
|
|
|
|
|
|
|
|
#include <dev/isa/essvar.h>
|
|
|
|
#include <dev/isa/essreg.h>
|
|
|
|
|
|
|
|
#ifdef AUDIO_DEBUG
|
|
|
|
#define DPRINTF(x) if (essdebug) printf x
|
1998-07-30 18:11:42 +04:00
|
|
|
#define DPRINTFN(n,x) if (essdebug>(n)) printf x
|
1998-06-30 00:56:21 +04:00
|
|
|
int essdebug = 0;
|
|
|
|
#else
|
|
|
|
#define DPRINTF(x)
|
1998-07-30 18:11:42 +04:00
|
|
|
#define DPRINTFN(n,x)
|
1998-06-30 00:56:21 +04:00
|
|
|
#endif
|
|
|
|
|
1998-07-30 18:11:42 +04:00
|
|
|
#if 0
|
|
|
|
unsigned uuu;
|
|
|
|
#define EREAD1(t, h, a) (uuu=bus_space_read_1(t, h, a),printf("EREAD %02x=%02x\n", ((int)h&0xfff)+a, uuu),uuu)
|
|
|
|
#define EWRITE1(t, h, a, d) (printf("EWRITE %02x=%02x\n", ((int)h & 0xfff)+a, d), bus_space_write_1(t, h, a, d))
|
|
|
|
#else
|
|
|
|
#define EREAD1(t, h, a) bus_space_read_1(t, h, a)
|
|
|
|
#define EWRITE1(t, h, a, d) bus_space_write_1(t, h, a, d)
|
|
|
|
#endif
|
1998-06-30 00:56:21 +04:00
|
|
|
|
1998-07-30 18:11:42 +04:00
|
|
|
|
|
|
|
int ess_setup_sc __P((struct ess_softc *, int));
|
1998-06-30 00:56:21 +04:00
|
|
|
|
|
|
|
int ess_open __P((void *, int));
|
1999-03-02 23:36:50 +03:00
|
|
|
void ess_1788_close __P((void *));
|
|
|
|
void ess_1888_close __P((void *));
|
1998-06-30 00:56:21 +04:00
|
|
|
int ess_getdev __P((void *, struct audio_device *));
|
|
|
|
int ess_drain __P((void *));
|
|
|
|
|
|
|
|
int ess_query_encoding __P((void *, struct audio_encoding *));
|
|
|
|
|
|
|
|
int ess_set_params __P((void *, int, int, struct audio_params *,
|
1998-08-10 19:32:18 +04:00
|
|
|
struct audio_params *));
|
1998-06-30 00:56:21 +04:00
|
|
|
|
|
|
|
int ess_round_blocksize __P((void *, int));
|
|
|
|
|
1999-03-16 16:32:25 +03:00
|
|
|
int ess_audio1_trigger_output __P((void *, void *, void *, int,
|
1999-03-16 16:06:35 +03:00
|
|
|
void (*)(void *), void *, struct audio_params *));
|
1999-03-16 16:32:25 +03:00
|
|
|
int ess_audio2_trigger_output __P((void *, void *, void *, int,
|
1999-03-16 16:06:35 +03:00
|
|
|
void (*)(void *), void *, struct audio_params *));
|
1999-03-16 16:32:25 +03:00
|
|
|
int ess_audio1_trigger_input __P((void *, void *, void *, int,
|
1999-03-16 16:06:35 +03:00
|
|
|
void (*)(void *), void *, struct audio_params *));
|
1999-03-17 04:06:17 +03:00
|
|
|
int ess_audio1_halt __P((void *));
|
|
|
|
int ess_audio2_halt __P((void *));
|
1999-03-16 16:32:25 +03:00
|
|
|
int ess_audio1_intr __P((void *));
|
|
|
|
int ess_audio2_intr __P((void *));
|
1999-03-18 07:31:36 +03:00
|
|
|
void ess_audio1_poll __P((void *));
|
|
|
|
void ess_audio2_poll __P((void *));
|
1998-06-30 00:56:21 +04:00
|
|
|
|
|
|
|
int ess_speaker_ctl __P((void *, int));
|
|
|
|
|
|
|
|
int ess_getdev __P((void *, struct audio_device *));
|
|
|
|
|
|
|
|
int ess_set_port __P((void *, mixer_ctrl_t *));
|
|
|
|
int ess_get_port __P((void *, mixer_ctrl_t *));
|
|
|
|
|
1999-02-17 05:37:38 +03:00
|
|
|
void *ess_malloc __P((void *, int, size_t, int, int));
|
1998-07-31 19:17:17 +04:00
|
|
|
void ess_free __P((void *, void *, int));
|
1999-02-17 05:37:38 +03:00
|
|
|
size_t ess_round_buffersize __P((void *, int, size_t));
|
1998-07-31 19:17:17 +04:00
|
|
|
int ess_mappage __P((void *, void *, int, int));
|
|
|
|
|
|
|
|
|
1998-06-30 00:56:21 +04:00
|
|
|
int ess_query_devinfo __P((void *, mixer_devinfo_t *));
|
1999-03-16 16:32:25 +03:00
|
|
|
int ess_1788_get_props __P((void *));
|
|
|
|
int ess_1888_get_props __P((void *));
|
1998-06-30 00:56:21 +04:00
|
|
|
|
1998-07-31 19:17:17 +04:00
|
|
|
void ess_speaker_on __P((struct ess_softc *));
|
|
|
|
void ess_speaker_off __P((struct ess_softc *));
|
1998-06-30 00:56:21 +04:00
|
|
|
|
|
|
|
int ess_config_addr __P((struct ess_softc *));
|
1998-07-31 19:17:17 +04:00
|
|
|
void ess_config_irq __P((struct ess_softc *));
|
|
|
|
void ess_config_drq __P((struct ess_softc *));
|
|
|
|
void ess_setup __P((struct ess_softc *));
|
1998-06-30 00:56:21 +04:00
|
|
|
int ess_identify __P((struct ess_softc *));
|
|
|
|
|
|
|
|
int ess_reset __P((struct ess_softc *));
|
|
|
|
void ess_set_gain __P((struct ess_softc *, int, int));
|
1999-03-02 23:36:50 +03:00
|
|
|
int ess_set_in_port __P((struct ess_softc *, int));
|
1998-06-30 00:56:21 +04:00
|
|
|
int ess_set_in_ports __P((struct ess_softc *, int));
|
|
|
|
u_int ess_srtotc __P((u_int));
|
|
|
|
u_int ess_srtofc __P((u_int));
|
|
|
|
u_char ess_get_dsp_status __P((struct ess_softc *));
|
|
|
|
u_char ess_dsp_read_ready __P((struct ess_softc *));
|
|
|
|
u_char ess_dsp_write_ready __P((struct ess_softc *sc));
|
|
|
|
int ess_rdsp __P((struct ess_softc *));
|
|
|
|
int ess_wdsp __P((struct ess_softc *, u_char));
|
|
|
|
u_char ess_read_x_reg __P((struct ess_softc *, u_char));
|
|
|
|
int ess_write_x_reg __P((struct ess_softc *, u_char, u_char));
|
|
|
|
void ess_clear_xreg_bits __P((struct ess_softc *, u_char, u_char));
|
|
|
|
void ess_set_xreg_bits __P((struct ess_softc *, u_char, u_char));
|
|
|
|
u_char ess_read_mix_reg __P((struct ess_softc *, u_char));
|
|
|
|
void ess_write_mix_reg __P((struct ess_softc *, u_char, u_char));
|
|
|
|
void ess_clear_mreg_bits __P((struct ess_softc *, u_char, u_char));
|
|
|
|
void ess_set_mreg_bits __P((struct ess_softc *, u_char, u_char));
|
|
|
|
|
|
|
|
static char *essmodel[] = {
|
|
|
|
"unsupported",
|
|
|
|
"1888",
|
|
|
|
"1887",
|
1999-03-02 23:36:50 +03:00
|
|
|
"888",
|
|
|
|
"1788"
|
1998-06-30 00:56:21 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct audio_device ess_device = {
|
|
|
|
"ESS Technology",
|
|
|
|
"x",
|
|
|
|
"ess"
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Define our interface to the higher level audio driver.
|
|
|
|
*/
|
|
|
|
|
1999-03-02 23:36:50 +03:00
|
|
|
struct audio_hw_if ess_1788_hw_if = {
|
|
|
|
ess_open,
|
|
|
|
ess_1788_close,
|
|
|
|
ess_drain,
|
|
|
|
ess_query_encoding,
|
|
|
|
ess_set_params,
|
|
|
|
ess_round_blocksize,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
1999-03-17 04:06:17 +03:00
|
|
|
ess_audio1_halt,
|
|
|
|
ess_audio1_halt,
|
1999-03-02 23:36:50 +03:00
|
|
|
ess_speaker_ctl,
|
|
|
|
ess_getdev,
|
|
|
|
NULL,
|
|
|
|
ess_set_port,
|
|
|
|
ess_get_port,
|
|
|
|
ess_query_devinfo,
|
|
|
|
ess_malloc,
|
|
|
|
ess_free,
|
|
|
|
ess_round_buffersize,
|
|
|
|
ess_mappage,
|
1999-03-16 16:32:25 +03:00
|
|
|
ess_1788_get_props,
|
|
|
|
ess_audio1_trigger_output,
|
|
|
|
ess_audio1_trigger_input,
|
1999-03-02 23:36:50 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct audio_hw_if ess_1888_hw_if = {
|
1998-06-30 00:56:21 +04:00
|
|
|
ess_open,
|
1999-03-02 23:36:50 +03:00
|
|
|
ess_1888_close,
|
1998-08-04 17:14:42 +04:00
|
|
|
ess_drain,
|
1998-06-30 00:56:21 +04:00
|
|
|
ess_query_encoding,
|
|
|
|
ess_set_params,
|
|
|
|
ess_round_blocksize,
|
|
|
|
NULL,
|
1998-08-10 19:32:18 +04:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
1999-03-17 04:06:17 +03:00
|
|
|
ess_audio2_halt,
|
|
|
|
ess_audio1_halt,
|
1998-06-30 00:56:21 +04:00
|
|
|
ess_speaker_ctl,
|
|
|
|
ess_getdev,
|
|
|
|
NULL,
|
|
|
|
ess_set_port,
|
|
|
|
ess_get_port,
|
|
|
|
ess_query_devinfo,
|
1998-07-31 19:17:17 +04:00
|
|
|
ess_malloc,
|
|
|
|
ess_free,
|
1999-02-17 05:37:38 +03:00
|
|
|
ess_round_buffersize,
|
1999-03-02 23:36:50 +03:00
|
|
|
ess_mappage,
|
1999-03-16 16:32:25 +03:00
|
|
|
ess_1888_get_props,
|
|
|
|
ess_audio2_trigger_output,
|
|
|
|
ess_audio1_trigger_input,
|
1998-06-30 00:56:21 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef AUDIO_DEBUG
|
|
|
|
void ess_printsc __P((struct ess_softc *));
|
|
|
|
void ess_dump_mixer __P((struct ess_softc *));
|
|
|
|
|
|
|
|
void
|
|
|
|
ess_printsc(sc)
|
|
|
|
struct ess_softc *sc;
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
printf("open %d iobase 0x%x outport %u inport %u speaker %s\n",
|
|
|
|
(int)sc->sc_open, sc->sc_iobase, sc->out_port,
|
|
|
|
sc->in_port, sc->spkr_state ? "on" : "off");
|
|
|
|
|
1999-03-16 16:24:27 +03:00
|
|
|
printf("audio1: dmachan %d irq %d nintr %lu intr %p arg %p\n",
|
1999-03-16 16:06:35 +03:00
|
|
|
sc->sc_audio1.drq, sc->sc_audio1.irq, sc->sc_audio1.nintr,
|
|
|
|
sc->sc_audio1.intr, sc->sc_audio1.arg);
|
|
|
|
|
1999-03-16 16:24:27 +03:00
|
|
|
if (sc->sc_model != ESS_1788) {
|
|
|
|
printf("audio2: dmachan %d irq %d nintr %lu intr %p arg %p\n",
|
1999-03-16 16:06:35 +03:00
|
|
|
sc->sc_audio2.drq, sc->sc_audio2.irq, sc->sc_audio2.nintr,
|
|
|
|
sc->sc_audio2.intr, sc->sc_audio2.arg);
|
1999-03-16 16:24:27 +03:00
|
|
|
}
|
1998-06-30 00:56:21 +04:00
|
|
|
|
|
|
|
printf("gain:");
|
1999-03-02 23:36:50 +03:00
|
|
|
for (i = 0; i < sc->ndevs; i++)
|
1998-06-30 00:56:21 +04:00
|
|
|
printf(" %u,%u", sc->gain[i][ESS_LEFT], sc->gain[i][ESS_RIGHT]);
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ess_dump_mixer(sc)
|
|
|
|
struct ess_softc *sc;
|
|
|
|
{
|
|
|
|
printf("ESS_DAC_PLAY_VOL: mix reg 0x%02x=0x%02x\n",
|
1999-03-16 16:06:35 +03:00
|
|
|
0x7C, ess_read_mix_reg(sc, 0x7C));
|
1998-06-30 00:56:21 +04:00
|
|
|
printf("ESS_MIC_PLAY_VOL: mix reg 0x%02x=0x%02x\n",
|
|
|
|
0x1A, ess_read_mix_reg(sc, 0x1A));
|
|
|
|
printf("ESS_LINE_PLAY_VOL: mix reg 0x%02x=0x%02x\n",
|
|
|
|
0x3E, ess_read_mix_reg(sc, 0x3E));
|
|
|
|
printf("ESS_SYNTH_PLAY_VOL: mix reg 0x%02x=0x%02x\n",
|
|
|
|
0x36, ess_read_mix_reg(sc, 0x36));
|
|
|
|
printf("ESS_CD_PLAY_VOL: mix reg 0x%02x=0x%02x\n",
|
|
|
|
0x38, ess_read_mix_reg(sc, 0x38));
|
|
|
|
printf("ESS_AUXB_PLAY_VOL: mix reg 0x%02x=0x%02x\n",
|
|
|
|
0x3A, ess_read_mix_reg(sc, 0x3A));
|
|
|
|
printf("ESS_MASTER_VOL: mix reg 0x%02x=0x%02x\n",
|
|
|
|
0x32, ess_read_mix_reg(sc, 0x32));
|
|
|
|
printf("ESS_PCSPEAKER_VOL: mix reg 0x%02x=0x%02x\n",
|
|
|
|
0x3C, ess_read_mix_reg(sc, 0x3C));
|
|
|
|
printf("ESS_DAC_REC_VOL: mix reg 0x%02x=0x%02x\n",
|
|
|
|
0x69, ess_read_mix_reg(sc, 0x69));
|
|
|
|
printf("ESS_MIC_REC_VOL: mix reg 0x%02x=0x%02x\n",
|
|
|
|
0x68, ess_read_mix_reg(sc, 0x68));
|
|
|
|
printf("ESS_LINE_REC_VOL: mix reg 0x%02x=0x%02x\n",
|
|
|
|
0x6E, ess_read_mix_reg(sc, 0x6E));
|
|
|
|
printf("ESS_SYNTH_REC_VOL: mix reg 0x%02x=0x%02x\n",
|
|
|
|
0x6B, ess_read_mix_reg(sc, 0x6B));
|
|
|
|
printf("ESS_CD_REC_VOL: mix reg 0x%02x=0x%02x\n",
|
|
|
|
0x6A, ess_read_mix_reg(sc, 0x6A));
|
|
|
|
printf("ESS_AUXB_REC_VOL: mix reg 0x%02x=0x%02x\n",
|
|
|
|
0x6C, ess_read_mix_reg(sc, 0x6C));
|
|
|
|
printf("ESS_RECORD_VOL: x reg 0x%02x=0x%02x\n",
|
|
|
|
0xB4, ess_read_x_reg(sc, 0xB4));
|
|
|
|
printf("Audio 1 play vol (unused): mix reg 0x%02x=0x%02x\n",
|
|
|
|
0x14, ess_read_mix_reg(sc, 0x14));
|
|
|
|
|
|
|
|
printf("ESS_MIC_PREAMP: x reg 0x%02x=0x%02x\n",
|
|
|
|
ESS_XCMD_PREAMP_CTRL, ess_read_x_reg(sc, ESS_XCMD_PREAMP_CTRL));
|
|
|
|
printf("ESS_RECORD_MONITOR: x reg 0x%02x=0x%02x\n",
|
|
|
|
ESS_XCMD_AUDIO_CTRL, ess_read_x_reg(sc, ESS_XCMD_AUDIO_CTRL));
|
|
|
|
printf("Record source: mix reg 0x%02x=0x%02x, 0x%02x=0x%02x\n",
|
1999-03-16 16:06:35 +03:00
|
|
|
ESS_MREG_ADC_SOURCE, ess_read_mix_reg(sc, ESS_MREG_ADC_SOURCE),
|
|
|
|
ESS_MREG_AUDIO2_CTRL2, ess_read_mix_reg(sc, ESS_MREG_AUDIO2_CTRL2));
|
1998-06-30 00:56:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Configure the ESS chip for the desired audio base address.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
ess_config_addr(sc)
|
|
|
|
struct ess_softc *sc;
|
|
|
|
{
|
|
|
|
int iobase = sc->sc_iobase;
|
|
|
|
bus_space_tag_t iot = sc->sc_iot;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Configure using the System Control Register method. This
|
|
|
|
* method is used when the AMODE line is tied high, which is
|
|
|
|
* the case for the Shark, but not for the evaluation board.
|
|
|
|
*/
|
|
|
|
|
|
|
|
bus_space_handle_t scr_access_ioh;
|
|
|
|
bus_space_handle_t scr_ioh;
|
|
|
|
u_short scr_value;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the SCR bit to enable audio.
|
|
|
|
*/
|
|
|
|
scr_value = ESS_SCR_AUDIO_ENABLE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the SCR bits necessary to select the specified audio
|
|
|
|
* base address.
|
|
|
|
*/
|
|
|
|
switch(iobase) {
|
|
|
|
case 0x220:
|
|
|
|
scr_value |= ESS_SCR_AUDIO_220;
|
|
|
|
break;
|
|
|
|
case 0x230:
|
|
|
|
scr_value |= ESS_SCR_AUDIO_230;
|
|
|
|
break;
|
|
|
|
case 0x240:
|
|
|
|
scr_value |= ESS_SCR_AUDIO_240;
|
|
|
|
break;
|
|
|
|
case 0x250:
|
|
|
|
scr_value |= ESS_SCR_AUDIO_250;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("ess: configured iobase 0x%x invalid\n", iobase);
|
|
|
|
return (1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get a mapping for the System Control Register (SCR) access
|
|
|
|
* registers and the SCR data registers.
|
|
|
|
*/
|
|
|
|
if (bus_space_map(iot, ESS_SCR_ACCESS_BASE, ESS_SCR_ACCESS_PORTS,
|
|
|
|
0, &scr_access_ioh)) {
|
|
|
|
printf("ess: can't map SCR access registers\n");
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
if (bus_space_map(iot, ESS_SCR_BASE, ESS_SCR_PORTS,
|
|
|
|
0, &scr_ioh)) {
|
|
|
|
printf("ess: can't map SCR registers\n");
|
|
|
|
bus_space_unmap(iot, scr_access_ioh, ESS_SCR_ACCESS_PORTS);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Unlock the SCR. */
|
1998-07-30 18:11:42 +04:00
|
|
|
EWRITE1(iot, scr_access_ioh, ESS_SCR_UNLOCK, 0);
|
1998-06-30 00:56:21 +04:00
|
|
|
|
|
|
|
/* Write the base address information into SCR[0]. */
|
1998-07-30 18:11:42 +04:00
|
|
|
EWRITE1(iot, scr_ioh, ESS_SCR_INDEX, 0);
|
|
|
|
EWRITE1(iot, scr_ioh, ESS_SCR_DATA, scr_value);
|
1998-06-30 00:56:21 +04:00
|
|
|
|
|
|
|
/* Lock the SCR. */
|
1998-07-30 18:11:42 +04:00
|
|
|
EWRITE1(iot, scr_access_ioh, ESS_SCR_LOCK, 0);
|
1998-06-30 00:56:21 +04:00
|
|
|
|
|
|
|
/* Unmap the SCR access ports and the SCR data ports. */
|
|
|
|
bus_space_unmap(iot, scr_access_ioh, ESS_SCR_ACCESS_PORTS);
|
|
|
|
bus_space_unmap(iot, scr_ioh, ESS_SCR_PORTS);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Configure the ESS chip for the desired IRQ and DMA channels.
|
1998-07-30 18:11:42 +04:00
|
|
|
* ESS ISA
|
|
|
|
* --------
|
|
|
|
* IRQA irq9
|
|
|
|
* IRQB irq5
|
|
|
|
* IRQC irq7
|
|
|
|
* IRQD irq10
|
|
|
|
* IRQE irq15
|
1998-07-31 19:17:17 +04:00
|
|
|
*
|
1998-07-30 18:11:42 +04:00
|
|
|
* DRQA drq0
|
|
|
|
* DRQB drq1
|
|
|
|
* DRQC drq3
|
|
|
|
* DRQD drq5
|
1998-06-30 00:56:21 +04:00
|
|
|
*/
|
|
|
|
void
|
1998-07-31 19:17:17 +04:00
|
|
|
ess_config_irq(sc)
|
1998-06-30 00:56:21 +04:00
|
|
|
struct ess_softc *sc;
|
|
|
|
{
|
1998-07-31 19:17:17 +04:00
|
|
|
int v;
|
1998-06-30 00:56:21 +04:00
|
|
|
|
1998-07-31 19:17:17 +04:00
|
|
|
DPRINTFN(2,("ess_config_irq\n"));
|
|
|
|
|
1999-03-16 16:06:35 +03:00
|
|
|
if (sc->sc_model == ESS_1887 &&
|
1999-03-18 07:31:36 +03:00
|
|
|
sc->sc_audio1.irq == sc->sc_audio2.irq &&
|
|
|
|
sc->sc_audio1.irq != -1) {
|
1998-07-31 19:17:17 +04:00
|
|
|
/* Use new method, both interrupts are the same. */
|
|
|
|
v = ESS_IS_SELECT_IRQ; /* enable intrs */
|
1999-03-18 07:31:36 +03:00
|
|
|
switch (sc->sc_audio1.irq) {
|
1998-07-31 19:17:17 +04:00
|
|
|
case 5:
|
|
|
|
v |= ESS_IS_INTRB;
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
v |= ESS_IS_INTRC;
|
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
v |= ESS_IS_INTRA;
|
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
v |= ESS_IS_INTRD;
|
|
|
|
break;
|
|
|
|
case 15:
|
|
|
|
v |= ESS_IS_INTRE;
|
|
|
|
break;
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
default:
|
|
|
|
printf("ess_config_irq: configured irq %d not supported for Audio 1\n",
|
1999-03-16 16:06:35 +03:00
|
|
|
sc->sc_audio1.irq);
|
1998-07-31 19:17:17 +04:00
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
/* Set the IRQ */
|
|
|
|
ess_write_mix_reg(sc, ESS_MREG_INTR_ST, v);
|
1999-03-16 16:06:35 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-03-18 07:31:36 +03:00
|
|
|
if (sc->sc_model == ESS_1887) {
|
|
|
|
/* Tell the 1887 to use the old interrupt method. */
|
|
|
|
ess_write_mix_reg(sc, ESS_MREG_INTR_ST, ESS_IS_ES1888);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sc->sc_audio1.polled) {
|
|
|
|
/* Turn off Audio1 interrupts. */
|
|
|
|
v = 0;
|
|
|
|
} else {
|
|
|
|
/* Configure Audio 1 for the appropriate IRQ line. */
|
|
|
|
v = ESS_IRQ_CTRL_MASK | ESS_IRQ_CTRL_EXT; /* All intrs on */
|
|
|
|
switch (sc->sc_audio1.irq) {
|
|
|
|
case 5:
|
|
|
|
v |= ESS_IRQ_CTRL_INTRB;
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
v |= ESS_IRQ_CTRL_INTRC;
|
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
v |= ESS_IRQ_CTRL_INTRA;
|
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
v |= ESS_IRQ_CTRL_INTRD;
|
|
|
|
break;
|
1999-03-16 16:06:35 +03:00
|
|
|
#ifdef DIAGNOSTIC
|
1999-03-18 07:31:36 +03:00
|
|
|
default:
|
|
|
|
printf("ess: configured irq %d not supported for Audio 1\n",
|
|
|
|
sc->sc_audio1.irq);
|
|
|
|
return;
|
1999-03-16 16:06:35 +03:00
|
|
|
#endif
|
1999-03-18 07:31:36 +03:00
|
|
|
}
|
1998-07-31 19:17:17 +04:00
|
|
|
}
|
1999-03-16 16:06:35 +03:00
|
|
|
ess_write_x_reg(sc, ESS_XCMD_IRQ_CTRL, v);
|
|
|
|
|
|
|
|
if (sc->sc_model == ESS_1788)
|
|
|
|
return;
|
|
|
|
|
1999-03-18 07:31:36 +03:00
|
|
|
if (sc->sc_audio2.polled) {
|
|
|
|
/* Turn off Audio2 interrupts. */
|
|
|
|
ess_clear_mreg_bits(sc, ESS_MREG_AUDIO2_CTRL2,
|
|
|
|
ESS_AUDIO2_CTRL2_IRQ2_ENABLE);
|
|
|
|
} else {
|
|
|
|
/* Audio2 is hardwired to INTRE in this mode. */
|
|
|
|
ess_set_mreg_bits(sc, ESS_MREG_AUDIO2_CTRL2,
|
|
|
|
ESS_AUDIO2_CTRL2_IRQ2_ENABLE);
|
|
|
|
}
|
1998-07-31 19:17:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ess_config_drq(sc)
|
|
|
|
struct ess_softc *sc;
|
|
|
|
{
|
|
|
|
int v;
|
|
|
|
|
|
|
|
DPRINTFN(2,("ess_config_drq\n"));
|
|
|
|
|
|
|
|
/* Configure Audio 1 (record) for DMA on the appropriate channel. */
|
|
|
|
v = ESS_DRQ_CTRL_PU | ESS_DRQ_CTRL_EXT;
|
1999-03-16 16:06:35 +03:00
|
|
|
switch (sc->sc_audio1.drq) {
|
1998-07-31 19:17:17 +04:00
|
|
|
case 0:
|
|
|
|
v |= ESS_DRQ_CTRL_DRQA;
|
1998-06-30 00:56:21 +04:00
|
|
|
break;
|
1998-07-31 19:17:17 +04:00
|
|
|
case 1:
|
|
|
|
v |= ESS_DRQ_CTRL_DRQB;
|
1998-06-30 00:56:21 +04:00
|
|
|
break;
|
1998-07-31 19:17:17 +04:00
|
|
|
case 3:
|
|
|
|
v |= ESS_DRQ_CTRL_DRQC;
|
1998-06-30 00:56:21 +04:00
|
|
|
break;
|
1998-07-30 18:11:42 +04:00
|
|
|
#ifdef DIAGNOSTIC
|
1998-06-30 00:56:21 +04:00
|
|
|
default:
|
1998-07-31 19:17:17 +04:00
|
|
|
printf("ess_config_drq: configured dma chan %d not supported for Audio 1\n",
|
1999-03-16 16:06:35 +03:00
|
|
|
sc->sc_audio1.drq);
|
1998-06-30 00:56:21 +04:00
|
|
|
return;
|
1998-07-31 19:17:17 +04:00
|
|
|
#endif
|
1998-08-01 03:54:09 +04:00
|
|
|
}
|
1998-07-31 19:17:17 +04:00
|
|
|
/* Set DRQ1 */
|
|
|
|
ess_write_x_reg(sc, ESS_XCMD_DRQ_CTRL, v);
|
|
|
|
|
1999-03-16 16:06:35 +03:00
|
|
|
if (sc->sc_model == ESS_1788)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Configure DRQ2 */
|
|
|
|
v = ESS_AUDIO2_CTRL3_DRQ_PD;
|
|
|
|
switch (sc->sc_audio2.drq) {
|
|
|
|
case 0:
|
|
|
|
v |= ESS_AUDIO2_CTRL3_DRQA;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
v |= ESS_AUDIO2_CTRL3_DRQB;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
v |= ESS_AUDIO2_CTRL3_DRQC;
|
|
|
|
break;
|
|
|
|
case 5:
|
1999-03-16 16:37:23 +03:00
|
|
|
v |= ESS_AUDIO2_CTRL3_DRQD;
|
1999-03-16 16:06:35 +03:00
|
|
|
break;
|
1998-07-30 18:11:42 +04:00
|
|
|
#ifdef DIAGNOSTIC
|
1999-03-16 16:06:35 +03:00
|
|
|
default:
|
|
|
|
printf("ess_config_drq: configured dma chan %d not supported for Audio 2\n",
|
|
|
|
sc->sc_audio2.drq);
|
|
|
|
return;
|
1998-07-30 18:11:42 +04:00
|
|
|
#endif
|
1998-08-01 03:54:09 +04:00
|
|
|
}
|
1999-03-16 16:06:35 +03:00
|
|
|
ess_write_mix_reg(sc, ESS_MREG_AUDIO2_CTRL3, v);
|
|
|
|
/* Enable DMA 2 */
|
|
|
|
ess_set_mreg_bits(sc, ESS_MREG_AUDIO2_CTRL2,
|
|
|
|
ESS_AUDIO2_CTRL2_DMA_ENABLE);
|
1998-07-31 19:17:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up registers after a reset.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ess_setup(sc)
|
|
|
|
struct ess_softc *sc;
|
|
|
|
{
|
1998-08-09 10:52:57 +04:00
|
|
|
|
1998-07-31 19:17:17 +04:00
|
|
|
ess_config_irq(sc);
|
|
|
|
ess_config_drq(sc);
|
1998-06-30 00:56:21 +04:00
|
|
|
|
1998-07-31 19:17:17 +04:00
|
|
|
DPRINTFN(2,("ess_setup: done\n"));
|
1998-07-30 18:11:42 +04:00
|
|
|
}
|
1998-06-30 00:56:21 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Determine the model of ESS chip we are talking to. Currently we
|
|
|
|
* only support ES1888, ES1887 and ES888. The method of determining
|
|
|
|
* the chip is based on the information on page 27 of the ES1887 data
|
|
|
|
* sheet.
|
|
|
|
*
|
|
|
|
* This routine sets the values of sc->sc_model and sc->sc_version.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
ess_identify(sc)
|
|
|
|
struct ess_softc *sc;
|
|
|
|
{
|
|
|
|
u_char reg1;
|
|
|
|
u_char reg2;
|
|
|
|
u_char reg3;
|
|
|
|
|
|
|
|
sc->sc_model = ESS_UNSUPPORTED;
|
|
|
|
sc->sc_version = 0;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 1. Check legacy ID bytes. These should be 0x68 0x8n, where
|
|
|
|
* n >= 8 for an ES1887 or an ES888. Other values indicate
|
|
|
|
* earlier (unsupported) chips.
|
|
|
|
*/
|
|
|
|
ess_wdsp(sc, ESS_ACMD_LEGACY_ID);
|
|
|
|
|
|
|
|
if ((reg1 = ess_rdsp(sc)) != 0x68) {
|
|
|
|
printf("ess: First ID byte wrong (0x%02x)\n", reg1);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
reg2 = ess_rdsp(sc);
|
|
|
|
if (((reg2 & 0xf0) != 0x80) ||
|
|
|
|
((reg2 & 0x0f) < 8)) {
|
|
|
|
printf("ess: Second ID byte wrong (0x%02x)\n", reg2);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Store the ID bytes as the version.
|
|
|
|
*/
|
|
|
|
sc->sc_version = (reg1 << 8) + reg2;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 2. Verify we can change bit 2 in mixer register 0x64. This
|
|
|
|
* should be possible on all supported chips.
|
|
|
|
*/
|
1999-03-02 23:36:50 +03:00
|
|
|
reg1 = ess_read_mix_reg(sc, ESS_MREG_VOLUME_CTRL);
|
1998-06-30 00:56:21 +04:00
|
|
|
reg2 = reg1 ^ 0x04; /* toggle bit 2 */
|
|
|
|
|
1999-03-02 23:36:50 +03:00
|
|
|
ess_write_mix_reg(sc, ESS_MREG_VOLUME_CTRL, reg2);
|
1998-06-30 00:56:21 +04:00
|
|
|
|
1999-03-02 23:36:50 +03:00
|
|
|
if (ess_read_mix_reg(sc, ESS_MREG_VOLUME_CTRL) != reg2) {
|
1998-06-30 00:56:21 +04:00
|
|
|
printf("ess: Hardware error (unable to toggle bit 2 of mixer register 0x64)\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Restore the original value of mixer register 0x64.
|
|
|
|
*/
|
1999-03-02 23:36:50 +03:00
|
|
|
ess_write_mix_reg(sc, ESS_MREG_VOLUME_CTRL, reg1);
|
1998-06-30 00:56:21 +04:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
1998-07-31 19:17:17 +04:00
|
|
|
* 3. Verify we can change the value of mixer register
|
|
|
|
* ESS_MREG_SAMPLE_RATE.
|
1999-03-02 23:36:50 +03:00
|
|
|
* This is possible on the 1888/1887/888, but not on the 1788.
|
1998-07-31 19:17:17 +04:00
|
|
|
* It is not necessary to restore the value of this mixer register.
|
1998-06-30 00:56:21 +04:00
|
|
|
*/
|
1998-07-31 19:17:17 +04:00
|
|
|
reg1 = ess_read_mix_reg(sc, ESS_MREG_SAMPLE_RATE);
|
1998-06-30 00:56:21 +04:00
|
|
|
reg2 = reg1 ^ 0xff; /* toggle all bits */
|
|
|
|
|
1998-07-31 19:17:17 +04:00
|
|
|
ess_write_mix_reg(sc, ESS_MREG_SAMPLE_RATE, reg2);
|
1998-06-30 00:56:21 +04:00
|
|
|
|
1998-07-31 19:17:17 +04:00
|
|
|
if (ess_read_mix_reg(sc, ESS_MREG_SAMPLE_RATE) != reg2) {
|
1999-03-16 16:06:35 +03:00
|
|
|
/* If we got this far before failing, it's a 1788. */
|
|
|
|
sc->sc_model = ESS_1788;
|
1998-06-30 00:56:21 +04:00
|
|
|
} else {
|
|
|
|
/*
|
1999-03-02 23:36:50 +03:00
|
|
|
* 4. Determine if we can change bit 5 in mixer register 0x64.
|
|
|
|
* This determines whether we have an ES1887:
|
1998-06-30 00:56:21 +04:00
|
|
|
*
|
1999-03-02 23:36:50 +03:00
|
|
|
* - can change indicates ES1887
|
|
|
|
* - can't change indicates ES1888 or ES888
|
1998-06-30 00:56:21 +04:00
|
|
|
*/
|
1999-03-02 23:36:50 +03:00
|
|
|
reg1 = ess_read_mix_reg(sc, ESS_MREG_VOLUME_CTRL);
|
|
|
|
reg2 = reg1 ^ 0x20; /* toggle bit 5 */
|
|
|
|
|
|
|
|
ess_write_mix_reg(sc, ESS_MREG_VOLUME_CTRL, reg2);
|
|
|
|
|
|
|
|
if (ess_read_mix_reg(sc, ESS_MREG_VOLUME_CTRL) == reg2) {
|
|
|
|
sc->sc_model = ESS_1887;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Restore the original value of mixer register 0x64.
|
|
|
|
*/
|
|
|
|
ess_write_mix_reg(sc, ESS_MREG_VOLUME_CTRL, reg1);
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* 5. Determine if we can change the value of mixer
|
|
|
|
* register 0x69 independently of mixer register
|
|
|
|
* 0x68. This determines which chip we have:
|
|
|
|
*
|
|
|
|
* - can modify idependently indicates ES888
|
|
|
|
* - register 0x69 is an alias of 0x68 indicates ES1888
|
|
|
|
*/
|
|
|
|
reg1 = ess_read_mix_reg(sc, 0x68);
|
|
|
|
reg2 = ess_read_mix_reg(sc, 0x69);
|
|
|
|
reg3 = reg2 ^ 0xff; /* toggle all bits */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Write different values to each register.
|
|
|
|
*/
|
|
|
|
ess_write_mix_reg(sc, 0x68, reg2);
|
|
|
|
ess_write_mix_reg(sc, 0x69, reg3);
|
|
|
|
|
1999-03-16 16:06:35 +03:00
|
|
|
if (ess_read_mix_reg(sc, 0x68) == reg2 &&
|
|
|
|
ess_read_mix_reg(sc, 0x69) == reg3)
|
1999-03-02 23:36:50 +03:00
|
|
|
sc->sc_model = ESS_888;
|
|
|
|
else
|
|
|
|
sc->sc_model = ESS_1888;
|
1998-06-30 00:56:21 +04:00
|
|
|
|
1999-03-02 23:36:50 +03:00
|
|
|
/*
|
|
|
|
* Restore the original value of the registers.
|
|
|
|
*/
|
|
|
|
ess_write_mix_reg(sc, 0x68, reg1);
|
|
|
|
ess_write_mix_reg(sc, 0x69, reg2);
|
|
|
|
}
|
1998-06-30 00:56:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
1998-07-30 18:11:42 +04:00
|
|
|
ess_setup_sc(sc, doinit)
|
1998-06-30 00:56:21 +04:00
|
|
|
struct ess_softc *sc;
|
|
|
|
int doinit;
|
|
|
|
{
|
|
|
|
/* Reset the chip. */
|
1998-07-31 19:17:17 +04:00
|
|
|
if (ess_reset(sc) != 0) {
|
|
|
|
DPRINTF(("ess_setup_sc: couldn't reset chip\n"));
|
1998-06-30 00:56:21 +04:00
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Identify the ESS chip, and check that it is supported. */
|
|
|
|
if (ess_identify(sc)) {
|
|
|
|
DPRINTF(("ess_setup_sc: couldn't identify\n"));
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Probe for the ESS hardware.
|
|
|
|
*/
|
|
|
|
int
|
1998-07-30 18:11:42 +04:00
|
|
|
essmatch(sc)
|
|
|
|
struct ess_softc *sc;
|
1998-06-30 00:56:21 +04:00
|
|
|
{
|
1998-07-30 18:11:42 +04:00
|
|
|
if (!ESS_BASE_VALID(sc->sc_iobase)) {
|
|
|
|
printf("ess: configured iobase 0x%x invalid\n", sc->sc_iobase);
|
1998-06-30 00:56:21 +04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1998-07-31 19:17:17 +04:00
|
|
|
/* Configure the ESS chip for the desired audio base address. */
|
|
|
|
if (ess_config_addr(sc))
|
|
|
|
return (0);
|
|
|
|
|
1998-07-30 18:11:42 +04:00
|
|
|
if (ess_setup_sc(sc, 1))
|
|
|
|
return (0);
|
1998-06-30 00:56:21 +04:00
|
|
|
|
|
|
|
if (sc->sc_model == ESS_UNSUPPORTED) {
|
|
|
|
DPRINTF(("ess: Unsupported model\n"));
|
1998-07-31 19:17:17 +04:00
|
|
|
return (0);
|
1998-06-30 00:56:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Check that requested DMA channels are valid and different. */
|
1999-03-16 16:06:35 +03:00
|
|
|
if (!ESS_DRQ1_VALID(sc->sc_audio1.drq)) {
|
|
|
|
printf("ess: record drq %d invalid\n", sc->sc_audio1.drq);
|
1998-07-31 19:17:17 +04:00
|
|
|
return (0);
|
1998-06-30 00:56:21 +04:00
|
|
|
}
|
1999-03-17 05:39:59 +03:00
|
|
|
if (!isa_drq_isfree(sc->sc_ic, sc->sc_audio1.drq))
|
|
|
|
return (0);
|
1999-03-02 23:36:50 +03:00
|
|
|
if (sc->sc_model != ESS_1788) {
|
1999-03-19 15:40:21 +03:00
|
|
|
if (!ESS_DRQ2_VALID(sc->sc_audio2.drq)) {
|
1999-03-16 16:06:35 +03:00
|
|
|
printf("ess: play drq %d invalid\n", sc->sc_audio2.drq);
|
1999-03-02 23:36:50 +03:00
|
|
|
return (0);
|
1998-08-07 04:51:06 +04:00
|
|
|
}
|
1999-03-16 16:06:35 +03:00
|
|
|
if (sc->sc_audio1.drq == sc->sc_audio2.drq) {
|
|
|
|
printf("ess: play and record drq both %d\n",
|
|
|
|
sc->sc_audio1.drq);
|
1998-07-31 19:17:17 +04:00
|
|
|
return (0);
|
|
|
|
}
|
1999-03-17 05:39:59 +03:00
|
|
|
if (!isa_drq_isfree(sc->sc_ic, sc->sc_audio2.drq))
|
|
|
|
return (0);
|
1998-07-31 19:17:17 +04:00
|
|
|
}
|
1999-03-16 16:06:35 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The 1887 has an additional IRQ mode where both channels are mapped
|
|
|
|
* to the same IRQ.
|
|
|
|
*/
|
|
|
|
if (sc->sc_model == ESS_1887 &&
|
|
|
|
sc->sc_audio1.irq == sc->sc_audio2.irq &&
|
1999-03-18 07:31:36 +03:00
|
|
|
sc->sc_audio1.irq != -1 &&
|
1999-03-16 16:06:35 +03:00
|
|
|
ESS_IRQ12_VALID(sc->sc_audio1.irq))
|
|
|
|
goto irq_not1888;
|
|
|
|
|
|
|
|
/* Check that requested IRQ lines are valid and different. */
|
1999-03-18 07:31:36 +03:00
|
|
|
if (sc->sc_audio1.irq != -1 &&
|
|
|
|
!ESS_IRQ1_VALID(sc->sc_audio1.irq)) {
|
1999-03-16 16:06:35 +03:00
|
|
|
printf("ess: record irq %d invalid\n", sc->sc_audio1.irq);
|
1998-07-31 19:17:17 +04:00
|
|
|
return (0);
|
1999-03-16 16:06:35 +03:00
|
|
|
}
|
|
|
|
if (sc->sc_model != ESS_1788) {
|
1999-03-18 07:31:36 +03:00
|
|
|
if (sc->sc_audio2.irq != -1 &&
|
|
|
|
!ESS_IRQ2_VALID(sc->sc_audio2.irq)) {
|
1999-03-16 16:06:35 +03:00
|
|
|
printf("ess: play irq %d invalid\n", sc->sc_audio2.irq);
|
1999-03-02 23:36:50 +03:00
|
|
|
return (0);
|
|
|
|
}
|
1999-03-18 07:31:36 +03:00
|
|
|
if (sc->sc_audio1.irq == sc->sc_audio2.irq &&
|
|
|
|
sc->sc_audio1.irq != -1) {
|
1999-03-16 16:06:35 +03:00
|
|
|
printf("ess: play and record irq both %d\n",
|
|
|
|
sc->sc_audio1.irq);
|
1999-03-02 23:36:50 +03:00
|
|
|
return (0);
|
|
|
|
}
|
1998-06-30 00:56:21 +04:00
|
|
|
}
|
|
|
|
|
1999-03-16 16:06:35 +03:00
|
|
|
irq_not1888:
|
1998-06-30 00:56:21 +04:00
|
|
|
/* XXX should we check IRQs as well? */
|
|
|
|
|
1998-07-30 18:11:42 +04:00
|
|
|
return (1);
|
1998-06-30 00:56:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Attach hardware to driver, attach hardware driver to audio
|
1998-07-31 19:17:17 +04:00
|
|
|
* pseudo-device driver.
|
1998-06-30 00:56:21 +04:00
|
|
|
*/
|
|
|
|
void
|
1998-07-30 18:11:42 +04:00
|
|
|
essattach(sc)
|
|
|
|
struct ess_softc *sc;
|
1998-06-30 00:56:21 +04:00
|
|
|
{
|
1998-08-23 02:55:09 +04:00
|
|
|
struct audio_attach_args arg;
|
1998-06-30 00:56:21 +04:00
|
|
|
struct audio_params pparams, rparams;
|
1999-03-16 16:06:35 +03:00
|
|
|
int i;
|
|
|
|
u_int v;
|
1998-06-30 00:56:21 +04:00
|
|
|
|
1998-07-30 18:11:42 +04:00
|
|
|
if (ess_setup_sc(sc, 0)) {
|
1999-03-18 07:31:36 +03:00
|
|
|
printf(": setup failed\n");
|
1998-06-30 00:56:21 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-03-18 07:31:36 +03:00
|
|
|
printf(": ESS Technology ES%s [version 0x%04x]\n",
|
|
|
|
essmodel[sc->sc_model], sc->sc_version);
|
|
|
|
|
1999-03-18 09:04:21 +03:00
|
|
|
sc->sc_audio1.irq = -1;
|
|
|
|
sc->sc_audio2.irq = -1;
|
|
|
|
|
1999-03-18 07:31:36 +03:00
|
|
|
sc->sc_audio1.polled = sc->sc_audio1.irq == -1;
|
|
|
|
if (!sc->sc_audio1.polled) {
|
|
|
|
sc->sc_audio1.ih = isa_intr_establish(sc->sc_ic,
|
|
|
|
sc->sc_audio1.irq, sc->sc_audio1.ist, IPL_AUDIO,
|
|
|
|
ess_audio1_intr, sc);
|
|
|
|
printf("%s: audio1 interrupting at irq %d\n",
|
|
|
|
sc->sc_dev.dv_xname, sc->sc_audio1.irq);
|
|
|
|
} else
|
|
|
|
printf("%s: audio1 polled\n", sc->sc_dev.dv_xname);
|
1999-03-16 16:06:35 +03:00
|
|
|
if (isa_dmamap_create(sc->sc_ic, sc->sc_audio1.drq,
|
|
|
|
MAX_ISADMA, BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW)) {
|
1998-06-30 00:56:21 +04:00
|
|
|
printf("%s: can't create map for drq %d\n",
|
1999-03-16 16:06:35 +03:00
|
|
|
sc->sc_dev.dv_xname, sc->sc_audio1.drq);
|
1998-06-30 00:56:21 +04:00
|
|
|
return;
|
|
|
|
}
|
1999-03-02 23:36:50 +03:00
|
|
|
|
|
|
|
if (sc->sc_model != ESS_1788) {
|
1999-03-18 07:31:36 +03:00
|
|
|
sc->sc_audio2.polled = sc->sc_audio2.irq == -1;
|
|
|
|
if (!sc->sc_audio2.polled) {
|
|
|
|
sc->sc_audio2.ih = isa_intr_establish(sc->sc_ic,
|
|
|
|
sc->sc_audio2.irq, sc->sc_audio2.ist, IPL_AUDIO,
|
|
|
|
ess_audio2_intr, sc);
|
|
|
|
printf("%s: audio2 interrupting at irq %d\n",
|
|
|
|
sc->sc_dev.dv_xname, sc->sc_audio2.irq);
|
|
|
|
} else
|
|
|
|
printf("%s: audio2 polled\n", sc->sc_dev.dv_xname);
|
1999-03-16 16:06:35 +03:00
|
|
|
if (isa_dmamap_create(sc->sc_ic, sc->sc_audio2.drq,
|
|
|
|
MAX_ISADMA, BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW)) {
|
1999-03-02 23:36:50 +03:00
|
|
|
printf("%s: can't create map for drq %d\n",
|
1999-03-16 16:06:35 +03:00
|
|
|
sc->sc_dev.dv_xname, sc->sc_audio2.drq);
|
1999-03-02 23:36:50 +03:00
|
|
|
return;
|
|
|
|
}
|
1998-06-30 00:56:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set record and play parameters to default values defined in
|
|
|
|
* generic audio driver.
|
|
|
|
*/
|
|
|
|
pparams = audio_default;
|
|
|
|
rparams = audio_default;
|
1999-03-16 16:06:35 +03:00
|
|
|
ess_set_params(sc, AUMODE_RECORD|AUMODE_PLAY, 0, &pparams, &rparams);
|
1998-06-30 00:56:21 +04:00
|
|
|
|
|
|
|
/* Do a hardware reset on the mixer. */
|
|
|
|
ess_write_mix_reg(sc, ESS_MIX_RESET, ESS_MIX_RESET);
|
|
|
|
|
1999-03-16 16:06:35 +03:00
|
|
|
/*
|
|
|
|
* Set volume of Audio 1 to zero and disable Audio 1 DAC input
|
|
|
|
* to playback mixer, since playback is always through Audio 2.
|
|
|
|
*/
|
|
|
|
if (sc->sc_model != ESS_1788)
|
|
|
|
ess_write_mix_reg(sc, ESS_MREG_VOLUME_VOICE, 0);
|
|
|
|
ess_wdsp(sc, ESS_ACMD_DISABLE_SPKR);
|
1998-06-30 00:56:21 +04:00
|
|
|
|
1999-03-02 23:36:50 +03:00
|
|
|
if (sc->sc_model == ESS_1788) {
|
1999-03-16 16:06:35 +03:00
|
|
|
ess_write_mix_reg(sc, ESS_MREG_ADC_SOURCE, ESS_SOURCE_MIC);
|
|
|
|
sc->in_port = ESS_SOURCE_MIC;
|
|
|
|
sc->ndevs = ESS_1788_NDEVS;
|
1999-03-02 23:36:50 +03:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Set hardware record source to use output of the record
|
|
|
|
* mixer. We do the selection of record source in software by
|
|
|
|
* setting the gain of the unused sources to zero. (See
|
|
|
|
* ess_set_in_ports.)
|
|
|
|
*/
|
|
|
|
ess_write_mix_reg(sc, ESS_MREG_ADC_SOURCE, ESS_SOURCE_MIXER);
|
1999-03-16 16:06:35 +03:00
|
|
|
sc->in_mask = 1 << ESS_MIC_REC_VOL;
|
|
|
|
sc->ndevs = ESS_1888_NDEVS;
|
|
|
|
ess_clear_mreg_bits(sc, ESS_MREG_AUDIO2_CTRL2, 0x10);
|
|
|
|
ess_set_mreg_bits(sc, ESS_MREG_AUDIO2_CTRL2, 0x08);
|
1999-03-02 23:36:50 +03:00
|
|
|
}
|
1998-06-30 00:56:21 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set gain on each mixer device to a sensible value.
|
|
|
|
* Devices not normally used are turned off, and other devices
|
1998-08-26 16:10:22 +04:00
|
|
|
* are set to 50% volume.
|
1998-06-30 00:56:21 +04:00
|
|
|
*/
|
1999-03-02 23:36:50 +03:00
|
|
|
for (i = 0; i < sc->ndevs; i++) {
|
1999-03-16 16:06:35 +03:00
|
|
|
switch (i) {
|
1998-06-30 00:56:21 +04:00
|
|
|
case ESS_MIC_PLAY_VOL:
|
|
|
|
case ESS_LINE_PLAY_VOL:
|
|
|
|
case ESS_CD_PLAY_VOL:
|
|
|
|
case ESS_AUXB_PLAY_VOL:
|
|
|
|
case ESS_DAC_REC_VOL:
|
|
|
|
case ESS_LINE_REC_VOL:
|
|
|
|
case ESS_SYNTH_REC_VOL:
|
|
|
|
case ESS_CD_REC_VOL:
|
|
|
|
case ESS_AUXB_REC_VOL:
|
|
|
|
v = 0;
|
|
|
|
break;
|
|
|
|
default:
|
1998-08-26 16:10:22 +04:00
|
|
|
v = ESS_4BIT_GAIN(AUDIO_MAX_GAIN / 2);
|
1998-06-30 00:56:21 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
sc->gain[i][ESS_LEFT] = sc->gain[i][ESS_RIGHT] = v;
|
|
|
|
ess_set_gain(sc, i, 1);
|
|
|
|
}
|
|
|
|
|
1998-07-31 19:17:17 +04:00
|
|
|
ess_setup(sc);
|
1998-07-30 18:11:42 +04:00
|
|
|
|
1998-06-30 00:56:21 +04:00
|
|
|
/* Disable the speaker until the device is opened. */
|
|
|
|
ess_speaker_off(sc);
|
|
|
|
sc->spkr_state = SPKR_OFF;
|
|
|
|
|
|
|
|
sprintf(ess_device.name, "ES%s", essmodel[sc->sc_model]);
|
|
|
|
sprintf(ess_device.version, "0x%04x", sc->sc_version);
|
|
|
|
|
1999-03-16 16:06:35 +03:00
|
|
|
if (sc->sc_model == ESS_1788)
|
|
|
|
audio_attach_mi(&ess_1788_hw_if, sc, &sc->sc_dev);
|
1999-03-02 23:36:50 +03:00
|
|
|
else
|
1999-03-16 16:06:35 +03:00
|
|
|
audio_attach_mi(&ess_1888_hw_if, sc, &sc->sc_dev);
|
1998-07-30 18:11:42 +04:00
|
|
|
|
1998-08-23 02:55:09 +04:00
|
|
|
arg.type = AUDIODEV_TYPE_OPL;
|
|
|
|
arg.hwif = 0;
|
|
|
|
arg.hdl = 0;
|
|
|
|
(void)config_found(&sc->sc_dev, &arg, audioprint);
|
|
|
|
|
1998-07-30 18:11:42 +04:00
|
|
|
#ifdef AUDIO_DEBUG
|
1998-08-26 17:08:44 +04:00
|
|
|
if (essdebug > 0)
|
|
|
|
ess_printsc(sc);
|
1998-07-30 18:11:42 +04:00
|
|
|
#endif
|
1998-06-30 00:56:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Various routines to interface to higher level audio driver
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
|
|
|
ess_open(addr, flags)
|
|
|
|
void *addr;
|
|
|
|
int flags;
|
|
|
|
{
|
|
|
|
struct ess_softc *sc = addr;
|
|
|
|
|
1999-03-16 16:06:35 +03:00
|
|
|
DPRINTF(("ess_open: sc=%p\n", sc));
|
1998-06-30 00:56:21 +04:00
|
|
|
|
|
|
|
if (sc->sc_open != 0 || ess_reset(sc) != 0)
|
|
|
|
return ENXIO;
|
|
|
|
|
1998-08-04 17:14:42 +04:00
|
|
|
ess_setup(sc); /* because we did a reset */
|
1998-06-30 00:56:21 +04:00
|
|
|
|
|
|
|
sc->sc_open = 1;
|
|
|
|
|
|
|
|
DPRINTF(("ess_open: opened\n"));
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-03-02 23:36:50 +03:00
|
|
|
ess_1788_close(addr)
|
1998-06-30 00:56:21 +04:00
|
|
|
void *addr;
|
|
|
|
{
|
|
|
|
struct ess_softc *sc = addr;
|
|
|
|
|
1999-03-02 23:36:50 +03:00
|
|
|
DPRINTF(("ess_1788_close: sc=%p\n", sc));
|
1998-06-30 00:56:21 +04:00
|
|
|
|
|
|
|
ess_speaker_off(sc);
|
|
|
|
sc->spkr_state = SPKR_OFF;
|
1999-03-16 16:06:35 +03:00
|
|
|
|
1999-03-17 04:06:17 +03:00
|
|
|
ess_audio1_halt(sc);
|
1999-03-16 16:06:35 +03:00
|
|
|
|
1999-03-02 23:36:50 +03:00
|
|
|
sc->sc_open = 0;
|
1999-03-16 16:06:35 +03:00
|
|
|
DPRINTF(("ess_1788_close: closed\n"));
|
1999-03-02 23:36:50 +03:00
|
|
|
}
|
1999-02-21 02:28:37 +03:00
|
|
|
|
1999-03-02 23:36:50 +03:00
|
|
|
void
|
|
|
|
ess_1888_close(addr)
|
|
|
|
void *addr;
|
|
|
|
{
|
|
|
|
struct ess_softc *sc = addr;
|
|
|
|
|
1999-03-16 16:06:35 +03:00
|
|
|
DPRINTF(("ess_1888_close: sc=%p\n", sc));
|
1999-03-02 23:36:50 +03:00
|
|
|
|
|
|
|
ess_speaker_off(sc);
|
|
|
|
sc->spkr_state = SPKR_OFF;
|
1999-03-16 16:06:35 +03:00
|
|
|
|
1999-03-17 04:06:17 +03:00
|
|
|
ess_audio1_halt(sc);
|
|
|
|
ess_audio2_halt(sc);
|
1999-03-16 16:06:35 +03:00
|
|
|
|
1999-02-21 02:28:37 +03:00
|
|
|
sc->sc_open = 0;
|
1999-03-16 16:06:35 +03:00
|
|
|
DPRINTF(("ess_1888_close: closed\n"));
|
1998-06-30 00:56:21 +04:00
|
|
|
}
|
|
|
|
|
1998-08-04 17:14:42 +04:00
|
|
|
/*
|
|
|
|
* Wait for FIFO to drain, and analog section to settle.
|
1999-03-02 23:36:50 +03:00
|
|
|
* XXX should check FIFO empty bit.
|
1998-08-04 17:14:42 +04:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
ess_drain(addr)
|
|
|
|
void *addr;
|
|
|
|
{
|
1998-08-09 01:37:00 +04:00
|
|
|
tsleep(addr, PWAIT | PCATCH, "essdr", hz/20); /* XXX */
|
1998-08-04 17:14:42 +04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1998-08-26 16:10:22 +04:00
|
|
|
/* XXX should use reference count */
|
1998-07-31 19:17:17 +04:00
|
|
|
int
|
|
|
|
ess_speaker_ctl(addr, newstate)
|
|
|
|
void *addr;
|
|
|
|
int newstate;
|
|
|
|
{
|
|
|
|
struct ess_softc *sc = addr;
|
|
|
|
|
|
|
|
if ((newstate == SPKR_ON) && (sc->spkr_state == SPKR_OFF)) {
|
|
|
|
ess_speaker_on(sc);
|
|
|
|
sc->spkr_state = SPKR_ON;
|
|
|
|
}
|
|
|
|
if ((newstate == SPKR_OFF) && (sc->spkr_state == SPKR_ON)) {
|
|
|
|
ess_speaker_off(sc);
|
|
|
|
sc->spkr_state = SPKR_OFF;
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1998-06-30 00:56:21 +04:00
|
|
|
int
|
|
|
|
ess_getdev(addr, retp)
|
|
|
|
void *addr;
|
|
|
|
struct audio_device *retp;
|
|
|
|
{
|
|
|
|
*retp = ess_device;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ess_query_encoding(addr, fp)
|
|
|
|
void *addr;
|
|
|
|
struct audio_encoding *fp;
|
|
|
|
{
|
|
|
|
/*struct ess_softc *sc = addr;*/
|
|
|
|
|
|
|
|
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);
|
1998-07-31 19:17:17 +04:00
|
|
|
fp->encoding = AUDIO_ENCODING_ALAW;
|
1998-06-30 00:56:21 +04:00
|
|
|
fp->precision = 8;
|
|
|
|
fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
|
|
|
|
return (0);
|
|
|
|
case 3:
|
1998-07-31 19:17:17 +04:00
|
|
|
strcpy(fp->name, AudioEslinear);
|
|
|
|
fp->encoding = AUDIO_ENCODING_SLINEAR;
|
1998-06-30 00:56:21 +04:00
|
|
|
fp->precision = 8;
|
|
|
|
fp->flags = 0;
|
|
|
|
return (0);
|
1999-03-02 23:36:50 +03:00
|
|
|
case 4:
|
1998-06-30 00:56:21 +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 = 0;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-08-09 00:55:36 +04:00
|
|
|
ess_set_params(addr, setmode, usemode, play, rec)
|
1998-06-30 00:56:21 +04:00
|
|
|
void *addr;
|
1998-08-09 00:55:36 +04:00
|
|
|
int setmode, usemode;
|
|
|
|
struct audio_params *play, *rec;
|
1998-06-30 00:56:21 +04:00
|
|
|
{
|
|
|
|
struct ess_softc *sc = addr;
|
1998-08-09 00:55:36 +04:00
|
|
|
struct audio_params *p;
|
|
|
|
int mode;
|
1998-08-10 19:32:18 +04:00
|
|
|
int rate;
|
1998-06-30 00:56:21 +04:00
|
|
|
|
1998-07-31 19:17:17 +04:00
|
|
|
DPRINTF(("ess_set_params: set=%d use=%d\n", setmode, usemode));
|
|
|
|
|
1998-08-09 08:58:08 +04:00
|
|
|
/*
|
|
|
|
* The ES1887 manual (page 39, `Full-Duplex DMA Mode') claims that in
|
|
|
|
* full-duplex operation the sample rates must be the same for both
|
1998-08-09 08:59:55 +04:00
|
|
|
* channels. This appears to be false; the only bit in common is the
|
|
|
|
* clock source selection. However, we'll be conservative here.
|
|
|
|
* - mycroft
|
1998-08-09 08:58:08 +04:00
|
|
|
*/
|
1998-08-10 19:32:18 +04:00
|
|
|
if (play->sample_rate != rec->sample_rate &&
|
|
|
|
usemode == (AUMODE_PLAY | AUMODE_RECORD)) {
|
|
|
|
if (setmode == AUMODE_PLAY) {
|
1998-08-09 08:14:47 +04:00
|
|
|
rec->sample_rate = play->sample_rate;
|
|
|
|
setmode |= AUMODE_RECORD;
|
1998-08-10 19:32:18 +04:00
|
|
|
} else if (setmode == AUMODE_RECORD) {
|
1998-08-09 08:14:47 +04:00
|
|
|
play->sample_rate = rec->sample_rate;
|
|
|
|
setmode |= AUMODE_PLAY;
|
|
|
|
} else
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
|
1998-08-09 10:38:30 +04:00
|
|
|
for (mode = AUMODE_RECORD; mode != -1;
|
|
|
|
mode = mode == AUMODE_RECORD ? AUMODE_PLAY : -1) {
|
1998-06-30 00:56:21 +04:00
|
|
|
if ((setmode & mode) == 0)
|
|
|
|
continue;
|
|
|
|
|
1998-08-09 00:55:36 +04:00
|
|
|
p = mode == AUMODE_PLAY ? play : rec;
|
1998-06-30 00:56:21 +04:00
|
|
|
|
1998-08-09 10:38:30 +04:00
|
|
|
if (p->sample_rate < ESS_MINRATE ||
|
|
|
|
p->sample_rate > ESS_MAXRATE ||
|
|
|
|
(p->precision != 8 && p->precision != 16) ||
|
|
|
|
(p->channels != 1 && p->channels != 2))
|
|
|
|
return (EINVAL);
|
1998-06-30 00:56:21 +04:00
|
|
|
|
1998-08-09 10:38:30 +04:00
|
|
|
p->factor = 1;
|
|
|
|
p->sw_code = 0;
|
1998-06-30 00:56:21 +04:00
|
|
|
switch (p->encoding) {
|
|
|
|
case AUDIO_ENCODING_SLINEAR_BE:
|
|
|
|
case AUDIO_ENCODING_ULINEAR_BE:
|
|
|
|
if (p->precision == 16)
|
1998-08-09 10:38:30 +04:00
|
|
|
p->sw_code = swap_bytes;
|
|
|
|
break;
|
|
|
|
case AUDIO_ENCODING_SLINEAR_LE:
|
1998-06-30 00:56:21 +04:00
|
|
|
case AUDIO_ENCODING_ULINEAR_LE:
|
|
|
|
break;
|
|
|
|
case AUDIO_ENCODING_ULAW:
|
1998-08-09 10:38:30 +04:00
|
|
|
if (mode == AUMODE_PLAY) {
|
|
|
|
p->factor = 2;
|
|
|
|
p->sw_code = mulaw_to_ulinear16;
|
|
|
|
} else
|
|
|
|
p->sw_code = ulinear8_to_mulaw;
|
|
|
|
break;
|
1998-06-30 00:56:21 +04:00
|
|
|
case AUDIO_ENCODING_ALAW:
|
1998-08-09 10:38:30 +04:00
|
|
|
if (mode == AUMODE_PLAY) {
|
|
|
|
p->factor = 2;
|
|
|
|
p->sw_code = alaw_to_ulinear16;
|
|
|
|
} else
|
|
|
|
p->sw_code = ulinear8_to_alaw;
|
|
|
|
break;
|
1998-06-30 00:56:21 +04:00
|
|
|
default:
|
1998-08-09 10:38:30 +04:00
|
|
|
return (EINVAL);
|
|
|
|
}
|
1998-06-30 00:56:21 +04:00
|
|
|
}
|
|
|
|
|
1998-08-10 19:32:18 +04:00
|
|
|
if (usemode == AUMODE_RECORD)
|
|
|
|
rate = rec->sample_rate;
|
|
|
|
else
|
|
|
|
rate = play->sample_rate;
|
|
|
|
|
1999-03-16 16:06:35 +03:00
|
|
|
ess_write_x_reg(sc, ESS_XCMD_SAMPLE_RATE, ess_srtotc(rate));
|
|
|
|
ess_write_x_reg(sc, ESS_XCMD_FILTER_CLOCK, ess_srtofc(rate));
|
|
|
|
|
1999-03-02 23:36:50 +03:00
|
|
|
if (sc->sc_model != ESS_1788) {
|
|
|
|
ess_write_mix_reg(sc, ESS_MREG_SAMPLE_RATE, ess_srtotc(rate));
|
|
|
|
ess_write_mix_reg(sc, ESS_MREG_FILTER_CLOCK, ess_srtofc(rate));
|
|
|
|
}
|
1998-08-10 19:32:18 +04:00
|
|
|
|
1998-06-30 00:56:21 +04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1999-03-16 16:32:25 +03:00
|
|
|
ess_audio1_trigger_output(addr, start, end, blksize, intr, arg, param)
|
1999-03-02 23:36:50 +03:00
|
|
|
void *addr;
|
|
|
|
void *start, *end;
|
|
|
|
int blksize;
|
|
|
|
void (*intr) __P((void *));
|
|
|
|
void *arg;
|
|
|
|
struct audio_params *param;
|
|
|
|
{
|
|
|
|
struct ess_softc *sc = addr;
|
1999-03-17 04:06:17 +03:00
|
|
|
u_int8_t reg;
|
1999-03-02 23:36:50 +03:00
|
|
|
|
1999-03-16 16:32:25 +03:00
|
|
|
DPRINTFN(1, ("ess_audio1_trigger_output: sc=%p start=%p end=%p blksize=%d intr=%p(%p)\n",
|
1999-03-16 16:06:35 +03:00
|
|
|
addr, start, end, blksize, intr, arg));
|
1999-03-02 23:36:50 +03:00
|
|
|
|
1999-03-16 16:06:35 +03:00
|
|
|
if (sc->sc_audio1.active)
|
1999-03-16 16:32:25 +03:00
|
|
|
panic("ess_audio1_trigger_output: already running");
|
1999-03-02 23:36:50 +03:00
|
|
|
|
1999-03-17 04:06:17 +03:00
|
|
|
sc->sc_audio1.active = 1;
|
1999-03-16 16:06:35 +03:00
|
|
|
sc->sc_audio1.intr = intr;
|
|
|
|
sc->sc_audio1.arg = arg;
|
1999-03-18 07:31:36 +03:00
|
|
|
if (sc->sc_audio1.polled) {
|
1999-03-18 09:04:21 +03:00
|
|
|
sc->sc_audio1.dmapos = 0;
|
|
|
|
sc->sc_audio1.buffersize = (char *)end - (char *)start;
|
1999-03-18 07:31:36 +03:00
|
|
|
sc->sc_audio1.dmacount = 0;
|
|
|
|
sc->sc_audio1.blksize = blksize;
|
|
|
|
timeout(ess_audio1_poll, sc, hz/30);
|
|
|
|
}
|
1999-03-02 23:36:50 +03:00
|
|
|
|
1999-03-17 04:06:17 +03:00
|
|
|
reg = ess_read_x_reg(sc, ESS_XCMD_AUDIO_CTRL);
|
1999-03-02 23:36:50 +03:00
|
|
|
if (param->channels == 2) {
|
1999-03-17 04:06:17 +03:00
|
|
|
reg &= ~ESS_AUDIO_CTRL_MONO;
|
|
|
|
reg |= ESS_AUDIO_CTRL_STEREO;
|
1999-03-02 23:36:50 +03:00
|
|
|
} else {
|
1999-03-17 04:06:17 +03:00
|
|
|
reg |= ESS_AUDIO_CTRL_MONO;
|
|
|
|
reg &= ~ESS_AUDIO_CTRL_STEREO;
|
1999-03-02 23:36:50 +03:00
|
|
|
}
|
1999-03-17 04:06:17 +03:00
|
|
|
ess_write_x_reg(sc, ESS_XCMD_AUDIO_CTRL, reg);
|
1999-03-02 23:36:50 +03:00
|
|
|
|
1999-03-17 04:06:17 +03:00
|
|
|
reg = ess_read_x_reg(sc, ESS_XCMD_AUDIO1_CTRL1);
|
|
|
|
if (param->precision * param->factor == 16)
|
|
|
|
reg |= ESS_AUDIO1_CTRL1_FIFO_SIZE;
|
|
|
|
else
|
|
|
|
reg &= ~ESS_AUDIO1_CTRL1_FIFO_SIZE;
|
|
|
|
if (param->channels == 2)
|
|
|
|
reg |= ESS_AUDIO1_CTRL1_FIFO_STEREO;
|
|
|
|
else
|
|
|
|
reg &= ~ESS_AUDIO1_CTRL1_FIFO_STEREO;
|
1999-03-16 16:06:35 +03:00
|
|
|
if (param->encoding == AUDIO_ENCODING_SLINEAR_BE ||
|
|
|
|
param->encoding == AUDIO_ENCODING_SLINEAR_LE)
|
1999-03-17 04:06:17 +03:00
|
|
|
reg |= ESS_AUDIO1_CTRL1_FIFO_SIGNED;
|
1999-03-16 16:06:35 +03:00
|
|
|
else
|
1999-03-17 04:06:17 +03:00
|
|
|
reg &= ~ESS_AUDIO1_CTRL1_FIFO_SIGNED;
|
|
|
|
reg |= ESS_AUDIO1_CTRL1_FIFO_CONNECT;
|
|
|
|
ess_write_x_reg(sc, ESS_XCMD_AUDIO1_CTRL1, reg);
|
1999-03-02 23:36:50 +03:00
|
|
|
|
1999-03-16 16:06:35 +03:00
|
|
|
isa_dmastart(sc->sc_ic, sc->sc_audio1.drq, start,
|
|
|
|
(char *)end - (char *)start, NULL,
|
|
|
|
DMAMODE_WRITE | DMAMODE_LOOPDEMAND, BUS_DMA_NOWAIT);
|
|
|
|
|
1999-03-02 23:36:50 +03:00
|
|
|
/* Program transfer count registers with 2's complement of count. */
|
|
|
|
blksize = -blksize;
|
|
|
|
ess_write_x_reg(sc, ESS_XCMD_XFER_COUNTLO, blksize);
|
|
|
|
ess_write_x_reg(sc, ESS_XCMD_XFER_COUNTHI, blksize >> 8);
|
|
|
|
|
1999-03-16 17:17:00 +03:00
|
|
|
/* Use 4 bytes per output DMA. */
|
1999-03-17 04:06:17 +03:00
|
|
|
ess_set_xreg_bits(sc, ESS_XCMD_DEMAND_CTRL, ESS_DEMAND_CTRL_DEMAND_4);
|
1999-03-02 23:36:50 +03:00
|
|
|
|
|
|
|
/* Start auto-init DMA */
|
1999-03-16 16:06:35 +03:00
|
|
|
ess_wdsp(sc, ESS_ACMD_ENABLE_SPKR);
|
1999-03-17 04:06:17 +03:00
|
|
|
reg = ess_read_x_reg(sc, ESS_XCMD_AUDIO1_CTRL2);
|
|
|
|
reg &= ~(ESS_AUDIO1_CTRL2_DMA_READ | ESS_AUDIO1_CTRL2_ADC_ENABLE);
|
|
|
|
reg |= ESS_AUDIO1_CTRL2_FIFO_ENABLE | ESS_AUDIO1_CTRL2_AUTO_INIT;
|
|
|
|
ess_write_x_reg(sc, ESS_XCMD_AUDIO1_CTRL2, reg);
|
1999-03-02 23:36:50 +03:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1999-03-16 16:32:25 +03:00
|
|
|
ess_audio2_trigger_output(addr, start, end, blksize, intr, arg, param)
|
1998-06-30 00:56:21 +04:00
|
|
|
void *addr;
|
1998-08-10 19:32:18 +04:00
|
|
|
void *start, *end;
|
|
|
|
int blksize;
|
|
|
|
void (*intr) __P((void *));
|
|
|
|
void *arg;
|
|
|
|
struct audio_params *param;
|
1998-06-30 00:56:21 +04:00
|
|
|
{
|
|
|
|
struct ess_softc *sc = addr;
|
1999-03-17 04:06:17 +03:00
|
|
|
u_int8_t reg;
|
1998-06-30 00:56:21 +04:00
|
|
|
|
1999-03-16 16:32:25 +03:00
|
|
|
DPRINTFN(1, ("ess_audio2_trigger_output: sc=%p start=%p end=%p blksize=%d intr=%p(%p)\n",
|
1999-03-16 16:06:35 +03:00
|
|
|
addr, start, end, blksize, intr, arg));
|
1998-08-10 19:32:18 +04:00
|
|
|
|
1999-03-16 16:06:35 +03:00
|
|
|
if (sc->sc_audio2.active)
|
1999-03-16 16:32:25 +03:00
|
|
|
panic("ess_audio2_trigger_output: already running");
|
1998-08-10 19:32:18 +04:00
|
|
|
|
1999-03-17 04:06:17 +03:00
|
|
|
sc->sc_audio2.active = 1;
|
1999-03-16 16:06:35 +03:00
|
|
|
sc->sc_audio2.intr = intr;
|
|
|
|
sc->sc_audio2.arg = arg;
|
1999-03-18 07:31:36 +03:00
|
|
|
if (sc->sc_audio2.polled) {
|
1999-03-18 09:04:21 +03:00
|
|
|
sc->sc_audio2.dmapos = 0;
|
|
|
|
sc->sc_audio2.buffersize = (char *)end - (char *)start;
|
1999-03-18 07:31:36 +03:00
|
|
|
sc->sc_audio2.dmacount = 0;
|
|
|
|
sc->sc_audio2.blksize = blksize;
|
|
|
|
timeout(ess_audio2_poll, sc, hz/30);
|
|
|
|
}
|
1998-06-30 00:56:21 +04:00
|
|
|
|
1999-03-17 04:06:17 +03:00
|
|
|
reg = ess_read_mix_reg(sc, ESS_MREG_AUDIO2_CTRL2);
|
1998-08-10 19:32:18 +04:00
|
|
|
if (param->precision * param->factor == 16)
|
1999-03-17 04:06:17 +03:00
|
|
|
reg |= ESS_AUDIO2_CTRL2_FIFO_SIZE;
|
1998-08-09 10:38:30 +04:00
|
|
|
else
|
1999-03-17 04:06:17 +03:00
|
|
|
reg &= ~ESS_AUDIO2_CTRL2_FIFO_SIZE;
|
1998-08-10 19:32:18 +04:00
|
|
|
if (param->channels == 2)
|
1999-03-17 04:06:17 +03:00
|
|
|
reg |= ESS_AUDIO2_CTRL2_CHANNELS;
|
1998-08-09 10:38:30 +04:00
|
|
|
else
|
1999-03-17 04:06:17 +03:00
|
|
|
reg &= ~ESS_AUDIO2_CTRL2_CHANNELS;
|
1998-08-10 19:32:18 +04:00
|
|
|
if (param->encoding == AUDIO_ENCODING_SLINEAR_BE ||
|
1999-03-16 16:06:35 +03:00
|
|
|
param->encoding == AUDIO_ENCODING_SLINEAR_LE)
|
1999-03-17 04:06:17 +03:00
|
|
|
reg |= ESS_AUDIO2_CTRL2_FIFO_SIGNED;
|
1998-08-09 10:38:30 +04:00
|
|
|
else
|
1999-03-17 04:06:17 +03:00
|
|
|
reg &= ~ESS_AUDIO2_CTRL2_FIFO_SIGNED;
|
|
|
|
ess_write_mix_reg(sc, ESS_MREG_AUDIO2_CTRL2, reg);
|
1998-08-04 17:14:42 +04:00
|
|
|
|
1999-03-16 16:06:35 +03:00
|
|
|
isa_dmastart(sc->sc_ic, sc->sc_audio2.drq, start,
|
|
|
|
(char *)end - (char *)start, NULL,
|
|
|
|
DMAMODE_WRITE | DMAMODE_LOOPDEMAND, BUS_DMA_NOWAIT);
|
1998-06-30 00:56:21 +04:00
|
|
|
|
1999-03-16 16:06:35 +03:00
|
|
|
if (IS16BITDRQ(sc->sc_audio2.drq))
|
1998-08-10 19:32:18 +04:00
|
|
|
blksize >>= 1; /* use word count for 16 bit DMA */
|
1998-08-04 17:14:42 +04:00
|
|
|
/* Program transfer count registers with 2's complement of count. */
|
1998-08-10 19:32:18 +04:00
|
|
|
blksize = -blksize;
|
|
|
|
ess_write_mix_reg(sc, ESS_MREG_XFER_COUNTLO, blksize);
|
|
|
|
ess_write_mix_reg(sc, ESS_MREG_XFER_COUNTHI, blksize >> 8);
|
1998-06-30 00:56:21 +04:00
|
|
|
|
1999-03-17 04:06:17 +03:00
|
|
|
reg = ess_read_mix_reg(sc, ESS_MREG_AUDIO2_CTRL1);
|
1999-03-16 16:06:35 +03:00
|
|
|
if (IS16BITDRQ(sc->sc_audio2.drq))
|
1999-03-17 04:06:17 +03:00
|
|
|
reg |= ESS_AUDIO2_CTRL1_XFER_SIZE;
|
1998-08-09 10:52:57 +04:00
|
|
|
else
|
1999-03-17 04:06:17 +03:00
|
|
|
reg &= ~ESS_AUDIO2_CTRL1_XFER_SIZE;
|
|
|
|
reg |= ESS_AUDIO2_CTRL1_DEMAND_8;
|
|
|
|
reg |= ESS_AUDIO2_CTRL1_DAC_ENABLE | ESS_AUDIO2_CTRL1_FIFO_ENABLE |
|
|
|
|
ESS_AUDIO2_CTRL1_AUTO_INIT;
|
|
|
|
ess_write_mix_reg(sc, ESS_MREG_AUDIO2_CTRL1, reg);
|
1999-03-02 23:36:50 +03:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1999-03-16 16:32:25 +03:00
|
|
|
ess_audio1_trigger_input(addr, start, end, blksize, intr, arg, param)
|
1999-03-02 23:36:50 +03:00
|
|
|
void *addr;
|
|
|
|
void *start, *end;
|
|
|
|
int blksize;
|
|
|
|
void (*intr) __P((void *));
|
|
|
|
void *arg;
|
|
|
|
struct audio_params *param;
|
|
|
|
{
|
|
|
|
struct ess_softc *sc = addr;
|
1999-03-17 04:06:17 +03:00
|
|
|
u_int8_t reg;
|
1999-03-02 23:36:50 +03:00
|
|
|
|
1999-03-16 16:32:25 +03:00
|
|
|
DPRINTFN(1, ("ess_audio1_trigger_input: sc=%p start=%p end=%p blksize=%d intr=%p(%p)\n",
|
1999-03-16 16:06:35 +03:00
|
|
|
addr, start, end, blksize, intr, arg));
|
1999-03-02 23:36:50 +03:00
|
|
|
|
1999-03-16 16:06:35 +03:00
|
|
|
if (sc->sc_audio1.active)
|
1999-03-16 16:32:25 +03:00
|
|
|
panic("ess_audio1_trigger_input: already running");
|
1999-03-02 23:36:50 +03:00
|
|
|
|
1999-03-17 04:06:17 +03:00
|
|
|
sc->sc_audio1.active = 1;
|
1999-03-16 16:06:35 +03:00
|
|
|
sc->sc_audio1.intr = intr;
|
|
|
|
sc->sc_audio1.arg = arg;
|
1999-03-18 07:31:36 +03:00
|
|
|
if (sc->sc_audio1.polled) {
|
1999-03-18 09:04:21 +03:00
|
|
|
sc->sc_audio1.dmapos = 0;
|
|
|
|
sc->sc_audio1.buffersize = (char *)end - (char *)start;
|
1999-03-18 07:31:36 +03:00
|
|
|
sc->sc_audio1.dmacount = 0;
|
|
|
|
sc->sc_audio1.blksize = blksize;
|
|
|
|
timeout(ess_audio1_poll, sc, hz/30);
|
|
|
|
}
|
1998-08-10 19:32:18 +04:00
|
|
|
|
1999-03-17 04:06:17 +03:00
|
|
|
reg = ess_read_x_reg(sc, ESS_XCMD_AUDIO_CTRL);
|
1998-08-10 19:32:18 +04:00
|
|
|
if (param->channels == 2) {
|
1999-03-17 04:06:17 +03:00
|
|
|
reg &= ~ESS_AUDIO_CTRL_MONO;
|
|
|
|
reg |= ESS_AUDIO_CTRL_STEREO;
|
1998-08-09 10:38:30 +04:00
|
|
|
} else {
|
1999-03-17 04:06:17 +03:00
|
|
|
reg |= ESS_AUDIO_CTRL_MONO;
|
|
|
|
reg &= ~ESS_AUDIO_CTRL_STEREO;
|
1998-08-09 10:38:30 +04:00
|
|
|
}
|
1999-03-17 04:06:17 +03:00
|
|
|
ess_write_x_reg(sc, ESS_XCMD_AUDIO_CTRL, reg);
|
1998-08-09 10:38:30 +04:00
|
|
|
|
1999-03-17 04:06:17 +03:00
|
|
|
reg = ess_read_x_reg(sc, ESS_XCMD_AUDIO1_CTRL1);
|
|
|
|
if (param->precision * param->factor == 16)
|
|
|
|
reg |= ESS_AUDIO1_CTRL1_FIFO_SIZE;
|
|
|
|
else
|
|
|
|
reg &= ~ESS_AUDIO1_CTRL1_FIFO_SIZE;
|
|
|
|
if (param->channels == 2)
|
|
|
|
reg |= ESS_AUDIO1_CTRL1_FIFO_STEREO;
|
|
|
|
else
|
|
|
|
reg &= ~ESS_AUDIO1_CTRL1_FIFO_STEREO;
|
1998-08-10 19:32:18 +04:00
|
|
|
if (param->encoding == AUDIO_ENCODING_SLINEAR_BE ||
|
1999-03-16 16:06:35 +03:00
|
|
|
param->encoding == AUDIO_ENCODING_SLINEAR_LE)
|
1999-03-17 04:06:17 +03:00
|
|
|
reg |= ESS_AUDIO1_CTRL1_FIFO_SIGNED;
|
1998-08-09 10:38:30 +04:00
|
|
|
else
|
1999-03-17 04:06:17 +03:00
|
|
|
reg &= ~ESS_AUDIO1_CTRL1_FIFO_SIGNED;
|
|
|
|
reg |= ESS_AUDIO1_CTRL1_FIFO_CONNECT;
|
|
|
|
ess_write_x_reg(sc, ESS_XCMD_AUDIO1_CTRL1, reg);
|
1998-08-09 10:38:30 +04:00
|
|
|
|
1999-03-16 16:06:35 +03:00
|
|
|
isa_dmastart(sc->sc_ic, sc->sc_audio1.drq, start,
|
|
|
|
(char *)end - (char *)start, NULL,
|
|
|
|
DMAMODE_READ | DMAMODE_LOOPDEMAND, BUS_DMA_NOWAIT);
|
1998-06-30 00:56:21 +04:00
|
|
|
|
1998-08-09 06:05:52 +04:00
|
|
|
/* Program transfer count registers with 2's complement of count. */
|
1998-08-10 19:32:18 +04:00
|
|
|
blksize = -blksize;
|
|
|
|
ess_write_x_reg(sc, ESS_XCMD_XFER_COUNTLO, blksize);
|
|
|
|
ess_write_x_reg(sc, ESS_XCMD_XFER_COUNTHI, blksize >> 8);
|
1998-06-30 00:56:21 +04:00
|
|
|
|
1998-08-09 10:52:57 +04:00
|
|
|
/* Use 4 bytes per input DMA. */
|
1999-03-17 04:06:17 +03:00
|
|
|
ess_set_xreg_bits(sc, ESS_XCMD_DEMAND_CTRL, ESS_DEMAND_CTRL_DEMAND_4);
|
1998-08-09 10:52:57 +04:00
|
|
|
|
1998-08-09 06:05:52 +04:00
|
|
|
/* Start auto-init DMA */
|
1999-03-17 04:06:17 +03:00
|
|
|
ess_wdsp(sc, ESS_ACMD_DISABLE_SPKR);
|
|
|
|
reg = ess_read_x_reg(sc, ESS_XCMD_AUDIO1_CTRL2);
|
|
|
|
reg |= ESS_AUDIO1_CTRL2_DMA_READ | ESS_AUDIO1_CTRL2_ADC_ENABLE;
|
|
|
|
reg |= ESS_AUDIO1_CTRL2_FIFO_ENABLE | ESS_AUDIO1_CTRL2_AUTO_INIT;
|
|
|
|
ess_write_x_reg(sc, ESS_XCMD_AUDIO1_CTRL2, reg);
|
1998-06-30 00:56:21 +04:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1999-03-16 16:06:35 +03:00
|
|
|
int
|
1999-03-17 04:06:17 +03:00
|
|
|
ess_audio1_halt(addr)
|
1998-06-30 00:56:21 +04:00
|
|
|
void *addr;
|
|
|
|
{
|
|
|
|
struct ess_softc *sc = addr;
|
|
|
|
|
1999-03-17 04:06:17 +03:00
|
|
|
DPRINTF(("ess_audio1_halt: sc=%p\n", sc));
|
1999-03-16 16:06:35 +03:00
|
|
|
|
|
|
|
if (sc->sc_audio1.active) {
|
|
|
|
ess_clear_xreg_bits(sc, ESS_XCMD_AUDIO1_CTRL2,
|
|
|
|
ESS_AUDIO1_CTRL2_FIFO_ENABLE);
|
|
|
|
isa_dmaabort(sc->sc_ic, sc->sc_audio1.drq);
|
1999-03-18 07:31:36 +03:00
|
|
|
if (sc->sc_audio1.polled)
|
|
|
|
untimeout(ess_audio1_poll, sc);
|
1999-03-16 16:06:35 +03:00
|
|
|
sc->sc_audio1.active = 0;
|
1999-03-02 23:36:50 +03:00
|
|
|
}
|
1998-06-30 00:56:21 +04:00
|
|
|
|
1999-03-02 23:36:50 +03:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1999-03-17 04:06:17 +03:00
|
|
|
ess_audio2_halt(addr)
|
1999-03-02 23:36:50 +03:00
|
|
|
void *addr;
|
|
|
|
{
|
|
|
|
struct ess_softc *sc = addr;
|
|
|
|
|
1999-03-17 04:06:17 +03:00
|
|
|
DPRINTF(("ess_audio2_halt: sc=%p\n", sc));
|
1999-03-16 16:06:35 +03:00
|
|
|
|
|
|
|
if (sc->sc_audio2.active) {
|
1999-02-21 02:28:37 +03:00
|
|
|
ess_clear_mreg_bits(sc, ESS_MREG_AUDIO2_CTRL1,
|
|
|
|
ESS_AUDIO2_CTRL1_DAC_ENABLE |
|
|
|
|
ESS_AUDIO2_CTRL1_FIFO_ENABLE);
|
1999-03-16 16:06:35 +03:00
|
|
|
isa_dmaabort(sc->sc_ic, sc->sc_audio2.drq);
|
1999-03-18 07:31:36 +03:00
|
|
|
if (sc->sc_audio2.polled)
|
|
|
|
untimeout(ess_audio2_poll, sc);
|
1999-03-16 16:06:35 +03:00
|
|
|
sc->sc_audio2.active = 0;
|
1999-03-02 23:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1998-06-30 00:56:21 +04:00
|
|
|
int
|
1999-03-16 16:32:25 +03:00
|
|
|
ess_audio1_intr(arg)
|
1998-06-30 00:56:21 +04:00
|
|
|
void *arg;
|
|
|
|
{
|
|
|
|
struct ess_softc *sc = arg;
|
1999-03-18 05:44:27 +03:00
|
|
|
u_int8_t reg;
|
1998-06-30 00:56:21 +04:00
|
|
|
|
1999-03-16 16:32:25 +03:00
|
|
|
DPRINTFN(1,("ess_audio1_intr: intr=%p\n", sc->sc_audio1.intr));
|
1998-06-30 00:56:21 +04:00
|
|
|
|
1999-03-18 05:44:27 +03:00
|
|
|
/* Check and clear interrupt on Audio1. */
|
|
|
|
reg = EREAD1(sc->sc_iot, sc->sc_ioh, ESS_DSP_RW_STATUS);
|
|
|
|
if ((reg & ESS_DSP_READ_OFLOW) == 0)
|
|
|
|
return (0);
|
|
|
|
reg = EREAD1(sc->sc_iot, sc->sc_ioh, ESS_CLEAR_INTR);
|
1998-08-09 06:05:52 +04:00
|
|
|
|
1999-03-16 16:32:25 +03:00
|
|
|
sc->sc_audio1.nintr++;
|
1998-06-30 00:56:21 +04:00
|
|
|
|
1999-03-17 04:06:17 +03:00
|
|
|
if (sc->sc_audio1.active) {
|
1999-03-16 16:32:25 +03:00
|
|
|
(*sc->sc_audio1.intr)(sc->sc_audio1.arg);
|
1999-03-17 04:06:17 +03:00
|
|
|
return (1);
|
|
|
|
} else
|
1999-03-16 16:06:35 +03:00
|
|
|
return (0);
|
1998-06-30 00:56:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1999-03-16 16:32:25 +03:00
|
|
|
ess_audio2_intr(arg)
|
1998-06-30 00:56:21 +04:00
|
|
|
void *arg;
|
|
|
|
{
|
|
|
|
struct ess_softc *sc = arg;
|
1999-03-18 05:44:27 +03:00
|
|
|
u_int8_t reg;
|
1998-06-30 00:56:21 +04:00
|
|
|
|
1999-03-16 16:32:25 +03:00
|
|
|
DPRINTFN(1,("ess_audio2_intr: intr=%p\n", sc->sc_audio2.intr));
|
1998-06-30 00:56:21 +04:00
|
|
|
|
1999-03-18 05:44:27 +03:00
|
|
|
/* Check and clear interrupt on Audio2. */
|
|
|
|
reg = ess_read_mix_reg(sc, ESS_MREG_AUDIO2_CTRL2);
|
|
|
|
if ((reg & ESS_AUDIO2_CTRL2_IRQ_LATCH) == 0)
|
|
|
|
return (0);
|
|
|
|
reg &= ~ESS_AUDIO2_CTRL2_IRQ_LATCH;
|
|
|
|
ess_write_mix_reg(sc, ESS_MREG_AUDIO2_CTRL2, reg);
|
1999-03-16 16:06:35 +03:00
|
|
|
|
1999-03-16 16:32:25 +03:00
|
|
|
sc->sc_audio2.nintr++;
|
1999-03-16 16:06:35 +03:00
|
|
|
|
1999-03-17 04:06:17 +03:00
|
|
|
if (sc->sc_audio2.active) {
|
1999-03-16 16:32:25 +03:00
|
|
|
(*sc->sc_audio2.intr)(sc->sc_audio2.arg);
|
1999-03-17 04:06:17 +03:00
|
|
|
return (1);
|
|
|
|
} else
|
1999-03-16 16:06:35 +03:00
|
|
|
return (0);
|
1998-06-30 00:56:21 +04:00
|
|
|
}
|
|
|
|
|
1999-03-18 07:31:36 +03:00
|
|
|
void
|
|
|
|
ess_audio1_poll(addr)
|
|
|
|
void *addr;
|
|
|
|
{
|
|
|
|
struct ess_softc *sc = addr;
|
|
|
|
int dmapos, dmacount;
|
|
|
|
|
|
|
|
if (!sc->sc_audio1.active)
|
|
|
|
return;
|
|
|
|
|
|
|
|
sc->sc_audio1.nintr++;
|
|
|
|
|
|
|
|
dmapos = isa_dmacount(sc->sc_ic, sc->sc_audio1.drq);
|
1999-03-18 09:04:21 +03:00
|
|
|
dmacount = sc->sc_audio1.dmapos - dmapos;
|
|
|
|
if (dmacount < 0)
|
1999-03-18 07:31:36 +03:00
|
|
|
dmacount += sc->sc_audio1.buffersize;
|
1999-03-18 09:04:21 +03:00
|
|
|
sc->sc_audio1.dmapos = dmapos;
|
|
|
|
#if 1
|
|
|
|
dmacount += sc->sc_audio1.dmacount;
|
1999-03-18 07:31:36 +03:00
|
|
|
while (dmacount > sc->sc_audio1.blksize) {
|
|
|
|
dmacount -= sc->sc_audio1.blksize;
|
|
|
|
(*sc->sc_audio1.intr)(sc->sc_audio1.arg);
|
|
|
|
}
|
|
|
|
sc->sc_audio1.dmacount = dmacount;
|
1999-03-18 09:04:21 +03:00
|
|
|
#else
|
|
|
|
(*sc->sc_audio1.intr)(sc->sc_audio1.arg, dmacount);
|
|
|
|
#endif
|
1999-03-18 07:31:36 +03:00
|
|
|
|
|
|
|
timeout(ess_audio1_poll, sc, hz/30);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ess_audio2_poll(addr)
|
|
|
|
void *addr;
|
|
|
|
{
|
|
|
|
struct ess_softc *sc = addr;
|
|
|
|
int dmapos, dmacount;
|
|
|
|
|
|
|
|
if (!sc->sc_audio2.active)
|
|
|
|
return;
|
|
|
|
|
|
|
|
sc->sc_audio2.nintr++;
|
|
|
|
|
|
|
|
dmapos = isa_dmacount(sc->sc_ic, sc->sc_audio2.drq);
|
1999-03-18 09:04:21 +03:00
|
|
|
dmacount = sc->sc_audio2.dmapos - dmapos;
|
|
|
|
if (dmacount < 0)
|
1999-03-18 07:31:36 +03:00
|
|
|
dmacount += sc->sc_audio2.buffersize;
|
1999-03-18 09:04:21 +03:00
|
|
|
sc->sc_audio2.dmapos = dmapos;
|
|
|
|
#if 1
|
|
|
|
dmacount += sc->sc_audio2.dmacount;
|
1999-03-18 07:31:36 +03:00
|
|
|
while (dmacount > sc->sc_audio2.blksize) {
|
|
|
|
dmacount -= sc->sc_audio2.blksize;
|
|
|
|
(*sc->sc_audio2.intr)(sc->sc_audio2.arg);
|
|
|
|
}
|
|
|
|
sc->sc_audio2.dmacount = dmacount;
|
1999-03-18 09:04:21 +03:00
|
|
|
#else
|
|
|
|
(*sc->sc_audio2.intr)(sc->sc_audio2.arg, dmacount);
|
|
|
|
#endif
|
1999-03-18 07:31:36 +03:00
|
|
|
|
|
|
|
timeout(ess_audio2_poll, sc, hz/30);
|
|
|
|
}
|
|
|
|
|
1998-06-30 00:56:21 +04:00
|
|
|
int
|
|
|
|
ess_round_blocksize(addr, blk)
|
|
|
|
void *addr;
|
|
|
|
int blk;
|
|
|
|
{
|
1998-07-31 19:17:17 +04:00
|
|
|
return (blk & -8); /* round for max DMA size */
|
1998-06-30 00:56:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ess_set_port(addr, cp)
|
|
|
|
void *addr;
|
|
|
|
mixer_ctrl_t *cp;
|
|
|
|
{
|
|
|
|
struct ess_softc *sc = addr;
|
|
|
|
int lgain, rgain;
|
|
|
|
|
1998-07-31 19:17:17 +04:00
|
|
|
DPRINTFN(5,("ess_set_port: port=%d num_channels=%d\n",
|
|
|
|
cp->dev, cp->un.value.num_channels));
|
1998-06-30 00:56:21 +04:00
|
|
|
|
|
|
|
switch (cp->dev) {
|
|
|
|
/*
|
|
|
|
* The following mixer ports are all stereo. If we get a
|
|
|
|
* single-channel gain value passed in, then we duplicate it
|
|
|
|
* to both left and right channels.
|
|
|
|
*/
|
|
|
|
case ESS_MASTER_VOL:
|
|
|
|
case ESS_DAC_PLAY_VOL:
|
|
|
|
case ESS_MIC_PLAY_VOL:
|
|
|
|
case ESS_LINE_PLAY_VOL:
|
|
|
|
case ESS_SYNTH_PLAY_VOL:
|
|
|
|
case ESS_CD_PLAY_VOL:
|
|
|
|
case ESS_AUXB_PLAY_VOL:
|
|
|
|
case ESS_RECORD_VOL:
|
|
|
|
if (cp->type != AUDIO_MIXER_VALUE)
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
switch (cp->un.value.num_channels) {
|
|
|
|
case 1:
|
|
|
|
lgain = rgain = ESS_4BIT_GAIN(
|
|
|
|
cp->un.value.level[AUDIO_MIXER_LEVEL_MONO]);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
lgain = ESS_4BIT_GAIN(
|
|
|
|
cp->un.value.level[AUDIO_MIXER_LEVEL_LEFT]);
|
|
|
|
rgain = ESS_4BIT_GAIN(
|
|
|
|
cp->un.value.level[AUDIO_MIXER_LEVEL_RIGHT]);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
sc->gain[cp->dev][ESS_LEFT] = lgain;
|
|
|
|
sc->gain[cp->dev][ESS_RIGHT] = rgain;
|
|
|
|
ess_set_gain(sc, cp->dev, 1);
|
1999-03-16 16:06:35 +03:00
|
|
|
return (0);
|
1998-06-30 00:56:21 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The PC speaker port is mono. If we get a stereo gain value
|
|
|
|
* passed in, then we return EINVAL.
|
|
|
|
*/
|
|
|
|
case ESS_PCSPEAKER_VOL:
|
|
|
|
if (cp->un.value.num_channels != 1)
|
|
|
|
return EINVAL;
|
|
|
|
|
1999-03-16 16:06:35 +03:00
|
|
|
sc->gain[cp->dev][ESS_LEFT] = sc->gain[cp->dev][ESS_RIGHT] =
|
1998-06-30 00:56:21 +04:00
|
|
|
ESS_3BIT_GAIN(cp->un.value.level[AUDIO_MIXER_LEVEL_MONO]);
|
|
|
|
ess_set_gain(sc, cp->dev, 1);
|
1999-03-16 16:06:35 +03:00
|
|
|
return (0);
|
1998-06-30 00:56:21 +04:00
|
|
|
|
|
|
|
case ESS_RECORD_SOURCE:
|
1999-03-16 16:06:35 +03:00
|
|
|
if (sc->sc_model == ESS_1788) {
|
|
|
|
if (cp->type == AUDIO_MIXER_ENUM)
|
|
|
|
return (ess_set_in_port(sc, cp->un.ord));
|
|
|
|
else
|
|
|
|
return (EINVAL);
|
|
|
|
} else {
|
|
|
|
if (cp->type == AUDIO_MIXER_SET)
|
|
|
|
return (ess_set_in_ports(sc, cp->un.mask));
|
|
|
|
else
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
return (0);
|
1998-06-30 00:56:21 +04:00
|
|
|
|
|
|
|
case ESS_RECORD_MONITOR:
|
|
|
|
if (cp->type != AUDIO_MIXER_ENUM)
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
if (cp->un.ord)
|
|
|
|
/* Enable monitor */
|
|
|
|
ess_set_xreg_bits(sc, ESS_XCMD_AUDIO_CTRL,
|
|
|
|
ESS_AUDIO_CTRL_MONITOR);
|
|
|
|
else
|
|
|
|
/* Disable monitor */
|
|
|
|
ess_clear_xreg_bits(sc, ESS_XCMD_AUDIO_CTRL,
|
|
|
|
ESS_AUDIO_CTRL_MONITOR);
|
1999-03-16 16:06:35 +03:00
|
|
|
return (0);
|
1998-06-30 00:56:21 +04:00
|
|
|
}
|
|
|
|
|
1999-03-16 16:06:35 +03:00
|
|
|
if (sc->sc_model == ESS_1788)
|
|
|
|
return (EINVAL);
|
1998-06-30 00:56:21 +04:00
|
|
|
|
|
|
|
switch (cp->dev) {
|
1999-03-02 23:36:50 +03:00
|
|
|
case ESS_DAC_REC_VOL:
|
|
|
|
case ESS_MIC_REC_VOL:
|
|
|
|
case ESS_LINE_REC_VOL:
|
|
|
|
case ESS_SYNTH_REC_VOL:
|
|
|
|
case ESS_CD_REC_VOL:
|
|
|
|
case ESS_AUXB_REC_VOL:
|
1999-03-16 16:06:35 +03:00
|
|
|
if (cp->type != AUDIO_MIXER_VALUE)
|
1999-03-02 23:36:50 +03:00
|
|
|
return EINVAL;
|
1999-03-16 16:06:35 +03:00
|
|
|
|
|
|
|
switch (cp->un.value.num_channels) {
|
|
|
|
case 1:
|
|
|
|
lgain = rgain = ESS_4BIT_GAIN(
|
|
|
|
cp->un.value.level[AUDIO_MIXER_LEVEL_MONO]);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
lgain = ESS_4BIT_GAIN(
|
|
|
|
cp->un.value.level[AUDIO_MIXER_LEVEL_LEFT]);
|
|
|
|
rgain = ESS_4BIT_GAIN(
|
|
|
|
cp->un.value.level[AUDIO_MIXER_LEVEL_RIGHT]);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
sc->gain[cp->dev][ESS_LEFT] = lgain;
|
|
|
|
sc->gain[cp->dev][ESS_RIGHT] = rgain;
|
|
|
|
ess_set_gain(sc, cp->dev, 1);
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
case ESS_MIC_PREAMP:
|
|
|
|
if (cp->type != AUDIO_MIXER_ENUM)
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
if (cp->un.ord)
|
|
|
|
/* Enable microphone preamp */
|
|
|
|
ess_set_xreg_bits(sc, ESS_XCMD_PREAMP_CTRL,
|
|
|
|
ESS_PREAMP_CTRL_ENABLE);
|
|
|
|
else
|
|
|
|
/* Disable microphone preamp */
|
|
|
|
ess_clear_xreg_bits(sc, ESS_XCMD_PREAMP_CTRL,
|
|
|
|
ESS_PREAMP_CTRL_ENABLE);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ess_get_port(addr, cp)
|
|
|
|
void *addr;
|
|
|
|
mixer_ctrl_t *cp;
|
|
|
|
{
|
|
|
|
struct ess_softc *sc = addr;
|
|
|
|
|
|
|
|
DPRINTFN(5,("ess_get_port: port=%d\n", cp->dev));
|
|
|
|
|
|
|
|
switch (cp->dev) {
|
|
|
|
case ESS_MASTER_VOL:
|
|
|
|
case ESS_DAC_PLAY_VOL:
|
1998-06-30 00:56:21 +04:00
|
|
|
case ESS_MIC_PLAY_VOL:
|
|
|
|
case ESS_LINE_PLAY_VOL:
|
|
|
|
case ESS_SYNTH_PLAY_VOL:
|
|
|
|
case ESS_CD_PLAY_VOL:
|
|
|
|
case ESS_AUXB_PLAY_VOL:
|
|
|
|
case ESS_RECORD_VOL:
|
|
|
|
switch (cp->un.value.num_channels) {
|
|
|
|
case 1:
|
|
|
|
cp->un.value.level[AUDIO_MIXER_LEVEL_MONO] =
|
|
|
|
sc->gain[cp->dev][ESS_LEFT];
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
cp->un.value.level[AUDIO_MIXER_LEVEL_LEFT] =
|
|
|
|
sc->gain[cp->dev][ESS_LEFT];
|
|
|
|
cp->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] =
|
|
|
|
sc->gain[cp->dev][ESS_RIGHT];
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return EINVAL;
|
|
|
|
}
|
1999-03-16 16:06:35 +03:00
|
|
|
return (0);
|
1998-06-30 00:56:21 +04:00
|
|
|
|
1999-03-16 16:06:35 +03:00
|
|
|
case ESS_PCSPEAKER_VOL:
|
|
|
|
if (cp->un.value.num_channels != 1)
|
1999-03-02 23:36:50 +03:00
|
|
|
return EINVAL;
|
1999-03-16 16:06:35 +03:00
|
|
|
|
|
|
|
cp->un.value.level[AUDIO_MIXER_LEVEL_MONO] =
|
|
|
|
sc->gain[cp->dev][ESS_LEFT];
|
|
|
|
return (0);
|
1998-06-30 00:56:21 +04:00
|
|
|
|
|
|
|
case ESS_RECORD_SOURCE:
|
1999-03-02 23:36:50 +03:00
|
|
|
if (sc->sc_model == ESS_1788)
|
|
|
|
cp->un.ord = sc->in_port;
|
|
|
|
else
|
|
|
|
cp->un.mask = sc->in_mask;
|
1999-03-16 16:06:35 +03:00
|
|
|
return (0);
|
1998-06-30 00:56:21 +04:00
|
|
|
|
|
|
|
case ESS_RECORD_MONITOR:
|
|
|
|
cp->un.ord = (ess_read_x_reg(sc, ESS_XCMD_AUDIO_CTRL) &
|
|
|
|
ESS_AUDIO_CTRL_MONITOR) ? 1 : 0;
|
1999-03-16 16:06:35 +03:00
|
|
|
return (0);
|
|
|
|
}
|
1998-06-30 00:56:21 +04:00
|
|
|
|
1999-03-16 16:06:35 +03:00
|
|
|
if (sc->sc_model == ESS_1788)
|
|
|
|
return (EINVAL);
|
|
|
|
|
|
|
|
switch (cp->dev) {
|
|
|
|
case ESS_DAC_REC_VOL:
|
|
|
|
case ESS_MIC_REC_VOL:
|
|
|
|
case ESS_LINE_REC_VOL:
|
|
|
|
case ESS_SYNTH_REC_VOL:
|
|
|
|
case ESS_CD_REC_VOL:
|
|
|
|
case ESS_AUXB_REC_VOL:
|
|
|
|
switch (cp->un.value.num_channels) {
|
|
|
|
case 1:
|
|
|
|
cp->un.value.level[AUDIO_MIXER_LEVEL_MONO] =
|
|
|
|
sc->gain[cp->dev][ESS_LEFT];
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
cp->un.value.level[AUDIO_MIXER_LEVEL_LEFT] =
|
|
|
|
sc->gain[cp->dev][ESS_LEFT];
|
|
|
|
cp->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] =
|
|
|
|
sc->gain[cp->dev][ESS_RIGHT];
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
case ESS_MIC_PREAMP:
|
|
|
|
cp->un.ord = (ess_read_x_reg(sc, ESS_XCMD_PREAMP_CTRL) &
|
|
|
|
ESS_PREAMP_CTRL_ENABLE) ? 1 : 0;
|
|
|
|
return (0);
|
1998-06-30 00:56:21 +04:00
|
|
|
}
|
|
|
|
|
1999-03-16 16:06:35 +03:00
|
|
|
return (EINVAL);
|
1998-06-30 00:56:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ess_query_devinfo(addr, dip)
|
|
|
|
void *addr;
|
|
|
|
mixer_devinfo_t *dip;
|
|
|
|
{
|
|
|
|
struct ess_softc *sc = addr;
|
|
|
|
|
1998-07-31 19:17:17 +04:00
|
|
|
DPRINTFN(5,("ess_query_devinfo: model=%d index=%d\n",
|
|
|
|
sc->sc_model, dip->index));
|
1998-06-30 00:56:21 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* REVISIT: There are some slight differences between the
|
|
|
|
* mixers on the different ESS chips, which can
|
|
|
|
* be sorted out using the chip model rather than a
|
|
|
|
* separate mixer model.
|
|
|
|
* This is currently coded assuming an ES1887; we
|
|
|
|
* need to work out which bits are not applicable to
|
|
|
|
* the other models (1888 and 888).
|
|
|
|
*/
|
|
|
|
switch (dip->index) {
|
|
|
|
case ESS_DAC_PLAY_VOL:
|
|
|
|
dip->mixer_class = ESS_INPUT_CLASS;
|
1998-11-25 16:39:37 +03:00
|
|
|
dip->next = dip->prev = AUDIO_MIXER_LAST;
|
1998-06-30 00:56:21 +04:00
|
|
|
strcpy(dip->label.name, AudioNdac);
|
1998-11-25 16:39:37 +03:00
|
|
|
dip->type = AUDIO_MIXER_VALUE;
|
1998-06-30 00:56:21 +04:00
|
|
|
dip->un.v.num_channels = 2;
|
|
|
|
strcpy(dip->un.v.units.name, AudioNvolume);
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
case ESS_MIC_PLAY_VOL:
|
|
|
|
dip->mixer_class = ESS_INPUT_CLASS;
|
|
|
|
dip->prev = AUDIO_MIXER_LAST;
|
1999-03-02 23:36:50 +03:00
|
|
|
if (sc->sc_model == ESS_1788)
|
|
|
|
dip->next = AUDIO_MIXER_LAST;
|
|
|
|
else
|
|
|
|
dip->next = ESS_MIC_PREAMP;
|
1998-06-30 00:56:21 +04:00
|
|
|
strcpy(dip->label.name, AudioNmicrophone);
|
1998-11-25 16:39:37 +03:00
|
|
|
dip->type = AUDIO_MIXER_VALUE;
|
1998-06-30 00:56:21 +04:00
|
|
|
dip->un.v.num_channels = 2;
|
|
|
|
strcpy(dip->un.v.units.name, AudioNvolume);
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
case ESS_LINE_PLAY_VOL:
|
|
|
|
dip->mixer_class = ESS_INPUT_CLASS;
|
1998-11-25 16:39:37 +03:00
|
|
|
dip->next = dip->prev = AUDIO_MIXER_LAST;
|
1998-06-30 00:56:21 +04:00
|
|
|
strcpy(dip->label.name, AudioNline);
|
1998-11-25 16:39:37 +03:00
|
|
|
dip->type = AUDIO_MIXER_VALUE;
|
1998-06-30 00:56:21 +04:00
|
|
|
dip->un.v.num_channels = 2;
|
|
|
|
strcpy(dip->un.v.units.name, AudioNvolume);
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
case ESS_SYNTH_PLAY_VOL:
|
|
|
|
dip->mixer_class = ESS_INPUT_CLASS;
|
1998-11-25 16:39:37 +03:00
|
|
|
dip->next = dip->prev = AUDIO_MIXER_LAST;
|
1998-06-30 00:56:21 +04:00
|
|
|
strcpy(dip->label.name, AudioNfmsynth);
|
1998-11-25 16:39:37 +03:00
|
|
|
dip->type = AUDIO_MIXER_VALUE;
|
1998-06-30 00:56:21 +04:00
|
|
|
dip->un.v.num_channels = 2;
|
|
|
|
strcpy(dip->un.v.units.name, AudioNvolume);
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
case ESS_CD_PLAY_VOL:
|
|
|
|
dip->mixer_class = ESS_INPUT_CLASS;
|
1998-11-25 16:39:37 +03:00
|
|
|
dip->next = dip->prev = AUDIO_MIXER_LAST;
|
1998-06-30 00:56:21 +04:00
|
|
|
strcpy(dip->label.name, AudioNcd);
|
1998-11-25 16:39:37 +03:00
|
|
|
dip->type = AUDIO_MIXER_VALUE;
|
1998-06-30 00:56:21 +04:00
|
|
|
dip->un.v.num_channels = 2;
|
|
|
|
strcpy(dip->un.v.units.name, AudioNvolume);
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
case ESS_AUXB_PLAY_VOL:
|
|
|
|
dip->mixer_class = ESS_INPUT_CLASS;
|
1998-11-25 16:39:37 +03:00
|
|
|
dip->next = dip->prev = AUDIO_MIXER_LAST;
|
1998-06-30 00:56:21 +04:00
|
|
|
strcpy(dip->label.name, "auxb");
|
1998-11-25 16:39:37 +03:00
|
|
|
dip->type = AUDIO_MIXER_VALUE;
|
1998-06-30 00:56:21 +04:00
|
|
|
dip->un.v.num_channels = 2;
|
|
|
|
strcpy(dip->un.v.units.name, AudioNvolume);
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
case ESS_INPUT_CLASS:
|
|
|
|
dip->mixer_class = ESS_INPUT_CLASS;
|
|
|
|
dip->next = dip->prev = AUDIO_MIXER_LAST;
|
|
|
|
strcpy(dip->label.name, AudioCinputs);
|
1998-11-25 16:39:37 +03:00
|
|
|
dip->type = AUDIO_MIXER_CLASS;
|
1998-06-30 00:56:21 +04:00
|
|
|
return (0);
|
|
|
|
|
|
|
|
case ESS_MASTER_VOL:
|
|
|
|
dip->mixer_class = ESS_OUTPUT_CLASS;
|
1998-11-25 16:39:37 +03:00
|
|
|
dip->next = dip->prev = AUDIO_MIXER_LAST;
|
1998-06-30 00:56:21 +04:00
|
|
|
strcpy(dip->label.name, AudioNmaster);
|
1998-11-25 16:39:37 +03:00
|
|
|
dip->type = AUDIO_MIXER_VALUE;
|
1998-06-30 00:56:21 +04:00
|
|
|
dip->un.v.num_channels = 2;
|
|
|
|
strcpy(dip->un.v.units.name, AudioNvolume);
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
case ESS_PCSPEAKER_VOL:
|
|
|
|
dip->mixer_class = ESS_OUTPUT_CLASS;
|
1998-11-25 16:39:37 +03:00
|
|
|
dip->next = dip->prev = AUDIO_MIXER_LAST;
|
1998-06-30 00:56:21 +04:00
|
|
|
strcpy(dip->label.name, "pc_speaker");
|
1998-11-25 16:39:37 +03:00
|
|
|
dip->type = AUDIO_MIXER_VALUE;
|
1998-06-30 00:56:21 +04:00
|
|
|
dip->un.v.num_channels = 1;
|
|
|
|
strcpy(dip->un.v.units.name, AudioNvolume);
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
case ESS_OUTPUT_CLASS:
|
|
|
|
dip->mixer_class = ESS_OUTPUT_CLASS;
|
|
|
|
dip->next = dip->prev = AUDIO_MIXER_LAST;
|
|
|
|
strcpy(dip->label.name, AudioCoutputs);
|
1998-11-25 16:39:37 +03:00
|
|
|
dip->type = AUDIO_MIXER_CLASS;
|
1998-06-30 00:56:21 +04:00
|
|
|
return (0);
|
|
|
|
|
|
|
|
case ESS_RECORD_VOL:
|
|
|
|
dip->mixer_class = ESS_RECORD_CLASS;
|
1998-11-25 16:39:37 +03:00
|
|
|
dip->next = dip->prev = AUDIO_MIXER_LAST;
|
1998-06-30 00:56:21 +04:00
|
|
|
strcpy(dip->label.name, AudioNrecord);
|
1998-11-25 16:39:37 +03:00
|
|
|
dip->type = AUDIO_MIXER_VALUE;
|
1998-06-30 00:56:21 +04:00
|
|
|
dip->un.v.num_channels = 2;
|
|
|
|
strcpy(dip->un.v.units.name, AudioNvolume);
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
case ESS_RECORD_SOURCE:
|
1999-03-16 16:06:35 +03:00
|
|
|
dip->mixer_class = ESS_RECORD_CLASS;
|
1998-11-25 16:39:37 +03:00
|
|
|
dip->next = dip->prev = AUDIO_MIXER_LAST;
|
1998-06-30 00:56:21 +04:00
|
|
|
strcpy(dip->label.name, AudioNsource);
|
1999-03-02 23:36:50 +03:00
|
|
|
if (sc->sc_model == ESS_1788) {
|
1999-03-16 16:06:35 +03:00
|
|
|
/*
|
|
|
|
* The 1788 doesn't use the input mixer control that
|
|
|
|
* the 1888 uses, because it's a pain when you only
|
|
|
|
* have one mixer.
|
|
|
|
* Perhaps it could be emulated by keeping both sets of
|
|
|
|
* gain values, and doing a `context switch' of the
|
|
|
|
* mixer registers when shifting from playing to
|
|
|
|
* recording.
|
1999-03-02 23:36:50 +03:00
|
|
|
*/
|
|
|
|
dip->type = AUDIO_MIXER_ENUM;
|
|
|
|
dip->un.e.num_mem = 4;
|
|
|
|
strcpy(dip->un.e.member[0].label.name, AudioNmicrophone);
|
|
|
|
dip->un.e.member[0].ord = ESS_SOURCE_MIC;
|
|
|
|
strcpy(dip->un.e.member[1].label.name, AudioNline);
|
|
|
|
dip->un.e.member[1].ord = ESS_SOURCE_LINE;
|
|
|
|
strcpy(dip->un.e.member[2].label.name, AudioNcd);
|
|
|
|
dip->un.e.member[2].ord = ESS_SOURCE_CD;
|
|
|
|
strcpy(dip->un.e.member[3].label.name, AudioNmixerout);
|
|
|
|
dip->un.e.member[3].ord = ESS_SOURCE_MIXER;
|
|
|
|
} else {
|
|
|
|
dip->type = AUDIO_MIXER_SET;
|
|
|
|
dip->un.s.num_mem = 6;
|
|
|
|
strcpy(dip->un.s.member[0].label.name, AudioNdac);
|
|
|
|
dip->un.s.member[0].mask = 1 << ESS_DAC_REC_VOL;
|
|
|
|
strcpy(dip->un.s.member[1].label.name, AudioNmicrophone);
|
|
|
|
dip->un.s.member[1].mask = 1 << ESS_MIC_REC_VOL;
|
|
|
|
strcpy(dip->un.s.member[2].label.name, AudioNline);
|
|
|
|
dip->un.s.member[2].mask = 1 << ESS_LINE_REC_VOL;
|
|
|
|
strcpy(dip->un.s.member[3].label.name, AudioNfmsynth);
|
|
|
|
dip->un.s.member[3].mask = 1 << ESS_SYNTH_REC_VOL;
|
|
|
|
strcpy(dip->un.s.member[4].label.name, AudioNcd);
|
|
|
|
dip->un.s.member[4].mask = 1 << ESS_CD_REC_VOL;
|
|
|
|
strcpy(dip->un.s.member[5].label.name, "auxb");
|
|
|
|
dip->un.s.member[5].mask = 1 << ESS_AUXB_REC_VOL;
|
|
|
|
}
|
1998-06-30 00:56:21 +04:00
|
|
|
return (0);
|
|
|
|
|
|
|
|
case ESS_RECORD_CLASS:
|
|
|
|
dip->mixer_class = ESS_RECORD_CLASS;
|
|
|
|
dip->next = dip->prev = AUDIO_MIXER_LAST;
|
|
|
|
strcpy(dip->label.name, AudioCrecord);
|
1998-11-25 16:39:37 +03:00
|
|
|
dip->type = AUDIO_MIXER_CLASS;
|
1998-06-30 00:56:21 +04:00
|
|
|
return (0);
|
|
|
|
|
|
|
|
case ESS_RECORD_MONITOR:
|
|
|
|
dip->prev = dip->next = AUDIO_MIXER_LAST;
|
|
|
|
strcpy(dip->label.name, AudioNmonitor);
|
|
|
|
dip->type = AUDIO_MIXER_ENUM;
|
1998-11-25 16:39:37 +03:00
|
|
|
dip->mixer_class = ESS_MONITOR_CLASS;
|
1998-06-30 00:56:21 +04:00
|
|
|
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);
|
|
|
|
|
|
|
|
case ESS_MONITOR_CLASS:
|
|
|
|
dip->mixer_class = ESS_MONITOR_CLASS;
|
|
|
|
dip->next = dip->prev = AUDIO_MIXER_LAST;
|
|
|
|
strcpy(dip->label.name, AudioCmonitor);
|
1998-11-25 16:39:37 +03:00
|
|
|
dip->type = AUDIO_MIXER_CLASS;
|
1998-06-30 00:56:21 +04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1999-03-16 16:06:35 +03:00
|
|
|
if (sc->sc_model == ESS_1788)
|
|
|
|
return (ENXIO);
|
|
|
|
|
|
|
|
switch (dip->index) {
|
|
|
|
case ESS_DAC_REC_VOL:
|
|
|
|
dip->mixer_class = ESS_RECORD_CLASS;
|
|
|
|
dip->next = dip->prev = AUDIO_MIXER_LAST;
|
|
|
|
strcpy(dip->label.name, AudioNdac);
|
|
|
|
dip->type = AUDIO_MIXER_VALUE;
|
|
|
|
dip->un.v.num_channels = 2;
|
|
|
|
strcpy(dip->un.v.units.name, AudioNvolume);
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
case ESS_MIC_REC_VOL:
|
|
|
|
dip->mixer_class = ESS_RECORD_CLASS;
|
|
|
|
dip->next = dip->prev = AUDIO_MIXER_LAST;
|
|
|
|
strcpy(dip->label.name, AudioNmicrophone);
|
|
|
|
dip->type = AUDIO_MIXER_VALUE;
|
|
|
|
dip->un.v.num_channels = 2;
|
|
|
|
strcpy(dip->un.v.units.name, AudioNvolume);
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
case ESS_LINE_REC_VOL:
|
|
|
|
dip->mixer_class = ESS_RECORD_CLASS;
|
|
|
|
dip->next = dip->prev = AUDIO_MIXER_LAST;
|
|
|
|
strcpy(dip->label.name, AudioNline);
|
|
|
|
dip->type = AUDIO_MIXER_VALUE;
|
|
|
|
dip->un.v.num_channels = 2;
|
|
|
|
strcpy(dip->un.v.units.name, AudioNvolume);
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
case ESS_SYNTH_REC_VOL:
|
|
|
|
dip->mixer_class = ESS_RECORD_CLASS;
|
|
|
|
dip->next = dip->prev = AUDIO_MIXER_LAST;
|
|
|
|
strcpy(dip->label.name, AudioNfmsynth);
|
|
|
|
dip->type = AUDIO_MIXER_VALUE;
|
|
|
|
dip->un.v.num_channels = 2;
|
|
|
|
strcpy(dip->un.v.units.name, AudioNvolume);
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
case ESS_CD_REC_VOL:
|
|
|
|
dip->mixer_class = ESS_RECORD_CLASS;
|
|
|
|
dip->next = dip->prev = AUDIO_MIXER_LAST;
|
|
|
|
strcpy(dip->label.name, AudioNcd);
|
|
|
|
dip->type = AUDIO_MIXER_VALUE;
|
|
|
|
dip->un.v.num_channels = 2;
|
|
|
|
strcpy(dip->un.v.units.name, AudioNvolume);
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
case ESS_AUXB_REC_VOL:
|
|
|
|
dip->mixer_class = ESS_RECORD_CLASS;
|
|
|
|
dip->next = dip->prev = AUDIO_MIXER_LAST;
|
|
|
|
strcpy(dip->label.name, "auxb");
|
|
|
|
dip->type = AUDIO_MIXER_VALUE;
|
|
|
|
dip->un.v.num_channels = 2;
|
|
|
|
strcpy(dip->un.v.units.name, AudioNvolume);
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
case ESS_MIC_PREAMP:
|
|
|
|
dip->mixer_class = ESS_INPUT_CLASS;
|
|
|
|
dip->prev = ESS_MIC_PLAY_VOL;
|
|
|
|
dip->next = AUDIO_MIXER_LAST;
|
|
|
|
strcpy(dip->label.name, AudioNpreamp);
|
|
|
|
dip->type = AUDIO_MIXER_ENUM;
|
|
|
|
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-07-31 19:17:17 +04:00
|
|
|
return (ENXIO);
|
|
|
|
}
|
|
|
|
|
|
|
|
void *
|
1999-02-17 05:37:38 +03:00
|
|
|
ess_malloc(addr, direction, size, pool, flags)
|
1998-07-31 19:17:17 +04:00
|
|
|
void *addr;
|
1999-02-17 05:37:38 +03:00
|
|
|
int direction;
|
|
|
|
size_t size;
|
|
|
|
int pool, flags;
|
1998-07-31 19:17:17 +04:00
|
|
|
{
|
|
|
|
struct ess_softc *sc = addr;
|
1999-02-17 05:37:38 +03:00
|
|
|
int drq;
|
1998-07-31 19:17:17 +04:00
|
|
|
|
1999-03-17 05:39:59 +03:00
|
|
|
if (sc->sc_model != ESS_1788 && direction == AUMODE_PLAY)
|
1999-03-16 16:06:35 +03:00
|
|
|
drq = sc->sc_audio2.drq;
|
1999-02-17 05:37:38 +03:00
|
|
|
else
|
1999-03-16 16:06:35 +03:00
|
|
|
drq = sc->sc_audio1.drq;
|
1999-02-17 05:37:38 +03:00
|
|
|
return (isa_malloc(sc->sc_ic, drq, size, pool, flags));
|
1998-07-31 19:17:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ess_free(addr, ptr, pool)
|
|
|
|
void *addr;
|
|
|
|
void *ptr;
|
|
|
|
int pool;
|
|
|
|
{
|
|
|
|
isa_free(ptr, pool);
|
|
|
|
}
|
|
|
|
|
1999-02-17 05:37:38 +03:00
|
|
|
size_t
|
|
|
|
ess_round_buffersize(addr, direction, size)
|
1998-07-31 19:17:17 +04:00
|
|
|
void *addr;
|
1999-02-17 05:37:38 +03:00
|
|
|
int direction;
|
|
|
|
size_t size;
|
1998-07-31 19:17:17 +04:00
|
|
|
{
|
|
|
|
if (size > MAX_ISADMA)
|
|
|
|
size = MAX_ISADMA;
|
1999-02-17 05:37:38 +03:00
|
|
|
return (size);
|
1998-07-31 19:17:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ess_mappage(addr, mem, off, prot)
|
|
|
|
void *addr;
|
1999-03-16 16:06:35 +03:00
|
|
|
void *mem;
|
|
|
|
int off;
|
1998-07-31 19:17:17 +04:00
|
|
|
int prot;
|
|
|
|
{
|
|
|
|
return (isa_mappage(mem, off, prot));
|
1998-06-30 00:56:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1999-03-16 16:32:25 +03:00
|
|
|
ess_1788_get_props(addr)
|
|
|
|
void *addr;
|
|
|
|
{
|
|
|
|
|
|
|
|
return (AUDIO_PROP_MMAP | AUDIO_PROP_INDEPENDENT);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ess_1888_get_props(addr)
|
1998-06-30 00:56:21 +04:00
|
|
|
void *addr;
|
|
|
|
{
|
1998-08-09 08:40:55 +04:00
|
|
|
|
1999-03-16 16:32:25 +03:00
|
|
|
return (AUDIO_PROP_MMAP | AUDIO_PROP_INDEPENDENT | AUDIO_PROP_FULLDUPLEX);
|
1998-06-30 00:56:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ============================================
|
|
|
|
* Generic functions for ess, not used by audio h/w i/f
|
|
|
|
* =============================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset the chip.
|
|
|
|
* Return non-zero if the chip isn't detected.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
ess_reset(sc)
|
|
|
|
struct ess_softc *sc;
|
|
|
|
{
|
|
|
|
bus_space_tag_t iot = sc->sc_iot;
|
|
|
|
bus_space_handle_t ioh = sc->sc_ioh;
|
|
|
|
|
1999-03-17 05:39:59 +03:00
|
|
|
sc->sc_audio1.active = 0;
|
|
|
|
sc->sc_audio2.active = 0;
|
1998-06-30 00:56:21 +04:00
|
|
|
|
1998-07-31 19:17:17 +04:00
|
|
|
EWRITE1(iot, ioh, ESS_DSP_RESET, ESS_RESET_EXT);
|
1998-06-30 00:56:21 +04:00
|
|
|
delay(10000);
|
1998-07-30 18:11:42 +04:00
|
|
|
EWRITE1(iot, ioh, ESS_DSP_RESET, 0);
|
1998-06-30 00:56:21 +04:00
|
|
|
if (ess_rdsp(sc) != ESS_MAGIC)
|
1998-07-31 19:17:17 +04:00
|
|
|
return (1);
|
1998-06-30 00:56:21 +04:00
|
|
|
|
1998-07-31 19:17:17 +04:00
|
|
|
/* Enable access to the ESS extension commands. */
|
1998-06-30 00:56:21 +04:00
|
|
|
ess_wdsp(sc, ESS_ACMD_ENABLE_EXT);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ess_set_gain(sc, port, on)
|
|
|
|
struct ess_softc *sc;
|
|
|
|
int port;
|
|
|
|
int on;
|
|
|
|
{
|
|
|
|
int gain, left, right;
|
|
|
|
int mix;
|
|
|
|
int src;
|
|
|
|
int stereo;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Most gain controls are found in the mixer registers and
|
|
|
|
* are stereo. Any that are not, must set mix and stereo as
|
|
|
|
* required.
|
|
|
|
*/
|
|
|
|
mix = 1;
|
|
|
|
stereo = 1;
|
|
|
|
|
|
|
|
switch (port) {
|
|
|
|
case ESS_MASTER_VOL:
|
1999-03-02 23:36:50 +03:00
|
|
|
src = ESS_MREG_VOLUME_MASTER;
|
1998-06-30 00:56:21 +04:00
|
|
|
break;
|
|
|
|
case ESS_DAC_PLAY_VOL:
|
1999-03-02 23:36:50 +03:00
|
|
|
if (sc->sc_model == ESS_1788)
|
|
|
|
src = ESS_MREG_VOLUME_VOICE;
|
|
|
|
else
|
|
|
|
src = 0x7C;
|
1998-06-30 00:56:21 +04:00
|
|
|
break;
|
|
|
|
case ESS_MIC_PLAY_VOL:
|
1999-03-02 23:36:50 +03:00
|
|
|
src = ESS_MREG_VOLUME_MIC;
|
1998-06-30 00:56:21 +04:00
|
|
|
break;
|
|
|
|
case ESS_LINE_PLAY_VOL:
|
1999-03-02 23:36:50 +03:00
|
|
|
src = ESS_MREG_VOLUME_LINE;
|
1998-06-30 00:56:21 +04:00
|
|
|
break;
|
|
|
|
case ESS_SYNTH_PLAY_VOL:
|
1999-03-02 23:36:50 +03:00
|
|
|
src = ESS_MREG_VOLUME_SYNTH;
|
1998-06-30 00:56:21 +04:00
|
|
|
break;
|
|
|
|
case ESS_CD_PLAY_VOL:
|
1999-03-02 23:36:50 +03:00
|
|
|
src = ESS_MREG_VOLUME_CD;
|
1998-06-30 00:56:21 +04:00
|
|
|
break;
|
|
|
|
case ESS_AUXB_PLAY_VOL:
|
1999-03-02 23:36:50 +03:00
|
|
|
src = ESS_MREG_VOLUME_AUXB;
|
1998-06-30 00:56:21 +04:00
|
|
|
break;
|
|
|
|
case ESS_PCSPEAKER_VOL:
|
1999-03-02 23:36:50 +03:00
|
|
|
src = ESS_MREG_VOLUME_PCSPKR;
|
1998-06-30 00:56:21 +04:00
|
|
|
stereo = 0;
|
|
|
|
break;
|
|
|
|
case ESS_DAC_REC_VOL:
|
|
|
|
src = 0x69;
|
|
|
|
break;
|
|
|
|
case ESS_MIC_REC_VOL:
|
|
|
|
src = 0x68;
|
|
|
|
break;
|
|
|
|
case ESS_LINE_REC_VOL:
|
|
|
|
src = 0x6E;
|
|
|
|
break;
|
|
|
|
case ESS_SYNTH_REC_VOL:
|
|
|
|
src = 0x6B;
|
|
|
|
break;
|
|
|
|
case ESS_CD_REC_VOL:
|
|
|
|
src = 0x6A;
|
|
|
|
break;
|
|
|
|
case ESS_AUXB_REC_VOL:
|
|
|
|
src = 0x6C;
|
|
|
|
break;
|
|
|
|
case ESS_RECORD_VOL:
|
1999-03-02 23:36:50 +03:00
|
|
|
src = ESS_XCMD_VOLIN_CTRL;
|
1998-06-30 00:56:21 +04:00
|
|
|
mix = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-03-02 23:36:50 +03:00
|
|
|
/* 1788 doesn't have a separate recording mixer */
|
1999-03-16 16:06:35 +03:00
|
|
|
if (sc->sc_model == ESS_1788 && mix && src > 0x62)
|
|
|
|
return;
|
1999-03-02 23:36:50 +03:00
|
|
|
|
1998-06-30 00:56:21 +04:00
|
|
|
if (on) {
|
|
|
|
left = sc->gain[port][ESS_LEFT];
|
|
|
|
right = sc->gain[port][ESS_RIGHT];
|
|
|
|
} else {
|
|
|
|
left = right = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (stereo)
|
|
|
|
gain = ESS_STEREO_GAIN(left, right);
|
|
|
|
else
|
|
|
|
gain = ESS_MONO_GAIN(left);
|
|
|
|
|
|
|
|
if (mix)
|
|
|
|
ess_write_mix_reg(sc, src, gain);
|
|
|
|
else
|
|
|
|
ess_write_x_reg(sc, src, gain);
|
|
|
|
}
|
|
|
|
|
1999-03-02 23:36:50 +03:00
|
|
|
/* Set the input device on devices without an input mixer. */
|
|
|
|
int
|
|
|
|
ess_set_in_port(sc, ord)
|
|
|
|
struct ess_softc *sc;
|
|
|
|
int ord;
|
|
|
|
{
|
|
|
|
mixer_devinfo_t di;
|
1999-03-16 16:06:35 +03:00
|
|
|
int i;
|
1999-03-02 23:36:50 +03:00
|
|
|
|
|
|
|
DPRINTF(("ess_set_in_port: ord=0x%x\n", ord));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the device info for the record source control,
|
|
|
|
* including the list of available sources.
|
|
|
|
*/
|
|
|
|
di.index = ESS_RECORD_SOURCE;
|
|
|
|
if (ess_query_devinfo(sc, &di))
|
|
|
|
return EINVAL;
|
|
|
|
|
1999-03-16 16:06:35 +03:00
|
|
|
/* See if the given ord value was anywhere in the list. */
|
1999-03-02 23:36:50 +03:00
|
|
|
for (i = 0; i < di.un.e.num_mem; i++) {
|
1999-03-16 16:06:35 +03:00
|
|
|
if (ord == di.un.e.member[i].ord)
|
1999-03-02 23:36:50 +03:00
|
|
|
break;
|
|
|
|
}
|
1999-03-16 16:06:35 +03:00
|
|
|
if (i == di.un.e.num_mem)
|
1999-03-02 23:36:50 +03:00
|
|
|
return EINVAL;
|
|
|
|
|
1999-03-16 16:06:35 +03:00
|
|
|
ess_write_mix_reg(sc, ESS_MREG_ADC_SOURCE, ord);
|
|
|
|
|
|
|
|
sc->in_port = ord;
|
1999-03-02 23:36:50 +03:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the input device levels on input-mixer-enabled devices. */
|
1998-06-30 00:56:21 +04:00
|
|
|
int
|
|
|
|
ess_set_in_ports(sc, mask)
|
|
|
|
struct ess_softc *sc;
|
|
|
|
int mask;
|
|
|
|
{
|
|
|
|
mixer_devinfo_t di;
|
1999-03-16 16:06:35 +03:00
|
|
|
int i, port;
|
1998-06-30 00:56:21 +04:00
|
|
|
|
|
|
|
DPRINTF(("ess_set_in_ports: mask=0x%x\n", mask));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the device info for the record source control,
|
|
|
|
* including the list of available sources.
|
|
|
|
*/
|
|
|
|
di.index = ESS_RECORD_SOURCE;
|
|
|
|
if (ess_query_devinfo(sc, &di))
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set or disable the record volume control for each of the
|
|
|
|
* possible sources.
|
|
|
|
*/
|
1999-03-02 23:36:50 +03:00
|
|
|
for (i = 0; i < di.un.s.num_mem; i++) {
|
1998-06-30 00:56:21 +04:00
|
|
|
/*
|
|
|
|
* Calculate the source port number from its mask.
|
|
|
|
*/
|
1999-03-16 16:06:35 +03:00
|
|
|
port = ffs(di.un.s.member[i].mask);
|
1998-06-30 00:56:21 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the source gain:
|
|
|
|
* to the current value if source is enabled
|
|
|
|
* to zero if source is disabled
|
|
|
|
*/
|
|
|
|
ess_set_gain(sc, port, mask & di.un.s.member[i].mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
sc->in_mask = mask;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ess_speaker_on(sc)
|
|
|
|
struct ess_softc *sc;
|
|
|
|
{
|
|
|
|
/* Disable mute on left- and right-master volume. */
|
1999-03-02 23:36:50 +03:00
|
|
|
ess_clear_mreg_bits(sc, ESS_MREG_VOLUME_LEFT, ESS_VOLUME_MUTE);
|
|
|
|
ess_clear_mreg_bits(sc, ESS_MREG_VOLUME_RIGHT, ESS_VOLUME_MUTE);
|
1998-06-30 00:56:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ess_speaker_off(sc)
|
|
|
|
struct ess_softc *sc;
|
|
|
|
{
|
|
|
|
/* Enable mute on left- and right-master volume. */
|
1999-03-02 23:36:50 +03:00
|
|
|
ess_set_mreg_bits(sc, ESS_MREG_VOLUME_LEFT, ESS_VOLUME_MUTE);
|
|
|
|
ess_set_mreg_bits(sc, ESS_MREG_VOLUME_RIGHT, ESS_VOLUME_MUTE);
|
1998-06-30 00:56:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Calculate the time constant for the requested sampling rate.
|
|
|
|
*/
|
|
|
|
u_int
|
|
|
|
ess_srtotc(rate)
|
|
|
|
u_int rate;
|
|
|
|
{
|
|
|
|
u_int tc;
|
|
|
|
|
|
|
|
/* The following formulae are from the ESS data sheet. */
|
1998-08-09 07:48:42 +04:00
|
|
|
if (rate <= 22050)
|
1998-06-30 00:56:21 +04:00
|
|
|
tc = 128 - 397700L / rate;
|
|
|
|
else
|
|
|
|
tc = 256 - 795500L / rate;
|
|
|
|
|
|
|
|
return (tc);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Calculate the filter constant for the reuqested sampling rate.
|
|
|
|
*/
|
|
|
|
u_int
|
|
|
|
ess_srtofc(rate)
|
|
|
|
u_int rate;
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* The following formula is derived from the information in
|
|
|
|
* the ES1887 data sheet, based on a roll-off frequency of
|
|
|
|
* 87%.
|
|
|
|
*/
|
|
|
|
return (256 - 200279L / rate);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return the status of the DSP.
|
|
|
|
*/
|
|
|
|
u_char
|
|
|
|
ess_get_dsp_status(sc)
|
|
|
|
struct ess_softc *sc;
|
|
|
|
{
|
1999-03-16 16:06:35 +03:00
|
|
|
return (EREAD1(sc->sc_iot, sc->sc_ioh, ESS_DSP_RW_STATUS));
|
1998-06-30 00:56:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return the read status of the DSP: 1 -> DSP ready for reading
|
|
|
|
* 0 -> DSP not ready for reading
|
|
|
|
*/
|
|
|
|
u_char
|
|
|
|
ess_dsp_read_ready(sc)
|
|
|
|
struct ess_softc *sc;
|
|
|
|
{
|
1999-03-16 16:06:35 +03:00
|
|
|
return ((ess_get_dsp_status(sc) & ESS_DSP_READ_READY) ? 1 : 0);
|
1998-06-30 00:56:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return the write status of the DSP: 1 -> DSP ready for writing
|
|
|
|
* 0 -> DSP not ready for writing
|
|
|
|
*/
|
|
|
|
u_char
|
|
|
|
ess_dsp_write_ready(sc)
|
|
|
|
struct ess_softc *sc;
|
|
|
|
{
|
1999-03-16 16:06:35 +03:00
|
|
|
return ((ess_get_dsp_status(sc) & ESS_DSP_WRITE_BUSY) ? 0 : 1);
|
1998-06-30 00:56:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read a byte from the DSP.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
ess_rdsp(sc)
|
|
|
|
struct ess_softc *sc;
|
|
|
|
{
|
|
|
|
bus_space_tag_t iot = sc->sc_iot;
|
|
|
|
bus_space_handle_t ioh = sc->sc_ioh;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = ESS_READ_TIMEOUT; i > 0; --i) {
|
|
|
|
if (ess_dsp_read_ready(sc)) {
|
1998-07-30 18:11:42 +04:00
|
|
|
i = EREAD1(iot, ioh, ESS_DSP_READ);
|
|
|
|
DPRINTFN(8,("ess_rdsp() = 0x%02x\n", i));
|
1998-06-30 00:56:21 +04:00
|
|
|
return i;
|
|
|
|
} else
|
|
|
|
delay(10);
|
|
|
|
}
|
|
|
|
|
|
|
|
DPRINTF(("ess_rdsp: timed out\n"));
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Write a byte to the DSP.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
ess_wdsp(sc, v)
|
|
|
|
struct ess_softc *sc;
|
|
|
|
u_char v;
|
|
|
|
{
|
|
|
|
bus_space_tag_t iot = sc->sc_iot;
|
|
|
|
bus_space_handle_t ioh = sc->sc_ioh;
|
|
|
|
int i;
|
1998-07-30 18:11:42 +04:00
|
|
|
|
|
|
|
DPRINTFN(8,("ess_wdsp(0x%02x)\n", v));
|
|
|
|
|
1998-06-30 00:56:21 +04:00
|
|
|
for (i = ESS_WRITE_TIMEOUT; i > 0; --i) {
|
|
|
|
if (ess_dsp_write_ready(sc)) {
|
1998-07-30 18:11:42 +04:00
|
|
|
EWRITE1(iot, ioh, ESS_DSP_WRITE, v);
|
1998-06-30 00:56:21 +04:00
|
|
|
return (0);
|
|
|
|
} else
|
|
|
|
delay(10);
|
|
|
|
}
|
|
|
|
|
|
|
|
DPRINTF(("ess_wdsp(0x%02x): timed out\n", v));
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Write a value to one of the ESS extended registers.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
ess_write_x_reg(sc, reg, val)
|
|
|
|
struct ess_softc *sc;
|
|
|
|
u_char reg;
|
|
|
|
u_char val;
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
1998-07-30 18:11:42 +04:00
|
|
|
DPRINTFN(2,("ess_write_x_reg: %02x=%02x\n", reg, val));
|
1998-06-30 00:56:21 +04:00
|
|
|
if ((error = ess_wdsp(sc, reg)) == 0)
|
|
|
|
error = ess_wdsp(sc, val);
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read the value of one of the ESS extended registers.
|
|
|
|
*/
|
|
|
|
u_char
|
|
|
|
ess_read_x_reg(sc, reg)
|
|
|
|
struct ess_softc *sc;
|
|
|
|
u_char reg;
|
|
|
|
{
|
|
|
|
int error;
|
1998-07-30 18:11:42 +04:00
|
|
|
int val;
|
1998-06-30 00:56:21 +04:00
|
|
|
|
|
|
|
if ((error = ess_wdsp(sc, 0xC0)) == 0)
|
|
|
|
error = ess_wdsp(sc, reg);
|
|
|
|
if (error)
|
|
|
|
DPRINTF(("Error reading extended register 0x%02x\n", reg));
|
|
|
|
/* REVISIT: what if an error is returned above? */
|
1998-07-30 18:11:42 +04:00
|
|
|
val = ess_rdsp(sc);
|
1999-03-02 23:36:50 +03:00
|
|
|
DPRINTFN(2,("ess_read_x_reg: %02x=%02x\n", reg, val));
|
1998-07-30 18:11:42 +04:00
|
|
|
return val;
|
1998-06-30 00:56:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ess_clear_xreg_bits(sc, reg, mask)
|
|
|
|
struct ess_softc *sc;
|
|
|
|
u_char reg;
|
|
|
|
u_char mask;
|
|
|
|
{
|
|
|
|
if (ess_write_x_reg(sc, reg, ess_read_x_reg(sc, reg) & ~mask) == -1)
|
|
|
|
DPRINTF(("Error clearing bits in extended register 0x%02x\n",
|
|
|
|
reg));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ess_set_xreg_bits(sc, reg, mask)
|
|
|
|
struct ess_softc *sc;
|
|
|
|
u_char reg;
|
|
|
|
u_char mask;
|
|
|
|
{
|
|
|
|
if (ess_write_x_reg(sc, reg, ess_read_x_reg(sc, reg) | mask) == -1)
|
|
|
|
DPRINTF(("Error setting bits in extended register 0x%02x\n",
|
|
|
|
reg));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Write a value to one of the ESS mixer registers.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ess_write_mix_reg(sc, reg, val)
|
|
|
|
struct ess_softc *sc;
|
|
|
|
u_char reg;
|
|
|
|
u_char val;
|
|
|
|
{
|
|
|
|
bus_space_tag_t iot = sc->sc_iot;
|
|
|
|
bus_space_handle_t ioh = sc->sc_ioh;
|
|
|
|
int s;
|
|
|
|
|
1998-07-30 18:11:42 +04:00
|
|
|
DPRINTFN(2,("ess_write_mix_reg: %x=%x\n", reg, val));
|
1998-06-30 00:56:21 +04:00
|
|
|
|
1998-07-31 19:17:17 +04:00
|
|
|
s = splaudio();
|
1998-07-30 18:11:42 +04:00
|
|
|
EWRITE1(iot, ioh, ESS_MIX_REG_SELECT, reg);
|
|
|
|
EWRITE1(iot, ioh, ESS_MIX_REG_DATA, val);
|
1998-06-30 00:56:21 +04:00
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read the value of one of the ESS mixer registers.
|
|
|
|
*/
|
|
|
|
u_char
|
|
|
|
ess_read_mix_reg(sc, reg)
|
|
|
|
struct ess_softc *sc;
|
|
|
|
u_char reg;
|
|
|
|
{
|
|
|
|
bus_space_tag_t iot = sc->sc_iot;
|
|
|
|
bus_space_handle_t ioh = sc->sc_ioh;
|
|
|
|
int s;
|
|
|
|
u_char val;
|
|
|
|
|
|
|
|
s = splaudio();
|
1998-07-30 18:11:42 +04:00
|
|
|
EWRITE1(iot, ioh, ESS_MIX_REG_SELECT, reg);
|
|
|
|
val = EREAD1(iot, ioh, ESS_MIX_REG_DATA);
|
1998-06-30 00:56:21 +04:00
|
|
|
splx(s);
|
1998-07-31 19:17:17 +04:00
|
|
|
|
1998-07-30 18:11:42 +04:00
|
|
|
DPRINTFN(2,("ess_read_mix_reg: %x=%x\n", reg, val));
|
1998-06-30 00:56:21 +04:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ess_clear_mreg_bits(sc, reg, mask)
|
|
|
|
struct ess_softc *sc;
|
|
|
|
u_char reg;
|
|
|
|
u_char mask;
|
|
|
|
{
|
|
|
|
ess_write_mix_reg(sc, reg, ess_read_mix_reg(sc, reg) & ~mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ess_set_mreg_bits(sc, reg, mask)
|
|
|
|
struct ess_softc *sc;
|
|
|
|
u_char reg;
|
|
|
|
u_char mask;
|
|
|
|
{
|
|
|
|
ess_write_mix_reg(sc, reg, ess_read_mix_reg(sc, reg) | mask);
|
|
|
|
}
|