2005-12-24 23:27:29 +03:00
|
|
|
/* $NetBSD: esm.c,v 1.32 2005/12/24 20:27:42 perry Exp $ */
|
2001-01-08 22:54:31 +03:00
|
|
|
|
|
|
|
/*-
|
2002-12-30 08:23:27 +03:00
|
|
|
* Copyright (c) 2002, 2003 Matt Fredette
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
2003-12-04 16:57:30 +03:00
|
|
|
* Copyright (c) 2000, 2001 Rene Hexel <rh@NetBSD.org>
|
2001-01-08 22:54:31 +03:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2000 Taku YAMAMOTO <taku@cent.saitama-u.ac.jp>
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* Taku Id: maestro.c,v 1.12 2000/09/06 03:32:34 taku Exp
|
|
|
|
* FreeBSD: /c/ncvs/src/sys/dev/sound/pci/maestro.c,v 1.4 2000/12/18 01:36:35 cg Exp
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* TODO:
|
|
|
|
* - hardware volume support
|
2002-12-30 08:23:27 +03:00
|
|
|
* - fix 16-bit stereo recording, add 8-bit recording
|
2001-01-08 22:54:31 +03:00
|
|
|
* - MIDI support
|
|
|
|
* - joystick support
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Credits:
|
|
|
|
*
|
|
|
|
* This code is based on the FreeBSD driver written by Taku YAMAMOTO
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Original credits from the FreeBSD driver:
|
|
|
|
*
|
|
|
|
* Part of this code (especially in many magic numbers) was heavily inspired
|
|
|
|
* by the Linux driver originally written by
|
|
|
|
* Alan Cox <alan.cox@linux.org>, modified heavily by
|
|
|
|
* Zach Brown <zab@zabbo.net>.
|
|
|
|
*
|
|
|
|
* busdma()-ize and buffer size reduction were suggested by
|
|
|
|
* Cameron Grant <gandalf@vilnya.demon.co.uk>.
|
|
|
|
* Also he showed me the way to use busdma() suite.
|
|
|
|
*
|
|
|
|
* Internal speaker problems on NEC VersaPro's and Dell Inspiron 7500
|
|
|
|
* were looked at by
|
|
|
|
* Munehiro Matsuda <haro@tk.kubota.co.jp>,
|
|
|
|
* who brought patches based on the Linux driver with some simplification.
|
|
|
|
*/
|
|
|
|
|
2001-11-13 10:48:40 +03:00
|
|
|
#include <sys/cdefs.h>
|
2005-12-24 23:27:29 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: esm.c,v 1.32 2005/12/24 20:27:42 perry Exp $");
|
2001-11-13 10:48:40 +03:00
|
|
|
|
2001-01-08 22:54:31 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
|
|
|
|
#include <machine/bus.h>
|
|
|
|
|
|
|
|
#include <sys/audioio.h>
|
|
|
|
#include <dev/audio_if.h>
|
|
|
|
#include <dev/mulaw.h>
|
|
|
|
#include <dev/auconv.h>
|
|
|
|
#include <dev/ic/ac97var.h>
|
2001-03-08 15:54:45 +03:00
|
|
|
#include <dev/ic/ac97reg.h>
|
2001-01-08 22:54:31 +03:00
|
|
|
|
|
|
|
#include <dev/pci/pcidevs.h>
|
|
|
|
#include <dev/pci/pcivar.h>
|
|
|
|
|
|
|
|
#include <dev/pci/esmreg.h>
|
|
|
|
#include <dev/pci/esmvar.h>
|
|
|
|
|
|
|
|
#define PCI_CBIO 0x10 /* Configuration Base I/O Address */
|
|
|
|
|
|
|
|
/* Debug */
|
|
|
|
#ifdef AUDIO_DEBUG
|
|
|
|
#define DPRINTF(l,x) do { if (esm_debug & (l)) printf x; } while(0)
|
|
|
|
#define DUMPREG(x) do { if (esm_debug & ESM_DEBUG_REG) \
|
|
|
|
esm_dump_regs(x); } while(0)
|
|
|
|
int esm_debug = 0xfffc;
|
|
|
|
#define ESM_DEBUG_CODECIO 0x0001
|
|
|
|
#define ESM_DEBUG_IRQ 0x0002
|
|
|
|
#define ESM_DEBUG_DMA 0x0004
|
|
|
|
#define ESM_DEBUG_TIMER 0x0008
|
|
|
|
#define ESM_DEBUG_REG 0x0010
|
|
|
|
#define ESM_DEBUG_PARAM 0x0020
|
|
|
|
#define ESM_DEBUG_APU 0x0040
|
|
|
|
#define ESM_DEBUG_CODEC 0x0080
|
2001-01-10 02:27:07 +03:00
|
|
|
#define ESM_DEBUG_PCI 0x0100
|
2001-03-08 15:54:45 +03:00
|
|
|
#define ESM_DEBUG_RESUME 0x0200
|
2001-01-08 22:54:31 +03:00
|
|
|
#else
|
|
|
|
#define DPRINTF(x,y) /* nothing */
|
|
|
|
#define DUMPREG(x) /* nothing */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
#define RANGE(n, l, h) if ((n) < (l) || (n) >= (h)) \
|
|
|
|
printf (#n "=%d out of range (%d, %d) in " \
|
|
|
|
__FILE__ ", line %d\n", (n), (l), (h), __LINE__)
|
|
|
|
#else
|
|
|
|
#define RANGE(x,y,z) /* nothing */
|
|
|
|
#endif
|
|
|
|
|
2005-12-24 23:27:29 +03:00
|
|
|
#define inline inline
|
2001-01-08 22:54:31 +03:00
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
static inline void ringbus_setdest(struct esm_softc *, int, int);
|
2001-01-08 22:54:31 +03:00
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
static inline uint16_t wp_rdreg(struct esm_softc *, uint16_t);
|
|
|
|
static inline void wp_wrreg(struct esm_softc *, uint16_t, uint16_t);
|
|
|
|
static inline uint16_t wp_rdapu(struct esm_softc *, int, uint16_t);
|
|
|
|
static inline void wp_wrapu(struct esm_softc *, int, uint16_t,
|
|
|
|
uint16_t);
|
2001-01-08 22:54:31 +03:00
|
|
|
static inline void wp_settimer(struct esm_softc *, u_int);
|
|
|
|
static inline void wp_starttimer(struct esm_softc *);
|
|
|
|
static inline void wp_stoptimer(struct esm_softc *);
|
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
static inline uint16_t wc_rdreg(struct esm_softc *, uint16_t);
|
|
|
|
static inline void wc_wrreg(struct esm_softc *, uint16_t, uint16_t);
|
|
|
|
static inline uint16_t wc_rdchctl(struct esm_softc *, int);
|
|
|
|
static inline void wc_wrchctl(struct esm_softc *, int, uint16_t);
|
2001-01-08 22:54:31 +03:00
|
|
|
|
|
|
|
static inline u_int calc_timer_freq(struct esm_chinfo*);
|
|
|
|
static void set_timer(struct esm_softc *);
|
|
|
|
|
|
|
|
static void esmch_set_format(struct esm_chinfo *,
|
merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework
Summary of changes:
* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.
* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t
* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.
* add `struct device *' parameter to ac97_attach()
* all of audio HW drivers follow audio_hw_if and ac97 changes
2005-01-11 01:01:36 +03:00
|
|
|
const audio_params_t *);
|
2002-12-30 08:23:27 +03:00
|
|
|
static void esmch_combine_input(struct esm_softc *,
|
merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework
Summary of changes:
* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.
* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t
* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.
* add `struct device *' parameter to ac97_attach()
* all of audio HW drivers follow audio_hw_if and ac97 changes
2005-01-11 01:01:36 +03:00
|
|
|
struct esm_chinfo *);
|
2001-01-08 22:54:31 +03:00
|
|
|
|
2001-02-13 02:56:40 +03:00
|
|
|
/* Power Management */
|
|
|
|
void esm_powerhook(int, void *);
|
|
|
|
|
2002-10-01 00:37:04 +04:00
|
|
|
CFATTACH_DECL(esm, sizeof(struct esm_softc),
|
2002-10-02 20:50:59 +04:00
|
|
|
esm_match, esm_attach, NULL, NULL);
|
2001-01-08 22:54:31 +03:00
|
|
|
|
2004-10-29 16:57:15 +04:00
|
|
|
const struct audio_hw_if esm_hw_if = {
|
merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework
Summary of changes:
* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.
* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t
* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.
* add `struct device *' parameter to ac97_attach()
* all of audio HW drivers follow audio_hw_if and ac97 changes
2005-01-11 01:01:36 +03:00
|
|
|
NULL, /* open */
|
|
|
|
NULL, /* close */
|
2001-01-08 22:54:31 +03:00
|
|
|
NULL, /* drain */
|
|
|
|
esm_query_encoding,
|
|
|
|
esm_set_params,
|
|
|
|
esm_round_blocksize,
|
|
|
|
NULL, /* commit_settings */
|
|
|
|
esm_init_output,
|
2002-12-30 08:23:27 +03:00
|
|
|
esm_init_input,
|
2001-01-08 22:54:31 +03:00
|
|
|
NULL, /* start_output */
|
|
|
|
NULL, /* start_input */
|
|
|
|
esm_halt_output,
|
|
|
|
esm_halt_input,
|
|
|
|
NULL, /* speaker_ctl */
|
|
|
|
esm_getdev,
|
|
|
|
NULL, /* getfd */
|
|
|
|
esm_set_port,
|
|
|
|
esm_get_port,
|
|
|
|
esm_query_devinfo,
|
|
|
|
esm_malloc,
|
|
|
|
esm_free,
|
|
|
|
esm_round_buffersize,
|
|
|
|
esm_mappage,
|
|
|
|
esm_get_props,
|
|
|
|
esm_trigger_output,
|
2001-10-03 04:04:47 +04:00
|
|
|
esm_trigger_input,
|
|
|
|
NULL,
|
2001-01-08 22:54:31 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct audio_device esm_device = {
|
|
|
|
"ESS Maestro",
|
|
|
|
"",
|
|
|
|
"esm"
|
|
|
|
};
|
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
#define MAESTRO_NENCODINGS 8
|
|
|
|
static audio_encoding_t esm_encoding[MAESTRO_NENCODINGS] = {
|
|
|
|
{ 0, AudioEulinear, AUDIO_ENCODING_ULINEAR, 8, 0 },
|
2001-01-08 22:54:31 +03:00
|
|
|
{ 1, AudioEmulaw, AUDIO_ENCODING_ULAW, 8,
|
2005-01-15 18:19:51 +03:00
|
|
|
AUDIO_ENCODINGFLAG_EMULATED },
|
|
|
|
{ 2, AudioEalaw, AUDIO_ENCODING_ALAW, 8, AUDIO_ENCODINGFLAG_EMULATED },
|
|
|
|
{ 3, AudioEslinear, AUDIO_ENCODING_SLINEAR, 8, 0 },
|
|
|
|
{ 4, AudioEslinear_le, AUDIO_ENCODING_SLINEAR_LE, 16, 0 },
|
2001-01-08 22:54:31 +03:00
|
|
|
{ 5, AudioEulinear_le, AUDIO_ENCODING_ULINEAR_LE, 16,
|
2005-01-15 18:19:51 +03:00
|
|
|
AUDIO_ENCODINGFLAG_EMULATED },
|
2001-01-08 22:54:31 +03:00
|
|
|
{ 6, AudioEslinear_be, AUDIO_ENCODING_SLINEAR_BE, 16,
|
2005-01-15 18:19:51 +03:00
|
|
|
AUDIO_ENCODINGFLAG_EMULATED },
|
2001-01-08 22:54:31 +03:00
|
|
|
{ 7, AudioEulinear_be, AUDIO_ENCODING_ULINEAR_BE, 16,
|
2005-01-15 18:19:51 +03:00
|
|
|
AUDIO_ENCODINGFLAG_EMULATED },
|
2001-01-08 22:54:31 +03:00
|
|
|
};
|
|
|
|
|
merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework
Summary of changes:
* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.
* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t
* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.
* add `struct device *' parameter to ac97_attach()
* all of audio HW drivers follow audio_hw_if and ac97 changes
2005-01-11 01:01:36 +03:00
|
|
|
#define ESM_NFORMATS 4
|
|
|
|
static const struct audio_format esm_formats[ESM_NFORMATS] = {
|
|
|
|
{NULL, AUMODE_PLAY | AUMODE_RECORD, AUDIO_ENCODING_SLINEAR_LE, 16, 16,
|
|
|
|
2, AUFMT_STEREO, 0, {4000, 48000}},
|
|
|
|
{NULL, AUMODE_PLAY | AUMODE_RECORD, AUDIO_ENCODING_SLINEAR_LE, 16, 16,
|
|
|
|
1, AUFMT_MONAURAL, 0, {4000, 48000}},
|
|
|
|
{NULL, AUMODE_PLAY | AUMODE_RECORD, AUDIO_ENCODING_ULINEAR_LE, 8, 8,
|
|
|
|
2, AUFMT_STEREO, 0, {4000, 48000}},
|
|
|
|
{NULL, AUMODE_PLAY | AUMODE_RECORD, AUDIO_ENCODING_ULINEAR_LE, 8, 8,
|
|
|
|
1, AUFMT_MONAURAL, 0, {4000, 48000}},
|
|
|
|
};
|
2001-01-10 02:27:07 +03:00
|
|
|
|
|
|
|
static const struct esm_quirks esm_quirks[] = {
|
|
|
|
/* COMPAL 38W2 OEM Notebook, e.g. Dell INSPIRON 5000e */
|
|
|
|
{ PCI_VENDOR_COMPAL, PCI_PRODUCT_COMPAL_38W2, ESM_QUIRKF_SWAPPEDCH },
|
|
|
|
|
2001-01-26 12:22:18 +03:00
|
|
|
/* COMPAQ Armada M700 Notebook */
|
|
|
|
{ PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_M700, ESM_QUIRKF_SWAPPEDCH },
|
|
|
|
|
2001-01-10 02:27:07 +03:00
|
|
|
/* NEC Versa Pro LX VA26D */
|
|
|
|
{ PCI_VENDOR_NEC, PCI_PRODUCT_NEC_VA26D, ESM_QUIRKF_GPIO },
|
|
|
|
|
|
|
|
/* NEC Versa LX */
|
2001-01-26 13:04:43 +03:00
|
|
|
{ PCI_VENDOR_NEC, PCI_PRODUCT_NEC_VERSALX, ESM_QUIRKF_GPIO },
|
|
|
|
|
2001-04-25 07:06:11 +04:00
|
|
|
/* Toshiba Portege */
|
|
|
|
{ PCI_VENDOR_TOSHIBA2, PCI_PRODUCT_TOSHIBA2_PORTEGE, ESM_QUIRKF_SWAPPEDCH }
|
2001-01-10 02:27:07 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
enum esm_quirk_flags
|
|
|
|
esm_get_quirks(pcireg_t subid)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < (sizeof esm_quirks / sizeof esm_quirks[0]); i++) {
|
|
|
|
if (PCI_VENDOR(subid) == esm_quirks[i].eq_vendor &&
|
|
|
|
PCI_PRODUCT(subid) == esm_quirks[i].eq_product) {
|
|
|
|
return esm_quirks[i].eq_quirks;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-01-08 22:54:31 +03:00
|
|
|
#ifdef AUDIO_DEBUG
|
|
|
|
struct esm_reg_info {
|
|
|
|
int offset; /* register offset */
|
|
|
|
int width; /* 1/2/4 bytes */
|
|
|
|
} dump_regs[] = {
|
|
|
|
{ PORT_WAVCACHE_CTRL, 2 },
|
|
|
|
{ PORT_HOSTINT_CTRL, 2 },
|
|
|
|
{ PORT_HOSTINT_STAT, 2 },
|
|
|
|
{ PORT_HWVOL_VOICE_SHADOW, 1 },
|
|
|
|
{ PORT_HWVOL_VOICE, 1 },
|
|
|
|
{ PORT_HWVOL_MASTER_SHADOW, 1 },
|
|
|
|
{ PORT_HWVOL_MASTER, 1 },
|
|
|
|
{ PORT_RINGBUS_CTRL, 4 },
|
|
|
|
{ PORT_GPIO_DATA, 2 },
|
|
|
|
{ PORT_GPIO_MASK, 2 },
|
|
|
|
{ PORT_GPIO_DIR, 2 },
|
|
|
|
{ PORT_ASSP_CTRL_A, 1 },
|
|
|
|
{ PORT_ASSP_CTRL_B, 1 },
|
|
|
|
{ PORT_ASSP_CTRL_C, 1 },
|
2001-01-10 02:27:07 +03:00
|
|
|
{ PORT_ASSP_INT_STAT, 1 }
|
2001-01-08 22:54:31 +03:00
|
|
|
};
|
|
|
|
|
2001-01-09 09:36:13 +03:00
|
|
|
static void
|
|
|
|
esm_dump_regs(struct esm_softc *ess)
|
2001-01-08 22:54:31 +03:00
|
|
|
{
|
2001-01-10 02:27:07 +03:00
|
|
|
int i;
|
2001-01-08 22:54:31 +03:00
|
|
|
|
|
|
|
printf("%s registers:", ess->sc_dev.dv_xname);
|
2001-01-10 02:27:07 +03:00
|
|
|
for (i = 0; i < (sizeof dump_regs / sizeof dump_regs[0]); i++) {
|
2001-01-08 22:54:31 +03:00
|
|
|
if (i % 5 == 0)
|
|
|
|
printf("\n");
|
|
|
|
printf("0x%2.2x: ", dump_regs[i].offset);
|
|
|
|
switch(dump_regs[i].width) {
|
|
|
|
case 4:
|
|
|
|
printf("%8.8x, ", bus_space_read_4(ess->st, ess->sh,
|
|
|
|
dump_regs[i].offset));
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
printf("%4.4x, ", bus_space_read_2(ess->st, ess->sh,
|
|
|
|
dump_regs[i].offset));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("%2.2x, ",
|
|
|
|
bus_space_read_1(ess->st, ess->sh,
|
|
|
|
dump_regs[i].offset));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-01-10 02:27:07 +03:00
|
|
|
|
2001-01-08 22:54:31 +03:00
|
|
|
/* -----------------------------
|
|
|
|
* Subsystems.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Codec/Ringbus */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
int
|
2005-01-15 18:19:51 +03:00
|
|
|
esm_read_codec(void *sc, uint8_t regno, uint16_t *result)
|
2001-01-08 22:54:31 +03:00
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
struct esm_softc *ess;
|
2001-01-08 22:54:31 +03:00
|
|
|
unsigned t;
|
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
ess = sc;
|
2001-01-08 22:54:31 +03:00
|
|
|
/* We have to wait for a SAFE time to write addr/data */
|
|
|
|
for (t = 0; t < 20; t++) {
|
|
|
|
if ((bus_space_read_1(ess->st, ess->sh, PORT_CODEC_STAT)
|
|
|
|
& CODEC_STAT_MASK) != CODEC_STAT_PROGLESS)
|
|
|
|
break;
|
|
|
|
delay(2); /* 20.8us / 13 */
|
|
|
|
}
|
|
|
|
if (t == 20)
|
|
|
|
printf("%s: esm_read_codec() PROGLESS timed out.\n",
|
|
|
|
ess->sc_dev.dv_xname);
|
|
|
|
|
|
|
|
bus_space_write_1(ess->st, ess->sh, PORT_CODEC_CMD,
|
|
|
|
CODEC_CMD_READ | regno);
|
|
|
|
delay(21); /* AC97 cycle = 20.8usec */
|
|
|
|
|
|
|
|
/* Wait for data retrieve */
|
|
|
|
for (t = 0; t < 20; t++) {
|
|
|
|
if ((bus_space_read_1(ess->st, ess->sh, PORT_CODEC_STAT)
|
|
|
|
& CODEC_STAT_MASK) == CODEC_STAT_RW_DONE)
|
|
|
|
break;
|
|
|
|
delay(2); /* 20.8us / 13 */
|
|
|
|
}
|
|
|
|
if (t == 20)
|
|
|
|
/* Timed out, but perform dummy read. */
|
|
|
|
printf("%s: esm_read_codec() RW_DONE timed out.\n",
|
|
|
|
ess->sc_dev.dv_xname);
|
|
|
|
|
|
|
|
*result = bus_space_read_2(ess->st, ess->sh, PORT_CODEC_REG);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-01-15 18:19:51 +03:00
|
|
|
esm_write_codec(void *sc, uint8_t regno, uint16_t data)
|
2001-01-08 22:54:31 +03:00
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
struct esm_softc *ess;
|
2001-01-08 22:54:31 +03:00
|
|
|
unsigned t;
|
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
ess = sc;
|
2001-01-08 22:54:31 +03:00
|
|
|
/* We have to wait for a SAFE time to write addr/data */
|
|
|
|
for (t = 0; t < 20; t++) {
|
|
|
|
if ((bus_space_read_1(ess->st, ess->sh, PORT_CODEC_STAT)
|
|
|
|
& CODEC_STAT_MASK) != CODEC_STAT_PROGLESS)
|
|
|
|
break;
|
|
|
|
delay(2); /* 20.8us / 13 */
|
|
|
|
}
|
|
|
|
if (t == 20) {
|
|
|
|
/* Timed out. Abort writing. */
|
|
|
|
printf("%s: esm_write_codec() PROGLESS timed out.\n",
|
|
|
|
ess->sc_dev.dv_xname);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bus_space_write_2(ess->st, ess->sh, PORT_CODEC_REG, data);
|
|
|
|
bus_space_write_1(ess->st, ess->sh, PORT_CODEC_CMD,
|
|
|
|
CODEC_CMD_WRITE | regno);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
ringbus_setdest(struct esm_softc *ess, int src, int dest)
|
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
uint32_t data;
|
2001-01-08 22:54:31 +03:00
|
|
|
|
|
|
|
data = bus_space_read_4(ess->st, ess->sh, PORT_RINGBUS_CTRL);
|
|
|
|
data &= ~(0xfU << src);
|
|
|
|
data |= (0xfU & dest) << src;
|
|
|
|
bus_space_write_4(ess->st, ess->sh, PORT_RINGBUS_CTRL, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Wave Processor */
|
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
static inline uint16_t
|
|
|
|
wp_rdreg(struct esm_softc *ess, uint16_t reg)
|
2001-01-08 22:54:31 +03:00
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
|
2001-01-08 22:54:31 +03:00
|
|
|
bus_space_write_2(ess->st, ess->sh, PORT_DSP_INDEX, reg);
|
|
|
|
return bus_space_read_2(ess->st, ess->sh, PORT_DSP_DATA);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
2005-01-15 18:19:51 +03:00
|
|
|
wp_wrreg(struct esm_softc *ess, uint16_t reg, uint16_t data)
|
2001-01-08 22:54:31 +03:00
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
|
2001-01-08 22:54:31 +03:00
|
|
|
bus_space_write_2(ess->st, ess->sh, PORT_DSP_INDEX, reg);
|
|
|
|
bus_space_write_2(ess->st, ess->sh, PORT_DSP_DATA, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
2005-01-15 18:19:51 +03:00
|
|
|
apu_setindex(struct esm_softc *ess, uint16_t reg)
|
2001-01-08 22:54:31 +03:00
|
|
|
{
|
|
|
|
int t;
|
|
|
|
|
|
|
|
wp_wrreg(ess, WPREG_CRAM_PTR, reg);
|
|
|
|
/* Sometimes WP fails to set apu register index. */
|
|
|
|
for (t = 0; t < 1000; t++) {
|
|
|
|
if (bus_space_read_2(ess->st, ess->sh, PORT_DSP_DATA) == reg)
|
|
|
|
break;
|
|
|
|
bus_space_write_2(ess->st, ess->sh, PORT_DSP_DATA, reg);
|
|
|
|
}
|
|
|
|
if (t == 1000)
|
|
|
|
printf("%s: apu_setindex() timed out.\n", ess->sc_dev.dv_xname);
|
|
|
|
}
|
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
static inline uint16_t
|
|
|
|
wp_rdapu(struct esm_softc *ess, int ch, uint16_t reg)
|
2001-01-08 22:54:31 +03:00
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
uint16_t ret;
|
2001-01-08 22:54:31 +03:00
|
|
|
|
|
|
|
apu_setindex(ess, ((unsigned)ch << 4) + reg);
|
|
|
|
ret = wp_rdreg(ess, WPREG_DATA_PORT);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
2005-01-15 18:19:51 +03:00
|
|
|
wp_wrapu(struct esm_softc *ess, int ch, uint16_t reg, uint16_t data)
|
2001-01-08 22:54:31 +03:00
|
|
|
{
|
|
|
|
int t;
|
|
|
|
|
|
|
|
DPRINTF(ESM_DEBUG_APU,
|
|
|
|
("wp_wrapu(%p, ch=%d, reg=0x%x, data=0x%04x)\n",
|
|
|
|
ess, ch, reg, data));
|
|
|
|
|
|
|
|
apu_setindex(ess, ((unsigned)ch << 4) + reg);
|
|
|
|
wp_wrreg(ess, WPREG_DATA_PORT, data);
|
|
|
|
for (t = 0; t < 1000; t++) {
|
|
|
|
if (bus_space_read_2(ess->st, ess->sh, PORT_DSP_DATA) == data)
|
|
|
|
break;
|
|
|
|
bus_space_write_2(ess->st, ess->sh, PORT_DSP_DATA, data);
|
|
|
|
}
|
|
|
|
if (t == 1000)
|
|
|
|
printf("%s: wp_wrapu() timed out.\n", ess->sc_dev.dv_xname);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
wp_settimer(struct esm_softc *ess, u_int freq)
|
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
u_int clock;
|
|
|
|
u_int prescale, divide;
|
2001-01-08 22:54:31 +03:00
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
clock = 48000 << 2;
|
|
|
|
prescale = 0;
|
|
|
|
divide = (freq != 0) ? (clock / freq) : ~0;
|
2001-01-08 22:54:31 +03:00
|
|
|
RANGE(divide, WPTIMER_MINDIV, WPTIMER_MAXDIV);
|
|
|
|
|
|
|
|
for (; divide > 32 << 1; divide >>= 1)
|
|
|
|
prescale++;
|
|
|
|
divide = (divide + 1) >> 1;
|
|
|
|
|
|
|
|
for (; prescale < 7 && divide > 2 && !(divide & 1); divide >>= 1)
|
|
|
|
prescale++;
|
|
|
|
|
|
|
|
DPRINTF(ESM_DEBUG_TIMER,
|
|
|
|
("wp_settimer(%p, %u): clock = %u, prescale = %u, divide = %u\n",
|
|
|
|
ess, freq, clock, prescale, divide));
|
|
|
|
|
|
|
|
wp_wrreg(ess, WPREG_TIMER_ENABLE, 0);
|
|
|
|
wp_wrreg(ess, WPREG_TIMER_FREQ,
|
|
|
|
(prescale << WP_TIMER_FREQ_PRESCALE_SHIFT) | (divide - 1));
|
|
|
|
wp_wrreg(ess, WPREG_TIMER_ENABLE, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
wp_starttimer(struct esm_softc *ess)
|
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
|
2001-01-08 22:54:31 +03:00
|
|
|
wp_wrreg(ess, WPREG_TIMER_START, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
wp_stoptimer(struct esm_softc *ess)
|
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
|
2001-01-08 22:54:31 +03:00
|
|
|
wp_wrreg(ess, WPREG_TIMER_START, 0);
|
|
|
|
bus_space_write_2(ess->st, ess->sh, PORT_INT_STAT, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* WaveCache */
|
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
static inline uint16_t
|
|
|
|
wc_rdreg(struct esm_softc *ess, uint16_t reg)
|
2001-01-08 22:54:31 +03:00
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
|
2001-01-08 22:54:31 +03:00
|
|
|
bus_space_write_2(ess->st, ess->sh, PORT_WAVCACHE_INDEX, reg);
|
|
|
|
return bus_space_read_2(ess->st, ess->sh, PORT_WAVCACHE_DATA);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
2005-01-15 18:19:51 +03:00
|
|
|
wc_wrreg(struct esm_softc *ess, uint16_t reg, uint16_t data)
|
2001-01-08 22:54:31 +03:00
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
|
2001-01-08 22:54:31 +03:00
|
|
|
bus_space_write_2(ess->st, ess->sh, PORT_WAVCACHE_INDEX, reg);
|
|
|
|
bus_space_write_2(ess->st, ess->sh, PORT_WAVCACHE_DATA, data);
|
|
|
|
}
|
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
static inline uint16_t
|
2001-01-08 22:54:31 +03:00
|
|
|
wc_rdchctl(struct esm_softc *ess, int ch)
|
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
|
2001-01-08 22:54:31 +03:00
|
|
|
return wc_rdreg(ess, ch << 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
2005-01-15 18:19:51 +03:00
|
|
|
wc_wrchctl(struct esm_softc *ess, int ch, uint16_t data)
|
2001-01-08 22:54:31 +03:00
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
|
2001-01-08 22:54:31 +03:00
|
|
|
wc_wrreg(ess, ch << 3, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Power management */
|
|
|
|
|
|
|
|
void
|
|
|
|
esm_power(struct esm_softc *ess, int status)
|
|
|
|
{
|
2002-01-14 22:24:39 +03:00
|
|
|
pcireg_t data;
|
|
|
|
int pmcapreg;
|
|
|
|
|
|
|
|
if (pci_get_capability(ess->pc, ess->tag, PCI_CAP_PWRMGMT,
|
|
|
|
&pmcapreg, 0)) {
|
2002-12-23 05:58:36 +03:00
|
|
|
data = pci_conf_read(ess->pc, ess->tag, pmcapreg + PCI_PMCSR);
|
2002-01-14 22:24:39 +03:00
|
|
|
if ((data && PCI_PMCSR_STATE_MASK) != status)
|
2002-12-23 05:58:36 +03:00
|
|
|
pci_conf_write(ess->pc, ess->tag,
|
|
|
|
pmcapreg + PCI_PMCSR, status);
|
2002-01-14 22:24:39 +03:00
|
|
|
}
|
2001-01-08 22:54:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* -----------------------------
|
|
|
|
* Controller.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
|
|
|
esm_attach_codec(void *sc, struct ac97_codec_if *codec_if)
|
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
struct esm_softc *ess;
|
2001-01-08 22:54:31 +03:00
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
ess = sc;
|
2001-01-08 22:54:31 +03:00
|
|
|
ess->codec_if = codec_if;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-09-22 16:20:24 +04:00
|
|
|
int
|
2001-01-08 22:54:31 +03:00
|
|
|
esm_reset_codec(void *sc)
|
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
|
2004-09-22 16:20:24 +04:00
|
|
|
return 0;
|
2001-01-08 22:54:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-01-10 02:27:07 +03:00
|
|
|
enum ac97_host_flags
|
|
|
|
esm_flags_codec(void *sc)
|
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
struct esm_softc *ess;
|
2001-01-10 02:27:07 +03:00
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
ess = sc;
|
2001-01-10 02:27:07 +03:00
|
|
|
return ess->codec_flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-01-08 22:54:31 +03:00
|
|
|
void
|
|
|
|
esm_initcodec(struct esm_softc *ess)
|
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
uint16_t data;
|
2001-01-08 22:54:31 +03:00
|
|
|
|
|
|
|
DPRINTF(ESM_DEBUG_CODEC, ("esm_initcodec(%p)\n", ess));
|
|
|
|
|
|
|
|
if (bus_space_read_4(ess->st, ess->sh, PORT_RINGBUS_CTRL)
|
|
|
|
& RINGBUS_CTRL_ACLINK_ENABLED) {
|
|
|
|
bus_space_write_4(ess->st, ess->sh, PORT_RINGBUS_CTRL, 0);
|
|
|
|
delay(104); /* 20.8us * (4 + 1) */
|
|
|
|
}
|
|
|
|
/* XXX - 2nd codec should be looked at. */
|
|
|
|
bus_space_write_4(ess->st, ess->sh, PORT_RINGBUS_CTRL,
|
|
|
|
RINGBUS_CTRL_AC97_SWRESET);
|
|
|
|
delay(2);
|
|
|
|
bus_space_write_4(ess->st, ess->sh, PORT_RINGBUS_CTRL,
|
|
|
|
RINGBUS_CTRL_ACLINK_ENABLED);
|
|
|
|
delay(21);
|
|
|
|
|
|
|
|
esm_read_codec(ess, 0, &data);
|
|
|
|
if (bus_space_read_1(ess->st, ess->sh, PORT_CODEC_STAT)
|
|
|
|
& CODEC_STAT_MASK) {
|
|
|
|
bus_space_write_4(ess->st, ess->sh, PORT_RINGBUS_CTRL, 0);
|
|
|
|
delay(21);
|
|
|
|
|
|
|
|
/* Try cold reset. */
|
|
|
|
printf("%s: will perform cold reset.\n", ess->sc_dev.dv_xname);
|
|
|
|
data = bus_space_read_2(ess->st, ess->sh, PORT_GPIO_DIR);
|
|
|
|
if (pci_conf_read(ess->pc, ess->tag, 0x58) & 1)
|
|
|
|
data |= 0x10;
|
|
|
|
data |= 0x009 &
|
|
|
|
~bus_space_read_2(ess->st, ess->sh, PORT_GPIO_DATA);
|
|
|
|
bus_space_write_2(ess->st, ess->sh, PORT_GPIO_MASK, 0xff6);
|
|
|
|
bus_space_write_2(ess->st, ess->sh, PORT_GPIO_DIR,
|
|
|
|
data | 0x009);
|
|
|
|
bus_space_write_2(ess->st, ess->sh, PORT_GPIO_DATA, 0x000);
|
|
|
|
delay(2);
|
|
|
|
bus_space_write_2(ess->st, ess->sh, PORT_GPIO_DATA, 0x001);
|
|
|
|
delay(1);
|
|
|
|
bus_space_write_2(ess->st, ess->sh, PORT_GPIO_DATA, 0x009);
|
|
|
|
delay(500000);
|
|
|
|
bus_space_write_2(ess->st, ess->sh, PORT_GPIO_DIR, data);
|
|
|
|
delay(84); /* 20.8us * 4 */
|
|
|
|
bus_space_write_4(ess->st, ess->sh, PORT_RINGBUS_CTRL,
|
|
|
|
RINGBUS_CTRL_ACLINK_ENABLED);
|
|
|
|
delay(21);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
esm_init(struct esm_softc *ess)
|
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
|
2001-01-08 22:54:31 +03:00
|
|
|
/* Reset direct sound. */
|
|
|
|
bus_space_write_2(ess->st, ess->sh, PORT_HOSTINT_CTRL,
|
|
|
|
HOSTINT_CTRL_DSOUND_RESET);
|
|
|
|
delay(10000);
|
|
|
|
bus_space_write_2(ess->st, ess->sh, PORT_HOSTINT_CTRL, 0);
|
|
|
|
delay(10000);
|
|
|
|
|
|
|
|
/* Enable direct sound interruption. */
|
|
|
|
bus_space_write_2(ess->st, ess->sh, PORT_HOSTINT_CTRL,
|
|
|
|
HOSTINT_CTRL_DSOUND_INT_ENABLED);
|
|
|
|
|
|
|
|
/* Setup Wave Processor. */
|
|
|
|
|
|
|
|
/* Enable WaveCache */
|
|
|
|
wp_wrreg(ess, WPREG_WAVE_ROMRAM,
|
|
|
|
WP_WAVE_VIRTUAL_ENABLED | WP_WAVE_DRAM_ENABLED);
|
|
|
|
bus_space_write_2(ess->st, ess->sh, PORT_WAVCACHE_CTRL,
|
|
|
|
WAVCACHE_ENABLED | WAVCACHE_WTSIZE_4MB);
|
|
|
|
|
|
|
|
/* Setup Codec/Ringbus. */
|
|
|
|
esm_initcodec(ess);
|
|
|
|
bus_space_write_4(ess->st, ess->sh, PORT_RINGBUS_CTRL,
|
|
|
|
RINGBUS_CTRL_RINGBUS_ENABLED | RINGBUS_CTRL_ACLINK_ENABLED);
|
|
|
|
|
2002-12-30 08:23:27 +03:00
|
|
|
/* Undocumented registers from the Linux driver. */
|
|
|
|
wp_wrreg(ess, 0x8, 0xB004);
|
|
|
|
wp_wrreg(ess, 0x9, 0x001B);
|
|
|
|
wp_wrreg(ess, 0xA, 0x8000);
|
|
|
|
wp_wrreg(ess, 0xB, 0x3F37);
|
|
|
|
wp_wrreg(ess, 0xD, 0x7632);
|
|
|
|
|
|
|
|
wp_wrreg(ess, WPREG_BASE, 0x8598); /* Parallel I/O */
|
2001-01-08 22:54:31 +03:00
|
|
|
ringbus_setdest(ess, RINGBUS_SRC_ADC,
|
|
|
|
RINGBUS_DEST_STEREO | RINGBUS_DEST_DSOUND_IN);
|
|
|
|
ringbus_setdest(ess, RINGBUS_SRC_DSOUND,
|
|
|
|
RINGBUS_DEST_STEREO | RINGBUS_DEST_DAC);
|
|
|
|
|
|
|
|
/* Setup ASSP. Needed for Dell Inspiron 7500? */
|
|
|
|
bus_space_write_1(ess->st, ess->sh, PORT_ASSP_CTRL_B, 0x00);
|
|
|
|
bus_space_write_1(ess->st, ess->sh, PORT_ASSP_CTRL_A, 0x03);
|
|
|
|
bus_space_write_1(ess->st, ess->sh, PORT_ASSP_CTRL_C, 0x00);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Setup GPIO.
|
|
|
|
* There seems to be speciality with NEC systems.
|
|
|
|
*/
|
2001-01-10 02:27:07 +03:00
|
|
|
if (esm_get_quirks(ess->subid) & ESM_QUIRKF_GPIO) {
|
|
|
|
bus_space_write_2(ess->st, ess->sh, PORT_GPIO_MASK,
|
|
|
|
0x9ff);
|
|
|
|
bus_space_write_2(ess->st, ess->sh, PORT_GPIO_DIR,
|
|
|
|
bus_space_read_2(ess->st, ess->sh, PORT_GPIO_DIR) |
|
|
|
|
0x600);
|
|
|
|
bus_space_write_2(ess->st, ess->sh, PORT_GPIO_DATA,
|
|
|
|
0x200);
|
2001-01-08 22:54:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
DUMPREG(ess);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Channel controller. */
|
|
|
|
|
|
|
|
int
|
|
|
|
esm_init_output (void *sc, void *start, int size)
|
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
struct esm_softc *ess;
|
2001-01-08 22:54:31 +03:00
|
|
|
struct esm_dma *p;
|
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
ess = sc;
|
2002-12-30 08:23:27 +03:00
|
|
|
p = &ess->sc_dma;
|
|
|
|
if ((caddr_t)start != p->addr + MAESTRO_PLAYBUF_OFF) {
|
2001-01-08 22:54:31 +03:00
|
|
|
printf("%s: esm_init_output: bad addr %p\n",
|
|
|
|
ess->sc_dev.dv_xname, start);
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
2002-12-30 08:23:27 +03:00
|
|
|
ess->pch.base = DMAADDR(p) + MAESTRO_PLAYBUF_OFF;
|
2001-01-08 22:54:31 +03:00
|
|
|
|
|
|
|
DPRINTF(ESM_DEBUG_DMA, ("%s: pch.base = 0x%x\n",
|
|
|
|
ess->sc_dev.dv_xname, ess->pch.base));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-12-30 08:23:27 +03:00
|
|
|
int
|
|
|
|
esm_init_input (void *sc, void *start, int size)
|
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
struct esm_softc *ess;
|
2002-12-30 08:23:27 +03:00
|
|
|
struct esm_dma *p;
|
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
ess = sc;
|
2002-12-30 08:23:27 +03:00
|
|
|
p = &ess->sc_dma;
|
|
|
|
if ((caddr_t)start != p->addr + MAESTRO_RECBUF_OFF) {
|
|
|
|
printf("%s: esm_init_input: bad addr %p\n",
|
|
|
|
ess->sc_dev.dv_xname, start);
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (ess->rch.aputype) {
|
|
|
|
case APUTYPE_16BITSTEREO:
|
|
|
|
ess->rch.base = DMAADDR(p) + MAESTRO_RECBUF_L_OFF;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ess->rch.base = DMAADDR(p) + MAESTRO_RECBUF_OFF;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
DPRINTF(ESM_DEBUG_DMA, ("%s: rch.base = 0x%x\n",
|
|
|
|
ess->sc_dev.dv_xname, ess->rch.base));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2001-01-08 22:54:31 +03:00
|
|
|
|
|
|
|
int
|
|
|
|
esm_trigger_output(void *sc, void *start, void *end, int blksize,
|
merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework
Summary of changes:
* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.
* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t
* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.
* add `struct device *' parameter to ac97_attach()
* all of audio HW drivers follow audio_hw_if and ac97 changes
2005-01-11 01:01:36 +03:00
|
|
|
void (*intr)(void *), void *arg, const audio_params_t *param)
|
2001-01-08 22:54:31 +03:00
|
|
|
{
|
|
|
|
size_t size;
|
2005-01-15 18:19:51 +03:00
|
|
|
struct esm_softc *ess;
|
|
|
|
struct esm_chinfo *ch;
|
|
|
|
struct esm_dma *p;
|
|
|
|
int pan, choffset;
|
|
|
|
int i, nch;
|
|
|
|
unsigned speed, offset, wpwa, dv;
|
|
|
|
uint16_t apuch;
|
2001-01-08 22:54:31 +03:00
|
|
|
|
|
|
|
DPRINTF(ESM_DEBUG_DMA,
|
|
|
|
("esm_trigger_output(%p, %p, %p, 0x%x, %p, %p, %p)\n",
|
|
|
|
sc, start, end, blksize, intr, arg, param));
|
2005-01-15 18:19:51 +03:00
|
|
|
ess = sc;
|
|
|
|
ch = &ess->pch;
|
|
|
|
pan = 0;
|
|
|
|
nch = 1;
|
|
|
|
speed = ch->sample_rate;
|
|
|
|
apuch = ch->num << 1;
|
2001-01-08 22:54:31 +03:00
|
|
|
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (ess->pactive) {
|
|
|
|
printf("%s: esm_trigger_output: already running",
|
|
|
|
ess->sc_dev.dv_xname);
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
ess->sc_pintr = intr;
|
|
|
|
ess->sc_parg = arg;
|
2002-12-30 08:23:27 +03:00
|
|
|
p = &ess->sc_dma;
|
|
|
|
if ((caddr_t)start != p->addr + MAESTRO_PLAYBUF_OFF) {
|
2001-01-08 22:54:31 +03:00
|
|
|
printf("%s: esm_trigger_output: bad addr %p\n",
|
|
|
|
ess->sc_dev.dv_xname, start);
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ess->pch.blocksize = blksize;
|
|
|
|
ess->pch.apublk = blksize >> 1;
|
|
|
|
ess->pactive = 1;
|
|
|
|
|
|
|
|
size = (size_t)(((caddr_t)end - (caddr_t)start) >> 1);
|
2002-12-30 08:23:27 +03:00
|
|
|
choffset = MAESTRO_PLAYBUF_OFF;
|
2001-01-08 22:54:31 +03:00
|
|
|
offset = choffset >> 1;
|
2002-12-30 08:23:27 +03:00
|
|
|
wpwa = APU_USE_SYSMEM | ((offset >> 8) & APU_64KPAGE_MASK);
|
2001-01-08 22:54:31 +03:00
|
|
|
|
|
|
|
DPRINTF(ESM_DEBUG_DMA,
|
2004-07-08 22:08:58 +04:00
|
|
|
("choffs=0x%x, wpwa=0x%x, size=0x%lx words\n",
|
|
|
|
choffset, wpwa, (unsigned long int)size));
|
2001-01-08 22:54:31 +03:00
|
|
|
|
|
|
|
switch (ch->aputype) {
|
|
|
|
case APUTYPE_16BITSTEREO:
|
|
|
|
ess->pch.apublk >>= 1;
|
|
|
|
wpwa >>= 1;
|
|
|
|
size >>= 1;
|
|
|
|
offset >>= 1;
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
case APUTYPE_8BITSTEREO:
|
2001-01-10 02:27:07 +03:00
|
|
|
if (ess->codec_flags & AC97_HOST_SWAPPED_CHANNELS)
|
|
|
|
pan = 8;
|
|
|
|
else
|
|
|
|
pan = -8;
|
|
|
|
nch++;
|
2001-01-08 22:54:31 +03:00
|
|
|
break;
|
|
|
|
case APUTYPE_8BITLINEAR:
|
|
|
|
ess->pch.apublk <<= 1;
|
|
|
|
speed >>= 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-12-30 08:23:27 +03:00
|
|
|
ess->pch.apubase = offset;
|
2001-01-08 22:54:31 +03:00
|
|
|
ess->pch.apubuf = size;
|
|
|
|
ess->pch.nextirq = ess->pch.apublk;
|
|
|
|
|
|
|
|
set_timer(ess);
|
|
|
|
wp_starttimer(ess);
|
|
|
|
|
|
|
|
dv = (((speed % 48000) << 16) + 24000) / 48000
|
|
|
|
+ ((speed / 48000) << 16);
|
|
|
|
|
2001-01-10 02:27:07 +03:00
|
|
|
for (i = nch-1; i >= 0; i--) {
|
|
|
|
wp_wrapu(ess, apuch + i, APUREG_WAVESPACE, wpwa & 0xff00);
|
|
|
|
wp_wrapu(ess, apuch + i, APUREG_CURPTR, offset);
|
|
|
|
wp_wrapu(ess, apuch + i, APUREG_ENDPTR, offset + size);
|
|
|
|
wp_wrapu(ess, apuch + i, APUREG_LOOPLEN, size - 1);
|
|
|
|
wp_wrapu(ess, apuch + i, APUREG_AMPLITUDE, 0xe800);
|
|
|
|
wp_wrapu(ess, apuch + i, APUREG_POSITION, 0x8f00
|
2001-01-08 22:54:31 +03:00
|
|
|
| (RADIUS_CENTERCIRCLE << APU_RADIUS_SHIFT)
|
|
|
|
| ((PAN_FRONT + pan) << APU_PAN_SHIFT));
|
2001-01-10 02:27:07 +03:00
|
|
|
wp_wrapu(ess, apuch + i, APUREG_FREQ_LOBYTE, APU_plus6dB
|
2001-01-08 22:54:31 +03:00
|
|
|
| ((dv & 0xff) << APU_FREQ_LOBYTE_SHIFT));
|
2001-01-10 02:27:07 +03:00
|
|
|
wp_wrapu(ess, apuch + i, APUREG_FREQ_HIWORD, dv >> 8);
|
2001-01-08 22:54:31 +03:00
|
|
|
|
|
|
|
if (ch->aputype == APUTYPE_16BITSTEREO)
|
|
|
|
wpwa |= APU_STEREO >> 1;
|
|
|
|
pan = -pan;
|
2001-01-10 02:27:07 +03:00
|
|
|
}
|
2001-01-08 22:54:31 +03:00
|
|
|
|
|
|
|
wc_wrchctl(ess, apuch, ch->wcreg_tpl);
|
2001-01-10 02:27:07 +03:00
|
|
|
if (nch > 1)
|
|
|
|
wc_wrchctl(ess, apuch + 1, ch->wcreg_tpl);
|
2001-01-08 22:54:31 +03:00
|
|
|
|
|
|
|
wp_wrapu(ess, apuch, APUREG_APUTYPE,
|
|
|
|
(ch->aputype << APU_APUTYPE_SHIFT) | APU_DMA_ENABLED | 0xf);
|
|
|
|
if (ch->wcreg_tpl & WAVCACHE_CHCTL_STEREO)
|
|
|
|
wp_wrapu(ess, apuch + 1, APUREG_APUTYPE,
|
|
|
|
(ch->aputype << APU_APUTYPE_SHIFT) | APU_DMA_ENABLED | 0xf);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
esm_trigger_input(void *sc, void *start, void *end, int blksize,
|
merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework
Summary of changes:
* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.
* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t
* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.
* add `struct device *' parameter to ac97_attach()
* all of audio HW drivers follow audio_hw_if and ac97 changes
2005-01-11 01:01:36 +03:00
|
|
|
void (*intr)(void *), void *arg, const audio_params_t *param)
|
2001-01-08 22:54:31 +03:00
|
|
|
{
|
2002-12-30 08:23:27 +03:00
|
|
|
size_t size;
|
|
|
|
size_t mixsize;
|
2005-01-15 18:19:51 +03:00
|
|
|
struct esm_softc *ess;
|
|
|
|
struct esm_chinfo *ch;
|
|
|
|
struct esm_dma *p;
|
|
|
|
uint32_t chctl, choffset;
|
|
|
|
uint32_t speed, offset, wpwa, dv;
|
|
|
|
uint32_t mixoffset, mixdv;
|
|
|
|
int i, nch;
|
|
|
|
uint16_t apuch;
|
|
|
|
uint16_t reg;
|
2002-12-30 08:23:27 +03:00
|
|
|
|
|
|
|
DPRINTF(ESM_DEBUG_DMA,
|
|
|
|
("esm_trigger_input(%p, %p, %p, 0x%x, %p, %p, %p)\n",
|
|
|
|
sc, start, end, blksize, intr, arg, param));
|
2005-01-15 18:19:51 +03:00
|
|
|
ess = sc;
|
|
|
|
ch = &ess->rch;
|
|
|
|
nch = 1;
|
|
|
|
speed = ch->sample_rate;
|
|
|
|
apuch = ch->num << 1;
|
2002-12-30 08:23:27 +03:00
|
|
|
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (ess->ractive) {
|
|
|
|
printf("%s: esm_trigger_input: already running",
|
|
|
|
ess->sc_dev.dv_xname);
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
ess->sc_rintr = intr;
|
|
|
|
ess->sc_rarg = arg;
|
|
|
|
p = &ess->sc_dma;
|
|
|
|
if ((caddr_t)start != p->addr + MAESTRO_RECBUF_OFF) {
|
|
|
|
printf("%s: esm_trigger_input: bad addr %p\n",
|
|
|
|
ess->sc_dev.dv_xname, start);
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ess->rch.buffer = (caddr_t)start;
|
|
|
|
ess->rch.offset = 0;
|
|
|
|
ess->rch.blocksize = blksize;
|
|
|
|
ess->rch.bufsize = ((caddr_t)end - (caddr_t)start);
|
|
|
|
ess->rch.apublk = blksize >> 1;
|
|
|
|
ess->ractive = 1;
|
|
|
|
|
|
|
|
size = (size_t)(((caddr_t)end - (caddr_t)start) >> 1);
|
|
|
|
choffset = MAESTRO_RECBUF_OFF;
|
|
|
|
switch (ch->aputype) {
|
|
|
|
case APUTYPE_16BITSTEREO:
|
|
|
|
size >>= 1;
|
|
|
|
choffset = MAESTRO_RECBUF_L_OFF;
|
|
|
|
ess->rch.apublk >>= 1;
|
|
|
|
nch++;
|
|
|
|
break;
|
|
|
|
case APUTYPE_16BITLINEAR:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ess->ractive = 0;
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
mixsize = (MAESTRO_MIXBUF_SZ >> 1) >> 1;
|
|
|
|
mixoffset = MAESTRO_MIXBUF_OFF;
|
|
|
|
|
|
|
|
ess->rch.apubase = (choffset >> 1);
|
|
|
|
ess->rch.apubuf = size;
|
|
|
|
ess->rch.nextirq = ess->rch.apublk;
|
|
|
|
|
|
|
|
set_timer(ess);
|
|
|
|
wp_starttimer(ess);
|
|
|
|
|
|
|
|
if (speed > 47999) speed = 47999;
|
|
|
|
if (speed < 4000) speed = 4000;
|
|
|
|
dv = (((speed % 48000) << 16) + 24000) / 48000
|
|
|
|
+ ((speed / 48000) << 16);
|
|
|
|
mixdv = 65536; /* 48KHz */
|
|
|
|
|
|
|
|
for (i = 0; i < nch; i++) {
|
|
|
|
|
|
|
|
/* Clear all rate conversion WP channel registers first. */
|
|
|
|
for (reg = 0; reg < 15; reg++)
|
|
|
|
wp_wrapu(ess, apuch + i, reg, 0);
|
|
|
|
|
|
|
|
/* Program the WaveCache for the rate conversion WP channel. */
|
|
|
|
chctl = (DMAADDR(p) + choffset - 0x10) &
|
|
|
|
WAVCACHE_CHCTL_ADDRTAG_MASK;
|
|
|
|
wc_wrchctl(ess, apuch + i, chctl);
|
|
|
|
|
|
|
|
/* Program the rate conversion WP channel. */
|
|
|
|
wp_wrapu(ess, apuch + i, APUREG_FREQ_LOBYTE, APU_plus6dB
|
|
|
|
| ((dv & 0xff) << APU_FREQ_LOBYTE_SHIFT) | 0x08);
|
|
|
|
wp_wrapu(ess, apuch + i, APUREG_FREQ_HIWORD, dv >> 8);
|
|
|
|
offset = choffset >> 1;
|
|
|
|
wpwa = APU_USE_SYSMEM | ((offset >> 8) & APU_64KPAGE_MASK);
|
|
|
|
wp_wrapu(ess, apuch + i, APUREG_WAVESPACE, wpwa);
|
|
|
|
wp_wrapu(ess, apuch + i, APUREG_CURPTR, offset);
|
|
|
|
wp_wrapu(ess, apuch + i, APUREG_ENDPTR, offset + size);
|
|
|
|
wp_wrapu(ess, apuch + i, APUREG_LOOPLEN, size - 1);
|
|
|
|
wp_wrapu(ess, apuch + i, APUREG_EFFECTS_ENV, 0x00f0);
|
|
|
|
wp_wrapu(ess, apuch + i, APUREG_AMPLITUDE, 0xe800);
|
|
|
|
wp_wrapu(ess, apuch + i, APUREG_POSITION, 0x8f00
|
|
|
|
| (RADIUS_CENTERCIRCLE << APU_RADIUS_SHIFT)
|
|
|
|
| (PAN_FRONT << APU_PAN_SHIFT));
|
|
|
|
wp_wrapu(ess, apuch + i, APUREG_ROUTE, apuch + 2 + i);
|
|
|
|
|
|
|
|
DPRINTF(ESM_DEBUG_DMA,
|
2004-07-08 22:08:58 +04:00
|
|
|
("choffs=0x%x, wpwa=0x%x, offset=0x%x words, size=0x%lx words\n",
|
|
|
|
choffset, wpwa, offset, (unsigned long int)size));
|
2002-12-30 08:23:27 +03:00
|
|
|
|
|
|
|
/* Clear all mixer WP channel registers first. */
|
|
|
|
for (reg = 0; reg < 15; reg++)
|
|
|
|
wp_wrapu(ess, apuch + 2 + i, reg, 0);
|
|
|
|
|
|
|
|
/* Program the WaveCache for the mixer WP channel. */
|
|
|
|
chctl = (ess->rch.base + mixoffset - 0x10) &
|
|
|
|
WAVCACHE_CHCTL_ADDRTAG_MASK;
|
|
|
|
wc_wrchctl(ess, apuch + 2 + i, chctl);
|
|
|
|
|
|
|
|
/* Program the mixer WP channel. */
|
|
|
|
wp_wrapu(ess, apuch + 2 + i, APUREG_FREQ_LOBYTE, APU_plus6dB
|
|
|
|
| ((mixdv & 0xff) << APU_FREQ_LOBYTE_SHIFT) | 0x08);
|
|
|
|
wp_wrapu(ess, apuch + 2 + i, APUREG_FREQ_HIWORD, mixdv >> 8);
|
|
|
|
offset = mixoffset >> 1;
|
|
|
|
wpwa = APU_USE_SYSMEM | ((offset >> 8) & APU_64KPAGE_MASK);
|
|
|
|
wp_wrapu(ess, apuch + 2 + i, APUREG_WAVESPACE, wpwa);
|
|
|
|
wp_wrapu(ess, apuch + 2 + i, APUREG_CURPTR, offset);
|
2005-01-15 18:19:51 +03:00
|
|
|
wp_wrapu(ess, apuch + 2 + i, APUREG_ENDPTR,
|
2002-12-30 08:23:27 +03:00
|
|
|
offset + mixsize);
|
|
|
|
wp_wrapu(ess, apuch + 2 + i, APUREG_LOOPLEN, mixsize);
|
|
|
|
wp_wrapu(ess, apuch + 2 + i, APUREG_EFFECTS_ENV, 0x00f0);
|
|
|
|
wp_wrapu(ess, apuch + 2 + i, APUREG_AMPLITUDE, 0xe800);
|
|
|
|
wp_wrapu(ess, apuch + 2 + i, APUREG_POSITION, 0x8f00
|
|
|
|
| (RADIUS_CENTERCIRCLE << APU_RADIUS_SHIFT)
|
|
|
|
| (PAN_FRONT << APU_PAN_SHIFT));
|
|
|
|
wp_wrapu(ess, apuch + 2 + i, APUREG_ROUTE,
|
|
|
|
ROUTE_PARALLEL + i);
|
|
|
|
|
|
|
|
DPRINTF(ESM_DEBUG_DMA,
|
2004-07-08 22:08:58 +04:00
|
|
|
("mixoffs=0x%x, wpwa=0x%x, offset=0x%x words, size=0x%lx words\n",
|
|
|
|
mixoffset, wpwa, offset, (unsigned long int)mixsize));
|
2002-12-30 08:23:27 +03:00
|
|
|
|
|
|
|
/* Assume we're going to loop to do the right channel. */
|
|
|
|
choffset += MAESTRO_RECBUF_L_SZ;
|
|
|
|
mixoffset += MAESTRO_MIXBUF_SZ >> 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
wp_wrapu(ess, apuch, APUREG_APUTYPE,
|
|
|
|
(APUTYPE_RATECONV << APU_APUTYPE_SHIFT) |
|
|
|
|
APU_DMA_ENABLED | 0xf);
|
|
|
|
if (nch > 1)
|
|
|
|
wp_wrapu(ess, apuch + 1, APUREG_APUTYPE,
|
|
|
|
(APUTYPE_RATECONV << APU_APUTYPE_SHIFT) |
|
|
|
|
APU_DMA_ENABLED | 0xf);
|
|
|
|
wp_wrapu(ess, apuch + 2, APUREG_APUTYPE,
|
|
|
|
(APUTYPE_INPUTMIXER << APU_APUTYPE_SHIFT) |
|
|
|
|
APU_DMA_ENABLED | 0xf);
|
|
|
|
if (nch > 1)
|
|
|
|
wp_wrapu(ess, apuch + 3, APUREG_APUTYPE,
|
|
|
|
(APUTYPE_RATECONV << APU_APUTYPE_SHIFT) |
|
|
|
|
APU_DMA_ENABLED | 0xf);
|
|
|
|
|
2001-01-08 22:54:31 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
esm_halt_output(void *sc)
|
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
struct esm_softc *ess;
|
|
|
|
struct esm_chinfo *ch;
|
2001-01-08 22:54:31 +03:00
|
|
|
|
|
|
|
DPRINTF(ESM_DEBUG_PARAM, ("esm_halt_output(%p)\n", sc));
|
2005-01-15 18:19:51 +03:00
|
|
|
ess = sc;
|
|
|
|
ch = &ess->pch;
|
2001-01-08 22:54:31 +03:00
|
|
|
|
|
|
|
wp_wrapu(ess, (ch->num << 1), APUREG_APUTYPE,
|
|
|
|
APUTYPE_INACTIVE << APU_APUTYPE_SHIFT);
|
|
|
|
wp_wrapu(ess, (ch->num << 1) + 1, APUREG_APUTYPE,
|
|
|
|
APUTYPE_INACTIVE << APU_APUTYPE_SHIFT);
|
|
|
|
|
|
|
|
ess->pactive = 0;
|
|
|
|
if (!ess->ractive)
|
|
|
|
wp_stoptimer(ess);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
esm_halt_input(void *sc)
|
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
struct esm_softc *ess;
|
|
|
|
struct esm_chinfo *ch;
|
2002-12-30 08:23:27 +03:00
|
|
|
|
|
|
|
DPRINTF(ESM_DEBUG_PARAM, ("esm_halt_input(%p)\n", sc));
|
2005-01-15 18:19:51 +03:00
|
|
|
ess = sc;
|
|
|
|
ch = &ess->rch;
|
2002-12-30 08:23:27 +03:00
|
|
|
|
|
|
|
wp_wrapu(ess, (ch->num << 1), APUREG_APUTYPE,
|
|
|
|
APUTYPE_INACTIVE << APU_APUTYPE_SHIFT);
|
|
|
|
wp_wrapu(ess, (ch->num << 1) + 1, APUREG_APUTYPE,
|
|
|
|
APUTYPE_INACTIVE << APU_APUTYPE_SHIFT);
|
|
|
|
wp_wrapu(ess, (ch->num << 1) + 2, APUREG_APUTYPE,
|
|
|
|
APUTYPE_INACTIVE << APU_APUTYPE_SHIFT);
|
|
|
|
wp_wrapu(ess, (ch->num << 1) + 3, APUREG_APUTYPE,
|
|
|
|
APUTYPE_INACTIVE << APU_APUTYPE_SHIFT);
|
|
|
|
|
|
|
|
ess->ractive = 0;
|
|
|
|
if (!ess->pactive)
|
|
|
|
wp_stoptimer(ess);
|
|
|
|
|
2001-01-08 22:54:31 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline u_int
|
|
|
|
calc_timer_freq(struct esm_chinfo *ch)
|
|
|
|
{
|
|
|
|
u_int freq;
|
|
|
|
|
|
|
|
freq = (ch->sample_rate + ch->apublk - 1) / ch->apublk;
|
|
|
|
|
|
|
|
DPRINTF(ESM_DEBUG_TIMER,
|
|
|
|
("calc_timer_freq(%p): rate = %u, blk = 0x%x (0x%x): freq = %u\n",
|
|
|
|
ch, ch->sample_rate, ch->apublk, ch->blocksize, freq));
|
|
|
|
|
|
|
|
return freq;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
set_timer(struct esm_softc *ess)
|
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
unsigned freq, freq2;
|
2001-01-08 22:54:31 +03:00
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
freq = 0;
|
2001-01-08 22:54:31 +03:00
|
|
|
if (ess->pactive)
|
|
|
|
freq = calc_timer_freq(&ess->pch);
|
|
|
|
|
|
|
|
if (ess->ractive) {
|
|
|
|
freq2 = calc_timer_freq(&ess->rch);
|
2002-12-30 08:23:27 +03:00
|
|
|
if (freq2 > freq)
|
2001-01-08 22:54:31 +03:00
|
|
|
freq = freq2;
|
|
|
|
}
|
|
|
|
|
2002-12-30 08:23:27 +03:00
|
|
|
KASSERT(freq != 0);
|
|
|
|
|
2001-01-08 22:54:31 +03:00
|
|
|
for (; freq < MAESTRO_MINFREQ; freq <<= 1)
|
2005-01-15 18:19:51 +03:00
|
|
|
continue;
|
2001-01-08 22:54:31 +03:00
|
|
|
|
|
|
|
if (freq > 0)
|
|
|
|
wp_settimer(ess, freq);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework
Summary of changes:
* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.
* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t
* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.
* add `struct device *' parameter to ac97_attach()
* all of audio HW drivers follow audio_hw_if and ac97 changes
2005-01-11 01:01:36 +03:00
|
|
|
esmch_set_format(struct esm_chinfo *ch, const audio_params_t *p)
|
2001-01-08 22:54:31 +03:00
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
uint16_t wcreg_tpl;
|
|
|
|
uint16_t aputype;
|
2001-01-08 22:54:31 +03:00
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
wcreg_tpl = (ch->base - 16) & WAVCACHE_CHCTL_ADDRTAG_MASK;
|
|
|
|
aputype = APUTYPE_16BITLINEAR;
|
2001-01-08 22:54:31 +03:00
|
|
|
if (p->channels == 2) {
|
|
|
|
wcreg_tpl |= WAVCACHE_CHCTL_STEREO;
|
|
|
|
aputype++;
|
|
|
|
}
|
merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework
Summary of changes:
* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.
* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t
* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.
* add `struct device *' parameter to ac97_attach()
* all of audio HW drivers follow audio_hw_if and ac97 changes
2005-01-11 01:01:36 +03:00
|
|
|
if (p->precision == 8) {
|
2001-01-08 22:54:31 +03:00
|
|
|
aputype += 2;
|
2004-04-30 18:14:55 +04:00
|
|
|
switch (p->encoding) {
|
|
|
|
case AUDIO_ENCODING_ULINEAR:
|
|
|
|
case AUDIO_ENCODING_ULINEAR_BE:
|
|
|
|
case AUDIO_ENCODING_ULINEAR_LE:
|
2001-01-08 22:54:31 +03:00
|
|
|
wcreg_tpl |= WAVCACHE_CHCTL_U8;
|
2004-04-30 18:14:55 +04:00
|
|
|
break;
|
|
|
|
}
|
2001-01-08 22:54:31 +03:00
|
|
|
}
|
|
|
|
ch->wcreg_tpl = wcreg_tpl;
|
|
|
|
ch->aputype = aputype;
|
|
|
|
ch->sample_rate = p->sample_rate;
|
|
|
|
|
|
|
|
DPRINTF(ESM_DEBUG_PARAM, ("esmch_set_format: "
|
merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework
Summary of changes:
* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.
* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t
* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.
* add `struct device *' parameter to ac97_attach()
* all of audio HW drivers follow audio_hw_if and ac97 changes
2005-01-11 01:01:36 +03:00
|
|
|
"numch=%u, prec=%u, tpl=0x%x, aputype=%d, rate=%u\n",
|
|
|
|
p->channels, p->precision, wcreg_tpl, aputype, p->sample_rate));
|
2001-01-08 22:54:31 +03:00
|
|
|
}
|
|
|
|
|
2002-12-30 08:23:27 +03:00
|
|
|
/*
|
|
|
|
* Since we can't record in true stereo, this function combines
|
2005-01-15 18:19:51 +03:00
|
|
|
* the separately recorded left and right channels into the final
|
2002-12-30 08:23:27 +03:00
|
|
|
* buffer for the upper layer.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
esmch_combine_input(struct esm_softc *ess, struct esm_chinfo *ch)
|
|
|
|
{
|
|
|
|
size_t offset, resid, count;
|
2005-01-15 18:19:51 +03:00
|
|
|
uint32_t *dst32s;
|
|
|
|
const uint32_t *left32s, *right32s;
|
|
|
|
uint32_t left32, right32;
|
2002-12-30 08:23:27 +03:00
|
|
|
|
|
|
|
/* The current offset into the upper layer buffer. */
|
|
|
|
offset = ch->offset;
|
|
|
|
|
|
|
|
/* The number of bytes left to combine. */
|
|
|
|
resid = ch->blocksize;
|
|
|
|
|
|
|
|
while (resid > 0) {
|
|
|
|
|
|
|
|
/* The 32-bit words for the left channel. */
|
2005-01-15 18:19:51 +03:00
|
|
|
left32s = (const uint32_t *)(ess->sc_dma.addr +
|
2002-12-30 08:23:27 +03:00
|
|
|
MAESTRO_RECBUF_L_OFF + offset / 2);
|
|
|
|
|
|
|
|
/* The 32-bit words for the right channel. */
|
2005-01-15 18:19:51 +03:00
|
|
|
right32s = (const uint32_t *)(ess->sc_dma.addr +
|
2002-12-30 08:23:27 +03:00
|
|
|
MAESTRO_RECBUF_R_OFF + offset / 2);
|
|
|
|
|
|
|
|
/* The pointer to the 32-bit words we will write. */
|
2005-01-15 18:19:51 +03:00
|
|
|
dst32s = (uint32_t *)(ch->buffer + offset);
|
2002-12-30 08:23:27 +03:00
|
|
|
|
|
|
|
/* Get the number of bytes we will combine now. */
|
|
|
|
count = ch->bufsize - offset;
|
|
|
|
if (count > resid)
|
|
|
|
count = resid;
|
|
|
|
resid -= count;
|
|
|
|
offset += count;
|
|
|
|
if (offset == ch->bufsize)
|
|
|
|
offset = 0;
|
|
|
|
|
|
|
|
/* Combine, writing two 32-bit words at a time. */
|
|
|
|
KASSERT((count & (sizeof(uint32_t) * 2 - 1)) == 0);
|
2005-01-15 18:19:51 +03:00
|
|
|
count /= (sizeof(uint32_t) * 2);
|
2002-12-30 08:23:27 +03:00
|
|
|
while (count > 0) {
|
|
|
|
left32 = *(left32s++);
|
|
|
|
right32 = *(right32s++);
|
|
|
|
/* XXX this endian handling is half-baked at best */
|
|
|
|
#if BYTE_ORDER == LITTLE_ENDIAN
|
|
|
|
*(dst32s++) = (left32 & 0xFFFF) | (right32 << 16);
|
|
|
|
*(dst32s++) = (left32 >> 16) | (right32 & 0xFFFF0000);
|
|
|
|
#else /* BYTE_ORDER == BIG_ENDIAN */
|
|
|
|
*(dst32s++) = (left32 & 0xFFFF0000) | (right32 >> 16);
|
|
|
|
*(dst32s++) = (left32 << 16) | (right32 & 0xFFFF);
|
|
|
|
#endif /* BYTE_ORDER == BIG_ENDIAN */
|
|
|
|
count--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update the offset. */
|
|
|
|
ch->offset = offset;
|
|
|
|
}
|
2001-01-08 22:54:31 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Audio interface glue functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
|
|
|
esm_getdev (void *sc, struct audio_device *adp)
|
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
|
2001-01-08 22:54:31 +03:00
|
|
|
*adp = esm_device;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework
Summary of changes:
* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.
* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t
* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.
* add `struct device *' parameter to ac97_attach()
* all of audio HW drivers follow audio_hw_if and ac97 changes
2005-01-11 01:01:36 +03:00
|
|
|
esm_round_blocksize(void *sc, int blk, int mode, const audio_params_t *param)
|
2001-01-08 22:54:31 +03:00
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
|
2001-01-08 22:54:31 +03:00
|
|
|
DPRINTF(ESM_DEBUG_PARAM,
|
|
|
|
("esm_round_blocksize(%p, 0x%x)", sc, blk));
|
|
|
|
|
|
|
|
blk &= ~0x3f; /* keep good alignment */
|
|
|
|
|
|
|
|
DPRINTF(ESM_DEBUG_PARAM, (" = 0x%x\n", blk));
|
|
|
|
|
|
|
|
return blk;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
esm_query_encoding(void *sc, struct audio_encoding *fp)
|
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
|
2001-01-08 22:54:31 +03:00
|
|
|
DPRINTF(ESM_DEBUG_PARAM,
|
|
|
|
("esm_query_encoding(%p, %d)\n", sc, fp->index));
|
|
|
|
|
|
|
|
if (fp->index < 0 || fp->index >= MAESTRO_NENCODINGS)
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
*fp = esm_encoding[fp->index];
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
esm_set_params(void *sc, int setmode, int usemode,
|
merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework
Summary of changes:
* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.
* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t
* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.
* add `struct device *' parameter to ac97_attach()
* all of audio HW drivers follow audio_hw_if and ac97 changes
2005-01-11 01:01:36 +03:00
|
|
|
audio_params_t *play, audio_params_t *rec,
|
|
|
|
stream_filter_list_t *pfil, stream_filter_list_t *rfil)
|
2001-01-08 22:54:31 +03:00
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
struct esm_softc *ess;
|
merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework
Summary of changes:
* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.
* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t
* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.
* add `struct device *' parameter to ac97_attach()
* all of audio HW drivers follow audio_hw_if and ac97 changes
2005-01-11 01:01:36 +03:00
|
|
|
audio_params_t *p;
|
|
|
|
const audio_params_t *hw_play, *hw_rec;
|
|
|
|
stream_filter_list_t *fil;
|
|
|
|
int mode, i;
|
2001-01-08 22:54:31 +03:00
|
|
|
|
|
|
|
DPRINTF(ESM_DEBUG_PARAM,
|
|
|
|
("esm_set_params(%p, 0x%x, 0x%x, %p, %p)\n",
|
|
|
|
sc, setmode, usemode, play, rec));
|
2005-01-15 18:19:51 +03:00
|
|
|
ess = sc;
|
merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework
Summary of changes:
* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.
* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t
* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.
* add `struct device *' parameter to ac97_attach()
* all of audio HW drivers follow audio_hw_if and ac97 changes
2005-01-11 01:01:36 +03:00
|
|
|
hw_play = NULL;
|
|
|
|
hw_rec = NULL;
|
2005-01-15 18:19:51 +03:00
|
|
|
for (mode = AUMODE_RECORD; mode != -1;
|
2001-01-08 22:54:31 +03:00
|
|
|
mode = mode == AUMODE_RECORD ? AUMODE_PLAY : -1) {
|
|
|
|
if ((setmode & mode) == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
p = mode == AUMODE_PLAY ? play : rec;
|
|
|
|
|
|
|
|
if (p->sample_rate < 4000 || p->sample_rate > 48000 ||
|
|
|
|
(p->precision != 8 && p->precision != 16) ||
|
|
|
|
(p->channels != 1 && p->channels != 2))
|
|
|
|
return EINVAL;
|
|
|
|
|
merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework
Summary of changes:
* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.
* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t
* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.
* add `struct device *' parameter to ac97_attach()
* all of audio HW drivers follow audio_hw_if and ac97 changes
2005-01-11 01:01:36 +03:00
|
|
|
fil = mode == AUMODE_PLAY ? pfil : rfil;
|
|
|
|
i = auconv_set_converter(esm_formats, ESM_NFORMATS,
|
|
|
|
mode, p, FALSE, fil);
|
|
|
|
if (i < 0)
|
2001-01-08 22:54:31 +03:00
|
|
|
return EINVAL;
|
merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework
Summary of changes:
* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.
* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t
* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.
* add `struct device *' parameter to ac97_attach()
* all of audio HW drivers follow audio_hw_if and ac97 changes
2005-01-11 01:01:36 +03:00
|
|
|
if (fil->req_size > 0)
|
|
|
|
p = &fil->filters[0].param;
|
|
|
|
if (mode == AUMODE_PLAY)
|
|
|
|
hw_play = p;
|
|
|
|
else
|
|
|
|
hw_rec = p;
|
2001-01-08 22:54:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (setmode & AUMODE_PLAY)
|
merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework
Summary of changes:
* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.
* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t
* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.
* add `struct device *' parameter to ac97_attach()
* all of audio HW drivers follow audio_hw_if and ac97 changes
2005-01-11 01:01:36 +03:00
|
|
|
esmch_set_format(&ess->pch, hw_play);
|
2001-01-08 22:54:31 +03:00
|
|
|
|
|
|
|
if (setmode & AUMODE_RECORD)
|
merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework
Summary of changes:
* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.
* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t
* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.
* add `struct device *' parameter to ac97_attach()
* all of audio HW drivers follow audio_hw_if and ac97 changes
2005-01-11 01:01:36 +03:00
|
|
|
esmch_set_format(&ess->rch, hw_rec);
|
2001-01-08 22:54:31 +03:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
esm_set_port(void *sc, mixer_ctrl_t *cp)
|
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
struct esm_softc *ess;
|
2001-01-08 22:54:31 +03:00
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
ess = sc;
|
|
|
|
return ess->codec_if->vtbl->mixer_set_port(ess->codec_if, cp);
|
2001-01-08 22:54:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
esm_get_port(void *sc, mixer_ctrl_t *cp)
|
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
struct esm_softc *ess;
|
2001-01-08 22:54:31 +03:00
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
ess = sc;
|
|
|
|
return ess->codec_if->vtbl->mixer_get_port(ess->codec_if, cp);
|
2001-01-08 22:54:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
esm_query_devinfo(void *sc, mixer_devinfo_t *dip)
|
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
struct esm_softc *ess;
|
2001-01-08 22:54:31 +03:00
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
ess = sc;
|
|
|
|
return ess->codec_if->vtbl->query_devinfo(ess->codec_if, dip);
|
2001-01-08 22:54:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void *
|
2003-02-01 09:23:35 +03:00
|
|
|
esm_malloc(void *sc, int direction, size_t size, struct malloc_type *pool,
|
|
|
|
int flags)
|
2001-01-08 22:54:31 +03:00
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
struct esm_softc *ess;
|
2002-12-30 08:23:27 +03:00
|
|
|
int off;
|
2001-01-08 22:54:31 +03:00
|
|
|
|
|
|
|
DPRINTF(ESM_DEBUG_DMA,
|
2004-07-08 22:08:58 +04:00
|
|
|
("esm_malloc(%p, %d, 0x%lx, %p, 0x%x)",
|
|
|
|
sc, direction, (unsigned long int)size, pool, flags));
|
2005-01-15 18:19:51 +03:00
|
|
|
ess = sc;
|
2002-12-30 08:23:27 +03:00
|
|
|
/*
|
|
|
|
* Each buffer can only be allocated once.
|
|
|
|
*/
|
|
|
|
if (ess->rings_alloced & direction) {
|
2001-01-08 22:54:31 +03:00
|
|
|
DPRINTF(ESM_DEBUG_DMA, (" = 0 (ENOMEM)\n"));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-12-30 08:23:27 +03:00
|
|
|
/*
|
|
|
|
* Mark this buffer as allocated and return its
|
|
|
|
* kernel virtual address.
|
|
|
|
*/
|
|
|
|
ess->rings_alloced |= direction;
|
|
|
|
off = (direction == AUMODE_PLAY ?
|
|
|
|
MAESTRO_PLAYBUF_OFF : MAESTRO_RECBUF_OFF);
|
|
|
|
DPRINTF(ESM_DEBUG_DMA, (" = %p (DMAADDR 0x%x)\n",
|
|
|
|
ess->sc_dma.addr + off,
|
|
|
|
(int)DMAADDR(&ess->sc_dma) + off));
|
2005-01-15 18:19:51 +03:00
|
|
|
return ess->sc_dma.addr + off;
|
2001-01-08 22:54:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-02-01 09:23:35 +03:00
|
|
|
esm_free(void *sc, void *ptr, struct malloc_type *pool)
|
2001-01-08 22:54:31 +03:00
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
struct esm_softc *ess;
|
2001-01-08 22:54:31 +03:00
|
|
|
|
|
|
|
DPRINTF(ESM_DEBUG_DMA,
|
2003-02-03 04:11:54 +03:00
|
|
|
("esm_free(%p, %p, %p)\n",
|
2001-01-08 22:54:31 +03:00
|
|
|
sc, ptr, pool));
|
2005-01-15 18:19:51 +03:00
|
|
|
ess = sc;
|
2002-12-30 08:23:27 +03:00
|
|
|
if ((caddr_t)ptr == ess->sc_dma.addr + MAESTRO_PLAYBUF_OFF)
|
|
|
|
ess->rings_alloced &= ~AUMODE_PLAY;
|
|
|
|
else if ((caddr_t)ptr == ess->sc_dma.addr + MAESTRO_RECBUF_OFF)
|
|
|
|
ess->rings_alloced &= ~AUMODE_RECORD;
|
2001-01-08 22:54:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
|
|
|
esm_round_buffersize(void *sc, int direction, size_t size)
|
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
|
2002-12-30 08:23:27 +03:00
|
|
|
if (size > MAESTRO_PLAYBUF_SZ)
|
|
|
|
size = MAESTRO_PLAYBUF_SZ;
|
|
|
|
if (size > MAESTRO_RECBUF_SZ)
|
|
|
|
size = MAESTRO_RECBUF_SZ;
|
2001-01-08 22:54:31 +03:00
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
paddr_t
|
|
|
|
esm_mappage(void *sc, void *mem, off_t off, int prot)
|
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
struct esm_softc *ess;
|
2001-01-08 22:54:31 +03:00
|
|
|
|
|
|
|
DPRINTF(ESM_DEBUG_DMA,
|
|
|
|
("esm_mappage(%p, %p, 0x%lx, 0x%x)\n",
|
|
|
|
sc, mem, (unsigned long)off, prot));
|
2005-01-15 18:19:51 +03:00
|
|
|
ess = sc;
|
2001-01-08 22:54:31 +03:00
|
|
|
if (off < 0)
|
2005-01-15 18:19:51 +03:00
|
|
|
return -1;
|
2001-01-08 22:54:31 +03:00
|
|
|
|
2002-12-30 08:23:27 +03:00
|
|
|
if ((caddr_t)mem == ess->sc_dma.addr + MAESTRO_PLAYBUF_OFF)
|
|
|
|
off += MAESTRO_PLAYBUF_OFF;
|
|
|
|
else if ((caddr_t)mem == ess->sc_dma.addr + MAESTRO_RECBUF_OFF)
|
|
|
|
off += MAESTRO_RECBUF_OFF;
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
return bus_dmamem_mmap(ess->dmat, ess->sc_dma.segs, ess->sc_dma.nsegs,
|
|
|
|
off, prot, BUS_DMA_WAITOK);
|
2001-01-08 22:54:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
esm_get_props(void *sc)
|
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
|
2001-01-08 22:54:31 +03:00
|
|
|
return AUDIO_PROP_MMAP | AUDIO_PROP_INDEPENDENT | AUDIO_PROP_FULLDUPLEX;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* -----------------------------
|
|
|
|
* Bus space.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
|
|
|
esm_intr(void *sc)
|
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
struct esm_softc *ess;
|
|
|
|
uint16_t status;
|
|
|
|
uint16_t pos;
|
|
|
|
int ret;
|
2001-01-08 22:54:31 +03:00
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
ess = sc;
|
|
|
|
ret = 0;
|
2001-01-08 22:54:31 +03:00
|
|
|
status = bus_space_read_1(ess->st, ess->sh, PORT_HOSTINT_STAT);
|
|
|
|
if (!status)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Acknowledge all. */
|
|
|
|
bus_space_write_2(ess->st, ess->sh, PORT_INT_STAT, 1);
|
|
|
|
bus_space_write_1(ess->st, ess->sh, PORT_HOSTINT_STAT, 0);
|
|
|
|
#if 0 /* XXX - HWVOL */
|
|
|
|
if (status & HOSTINT_STAT_HWVOL) {
|
|
|
|
u_int delta;
|
|
|
|
delta = bus_space_read_1(ess->st, ess->sh, PORT_HWVOL_MASTER)
|
|
|
|
- 0x88;
|
|
|
|
if (delta & 0x11)
|
|
|
|
mixer_set(device_get_softc(ess->dev),
|
|
|
|
SOUND_MIXER_VOLUME, 0);
|
|
|
|
else {
|
|
|
|
mixer_set(device_get_softc(ess->dev),
|
|
|
|
SOUND_MIXER_VOLUME,
|
|
|
|
mixer_get(device_get_softc(ess->dev),
|
|
|
|
SOUND_MIXER_VOLUME)
|
|
|
|
+ ((delta >> 5) & 0x7) - 4
|
|
|
|
+ ((delta << 7) & 0x700) - 0x400);
|
|
|
|
}
|
|
|
|
bus_space_write_1(ess->st, ess->sh, PORT_HWVOL_MASTER, 0x88);
|
|
|
|
ret++;
|
|
|
|
}
|
|
|
|
#endif /* XXX - HWVOL */
|
|
|
|
|
|
|
|
if (ess->pactive) {
|
|
|
|
pos = wp_rdapu(ess, ess->pch.num << 1, APUREG_CURPTR);
|
|
|
|
|
|
|
|
DPRINTF(ESM_DEBUG_IRQ, (" %4.4x/%4.4x ", pos,
|
|
|
|
wp_rdapu(ess, (ess->pch.num<<1)+1, APUREG_CURPTR)));
|
|
|
|
|
2002-12-30 08:23:27 +03:00
|
|
|
pos -= ess->pch.apubase;
|
2001-01-08 22:54:31 +03:00
|
|
|
if (pos >= ess->pch.nextirq &&
|
|
|
|
pos - ess->pch.nextirq < ess->pch.apubuf / 2) {
|
|
|
|
ess->pch.nextirq += ess->pch.apublk;
|
|
|
|
|
|
|
|
if (ess->pch.nextirq >= ess->pch.apubuf)
|
|
|
|
ess->pch.nextirq = 0;
|
|
|
|
|
|
|
|
if (ess->sc_pintr) {
|
|
|
|
DPRINTF(ESM_DEBUG_IRQ, ("P\n"));
|
|
|
|
ess->sc_pintr(ess->sc_parg);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
ret++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ess->ractive) {
|
|
|
|
pos = wp_rdapu(ess, ess->rch.num << 1, APUREG_CURPTR);
|
|
|
|
|
|
|
|
DPRINTF(ESM_DEBUG_IRQ, (" %4.4x/%4.4x ", pos,
|
|
|
|
wp_rdapu(ess, (ess->rch.num<<1)+1, APUREG_CURPTR)));
|
|
|
|
|
2002-12-30 08:23:27 +03:00
|
|
|
pos -= ess->rch.apubase;
|
2001-01-08 22:54:31 +03:00
|
|
|
if (pos >= ess->rch.nextirq &&
|
|
|
|
pos - ess->rch.nextirq < ess->rch.apubuf / 2) {
|
|
|
|
ess->rch.nextirq += ess->rch.apublk;
|
|
|
|
|
|
|
|
if (ess->rch.nextirq >= ess->rch.apubuf)
|
|
|
|
ess->rch.nextirq = 0;
|
|
|
|
|
|
|
|
if (ess->sc_rintr) {
|
|
|
|
DPRINTF(ESM_DEBUG_IRQ, ("R\n"));
|
2002-12-30 08:23:27 +03:00
|
|
|
switch(ess->rch.aputype) {
|
|
|
|
case APUTYPE_16BITSTEREO:
|
|
|
|
esmch_combine_input(ess, &ess->rch);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ess->sc_rintr(ess->sc_rarg);
|
2001-01-08 22:54:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
ret++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
esm_allocmem(struct esm_softc *sc, size_t size, size_t align,
|
|
|
|
struct esm_dma *p)
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
|
|
|
p->size = size;
|
|
|
|
error = bus_dmamem_alloc(sc->dmat, p->size, align, 0,
|
|
|
|
p->segs, sizeof(p->segs)/sizeof(p->segs[0]),
|
|
|
|
&p->nsegs, BUS_DMA_NOWAIT);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
|
|
|
|
error = bus_dmamem_map(sc->dmat, p->segs, p->nsegs, p->size,
|
|
|
|
&p->addr, BUS_DMA_NOWAIT|BUS_DMA_COHERENT);
|
|
|
|
if (error)
|
|
|
|
goto free;
|
|
|
|
|
|
|
|
error = bus_dmamap_create(sc->dmat, p->size, 1, p->size,
|
|
|
|
0, BUS_DMA_NOWAIT, &p->map);
|
|
|
|
if (error)
|
|
|
|
goto unmap;
|
|
|
|
|
|
|
|
error = bus_dmamap_load(sc->dmat, p->map, p->addr, p->size, NULL,
|
|
|
|
BUS_DMA_NOWAIT);
|
|
|
|
if (error)
|
|
|
|
goto destroy;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
destroy:
|
|
|
|
bus_dmamap_destroy(sc->dmat, p->map);
|
|
|
|
unmap:
|
|
|
|
bus_dmamem_unmap(sc->dmat, p->addr, p->size);
|
|
|
|
free:
|
|
|
|
bus_dmamem_free(sc->dmat, p->segs, p->nsegs);
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
esm_match(struct device *dev, struct cfdata *match, void *aux)
|
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
struct pci_attach_args *pa;
|
2001-01-08 22:54:31 +03:00
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
pa = (struct pci_attach_args *)aux;
|
2001-01-08 22:54:31 +03:00
|
|
|
switch (PCI_VENDOR(pa->pa_id)) {
|
|
|
|
case PCI_VENDOR_ESSTECH:
|
|
|
|
switch (PCI_PRODUCT(pa->pa_id)) {
|
|
|
|
case PCI_PRODUCT_ESSTECH_MAESTRO1:
|
|
|
|
case PCI_PRODUCT_ESSTECH_MAESTRO2:
|
|
|
|
case PCI_PRODUCT_ESSTECH_MAESTRO2E:
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
case PCI_VENDOR_ESSTECH2:
|
|
|
|
switch (PCI_PRODUCT(pa->pa_id)) {
|
|
|
|
case PCI_PRODUCT_ESSTECH2_MAESTRO1:
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
esm_attach(struct device *parent, struct device *self, void *aux)
|
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
char devinfo[256];
|
|
|
|
struct esm_softc *ess;
|
|
|
|
struct pci_attach_args *pa;
|
|
|
|
const char *intrstr;
|
|
|
|
pci_chipset_tag_t pc;
|
|
|
|
pcitag_t tag;
|
2001-01-08 22:54:31 +03:00
|
|
|
pci_intr_handle_t ih;
|
|
|
|
pcireg_t csr, data;
|
|
|
|
int revision;
|
2005-01-15 18:19:51 +03:00
|
|
|
uint16_t codec_data;
|
|
|
|
uint16_t pcmbar;
|
2001-01-08 22:54:31 +03:00
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
ess = (struct esm_softc *)self;
|
|
|
|
pa = (struct pci_attach_args *)aux;
|
|
|
|
pc = pa->pa_pc;
|
|
|
|
tag = pa->pa_tag;
|
2003-01-31 03:07:39 +03:00
|
|
|
aprint_naive(": Audio controller\n");
|
|
|
|
|
2004-04-24 01:13:05 +04:00
|
|
|
pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
|
2001-01-08 22:54:31 +03:00
|
|
|
revision = PCI_REVISION(pa->pa_class);
|
2003-01-31 03:07:39 +03:00
|
|
|
aprint_normal(": %s (rev. 0x%02x)\n", devinfo, revision);
|
2001-01-08 22:54:31 +03:00
|
|
|
|
|
|
|
/* Enable the device. */
|
|
|
|
csr = pci_conf_read(pc, tag, PCI_COMMAND_STATUS_REG);
|
|
|
|
pci_conf_write(pc, tag, PCI_COMMAND_STATUS_REG,
|
|
|
|
csr | PCI_COMMAND_MASTER_ENABLE | PCI_COMMAND_IO_ENABLE);
|
|
|
|
|
|
|
|
/* Map I/O register */
|
|
|
|
if (pci_mapreg_map(pa, PCI_CBIO, PCI_MAPREG_TYPE_IO, 0,
|
|
|
|
&ess->st, &ess->sh, NULL, NULL)) {
|
2003-01-31 03:07:39 +03:00
|
|
|
aprint_error("%s: can't map i/o space\n", ess->sc_dev.dv_xname);
|
2001-01-08 22:54:31 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize softc */
|
|
|
|
ess->pch.num = 0;
|
2002-12-30 08:23:27 +03:00
|
|
|
ess->rch.num = 1;
|
2001-01-08 22:54:31 +03:00
|
|
|
ess->dmat = pa->pa_dmat;
|
|
|
|
ess->tag = tag;
|
|
|
|
ess->pc = pc;
|
|
|
|
ess->subid = pci_conf_read(pc, tag, PCI_SUBSYS_ID_REG);
|
|
|
|
|
2001-01-10 02:27:07 +03:00
|
|
|
DPRINTF(ESM_DEBUG_PCI,
|
|
|
|
("%s: sub-system vendor 0x%4.4x, product 0x%4.4x\n",
|
|
|
|
ess->sc_dev.dv_xname,
|
|
|
|
PCI_VENDOR(ess->subid), PCI_PRODUCT(ess->subid)));
|
|
|
|
|
2001-01-08 22:54:31 +03:00
|
|
|
/* Map and establish the interrupt. */
|
|
|
|
if (pci_intr_map(pa, &ih)) {
|
2003-01-31 03:07:39 +03:00
|
|
|
aprint_error("%s: can't map interrupt\n", ess->sc_dev.dv_xname);
|
2001-01-08 22:54:31 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
intrstr = pci_intr_string(pc, ih);
|
|
|
|
ess->ih = pci_intr_establish(pc, ih, IPL_AUDIO, esm_intr, self);
|
|
|
|
if (ess->ih == NULL) {
|
2003-01-31 03:07:39 +03:00
|
|
|
aprint_error("%s: can't establish interrupt",
|
|
|
|
ess->sc_dev.dv_xname);
|
2001-01-08 22:54:31 +03:00
|
|
|
if (intrstr != NULL)
|
2003-01-31 03:07:39 +03:00
|
|
|
aprint_normal(" at %s", intrstr);
|
|
|
|
aprint_normal("\n");
|
2001-01-08 22:54:31 +03:00
|
|
|
return;
|
|
|
|
}
|
2003-01-31 03:07:39 +03:00
|
|
|
aprint_normal("%s: interrupting at %s\n",
|
|
|
|
ess->sc_dev.dv_xname, intrstr);
|
2001-01-08 22:54:31 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Setup PCI config registers
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* set to power state D0 */
|
2002-01-14 22:24:39 +03:00
|
|
|
esm_power(ess, PCI_PMCSR_STATE_D0);
|
2001-01-08 22:54:31 +03:00
|
|
|
delay(100000);
|
|
|
|
|
|
|
|
/* Disable all legacy emulations. */
|
|
|
|
data = pci_conf_read(pc, tag, CONF_LEGACY);
|
|
|
|
pci_conf_write(pc, tag, CONF_LEGACY, data | LEGACY_DISABLED);
|
|
|
|
|
|
|
|
/* Disconnect from CHI. (Makes Dell inspiron 7500 work?)
|
|
|
|
* Enable posted write.
|
|
|
|
* Prefer PCI timing rather than that of ISA.
|
|
|
|
* Don't swap L/R. */
|
|
|
|
data = pci_conf_read(pc, tag, CONF_MAESTRO);
|
|
|
|
data |= MAESTRO_CHIBUS | MAESTRO_POSTEDWRITE | MAESTRO_DMA_PCITIMING;
|
|
|
|
data &= ~MAESTRO_SWAP_LR;
|
|
|
|
pci_conf_write(pc, tag, CONF_MAESTRO, data);
|
|
|
|
|
|
|
|
/* initialize sound chip */
|
|
|
|
esm_init(ess);
|
|
|
|
|
|
|
|
esm_read_codec(ess, 0, &codec_data);
|
|
|
|
if (codec_data == 0x80) {
|
2003-01-31 03:07:39 +03:00
|
|
|
aprint_error("%s: PT101 codec detected!\n",
|
|
|
|
ess->sc_dev.dv_xname);
|
2001-01-08 22:54:31 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-01-10 02:27:07 +03:00
|
|
|
/*
|
|
|
|
* Some cards and Notebooks appear to have left and right channels
|
|
|
|
* reversed. Check if there is a corresponding quirk entry for
|
|
|
|
* the subsystem vendor and product and if so, set the appropriate
|
|
|
|
* codec flag.
|
|
|
|
*/
|
|
|
|
if (esm_get_quirks(ess->subid) & ESM_QUIRKF_SWAPPEDCH) {
|
|
|
|
ess->codec_flags |= AC97_HOST_SWAPPED_CHANNELS;
|
|
|
|
}
|
2001-01-26 12:22:18 +03:00
|
|
|
ess->codec_flags |= AC97_HOST_DONT_READ;
|
2001-01-10 02:27:07 +03:00
|
|
|
|
2001-01-08 22:54:31 +03:00
|
|
|
/* initialize AC97 host interface */
|
|
|
|
ess->host_if.arg = self;
|
|
|
|
ess->host_if.attach = esm_attach_codec;
|
|
|
|
ess->host_if.read = esm_read_codec;
|
|
|
|
ess->host_if.write = esm_write_codec;
|
|
|
|
ess->host_if.reset = esm_reset_codec;
|
2001-01-10 02:27:07 +03:00
|
|
|
ess->host_if.flags = esm_flags_codec;
|
2001-01-08 22:54:31 +03:00
|
|
|
|
merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework
Summary of changes:
* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.
* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t
* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.
* add `struct device *' parameter to ac97_attach()
* all of audio HW drivers follow audio_hw_if and ac97 changes
2005-01-11 01:01:36 +03:00
|
|
|
if (ac97_attach(&ess->host_if, self) != 0)
|
2001-01-08 22:54:31 +03:00
|
|
|
return;
|
|
|
|
|
2002-12-30 08:23:27 +03:00
|
|
|
/* allocate our DMA region */
|
|
|
|
if (esm_allocmem(ess, MAESTRO_DMA_SZ, MAESTRO_DMA_ALIGN,
|
|
|
|
&ess->sc_dma)) {
|
2003-01-31 03:07:39 +03:00
|
|
|
aprint_error("%s: couldn't allocate memory!\n",
|
|
|
|
ess->sc_dev.dv_xname);
|
2002-12-30 08:23:27 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
ess->rings_alloced = 0;
|
|
|
|
|
|
|
|
/* set DMA base address */
|
|
|
|
for (pcmbar = WAVCACHE_PCMBAR; pcmbar < WAVCACHE_PCMBAR + 4; pcmbar++)
|
|
|
|
wc_wrreg(ess, pcmbar,
|
|
|
|
DMAADDR(&ess->sc_dma) >> WAVCACHE_BASEADDR_SHIFT);
|
|
|
|
|
2001-01-08 22:54:31 +03:00
|
|
|
audio_attach_mi(&esm_hw_if, self, &ess->sc_dev);
|
2001-02-13 02:56:40 +03:00
|
|
|
|
|
|
|
ess->esm_suspend = PWR_RESUME;
|
|
|
|
ess->esm_powerhook = powerhook_establish(esm_powerhook, ess);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Power Hook */
|
|
|
|
void
|
2005-01-15 18:19:51 +03:00
|
|
|
esm_powerhook(int why, void *v)
|
2001-02-13 02:56:40 +03:00
|
|
|
{
|
2005-01-15 18:19:51 +03:00
|
|
|
struct esm_softc *ess;
|
2001-02-13 02:56:40 +03:00
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
ess = (struct esm_softc *)v;
|
2001-02-13 02:56:40 +03:00
|
|
|
DPRINTF(ESM_DEBUG_PARAM,
|
2005-01-15 18:19:51 +03:00
|
|
|
("%s: ESS maestro 2E why=%d\n", ess->sc_dev.dv_xname, why));
|
2001-02-13 02:56:40 +03:00
|
|
|
switch (why) {
|
2005-01-15 18:19:51 +03:00
|
|
|
case PWR_SUSPEND:
|
|
|
|
case PWR_STANDBY:
|
|
|
|
ess->esm_suspend = why;
|
|
|
|
esm_suspend(ess);
|
|
|
|
DPRINTF(ESM_DEBUG_RESUME, ("esm_suspend\n"));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PWR_RESUME:
|
|
|
|
ess->esm_suspend = why;
|
|
|
|
esm_resume(ess);
|
|
|
|
DPRINTF(ESM_DEBUG_RESUME, ("esm_resumed\n"));
|
|
|
|
break;
|
2001-02-13 02:56:40 +03:00
|
|
|
}
|
2001-01-08 22:54:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
esm_suspend(struct esm_softc *ess)
|
|
|
|
{
|
2001-03-08 15:54:45 +03:00
|
|
|
int x;
|
2001-01-08 22:54:31 +03:00
|
|
|
|
|
|
|
x = splaudio();
|
|
|
|
wp_stoptimer(ess);
|
|
|
|
bus_space_write_2(ess->st, ess->sh, PORT_HOSTINT_CTRL, 0);
|
|
|
|
|
|
|
|
esm_halt_output(ess);
|
|
|
|
esm_halt_input(ess);
|
|
|
|
splx(x);
|
|
|
|
|
|
|
|
/* Power down everything except clock. */
|
|
|
|
esm_write_codec(ess, AC97_REG_POWER, 0xdf00);
|
|
|
|
delay(20);
|
|
|
|
bus_space_write_4(ess->st, ess->sh, PORT_RINGBUS_CTRL, 0);
|
|
|
|
delay(1);
|
2002-01-14 22:24:39 +03:00
|
|
|
esm_power(ess, PCI_PMCSR_STATE_D3);
|
2001-01-08 22:54:31 +03:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
esm_resume(struct esm_softc *ess)
|
|
|
|
{
|
2001-03-08 15:54:45 +03:00
|
|
|
int x;
|
2001-01-08 22:54:31 +03:00
|
|
|
|
2002-01-14 22:24:39 +03:00
|
|
|
esm_power(ess, PCI_PMCSR_STATE_D0);
|
2001-01-08 22:54:31 +03:00
|
|
|
delay(100000);
|
|
|
|
esm_init(ess);
|
2001-03-08 15:54:45 +03:00
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
ess->codec_if->vtbl->restore_ports(ess->codec_if);
|
2001-03-08 15:54:45 +03:00
|
|
|
#if 0
|
2001-01-08 22:54:31 +03:00
|
|
|
if (mixer_reinit(dev)) {
|
|
|
|
printf("%s: unable to reinitialize the mixer\n",
|
|
|
|
ess->sc_dev.dv_xname);
|
|
|
|
return ENXIO;
|
|
|
|
}
|
2001-03-08 15:54:45 +03:00
|
|
|
#endif
|
2001-01-08 22:54:31 +03:00
|
|
|
|
|
|
|
x = splaudio();
|
2001-03-08 15:54:45 +03:00
|
|
|
#if TODO
|
2001-01-08 22:54:31 +03:00
|
|
|
if (ess->pactive)
|
|
|
|
esm_start_output(ess);
|
|
|
|
if (ess->ractive)
|
|
|
|
esm_start_input(ess);
|
2005-01-15 18:19:51 +03:00
|
|
|
#endif
|
2001-01-08 22:54:31 +03:00
|
|
|
if (ess->pactive || ess->ractive) {
|
|
|
|
set_timer(ess);
|
|
|
|
wp_starttimer(ess);
|
|
|
|
}
|
|
|
|
splx(x);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-03-08 15:54:45 +03:00
|
|
|
#if 0
|
2001-01-08 22:54:31 +03:00
|
|
|
int
|
|
|
|
esm_shutdown(struct esm_softc *ess)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
wp_stoptimer(ess);
|
|
|
|
bus_space_write_2(ess->st, ess->sh, PORT_HOSTINT_CTRL, 0);
|
|
|
|
|
|
|
|
esm_halt_output(ess);
|
|
|
|
esm_halt_input(ess);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|