Add snd_emu10kx driver for Creative SoundBlaster Live! and Audigy series
sound cards with optional pseudo-multichannel playback. It's based on snd_emu10k1 sound driver. Single channel version is available from audio/emu10kx port since some time. The two new ALSA header files (GPLed), which contain Audigy 2 ("p16v") and Audigy 2 Value ("p17v") specific interfaces, are latest versions from ALSA Mercurial repository. This is not connected to the build yet. Submitted by: Yuriy Tsibizov <Yuriy.Tsibizov@gfk.ru>
This commit is contained in:
parent
53f4fb1109
commit
d056fa046c
249
sys/dev/sound/pci/emu10kx-midi.c
Normal file
249
sys/dev/sound/pci/emu10kx-midi.c
Normal file
@ -0,0 +1,249 @@
|
||||
/*-
|
||||
* Copyright (c) 1999 Seigo Tanimura
|
||||
* (c) 2003 Mathew Kanner
|
||||
* Copyright (c) 2003-2006 Yuriy Tsibizov <yuriy.tsibizov@gfk.ru>
|
||||
* 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/bus.h>
|
||||
#include <machine/bus.h>
|
||||
#include <sys/rman.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/sbuf.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/mutex.h>
|
||||
|
||||
#include <dev/sound/chip.h>
|
||||
#include <dev/sound/pcm/sound.h>
|
||||
|
||||
#include <dev/sound/midi/midi.h>
|
||||
#include <dev/sound/midi/mpu401.h>
|
||||
#include "mpufoi_if.h"
|
||||
|
||||
#include "opt_emu10kx.h"
|
||||
#include <dev/sound/pci/emu10kx.h>
|
||||
#include "emu10k1-alsa%diked.h"
|
||||
|
||||
struct emu_midi_softc {
|
||||
struct mtx mtx;
|
||||
device_t dev;
|
||||
struct mpu401 *mpu;
|
||||
mpu401_intr_t *mpu_intr;
|
||||
struct emu_sc_info *card;
|
||||
int port; /* I/O port or I/O ptr reg */
|
||||
int is_emu10k1;
|
||||
int fflags; /* File flags */
|
||||
int ihandle; /* interrupt manager handle */
|
||||
};
|
||||
|
||||
static uint32_t emu_midi_card_intr(void *p, uint32_t arg);
|
||||
static devclass_t emu_midi_devclass;
|
||||
|
||||
static unsigned char
|
||||
emu_mread(void *arg __unused, struct emu_midi_softc *sc, int reg)
|
||||
{
|
||||
unsigned int d;
|
||||
|
||||
d = 0;
|
||||
if (sc->is_emu10k1)
|
||||
d = emu_rd(sc->card, 0x18 + reg, 1);
|
||||
else
|
||||
d = emu_rdptr(sc->card, 0, sc->port + reg);
|
||||
|
||||
return (d);
|
||||
}
|
||||
|
||||
static void
|
||||
emu_mwrite(void *arg __unused, struct emu_midi_softc *sc, int reg, unsigned char b)
|
||||
{
|
||||
|
||||
if (sc->is_emu10k1)
|
||||
emu_wr(sc->card, 0x18 + reg, b, 1);
|
||||
else
|
||||
emu_wrptr(sc->card, 0, sc->port + reg, b);
|
||||
}
|
||||
|
||||
static int
|
||||
emu_muninit(void *arg __unused, struct emu_midi_softc *sc)
|
||||
{
|
||||
|
||||
mtx_lock(&sc->mtx);
|
||||
sc->mpu_intr = NULL;
|
||||
mtx_unlock(&sc->mtx);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static kobj_method_t emu_mpu_methods[] = {
|
||||
KOBJMETHOD(mpufoi_read, emu_mread),
|
||||
KOBJMETHOD(mpufoi_write, emu_mwrite),
|
||||
KOBJMETHOD(mpufoi_uninit, emu_muninit),
|
||||
{0, 0}
|
||||
};
|
||||
DEFINE_CLASS(emu_mpu, emu_mpu_methods, 0);
|
||||
|
||||
static uint32_t
|
||||
emu_midi_card_intr(void *p, uint32_t intr_status)
|
||||
{
|
||||
struct emu_midi_softc *sc = (struct emu_midi_softc *)p;
|
||||
if (sc->mpu_intr)
|
||||
(sc->mpu_intr) (sc->mpu);
|
||||
if (sc->mpu_intr == NULL) {
|
||||
/* We should read MIDI event to unlock card after
|
||||
* interrupt. XXX - check, why this happens. */
|
||||
#ifdef SND_EMU10KX_DEBUG
|
||||
device_printf(sc->dev, "midi interrupt %08x without interrupt handler, force mread!\n", intr_status);
|
||||
#endif
|
||||
(void)emu_mread((void *)(NULL), sc, 0);
|
||||
}
|
||||
return (intr_status); /* Acknowledge everything */
|
||||
}
|
||||
|
||||
static void
|
||||
emu_midi_intr(void *p)
|
||||
{
|
||||
(void)emu_midi_card_intr(p, 0);
|
||||
}
|
||||
|
||||
static int
|
||||
emu_midi_probe(device_t dev)
|
||||
{
|
||||
struct emu_midi_softc *scp;
|
||||
uintptr_t func, r;
|
||||
|
||||
r = BUS_READ_IVAR(device_get_parent(dev), dev, 0, &func);
|
||||
if (func != SCF_MIDI)
|
||||
return (ENXIO);
|
||||
|
||||
scp = device_get_softc(dev);
|
||||
bzero(scp, sizeof(*scp));
|
||||
r = BUS_READ_IVAR(device_get_parent(dev), dev, EMU_VAR_ISEMU10K1, &(scp->is_emu10k1));
|
||||
|
||||
device_set_desc(dev, "EMU10Kx MIDI Interface");
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
emu_midi_attach(device_t dev)
|
||||
{
|
||||
struct emu_midi_softc * scp;
|
||||
struct sndcard_func *func;
|
||||
struct emu_midiinfo *midiinfo;
|
||||
uint32_t inte_val, ipr_val;
|
||||
|
||||
scp = device_get_softc(dev);
|
||||
func = device_get_ivars(dev);
|
||||
|
||||
scp->dev = dev;
|
||||
midiinfo = (struct emu_midiinfo *)func->varinfo;
|
||||
scp->port = midiinfo->port;
|
||||
scp->card = midiinfo->card;
|
||||
|
||||
mtx_init(&scp->mtx, "emu10kx_midi", NULL, MTX_DEF);
|
||||
|
||||
if (scp->is_emu10k1) {
|
||||
/* SB Live! - only one MIDI device here */
|
||||
inte_val = 0;
|
||||
/* inte_val |= INTE_MIDITXENABLE;*/
|
||||
inte_val |= INTE_MIDIRXENABLE;
|
||||
ipr_val = IPR_MIDITRANSBUFEMPTY;
|
||||
ipr_val |= IPR_MIDIRECVBUFEMPTY;
|
||||
} else {
|
||||
if (scp->port == A_MUDATA1) {
|
||||
/* EXTERNAL MIDI (AudigyDrive) */
|
||||
inte_val = 0;
|
||||
/* inte_val |= A_INTE_MIDITXENABLE1;*/
|
||||
inte_val |= INTE_MIDIRXENABLE;
|
||||
ipr_val = IPR_MIDITRANSBUFEMPTY;
|
||||
ipr_val |= IPR_MIDIRECVBUFEMPTY;
|
||||
} else {
|
||||
/* MIDI hw config port 2 */
|
||||
inte_val = 0;
|
||||
/* inte_val |= A_INTE_MIDITXENABLE2;*/
|
||||
inte_val |= INTE_A_MIDIRXENABLE2;
|
||||
ipr_val = IPR_A_MIDITRANSBUFEMPTY2;
|
||||
ipr_val |= IPR_A_MIDIRECVBUFEMPTY2;
|
||||
}
|
||||
}
|
||||
if (inte_val == 0)
|
||||
return (ENXIO);
|
||||
|
||||
scp->ihandle = emu_intr_register(scp->card, inte_val, ipr_val, &emu_midi_card_intr, scp);
|
||||
/* Init the interface. */
|
||||
scp->mpu = mpu401_init(&emu_mpu_class, scp, emu_midi_intr, &scp->mpu_intr);
|
||||
if (scp->mpu == NULL) {
|
||||
emu_intr_unregister(scp->card, scp->ihandle);
|
||||
mtx_destroy(&scp->mtx);
|
||||
return (ENOMEM);
|
||||
}
|
||||
/*
|
||||
* XXX I don't know how to check for Live!Drive / AudigyDrive
|
||||
* presence. Let's hope that IR enabling code will not harm if
|
||||
* it is not present.
|
||||
*/
|
||||
if (scp->is_emu10k1)
|
||||
emu_enable_ir(scp->card);
|
||||
else {
|
||||
if (scp->port == A_MUDATA1)
|
||||
emu_enable_ir(scp->card);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
emu_midi_detach(device_t dev)
|
||||
{
|
||||
struct emu_midi_softc *scp;
|
||||
|
||||
scp = device_get_softc(dev);
|
||||
mpu401_uninit(scp->mpu);
|
||||
emu_intr_unregister(scp->card, scp->ihandle);
|
||||
mtx_destroy(&scp->mtx);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static device_method_t emu_midi_methods[] = {
|
||||
DEVMETHOD(device_probe, emu_midi_probe),
|
||||
DEVMETHOD(device_attach, emu_midi_attach),
|
||||
DEVMETHOD(device_detach, emu_midi_detach),
|
||||
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
static driver_t emu_midi_driver = {
|
||||
"midi",
|
||||
emu_midi_methods,
|
||||
sizeof(struct emu_midi_softc),
|
||||
};
|
||||
DRIVER_MODULE(snd_emu10kx_midi, emu10kx, emu_midi_driver, emu_midi_devclass, 0, 0);
|
||||
MODULE_DEPEND(snd_emu10kx_midi, snd_emu10kx, SND_EMU10KX_MINVER, SND_EMU10KX_PREFVER, SND_EMU10KX_MAXVER);
|
||||
MODULE_DEPEND(snd_emu10kx_midi, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER);
|
||||
MODULE_VERSION(snd_emu10kx_midi, SND_EMU10KX_PREFVER);
|
965
sys/dev/sound/pci/emu10kx-pcm.c
Normal file
965
sys/dev/sound/pci/emu10kx-pcm.c
Normal file
@ -0,0 +1,965 @@
|
||||
/*-
|
||||
* Copyright (c) 1999 Cameron Grant <gandalf@vilnya.demon.co.uk>
|
||||
* Copyright (c) 2003-2006 Yuriy Tsibizov <yuriy.tsibizov@gfk.ru>
|
||||
* 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, WHETHERIN 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/bus.h>
|
||||
#include <machine/bus.h>
|
||||
#include <sys/rman.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/sbuf.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/mutex.h>
|
||||
|
||||
#include <dev/sound/chip.h>
|
||||
#include <dev/sound/pcm/sound.h>
|
||||
#include <dev/sound/pcm/ac97.h>
|
||||
|
||||
#include "mixer_if.h"
|
||||
|
||||
#include "opt_emu10kx.h"
|
||||
#include <dev/sound/pci/emu10kx.h>
|
||||
#include "emu10k1-alsa%diked.h"
|
||||
|
||||
struct emu_pcm_pchinfo {
|
||||
int spd;
|
||||
int fmt;
|
||||
int blksz;
|
||||
int run;
|
||||
struct emu_voice *master;
|
||||
struct emu_voice *slave;
|
||||
struct snd_dbuf *buffer;
|
||||
struct pcm_channel *channel;
|
||||
struct emu_pcm_info *pcm;
|
||||
int timer;
|
||||
};
|
||||
|
||||
struct emu_pcm_rchinfo {
|
||||
int spd;
|
||||
int fmt;
|
||||
int blksz;
|
||||
int run;
|
||||
uint32_t idxreg;
|
||||
uint32_t basereg;
|
||||
uint32_t sizereg;
|
||||
uint32_t setupreg;
|
||||
uint32_t irqmask;
|
||||
uint32_t iprmask;
|
||||
int ihandle;
|
||||
struct snd_dbuf *buffer;
|
||||
struct pcm_channel *channel;
|
||||
struct emu_pcm_info *pcm;
|
||||
};
|
||||
|
||||
/* Hardware channels for front output */
|
||||
#define MAX_CHANNELS 4
|
||||
|
||||
#if MAX_CHANNELS > 13
|
||||
#error Too many hardware channels defined. 13 is the maximum
|
||||
#endif
|
||||
struct emu_pcm_info {
|
||||
struct mtx *lock;
|
||||
device_t dev; /* device information */
|
||||
struct snddev_info *devinfo; /* pcm device information */
|
||||
struct emu_sc_info *card;
|
||||
struct emu_pcm_pchinfo pch[MAX_CHANNELS]; /* hardware channels */
|
||||
int pnum; /* next free channel number */
|
||||
struct emu_pcm_rchinfo rch;
|
||||
struct emu_route rt;
|
||||
int route;
|
||||
int ihandle; /* interrupt handler */
|
||||
unsigned int bufsz;
|
||||
int is_emu10k1;
|
||||
struct ac97_info *codec;
|
||||
uint32_t ac97_state[0x7F];
|
||||
};
|
||||
|
||||
|
||||
static uint32_t emu_rfmt[] = {
|
||||
AFMT_S16_LE,
|
||||
AFMT_STEREO | AFMT_S16_LE,
|
||||
0
|
||||
};
|
||||
static struct pcmchan_caps emu_reccaps = {
|
||||
/* XXX should be "8000, 48000, emu_rfmt, 0", but 8000/8bit/mono is broken */
|
||||
11025, 48000, emu_rfmt, 0
|
||||
};
|
||||
|
||||
static uint32_t emu_pfmt[] = {
|
||||
AFMT_U8,
|
||||
AFMT_STEREO | AFMT_U8,
|
||||
AFMT_S16_LE,
|
||||
AFMT_STEREO | AFMT_S16_LE,
|
||||
0
|
||||
};
|
||||
static uint32_t emu_pfmt_mono[] = {
|
||||
AFMT_U8,
|
||||
AFMT_S16_LE,
|
||||
0
|
||||
};
|
||||
|
||||
static struct pcmchan_caps emu_playcaps = {4000, 48000, emu_pfmt, 0};
|
||||
static struct pcmchan_caps emu_playcaps_mono = {4000, 48000, emu_pfmt_mono, 0};
|
||||
|
||||
static int emu10k1_adcspeed[8] = {48000, 44100, 32000, 24000, 22050, 16000, 11025, 8000};
|
||||
/* audigy supports 12kHz. */
|
||||
static int emu10k2_adcspeed[9] = {48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000};
|
||||
|
||||
static uint32_t emu_pcm_intr(void *pcm, uint32_t stat);
|
||||
|
||||
static const struct emu_dspmix_props {
|
||||
u_int8_t present;
|
||||
} dspmix [SOUND_MIXER_NRDEVICES] = {
|
||||
[SOUND_MIXER_VOLUME] = {1},
|
||||
[SOUND_MIXER_PCM] = {1},
|
||||
};
|
||||
|
||||
static int
|
||||
emu_dspmixer_init(struct snd_mixer *m)
|
||||
{
|
||||
int i;
|
||||
int v;
|
||||
|
||||
v = 0;
|
||||
for (i = 0; i < SOUND_MIXER_NRDEVICES; i++) {
|
||||
if (dspmix[i].present)
|
||||
v |= 1 << i;
|
||||
}
|
||||
mix_setdevs(m, v);
|
||||
|
||||
mix_setrecdevs(m, 0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
emu_dspmixer_set(struct snd_mixer *m, unsigned dev, unsigned left, unsigned right)
|
||||
{
|
||||
struct emu_pcm_info *sc;
|
||||
|
||||
sc = mix_getdevinfo(m);
|
||||
|
||||
switch (dev) {
|
||||
case SOUND_MIXER_VOLUME:
|
||||
switch (sc->route) {
|
||||
case RT_REAR:
|
||||
emumix_set_volume(sc->card, M_MASTER_REAR_L, left);
|
||||
emumix_set_volume(sc->card, M_MASTER_REAR_R, right);
|
||||
break;
|
||||
case RT_CENTER:
|
||||
emumix_set_volume(sc->card, M_MASTER_CENTER, (left+right)/2);
|
||||
break;
|
||||
case RT_SUB:
|
||||
emumix_set_volume(sc->card, M_MASTER_SUBWOOFER, (left+right)/2);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case SOUND_MIXER_PCM:
|
||||
switch (sc->route) {
|
||||
case RT_REAR:
|
||||
emumix_set_volume(sc->card, M_FX2_REAR_L, left);
|
||||
emumix_set_volume(sc->card, M_FX3_REAR_R, right);
|
||||
break;
|
||||
case RT_CENTER:
|
||||
emumix_set_volume(sc->card, M_FX4_CENTER, (left+right)/2);
|
||||
break;
|
||||
case RT_SUB:
|
||||
emumix_set_volume(sc->card, M_FX5_SUBWOOFER, (left+right)/2);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
device_printf(sc->dev, "mixer error: unknown device %d\n", dev);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
emu_dspmixer_setrecsrc(struct snd_mixer *m __unused, u_int32_t src __unused)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
static kobj_method_t emudspmixer_methods[] = {
|
||||
KOBJMETHOD(mixer_init, emu_dspmixer_init),
|
||||
KOBJMETHOD(mixer_set, emu_dspmixer_set),
|
||||
KOBJMETHOD(mixer_setrecsrc, emu_dspmixer_setrecsrc),
|
||||
{ 0, 0 }
|
||||
};
|
||||
MIXER_DECLARE(emudspmixer);
|
||||
|
||||
/*
|
||||
* AC97 emulation code for Audigy and later cards.
|
||||
* Some parts of AC97 codec are not used by hardware, but can be used
|
||||
* to change some DSP controls via AC97 mixer interface. This includes:
|
||||
* - master volume controls MASTER_FRONT_[R|L]
|
||||
* - pcm volume controls FX[0|1]_FRONT_[R|L]
|
||||
* - rec volume controls MASTER_REC_[R|L]
|
||||
* We do it because we need to put it under user control....
|
||||
* We also keep some parts of AC97 disabled to get better sound quality
|
||||
*/
|
||||
|
||||
#define AC97LEFT(x) ((x & 0x7F00)>>8)
|
||||
#define AC97RIGHT(x) (x & 0x007F)
|
||||
#define AC97MUTE(x) ((x & 0x8000)>>15)
|
||||
#define BIT4_TO100(x) (100-(x)*100/(0x0f))
|
||||
#define BIT6_TO100(x) (100-(x)*100/(0x3f))
|
||||
#define BIT4_TO255(x) (255-(x)*255/(0x0f))
|
||||
#define BIT6_TO255(x) (255-(x)*255/(0x3f))
|
||||
#define V100_TOBIT6(x) (0x3f*(100-x)/100)
|
||||
#define V100_TOBIT4(x) (0x0f*(100-x)/100)
|
||||
#define AC97ENCODE(x_muted,x_left,x_right) (((x_muted&1)<<15) | ((x_left&0x3f)<<8) | (x_right&0x3f))
|
||||
|
||||
static int
|
||||
emu_ac97_read_emulation(struct emu_pcm_info *sc, int regno)
|
||||
{
|
||||
int use_ac97;
|
||||
int emulated;
|
||||
int tmp;
|
||||
|
||||
use_ac97 = 1;
|
||||
emulated = 0;
|
||||
|
||||
switch (regno) {
|
||||
case AC97_MIX_MASTER:
|
||||
emulated = sc->ac97_state[AC97_MIX_MASTER];
|
||||
use_ac97 = 0;
|
||||
break;
|
||||
case AC97_MIX_PCM:
|
||||
emulated = sc->ac97_state[AC97_MIX_PCM];
|
||||
use_ac97 = 0;
|
||||
break;
|
||||
case AC97_REG_RECSEL:
|
||||
emulated = 0x0505;
|
||||
use_ac97 = 0;
|
||||
break;
|
||||
case AC97_MIX_RGAIN:
|
||||
emulated = sc->ac97_state[AC97_MIX_RGAIN];
|
||||
use_ac97 = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
emu_wr(sc->card, AC97ADDRESS, regno, 1);
|
||||
tmp = emu_rd(sc->card, AC97DATA, 2);
|
||||
|
||||
if (use_ac97)
|
||||
emulated = tmp;
|
||||
|
||||
return (emulated);
|
||||
}
|
||||
|
||||
static void
|
||||
emu_ac97_write_emulation(struct emu_pcm_info *sc, int regno, uint32_t data)
|
||||
{
|
||||
int write_ac97;
|
||||
int left, right;
|
||||
uint32_t emu_left, emu_right;
|
||||
int is_mute;
|
||||
|
||||
write_ac97 = 1;
|
||||
|
||||
left = AC97LEFT(data);
|
||||
emu_left = BIT6_TO100(left); /* We show us as 6-bit AC97 mixer */
|
||||
right = AC97RIGHT(data);
|
||||
emu_right = BIT6_TO100(right);
|
||||
is_mute = AC97MUTE(data);
|
||||
if (is_mute)
|
||||
emu_left = emu_right = 0;
|
||||
|
||||
switch (regno) {
|
||||
/* TODO: reset emulator on AC97_RESET */
|
||||
case AC97_MIX_MASTER:
|
||||
emumix_set_volume(sc->card, M_MASTER_FRONT_L, emu_left);
|
||||
emumix_set_volume(sc->card, M_MASTER_FRONT_R, emu_right);
|
||||
sc->ac97_state[AC97_MIX_MASTER] = data & (0x8000 | 0x3f3f);
|
||||
data = 0x8000; /* Mute AC97 main out */
|
||||
break;
|
||||
case AC97_MIX_PCM: /* PCM OUT VOL */
|
||||
emumix_set_volume(sc->card, M_FX0_FRONT_L, emu_left);
|
||||
emumix_set_volume(sc->card, M_FX1_FRONT_R, emu_right);
|
||||
sc->ac97_state[AC97_MIX_PCM] = data & (0x8000 | 0x3f3f);
|
||||
data = 0x8000; /* Mute AC97 PCM out */
|
||||
break;
|
||||
case AC97_REG_RECSEL:
|
||||
/*
|
||||
* PCM recording source is set to "stereo mix" (labeled "vol"
|
||||
* in mixer) XXX !I can't remember why!
|
||||
*/
|
||||
data = 0x0505;
|
||||
break;
|
||||
case AC97_MIX_RGAIN: /* RECORD GAIN */
|
||||
emu_left = BIT4_TO100(left); /* rgain is 4-bit */
|
||||
emu_right = BIT4_TO100(right);
|
||||
emumix_set_volume(sc->card, M_MASTER_REC_L, 100-emu_left);
|
||||
emumix_set_volume(sc->card, M_MASTER_REC_R, 100-emu_right);
|
||||
/*
|
||||
* Record gain on AC97 should stay zero to get AC97 sound on
|
||||
* AC97_[RL] connectors on EMU10K2 chip. AC97 on Audigy is not
|
||||
* directly connected to any output, only to EMU10K2 chip Use
|
||||
* this control to set AC97 mix volume inside EMU10K2 chip
|
||||
*/
|
||||
sc->ac97_state[AC97_MIX_RGAIN] = data & (0x8000 | 0x0f0f);
|
||||
data = 0x0000;
|
||||
break;
|
||||
}
|
||||
if (write_ac97) {
|
||||
emu_wr(sc->card, AC97ADDRESS, regno, 1);
|
||||
emu_wr(sc->card, AC97DATA, data, 2);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
emu_erdcd(kobj_t obj __unused, void *devinfo, int regno)
|
||||
{
|
||||
struct emu_pcm_info *sc = (struct emu_pcm_info *)devinfo;
|
||||
|
||||
return (emu_ac97_read_emulation(sc, regno));
|
||||
}
|
||||
|
||||
static int
|
||||
emu_ewrcd(kobj_t obj __unused, void *devinfo, int regno, uint32_t data)
|
||||
{
|
||||
struct emu_pcm_info *sc = (struct emu_pcm_info *)devinfo;
|
||||
|
||||
emu_ac97_write_emulation(sc, regno, data);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static kobj_method_t emu_eac97_methods[] = {
|
||||
KOBJMETHOD(ac97_read, emu_erdcd),
|
||||
KOBJMETHOD(ac97_write, emu_ewrcd),
|
||||
{0, 0}
|
||||
};
|
||||
AC97_DECLARE(emu_eac97);
|
||||
|
||||
/* real ac97 codec */
|
||||
static int
|
||||
emu_rdcd(kobj_t obj __unused, void *devinfo, int regno)
|
||||
{
|
||||
int rd;
|
||||
struct emu_pcm_info *sc = (struct emu_pcm_info *)devinfo;
|
||||
|
||||
KASSERT(sc->card != NULL, ("emu_rdcd: no soundcard"));
|
||||
emu_wr(sc->card, AC97ADDRESS, regno, 1);
|
||||
rd = emu_rd(sc->card, AC97DATA, 2);
|
||||
return (rd);
|
||||
}
|
||||
|
||||
static int
|
||||
emu_wrcd(kobj_t obj __unused, void *devinfo, int regno, uint32_t data)
|
||||
{
|
||||
struct emu_pcm_info *sc = (struct emu_pcm_info *)devinfo;
|
||||
|
||||
KASSERT(sc->card != NULL, ("emu_wrcd: no soundcard"));
|
||||
emu_wr(sc->card, AC97ADDRESS, regno, 1);
|
||||
emu_wr(sc->card, AC97DATA, data, 2);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static kobj_method_t emu_ac97_methods[] = {
|
||||
KOBJMETHOD(ac97_read, emu_rdcd),
|
||||
KOBJMETHOD(ac97_write, emu_wrcd),
|
||||
{0, 0}
|
||||
};
|
||||
AC97_DECLARE(emu_ac97);
|
||||
|
||||
|
||||
static int
|
||||
emu_k1_recval(int speed)
|
||||
{
|
||||
int val;
|
||||
|
||||
val = 0;
|
||||
while ((val < 7) && (speed < emu10k1_adcspeed[val]))
|
||||
val++;
|
||||
if (val == 6) val=5; /* XXX 8kHz does not work */
|
||||
return (val);
|
||||
}
|
||||
|
||||
static int
|
||||
emu_k2_recval(int speed)
|
||||
{
|
||||
int val;
|
||||
|
||||
val = 0;
|
||||
while ((val < 8) && (speed < emu10k2_adcspeed[val]))
|
||||
val++;
|
||||
if (val == 7) val=6; /* XXX 8kHz does not work */
|
||||
return (val);
|
||||
}
|
||||
|
||||
static void *
|
||||
emupchan_init(kobj_t obj __unused, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir __unused)
|
||||
{
|
||||
struct emu_pcm_info *sc = devinfo;
|
||||
struct emu_pcm_pchinfo *ch;
|
||||
void *r;
|
||||
|
||||
KASSERT(dir == PCMDIR_PLAY, ("emupchan_init: bad direction"));
|
||||
KASSERT(sc->card != NULL, ("empchan_init: no soundcard"));
|
||||
|
||||
|
||||
if (sc->pnum >= MAX_CHANNELS)
|
||||
return (NULL);
|
||||
ch = &(sc->pch[sc->pnum++]);
|
||||
ch->buffer = b;
|
||||
ch->pcm = sc;
|
||||
ch->channel = c;
|
||||
ch->blksz = sc->bufsz;
|
||||
ch->fmt = AFMT_U8;
|
||||
ch->spd = 8000;
|
||||
ch->master = emu_valloc(sc->card);
|
||||
/*
|
||||
* XXX we have to allocate slave even for mono channel until we
|
||||
* fix emu_vfree to handle this case.
|
||||
*/
|
||||
ch->slave = emu_valloc(sc->card);
|
||||
ch->timer = emu_timer_create(sc->card);
|
||||
r = (emu_vinit(sc->card, ch->master, ch->slave, sc->bufsz, ch->buffer)) ? NULL : ch;
|
||||
return (r);
|
||||
}
|
||||
|
||||
static int
|
||||
emupchan_free(kobj_t obj __unused, void *c_devinfo)
|
||||
{
|
||||
struct emu_pcm_pchinfo *ch = c_devinfo;
|
||||
struct emu_pcm_info *sc = ch->pcm;
|
||||
|
||||
emu_timer_clear(sc->card, ch->timer);
|
||||
if (ch->slave != NULL)
|
||||
emu_vfree(sc->card, ch->slave);
|
||||
emu_vfree(sc->card, ch->master);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
emupchan_setformat(kobj_t obj __unused, void *c_devinfo, uint32_t format)
|
||||
{
|
||||
struct emu_pcm_pchinfo *ch = c_devinfo;
|
||||
|
||||
ch->fmt = format;
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
emupchan_setspeed(kobj_t obj __unused, void *c_devinfo, uint32_t speed)
|
||||
{
|
||||
struct emu_pcm_pchinfo *ch = c_devinfo;
|
||||
|
||||
ch->spd = speed;
|
||||
return (ch->spd);
|
||||
}
|
||||
|
||||
static int
|
||||
emupchan_setblocksize(kobj_t obj __unused, void *c_devinfo, uint32_t blocksize)
|
||||
{
|
||||
struct emu_pcm_pchinfo *ch = c_devinfo;
|
||||
struct emu_pcm_info *sc = ch->pcm;
|
||||
|
||||
if (blocksize > ch->pcm->bufsz)
|
||||
blocksize = ch->pcm->bufsz;
|
||||
snd_mtxlock(sc->lock);
|
||||
ch->blksz = blocksize;
|
||||
emu_timer_set(sc->card, ch->timer, ch->blksz / sndbuf_getbps(ch->buffer));
|
||||
snd_mtxunlock(sc->lock);
|
||||
return (blocksize);
|
||||
}
|
||||
|
||||
static int
|
||||
emupchan_trigger(kobj_t obj __unused, void *c_devinfo, int go)
|
||||
{
|
||||
struct emu_pcm_pchinfo *ch = c_devinfo;
|
||||
struct emu_pcm_info *sc = ch->pcm;
|
||||
|
||||
if (go == PCMTRIG_EMLDMAWR || go == PCMTRIG_EMLDMARD)
|
||||
return (0);
|
||||
snd_mtxlock(sc->lock); /* XXX can we trigger on parallel threads ? */
|
||||
if (go == PCMTRIG_START) {
|
||||
emu_vsetup(ch->master, ch->fmt, ch->spd);
|
||||
emu_vroute(sc->card, &(sc->rt), ch->master);
|
||||
emu_vwrite(sc->card, ch->master);
|
||||
emu_timer_set(sc->card, ch->timer, ch->blksz / sndbuf_getbps(ch->buffer));
|
||||
emu_timer_enable(sc->card, ch->timer, 1);
|
||||
}
|
||||
/* PCM interrupt handler will handle PCMTRIG_STOP event */
|
||||
ch->run = (go == PCMTRIG_START) ? 1 : 0;
|
||||
emu_vtrigger(sc->card, ch->master, ch->run);
|
||||
snd_mtxunlock(sc->lock);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
emupchan_getptr(kobj_t obj __unused, void *c_devinfo)
|
||||
{
|
||||
struct emu_pcm_pchinfo *ch = c_devinfo;
|
||||
struct emu_pcm_info *sc = ch->pcm;
|
||||
int r;
|
||||
|
||||
r = emu_vpos(sc->card, ch->master);
|
||||
|
||||
return (r);
|
||||
}
|
||||
|
||||
static struct pcmchan_caps *
|
||||
emupchan_getcaps(kobj_t obj __unused, void *c_devinfo __unused)
|
||||
{
|
||||
struct emu_pcm_pchinfo *ch = c_devinfo;
|
||||
struct emu_pcm_info *sc = ch->pcm;
|
||||
|
||||
switch (sc->route) {
|
||||
case RT_FRONT:
|
||||
/* FALLTHROUGH */
|
||||
case RT_REAR:
|
||||
/* FALLTHROUGH */
|
||||
case RT_SIDE:
|
||||
return (&emu_playcaps);
|
||||
break;
|
||||
case RT_CENTER:
|
||||
/* FALLTHROUGH */
|
||||
case RT_SUB:
|
||||
return (&emu_playcaps_mono);
|
||||
break;
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
static kobj_method_t emupchan_methods[] = {
|
||||
KOBJMETHOD(channel_init, emupchan_init),
|
||||
KOBJMETHOD(channel_free, emupchan_free),
|
||||
KOBJMETHOD(channel_setformat, emupchan_setformat),
|
||||
KOBJMETHOD(channel_setspeed, emupchan_setspeed),
|
||||
KOBJMETHOD(channel_setblocksize, emupchan_setblocksize),
|
||||
KOBJMETHOD(channel_trigger, emupchan_trigger),
|
||||
KOBJMETHOD(channel_getptr, emupchan_getptr),
|
||||
KOBJMETHOD(channel_getcaps, emupchan_getcaps),
|
||||
{0, 0}
|
||||
};
|
||||
CHANNEL_DECLARE(emupchan);
|
||||
|
||||
static void *
|
||||
emurchan_init(kobj_t obj __unused, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir __unused)
|
||||
{
|
||||
struct emu_pcm_info *sc = devinfo;
|
||||
struct emu_pcm_rchinfo *ch;
|
||||
|
||||
KASSERT(dir == PCMDIR_REC, ("emurchan_init: bad direction"));
|
||||
ch = &sc->rch;
|
||||
ch->buffer = b;
|
||||
ch->pcm = sc;
|
||||
ch->channel = c;
|
||||
ch->blksz = sc->bufsz;
|
||||
ch->fmt = AFMT_U8;
|
||||
ch->spd = 11025; /* XXX 8000 Hz does not work */
|
||||
ch->idxreg = sc->is_emu10k1 ? ADCIDX : A_ADCIDX;
|
||||
ch->basereg = ADCBA;
|
||||
ch->sizereg = ADCBS;
|
||||
ch->setupreg = ADCCR;
|
||||
ch->irqmask = INTE_ADCBUFENABLE;
|
||||
ch->iprmask = IPR_ADCBUFFULL | IPR_ADCBUFHALFFULL;
|
||||
|
||||
if (sndbuf_alloc(ch->buffer, emu_gettag(sc->card), sc->bufsz) != 0)
|
||||
return (NULL);
|
||||
else {
|
||||
emu_wrptr(sc->card, 0, ch->basereg, sndbuf_getbufaddr(ch->buffer));
|
||||
emu_wrptr(sc->card, 0, ch->sizereg, 0); /* off */
|
||||
return (ch);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
emurchan_setformat(kobj_t obj __unused, void *c_devinfo, uint32_t format)
|
||||
{
|
||||
struct emu_pcm_rchinfo *ch = c_devinfo;
|
||||
|
||||
ch->fmt = format;
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
emurchan_setspeed(kobj_t obj __unused, void *c_devinfo, uint32_t speed)
|
||||
{
|
||||
struct emu_pcm_rchinfo *ch = c_devinfo;
|
||||
|
||||
if (ch->pcm->is_emu10k1) {
|
||||
speed = emu10k1_adcspeed[emu_k1_recval(speed)];
|
||||
} else {
|
||||
speed = emu10k2_adcspeed[emu_k2_recval(speed)];
|
||||
}
|
||||
ch->spd = speed;
|
||||
return (ch->spd);
|
||||
}
|
||||
|
||||
static int
|
||||
emurchan_setblocksize(kobj_t obj __unused, void *c_devinfo, uint32_t blocksize)
|
||||
{
|
||||
struct emu_pcm_rchinfo *ch = c_devinfo;
|
||||
|
||||
ch->blksz = blocksize;
|
||||
return (blocksize);
|
||||
}
|
||||
|
||||
static int
|
||||
emurchan_trigger(kobj_t obj __unused, void *c_devinfo, int go)
|
||||
{
|
||||
struct emu_pcm_rchinfo *ch = c_devinfo;
|
||||
struct emu_pcm_info *sc = ch->pcm;
|
||||
uint32_t val, sz;
|
||||
|
||||
switch (sc->bufsz) {
|
||||
case 4096:
|
||||
sz = ADCBS_BUFSIZE_4096;
|
||||
break;
|
||||
case 8192:
|
||||
sz = ADCBS_BUFSIZE_8192;
|
||||
break;
|
||||
case 16384:
|
||||
sz = ADCBS_BUFSIZE_16384;
|
||||
break;
|
||||
case 32768:
|
||||
sz = ADCBS_BUFSIZE_32768;
|
||||
break;
|
||||
case 65536:
|
||||
sz = ADCBS_BUFSIZE_65536;
|
||||
break;
|
||||
default:
|
||||
sz = ADCBS_BUFSIZE_4096;
|
||||
}
|
||||
|
||||
snd_mtxlock(sc->lock);
|
||||
switch (go) {
|
||||
case PCMTRIG_START:
|
||||
ch->run = 1;
|
||||
emu_wrptr(sc->card, 0, ch->sizereg, sz);
|
||||
val = sc->is_emu10k1 ? ADCCR_LCHANENABLE : A_ADCCR_LCHANENABLE;
|
||||
if (ch->fmt & AFMT_STEREO)
|
||||
val |= sc->is_emu10k1 ? ADCCR_RCHANENABLE : A_ADCCR_RCHANENABLE;
|
||||
val |= sc->is_emu10k1 ? emu_k1_recval(ch->spd) : emu_k2_recval(ch->spd);
|
||||
emu_wrptr(sc->card, 0, ch->setupreg, 0);
|
||||
emu_wrptr(sc->card, 0, ch->setupreg, val);
|
||||
ch->ihandle = emu_intr_register(sc->card, ch->irqmask, ch->iprmask, &emu_pcm_intr, sc);
|
||||
break;
|
||||
case PCMTRIG_STOP:
|
||||
/* FALLTHROUGH */
|
||||
case PCMTRIG_ABORT:
|
||||
ch->run = 0;
|
||||
emu_wrptr(sc->card, 0, ch->sizereg, 0);
|
||||
if (ch->setupreg)
|
||||
emu_wrptr(sc->card, 0, ch->setupreg, 0);
|
||||
(void)emu_intr_unregister(sc->card, ch->ihandle);
|
||||
break;
|
||||
case PCMTRIG_EMLDMAWR:
|
||||
/* FALLTHROUGH */
|
||||
case PCMTRIG_EMLDMARD:
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
break;
|
||||
}
|
||||
snd_mtxunlock(sc->lock);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
emurchan_getptr(kobj_t obj __unused, void *c_devinfo)
|
||||
{
|
||||
struct emu_pcm_rchinfo *ch = c_devinfo;
|
||||
struct emu_pcm_info *sc = ch->pcm;
|
||||
int r;
|
||||
|
||||
r = emu_rdptr(sc->card, 0, ch->idxreg) & 0x0000ffff;
|
||||
|
||||
return (r);
|
||||
}
|
||||
|
||||
static struct pcmchan_caps *
|
||||
emurchan_getcaps(kobj_t obj __unused, void *c_devinfo __unused)
|
||||
{
|
||||
return (&emu_reccaps);
|
||||
}
|
||||
|
||||
static kobj_method_t emurchan_methods[] = {
|
||||
KOBJMETHOD(channel_init, emurchan_init),
|
||||
KOBJMETHOD(channel_setformat, emurchan_setformat),
|
||||
KOBJMETHOD(channel_setspeed, emurchan_setspeed),
|
||||
KOBJMETHOD(channel_setblocksize, emurchan_setblocksize),
|
||||
KOBJMETHOD(channel_trigger, emurchan_trigger),
|
||||
KOBJMETHOD(channel_getptr, emurchan_getptr),
|
||||
KOBJMETHOD(channel_getcaps, emurchan_getcaps),
|
||||
{0, 0}
|
||||
};
|
||||
CHANNEL_DECLARE(emurchan);
|
||||
|
||||
|
||||
static uint32_t
|
||||
emu_pcm_intr(void *pcm, uint32_t stat)
|
||||
{
|
||||
struct emu_pcm_info *sc = (struct emu_pcm_info *)pcm;
|
||||
uint32_t ack;
|
||||
int i;
|
||||
|
||||
ack = 0;
|
||||
|
||||
if (stat & IPR_INTERVALTIMER) {
|
||||
ack |= IPR_INTERVALTIMER;
|
||||
for (i = 0; i < MAX_CHANNELS; i++)
|
||||
if (sc->pch[i].channel) {
|
||||
if (sc->pch[i].run == 1)
|
||||
chn_intr(sc->pch[i].channel);
|
||||
else
|
||||
emu_timer_enable(sc->card, sc->pch[i].timer, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (stat & (IPR_ADCBUFFULL | IPR_ADCBUFHALFFULL)) {
|
||||
ack |= stat & (IPR_ADCBUFFULL | IPR_ADCBUFHALFFULL);
|
||||
if (sc->rch.channel)
|
||||
chn_intr(sc->rch.channel);
|
||||
}
|
||||
return (ack);
|
||||
}
|
||||
|
||||
static int
|
||||
emu_pcm_init(struct emu_pcm_info *sc)
|
||||
{
|
||||
sc->bufsz = pcm_getbuffersize(sc->dev, 4096, EMU_DEFAULT_BUFSZ, EMU_MAX_BUFSZ);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
emu_pcm_uninit(struct emu_pcm_info *sc __unused)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
emu_pcm_probe(device_t dev)
|
||||
{
|
||||
uintptr_t func, route, r;
|
||||
const char *rt;
|
||||
char buffer[255];
|
||||
|
||||
r = BUS_READ_IVAR(device_get_parent(dev), dev, EMU_VAR_FUNC, &func);
|
||||
|
||||
if (func != SCF_PCM)
|
||||
return (ENXIO);
|
||||
|
||||
rt = "UNKNOWN";
|
||||
r = BUS_READ_IVAR(device_get_parent(dev), dev, EMU_VAR_ROUTE, &route);
|
||||
switch (route) {
|
||||
case RT_FRONT:
|
||||
rt = "FRONT";
|
||||
break;
|
||||
case RT_REAR:
|
||||
rt = "REAR";
|
||||
break;
|
||||
case RT_CENTER:
|
||||
rt = "CENTER";
|
||||
break;
|
||||
case RT_SUB:
|
||||
rt = "SUBWOOFER";
|
||||
break;
|
||||
case RT_SIDE:
|
||||
rt = "SIDE";
|
||||
break;
|
||||
}
|
||||
|
||||
snprintf(buffer, 255, "EMU10Kx DSP %s PCM Interface", rt);
|
||||
device_set_desc_copy(dev, buffer);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
emu_pcm_attach(device_t dev)
|
||||
{
|
||||
struct emu_pcm_info *sc;
|
||||
unsigned int i;
|
||||
char status[SND_STATUSLEN];
|
||||
uint32_t inte, ipr;
|
||||
uintptr_t route, r;
|
||||
|
||||
if ((sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK | M_ZERO)) == NULL) {
|
||||
device_printf(dev, "cannot allocate softc\n");
|
||||
return (ENXIO);
|
||||
}
|
||||
bzero(sc, sizeof(*sc));
|
||||
|
||||
sc->card = (struct emu_sc_info *)(device_get_softc(device_get_parent(dev)));
|
||||
if (sc->card == NULL) {
|
||||
device_printf(dev, "cannot get bridge conf\n");
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
sc->lock = snd_mtxcreate(device_get_nameunit(dev), "sound softc");
|
||||
sc->dev = dev;
|
||||
|
||||
r = BUS_READ_IVAR(device_get_parent(dev), dev, EMU_VAR_ISEMU10K1, &(sc->is_emu10k1));
|
||||
|
||||
sc->codec = NULL;
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
sc->rt.routing_left[i] = i;
|
||||
sc->rt.amounts_left[i] = 0x00;
|
||||
sc->rt.routing_right[i] = i;
|
||||
sc->rt.amounts_right[i] = 0x00;
|
||||
}
|
||||
|
||||
r = BUS_READ_IVAR(device_get_parent(dev), dev, EMU_VAR_ROUTE, &route);
|
||||
sc->route = route;
|
||||
switch (route) {
|
||||
case RT_FRONT:
|
||||
sc->rt.amounts_left[0] = 0xff;
|
||||
sc->rt.amounts_right[1] = 0xff;
|
||||
if (sc->is_emu10k1)
|
||||
sc->codec = AC97_CREATE(dev, sc, emu_ac97);
|
||||
else
|
||||
sc->codec = AC97_CREATE(dev, sc, emu_eac97);
|
||||
if (sc->codec == NULL) {
|
||||
if (mixer_init(dev, &emudspmixer_class, sc)) {
|
||||
device_printf(dev, "failed to initialize DSP mixer\n");
|
||||
goto bad;
|
||||
}
|
||||
} else
|
||||
if (mixer_init(dev, ac97_getmixerclass(), sc->codec) == -1) {
|
||||
device_printf(dev, "can't initialize AC97 mixer!\n");
|
||||
goto bad;
|
||||
}
|
||||
break;
|
||||
case RT_REAR:
|
||||
sc->rt.amounts_left[2] = 0xff;
|
||||
sc->rt.amounts_right[3] = 0xff;
|
||||
if (mixer_init(dev, &emudspmixer_class, sc)) {
|
||||
device_printf(dev, "failed to initialize mixer\n");
|
||||
goto bad;
|
||||
}
|
||||
break;
|
||||
case RT_CENTER:
|
||||
sc->rt.amounts_left[4] = 0xff;
|
||||
if (mixer_init(dev, &emudspmixer_class, sc)) {
|
||||
device_printf(dev, "failed to initialize mixer\n");
|
||||
goto bad;
|
||||
}
|
||||
break;
|
||||
case RT_SUB:
|
||||
sc->rt.amounts_left[5] = 0xff;
|
||||
if (mixer_init(dev, &emudspmixer_class, sc)) {
|
||||
device_printf(dev, "failed to initialize mixer\n");
|
||||
goto bad;
|
||||
}
|
||||
break;
|
||||
case RT_SIDE:
|
||||
sc->rt.amounts_left[6] = 0xff;
|
||||
sc->rt.amounts_right[7] = 0xff;
|
||||
if (mixer_init(dev, &emudspmixer_class, sc)) {
|
||||
device_printf(dev, "failed to initialize mixer\n");
|
||||
goto bad;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
device_printf(dev, "invalid default route\n");
|
||||
goto bad;
|
||||
}
|
||||
|
||||
inte = INTE_INTERVALTIMERENB;
|
||||
ipr = IPR_INTERVALTIMER; /* Used by playback */
|
||||
sc->ihandle = emu_intr_register(sc->card, inte, ipr, &emu_pcm_intr, sc);
|
||||
|
||||
if (emu_pcm_init(sc) == -1) {
|
||||
device_printf(dev, "unable to initialize PCM part of the card\n");
|
||||
goto bad;
|
||||
}
|
||||
|
||||
/* XXX we should better get number of available channels from parent */
|
||||
if (pcm_register(dev, sc, (route == RT_FRONT) ? MAX_CHANNELS : 1, (route == RT_FRONT) ? 1 : 0)) {
|
||||
device_printf(dev, "can't register PCM channels!\n");
|
||||
goto bad;
|
||||
}
|
||||
sc->pnum = 0;
|
||||
pcm_addchan(dev, PCMDIR_PLAY, &emupchan_class, sc);
|
||||
if (route == RT_FRONT) {
|
||||
for (i = 1; i < MAX_CHANNELS; i++)
|
||||
pcm_addchan(dev, PCMDIR_PLAY, &emupchan_class, sc);
|
||||
pcm_addchan(dev, PCMDIR_REC, &emurchan_class, sc);
|
||||
}
|
||||
snprintf(status, SND_STATUSLEN, "on %s", device_get_nameunit(device_get_parent(dev)));
|
||||
pcm_setstatus(dev, status);
|
||||
|
||||
return (0);
|
||||
|
||||
bad:
|
||||
if (sc->codec)
|
||||
ac97_destroy(sc->codec);
|
||||
if (sc->lock)
|
||||
snd_mtxfree(sc->lock);
|
||||
free(sc, M_DEVBUF);
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
static int
|
||||
emu_pcm_detach(device_t dev)
|
||||
{
|
||||
int r;
|
||||
struct emu_pcm_info *sc;
|
||||
|
||||
sc = pcm_getdevinfo(dev);
|
||||
|
||||
r = pcm_unregister(dev);
|
||||
|
||||
if (r) return (r);
|
||||
|
||||
emu_pcm_uninit(sc);
|
||||
|
||||
if (sc->lock)
|
||||
snd_mtxfree(sc->lock);
|
||||
free(sc, M_DEVBUF);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static device_method_t emu_pcm_methods[] = {
|
||||
DEVMETHOD(device_probe, emu_pcm_probe),
|
||||
DEVMETHOD(device_attach, emu_pcm_attach),
|
||||
DEVMETHOD(device_detach, emu_pcm_detach),
|
||||
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
static driver_t emu_pcm_driver = {
|
||||
"pcm",
|
||||
emu_pcm_methods,
|
||||
PCM_SOFTC_SIZE,
|
||||
NULL,
|
||||
0,
|
||||
NULL
|
||||
};
|
||||
DRIVER_MODULE(snd_emu10kx_pcm, emu10kx, emu_pcm_driver, pcm_devclass, 0, 0);
|
||||
MODULE_DEPEND(snd_emu10kx_pcm, snd_emu10kx, SND_EMU10KX_MINVER, SND_EMU10KX_PREFVER, SND_EMU10KX_MAXVER);
|
||||
MODULE_DEPEND(snd_emu10kx_pcm, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER);
|
||||
MODULE_VERSION(snd_emu10kx_pcm, SND_EMU10KX_PREFVER);
|
3022
sys/dev/sound/pci/emu10kx.c
Normal file
3022
sys/dev/sound/pci/emu10kx.c
Normal file
File diff suppressed because it is too large
Load Diff
180
sys/dev/sound/pci/emu10kx.h
Normal file
180
sys/dev/sound/pci/emu10kx.h
Normal file
@ -0,0 +1,180 @@
|
||||
/*-
|
||||
* Copyright (c) 1999 Cameron Grant <gandalf@vilnya.demon.co.uk>
|
||||
* Copyright (c) 2003-2006 Yuriy Tsibizov <yuriy.tsibizov@gfk.ru>
|
||||
* 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, WHETHERIN 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef EMU10KX_H
|
||||
#define EMU10KX_H
|
||||
|
||||
#define SND_EMU10KX_MINVER 1
|
||||
#define SND_EMU10KX_PREFVER 1
|
||||
#define SND_EMU10KX_MAXVER 1
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
#define EMUPAGESIZE 4096
|
||||
#define NUM_G 64
|
||||
/* XXX */
|
||||
/* There is a problem playing sound files less then EMU_DEFAULT_BUFSZ in
|
||||
* size. But using large buffer decreases interrupt rate and allow better
|
||||
* sound quality on ATA systems... */
|
||||
#define EMU_DEFAULT_BUFSZ EMUPAGESIZE*4
|
||||
#define EMU_MAX_BUFSZ EMUPAGESIZE*8
|
||||
#define MAXPAGES (EMU_MAX_BUFSZ * NUM_G / EMUPAGESIZE)
|
||||
|
||||
|
||||
#define EMU_VAR_FUNC 0
|
||||
#define EMU_VAR_ROUTE 1
|
||||
#define EMU_VAR_ISEMU10K1 2
|
||||
|
||||
#define RT_FRONT 0
|
||||
#define RT_REAR 1
|
||||
#define RT_CENTER 2
|
||||
#define RT_SUB 3
|
||||
#define RT_SIDE 4
|
||||
|
||||
/* mixer controls */
|
||||
/* fx play */
|
||||
#define M_FX0_FRONT_L 0
|
||||
#define M_FX1_FRONT_R 1
|
||||
#define M_FX2_REAR_L 2
|
||||
#define M_FX3_REAR_R 3
|
||||
#define M_FX4_CENTER 4
|
||||
#define M_FX5_SUBWOOFER 5
|
||||
#define M_FX6_SIDE_L 6
|
||||
#define M_FX7_SIDE_R 7
|
||||
/* fx rec */
|
||||
#define M_FX0_REC_L 8
|
||||
#define M_FX1_REC_R 9
|
||||
/* inputs play */
|
||||
#define M_IN0_FRONT_L 10
|
||||
#define M_IN0_FRONT_R 11
|
||||
#define M_IN1_FRONT_L 12
|
||||
#define M_IN1_FRONT_R 13
|
||||
#define M_IN2_FRONT_L 14
|
||||
#define M_IN2_FRONT_R 15
|
||||
#define M_IN3_FRONT_L 16
|
||||
#define M_IN3_FRONT_R 17
|
||||
#define M_IN4_FRONT_L 18
|
||||
#define M_IN4_FRONT_R 19
|
||||
#define M_IN5_FRONT_L 20
|
||||
#define M_IN5_FRONT_R 21
|
||||
#define M_IN6_FRONT_L 22
|
||||
#define M_IN6_FRONT_R 23
|
||||
#define M_IN7_FRONT_L 24
|
||||
#define M_IN7_FRONT_R 25
|
||||
/* inputs rec */
|
||||
#define M_IN0_REC_L 26
|
||||
#define M_IN0_REC_R 27
|
||||
#define M_IN1_REC_L 28
|
||||
#define M_IN1_REC_R 29
|
||||
#define M_IN2_REC_L 30
|
||||
#define M_IN2_REC_R 31
|
||||
#define M_IN3_REC_L 32
|
||||
#define M_IN3_REC_R 33
|
||||
#define M_IN4_REC_L 34
|
||||
#define M_IN4_REC_R 35
|
||||
#define M_IN5_REC_L 36
|
||||
#define M_IN5_REC_R 37
|
||||
#define M_IN6_REC_L 38
|
||||
#define M_IN6_REC_R 39
|
||||
#define M_IN7_REC_L 40
|
||||
#define M_IN7_REC_R 41
|
||||
/* master volume */
|
||||
#define M_MASTER_FRONT_L 42
|
||||
#define M_MASTER_FRONT_R 43
|
||||
#define M_MASTER_REAR_L 44
|
||||
#define M_MASTER_REAR_R 45
|
||||
#define M_MASTER_CENTER 46
|
||||
#define M_MASTER_SUBWOOFER 47
|
||||
#define M_MASTER_SIDE_L 48
|
||||
#define M_MASTER_SIDE_R 49
|
||||
/* master rec volume */
|
||||
#define M_MASTER_REC_L 50
|
||||
#define M_MASTER_REC_R 51
|
||||
|
||||
#define NUM_MIXERS 52
|
||||
|
||||
struct emu_sc_info;
|
||||
|
||||
/* MIDI device parameters */
|
||||
struct emu_midiinfo {
|
||||
struct emu_sc_info *card;
|
||||
int port;
|
||||
int portnr;
|
||||
};
|
||||
|
||||
/* PCM device parameters */
|
||||
struct emu_pcminfo {
|
||||
struct emu_sc_info *card;
|
||||
int route;
|
||||
};
|
||||
|
||||
int emu_intr_register(struct emu_sc_info *sc, uint32_t inte_mask, uint32_t intr_mask, uint32_t(*func) (void *softc, uint32_t irq), void *isc);
|
||||
int emu_intr_unregister(struct emu_sc_info *sc, int ihandle);
|
||||
|
||||
uint32_t emu_rd(struct emu_sc_info *sc, unsigned int regno, unsigned int size);
|
||||
void emu_wr(struct emu_sc_info *sc, unsigned int regno, uint32_t data, unsigned int size);
|
||||
|
||||
uint32_t emu_rdptr(struct emu_sc_info *sc, unsigned int chn, unsigned int reg);
|
||||
void emu_wrptr(struct emu_sc_info *sc, unsigned int chn, unsigned int reg, uint32_t data);
|
||||
|
||||
uint32_t emu_rd_p16vptr(struct emu_sc_info *sc, uint16_t chn, uint16_t reg);
|
||||
void emu_wr_p16vptr(struct emu_sc_info *sc, uint16_t chn, uint16_t reg, uint32_t data);
|
||||
|
||||
int emu_timer_create(struct emu_sc_info *sc);
|
||||
int emu_timer_set(struct emu_sc_info *sc, int timer, int delay);
|
||||
int emu_timer_enable(struct emu_sc_info *sc, int timer, int go);
|
||||
int emu_timer_clear(struct emu_sc_info *sc, int timer);
|
||||
|
||||
struct emu_voice;
|
||||
|
||||
struct emu_route {
|
||||
int routing_left[8];
|
||||
int amounts_left[8];
|
||||
int routing_right[8];
|
||||
int amounts_right[8];
|
||||
};
|
||||
|
||||
struct emu_voice* emu_valloc(struct emu_sc_info *sc);
|
||||
void emu_vfree(struct emu_sc_info *sc, struct emu_voice *v);
|
||||
int emu_vinit(struct emu_sc_info *sc, struct emu_voice *m, struct emu_voice *s,
|
||||
uint32_t sz, struct snd_dbuf *b);
|
||||
void emu_vroute(struct emu_sc_info *sc, struct emu_route *rt, struct emu_voice *v);
|
||||
void emu_vsetup(struct emu_voice *v, int fmt, int spd);
|
||||
void emu_vwrite(struct emu_sc_info *sc, struct emu_voice *v);
|
||||
void emu_vtrigger(struct emu_sc_info *sc, struct emu_voice *v, int go);
|
||||
int emu_vpos(struct emu_sc_info *sc, struct emu_voice *v);
|
||||
|
||||
bus_dma_tag_t emu_gettag(struct emu_sc_info *sc);
|
||||
|
||||
void emumix_set_volume(struct emu_sc_info *sc, int mixer_idx, int volume);
|
||||
int emumix_get_volume(struct emu_sc_info *sc, int mixer_idx);
|
||||
|
||||
void emu_enable_ir(struct emu_sc_info *sc);
|
||||
#endif /* _KERNEL */
|
||||
#endif /* EMU10K1_H */
|
301
sys/gnu/dev/sound/pci/p16v-alsa.h
Normal file
301
sys/gnu/dev/sound/pci/p16v-alsa.h
Normal file
@ -0,0 +1,301 @@
|
||||
/*-
|
||||
* Copyright (c) by James Courtier-Dutton <James@superbug.demon.co.uk>
|
||||
* Driver p16v chips
|
||||
* Version: 0.21
|
||||
*
|
||||
* FEATURES currently supported:
|
||||
* Output fixed at S32_LE, 2 channel to hw:0,0
|
||||
* Rates: 44.1, 48, 96, 192.
|
||||
*
|
||||
* Changelog:
|
||||
* 0.8
|
||||
* Use separate card based buffer for periods table.
|
||||
* 0.9
|
||||
* Use 2 channel output streams instead of 8 channel.
|
||||
* (8 channel output streams might be good for ASIO type output)
|
||||
* Corrected speaker output, so Front -> Front etc.
|
||||
* 0.10
|
||||
* Fixed missed interrupts.
|
||||
* 0.11
|
||||
* Add Sound card model number and names.
|
||||
* Add Analog volume controls.
|
||||
* 0.12
|
||||
* Corrected playback interrupts. Now interrupt per period, instead of half period.
|
||||
* 0.13
|
||||
* Use single trigger for multichannel.
|
||||
* 0.14
|
||||
* Mic capture now works at fixed: S32_LE, 96000Hz, Stereo.
|
||||
* 0.15
|
||||
* Force buffer_size / period_size == INTEGER.
|
||||
* 0.16
|
||||
* Update p16v.c to work with changed alsa api.
|
||||
* 0.17
|
||||
* Update p16v.c to work with changed alsa api. Removed boot_devs.
|
||||
* 0.18
|
||||
* Merging with snd-emu10k1 driver.
|
||||
* 0.19
|
||||
* One stereo channel at 24bit now works.
|
||||
* 0.20
|
||||
* Added better register defines.
|
||||
* 0.21
|
||||
* Split from p16v.c
|
||||
*
|
||||
*
|
||||
* BUGS:
|
||||
* Some stability problems when unloading the snd-p16v kernel module.
|
||||
* --
|
||||
*
|
||||
* TODO:
|
||||
* SPDIF out.
|
||||
* Find out how to change capture sample rates. E.g. To record SPDIF at 48000Hz.
|
||||
* Currently capture fixed at 48000Hz.
|
||||
*
|
||||
* --
|
||||
* GENERAL INFO:
|
||||
* Model: SB0240
|
||||
* P16V Chip: CA0151-DBS
|
||||
* Audigy 2 Chip: CA0102-IAT
|
||||
* AC97 Codec: STAC 9721
|
||||
* ADC: Philips 1361T (Stereo 24bit)
|
||||
* DAC: CS4382-K (8-channel, 24bit, 192Khz)
|
||||
*
|
||||
* This code was initally based on code from ALSA's emu10k1x.c which is:
|
||||
* Copyright (c) by Francisco Moraes <fmoraes@nc.rr.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
/* $FreeBSD$ */
|
||||
|
||||
/********************************************************************************************************/
|
||||
/* Audigy2 P16V pointer-offset register set, accessed through the PTR2 and DATA2 registers */
|
||||
/********************************************************************************************************/
|
||||
|
||||
/* The sample rate of the SPDIF outputs is set by modifying a register in the EMU10K2 PTR register A_SPDIF_SAMPLERATE.
|
||||
* The sample rate is also controlled by the same registers that control the rate of the EMU10K2 sample rate converters.
|
||||
*/
|
||||
|
||||
/* Initally all registers from 0x00 to 0x3f have zero contents. */
|
||||
#define PLAYBACK_LIST_ADDR 0x00 /* Base DMA address of a list of pointers to each period/size */
|
||||
/* One list entry: 4 bytes for DMA address,
|
||||
* 4 bytes for period_size << 16.
|
||||
* One list entry is 8 bytes long.
|
||||
* One list entry for each period in the buffer.
|
||||
*/
|
||||
#define PLAYBACK_LIST_SIZE 0x01 /* Size of list in bytes << 16. E.g. 8 periods -> 0x00380000 */
|
||||
#define PLAYBACK_LIST_PTR 0x02 /* Pointer to the current period being played */
|
||||
#define PLAYBACK_UNKNOWN3 0x03 /* Not used */
|
||||
#define PLAYBACK_DMA_ADDR 0x04 /* Playback DMA addresss */
|
||||
#define PLAYBACK_PERIOD_SIZE 0x05 /* Playback period size. win2000 uses 0x04000000 */
|
||||
#define PLAYBACK_POINTER 0x06 /* Playback period pointer. Used with PLAYBACK_LIST_PTR to determine buffer position currently in DAC */
|
||||
#define PLAYBACK_FIFO_END_ADDRESS 0x07 /* Playback FIFO end address */
|
||||
#define PLAYBACK_FIFO_POINTER 0x08 /* Playback FIFO pointer and number of valid sound samples in cache */
|
||||
#define PLAYBACK_UNKNOWN9 0x09 /* Not used */
|
||||
#define CAPTURE_DMA_ADDR 0x10 /* Capture DMA address */
|
||||
#define CAPTURE_BUFFER_SIZE 0x11 /* Capture buffer size */
|
||||
#define CAPTURE_POINTER 0x12 /* Capture buffer pointer. Sample currently in ADC */
|
||||
#define CAPTURE_FIFO_POINTER 0x13 /* Capture FIFO pointer and number of valid sound samples in cache */
|
||||
#define CAPTURE_P16V_VOLUME1 0x14 /* Low: Capture volume 0xXXXX3030 */
|
||||
#define CAPTURE_P16V_VOLUME2 0x15 /* High:Has no effect on capture volume */
|
||||
#define CAPTURE_P16V_SOURCE 0x16 /* P16V source select. Set to 0x0700E4E5 for AC97 CAPTURE */
|
||||
/* [0:1] Capture input 0 channel select. 0 = Capture output 0.
|
||||
* 1 = Capture output 1.
|
||||
* 2 = Capture output 2.
|
||||
* 3 = Capture output 3.
|
||||
* [3:2] Capture input 1 channel select. 0 = Capture output 0.
|
||||
* 1 = Capture output 1.
|
||||
* 2 = Capture output 2.
|
||||
* 3 = Capture output 3.
|
||||
* [5:4] Capture input 2 channel select. 0 = Capture output 0.
|
||||
* 1 = Capture output 1.
|
||||
* 2 = Capture output 2.
|
||||
* 3 = Capture output 3.
|
||||
* [7:6] Capture input 3 channel select. 0 = Capture output 0.
|
||||
* 1 = Capture output 1.
|
||||
* 2 = Capture output 2.
|
||||
* 3 = Capture output 3.
|
||||
* [9:8] Playback input 0 channel select. 0 = Play output 0.
|
||||
* 1 = Play output 1.
|
||||
* 2 = Play output 2.
|
||||
* 3 = Play output 3.
|
||||
* [11:10] Playback input 1 channel select. 0 = Play output 0.
|
||||
* 1 = Play output 1.
|
||||
* 2 = Play output 2.
|
||||
* 3 = Play output 3.
|
||||
* [13:12] Playback input 2 channel select. 0 = Play output 0.
|
||||
* 1 = Play output 1.
|
||||
* 2 = Play output 2.
|
||||
* 3 = Play output 3.
|
||||
* [15:14] Playback input 3 channel select. 0 = Play output 0.
|
||||
* 1 = Play output 1.
|
||||
* 2 = Play output 2.
|
||||
* 3 = Play output 3.
|
||||
* [19:16] Playback mixer output enable. 1 bit per channel.
|
||||
* [23:20] Capture mixer output enable. 1 bit per channel.
|
||||
* [26:24] FX engine channel capture 0 = 0x60-0x67.
|
||||
* 1 = 0x68-0x6f.
|
||||
* 2 = 0x70-0x77.
|
||||
* 3 = 0x78-0x7f.
|
||||
* 4 = 0x80-0x87.
|
||||
* 5 = 0x88-0x8f.
|
||||
* 6 = 0x90-0x97.
|
||||
* 7 = 0x98-0x9f.
|
||||
* [31:27] Not used.
|
||||
*/
|
||||
|
||||
/* 0x1 = capture on.
|
||||
* 0x100 = capture off.
|
||||
* 0x200 = capture off.
|
||||
* 0x1000 = capture off.
|
||||
*/
|
||||
#define CAPTURE_RATE_STATUS 0x17 /* Capture sample rate. Read only */
|
||||
/* [15:0] Not used.
|
||||
* [18:16] Channel 0 Detected sample rate. 0 - 44.1khz
|
||||
* 1 - 48 khz
|
||||
* 2 - 96 khz
|
||||
* 3 - 192 khz
|
||||
* 7 - undefined rate.
|
||||
* [19] Channel 0. 1 - Valid, 0 - Not Valid.
|
||||
* [22:20] Channel 1 Detected sample rate.
|
||||
* [23] Channel 1. 1 - Valid, 0 - Not Valid.
|
||||
* [26:24] Channel 2 Detected sample rate.
|
||||
* [27] Channel 2. 1 - Valid, 0 - Not Valid.
|
||||
* [30:28] Channel 3 Detected sample rate.
|
||||
* [31] Channel 3. 1 - Valid, 0 - Not Valid.
|
||||
*/
|
||||
/* 0x18 - 0x1f unused */
|
||||
#define PLAYBACK_LAST_SAMPLE 0x20 /* The sample currently being played. Read only */
|
||||
/* 0x21 - 0x3f unused */
|
||||
#define BASIC_INTERRUPT 0x40 /* Used by both playback and capture interrupt handler */
|
||||
/* Playback (0x1<<channel_id) Don't touch high 16bits. */
|
||||
/* Capture (0x100<<channel_id). not tested */
|
||||
/* Start Playback [3:0] (one bit per channel)
|
||||
* Start Capture [11:8] (one bit per channel)
|
||||
* Record source select for channel 0 [18:16]
|
||||
* Record source select for channel 1 [22:20]
|
||||
* Record source select for channel 2 [26:24]
|
||||
* Record source select for channel 3 [30:28]
|
||||
* 0 - SPDIF channel.
|
||||
* 1 - I2S channel.
|
||||
* 2 - SRC48 channel.
|
||||
* 3 - SRCMulti_SPDIF channel.
|
||||
* 4 - SRCMulti_I2S channel.
|
||||
* 5 - SPDIF channel.
|
||||
* 6 - fxengine capture.
|
||||
* 7 - AC97 capture.
|
||||
*/
|
||||
/* Default 41110000.
|
||||
* Writing 0xffffffff hangs the PC.
|
||||
* Writing 0xffff0000 -> 77770000 so it must be some sort of route.
|
||||
* bit 0x1 starts DMA playback on channel_id 0
|
||||
*/
|
||||
/* 0x41,42 take values from 0 - 0xffffffff, but have no effect on playback */
|
||||
/* 0x43,0x48 do not remember settings */
|
||||
/* 0x41-45 unused */
|
||||
#define WATERMARK 0x46 /* Test bit to indicate cache level usage */
|
||||
/* Values it can have while playing on channel 0.
|
||||
* 0000f000, 0000f004, 0000f008, 0000f00c.
|
||||
* Readonly.
|
||||
*/
|
||||
/* 0x47-0x4f unused */
|
||||
/* 0x50-0x5f Capture cache data */
|
||||
#define SRCSel 0x60 /* SRCSel. Default 0x4. Bypass P16V 0x14 */
|
||||
/* [0] 0 = 10K2 audio, 1 = SRC48 mixer output.
|
||||
* [2] 0 = 10K2 audio, 1 = SRCMulti SPDIF mixer output.
|
||||
* [4] 0 = 10K2 audio, 1 = SRCMulti I2S mixer output.
|
||||
*/
|
||||
/* SRC48 converts samples rates 44.1, 48, 96, 192 to 48 khz. */
|
||||
/* SRCMulti converts 48khz samples rates to 44.1, 48, 96, 192 to 48. */
|
||||
/* SRC48 and SRCMULTI sample rate select and output select. */
|
||||
/* 0xffffffff -> 0xC0000015
|
||||
* 0xXXXXXXX4 = Enable Front Left/Right
|
||||
* Enable PCMs
|
||||
*/
|
||||
|
||||
/* 0x61 -> 0x6c are Volume controls */
|
||||
#define PLAYBACK_VOLUME_MIXER1 0x61 /* SRC48 Low to mixer input volume control. */
|
||||
#define PLAYBACK_VOLUME_MIXER2 0x62 /* SRC48 High to mixer input volume control. */
|
||||
#define PLAYBACK_VOLUME_MIXER3 0x63 /* SRCMULTI SPDIF Low to mixer input volume control. */
|
||||
#define PLAYBACK_VOLUME_MIXER4 0x64 /* SRCMULTI SPDIF High to mixer input volume control. */
|
||||
#define PLAYBACK_VOLUME_MIXER5 0x65 /* SRCMULTI I2S Low to mixer input volume control. */
|
||||
#define PLAYBACK_VOLUME_MIXER6 0x66 /* SRCMULTI I2S High to mixer input volume control. */
|
||||
#define PLAYBACK_VOLUME_MIXER7 0x67 /* P16V Low to SRCMULTI SPDIF mixer input volume control. */
|
||||
#define PLAYBACK_VOLUME_MIXER8 0x68 /* P16V High to SRCMULTI SPDIF mixer input volume control. */
|
||||
#define PLAYBACK_VOLUME_MIXER9 0x69 /* P16V Low to SRCMULTI I2S mixer input volume control. */
|
||||
/* 0xXXXX3030 = PCM0 Volume (Front).
|
||||
* 0x3030XXXX = PCM1 Volume (Center)
|
||||
*/
|
||||
#define PLAYBACK_VOLUME_MIXER10 0x6a /* P16V High to SRCMULTI I2S mixer input volume control. */
|
||||
/* 0x3030XXXX = PCM3 Volume (Rear). */
|
||||
#define PLAYBACK_VOLUME_MIXER11 0x6b /* E10K2 Low to SRC48 mixer input volume control. */
|
||||
#define PLAYBACK_VOLUME_MIXER12 0x6c /* E10K2 High to SRC48 mixer input volume control. */
|
||||
|
||||
#define SRC48_ENABLE 0x6d /* SRC48 input audio enable */
|
||||
/* SRC48 converts samples rates 44.1, 48, 96, 192 to 48 khz. */
|
||||
/* [23:16] The corresponding P16V channel to SRC48 enabled if == 1.
|
||||
* [31:24] The corresponding E10K2 channel to SRC48 enabled.
|
||||
*/
|
||||
#define SRCMULTI_ENABLE 0x6e /* SRCMulti input audio enable. Default 0xffffffff */
|
||||
/* SRCMulti converts 48khz samples rates to 44.1, 48, 96, 192 to 48. */
|
||||
/* [7:0] The corresponding P16V channel to SRCMulti_I2S enabled if == 1.
|
||||
* [15:8] The corresponding E10K2 channel to SRCMulti I2S enabled.
|
||||
* [23:16] The corresponding P16V channel to SRCMulti SPDIF enabled.
|
||||
* [31:24] The corresponding E10K2 channel to SRCMulti SPDIF enabled.
|
||||
*/
|
||||
/* Bypass P16V 0xff00ff00
|
||||
* Bitmap. 0 = Off, 1 = On.
|
||||
* P16V playback outputs:
|
||||
* 0xXXXXXXX1 = PCM0 Left. (Front)
|
||||
* 0xXXXXXXX2 = PCM0 Right.
|
||||
* 0xXXXXXXX4 = PCM1 Left. (Center/LFE)
|
||||
* 0xXXXXXXX8 = PCM1 Right.
|
||||
* 0xXXXXXX1X = PCM2 Left. (Unknown)
|
||||
* 0xXXXXXX2X = PCM2 Right.
|
||||
* 0xXXXXXX4X = PCM3 Left. (Rear)
|
||||
* 0xXXXXXX8X = PCM3 Right.
|
||||
*/
|
||||
#define AUDIO_OUT_ENABLE 0x6f /* Default: 000100FF */
|
||||
/* [3:0] Does something, but not documented. Probably capture enable.
|
||||
* [7:4] Playback channels enable. not documented.
|
||||
* [16] AC97 output enable if == 1
|
||||
* [30] 0 = SRCMulti_I2S input from fxengine 0x68-0x6f.
|
||||
* 1 = SRCMulti_I2S input from SRC48 output.
|
||||
* [31] 0 = SRCMulti_SPDIF input from fxengine 0x60-0x67.
|
||||
* 1 = SRCMulti_SPDIF input from SRC48 output.
|
||||
*/
|
||||
/* 0xffffffff -> C00100FF */
|
||||
/* 0 -> Not playback sound, irq still running */
|
||||
/* 0xXXXXXX10 = PCM0 Left/Right On. (Front)
|
||||
* 0xXXXXXX20 = PCM1 Left/Right On. (Center/LFE)
|
||||
* 0xXXXXXX40 = PCM2 Left/Right On. (Unknown)
|
||||
* 0xXXXXXX80 = PCM3 Left/Right On. (Rear)
|
||||
*/
|
||||
#define PLAYBACK_SPDIF_SELECT 0x70 /* Default: 12030F00 */
|
||||
/* 0xffffffff -> 3FF30FFF */
|
||||
/* 0x00000001 pauses stream/irq fail. */
|
||||
/* All other bits do not effect playback */
|
||||
#define PLAYBACK_SPDIF_SRC_SELECT 0x71 /* Default: 0000E4E4 */
|
||||
/* 0xffffffff -> F33FFFFF */
|
||||
/* All bits do not effect playback */
|
||||
#define PLAYBACK_SPDIF_USER_DATA0 0x72 /* SPDIF out user data 0 */
|
||||
#define PLAYBACK_SPDIF_USER_DATA1 0x73 /* SPDIF out user data 1 */
|
||||
/* 0x74-0x75 unknown */
|
||||
#define CAPTURE_SPDIF_CONTROL 0x76 /* SPDIF in control setting */
|
||||
#define CAPTURE_SPDIF_STATUS 0x77 /* SPDIF in status */
|
||||
#define CAPURE_SPDIF_USER_DATA0 0x78 /* SPDIF in user data 0 */
|
||||
#define CAPURE_SPDIF_USER_DATA1 0x79 /* SPDIF in user data 1 */
|
||||
#define CAPURE_SPDIF_USER_DATA2 0x7a /* SPDIF in user data 2 */
|
||||
|
113
sys/gnu/dev/sound/pci/p17v-alsa.h
Normal file
113
sys/gnu/dev/sound/pci/p17v-alsa.h
Normal file
@ -0,0 +1,113 @@
|
||||
/*-
|
||||
* Copyright (c) by James Courtier-Dutton <James@superbug.demon.co.uk>
|
||||
* Driver p17v chips
|
||||
* Version: 0.01
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
/* $FreeBSD$ */
|
||||
|
||||
/******************************************************************************/
|
||||
/* Audigy2Value Tina (P17V) pointer-offset register set,
|
||||
* accessed through the PTR20 and DATA24 registers */
|
||||
/******************************************************************************/
|
||||
|
||||
/* 00 - 07: Not used */
|
||||
#define P17V_PLAYBACK_FIFO_PTR 0x08 /* Current playback fifo pointer
|
||||
* and number of sound samples in cache.
|
||||
*/
|
||||
/* 09 - 12: Not used */
|
||||
#define P17V_CAPTURE_FIFO_PTR 0x13 /* Current capture fifo pointer
|
||||
* and number of sound samples in cache.
|
||||
*/
|
||||
/* 14 - 17: Not used */
|
||||
#define P17V_PB_CHN_SEL 0x18 /* P17v playback channel select */
|
||||
#define P17V_SE_SLOT_SEL_L 0x19 /* Sound Engine slot select low */
|
||||
#define P17V_SE_SLOT_SEL_H 0x1a /* Sound Engine slot select high */
|
||||
/* 1b - 1f: Not used */
|
||||
/* 20 - 2f: Not used */
|
||||
/* 30 - 3b: Not used */
|
||||
#define P17V_SPI 0x3c /* SPI interface register */
|
||||
#define P17V_I2C_ADDR 0x3d /* I2C Address */
|
||||
#define P17V_I2C_0 0x3e /* I2C Data */
|
||||
#define P17V_I2C_1 0x3f /* I2C Data */
|
||||
|
||||
#define P17V_START_AUDIO 0x40 /* Start Audio bit */
|
||||
/* 41 - 47: Reserved */
|
||||
#define P17V_START_CAPTURE 0x48 /* Start Capture bit */
|
||||
#define P17V_CAPTURE_FIFO_BASE 0x49 /* Record FIFO base address */
|
||||
#define P17V_CAPTURE_FIFO_SIZE 0x4a /* Record FIFO buffer size */
|
||||
#define P17V_CAPTURE_FIFO_INDEX 0x4b /* Record FIFO capture index */
|
||||
#define P17V_CAPTURE_VOL_H 0x4c /* P17v capture volume control */
|
||||
#define P17V_CAPTURE_VOL_L 0x4d /* P17v capture volume control */
|
||||
/* 4e - 4f: Not used */
|
||||
/* 50 - 5f: Not used */
|
||||
#define P17V_SRCSel 0x60 /* SRC48 and SRCMulti sample rate select
|
||||
* and output select
|
||||
*/
|
||||
#define P17V_MIXER_AC97_10K1_VOL_L 0x61 /* 10K to Mixer_AC97 input volume control */
|
||||
#define P17V_MIXER_AC97_10K1_VOL_H 0x62 /* 10K to Mixer_AC97 input volume control */
|
||||
#define P17V_MIXER_AC97_P17V_VOL_L 0x63 /* P17V to Mixer_AC97 input volume control */
|
||||
#define P17V_MIXER_AC97_P17V_VOL_H 0x64 /* P17V to Mixer_AC97 input volume control */
|
||||
#define P17V_MIXER_AC97_SRP_REC_VOL_L 0x65 /* SRP Record to Mixer_AC97 input volume control */
|
||||
#define P17V_MIXER_AC97_SRP_REC_VOL_H 0x66 /* SRP Record to Mixer_AC97 input volume control */
|
||||
/* 67 - 68: Reserved */
|
||||
#define P17V_MIXER_Spdif_10K1_VOL_L 0x69 /* 10K to Mixer_Spdif input volume control */
|
||||
#define P17V_MIXER_Spdif_10K1_VOL_H 0x6A /* 10K to Mixer_Spdif input volume control */
|
||||
#define P17V_MIXER_Spdif_P17V_VOL_L 0x6B /* P17V to Mixer_Spdif input volume control */
|
||||
#define P17V_MIXER_Spdif_P17V_VOL_H 0x6C /* P17V to Mixer_Spdif input volume control */
|
||||
#define P17V_MIXER_Spdif_SRP_REC_VOL_L 0x6D /* SRP Record to Mixer_Spdif input volume control */
|
||||
#define P17V_MIXER_Spdif_SRP_REC_VOL_H 0x6E /* SRP Record to Mixer_Spdif input volume control */
|
||||
/* 6f - 70: Reserved */
|
||||
#define P17V_MIXER_I2S_10K1_VOL_L 0x71 /* 10K to Mixer_I2S input volume control */
|
||||
#define P17V_MIXER_I2S_10K1_VOL_H 0x72 /* 10K to Mixer_I2S input volume control */
|
||||
#define P17V_MIXER_I2S_P17V_VOL_L 0x73 /* P17V to Mixer_I2S input volume control */
|
||||
#define P17V_MIXER_I2S_P17V_VOL_H 0x74 /* P17V to Mixer_I2S input volume control */
|
||||
#define P17V_MIXER_I2S_SRP_REC_VOL_L 0x75 /* SRP Record to Mixer_I2S input volume control */
|
||||
#define P17V_MIXER_I2S_SRP_REC_VOL_H 0x76 /* SRP Record to Mixer_I2S input volume control */
|
||||
/* 77 - 78: Reserved */
|
||||
#define P17V_MIXER_AC97_ENABLE 0x79 /* Mixer AC97 input audio enable */
|
||||
#define P17V_MIXER_SPDIF_ENABLE 0x7A /* Mixer SPDIF input audio enable */
|
||||
#define P17V_MIXER_I2S_ENABLE 0x7B /* Mixer I2S input audio enable */
|
||||
#define P17V_AUDIO_OUT_ENABLE 0x7C /* Audio out enable */
|
||||
#define P17V_MIXER_ATT 0x7D /* SRP Mixer Attenuation Select */
|
||||
#define P17V_SRP_RECORD_SRR 0x7E /* SRP Record channel source Select */
|
||||
#define P17V_SOFT_RESET_SRP_MIXER 0x7F /* SRP and mixer soft reset */
|
||||
|
||||
#define P17V_AC97_OUT_MASTER_VOL_L 0x80 /* AC97 Output master volume control */
|
||||
#define P17V_AC97_OUT_MASTER_VOL_H 0x81 /* AC97 Output master volume control */
|
||||
#define P17V_SPDIF_OUT_MASTER_VOL_L 0x82 /* SPDIF Output master volume control */
|
||||
#define P17V_SPDIF_OUT_MASTER_VOL_H 0x83 /* SPDIF Output master volume control */
|
||||
#define P17V_I2S_OUT_MASTER_VOL_L 0x84 /* I2S Output master volume control */
|
||||
#define P17V_I2S_OUT_MASTER_VOL_H 0x85 /* I2S Output master volume control */
|
||||
/* 86 - 87: Not used */
|
||||
#define P17V_I2S_CHANNEL_SWAP_PHASE_INVERSE 0x88 /* I2S out mono channel swap
|
||||
* and phase inverse */
|
||||
#define P17V_SPDIF_CHANNEL_SWAP_PHASE_INVERSE 0x89 /* SPDIF out mono channel swap
|
||||
* and phase inverse */
|
||||
/* 8A: Not used */
|
||||
#define P17V_SRP_P17V_ESR 0x8B /* SRP_P17V estimated sample rate and rate lock */
|
||||
#define P17V_SRP_REC_ESR 0x8C /* SRP_REC estimated sample rate and rate lock */
|
||||
#define P17V_SRP_BYPASS 0x8D /* srps channel bypass and srps bypass */
|
||||
/* 8E - 92: Not used */
|
||||
#define P17V_I2S_SRC_SEL 0x93 /* I2SIN mode sel */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
48
sys/modules/sound/driver/emu10kx/Makefile
Normal file
48
sys/modules/sound/driver/emu10kx/Makefile
Normal file
@ -0,0 +1,48 @@
|
||||
# $FreeBSD$
|
||||
.PATH: ${.CURDIR}/../../../../dev/sound/pci \
|
||||
${.CURDIR}/../../../../gnu/dev/sound/pci
|
||||
|
||||
WARNS?= 2 ## because sound is WARNS=2 only
|
||||
## WARNS=3 fails on _class.refs in -pcm.c
|
||||
## WARNS=4 fails on min/max in sound headers
|
||||
## otherwise it should be WARNS=6 clean
|
||||
KMOD= snd_emu10kx
|
||||
|
||||
SRCS= device_if.h bus_if.h pci_if.h
|
||||
SRCS+= isa_if.h channel_if.h ac97_if.h mixer_if.h mpufoi_if.h
|
||||
SRCS+= vnode_if.h opt_emu10kx.h
|
||||
# Master, PCM and MIDI devices
|
||||
SRCS+= emu10kx.c
|
||||
SRCS+= emu10kx-pcm.c
|
||||
SRCS+= emu10kx-midi.c
|
||||
# de-GPLed Makefiles
|
||||
SRCS+= emu10k1-alsa%diked.h
|
||||
SRCS+= p16v-alsa%diked.h
|
||||
SRCS+= p17v-alsa%diked.h
|
||||
|
||||
emu10k1-alsa%diked.h: emu10k1-alsa.h
|
||||
grep -v '#include' ${.OODATE} | $(CC) -E -D__KERNEL__ -dM - \
|
||||
| awk -F"[ (]" '/define/ \
|
||||
{ print "#ifndef " $$2 ; print ; print "#endif" }' \
|
||||
>${.TARGET}
|
||||
p16v-alsa%diked.h: p16v-alsa.h
|
||||
grep -v '#include' ${.OODATE} | $(CC) -E -D__KERNEL__ -dM - \
|
||||
| awk -F"[ (]" '/define/ \
|
||||
{ print "#ifndef " $$2 ; print ; print "#endif" }' \
|
||||
>${.TARGET}
|
||||
p17v-alsa%diked.h: p17v-alsa.h
|
||||
grep -v '#include' ${.OODATE} | $(CC) -E -D__KERNEL__ -dM - \
|
||||
| awk -F"[ (]" '/define/ \
|
||||
{ print "#ifndef " $$2 ; print ; print "#endif" }' \
|
||||
>${.TARGET}
|
||||
|
||||
CLEANFILES+= emu10k1-alsa%diked.h
|
||||
CLEANFILES+= p16v-alsa%diked.h
|
||||
CLEANFILES+= p17v-alsa%diked.h
|
||||
|
||||
.if !defined(KERNBUILDDIR)
|
||||
opt_emu10kx.h:
|
||||
echo "#define SND_EMU10KX_MULTICHANNEL" > opt_emu10kx.h
|
||||
.endif
|
||||
|
||||
.include <bsd.kmod.mk>
|
Loading…
Reference in New Issue
Block a user