mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2025-01-01 00:18:15 +01:00
* Ignore the wierd fakechan workarounds for simplex in dsp_ioctl().
Without this, ioctl commands for setting formats and speeds were essentially ignored for simplex devices until the application actually performed a read or write. * Make sure that both channels are set in the SB mixer code and provide a mixer table specifically for the ess18xx which supports the extended accuracy available on this part. * Fix a stupid bug in ess_format() which ignored the passed-in format and changed the hardware based on the value which was set last time. This meant that the hardware setting was often not set correctly at all. * Add a custom identify driver for the ESS1888 which automagically detects and adds the device in a pseudo-PnP way. This driver also emits the magic sequence which enables the sound hardware after a hard reset, allowing it to work correctly for the sound hardware of a PWS 433au (and probably all other PWS class alpha machines). With these changes, I was able to play back simple sounds on my 433au. I have not tested recording or any other formats other than 8bit ulaw and 16bit stereo.
This commit is contained in:
parent
e6ee5b3933
commit
62c631ed7f
@ -208,7 +208,8 @@ dsp_ioctl(snddev_info *d, int chan, u_long cmd, caddr_t arg)
|
|||||||
u_long s;
|
u_long s;
|
||||||
pcm_channel *wrch = NULL, *rdch = NULL;
|
pcm_channel *wrch = NULL, *rdch = NULL;
|
||||||
|
|
||||||
getchns(d, chan, &rdch, &wrch);
|
rdch = d->arec[chan];
|
||||||
|
wrch = d->aplay[chan];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* all routines are called with int. blocked. Make sure that
|
* all routines are called with int. blocked. Make sure that
|
||||||
|
171
sys/dev/pcm/isa/es1888.c
Normal file
171
sys/dev/pcm/isa/es1888.c
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
/*-
|
||||||
|
* Copyright (c) 1999 Doug Rabson
|
||||||
|
* 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 <dev/pcm/sound.h>
|
||||||
|
#include <dev/pcm/isa/sb.h>
|
||||||
|
|
||||||
|
#if NPCM > 0
|
||||||
|
|
||||||
|
static int
|
||||||
|
es1888_dspready(u_int32_t port)
|
||||||
|
{
|
||||||
|
return ((inb(port + SBDSP_STATUS) & 0x80) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
es1888_dspwr(u_int32_t port, u_char val)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < 1000; i++) {
|
||||||
|
if (es1888_dspready(port)) {
|
||||||
|
outb(port + SBDSP_CMD, val);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (i > 10) DELAY((i > 100)? 1000 : 10);
|
||||||
|
}
|
||||||
|
printf("es1888_dspwr(0x%02x) timed out.\n", val);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static u_int
|
||||||
|
es1888_get_byte(u_int32_t port)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 1000; i > 0; i--) {
|
||||||
|
if (inb(port + DSP_DATA_AVAIL) & 0x80)
|
||||||
|
return inb(port + DSP_READ);
|
||||||
|
else
|
||||||
|
DELAY(20);
|
||||||
|
}
|
||||||
|
return 0xffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
es1888_reset(u_int32_t port)
|
||||||
|
{
|
||||||
|
outb(port + SBDSP_RST, 3);
|
||||||
|
DELAY(100);
|
||||||
|
outb(port + SBDSP_RST, 0);
|
||||||
|
if (es1888_get_byte(port) != 0xAA) {
|
||||||
|
DEB(printf("sb_reset_dsp 0x%lx failed\n",
|
||||||
|
rman_get_start(d->io_base)));
|
||||||
|
return ENXIO; /* Sorry */
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
es1888_configuration_mode(void)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Emit the Read-Sequence-Key to enter configuration
|
||||||
|
* mode. Note this only works after a reset (or after bit 2 of
|
||||||
|
* mixer register 0x40 is set).
|
||||||
|
*
|
||||||
|
* 3 reads from 0x229 in a row guarantees reset of key
|
||||||
|
* sequence to beginning.
|
||||||
|
*/
|
||||||
|
inb(0x229);
|
||||||
|
inb(0x229);
|
||||||
|
inb(0x229);
|
||||||
|
|
||||||
|
inb(0x22b); /* state 1 */
|
||||||
|
inb(0x229); /* state 2 */
|
||||||
|
inb(0x22b); /* state 3 */
|
||||||
|
inb(0x229); /* state 4 */
|
||||||
|
inb(0x229); /* state 5 */
|
||||||
|
inb(0x22b); /* state 6 */
|
||||||
|
inb(0x229); /* state 7 */
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
es1888_set_port(u_int32_t port)
|
||||||
|
{
|
||||||
|
es1888_configuration_mode();
|
||||||
|
inb(port);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
es1888_identify(driver_t *driver, device_t parent)
|
||||||
|
{
|
||||||
|
u_int32_t lo, hi;
|
||||||
|
device_t dev;
|
||||||
|
|
||||||
|
es1888_set_port(0x220);
|
||||||
|
es1888_reset(0x220);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check identification bytes for es1888.
|
||||||
|
*/
|
||||||
|
es1888_dspwr(0x220, 0xe7);
|
||||||
|
hi = es1888_get_byte(0x220);
|
||||||
|
lo = es1888_get_byte(0x220);
|
||||||
|
printf("es1888_identify: 0x%02x%02x\n", hi, lo);
|
||||||
|
if (hi != 0x68 || (lo & 0xf0) != 0x80)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Program irq and drq.
|
||||||
|
*/
|
||||||
|
es1888_dspwr(0x220, 0xc6); /* enter extended mode */
|
||||||
|
es1888_dspwr(0x220, 0xb1); /* write register b1 */
|
||||||
|
es1888_dspwr(0x220, 0x14); /* enable irq 5 */
|
||||||
|
es1888_dspwr(0x220, 0xb2); /* write register b1 */
|
||||||
|
es1888_dspwr(0x220, 0x18); /* enable drq 1 */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create the device and program its resources.
|
||||||
|
*/
|
||||||
|
dev = BUS_ADD_CHILD(parent, ISA_ORDER_PNP, NULL, -1);
|
||||||
|
bus_set_resource(dev, SYS_RES_IOPORT, 0, 0x220, 0x10);
|
||||||
|
bus_set_resource(dev, SYS_RES_IRQ, 0, 5, 1);
|
||||||
|
bus_set_resource(dev, SYS_RES_DRQ, 0, 1, 1);
|
||||||
|
isa_set_vendorid(dev, PNP_EISAID("ESS1888"));
|
||||||
|
isa_set_logicalid(dev, PNP_EISAID("ESS1888"));
|
||||||
|
}
|
||||||
|
|
||||||
|
static device_method_t es1888_methods[] = {
|
||||||
|
/* Device interface */
|
||||||
|
DEVMETHOD(device_identify, es1888_identify),
|
||||||
|
|
||||||
|
{ 0, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
static driver_t es1888_driver = {
|
||||||
|
"pcm",
|
||||||
|
es1888_methods,
|
||||||
|
1, /* no softc */
|
||||||
|
};
|
||||||
|
|
||||||
|
static devclass_t pcm_devclass;
|
||||||
|
|
||||||
|
DRIVER_MODULE(es1888, isa, es1888_driver, pcm_devclass, 0, 0);
|
||||||
|
|
||||||
|
#endif /* NPCM > 0 */
|
@ -881,8 +881,8 @@ ess_format(struct sb_chinfo *ch, u_int32_t format)
|
|||||||
{
|
{
|
||||||
struct sb_info *sb = ch->parent;
|
struct sb_info *sb = ch->parent;
|
||||||
int play = (ch->dir == PCMDIR_PLAY)? 1 : 0;
|
int play = (ch->dir == PCMDIR_PLAY)? 1 : 0;
|
||||||
int b16 = (ch->fmt & AFMT_S16_LE)? 1 : 0;
|
int b16 = (format & AFMT_S16_LE)? 1 : 0;
|
||||||
int stereo = (ch->fmt & AFMT_STEREO)? 1 : 0;
|
int stereo = (format & AFMT_STEREO)? 1 : 0;
|
||||||
u_char c;
|
u_char c;
|
||||||
ch->fmt = format;
|
ch->fmt = format;
|
||||||
sb_reset_dsp(sb);
|
sb_reset_dsp(sb);
|
||||||
@ -913,7 +913,7 @@ ess_speed(struct sb_chinfo *ch, int speed)
|
|||||||
if (speed > 22000) {
|
if (speed > 22000) {
|
||||||
t = (795500 + speed / 2) / speed;
|
t = (795500 + speed / 2) / speed;
|
||||||
speed = (795500 + t / 2) / t;
|
speed = (795500 + t / 2) / t;
|
||||||
t = (256 - t ) | 0x80;
|
t = (256 - t ) | 0x80;
|
||||||
} else {
|
} else {
|
||||||
t = (397700 + speed / 2) / speed;
|
t = (397700 + speed / 2) / speed;
|
||||||
speed = (397700 + t / 2) / t;
|
speed = (397700 + t / 2) / t;
|
||||||
@ -1175,7 +1175,10 @@ sbmix_set(snd_mixer *m, unsigned dev, unsigned left, unsigned right)
|
|||||||
|
|
||||||
switch (sb->bd_flags & BD_F_MIX_MASK) {
|
switch (sb->bd_flags & BD_F_MIX_MASK) {
|
||||||
case BD_F_MIX_CT1345:
|
case BD_F_MIX_CT1345:
|
||||||
iomap = &sbpro_mix;
|
if (sb->bd_flags & BD_F_ESS)
|
||||||
|
iomap = &ess_mix;
|
||||||
|
else
|
||||||
|
iomap = &sbpro_mix;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BD_F_MIX_CT1745:
|
case BD_F_MIX_CT1745:
|
||||||
@ -1186,19 +1189,24 @@ sbmix_set(snd_mixer *m, unsigned dev, unsigned left, unsigned right)
|
|||||||
return -1;
|
return -1;
|
||||||
/* XXX how about the SG NX Pro, iomap = sgnxpro_mix */
|
/* XXX how about the SG NX Pro, iomap = sgnxpro_mix */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Change left channel */
|
||||||
regoffs = (*iomap)[dev][LEFT_CHN].regno;
|
regoffs = (*iomap)[dev][LEFT_CHN].regno;
|
||||||
if (regoffs == 0) return -1;
|
if (regoffs != 0) {
|
||||||
val = sb_getmixer(sb, regoffs);
|
val = sb_getmixer(sb, regoffs);
|
||||||
change_bits(iomap, &val, dev, LEFT_CHN, left);
|
change_bits(iomap, &val, dev, LEFT_CHN, left);
|
||||||
sb_setmixer(sb, regoffs, val);
|
sb_setmixer(sb, regoffs, val);
|
||||||
if ((*iomap)[dev][RIGHT_CHN].regno != regoffs) { /* Change register */
|
}
|
||||||
regoffs = (*iomap)[dev][RIGHT_CHN].regno;
|
|
||||||
if (regoffs != 0) {
|
/* Change right channel */
|
||||||
val = sb_getmixer(sb, regoffs); /* Read the new one */
|
regoffs = (*iomap)[dev][RIGHT_CHN].regno;
|
||||||
change_bits(iomap, &val, dev, RIGHT_CHN, right);
|
if (regoffs != 0) {
|
||||||
sb_setmixer(sb, regoffs, val);
|
val = sb_getmixer(sb, regoffs); /* Read the new one */
|
||||||
} else right = left;
|
change_bits(iomap, &val, dev, RIGHT_CHN, right);
|
||||||
} else right = left;
|
sb_setmixer(sb, regoffs, val);
|
||||||
|
} else
|
||||||
|
right = left;
|
||||||
|
|
||||||
return left | (right << 8);
|
return left | (right << 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1284,6 +1292,10 @@ sbpnp_probe(device_t dev)
|
|||||||
case 0x69187316: /* ESS1869 */
|
case 0x69187316: /* ESS1869 */
|
||||||
s = "ESS1869";
|
s = "ESS1869";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 0x88187316: /* ESS1888 */
|
||||||
|
s = "ESS1888";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (s) {
|
if (s) {
|
||||||
device_set_desc(dev, s);
|
device_set_desc(dev, s);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* file: sbcard.h
|
* file: sbcard.h
|
||||||
|
* $FreeBSD$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct _sbdev_info {
|
typedef struct _sbdev_info {
|
||||||
@ -257,6 +258,7 @@ extern int sbc_major, sbc_minor ;
|
|||||||
|
|
||||||
#ifndef __SB_MIXER_C__
|
#ifndef __SB_MIXER_C__
|
||||||
mixer_tab sbpro_mix;
|
mixer_tab sbpro_mix;
|
||||||
|
mixer_tab ess_mix;
|
||||||
mixer_tab sb16_mix;
|
mixer_tab sb16_mix;
|
||||||
#ifdef __SGNXPRO__
|
#ifdef __SGNXPRO__
|
||||||
mixer_tab sgnxpro_mix;
|
mixer_tab sgnxpro_mix;
|
||||||
@ -279,6 +281,21 @@ mixer_tab sbpro_mix = {
|
|||||||
PMIX_ENT(SOUND_MIXER_RECLEV, 0x00, 0, 0, 0x00, 0, 0)
|
PMIX_ENT(SOUND_MIXER_RECLEV, 0x00, 0, 0, 0x00, 0, 0)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mixer_tab ess_mix = {
|
||||||
|
PMIX_ENT(SOUND_MIXER_VOLUME, 0x32, 4, 4, 0x32, 0, 4),
|
||||||
|
PMIX_ENT(SOUND_MIXER_BASS, 0x00, 0, 0, 0x00, 0, 0),
|
||||||
|
PMIX_ENT(SOUND_MIXER_TREBLE, 0x00, 0, 0, 0x00, 0, 0),
|
||||||
|
PMIX_ENT(SOUND_MIXER_SYNTH, 0x36, 4, 4, 0x26, 0, 4),
|
||||||
|
PMIX_ENT(SOUND_MIXER_PCM, 0x14, 4, 4, 0x04, 0, 4),
|
||||||
|
PMIX_ENT(SOUND_MIXER_SPEAKER, 0x3c, 0, 3, 0x00, 0, 0),
|
||||||
|
PMIX_ENT(SOUND_MIXER_LINE, 0x3e, 4, 4, 0x2e, 0, 4),
|
||||||
|
PMIX_ENT(SOUND_MIXER_MIC, 0x1a, 4, 4, 0x1a, 0, 4),
|
||||||
|
PMIX_ENT(SOUND_MIXER_CD, 0x38, 4, 4, 0x28, 0, 4),
|
||||||
|
PMIX_ENT(SOUND_MIXER_IMIX, 0x00, 0, 0, 0x00, 0, 0),
|
||||||
|
PMIX_ENT(SOUND_MIXER_ALTPCM, 0x00, 0, 0, 0x00, 0, 0),
|
||||||
|
PMIX_ENT(SOUND_MIXER_RECLEV, 0x00, 0, 0, 0x00, 0, 0)
|
||||||
|
};
|
||||||
|
|
||||||
#ifdef __SGNXPRO__
|
#ifdef __SGNXPRO__
|
||||||
mixer_tab sgnxpro_mix = {
|
mixer_tab sgnxpro_mix = {
|
||||||
PMIX_ENT(SOUND_MIXER_VOLUME, 0x22, 4, 4, 0x22, 0, 4),
|
PMIX_ENT(SOUND_MIXER_VOLUME, 0x22, 4, 4, 0x22, 0, 4),
|
||||||
|
171
sys/dev/sound/isa/es1888.c
Normal file
171
sys/dev/sound/isa/es1888.c
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
/*-
|
||||||
|
* Copyright (c) 1999 Doug Rabson
|
||||||
|
* 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 <dev/pcm/sound.h>
|
||||||
|
#include <dev/pcm/isa/sb.h>
|
||||||
|
|
||||||
|
#if NPCM > 0
|
||||||
|
|
||||||
|
static int
|
||||||
|
es1888_dspready(u_int32_t port)
|
||||||
|
{
|
||||||
|
return ((inb(port + SBDSP_STATUS) & 0x80) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
es1888_dspwr(u_int32_t port, u_char val)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < 1000; i++) {
|
||||||
|
if (es1888_dspready(port)) {
|
||||||
|
outb(port + SBDSP_CMD, val);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (i > 10) DELAY((i > 100)? 1000 : 10);
|
||||||
|
}
|
||||||
|
printf("es1888_dspwr(0x%02x) timed out.\n", val);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static u_int
|
||||||
|
es1888_get_byte(u_int32_t port)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 1000; i > 0; i--) {
|
||||||
|
if (inb(port + DSP_DATA_AVAIL) & 0x80)
|
||||||
|
return inb(port + DSP_READ);
|
||||||
|
else
|
||||||
|
DELAY(20);
|
||||||
|
}
|
||||||
|
return 0xffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
es1888_reset(u_int32_t port)
|
||||||
|
{
|
||||||
|
outb(port + SBDSP_RST, 3);
|
||||||
|
DELAY(100);
|
||||||
|
outb(port + SBDSP_RST, 0);
|
||||||
|
if (es1888_get_byte(port) != 0xAA) {
|
||||||
|
DEB(printf("sb_reset_dsp 0x%lx failed\n",
|
||||||
|
rman_get_start(d->io_base)));
|
||||||
|
return ENXIO; /* Sorry */
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
es1888_configuration_mode(void)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Emit the Read-Sequence-Key to enter configuration
|
||||||
|
* mode. Note this only works after a reset (or after bit 2 of
|
||||||
|
* mixer register 0x40 is set).
|
||||||
|
*
|
||||||
|
* 3 reads from 0x229 in a row guarantees reset of key
|
||||||
|
* sequence to beginning.
|
||||||
|
*/
|
||||||
|
inb(0x229);
|
||||||
|
inb(0x229);
|
||||||
|
inb(0x229);
|
||||||
|
|
||||||
|
inb(0x22b); /* state 1 */
|
||||||
|
inb(0x229); /* state 2 */
|
||||||
|
inb(0x22b); /* state 3 */
|
||||||
|
inb(0x229); /* state 4 */
|
||||||
|
inb(0x229); /* state 5 */
|
||||||
|
inb(0x22b); /* state 6 */
|
||||||
|
inb(0x229); /* state 7 */
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
es1888_set_port(u_int32_t port)
|
||||||
|
{
|
||||||
|
es1888_configuration_mode();
|
||||||
|
inb(port);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
es1888_identify(driver_t *driver, device_t parent)
|
||||||
|
{
|
||||||
|
u_int32_t lo, hi;
|
||||||
|
device_t dev;
|
||||||
|
|
||||||
|
es1888_set_port(0x220);
|
||||||
|
es1888_reset(0x220);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check identification bytes for es1888.
|
||||||
|
*/
|
||||||
|
es1888_dspwr(0x220, 0xe7);
|
||||||
|
hi = es1888_get_byte(0x220);
|
||||||
|
lo = es1888_get_byte(0x220);
|
||||||
|
printf("es1888_identify: 0x%02x%02x\n", hi, lo);
|
||||||
|
if (hi != 0x68 || (lo & 0xf0) != 0x80)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Program irq and drq.
|
||||||
|
*/
|
||||||
|
es1888_dspwr(0x220, 0xc6); /* enter extended mode */
|
||||||
|
es1888_dspwr(0x220, 0xb1); /* write register b1 */
|
||||||
|
es1888_dspwr(0x220, 0x14); /* enable irq 5 */
|
||||||
|
es1888_dspwr(0x220, 0xb2); /* write register b1 */
|
||||||
|
es1888_dspwr(0x220, 0x18); /* enable drq 1 */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create the device and program its resources.
|
||||||
|
*/
|
||||||
|
dev = BUS_ADD_CHILD(parent, ISA_ORDER_PNP, NULL, -1);
|
||||||
|
bus_set_resource(dev, SYS_RES_IOPORT, 0, 0x220, 0x10);
|
||||||
|
bus_set_resource(dev, SYS_RES_IRQ, 0, 5, 1);
|
||||||
|
bus_set_resource(dev, SYS_RES_DRQ, 0, 1, 1);
|
||||||
|
isa_set_vendorid(dev, PNP_EISAID("ESS1888"));
|
||||||
|
isa_set_logicalid(dev, PNP_EISAID("ESS1888"));
|
||||||
|
}
|
||||||
|
|
||||||
|
static device_method_t es1888_methods[] = {
|
||||||
|
/* Device interface */
|
||||||
|
DEVMETHOD(device_identify, es1888_identify),
|
||||||
|
|
||||||
|
{ 0, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
static driver_t es1888_driver = {
|
||||||
|
"pcm",
|
||||||
|
es1888_methods,
|
||||||
|
1, /* no softc */
|
||||||
|
};
|
||||||
|
|
||||||
|
static devclass_t pcm_devclass;
|
||||||
|
|
||||||
|
DRIVER_MODULE(es1888, isa, es1888_driver, pcm_devclass, 0, 0);
|
||||||
|
|
||||||
|
#endif /* NPCM > 0 */
|
@ -881,8 +881,8 @@ ess_format(struct sb_chinfo *ch, u_int32_t format)
|
|||||||
{
|
{
|
||||||
struct sb_info *sb = ch->parent;
|
struct sb_info *sb = ch->parent;
|
||||||
int play = (ch->dir == PCMDIR_PLAY)? 1 : 0;
|
int play = (ch->dir == PCMDIR_PLAY)? 1 : 0;
|
||||||
int b16 = (ch->fmt & AFMT_S16_LE)? 1 : 0;
|
int b16 = (format & AFMT_S16_LE)? 1 : 0;
|
||||||
int stereo = (ch->fmt & AFMT_STEREO)? 1 : 0;
|
int stereo = (format & AFMT_STEREO)? 1 : 0;
|
||||||
u_char c;
|
u_char c;
|
||||||
ch->fmt = format;
|
ch->fmt = format;
|
||||||
sb_reset_dsp(sb);
|
sb_reset_dsp(sb);
|
||||||
@ -913,7 +913,7 @@ ess_speed(struct sb_chinfo *ch, int speed)
|
|||||||
if (speed > 22000) {
|
if (speed > 22000) {
|
||||||
t = (795500 + speed / 2) / speed;
|
t = (795500 + speed / 2) / speed;
|
||||||
speed = (795500 + t / 2) / t;
|
speed = (795500 + t / 2) / t;
|
||||||
t = (256 - t ) | 0x80;
|
t = (256 - t ) | 0x80;
|
||||||
} else {
|
} else {
|
||||||
t = (397700 + speed / 2) / speed;
|
t = (397700 + speed / 2) / speed;
|
||||||
speed = (397700 + t / 2) / t;
|
speed = (397700 + t / 2) / t;
|
||||||
@ -1175,7 +1175,10 @@ sbmix_set(snd_mixer *m, unsigned dev, unsigned left, unsigned right)
|
|||||||
|
|
||||||
switch (sb->bd_flags & BD_F_MIX_MASK) {
|
switch (sb->bd_flags & BD_F_MIX_MASK) {
|
||||||
case BD_F_MIX_CT1345:
|
case BD_F_MIX_CT1345:
|
||||||
iomap = &sbpro_mix;
|
if (sb->bd_flags & BD_F_ESS)
|
||||||
|
iomap = &ess_mix;
|
||||||
|
else
|
||||||
|
iomap = &sbpro_mix;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BD_F_MIX_CT1745:
|
case BD_F_MIX_CT1745:
|
||||||
@ -1186,19 +1189,24 @@ sbmix_set(snd_mixer *m, unsigned dev, unsigned left, unsigned right)
|
|||||||
return -1;
|
return -1;
|
||||||
/* XXX how about the SG NX Pro, iomap = sgnxpro_mix */
|
/* XXX how about the SG NX Pro, iomap = sgnxpro_mix */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Change left channel */
|
||||||
regoffs = (*iomap)[dev][LEFT_CHN].regno;
|
regoffs = (*iomap)[dev][LEFT_CHN].regno;
|
||||||
if (regoffs == 0) return -1;
|
if (regoffs != 0) {
|
||||||
val = sb_getmixer(sb, regoffs);
|
val = sb_getmixer(sb, regoffs);
|
||||||
change_bits(iomap, &val, dev, LEFT_CHN, left);
|
change_bits(iomap, &val, dev, LEFT_CHN, left);
|
||||||
sb_setmixer(sb, regoffs, val);
|
sb_setmixer(sb, regoffs, val);
|
||||||
if ((*iomap)[dev][RIGHT_CHN].regno != regoffs) { /* Change register */
|
}
|
||||||
regoffs = (*iomap)[dev][RIGHT_CHN].regno;
|
|
||||||
if (regoffs != 0) {
|
/* Change right channel */
|
||||||
val = sb_getmixer(sb, regoffs); /* Read the new one */
|
regoffs = (*iomap)[dev][RIGHT_CHN].regno;
|
||||||
change_bits(iomap, &val, dev, RIGHT_CHN, right);
|
if (regoffs != 0) {
|
||||||
sb_setmixer(sb, regoffs, val);
|
val = sb_getmixer(sb, regoffs); /* Read the new one */
|
||||||
} else right = left;
|
change_bits(iomap, &val, dev, RIGHT_CHN, right);
|
||||||
} else right = left;
|
sb_setmixer(sb, regoffs, val);
|
||||||
|
} else
|
||||||
|
right = left;
|
||||||
|
|
||||||
return left | (right << 8);
|
return left | (right << 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1284,6 +1292,10 @@ sbpnp_probe(device_t dev)
|
|||||||
case 0x69187316: /* ESS1869 */
|
case 0x69187316: /* ESS1869 */
|
||||||
s = "ESS1869";
|
s = "ESS1869";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 0x88187316: /* ESS1888 */
|
||||||
|
s = "ESS1888";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (s) {
|
if (s) {
|
||||||
device_set_desc(dev, s);
|
device_set_desc(dev, s);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* file: sbcard.h
|
* file: sbcard.h
|
||||||
|
* $FreeBSD$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct _sbdev_info {
|
typedef struct _sbdev_info {
|
||||||
@ -257,6 +258,7 @@ extern int sbc_major, sbc_minor ;
|
|||||||
|
|
||||||
#ifndef __SB_MIXER_C__
|
#ifndef __SB_MIXER_C__
|
||||||
mixer_tab sbpro_mix;
|
mixer_tab sbpro_mix;
|
||||||
|
mixer_tab ess_mix;
|
||||||
mixer_tab sb16_mix;
|
mixer_tab sb16_mix;
|
||||||
#ifdef __SGNXPRO__
|
#ifdef __SGNXPRO__
|
||||||
mixer_tab sgnxpro_mix;
|
mixer_tab sgnxpro_mix;
|
||||||
@ -279,6 +281,21 @@ mixer_tab sbpro_mix = {
|
|||||||
PMIX_ENT(SOUND_MIXER_RECLEV, 0x00, 0, 0, 0x00, 0, 0)
|
PMIX_ENT(SOUND_MIXER_RECLEV, 0x00, 0, 0, 0x00, 0, 0)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mixer_tab ess_mix = {
|
||||||
|
PMIX_ENT(SOUND_MIXER_VOLUME, 0x32, 4, 4, 0x32, 0, 4),
|
||||||
|
PMIX_ENT(SOUND_MIXER_BASS, 0x00, 0, 0, 0x00, 0, 0),
|
||||||
|
PMIX_ENT(SOUND_MIXER_TREBLE, 0x00, 0, 0, 0x00, 0, 0),
|
||||||
|
PMIX_ENT(SOUND_MIXER_SYNTH, 0x36, 4, 4, 0x26, 0, 4),
|
||||||
|
PMIX_ENT(SOUND_MIXER_PCM, 0x14, 4, 4, 0x04, 0, 4),
|
||||||
|
PMIX_ENT(SOUND_MIXER_SPEAKER, 0x3c, 0, 3, 0x00, 0, 0),
|
||||||
|
PMIX_ENT(SOUND_MIXER_LINE, 0x3e, 4, 4, 0x2e, 0, 4),
|
||||||
|
PMIX_ENT(SOUND_MIXER_MIC, 0x1a, 4, 4, 0x1a, 0, 4),
|
||||||
|
PMIX_ENT(SOUND_MIXER_CD, 0x38, 4, 4, 0x28, 0, 4),
|
||||||
|
PMIX_ENT(SOUND_MIXER_IMIX, 0x00, 0, 0, 0x00, 0, 0),
|
||||||
|
PMIX_ENT(SOUND_MIXER_ALTPCM, 0x00, 0, 0, 0x00, 0, 0),
|
||||||
|
PMIX_ENT(SOUND_MIXER_RECLEV, 0x00, 0, 0, 0x00, 0, 0)
|
||||||
|
};
|
||||||
|
|
||||||
#ifdef __SGNXPRO__
|
#ifdef __SGNXPRO__
|
||||||
mixer_tab sgnxpro_mix = {
|
mixer_tab sgnxpro_mix = {
|
||||||
PMIX_ENT(SOUND_MIXER_VOLUME, 0x22, 4, 4, 0x22, 0, 4),
|
PMIX_ENT(SOUND_MIXER_VOLUME, 0x22, 4, 4, 0x22, 0, 4),
|
||||||
|
@ -881,8 +881,8 @@ ess_format(struct sb_chinfo *ch, u_int32_t format)
|
|||||||
{
|
{
|
||||||
struct sb_info *sb = ch->parent;
|
struct sb_info *sb = ch->parent;
|
||||||
int play = (ch->dir == PCMDIR_PLAY)? 1 : 0;
|
int play = (ch->dir == PCMDIR_PLAY)? 1 : 0;
|
||||||
int b16 = (ch->fmt & AFMT_S16_LE)? 1 : 0;
|
int b16 = (format & AFMT_S16_LE)? 1 : 0;
|
||||||
int stereo = (ch->fmt & AFMT_STEREO)? 1 : 0;
|
int stereo = (format & AFMT_STEREO)? 1 : 0;
|
||||||
u_char c;
|
u_char c;
|
||||||
ch->fmt = format;
|
ch->fmt = format;
|
||||||
sb_reset_dsp(sb);
|
sb_reset_dsp(sb);
|
||||||
@ -913,7 +913,7 @@ ess_speed(struct sb_chinfo *ch, int speed)
|
|||||||
if (speed > 22000) {
|
if (speed > 22000) {
|
||||||
t = (795500 + speed / 2) / speed;
|
t = (795500 + speed / 2) / speed;
|
||||||
speed = (795500 + t / 2) / t;
|
speed = (795500 + t / 2) / t;
|
||||||
t = (256 - t ) | 0x80;
|
t = (256 - t ) | 0x80;
|
||||||
} else {
|
} else {
|
||||||
t = (397700 + speed / 2) / speed;
|
t = (397700 + speed / 2) / speed;
|
||||||
speed = (397700 + t / 2) / t;
|
speed = (397700 + t / 2) / t;
|
||||||
@ -1175,7 +1175,10 @@ sbmix_set(snd_mixer *m, unsigned dev, unsigned left, unsigned right)
|
|||||||
|
|
||||||
switch (sb->bd_flags & BD_F_MIX_MASK) {
|
switch (sb->bd_flags & BD_F_MIX_MASK) {
|
||||||
case BD_F_MIX_CT1345:
|
case BD_F_MIX_CT1345:
|
||||||
iomap = &sbpro_mix;
|
if (sb->bd_flags & BD_F_ESS)
|
||||||
|
iomap = &ess_mix;
|
||||||
|
else
|
||||||
|
iomap = &sbpro_mix;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BD_F_MIX_CT1745:
|
case BD_F_MIX_CT1745:
|
||||||
@ -1186,19 +1189,24 @@ sbmix_set(snd_mixer *m, unsigned dev, unsigned left, unsigned right)
|
|||||||
return -1;
|
return -1;
|
||||||
/* XXX how about the SG NX Pro, iomap = sgnxpro_mix */
|
/* XXX how about the SG NX Pro, iomap = sgnxpro_mix */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Change left channel */
|
||||||
regoffs = (*iomap)[dev][LEFT_CHN].regno;
|
regoffs = (*iomap)[dev][LEFT_CHN].regno;
|
||||||
if (regoffs == 0) return -1;
|
if (regoffs != 0) {
|
||||||
val = sb_getmixer(sb, regoffs);
|
val = sb_getmixer(sb, regoffs);
|
||||||
change_bits(iomap, &val, dev, LEFT_CHN, left);
|
change_bits(iomap, &val, dev, LEFT_CHN, left);
|
||||||
sb_setmixer(sb, regoffs, val);
|
sb_setmixer(sb, regoffs, val);
|
||||||
if ((*iomap)[dev][RIGHT_CHN].regno != regoffs) { /* Change register */
|
}
|
||||||
regoffs = (*iomap)[dev][RIGHT_CHN].regno;
|
|
||||||
if (regoffs != 0) {
|
/* Change right channel */
|
||||||
val = sb_getmixer(sb, regoffs); /* Read the new one */
|
regoffs = (*iomap)[dev][RIGHT_CHN].regno;
|
||||||
change_bits(iomap, &val, dev, RIGHT_CHN, right);
|
if (regoffs != 0) {
|
||||||
sb_setmixer(sb, regoffs, val);
|
val = sb_getmixer(sb, regoffs); /* Read the new one */
|
||||||
} else right = left;
|
change_bits(iomap, &val, dev, RIGHT_CHN, right);
|
||||||
} else right = left;
|
sb_setmixer(sb, regoffs, val);
|
||||||
|
} else
|
||||||
|
right = left;
|
||||||
|
|
||||||
return left | (right << 8);
|
return left | (right << 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1284,6 +1292,10 @@ sbpnp_probe(device_t dev)
|
|||||||
case 0x69187316: /* ESS1869 */
|
case 0x69187316: /* ESS1869 */
|
||||||
s = "ESS1869";
|
s = "ESS1869";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 0x88187316: /* ESS1888 */
|
||||||
|
s = "ESS1888";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (s) {
|
if (s) {
|
||||||
device_set_desc(dev, s);
|
device_set_desc(dev, s);
|
||||||
|
@ -881,8 +881,8 @@ ess_format(struct sb_chinfo *ch, u_int32_t format)
|
|||||||
{
|
{
|
||||||
struct sb_info *sb = ch->parent;
|
struct sb_info *sb = ch->parent;
|
||||||
int play = (ch->dir == PCMDIR_PLAY)? 1 : 0;
|
int play = (ch->dir == PCMDIR_PLAY)? 1 : 0;
|
||||||
int b16 = (ch->fmt & AFMT_S16_LE)? 1 : 0;
|
int b16 = (format & AFMT_S16_LE)? 1 : 0;
|
||||||
int stereo = (ch->fmt & AFMT_STEREO)? 1 : 0;
|
int stereo = (format & AFMT_STEREO)? 1 : 0;
|
||||||
u_char c;
|
u_char c;
|
||||||
ch->fmt = format;
|
ch->fmt = format;
|
||||||
sb_reset_dsp(sb);
|
sb_reset_dsp(sb);
|
||||||
@ -913,7 +913,7 @@ ess_speed(struct sb_chinfo *ch, int speed)
|
|||||||
if (speed > 22000) {
|
if (speed > 22000) {
|
||||||
t = (795500 + speed / 2) / speed;
|
t = (795500 + speed / 2) / speed;
|
||||||
speed = (795500 + t / 2) / t;
|
speed = (795500 + t / 2) / t;
|
||||||
t = (256 - t ) | 0x80;
|
t = (256 - t ) | 0x80;
|
||||||
} else {
|
} else {
|
||||||
t = (397700 + speed / 2) / speed;
|
t = (397700 + speed / 2) / speed;
|
||||||
speed = (397700 + t / 2) / t;
|
speed = (397700 + t / 2) / t;
|
||||||
@ -1175,7 +1175,10 @@ sbmix_set(snd_mixer *m, unsigned dev, unsigned left, unsigned right)
|
|||||||
|
|
||||||
switch (sb->bd_flags & BD_F_MIX_MASK) {
|
switch (sb->bd_flags & BD_F_MIX_MASK) {
|
||||||
case BD_F_MIX_CT1345:
|
case BD_F_MIX_CT1345:
|
||||||
iomap = &sbpro_mix;
|
if (sb->bd_flags & BD_F_ESS)
|
||||||
|
iomap = &ess_mix;
|
||||||
|
else
|
||||||
|
iomap = &sbpro_mix;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BD_F_MIX_CT1745:
|
case BD_F_MIX_CT1745:
|
||||||
@ -1186,19 +1189,24 @@ sbmix_set(snd_mixer *m, unsigned dev, unsigned left, unsigned right)
|
|||||||
return -1;
|
return -1;
|
||||||
/* XXX how about the SG NX Pro, iomap = sgnxpro_mix */
|
/* XXX how about the SG NX Pro, iomap = sgnxpro_mix */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Change left channel */
|
||||||
regoffs = (*iomap)[dev][LEFT_CHN].regno;
|
regoffs = (*iomap)[dev][LEFT_CHN].regno;
|
||||||
if (regoffs == 0) return -1;
|
if (regoffs != 0) {
|
||||||
val = sb_getmixer(sb, regoffs);
|
val = sb_getmixer(sb, regoffs);
|
||||||
change_bits(iomap, &val, dev, LEFT_CHN, left);
|
change_bits(iomap, &val, dev, LEFT_CHN, left);
|
||||||
sb_setmixer(sb, regoffs, val);
|
sb_setmixer(sb, regoffs, val);
|
||||||
if ((*iomap)[dev][RIGHT_CHN].regno != regoffs) { /* Change register */
|
}
|
||||||
regoffs = (*iomap)[dev][RIGHT_CHN].regno;
|
|
||||||
if (regoffs != 0) {
|
/* Change right channel */
|
||||||
val = sb_getmixer(sb, regoffs); /* Read the new one */
|
regoffs = (*iomap)[dev][RIGHT_CHN].regno;
|
||||||
change_bits(iomap, &val, dev, RIGHT_CHN, right);
|
if (regoffs != 0) {
|
||||||
sb_setmixer(sb, regoffs, val);
|
val = sb_getmixer(sb, regoffs); /* Read the new one */
|
||||||
} else right = left;
|
change_bits(iomap, &val, dev, RIGHT_CHN, right);
|
||||||
} else right = left;
|
sb_setmixer(sb, regoffs, val);
|
||||||
|
} else
|
||||||
|
right = left;
|
||||||
|
|
||||||
return left | (right << 8);
|
return left | (right << 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1284,6 +1292,10 @@ sbpnp_probe(device_t dev)
|
|||||||
case 0x69187316: /* ESS1869 */
|
case 0x69187316: /* ESS1869 */
|
||||||
s = "ESS1869";
|
s = "ESS1869";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 0x88187316: /* ESS1888 */
|
||||||
|
s = "ESS1888";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (s) {
|
if (s) {
|
||||||
device_set_desc(dev, s);
|
device_set_desc(dev, s);
|
||||||
|
@ -208,7 +208,8 @@ dsp_ioctl(snddev_info *d, int chan, u_long cmd, caddr_t arg)
|
|||||||
u_long s;
|
u_long s;
|
||||||
pcm_channel *wrch = NULL, *rdch = NULL;
|
pcm_channel *wrch = NULL, *rdch = NULL;
|
||||||
|
|
||||||
getchns(d, chan, &rdch, &wrch);
|
rdch = d->arec[chan];
|
||||||
|
wrch = d->aplay[chan];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* all routines are called with int. blocked. Make sure that
|
* all routines are called with int. blocked. Make sure that
|
||||||
|
Loading…
Reference in New Issue
Block a user