2005-01-06 01:43:34 +00:00
|
|
|
/*-
|
2017-11-27 14:52:40 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
|
|
|
*
|
2000-06-06 22:34:09 +00:00
|
|
|
* Copyright (c) 2000 Cameron Grant <cg@freebsd.org>
|
2000-05-31 03:21:36 +00:00
|
|
|
* 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 THEPOSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
Sound Mega-commit. Expect further cleanup until code freeze.
For a slightly thorough explaination, please refer to
[1] http://people.freebsd.org/~ariff/SOUND_4.TXT.html .
Summary of changes includes:
1 Volume Per-Channel (vpc). Provides private / standalone volume control
unique per-stream pcm channel without touching master volume / pcm.
Applications can directly use SNDCTL_DSP_[GET|SET][PLAY|REC]VOL, or for
backwards compatibility, SOUND_MIXER_PCM through the opened dsp device
instead of /dev/mixer. Special "bypass" mode is enabled through
/dev/mixer which will automatically detect if the adjustment is made
through /dev/mixer and forward its request to this private volume
controller. Changes to this volume object will not interfere with
other channels.
Requirements:
- SNDCTL_DSP_[GET|SET][PLAY|REC]_VOL are newer ioctls (OSSv4) which
require specific application modifications (preferred).
- No modifications required for using bypass mode, so applications
like mplayer or xmms should work out of the box.
Kernel hints:
- hint.pcm.%d.vpc (0 = disable vpc).
Kernel sysctls:
- hw.snd.vpc_mixer_bypass (default: 1). Enable or disable /dev/mixer
bypass mode.
- hw.snd.vpc_autoreset (default: 1). By default, closing/opening
/dev/dsp will reset the volume back to 0 db gain/attenuation.
Setting this to 0 will preserve its settings across device
closing/opening.
- hw.snd.vpc_reset (default: 0). Panic/reset button to reset all
volume settings back to 0 db.
- hw.snd.vpc_0db (default: 45). 0 db relative to linear mixer value.
2 High quality fixed-point Bandlimited SINC sampling rate converter,
based on Julius O'Smith's Digital Audio Resampling -
http://ccrma.stanford.edu/~jos/resample/. It includes a filter design
script written in awk (the clumsiest joke I've ever written)
- 100% 32bit fixed-point, 64bit accumulator.
- Possibly among the fastest (if not fastest) of its kind.
- Resampling quality is tunable, either runtime or during kernel
compilation (FEEDER_RATE_PRESETS).
- Quality can be further customized during kernel compilation by
defining FEEDER_RATE_PRESETS in /etc/make.conf.
Kernel sysctls:
- hw.snd.feeder_rate_quality.
0 - Zero-order Hold (ZOH). Fastest, bad quality.
1 - Linear Interpolation (LINEAR). Slightly slower than ZOH,
better quality but still does not eliminate aliasing.
2 - (and above) - Sinc Interpolation(SINC). Best quality. SINC
quality always start from 2 and above.
Rough quality comparisons:
- http://people.freebsd.org/~ariff/z_comparison/
3 Bit-perfect mode. Bypasses all feeder/dsp effects. Pure sound will be
directly fed into the hardware.
4 Parametric (compile time) Software Equalizer (Bass/Treble mixer). Can
be customized by defining FEEDER_EQ_PRESETS in /etc/make.conf.
5 Transparent/Adaptive Virtual Channel. Now you don't have to disable
vchans in order to make digital format pass through. It also makes
vchans more dynamic by choosing a better format/rate among all the
concurrent streams, which means that dev.pcm.X.play.vchanformat/rate
becomes sort of optional.
6 Exclusive Stream, with special open() mode O_EXCL. This will "mute"
other concurrent vchan streams and only allow a single channel with
O_EXCL set to keep producing sound.
Other Changes:
* most feeder_* stuffs are compilable in userland. Let's not
speculate whether we should go all out for it (save that for
FreeBSD 16.0-RELEASE).
* kobj signature fixups, thanks to Andriy Gapon <avg@freebsd.org>
* pull out channel mixing logic out of vchan.c and create its own
feeder_mixer for world justice.
* various refactoring here and there, for good or bad.
* activation of few more OSSv4 ioctls() (see [1] above).
* opt_snd.h for possible compile time configuration:
(mostly for debugging purposes, don't try these at home)
SND_DEBUG
SND_DIAGNOSTIC
SND_FEEDER_MULTIFORMAT
SND_FEEDER_FULL_MULTIFORMAT
SND_FEEDER_RATE_HP
SND_PCM_64
SND_OLDSTEREO
Manual page updates are on the way.
Tested by: joel, Olivier SMEDTS <olivier at gid0 d org>, too many
unsung / unnamed heroes.
2009-06-07 19:12:08 +00:00
|
|
|
#ifdef HAVE_KERNEL_OPTION_HEADERS
|
|
|
|
#include "opt_snd.h"
|
|
|
|
#endif
|
|
|
|
|
2000-05-31 03:21:36 +00:00
|
|
|
#include <dev/sound/pcm/sound.h>
|
|
|
|
#include <dev/sound/pcm/ac97.h>
|
|
|
|
|
2003-08-22 07:08:17 +00:00
|
|
|
#include <dev/pci/pcireg.h>
|
|
|
|
#include <dev/pci/pcivar.h>
|
2000-05-31 03:21:36 +00:00
|
|
|
|
|
|
|
#include <dev/sound/pci/ds1.h>
|
|
|
|
#include <dev/sound/pci/ds1-fw.h>
|
|
|
|
|
2001-08-23 11:30:52 +00:00
|
|
|
SND_DECLARE_FILE("$FreeBSD$");
|
|
|
|
|
2000-05-31 03:21:36 +00:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
#define DS1_CHANS 4
|
2000-06-06 22:34:09 +00:00
|
|
|
#define DS1_RECPRIMARY 0
|
2000-12-25 01:42:13 +00:00
|
|
|
#define DS1_IRQHZ ((48000 << 8) / 256)
|
2001-01-24 01:22:53 +00:00
|
|
|
#define DS1_BUFFSIZE 4096
|
2000-05-31 03:21:36 +00:00
|
|
|
|
|
|
|
struct pbank {
|
|
|
|
volatile u_int32_t Format;
|
|
|
|
volatile u_int32_t LoopDefault;
|
|
|
|
volatile u_int32_t PgBase;
|
|
|
|
volatile u_int32_t PgLoop;
|
|
|
|
volatile u_int32_t PgLoopEnd;
|
|
|
|
volatile u_int32_t PgLoopFrac;
|
|
|
|
volatile u_int32_t PgDeltaEnd;
|
|
|
|
volatile u_int32_t LpfKEnd;
|
|
|
|
volatile u_int32_t EgGainEnd;
|
|
|
|
volatile u_int32_t LchGainEnd;
|
|
|
|
volatile u_int32_t RchGainEnd;
|
|
|
|
volatile u_int32_t Effect1GainEnd;
|
|
|
|
volatile u_int32_t Effect2GainEnd;
|
|
|
|
volatile u_int32_t Effect3GainEnd;
|
|
|
|
volatile u_int32_t LpfQ;
|
|
|
|
volatile u_int32_t Status;
|
|
|
|
volatile u_int32_t NumOfFrames;
|
|
|
|
volatile u_int32_t LoopCount;
|
|
|
|
volatile u_int32_t PgStart;
|
|
|
|
volatile u_int32_t PgStartFrac;
|
|
|
|
volatile u_int32_t PgDelta;
|
|
|
|
volatile u_int32_t LpfK;
|
|
|
|
volatile u_int32_t EgGain;
|
|
|
|
volatile u_int32_t LchGain;
|
|
|
|
volatile u_int32_t RchGain;
|
|
|
|
volatile u_int32_t Effect1Gain;
|
|
|
|
volatile u_int32_t Effect2Gain;
|
|
|
|
volatile u_int32_t Effect3Gain;
|
|
|
|
volatile u_int32_t LpfD1;
|
|
|
|
volatile u_int32_t LpfD2;
|
|
|
|
};
|
|
|
|
|
2000-06-06 22:34:09 +00:00
|
|
|
struct rbank {
|
|
|
|
volatile u_int32_t PgBase;
|
|
|
|
volatile u_int32_t PgLoopEnd;
|
|
|
|
volatile u_int32_t PgStart;
|
|
|
|
volatile u_int32_t NumOfLoops;
|
|
|
|
};
|
|
|
|
|
2000-05-31 03:21:36 +00:00
|
|
|
struct sc_info;
|
|
|
|
|
|
|
|
/* channel registers */
|
2000-06-06 22:34:09 +00:00
|
|
|
struct sc_pchinfo {
|
2000-05-31 03:21:36 +00:00
|
|
|
int run, spd, dir, fmt;
|
2001-03-24 23:10:29 +00:00
|
|
|
struct snd_dbuf *buffer;
|
|
|
|
struct pcm_channel *channel;
|
2000-05-31 03:21:36 +00:00
|
|
|
volatile struct pbank *lslot, *rslot;
|
|
|
|
int lsnum, rsnum;
|
|
|
|
struct sc_info *parent;
|
|
|
|
};
|
|
|
|
|
2000-06-06 22:34:09 +00:00
|
|
|
struct sc_rchinfo {
|
|
|
|
int run, spd, dir, fmt, num;
|
2001-03-24 23:10:29 +00:00
|
|
|
struct snd_dbuf *buffer;
|
|
|
|
struct pcm_channel *channel;
|
2000-06-06 22:34:09 +00:00
|
|
|
volatile struct rbank *slot;
|
|
|
|
struct sc_info *parent;
|
|
|
|
};
|
|
|
|
|
2000-05-31 03:21:36 +00:00
|
|
|
/* device private data */
|
|
|
|
struct sc_info {
|
|
|
|
device_t dev;
|
|
|
|
u_int32_t type, rev;
|
|
|
|
u_int32_t cd2id, ctrlbase;
|
|
|
|
|
|
|
|
bus_space_tag_t st;
|
|
|
|
bus_space_handle_t sh;
|
2001-10-08 06:01:13 +00:00
|
|
|
bus_dma_tag_t buffer_dmat, control_dmat;
|
2000-09-01 20:09:24 +00:00
|
|
|
bus_dmamap_t map;
|
2000-05-31 03:21:36 +00:00
|
|
|
|
|
|
|
struct resource *reg, *irq;
|
|
|
|
int regid, irqid;
|
|
|
|
void *ih;
|
2002-11-26 18:16:27 +00:00
|
|
|
struct mtx *lock;
|
2000-05-31 03:21:36 +00:00
|
|
|
|
2000-08-29 20:50:42 +00:00
|
|
|
void *regbase;
|
2000-05-31 03:21:36 +00:00
|
|
|
u_int32_t *pbase, pbankbase, pbanksize;
|
|
|
|
volatile struct pbank *pbank[2 * 64];
|
2000-06-06 22:34:09 +00:00
|
|
|
volatile struct rbank *rbank;
|
2000-05-31 03:21:36 +00:00
|
|
|
int pslotfree, currbank, pchn, rchn;
|
2001-10-08 06:01:13 +00:00
|
|
|
unsigned int bufsz;
|
2000-05-31 03:21:36 +00:00
|
|
|
|
2000-06-06 22:34:09 +00:00
|
|
|
struct sc_pchinfo pch[DS1_CHANS];
|
|
|
|
struct sc_rchinfo rch[2];
|
2000-05-31 03:21:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct {
|
|
|
|
u_int32_t dev, subdev;
|
|
|
|
char *name;
|
|
|
|
u_int32_t *mcode;
|
|
|
|
} ds_devs[] = {
|
|
|
|
{0x00041073, 0, "Yamaha DS-1 (YMF724)", CntrlInst},
|
|
|
|
{0x000d1073, 0, "Yamaha DS-1E (YMF724F)", CntrlInst1E},
|
|
|
|
{0x00051073, 0, "Yamaha DS-1? (YMF734)", CntrlInst},
|
|
|
|
{0x00081073, 0, "Yamaha DS-1? (YMF737)", CntrlInst},
|
|
|
|
{0x00201073, 0, "Yamaha DS-1? (YMF738)", CntrlInst},
|
|
|
|
{0x00061073, 0, "Yamaha DS-1? (YMF738_TEG)", CntrlInst},
|
|
|
|
{0x000a1073, 0x00041073, "Yamaha DS-1 (YMF740)", CntrlInst},
|
|
|
|
{0x000a1073, 0x000a1073, "Yamaha DS-1 (YMF740B)", CntrlInst},
|
2000-12-18 01:36:41 +00:00
|
|
|
{0x000a1073, 0x53328086, "Yamaha DS-1 (YMF740I)", CntrlInst},
|
2000-06-01 03:58:27 +00:00
|
|
|
{0x000a1073, 0, "Yamaha DS-1 (YMF740?)", CntrlInst},
|
2000-05-31 03:21:36 +00:00
|
|
|
{0x000c1073, 0, "Yamaha DS-1E (YMF740C)", CntrlInst1E},
|
2000-12-18 01:36:41 +00:00
|
|
|
{0x00101073, 0, "Yamaha DS-1E (YMF744)", CntrlInst1E},
|
2000-05-31 03:21:36 +00:00
|
|
|
{0x00121073, 0, "Yamaha DS-1E (YMF754)", CntrlInst1E},
|
|
|
|
{0, 0, NULL, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* prototypes
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* stuff */
|
2007-02-23 19:41:16 +00:00
|
|
|
static int ds_init(struct sc_info *);
|
2000-05-31 03:21:36 +00:00
|
|
|
static void ds_intr(void *);
|
|
|
|
|
|
|
|
/* talk to the card */
|
|
|
|
static u_int32_t ds_rd(struct sc_info *, int, int);
|
|
|
|
static void ds_wr(struct sc_info *, int, u_int32_t, int);
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
2000-08-20 22:18:56 +00:00
|
|
|
static u_int32_t ds_recfmt[] = {
|
Sound Mega-commit. Expect further cleanup until code freeze.
For a slightly thorough explaination, please refer to
[1] http://people.freebsd.org/~ariff/SOUND_4.TXT.html .
Summary of changes includes:
1 Volume Per-Channel (vpc). Provides private / standalone volume control
unique per-stream pcm channel without touching master volume / pcm.
Applications can directly use SNDCTL_DSP_[GET|SET][PLAY|REC]VOL, or for
backwards compatibility, SOUND_MIXER_PCM through the opened dsp device
instead of /dev/mixer. Special "bypass" mode is enabled through
/dev/mixer which will automatically detect if the adjustment is made
through /dev/mixer and forward its request to this private volume
controller. Changes to this volume object will not interfere with
other channels.
Requirements:
- SNDCTL_DSP_[GET|SET][PLAY|REC]_VOL are newer ioctls (OSSv4) which
require specific application modifications (preferred).
- No modifications required for using bypass mode, so applications
like mplayer or xmms should work out of the box.
Kernel hints:
- hint.pcm.%d.vpc (0 = disable vpc).
Kernel sysctls:
- hw.snd.vpc_mixer_bypass (default: 1). Enable or disable /dev/mixer
bypass mode.
- hw.snd.vpc_autoreset (default: 1). By default, closing/opening
/dev/dsp will reset the volume back to 0 db gain/attenuation.
Setting this to 0 will preserve its settings across device
closing/opening.
- hw.snd.vpc_reset (default: 0). Panic/reset button to reset all
volume settings back to 0 db.
- hw.snd.vpc_0db (default: 45). 0 db relative to linear mixer value.
2 High quality fixed-point Bandlimited SINC sampling rate converter,
based on Julius O'Smith's Digital Audio Resampling -
http://ccrma.stanford.edu/~jos/resample/. It includes a filter design
script written in awk (the clumsiest joke I've ever written)
- 100% 32bit fixed-point, 64bit accumulator.
- Possibly among the fastest (if not fastest) of its kind.
- Resampling quality is tunable, either runtime or during kernel
compilation (FEEDER_RATE_PRESETS).
- Quality can be further customized during kernel compilation by
defining FEEDER_RATE_PRESETS in /etc/make.conf.
Kernel sysctls:
- hw.snd.feeder_rate_quality.
0 - Zero-order Hold (ZOH). Fastest, bad quality.
1 - Linear Interpolation (LINEAR). Slightly slower than ZOH,
better quality but still does not eliminate aliasing.
2 - (and above) - Sinc Interpolation(SINC). Best quality. SINC
quality always start from 2 and above.
Rough quality comparisons:
- http://people.freebsd.org/~ariff/z_comparison/
3 Bit-perfect mode. Bypasses all feeder/dsp effects. Pure sound will be
directly fed into the hardware.
4 Parametric (compile time) Software Equalizer (Bass/Treble mixer). Can
be customized by defining FEEDER_EQ_PRESETS in /etc/make.conf.
5 Transparent/Adaptive Virtual Channel. Now you don't have to disable
vchans in order to make digital format pass through. It also makes
vchans more dynamic by choosing a better format/rate among all the
concurrent streams, which means that dev.pcm.X.play.vchanformat/rate
becomes sort of optional.
6 Exclusive Stream, with special open() mode O_EXCL. This will "mute"
other concurrent vchan streams and only allow a single channel with
O_EXCL set to keep producing sound.
Other Changes:
* most feeder_* stuffs are compilable in userland. Let's not
speculate whether we should go all out for it (save that for
FreeBSD 16.0-RELEASE).
* kobj signature fixups, thanks to Andriy Gapon <avg@freebsd.org>
* pull out channel mixing logic out of vchan.c and create its own
feeder_mixer for world justice.
* various refactoring here and there, for good or bad.
* activation of few more OSSv4 ioctls() (see [1] above).
* opt_snd.h for possible compile time configuration:
(mostly for debugging purposes, don't try these at home)
SND_DEBUG
SND_DIAGNOSTIC
SND_FEEDER_MULTIFORMAT
SND_FEEDER_FULL_MULTIFORMAT
SND_FEEDER_RATE_HP
SND_PCM_64
SND_OLDSTEREO
Manual page updates are on the way.
Tested by: joel, Olivier SMEDTS <olivier at gid0 d org>, too many
unsung / unnamed heroes.
2009-06-07 19:12:08 +00:00
|
|
|
SND_FORMAT(AFMT_U8, 1, 0),
|
|
|
|
SND_FORMAT(AFMT_U8, 2, 0),
|
|
|
|
SND_FORMAT(AFMT_S8, 1, 0),
|
|
|
|
SND_FORMAT(AFMT_S8, 2, 0),
|
|
|
|
SND_FORMAT(AFMT_S16_LE, 1, 0),
|
|
|
|
SND_FORMAT(AFMT_S16_LE, 2, 0),
|
|
|
|
SND_FORMAT(AFMT_U16_LE, 1, 0),
|
|
|
|
SND_FORMAT(AFMT_U16_LE, 2, 0),
|
2000-08-20 22:18:56 +00:00
|
|
|
0
|
2000-05-31 03:21:36 +00:00
|
|
|
};
|
2001-03-24 23:10:29 +00:00
|
|
|
static struct pcmchan_caps ds_reccaps = {4000, 48000, ds_recfmt, 0};
|
2000-08-20 22:18:56 +00:00
|
|
|
|
|
|
|
static u_int32_t ds_playfmt[] = {
|
Sound Mega-commit. Expect further cleanup until code freeze.
For a slightly thorough explaination, please refer to
[1] http://people.freebsd.org/~ariff/SOUND_4.TXT.html .
Summary of changes includes:
1 Volume Per-Channel (vpc). Provides private / standalone volume control
unique per-stream pcm channel without touching master volume / pcm.
Applications can directly use SNDCTL_DSP_[GET|SET][PLAY|REC]VOL, or for
backwards compatibility, SOUND_MIXER_PCM through the opened dsp device
instead of /dev/mixer. Special "bypass" mode is enabled through
/dev/mixer which will automatically detect if the adjustment is made
through /dev/mixer and forward its request to this private volume
controller. Changes to this volume object will not interfere with
other channels.
Requirements:
- SNDCTL_DSP_[GET|SET][PLAY|REC]_VOL are newer ioctls (OSSv4) which
require specific application modifications (preferred).
- No modifications required for using bypass mode, so applications
like mplayer or xmms should work out of the box.
Kernel hints:
- hint.pcm.%d.vpc (0 = disable vpc).
Kernel sysctls:
- hw.snd.vpc_mixer_bypass (default: 1). Enable or disable /dev/mixer
bypass mode.
- hw.snd.vpc_autoreset (default: 1). By default, closing/opening
/dev/dsp will reset the volume back to 0 db gain/attenuation.
Setting this to 0 will preserve its settings across device
closing/opening.
- hw.snd.vpc_reset (default: 0). Panic/reset button to reset all
volume settings back to 0 db.
- hw.snd.vpc_0db (default: 45). 0 db relative to linear mixer value.
2 High quality fixed-point Bandlimited SINC sampling rate converter,
based on Julius O'Smith's Digital Audio Resampling -
http://ccrma.stanford.edu/~jos/resample/. It includes a filter design
script written in awk (the clumsiest joke I've ever written)
- 100% 32bit fixed-point, 64bit accumulator.
- Possibly among the fastest (if not fastest) of its kind.
- Resampling quality is tunable, either runtime or during kernel
compilation (FEEDER_RATE_PRESETS).
- Quality can be further customized during kernel compilation by
defining FEEDER_RATE_PRESETS in /etc/make.conf.
Kernel sysctls:
- hw.snd.feeder_rate_quality.
0 - Zero-order Hold (ZOH). Fastest, bad quality.
1 - Linear Interpolation (LINEAR). Slightly slower than ZOH,
better quality but still does not eliminate aliasing.
2 - (and above) - Sinc Interpolation(SINC). Best quality. SINC
quality always start from 2 and above.
Rough quality comparisons:
- http://people.freebsd.org/~ariff/z_comparison/
3 Bit-perfect mode. Bypasses all feeder/dsp effects. Pure sound will be
directly fed into the hardware.
4 Parametric (compile time) Software Equalizer (Bass/Treble mixer). Can
be customized by defining FEEDER_EQ_PRESETS in /etc/make.conf.
5 Transparent/Adaptive Virtual Channel. Now you don't have to disable
vchans in order to make digital format pass through. It also makes
vchans more dynamic by choosing a better format/rate among all the
concurrent streams, which means that dev.pcm.X.play.vchanformat/rate
becomes sort of optional.
6 Exclusive Stream, with special open() mode O_EXCL. This will "mute"
other concurrent vchan streams and only allow a single channel with
O_EXCL set to keep producing sound.
Other Changes:
* most feeder_* stuffs are compilable in userland. Let's not
speculate whether we should go all out for it (save that for
FreeBSD 16.0-RELEASE).
* kobj signature fixups, thanks to Andriy Gapon <avg@freebsd.org>
* pull out channel mixing logic out of vchan.c and create its own
feeder_mixer for world justice.
* various refactoring here and there, for good or bad.
* activation of few more OSSv4 ioctls() (see [1] above).
* opt_snd.h for possible compile time configuration:
(mostly for debugging purposes, don't try these at home)
SND_DEBUG
SND_DIAGNOSTIC
SND_FEEDER_MULTIFORMAT
SND_FEEDER_FULL_MULTIFORMAT
SND_FEEDER_RATE_HP
SND_PCM_64
SND_OLDSTEREO
Manual page updates are on the way.
Tested by: joel, Olivier SMEDTS <olivier at gid0 d org>, too many
unsung / unnamed heroes.
2009-06-07 19:12:08 +00:00
|
|
|
SND_FORMAT(AFMT_U8, 1, 0),
|
|
|
|
SND_FORMAT(AFMT_U8, 2, 0),
|
|
|
|
/* SND_FORMAT(AFMT_S16_LE, 1, 0), */
|
|
|
|
SND_FORMAT(AFMT_S16_LE, 2, 0),
|
2000-08-20 22:18:56 +00:00
|
|
|
0
|
2000-05-31 03:21:36 +00:00
|
|
|
};
|
2001-03-24 23:10:29 +00:00
|
|
|
static struct pcmchan_caps ds_playcaps = {4000, 96000, ds_playfmt, 0};
|
2000-05-31 03:21:36 +00:00
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/* Hardware */
|
|
|
|
static u_int32_t
|
|
|
|
ds_rd(struct sc_info *sc, int regno, int size)
|
|
|
|
{
|
|
|
|
switch (size) {
|
|
|
|
case 1:
|
|
|
|
return bus_space_read_1(sc->st, sc->sh, regno);
|
|
|
|
case 2:
|
|
|
|
return bus_space_read_2(sc->st, sc->sh, regno);
|
|
|
|
case 4:
|
|
|
|
return bus_space_read_4(sc->st, sc->sh, regno);
|
|
|
|
default:
|
|
|
|
return 0xffffffff;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ds_wr(struct sc_info *sc, int regno, u_int32_t data, int size)
|
|
|
|
{
|
|
|
|
switch (size) {
|
|
|
|
case 1:
|
|
|
|
bus_space_write_1(sc->st, sc->sh, regno, data);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
bus_space_write_2(sc->st, sc->sh, regno, data);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
bus_space_write_4(sc->st, sc->sh, regno, data);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wrl(struct sc_info *sc, u_int32_t *ptr, u_int32_t val)
|
|
|
|
{
|
|
|
|
*(volatile u_int32_t *)ptr = val;
|
2000-08-28 21:02:18 +00:00
|
|
|
bus_space_barrier(sc->st, sc->sh, 0, 0, BUS_SPACE_BARRIER_WRITE);
|
2000-05-31 03:21:36 +00:00
|
|
|
}
|
|
|
|
|
2000-12-18 01:36:41 +00:00
|
|
|
/* -------------------------------------------------------------------- */
|
2000-05-31 03:21:36 +00:00
|
|
|
/* ac97 codec */
|
|
|
|
static int
|
|
|
|
ds_cdbusy(struct sc_info *sc, int sec)
|
|
|
|
{
|
|
|
|
int i, reg;
|
|
|
|
|
|
|
|
reg = sec? YDSXGR_SECSTATUSADR : YDSXGR_PRISTATUSADR;
|
|
|
|
i = YDSXG_AC97TIMEOUT;
|
|
|
|
while (i > 0) {
|
|
|
|
if (!(ds_rd(sc, reg, 2) & 0x8000))
|
|
|
|
return 0;
|
|
|
|
i--;
|
|
|
|
}
|
|
|
|
return ETIMEDOUT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static u_int32_t
|
2000-12-18 01:36:41 +00:00
|
|
|
ds_initcd(kobj_t obj, void *devinfo)
|
2000-05-31 03:21:36 +00:00
|
|
|
{
|
|
|
|
struct sc_info *sc = (struct sc_info *)devinfo;
|
|
|
|
u_int32_t x;
|
|
|
|
|
|
|
|
x = pci_read_config(sc->dev, PCIR_DSXGCTRL, 1);
|
|
|
|
if (x & 0x03) {
|
|
|
|
pci_write_config(sc->dev, PCIR_DSXGCTRL, x & ~0x03, 1);
|
|
|
|
pci_write_config(sc->dev, PCIR_DSXGCTRL, x | 0x03, 1);
|
|
|
|
pci_write_config(sc->dev, PCIR_DSXGCTRL, x & ~0x03, 1);
|
2000-06-01 03:58:27 +00:00
|
|
|
/*
|
|
|
|
* The YMF740 on some Intel motherboards requires a pretty
|
|
|
|
* hefty delay after this reset for some reason... Otherwise:
|
|
|
|
* "pcm0: ac97 codec init failed"
|
|
|
|
* Maybe this is needed for all YMF740's?
|
|
|
|
* 400ms and 500ms here seem to work, 300ms does not.
|
2000-07-30 02:33:37 +00:00
|
|
|
*
|
|
|
|
* do it for all chips -cg
|
2000-06-01 03:58:27 +00:00
|
|
|
*/
|
2000-07-30 02:33:37 +00:00
|
|
|
DELAY(500000);
|
2000-05-31 03:21:36 +00:00
|
|
|
}
|
|
|
|
|
2000-09-05 21:08:01 +00:00
|
|
|
return ds_cdbusy(sc, 0)? 0 : 1;
|
2000-05-31 03:21:36 +00:00
|
|
|
}
|
|
|
|
|
2000-12-18 01:36:41 +00:00
|
|
|
static int
|
|
|
|
ds_rdcd(kobj_t obj, void *devinfo, int regno)
|
2000-05-31 03:21:36 +00:00
|
|
|
{
|
|
|
|
struct sc_info *sc = (struct sc_info *)devinfo;
|
|
|
|
int sec, cid, i;
|
|
|
|
u_int32_t cmd, reg;
|
|
|
|
|
|
|
|
sec = regno & 0x100;
|
|
|
|
regno &= 0xff;
|
|
|
|
cid = sec? (sc->cd2id << 8) : 0;
|
|
|
|
reg = sec? YDSXGR_SECSTATUSDATA : YDSXGR_PRISTATUSDATA;
|
|
|
|
if (sec && cid == 0)
|
|
|
|
return 0xffffffff;
|
|
|
|
|
|
|
|
cmd = YDSXG_AC97READCMD | cid | regno;
|
|
|
|
ds_wr(sc, YDSXGR_AC97CMDADR, cmd, 2);
|
|
|
|
|
|
|
|
if (ds_cdbusy(sc, sec))
|
|
|
|
return 0xffffffff;
|
|
|
|
|
2000-06-01 03:58:27 +00:00
|
|
|
if (sc->type == 11 && sc->rev < 2)
|
2000-05-31 03:21:36 +00:00
|
|
|
for (i = 0; i < 600; i++)
|
|
|
|
ds_rd(sc, reg, 2);
|
|
|
|
|
|
|
|
return ds_rd(sc, reg, 2);
|
|
|
|
}
|
|
|
|
|
2000-12-18 01:36:41 +00:00
|
|
|
static int
|
|
|
|
ds_wrcd(kobj_t obj, void *devinfo, int regno, u_int32_t data)
|
2000-05-31 03:21:36 +00:00
|
|
|
{
|
|
|
|
struct sc_info *sc = (struct sc_info *)devinfo;
|
|
|
|
int sec, cid;
|
|
|
|
u_int32_t cmd;
|
|
|
|
|
|
|
|
sec = regno & 0x100;
|
|
|
|
regno &= 0xff;
|
|
|
|
cid = sec? (sc->cd2id << 8) : 0;
|
|
|
|
if (sec && cid == 0)
|
2000-12-18 01:36:41 +00:00
|
|
|
return ENXIO;
|
2000-05-31 03:21:36 +00:00
|
|
|
|
|
|
|
cmd = YDSXG_AC97WRITECMD | cid | regno;
|
|
|
|
cmd <<= 16;
|
|
|
|
cmd |= data;
|
|
|
|
ds_wr(sc, YDSXGR_AC97CMDDATA, cmd, 4);
|
|
|
|
|
2000-12-18 01:36:41 +00:00
|
|
|
return ds_cdbusy(sc, sec);
|
2000-05-31 03:21:36 +00:00
|
|
|
}
|
|
|
|
|
2000-12-18 01:36:41 +00:00
|
|
|
static kobj_method_t ds_ac97_methods[] = {
|
|
|
|
KOBJMETHOD(ac97_init, ds_initcd),
|
|
|
|
KOBJMETHOD(ac97_read, ds_rdcd),
|
|
|
|
KOBJMETHOD(ac97_write, ds_wrcd),
|
Sound Mega-commit. Expect further cleanup until code freeze.
For a slightly thorough explaination, please refer to
[1] http://people.freebsd.org/~ariff/SOUND_4.TXT.html .
Summary of changes includes:
1 Volume Per-Channel (vpc). Provides private / standalone volume control
unique per-stream pcm channel without touching master volume / pcm.
Applications can directly use SNDCTL_DSP_[GET|SET][PLAY|REC]VOL, or for
backwards compatibility, SOUND_MIXER_PCM through the opened dsp device
instead of /dev/mixer. Special "bypass" mode is enabled through
/dev/mixer which will automatically detect if the adjustment is made
through /dev/mixer and forward its request to this private volume
controller. Changes to this volume object will not interfere with
other channels.
Requirements:
- SNDCTL_DSP_[GET|SET][PLAY|REC]_VOL are newer ioctls (OSSv4) which
require specific application modifications (preferred).
- No modifications required for using bypass mode, so applications
like mplayer or xmms should work out of the box.
Kernel hints:
- hint.pcm.%d.vpc (0 = disable vpc).
Kernel sysctls:
- hw.snd.vpc_mixer_bypass (default: 1). Enable or disable /dev/mixer
bypass mode.
- hw.snd.vpc_autoreset (default: 1). By default, closing/opening
/dev/dsp will reset the volume back to 0 db gain/attenuation.
Setting this to 0 will preserve its settings across device
closing/opening.
- hw.snd.vpc_reset (default: 0). Panic/reset button to reset all
volume settings back to 0 db.
- hw.snd.vpc_0db (default: 45). 0 db relative to linear mixer value.
2 High quality fixed-point Bandlimited SINC sampling rate converter,
based on Julius O'Smith's Digital Audio Resampling -
http://ccrma.stanford.edu/~jos/resample/. It includes a filter design
script written in awk (the clumsiest joke I've ever written)
- 100% 32bit fixed-point, 64bit accumulator.
- Possibly among the fastest (if not fastest) of its kind.
- Resampling quality is tunable, either runtime or during kernel
compilation (FEEDER_RATE_PRESETS).
- Quality can be further customized during kernel compilation by
defining FEEDER_RATE_PRESETS in /etc/make.conf.
Kernel sysctls:
- hw.snd.feeder_rate_quality.
0 - Zero-order Hold (ZOH). Fastest, bad quality.
1 - Linear Interpolation (LINEAR). Slightly slower than ZOH,
better quality but still does not eliminate aliasing.
2 - (and above) - Sinc Interpolation(SINC). Best quality. SINC
quality always start from 2 and above.
Rough quality comparisons:
- http://people.freebsd.org/~ariff/z_comparison/
3 Bit-perfect mode. Bypasses all feeder/dsp effects. Pure sound will be
directly fed into the hardware.
4 Parametric (compile time) Software Equalizer (Bass/Treble mixer). Can
be customized by defining FEEDER_EQ_PRESETS in /etc/make.conf.
5 Transparent/Adaptive Virtual Channel. Now you don't have to disable
vchans in order to make digital format pass through. It also makes
vchans more dynamic by choosing a better format/rate among all the
concurrent streams, which means that dev.pcm.X.play.vchanformat/rate
becomes sort of optional.
6 Exclusive Stream, with special open() mode O_EXCL. This will "mute"
other concurrent vchan streams and only allow a single channel with
O_EXCL set to keep producing sound.
Other Changes:
* most feeder_* stuffs are compilable in userland. Let's not
speculate whether we should go all out for it (save that for
FreeBSD 16.0-RELEASE).
* kobj signature fixups, thanks to Andriy Gapon <avg@freebsd.org>
* pull out channel mixing logic out of vchan.c and create its own
feeder_mixer for world justice.
* various refactoring here and there, for good or bad.
* activation of few more OSSv4 ioctls() (see [1] above).
* opt_snd.h for possible compile time configuration:
(mostly for debugging purposes, don't try these at home)
SND_DEBUG
SND_DIAGNOSTIC
SND_FEEDER_MULTIFORMAT
SND_FEEDER_FULL_MULTIFORMAT
SND_FEEDER_RATE_HP
SND_PCM_64
SND_OLDSTEREO
Manual page updates are on the way.
Tested by: joel, Olivier SMEDTS <olivier at gid0 d org>, too many
unsung / unnamed heroes.
2009-06-07 19:12:08 +00:00
|
|
|
KOBJMETHOD_END
|
2000-12-18 01:36:41 +00:00
|
|
|
};
|
|
|
|
AC97_DECLARE(ds_ac97);
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
2000-05-31 03:21:36 +00:00
|
|
|
static void
|
|
|
|
ds_enadsp(struct sc_info *sc, int on)
|
|
|
|
{
|
|
|
|
u_int32_t v, i;
|
|
|
|
|
|
|
|
v = on? 1 : 0;
|
|
|
|
if (on) {
|
|
|
|
ds_wr(sc, YDSXGR_CONFIG, 0x00000001, 4);
|
|
|
|
} else {
|
|
|
|
if (ds_rd(sc, YDSXGR_CONFIG, 4))
|
|
|
|
ds_wr(sc, YDSXGR_CONFIG, 0x00000000, 4);
|
|
|
|
i = YDSXG_WORKBITTIMEOUT;
|
|
|
|
while (i > 0) {
|
|
|
|
if (!(ds_rd(sc, YDSXGR_CONFIG, 4) & 0x00000002))
|
|
|
|
break;
|
|
|
|
i--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static volatile struct pbank *
|
|
|
|
ds_allocpslot(struct sc_info *sc)
|
|
|
|
{
|
|
|
|
int slot;
|
|
|
|
|
|
|
|
if (sc->pslotfree > 63)
|
|
|
|
return NULL;
|
|
|
|
slot = sc->pslotfree++;
|
|
|
|
return sc->pbank[slot * 2];
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2013-07-25 09:29:48 +00:00
|
|
|
ds_initpbank(volatile struct pbank *pb, int ch, int stereo, int b16, u_int32_t rate, bus_addr_t base, u_int32_t len)
|
2000-05-31 03:21:36 +00:00
|
|
|
{
|
|
|
|
u_int32_t lv[] = {1, 1, 0, 0, 0};
|
|
|
|
u_int32_t rv[] = {1, 0, 1, 0, 0};
|
|
|
|
u_int32_t e1[] = {0, 0, 0, 0, 0};
|
|
|
|
u_int32_t e2[] = {1, 0, 0, 1, 0};
|
|
|
|
u_int32_t e3[] = {1, 0, 0, 0, 1};
|
|
|
|
int ss, i;
|
|
|
|
u_int32_t delta;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
int rate, fK, fQ;
|
|
|
|
} speedinfo[] = {
|
|
|
|
{ 100, 0x00570000, 0x35280000},
|
|
|
|
{ 2000, 0x06aa0000, 0x34a70000},
|
|
|
|
{ 8000, 0x18b20000, 0x32020000},
|
|
|
|
{11025, 0x20930000, 0x31770000},
|
|
|
|
{16000, 0x2b9a0000, 0x31390000},
|
|
|
|
{22050, 0x35a10000, 0x31c90000},
|
|
|
|
{32000, 0x3eaa0000, 0x33d00000},
|
|
|
|
/* {44100, 0x04646000, 0x370a0000},
|
|
|
|
*/ {48000, 0x40000000, 0x40000000},
|
|
|
|
};
|
|
|
|
|
|
|
|
ss = b16? 1 : 0;
|
|
|
|
ss += stereo? 1 : 0;
|
|
|
|
delta = (65536 * rate) / 48000;
|
|
|
|
i = 0;
|
|
|
|
while (i < 7 && speedinfo[i].rate < rate)
|
|
|
|
i++;
|
|
|
|
|
|
|
|
pb->Format = stereo? 0x00010000 : 0;
|
|
|
|
pb->Format |= b16? 0 : 0x80000000;
|
|
|
|
pb->Format |= (stereo && (ch == 2 || ch == 4))? 0x00000001 : 0;
|
|
|
|
pb->LoopDefault = 0;
|
2009-02-09 22:59:22 +00:00
|
|
|
pb->PgBase = base;
|
2000-05-31 03:21:36 +00:00
|
|
|
pb->PgLoop = 0;
|
|
|
|
pb->PgLoopEnd = len >> ss;
|
|
|
|
pb->PgLoopFrac = 0;
|
|
|
|
pb->Status = 0;
|
|
|
|
pb->NumOfFrames = 0;
|
|
|
|
pb->LoopCount = 0;
|
|
|
|
pb->PgStart = 0;
|
|
|
|
pb->PgStartFrac = 0;
|
|
|
|
pb->PgDelta = pb->PgDeltaEnd = delta << 12;
|
|
|
|
pb->LpfQ = speedinfo[i].fQ;
|
|
|
|
pb->LpfK = pb->LpfKEnd = speedinfo[i].fK;
|
|
|
|
pb->LpfD1 = pb->LpfD2 = 0;
|
|
|
|
pb->EgGain = pb->EgGainEnd = 0x40000000;
|
|
|
|
pb->LchGain = pb->LchGainEnd = lv[ch] * 0x40000000;
|
|
|
|
pb->RchGain = pb->RchGainEnd = rv[ch] * 0x40000000;
|
|
|
|
pb->Effect1Gain = pb->Effect1GainEnd = e1[ch] * 0x40000000;
|
|
|
|
pb->Effect2Gain = pb->Effect2GainEnd = e2[ch] * 0x40000000;
|
|
|
|
pb->Effect3Gain = pb->Effect3GainEnd = e3[ch] * 0x40000000;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ds_enapslot(struct sc_info *sc, int slot, int go)
|
|
|
|
{
|
|
|
|
wrl(sc, &sc->pbase[slot + 1], go? (sc->pbankbase + 2 * slot * sc->pbanksize) : 0);
|
|
|
|
/* printf("pbase[%d] = 0x%x\n", slot + 1, go? (sc->pbankbase + 2 * slot * sc->pbanksize) : 0); */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-06-06 22:34:09 +00:00
|
|
|
ds_setuppch(struct sc_pchinfo *ch)
|
2000-05-31 03:21:36 +00:00
|
|
|
{
|
2000-06-06 22:34:09 +00:00
|
|
|
int stereo, b16, c, sz;
|
2003-02-20 17:31:12 +00:00
|
|
|
bus_addr_t addr;
|
2000-05-31 03:21:36 +00:00
|
|
|
|
Sound Mega-commit. Expect further cleanup until code freeze.
For a slightly thorough explaination, please refer to
[1] http://people.freebsd.org/~ariff/SOUND_4.TXT.html .
Summary of changes includes:
1 Volume Per-Channel (vpc). Provides private / standalone volume control
unique per-stream pcm channel without touching master volume / pcm.
Applications can directly use SNDCTL_DSP_[GET|SET][PLAY|REC]VOL, or for
backwards compatibility, SOUND_MIXER_PCM through the opened dsp device
instead of /dev/mixer. Special "bypass" mode is enabled through
/dev/mixer which will automatically detect if the adjustment is made
through /dev/mixer and forward its request to this private volume
controller. Changes to this volume object will not interfere with
other channels.
Requirements:
- SNDCTL_DSP_[GET|SET][PLAY|REC]_VOL are newer ioctls (OSSv4) which
require specific application modifications (preferred).
- No modifications required for using bypass mode, so applications
like mplayer or xmms should work out of the box.
Kernel hints:
- hint.pcm.%d.vpc (0 = disable vpc).
Kernel sysctls:
- hw.snd.vpc_mixer_bypass (default: 1). Enable or disable /dev/mixer
bypass mode.
- hw.snd.vpc_autoreset (default: 1). By default, closing/opening
/dev/dsp will reset the volume back to 0 db gain/attenuation.
Setting this to 0 will preserve its settings across device
closing/opening.
- hw.snd.vpc_reset (default: 0). Panic/reset button to reset all
volume settings back to 0 db.
- hw.snd.vpc_0db (default: 45). 0 db relative to linear mixer value.
2 High quality fixed-point Bandlimited SINC sampling rate converter,
based on Julius O'Smith's Digital Audio Resampling -
http://ccrma.stanford.edu/~jos/resample/. It includes a filter design
script written in awk (the clumsiest joke I've ever written)
- 100% 32bit fixed-point, 64bit accumulator.
- Possibly among the fastest (if not fastest) of its kind.
- Resampling quality is tunable, either runtime or during kernel
compilation (FEEDER_RATE_PRESETS).
- Quality can be further customized during kernel compilation by
defining FEEDER_RATE_PRESETS in /etc/make.conf.
Kernel sysctls:
- hw.snd.feeder_rate_quality.
0 - Zero-order Hold (ZOH). Fastest, bad quality.
1 - Linear Interpolation (LINEAR). Slightly slower than ZOH,
better quality but still does not eliminate aliasing.
2 - (and above) - Sinc Interpolation(SINC). Best quality. SINC
quality always start from 2 and above.
Rough quality comparisons:
- http://people.freebsd.org/~ariff/z_comparison/
3 Bit-perfect mode. Bypasses all feeder/dsp effects. Pure sound will be
directly fed into the hardware.
4 Parametric (compile time) Software Equalizer (Bass/Treble mixer). Can
be customized by defining FEEDER_EQ_PRESETS in /etc/make.conf.
5 Transparent/Adaptive Virtual Channel. Now you don't have to disable
vchans in order to make digital format pass through. It also makes
vchans more dynamic by choosing a better format/rate among all the
concurrent streams, which means that dev.pcm.X.play.vchanformat/rate
becomes sort of optional.
6 Exclusive Stream, with special open() mode O_EXCL. This will "mute"
other concurrent vchan streams and only allow a single channel with
O_EXCL set to keep producing sound.
Other Changes:
* most feeder_* stuffs are compilable in userland. Let's not
speculate whether we should go all out for it (save that for
FreeBSD 16.0-RELEASE).
* kobj signature fixups, thanks to Andriy Gapon <avg@freebsd.org>
* pull out channel mixing logic out of vchan.c and create its own
feeder_mixer for world justice.
* various refactoring here and there, for good or bad.
* activation of few more OSSv4 ioctls() (see [1] above).
* opt_snd.h for possible compile time configuration:
(mostly for debugging purposes, don't try these at home)
SND_DEBUG
SND_DIAGNOSTIC
SND_FEEDER_MULTIFORMAT
SND_FEEDER_FULL_MULTIFORMAT
SND_FEEDER_RATE_HP
SND_PCM_64
SND_OLDSTEREO
Manual page updates are on the way.
Tested by: joel, Olivier SMEDTS <olivier at gid0 d org>, too many
unsung / unnamed heroes.
2009-06-07 19:12:08 +00:00
|
|
|
stereo = (AFMT_CHANNEL(ch->fmt) > 1)? 1 : 0;
|
2000-05-31 03:21:36 +00:00
|
|
|
b16 = (ch->fmt & AFMT_16BIT)? 1 : 0;
|
|
|
|
c = stereo? 1 : 0;
|
2003-02-20 17:31:12 +00:00
|
|
|
addr = sndbuf_getbufaddr(ch->buffer);
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
sz = sndbuf_getsize(ch->buffer);
|
2000-05-31 03:21:36 +00:00
|
|
|
|
2003-02-20 17:31:12 +00:00
|
|
|
ds_initpbank(ch->lslot, c, stereo, b16, ch->spd, addr, sz);
|
|
|
|
ds_initpbank(ch->lslot + 1, c, stereo, b16, ch->spd, addr, sz);
|
|
|
|
ds_initpbank(ch->rslot, 2, stereo, b16, ch->spd, addr, sz);
|
|
|
|
ds_initpbank(ch->rslot + 1, 2, stereo, b16, ch->spd, addr, sz);
|
2000-05-31 03:21:36 +00:00
|
|
|
}
|
|
|
|
|
2000-06-06 22:34:09 +00:00
|
|
|
static void
|
|
|
|
ds_setuprch(struct sc_rchinfo *ch)
|
|
|
|
{
|
|
|
|
struct sc_info *sc = ch->parent;
|
|
|
|
int stereo, b16, i, sz, pri;
|
|
|
|
u_int32_t x, y;
|
2003-02-20 17:31:12 +00:00
|
|
|
bus_addr_t addr;
|
2000-06-06 22:34:09 +00:00
|
|
|
|
Sound Mega-commit. Expect further cleanup until code freeze.
For a slightly thorough explaination, please refer to
[1] http://people.freebsd.org/~ariff/SOUND_4.TXT.html .
Summary of changes includes:
1 Volume Per-Channel (vpc). Provides private / standalone volume control
unique per-stream pcm channel without touching master volume / pcm.
Applications can directly use SNDCTL_DSP_[GET|SET][PLAY|REC]VOL, or for
backwards compatibility, SOUND_MIXER_PCM through the opened dsp device
instead of /dev/mixer. Special "bypass" mode is enabled through
/dev/mixer which will automatically detect if the adjustment is made
through /dev/mixer and forward its request to this private volume
controller. Changes to this volume object will not interfere with
other channels.
Requirements:
- SNDCTL_DSP_[GET|SET][PLAY|REC]_VOL are newer ioctls (OSSv4) which
require specific application modifications (preferred).
- No modifications required for using bypass mode, so applications
like mplayer or xmms should work out of the box.
Kernel hints:
- hint.pcm.%d.vpc (0 = disable vpc).
Kernel sysctls:
- hw.snd.vpc_mixer_bypass (default: 1). Enable or disable /dev/mixer
bypass mode.
- hw.snd.vpc_autoreset (default: 1). By default, closing/opening
/dev/dsp will reset the volume back to 0 db gain/attenuation.
Setting this to 0 will preserve its settings across device
closing/opening.
- hw.snd.vpc_reset (default: 0). Panic/reset button to reset all
volume settings back to 0 db.
- hw.snd.vpc_0db (default: 45). 0 db relative to linear mixer value.
2 High quality fixed-point Bandlimited SINC sampling rate converter,
based on Julius O'Smith's Digital Audio Resampling -
http://ccrma.stanford.edu/~jos/resample/. It includes a filter design
script written in awk (the clumsiest joke I've ever written)
- 100% 32bit fixed-point, 64bit accumulator.
- Possibly among the fastest (if not fastest) of its kind.
- Resampling quality is tunable, either runtime or during kernel
compilation (FEEDER_RATE_PRESETS).
- Quality can be further customized during kernel compilation by
defining FEEDER_RATE_PRESETS in /etc/make.conf.
Kernel sysctls:
- hw.snd.feeder_rate_quality.
0 - Zero-order Hold (ZOH). Fastest, bad quality.
1 - Linear Interpolation (LINEAR). Slightly slower than ZOH,
better quality but still does not eliminate aliasing.
2 - (and above) - Sinc Interpolation(SINC). Best quality. SINC
quality always start from 2 and above.
Rough quality comparisons:
- http://people.freebsd.org/~ariff/z_comparison/
3 Bit-perfect mode. Bypasses all feeder/dsp effects. Pure sound will be
directly fed into the hardware.
4 Parametric (compile time) Software Equalizer (Bass/Treble mixer). Can
be customized by defining FEEDER_EQ_PRESETS in /etc/make.conf.
5 Transparent/Adaptive Virtual Channel. Now you don't have to disable
vchans in order to make digital format pass through. It also makes
vchans more dynamic by choosing a better format/rate among all the
concurrent streams, which means that dev.pcm.X.play.vchanformat/rate
becomes sort of optional.
6 Exclusive Stream, with special open() mode O_EXCL. This will "mute"
other concurrent vchan streams and only allow a single channel with
O_EXCL set to keep producing sound.
Other Changes:
* most feeder_* stuffs are compilable in userland. Let's not
speculate whether we should go all out for it (save that for
FreeBSD 16.0-RELEASE).
* kobj signature fixups, thanks to Andriy Gapon <avg@freebsd.org>
* pull out channel mixing logic out of vchan.c and create its own
feeder_mixer for world justice.
* various refactoring here and there, for good or bad.
* activation of few more OSSv4 ioctls() (see [1] above).
* opt_snd.h for possible compile time configuration:
(mostly for debugging purposes, don't try these at home)
SND_DEBUG
SND_DIAGNOSTIC
SND_FEEDER_MULTIFORMAT
SND_FEEDER_FULL_MULTIFORMAT
SND_FEEDER_RATE_HP
SND_PCM_64
SND_OLDSTEREO
Manual page updates are on the way.
Tested by: joel, Olivier SMEDTS <olivier at gid0 d org>, too many
unsung / unnamed heroes.
2009-06-07 19:12:08 +00:00
|
|
|
stereo = (AFMT_CHANNEL(ch->fmt) > 1)? 1 : 0;
|
2000-06-06 22:34:09 +00:00
|
|
|
b16 = (ch->fmt & AFMT_16BIT)? 1 : 0;
|
2003-02-20 17:31:12 +00:00
|
|
|
addr = sndbuf_getbufaddr(ch->buffer);
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
sz = sndbuf_getsize(ch->buffer);
|
2000-06-06 22:34:09 +00:00
|
|
|
pri = (ch->num == DS1_RECPRIMARY)? 1 : 0;
|
|
|
|
|
|
|
|
for (i = 0; i < 2; i++) {
|
2003-02-20 17:31:12 +00:00
|
|
|
ch->slot[i].PgBase = addr;
|
2000-06-06 22:34:09 +00:00
|
|
|
ch->slot[i].PgLoopEnd = sz;
|
|
|
|
ch->slot[i].PgStart = 0;
|
|
|
|
ch->slot[i].NumOfLoops = 0;
|
|
|
|
}
|
|
|
|
x = (b16? 0x00 : 0x01) | (stereo? 0x02 : 0x00);
|
|
|
|
y = (48000 * 4096) / ch->spd;
|
|
|
|
y--;
|
|
|
|
/* printf("pri = %d, x = %d, y = %d\n", pri, x, y); */
|
|
|
|
ds_wr(sc, pri? YDSXGR_ADCFORMAT : YDSXGR_RECFORMAT, x, 4);
|
|
|
|
ds_wr(sc, pri? YDSXGR_ADCSLOTSR : YDSXGR_RECSLOTSR, y, 4);
|
|
|
|
}
|
|
|
|
|
2000-12-18 01:36:41 +00:00
|
|
|
/* -------------------------------------------------------------------- */
|
2000-06-06 22:34:09 +00:00
|
|
|
/* play channel interface */
|
|
|
|
static void *
|
2001-03-24 23:10:29 +00:00
|
|
|
ds1pchan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir)
|
2000-05-31 03:21:36 +00:00
|
|
|
{
|
|
|
|
struct sc_info *sc = devinfo;
|
2000-06-06 22:34:09 +00:00
|
|
|
struct sc_pchinfo *ch;
|
|
|
|
|
|
|
|
KASSERT(dir == PCMDIR_PLAY, ("ds1pchan_init: bad direction"));
|
2000-05-31 03:21:36 +00:00
|
|
|
|
2000-06-06 22:34:09 +00:00
|
|
|
ch = &sc->pch[sc->pchn++];
|
2000-05-31 03:21:36 +00:00
|
|
|
ch->buffer = b;
|
|
|
|
ch->parent = sc;
|
|
|
|
ch->channel = c;
|
2000-06-06 22:34:09 +00:00
|
|
|
ch->dir = dir;
|
Sound Mega-commit. Expect further cleanup until code freeze.
For a slightly thorough explaination, please refer to
[1] http://people.freebsd.org/~ariff/SOUND_4.TXT.html .
Summary of changes includes:
1 Volume Per-Channel (vpc). Provides private / standalone volume control
unique per-stream pcm channel without touching master volume / pcm.
Applications can directly use SNDCTL_DSP_[GET|SET][PLAY|REC]VOL, or for
backwards compatibility, SOUND_MIXER_PCM through the opened dsp device
instead of /dev/mixer. Special "bypass" mode is enabled through
/dev/mixer which will automatically detect if the adjustment is made
through /dev/mixer and forward its request to this private volume
controller. Changes to this volume object will not interfere with
other channels.
Requirements:
- SNDCTL_DSP_[GET|SET][PLAY|REC]_VOL are newer ioctls (OSSv4) which
require specific application modifications (preferred).
- No modifications required for using bypass mode, so applications
like mplayer or xmms should work out of the box.
Kernel hints:
- hint.pcm.%d.vpc (0 = disable vpc).
Kernel sysctls:
- hw.snd.vpc_mixer_bypass (default: 1). Enable or disable /dev/mixer
bypass mode.
- hw.snd.vpc_autoreset (default: 1). By default, closing/opening
/dev/dsp will reset the volume back to 0 db gain/attenuation.
Setting this to 0 will preserve its settings across device
closing/opening.
- hw.snd.vpc_reset (default: 0). Panic/reset button to reset all
volume settings back to 0 db.
- hw.snd.vpc_0db (default: 45). 0 db relative to linear mixer value.
2 High quality fixed-point Bandlimited SINC sampling rate converter,
based on Julius O'Smith's Digital Audio Resampling -
http://ccrma.stanford.edu/~jos/resample/. It includes a filter design
script written in awk (the clumsiest joke I've ever written)
- 100% 32bit fixed-point, 64bit accumulator.
- Possibly among the fastest (if not fastest) of its kind.
- Resampling quality is tunable, either runtime or during kernel
compilation (FEEDER_RATE_PRESETS).
- Quality can be further customized during kernel compilation by
defining FEEDER_RATE_PRESETS in /etc/make.conf.
Kernel sysctls:
- hw.snd.feeder_rate_quality.
0 - Zero-order Hold (ZOH). Fastest, bad quality.
1 - Linear Interpolation (LINEAR). Slightly slower than ZOH,
better quality but still does not eliminate aliasing.
2 - (and above) - Sinc Interpolation(SINC). Best quality. SINC
quality always start from 2 and above.
Rough quality comparisons:
- http://people.freebsd.org/~ariff/z_comparison/
3 Bit-perfect mode. Bypasses all feeder/dsp effects. Pure sound will be
directly fed into the hardware.
4 Parametric (compile time) Software Equalizer (Bass/Treble mixer). Can
be customized by defining FEEDER_EQ_PRESETS in /etc/make.conf.
5 Transparent/Adaptive Virtual Channel. Now you don't have to disable
vchans in order to make digital format pass through. It also makes
vchans more dynamic by choosing a better format/rate among all the
concurrent streams, which means that dev.pcm.X.play.vchanformat/rate
becomes sort of optional.
6 Exclusive Stream, with special open() mode O_EXCL. This will "mute"
other concurrent vchan streams and only allow a single channel with
O_EXCL set to keep producing sound.
Other Changes:
* most feeder_* stuffs are compilable in userland. Let's not
speculate whether we should go all out for it (save that for
FreeBSD 16.0-RELEASE).
* kobj signature fixups, thanks to Andriy Gapon <avg@freebsd.org>
* pull out channel mixing logic out of vchan.c and create its own
feeder_mixer for world justice.
* various refactoring here and there, for good or bad.
* activation of few more OSSv4 ioctls() (see [1] above).
* opt_snd.h for possible compile time configuration:
(mostly for debugging purposes, don't try these at home)
SND_DEBUG
SND_DIAGNOSTIC
SND_FEEDER_MULTIFORMAT
SND_FEEDER_FULL_MULTIFORMAT
SND_FEEDER_RATE_HP
SND_PCM_64
SND_OLDSTEREO
Manual page updates are on the way.
Tested by: joel, Olivier SMEDTS <olivier at gid0 d org>, too many
unsung / unnamed heroes.
2009-06-07 19:12:08 +00:00
|
|
|
ch->fmt = SND_FORMAT(AFMT_U8, 1, 0);
|
2000-05-31 03:21:36 +00:00
|
|
|
ch->spd = 8000;
|
|
|
|
ch->run = 0;
|
2007-04-18 18:26:41 +00:00
|
|
|
if (sndbuf_alloc(ch->buffer, sc->buffer_dmat, 0, sc->bufsz) != 0)
|
2000-05-31 03:21:36 +00:00
|
|
|
return NULL;
|
|
|
|
else {
|
|
|
|
ch->lsnum = sc->pslotfree;
|
|
|
|
ch->lslot = ds_allocpslot(sc);
|
|
|
|
ch->rsnum = sc->pslotfree;
|
|
|
|
ch->rslot = ds_allocpslot(sc);
|
2000-06-06 22:34:09 +00:00
|
|
|
ds_setuppch(ch);
|
2000-05-31 03:21:36 +00:00
|
|
|
return ch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2000-12-18 01:36:41 +00:00
|
|
|
ds1pchan_setformat(kobj_t obj, void *data, u_int32_t format)
|
2000-05-31 03:21:36 +00:00
|
|
|
{
|
2000-06-06 22:34:09 +00:00
|
|
|
struct sc_pchinfo *ch = data;
|
2000-05-31 03:21:36 +00:00
|
|
|
|
|
|
|
ch->fmt = format;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
Sound Mega-commit. Expect further cleanup until code freeze.
For a slightly thorough explaination, please refer to
[1] http://people.freebsd.org/~ariff/SOUND_4.TXT.html .
Summary of changes includes:
1 Volume Per-Channel (vpc). Provides private / standalone volume control
unique per-stream pcm channel without touching master volume / pcm.
Applications can directly use SNDCTL_DSP_[GET|SET][PLAY|REC]VOL, or for
backwards compatibility, SOUND_MIXER_PCM through the opened dsp device
instead of /dev/mixer. Special "bypass" mode is enabled through
/dev/mixer which will automatically detect if the adjustment is made
through /dev/mixer and forward its request to this private volume
controller. Changes to this volume object will not interfere with
other channels.
Requirements:
- SNDCTL_DSP_[GET|SET][PLAY|REC]_VOL are newer ioctls (OSSv4) which
require specific application modifications (preferred).
- No modifications required for using bypass mode, so applications
like mplayer or xmms should work out of the box.
Kernel hints:
- hint.pcm.%d.vpc (0 = disable vpc).
Kernel sysctls:
- hw.snd.vpc_mixer_bypass (default: 1). Enable or disable /dev/mixer
bypass mode.
- hw.snd.vpc_autoreset (default: 1). By default, closing/opening
/dev/dsp will reset the volume back to 0 db gain/attenuation.
Setting this to 0 will preserve its settings across device
closing/opening.
- hw.snd.vpc_reset (default: 0). Panic/reset button to reset all
volume settings back to 0 db.
- hw.snd.vpc_0db (default: 45). 0 db relative to linear mixer value.
2 High quality fixed-point Bandlimited SINC sampling rate converter,
based on Julius O'Smith's Digital Audio Resampling -
http://ccrma.stanford.edu/~jos/resample/. It includes a filter design
script written in awk (the clumsiest joke I've ever written)
- 100% 32bit fixed-point, 64bit accumulator.
- Possibly among the fastest (if not fastest) of its kind.
- Resampling quality is tunable, either runtime or during kernel
compilation (FEEDER_RATE_PRESETS).
- Quality can be further customized during kernel compilation by
defining FEEDER_RATE_PRESETS in /etc/make.conf.
Kernel sysctls:
- hw.snd.feeder_rate_quality.
0 - Zero-order Hold (ZOH). Fastest, bad quality.
1 - Linear Interpolation (LINEAR). Slightly slower than ZOH,
better quality but still does not eliminate aliasing.
2 - (and above) - Sinc Interpolation(SINC). Best quality. SINC
quality always start from 2 and above.
Rough quality comparisons:
- http://people.freebsd.org/~ariff/z_comparison/
3 Bit-perfect mode. Bypasses all feeder/dsp effects. Pure sound will be
directly fed into the hardware.
4 Parametric (compile time) Software Equalizer (Bass/Treble mixer). Can
be customized by defining FEEDER_EQ_PRESETS in /etc/make.conf.
5 Transparent/Adaptive Virtual Channel. Now you don't have to disable
vchans in order to make digital format pass through. It also makes
vchans more dynamic by choosing a better format/rate among all the
concurrent streams, which means that dev.pcm.X.play.vchanformat/rate
becomes sort of optional.
6 Exclusive Stream, with special open() mode O_EXCL. This will "mute"
other concurrent vchan streams and only allow a single channel with
O_EXCL set to keep producing sound.
Other Changes:
* most feeder_* stuffs are compilable in userland. Let's not
speculate whether we should go all out for it (save that for
FreeBSD 16.0-RELEASE).
* kobj signature fixups, thanks to Andriy Gapon <avg@freebsd.org>
* pull out channel mixing logic out of vchan.c and create its own
feeder_mixer for world justice.
* various refactoring here and there, for good or bad.
* activation of few more OSSv4 ioctls() (see [1] above).
* opt_snd.h for possible compile time configuration:
(mostly for debugging purposes, don't try these at home)
SND_DEBUG
SND_DIAGNOSTIC
SND_FEEDER_MULTIFORMAT
SND_FEEDER_FULL_MULTIFORMAT
SND_FEEDER_RATE_HP
SND_PCM_64
SND_OLDSTEREO
Manual page updates are on the way.
Tested by: joel, Olivier SMEDTS <olivier at gid0 d org>, too many
unsung / unnamed heroes.
2009-06-07 19:12:08 +00:00
|
|
|
static u_int32_t
|
2000-12-18 01:36:41 +00:00
|
|
|
ds1pchan_setspeed(kobj_t obj, void *data, u_int32_t speed)
|
2000-05-31 03:21:36 +00:00
|
|
|
{
|
2000-06-06 22:34:09 +00:00
|
|
|
struct sc_pchinfo *ch = data;
|
2000-05-31 03:21:36 +00:00
|
|
|
|
|
|
|
ch->spd = speed;
|
|
|
|
|
|
|
|
return speed;
|
|
|
|
}
|
|
|
|
|
Sound Mega-commit. Expect further cleanup until code freeze.
For a slightly thorough explaination, please refer to
[1] http://people.freebsd.org/~ariff/SOUND_4.TXT.html .
Summary of changes includes:
1 Volume Per-Channel (vpc). Provides private / standalone volume control
unique per-stream pcm channel without touching master volume / pcm.
Applications can directly use SNDCTL_DSP_[GET|SET][PLAY|REC]VOL, or for
backwards compatibility, SOUND_MIXER_PCM through the opened dsp device
instead of /dev/mixer. Special "bypass" mode is enabled through
/dev/mixer which will automatically detect if the adjustment is made
through /dev/mixer and forward its request to this private volume
controller. Changes to this volume object will not interfere with
other channels.
Requirements:
- SNDCTL_DSP_[GET|SET][PLAY|REC]_VOL are newer ioctls (OSSv4) which
require specific application modifications (preferred).
- No modifications required for using bypass mode, so applications
like mplayer or xmms should work out of the box.
Kernel hints:
- hint.pcm.%d.vpc (0 = disable vpc).
Kernel sysctls:
- hw.snd.vpc_mixer_bypass (default: 1). Enable or disable /dev/mixer
bypass mode.
- hw.snd.vpc_autoreset (default: 1). By default, closing/opening
/dev/dsp will reset the volume back to 0 db gain/attenuation.
Setting this to 0 will preserve its settings across device
closing/opening.
- hw.snd.vpc_reset (default: 0). Panic/reset button to reset all
volume settings back to 0 db.
- hw.snd.vpc_0db (default: 45). 0 db relative to linear mixer value.
2 High quality fixed-point Bandlimited SINC sampling rate converter,
based on Julius O'Smith's Digital Audio Resampling -
http://ccrma.stanford.edu/~jos/resample/. It includes a filter design
script written in awk (the clumsiest joke I've ever written)
- 100% 32bit fixed-point, 64bit accumulator.
- Possibly among the fastest (if not fastest) of its kind.
- Resampling quality is tunable, either runtime or during kernel
compilation (FEEDER_RATE_PRESETS).
- Quality can be further customized during kernel compilation by
defining FEEDER_RATE_PRESETS in /etc/make.conf.
Kernel sysctls:
- hw.snd.feeder_rate_quality.
0 - Zero-order Hold (ZOH). Fastest, bad quality.
1 - Linear Interpolation (LINEAR). Slightly slower than ZOH,
better quality but still does not eliminate aliasing.
2 - (and above) - Sinc Interpolation(SINC). Best quality. SINC
quality always start from 2 and above.
Rough quality comparisons:
- http://people.freebsd.org/~ariff/z_comparison/
3 Bit-perfect mode. Bypasses all feeder/dsp effects. Pure sound will be
directly fed into the hardware.
4 Parametric (compile time) Software Equalizer (Bass/Treble mixer). Can
be customized by defining FEEDER_EQ_PRESETS in /etc/make.conf.
5 Transparent/Adaptive Virtual Channel. Now you don't have to disable
vchans in order to make digital format pass through. It also makes
vchans more dynamic by choosing a better format/rate among all the
concurrent streams, which means that dev.pcm.X.play.vchanformat/rate
becomes sort of optional.
6 Exclusive Stream, with special open() mode O_EXCL. This will "mute"
other concurrent vchan streams and only allow a single channel with
O_EXCL set to keep producing sound.
Other Changes:
* most feeder_* stuffs are compilable in userland. Let's not
speculate whether we should go all out for it (save that for
FreeBSD 16.0-RELEASE).
* kobj signature fixups, thanks to Andriy Gapon <avg@freebsd.org>
* pull out channel mixing logic out of vchan.c and create its own
feeder_mixer for world justice.
* various refactoring here and there, for good or bad.
* activation of few more OSSv4 ioctls() (see [1] above).
* opt_snd.h for possible compile time configuration:
(mostly for debugging purposes, don't try these at home)
SND_DEBUG
SND_DIAGNOSTIC
SND_FEEDER_MULTIFORMAT
SND_FEEDER_FULL_MULTIFORMAT
SND_FEEDER_RATE_HP
SND_PCM_64
SND_OLDSTEREO
Manual page updates are on the way.
Tested by: joel, Olivier SMEDTS <olivier at gid0 d org>, too many
unsung / unnamed heroes.
2009-06-07 19:12:08 +00:00
|
|
|
static u_int32_t
|
2000-12-18 01:36:41 +00:00
|
|
|
ds1pchan_setblocksize(kobj_t obj, void *data, u_int32_t blocksize)
|
2000-05-31 03:21:36 +00:00
|
|
|
{
|
2000-12-25 01:42:13 +00:00
|
|
|
struct sc_pchinfo *ch = data;
|
2003-08-23 13:00:48 +00:00
|
|
|
struct sc_info *sc = ch->parent;
|
2000-12-25 01:42:13 +00:00
|
|
|
int drate;
|
|
|
|
|
|
|
|
/* irq rate is fixed at 187.5hz */
|
Sound Mega-commit. Expect further cleanup until code freeze.
For a slightly thorough explaination, please refer to
[1] http://people.freebsd.org/~ariff/SOUND_4.TXT.html .
Summary of changes includes:
1 Volume Per-Channel (vpc). Provides private / standalone volume control
unique per-stream pcm channel without touching master volume / pcm.
Applications can directly use SNDCTL_DSP_[GET|SET][PLAY|REC]VOL, or for
backwards compatibility, SOUND_MIXER_PCM through the opened dsp device
instead of /dev/mixer. Special "bypass" mode is enabled through
/dev/mixer which will automatically detect if the adjustment is made
through /dev/mixer and forward its request to this private volume
controller. Changes to this volume object will not interfere with
other channels.
Requirements:
- SNDCTL_DSP_[GET|SET][PLAY|REC]_VOL are newer ioctls (OSSv4) which
require specific application modifications (preferred).
- No modifications required for using bypass mode, so applications
like mplayer or xmms should work out of the box.
Kernel hints:
- hint.pcm.%d.vpc (0 = disable vpc).
Kernel sysctls:
- hw.snd.vpc_mixer_bypass (default: 1). Enable or disable /dev/mixer
bypass mode.
- hw.snd.vpc_autoreset (default: 1). By default, closing/opening
/dev/dsp will reset the volume back to 0 db gain/attenuation.
Setting this to 0 will preserve its settings across device
closing/opening.
- hw.snd.vpc_reset (default: 0). Panic/reset button to reset all
volume settings back to 0 db.
- hw.snd.vpc_0db (default: 45). 0 db relative to linear mixer value.
2 High quality fixed-point Bandlimited SINC sampling rate converter,
based on Julius O'Smith's Digital Audio Resampling -
http://ccrma.stanford.edu/~jos/resample/. It includes a filter design
script written in awk (the clumsiest joke I've ever written)
- 100% 32bit fixed-point, 64bit accumulator.
- Possibly among the fastest (if not fastest) of its kind.
- Resampling quality is tunable, either runtime or during kernel
compilation (FEEDER_RATE_PRESETS).
- Quality can be further customized during kernel compilation by
defining FEEDER_RATE_PRESETS in /etc/make.conf.
Kernel sysctls:
- hw.snd.feeder_rate_quality.
0 - Zero-order Hold (ZOH). Fastest, bad quality.
1 - Linear Interpolation (LINEAR). Slightly slower than ZOH,
better quality but still does not eliminate aliasing.
2 - (and above) - Sinc Interpolation(SINC). Best quality. SINC
quality always start from 2 and above.
Rough quality comparisons:
- http://people.freebsd.org/~ariff/z_comparison/
3 Bit-perfect mode. Bypasses all feeder/dsp effects. Pure sound will be
directly fed into the hardware.
4 Parametric (compile time) Software Equalizer (Bass/Treble mixer). Can
be customized by defining FEEDER_EQ_PRESETS in /etc/make.conf.
5 Transparent/Adaptive Virtual Channel. Now you don't have to disable
vchans in order to make digital format pass through. It also makes
vchans more dynamic by choosing a better format/rate among all the
concurrent streams, which means that dev.pcm.X.play.vchanformat/rate
becomes sort of optional.
6 Exclusive Stream, with special open() mode O_EXCL. This will "mute"
other concurrent vchan streams and only allow a single channel with
O_EXCL set to keep producing sound.
Other Changes:
* most feeder_* stuffs are compilable in userland. Let's not
speculate whether we should go all out for it (save that for
FreeBSD 16.0-RELEASE).
* kobj signature fixups, thanks to Andriy Gapon <avg@freebsd.org>
* pull out channel mixing logic out of vchan.c and create its own
feeder_mixer for world justice.
* various refactoring here and there, for good or bad.
* activation of few more OSSv4 ioctls() (see [1] above).
* opt_snd.h for possible compile time configuration:
(mostly for debugging purposes, don't try these at home)
SND_DEBUG
SND_DIAGNOSTIC
SND_FEEDER_MULTIFORMAT
SND_FEEDER_FULL_MULTIFORMAT
SND_FEEDER_RATE_HP
SND_PCM_64
SND_OLDSTEREO
Manual page updates are on the way.
Tested by: joel, Olivier SMEDTS <olivier at gid0 d org>, too many
unsung / unnamed heroes.
2009-06-07 19:12:08 +00:00
|
|
|
drate = ch->spd * sndbuf_getalign(ch->buffer);
|
2003-08-23 13:00:48 +00:00
|
|
|
blocksize = roundup2((drate << 8) / DS1_IRQHZ, 4);
|
|
|
|
sndbuf_resize(ch->buffer, sc->bufsz / blocksize, blocksize);
|
2001-01-24 01:22:53 +00:00
|
|
|
|
2000-05-31 03:21:36 +00:00
|
|
|
return blocksize;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* semantic note: must start at beginning of buffer */
|
|
|
|
static int
|
2000-12-18 01:36:41 +00:00
|
|
|
ds1pchan_trigger(kobj_t obj, void *data, int go)
|
2000-05-31 03:21:36 +00:00
|
|
|
{
|
2000-06-06 22:34:09 +00:00
|
|
|
struct sc_pchinfo *ch = data;
|
|
|
|
struct sc_info *sc = ch->parent;
|
2000-05-31 03:21:36 +00:00
|
|
|
int stereo;
|
|
|
|
|
2007-06-11 00:49:46 +00:00
|
|
|
if (!PCMTRIG_COMMON(go))
|
2000-05-31 03:21:36 +00:00
|
|
|
return 0;
|
Sound Mega-commit. Expect further cleanup until code freeze.
For a slightly thorough explaination, please refer to
[1] http://people.freebsd.org/~ariff/SOUND_4.TXT.html .
Summary of changes includes:
1 Volume Per-Channel (vpc). Provides private / standalone volume control
unique per-stream pcm channel without touching master volume / pcm.
Applications can directly use SNDCTL_DSP_[GET|SET][PLAY|REC]VOL, or for
backwards compatibility, SOUND_MIXER_PCM through the opened dsp device
instead of /dev/mixer. Special "bypass" mode is enabled through
/dev/mixer which will automatically detect if the adjustment is made
through /dev/mixer and forward its request to this private volume
controller. Changes to this volume object will not interfere with
other channels.
Requirements:
- SNDCTL_DSP_[GET|SET][PLAY|REC]_VOL are newer ioctls (OSSv4) which
require specific application modifications (preferred).
- No modifications required for using bypass mode, so applications
like mplayer or xmms should work out of the box.
Kernel hints:
- hint.pcm.%d.vpc (0 = disable vpc).
Kernel sysctls:
- hw.snd.vpc_mixer_bypass (default: 1). Enable or disable /dev/mixer
bypass mode.
- hw.snd.vpc_autoreset (default: 1). By default, closing/opening
/dev/dsp will reset the volume back to 0 db gain/attenuation.
Setting this to 0 will preserve its settings across device
closing/opening.
- hw.snd.vpc_reset (default: 0). Panic/reset button to reset all
volume settings back to 0 db.
- hw.snd.vpc_0db (default: 45). 0 db relative to linear mixer value.
2 High quality fixed-point Bandlimited SINC sampling rate converter,
based on Julius O'Smith's Digital Audio Resampling -
http://ccrma.stanford.edu/~jos/resample/. It includes a filter design
script written in awk (the clumsiest joke I've ever written)
- 100% 32bit fixed-point, 64bit accumulator.
- Possibly among the fastest (if not fastest) of its kind.
- Resampling quality is tunable, either runtime or during kernel
compilation (FEEDER_RATE_PRESETS).
- Quality can be further customized during kernel compilation by
defining FEEDER_RATE_PRESETS in /etc/make.conf.
Kernel sysctls:
- hw.snd.feeder_rate_quality.
0 - Zero-order Hold (ZOH). Fastest, bad quality.
1 - Linear Interpolation (LINEAR). Slightly slower than ZOH,
better quality but still does not eliminate aliasing.
2 - (and above) - Sinc Interpolation(SINC). Best quality. SINC
quality always start from 2 and above.
Rough quality comparisons:
- http://people.freebsd.org/~ariff/z_comparison/
3 Bit-perfect mode. Bypasses all feeder/dsp effects. Pure sound will be
directly fed into the hardware.
4 Parametric (compile time) Software Equalizer (Bass/Treble mixer). Can
be customized by defining FEEDER_EQ_PRESETS in /etc/make.conf.
5 Transparent/Adaptive Virtual Channel. Now you don't have to disable
vchans in order to make digital format pass through. It also makes
vchans more dynamic by choosing a better format/rate among all the
concurrent streams, which means that dev.pcm.X.play.vchanformat/rate
becomes sort of optional.
6 Exclusive Stream, with special open() mode O_EXCL. This will "mute"
other concurrent vchan streams and only allow a single channel with
O_EXCL set to keep producing sound.
Other Changes:
* most feeder_* stuffs are compilable in userland. Let's not
speculate whether we should go all out for it (save that for
FreeBSD 16.0-RELEASE).
* kobj signature fixups, thanks to Andriy Gapon <avg@freebsd.org>
* pull out channel mixing logic out of vchan.c and create its own
feeder_mixer for world justice.
* various refactoring here and there, for good or bad.
* activation of few more OSSv4 ioctls() (see [1] above).
* opt_snd.h for possible compile time configuration:
(mostly for debugging purposes, don't try these at home)
SND_DEBUG
SND_DIAGNOSTIC
SND_FEEDER_MULTIFORMAT
SND_FEEDER_FULL_MULTIFORMAT
SND_FEEDER_RATE_HP
SND_PCM_64
SND_OLDSTEREO
Manual page updates are on the way.
Tested by: joel, Olivier SMEDTS <olivier at gid0 d org>, too many
unsung / unnamed heroes.
2009-06-07 19:12:08 +00:00
|
|
|
stereo = (AFMT_CHANNEL(ch->fmt) > 1)? 1 : 0;
|
2000-05-31 03:21:36 +00:00
|
|
|
if (go == PCMTRIG_START) {
|
|
|
|
ch->run = 1;
|
2000-06-06 22:34:09 +00:00
|
|
|
ds_setuppch(ch);
|
2000-05-31 03:21:36 +00:00
|
|
|
ds_enapslot(sc, ch->lsnum, 1);
|
|
|
|
ds_enapslot(sc, ch->rsnum, stereo);
|
2001-03-24 23:10:29 +00:00
|
|
|
snd_mtxlock(sc->lock);
|
2000-05-31 03:21:36 +00:00
|
|
|
ds_wr(sc, YDSXGR_MODE, 0x00000003, 4);
|
2001-03-24 23:10:29 +00:00
|
|
|
snd_mtxunlock(sc->lock);
|
2000-05-31 03:21:36 +00:00
|
|
|
} else {
|
|
|
|
ch->run = 0;
|
2000-06-06 22:34:09 +00:00
|
|
|
/* ds_setuppch(ch); */
|
2000-05-31 03:21:36 +00:00
|
|
|
ds_enapslot(sc, ch->lsnum, 0);
|
|
|
|
ds_enapslot(sc, ch->rsnum, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
Sound Mega-commit. Expect further cleanup until code freeze.
For a slightly thorough explaination, please refer to
[1] http://people.freebsd.org/~ariff/SOUND_4.TXT.html .
Summary of changes includes:
1 Volume Per-Channel (vpc). Provides private / standalone volume control
unique per-stream pcm channel without touching master volume / pcm.
Applications can directly use SNDCTL_DSP_[GET|SET][PLAY|REC]VOL, or for
backwards compatibility, SOUND_MIXER_PCM through the opened dsp device
instead of /dev/mixer. Special "bypass" mode is enabled through
/dev/mixer which will automatically detect if the adjustment is made
through /dev/mixer and forward its request to this private volume
controller. Changes to this volume object will not interfere with
other channels.
Requirements:
- SNDCTL_DSP_[GET|SET][PLAY|REC]_VOL are newer ioctls (OSSv4) which
require specific application modifications (preferred).
- No modifications required for using bypass mode, so applications
like mplayer or xmms should work out of the box.
Kernel hints:
- hint.pcm.%d.vpc (0 = disable vpc).
Kernel sysctls:
- hw.snd.vpc_mixer_bypass (default: 1). Enable or disable /dev/mixer
bypass mode.
- hw.snd.vpc_autoreset (default: 1). By default, closing/opening
/dev/dsp will reset the volume back to 0 db gain/attenuation.
Setting this to 0 will preserve its settings across device
closing/opening.
- hw.snd.vpc_reset (default: 0). Panic/reset button to reset all
volume settings back to 0 db.
- hw.snd.vpc_0db (default: 45). 0 db relative to linear mixer value.
2 High quality fixed-point Bandlimited SINC sampling rate converter,
based on Julius O'Smith's Digital Audio Resampling -
http://ccrma.stanford.edu/~jos/resample/. It includes a filter design
script written in awk (the clumsiest joke I've ever written)
- 100% 32bit fixed-point, 64bit accumulator.
- Possibly among the fastest (if not fastest) of its kind.
- Resampling quality is tunable, either runtime or during kernel
compilation (FEEDER_RATE_PRESETS).
- Quality can be further customized during kernel compilation by
defining FEEDER_RATE_PRESETS in /etc/make.conf.
Kernel sysctls:
- hw.snd.feeder_rate_quality.
0 - Zero-order Hold (ZOH). Fastest, bad quality.
1 - Linear Interpolation (LINEAR). Slightly slower than ZOH,
better quality but still does not eliminate aliasing.
2 - (and above) - Sinc Interpolation(SINC). Best quality. SINC
quality always start from 2 and above.
Rough quality comparisons:
- http://people.freebsd.org/~ariff/z_comparison/
3 Bit-perfect mode. Bypasses all feeder/dsp effects. Pure sound will be
directly fed into the hardware.
4 Parametric (compile time) Software Equalizer (Bass/Treble mixer). Can
be customized by defining FEEDER_EQ_PRESETS in /etc/make.conf.
5 Transparent/Adaptive Virtual Channel. Now you don't have to disable
vchans in order to make digital format pass through. It also makes
vchans more dynamic by choosing a better format/rate among all the
concurrent streams, which means that dev.pcm.X.play.vchanformat/rate
becomes sort of optional.
6 Exclusive Stream, with special open() mode O_EXCL. This will "mute"
other concurrent vchan streams and only allow a single channel with
O_EXCL set to keep producing sound.
Other Changes:
* most feeder_* stuffs are compilable in userland. Let's not
speculate whether we should go all out for it (save that for
FreeBSD 16.0-RELEASE).
* kobj signature fixups, thanks to Andriy Gapon <avg@freebsd.org>
* pull out channel mixing logic out of vchan.c and create its own
feeder_mixer for world justice.
* various refactoring here and there, for good or bad.
* activation of few more OSSv4 ioctls() (see [1] above).
* opt_snd.h for possible compile time configuration:
(mostly for debugging purposes, don't try these at home)
SND_DEBUG
SND_DIAGNOSTIC
SND_FEEDER_MULTIFORMAT
SND_FEEDER_FULL_MULTIFORMAT
SND_FEEDER_RATE_HP
SND_PCM_64
SND_OLDSTEREO
Manual page updates are on the way.
Tested by: joel, Olivier SMEDTS <olivier at gid0 d org>, too many
unsung / unnamed heroes.
2009-06-07 19:12:08 +00:00
|
|
|
static u_int32_t
|
2000-12-18 01:36:41 +00:00
|
|
|
ds1pchan_getptr(kobj_t obj, void *data)
|
2000-05-31 03:21:36 +00:00
|
|
|
{
|
2000-06-06 22:34:09 +00:00
|
|
|
struct sc_pchinfo *ch = data;
|
2000-05-31 03:21:36 +00:00
|
|
|
struct sc_info *sc = ch->parent;
|
|
|
|
volatile struct pbank *bank;
|
|
|
|
int ss;
|
|
|
|
u_int32_t ptr;
|
|
|
|
|
Sound Mega-commit. Expect further cleanup until code freeze.
For a slightly thorough explaination, please refer to
[1] http://people.freebsd.org/~ariff/SOUND_4.TXT.html .
Summary of changes includes:
1 Volume Per-Channel (vpc). Provides private / standalone volume control
unique per-stream pcm channel without touching master volume / pcm.
Applications can directly use SNDCTL_DSP_[GET|SET][PLAY|REC]VOL, or for
backwards compatibility, SOUND_MIXER_PCM through the opened dsp device
instead of /dev/mixer. Special "bypass" mode is enabled through
/dev/mixer which will automatically detect if the adjustment is made
through /dev/mixer and forward its request to this private volume
controller. Changes to this volume object will not interfere with
other channels.
Requirements:
- SNDCTL_DSP_[GET|SET][PLAY|REC]_VOL are newer ioctls (OSSv4) which
require specific application modifications (preferred).
- No modifications required for using bypass mode, so applications
like mplayer or xmms should work out of the box.
Kernel hints:
- hint.pcm.%d.vpc (0 = disable vpc).
Kernel sysctls:
- hw.snd.vpc_mixer_bypass (default: 1). Enable or disable /dev/mixer
bypass mode.
- hw.snd.vpc_autoreset (default: 1). By default, closing/opening
/dev/dsp will reset the volume back to 0 db gain/attenuation.
Setting this to 0 will preserve its settings across device
closing/opening.
- hw.snd.vpc_reset (default: 0). Panic/reset button to reset all
volume settings back to 0 db.
- hw.snd.vpc_0db (default: 45). 0 db relative to linear mixer value.
2 High quality fixed-point Bandlimited SINC sampling rate converter,
based on Julius O'Smith's Digital Audio Resampling -
http://ccrma.stanford.edu/~jos/resample/. It includes a filter design
script written in awk (the clumsiest joke I've ever written)
- 100% 32bit fixed-point, 64bit accumulator.
- Possibly among the fastest (if not fastest) of its kind.
- Resampling quality is tunable, either runtime or during kernel
compilation (FEEDER_RATE_PRESETS).
- Quality can be further customized during kernel compilation by
defining FEEDER_RATE_PRESETS in /etc/make.conf.
Kernel sysctls:
- hw.snd.feeder_rate_quality.
0 - Zero-order Hold (ZOH). Fastest, bad quality.
1 - Linear Interpolation (LINEAR). Slightly slower than ZOH,
better quality but still does not eliminate aliasing.
2 - (and above) - Sinc Interpolation(SINC). Best quality. SINC
quality always start from 2 and above.
Rough quality comparisons:
- http://people.freebsd.org/~ariff/z_comparison/
3 Bit-perfect mode. Bypasses all feeder/dsp effects. Pure sound will be
directly fed into the hardware.
4 Parametric (compile time) Software Equalizer (Bass/Treble mixer). Can
be customized by defining FEEDER_EQ_PRESETS in /etc/make.conf.
5 Transparent/Adaptive Virtual Channel. Now you don't have to disable
vchans in order to make digital format pass through. It also makes
vchans more dynamic by choosing a better format/rate among all the
concurrent streams, which means that dev.pcm.X.play.vchanformat/rate
becomes sort of optional.
6 Exclusive Stream, with special open() mode O_EXCL. This will "mute"
other concurrent vchan streams and only allow a single channel with
O_EXCL set to keep producing sound.
Other Changes:
* most feeder_* stuffs are compilable in userland. Let's not
speculate whether we should go all out for it (save that for
FreeBSD 16.0-RELEASE).
* kobj signature fixups, thanks to Andriy Gapon <avg@freebsd.org>
* pull out channel mixing logic out of vchan.c and create its own
feeder_mixer for world justice.
* various refactoring here and there, for good or bad.
* activation of few more OSSv4 ioctls() (see [1] above).
* opt_snd.h for possible compile time configuration:
(mostly for debugging purposes, don't try these at home)
SND_DEBUG
SND_DIAGNOSTIC
SND_FEEDER_MULTIFORMAT
SND_FEEDER_FULL_MULTIFORMAT
SND_FEEDER_RATE_HP
SND_PCM_64
SND_OLDSTEREO
Manual page updates are on the way.
Tested by: joel, Olivier SMEDTS <olivier at gid0 d org>, too many
unsung / unnamed heroes.
2009-06-07 19:12:08 +00:00
|
|
|
ss = (AFMT_CHANNEL(ch->fmt) > 1)? 1 : 0;
|
2000-05-31 03:21:36 +00:00
|
|
|
ss += (ch->fmt & AFMT_16BIT)? 1 : 0;
|
|
|
|
|
|
|
|
bank = ch->lslot + sc->currbank;
|
|
|
|
/* printf("getptr: %d\n", bank->PgStart << ss); */
|
|
|
|
ptr = bank->PgStart;
|
|
|
|
ptr <<= ss;
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
2001-03-24 23:10:29 +00:00
|
|
|
static struct pcmchan_caps *
|
2000-12-18 01:36:41 +00:00
|
|
|
ds1pchan_getcaps(kobj_t obj, void *data)
|
2000-05-31 03:21:36 +00:00
|
|
|
{
|
2000-06-06 22:34:09 +00:00
|
|
|
return &ds_playcaps;
|
|
|
|
}
|
|
|
|
|
2000-12-18 01:36:41 +00:00
|
|
|
static kobj_method_t ds1pchan_methods[] = {
|
|
|
|
KOBJMETHOD(channel_init, ds1pchan_init),
|
|
|
|
KOBJMETHOD(channel_setformat, ds1pchan_setformat),
|
|
|
|
KOBJMETHOD(channel_setspeed, ds1pchan_setspeed),
|
|
|
|
KOBJMETHOD(channel_setblocksize, ds1pchan_setblocksize),
|
|
|
|
KOBJMETHOD(channel_trigger, ds1pchan_trigger),
|
|
|
|
KOBJMETHOD(channel_getptr, ds1pchan_getptr),
|
|
|
|
KOBJMETHOD(channel_getcaps, ds1pchan_getcaps),
|
Sound Mega-commit. Expect further cleanup until code freeze.
For a slightly thorough explaination, please refer to
[1] http://people.freebsd.org/~ariff/SOUND_4.TXT.html .
Summary of changes includes:
1 Volume Per-Channel (vpc). Provides private / standalone volume control
unique per-stream pcm channel without touching master volume / pcm.
Applications can directly use SNDCTL_DSP_[GET|SET][PLAY|REC]VOL, or for
backwards compatibility, SOUND_MIXER_PCM through the opened dsp device
instead of /dev/mixer. Special "bypass" mode is enabled through
/dev/mixer which will automatically detect if the adjustment is made
through /dev/mixer and forward its request to this private volume
controller. Changes to this volume object will not interfere with
other channels.
Requirements:
- SNDCTL_DSP_[GET|SET][PLAY|REC]_VOL are newer ioctls (OSSv4) which
require specific application modifications (preferred).
- No modifications required for using bypass mode, so applications
like mplayer or xmms should work out of the box.
Kernel hints:
- hint.pcm.%d.vpc (0 = disable vpc).
Kernel sysctls:
- hw.snd.vpc_mixer_bypass (default: 1). Enable or disable /dev/mixer
bypass mode.
- hw.snd.vpc_autoreset (default: 1). By default, closing/opening
/dev/dsp will reset the volume back to 0 db gain/attenuation.
Setting this to 0 will preserve its settings across device
closing/opening.
- hw.snd.vpc_reset (default: 0). Panic/reset button to reset all
volume settings back to 0 db.
- hw.snd.vpc_0db (default: 45). 0 db relative to linear mixer value.
2 High quality fixed-point Bandlimited SINC sampling rate converter,
based on Julius O'Smith's Digital Audio Resampling -
http://ccrma.stanford.edu/~jos/resample/. It includes a filter design
script written in awk (the clumsiest joke I've ever written)
- 100% 32bit fixed-point, 64bit accumulator.
- Possibly among the fastest (if not fastest) of its kind.
- Resampling quality is tunable, either runtime or during kernel
compilation (FEEDER_RATE_PRESETS).
- Quality can be further customized during kernel compilation by
defining FEEDER_RATE_PRESETS in /etc/make.conf.
Kernel sysctls:
- hw.snd.feeder_rate_quality.
0 - Zero-order Hold (ZOH). Fastest, bad quality.
1 - Linear Interpolation (LINEAR). Slightly slower than ZOH,
better quality but still does not eliminate aliasing.
2 - (and above) - Sinc Interpolation(SINC). Best quality. SINC
quality always start from 2 and above.
Rough quality comparisons:
- http://people.freebsd.org/~ariff/z_comparison/
3 Bit-perfect mode. Bypasses all feeder/dsp effects. Pure sound will be
directly fed into the hardware.
4 Parametric (compile time) Software Equalizer (Bass/Treble mixer). Can
be customized by defining FEEDER_EQ_PRESETS in /etc/make.conf.
5 Transparent/Adaptive Virtual Channel. Now you don't have to disable
vchans in order to make digital format pass through. It also makes
vchans more dynamic by choosing a better format/rate among all the
concurrent streams, which means that dev.pcm.X.play.vchanformat/rate
becomes sort of optional.
6 Exclusive Stream, with special open() mode O_EXCL. This will "mute"
other concurrent vchan streams and only allow a single channel with
O_EXCL set to keep producing sound.
Other Changes:
* most feeder_* stuffs are compilable in userland. Let's not
speculate whether we should go all out for it (save that for
FreeBSD 16.0-RELEASE).
* kobj signature fixups, thanks to Andriy Gapon <avg@freebsd.org>
* pull out channel mixing logic out of vchan.c and create its own
feeder_mixer for world justice.
* various refactoring here and there, for good or bad.
* activation of few more OSSv4 ioctls() (see [1] above).
* opt_snd.h for possible compile time configuration:
(mostly for debugging purposes, don't try these at home)
SND_DEBUG
SND_DIAGNOSTIC
SND_FEEDER_MULTIFORMAT
SND_FEEDER_FULL_MULTIFORMAT
SND_FEEDER_RATE_HP
SND_PCM_64
SND_OLDSTEREO
Manual page updates are on the way.
Tested by: joel, Olivier SMEDTS <olivier at gid0 d org>, too many
unsung / unnamed heroes.
2009-06-07 19:12:08 +00:00
|
|
|
KOBJMETHOD_END
|
2000-12-18 01:36:41 +00:00
|
|
|
};
|
|
|
|
CHANNEL_DECLARE(ds1pchan);
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
2000-06-06 22:34:09 +00:00
|
|
|
/* record channel interface */
|
|
|
|
static void *
|
2001-03-24 23:10:29 +00:00
|
|
|
ds1rchan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir)
|
2000-06-06 22:34:09 +00:00
|
|
|
{
|
|
|
|
struct sc_info *sc = devinfo;
|
|
|
|
struct sc_rchinfo *ch;
|
2000-05-31 03:21:36 +00:00
|
|
|
|
2000-06-06 22:34:09 +00:00
|
|
|
KASSERT(dir == PCMDIR_REC, ("ds1rchan_init: bad direction"));
|
|
|
|
|
|
|
|
ch = &sc->rch[sc->rchn];
|
|
|
|
ch->num = sc->rchn++;
|
|
|
|
ch->buffer = b;
|
|
|
|
ch->parent = sc;
|
|
|
|
ch->channel = c;
|
|
|
|
ch->dir = dir;
|
Sound Mega-commit. Expect further cleanup until code freeze.
For a slightly thorough explaination, please refer to
[1] http://people.freebsd.org/~ariff/SOUND_4.TXT.html .
Summary of changes includes:
1 Volume Per-Channel (vpc). Provides private / standalone volume control
unique per-stream pcm channel without touching master volume / pcm.
Applications can directly use SNDCTL_DSP_[GET|SET][PLAY|REC]VOL, or for
backwards compatibility, SOUND_MIXER_PCM through the opened dsp device
instead of /dev/mixer. Special "bypass" mode is enabled through
/dev/mixer which will automatically detect if the adjustment is made
through /dev/mixer and forward its request to this private volume
controller. Changes to this volume object will not interfere with
other channels.
Requirements:
- SNDCTL_DSP_[GET|SET][PLAY|REC]_VOL are newer ioctls (OSSv4) which
require specific application modifications (preferred).
- No modifications required for using bypass mode, so applications
like mplayer or xmms should work out of the box.
Kernel hints:
- hint.pcm.%d.vpc (0 = disable vpc).
Kernel sysctls:
- hw.snd.vpc_mixer_bypass (default: 1). Enable or disable /dev/mixer
bypass mode.
- hw.snd.vpc_autoreset (default: 1). By default, closing/opening
/dev/dsp will reset the volume back to 0 db gain/attenuation.
Setting this to 0 will preserve its settings across device
closing/opening.
- hw.snd.vpc_reset (default: 0). Panic/reset button to reset all
volume settings back to 0 db.
- hw.snd.vpc_0db (default: 45). 0 db relative to linear mixer value.
2 High quality fixed-point Bandlimited SINC sampling rate converter,
based on Julius O'Smith's Digital Audio Resampling -
http://ccrma.stanford.edu/~jos/resample/. It includes a filter design
script written in awk (the clumsiest joke I've ever written)
- 100% 32bit fixed-point, 64bit accumulator.
- Possibly among the fastest (if not fastest) of its kind.
- Resampling quality is tunable, either runtime or during kernel
compilation (FEEDER_RATE_PRESETS).
- Quality can be further customized during kernel compilation by
defining FEEDER_RATE_PRESETS in /etc/make.conf.
Kernel sysctls:
- hw.snd.feeder_rate_quality.
0 - Zero-order Hold (ZOH). Fastest, bad quality.
1 - Linear Interpolation (LINEAR). Slightly slower than ZOH,
better quality but still does not eliminate aliasing.
2 - (and above) - Sinc Interpolation(SINC). Best quality. SINC
quality always start from 2 and above.
Rough quality comparisons:
- http://people.freebsd.org/~ariff/z_comparison/
3 Bit-perfect mode. Bypasses all feeder/dsp effects. Pure sound will be
directly fed into the hardware.
4 Parametric (compile time) Software Equalizer (Bass/Treble mixer). Can
be customized by defining FEEDER_EQ_PRESETS in /etc/make.conf.
5 Transparent/Adaptive Virtual Channel. Now you don't have to disable
vchans in order to make digital format pass through. It also makes
vchans more dynamic by choosing a better format/rate among all the
concurrent streams, which means that dev.pcm.X.play.vchanformat/rate
becomes sort of optional.
6 Exclusive Stream, with special open() mode O_EXCL. This will "mute"
other concurrent vchan streams and only allow a single channel with
O_EXCL set to keep producing sound.
Other Changes:
* most feeder_* stuffs are compilable in userland. Let's not
speculate whether we should go all out for it (save that for
FreeBSD 16.0-RELEASE).
* kobj signature fixups, thanks to Andriy Gapon <avg@freebsd.org>
* pull out channel mixing logic out of vchan.c and create its own
feeder_mixer for world justice.
* various refactoring here and there, for good or bad.
* activation of few more OSSv4 ioctls() (see [1] above).
* opt_snd.h for possible compile time configuration:
(mostly for debugging purposes, don't try these at home)
SND_DEBUG
SND_DIAGNOSTIC
SND_FEEDER_MULTIFORMAT
SND_FEEDER_FULL_MULTIFORMAT
SND_FEEDER_RATE_HP
SND_PCM_64
SND_OLDSTEREO
Manual page updates are on the way.
Tested by: joel, Olivier SMEDTS <olivier at gid0 d org>, too many
unsung / unnamed heroes.
2009-06-07 19:12:08 +00:00
|
|
|
ch->fmt = SND_FORMAT(AFMT_U8, 1, 0);
|
2000-06-06 22:34:09 +00:00
|
|
|
ch->spd = 8000;
|
2007-04-18 18:26:41 +00:00
|
|
|
if (sndbuf_alloc(ch->buffer, sc->buffer_dmat, 0, sc->bufsz) != 0)
|
2000-06-06 22:34:09 +00:00
|
|
|
return NULL;
|
|
|
|
else {
|
|
|
|
ch->slot = (ch->num == DS1_RECPRIMARY)? sc->rbank + 2: sc->rbank;
|
|
|
|
ds_setuprch(ch);
|
|
|
|
return ch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2000-12-18 01:36:41 +00:00
|
|
|
ds1rchan_setformat(kobj_t obj, void *data, u_int32_t format)
|
2000-06-06 22:34:09 +00:00
|
|
|
{
|
|
|
|
struct sc_rchinfo *ch = data;
|
|
|
|
|
|
|
|
ch->fmt = format;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
Sound Mega-commit. Expect further cleanup until code freeze.
For a slightly thorough explaination, please refer to
[1] http://people.freebsd.org/~ariff/SOUND_4.TXT.html .
Summary of changes includes:
1 Volume Per-Channel (vpc). Provides private / standalone volume control
unique per-stream pcm channel without touching master volume / pcm.
Applications can directly use SNDCTL_DSP_[GET|SET][PLAY|REC]VOL, or for
backwards compatibility, SOUND_MIXER_PCM through the opened dsp device
instead of /dev/mixer. Special "bypass" mode is enabled through
/dev/mixer which will automatically detect if the adjustment is made
through /dev/mixer and forward its request to this private volume
controller. Changes to this volume object will not interfere with
other channels.
Requirements:
- SNDCTL_DSP_[GET|SET][PLAY|REC]_VOL are newer ioctls (OSSv4) which
require specific application modifications (preferred).
- No modifications required for using bypass mode, so applications
like mplayer or xmms should work out of the box.
Kernel hints:
- hint.pcm.%d.vpc (0 = disable vpc).
Kernel sysctls:
- hw.snd.vpc_mixer_bypass (default: 1). Enable or disable /dev/mixer
bypass mode.
- hw.snd.vpc_autoreset (default: 1). By default, closing/opening
/dev/dsp will reset the volume back to 0 db gain/attenuation.
Setting this to 0 will preserve its settings across device
closing/opening.
- hw.snd.vpc_reset (default: 0). Panic/reset button to reset all
volume settings back to 0 db.
- hw.snd.vpc_0db (default: 45). 0 db relative to linear mixer value.
2 High quality fixed-point Bandlimited SINC sampling rate converter,
based on Julius O'Smith's Digital Audio Resampling -
http://ccrma.stanford.edu/~jos/resample/. It includes a filter design
script written in awk (the clumsiest joke I've ever written)
- 100% 32bit fixed-point, 64bit accumulator.
- Possibly among the fastest (if not fastest) of its kind.
- Resampling quality is tunable, either runtime or during kernel
compilation (FEEDER_RATE_PRESETS).
- Quality can be further customized during kernel compilation by
defining FEEDER_RATE_PRESETS in /etc/make.conf.
Kernel sysctls:
- hw.snd.feeder_rate_quality.
0 - Zero-order Hold (ZOH). Fastest, bad quality.
1 - Linear Interpolation (LINEAR). Slightly slower than ZOH,
better quality but still does not eliminate aliasing.
2 - (and above) - Sinc Interpolation(SINC). Best quality. SINC
quality always start from 2 and above.
Rough quality comparisons:
- http://people.freebsd.org/~ariff/z_comparison/
3 Bit-perfect mode. Bypasses all feeder/dsp effects. Pure sound will be
directly fed into the hardware.
4 Parametric (compile time) Software Equalizer (Bass/Treble mixer). Can
be customized by defining FEEDER_EQ_PRESETS in /etc/make.conf.
5 Transparent/Adaptive Virtual Channel. Now you don't have to disable
vchans in order to make digital format pass through. It also makes
vchans more dynamic by choosing a better format/rate among all the
concurrent streams, which means that dev.pcm.X.play.vchanformat/rate
becomes sort of optional.
6 Exclusive Stream, with special open() mode O_EXCL. This will "mute"
other concurrent vchan streams and only allow a single channel with
O_EXCL set to keep producing sound.
Other Changes:
* most feeder_* stuffs are compilable in userland. Let's not
speculate whether we should go all out for it (save that for
FreeBSD 16.0-RELEASE).
* kobj signature fixups, thanks to Andriy Gapon <avg@freebsd.org>
* pull out channel mixing logic out of vchan.c and create its own
feeder_mixer for world justice.
* various refactoring here and there, for good or bad.
* activation of few more OSSv4 ioctls() (see [1] above).
* opt_snd.h for possible compile time configuration:
(mostly for debugging purposes, don't try these at home)
SND_DEBUG
SND_DIAGNOSTIC
SND_FEEDER_MULTIFORMAT
SND_FEEDER_FULL_MULTIFORMAT
SND_FEEDER_RATE_HP
SND_PCM_64
SND_OLDSTEREO
Manual page updates are on the way.
Tested by: joel, Olivier SMEDTS <olivier at gid0 d org>, too many
unsung / unnamed heroes.
2009-06-07 19:12:08 +00:00
|
|
|
static u_int32_t
|
2000-12-18 01:36:41 +00:00
|
|
|
ds1rchan_setspeed(kobj_t obj, void *data, u_int32_t speed)
|
2000-06-06 22:34:09 +00:00
|
|
|
{
|
|
|
|
struct sc_rchinfo *ch = data;
|
|
|
|
|
|
|
|
ch->spd = speed;
|
|
|
|
|
|
|
|
return speed;
|
|
|
|
}
|
|
|
|
|
Sound Mega-commit. Expect further cleanup until code freeze.
For a slightly thorough explaination, please refer to
[1] http://people.freebsd.org/~ariff/SOUND_4.TXT.html .
Summary of changes includes:
1 Volume Per-Channel (vpc). Provides private / standalone volume control
unique per-stream pcm channel without touching master volume / pcm.
Applications can directly use SNDCTL_DSP_[GET|SET][PLAY|REC]VOL, or for
backwards compatibility, SOUND_MIXER_PCM through the opened dsp device
instead of /dev/mixer. Special "bypass" mode is enabled through
/dev/mixer which will automatically detect if the adjustment is made
through /dev/mixer and forward its request to this private volume
controller. Changes to this volume object will not interfere with
other channels.
Requirements:
- SNDCTL_DSP_[GET|SET][PLAY|REC]_VOL are newer ioctls (OSSv4) which
require specific application modifications (preferred).
- No modifications required for using bypass mode, so applications
like mplayer or xmms should work out of the box.
Kernel hints:
- hint.pcm.%d.vpc (0 = disable vpc).
Kernel sysctls:
- hw.snd.vpc_mixer_bypass (default: 1). Enable or disable /dev/mixer
bypass mode.
- hw.snd.vpc_autoreset (default: 1). By default, closing/opening
/dev/dsp will reset the volume back to 0 db gain/attenuation.
Setting this to 0 will preserve its settings across device
closing/opening.
- hw.snd.vpc_reset (default: 0). Panic/reset button to reset all
volume settings back to 0 db.
- hw.snd.vpc_0db (default: 45). 0 db relative to linear mixer value.
2 High quality fixed-point Bandlimited SINC sampling rate converter,
based on Julius O'Smith's Digital Audio Resampling -
http://ccrma.stanford.edu/~jos/resample/. It includes a filter design
script written in awk (the clumsiest joke I've ever written)
- 100% 32bit fixed-point, 64bit accumulator.
- Possibly among the fastest (if not fastest) of its kind.
- Resampling quality is tunable, either runtime or during kernel
compilation (FEEDER_RATE_PRESETS).
- Quality can be further customized during kernel compilation by
defining FEEDER_RATE_PRESETS in /etc/make.conf.
Kernel sysctls:
- hw.snd.feeder_rate_quality.
0 - Zero-order Hold (ZOH). Fastest, bad quality.
1 - Linear Interpolation (LINEAR). Slightly slower than ZOH,
better quality but still does not eliminate aliasing.
2 - (and above) - Sinc Interpolation(SINC). Best quality. SINC
quality always start from 2 and above.
Rough quality comparisons:
- http://people.freebsd.org/~ariff/z_comparison/
3 Bit-perfect mode. Bypasses all feeder/dsp effects. Pure sound will be
directly fed into the hardware.
4 Parametric (compile time) Software Equalizer (Bass/Treble mixer). Can
be customized by defining FEEDER_EQ_PRESETS in /etc/make.conf.
5 Transparent/Adaptive Virtual Channel. Now you don't have to disable
vchans in order to make digital format pass through. It also makes
vchans more dynamic by choosing a better format/rate among all the
concurrent streams, which means that dev.pcm.X.play.vchanformat/rate
becomes sort of optional.
6 Exclusive Stream, with special open() mode O_EXCL. This will "mute"
other concurrent vchan streams and only allow a single channel with
O_EXCL set to keep producing sound.
Other Changes:
* most feeder_* stuffs are compilable in userland. Let's not
speculate whether we should go all out for it (save that for
FreeBSD 16.0-RELEASE).
* kobj signature fixups, thanks to Andriy Gapon <avg@freebsd.org>
* pull out channel mixing logic out of vchan.c and create its own
feeder_mixer for world justice.
* various refactoring here and there, for good or bad.
* activation of few more OSSv4 ioctls() (see [1] above).
* opt_snd.h for possible compile time configuration:
(mostly for debugging purposes, don't try these at home)
SND_DEBUG
SND_DIAGNOSTIC
SND_FEEDER_MULTIFORMAT
SND_FEEDER_FULL_MULTIFORMAT
SND_FEEDER_RATE_HP
SND_PCM_64
SND_OLDSTEREO
Manual page updates are on the way.
Tested by: joel, Olivier SMEDTS <olivier at gid0 d org>, too many
unsung / unnamed heroes.
2009-06-07 19:12:08 +00:00
|
|
|
static u_int32_t
|
2000-12-18 01:36:41 +00:00
|
|
|
ds1rchan_setblocksize(kobj_t obj, void *data, u_int32_t blocksize)
|
2000-06-06 22:34:09 +00:00
|
|
|
{
|
2001-01-24 01:22:53 +00:00
|
|
|
struct sc_rchinfo *ch = data;
|
2003-08-23 13:00:48 +00:00
|
|
|
struct sc_info *sc = ch->parent;
|
2001-01-24 01:22:53 +00:00
|
|
|
int drate;
|
|
|
|
|
|
|
|
/* irq rate is fixed at 187.5hz */
|
Sound Mega-commit. Expect further cleanup until code freeze.
For a slightly thorough explaination, please refer to
[1] http://people.freebsd.org/~ariff/SOUND_4.TXT.html .
Summary of changes includes:
1 Volume Per-Channel (vpc). Provides private / standalone volume control
unique per-stream pcm channel without touching master volume / pcm.
Applications can directly use SNDCTL_DSP_[GET|SET][PLAY|REC]VOL, or for
backwards compatibility, SOUND_MIXER_PCM through the opened dsp device
instead of /dev/mixer. Special "bypass" mode is enabled through
/dev/mixer which will automatically detect if the adjustment is made
through /dev/mixer and forward its request to this private volume
controller. Changes to this volume object will not interfere with
other channels.
Requirements:
- SNDCTL_DSP_[GET|SET][PLAY|REC]_VOL are newer ioctls (OSSv4) which
require specific application modifications (preferred).
- No modifications required for using bypass mode, so applications
like mplayer or xmms should work out of the box.
Kernel hints:
- hint.pcm.%d.vpc (0 = disable vpc).
Kernel sysctls:
- hw.snd.vpc_mixer_bypass (default: 1). Enable or disable /dev/mixer
bypass mode.
- hw.snd.vpc_autoreset (default: 1). By default, closing/opening
/dev/dsp will reset the volume back to 0 db gain/attenuation.
Setting this to 0 will preserve its settings across device
closing/opening.
- hw.snd.vpc_reset (default: 0). Panic/reset button to reset all
volume settings back to 0 db.
- hw.snd.vpc_0db (default: 45). 0 db relative to linear mixer value.
2 High quality fixed-point Bandlimited SINC sampling rate converter,
based on Julius O'Smith's Digital Audio Resampling -
http://ccrma.stanford.edu/~jos/resample/. It includes a filter design
script written in awk (the clumsiest joke I've ever written)
- 100% 32bit fixed-point, 64bit accumulator.
- Possibly among the fastest (if not fastest) of its kind.
- Resampling quality is tunable, either runtime or during kernel
compilation (FEEDER_RATE_PRESETS).
- Quality can be further customized during kernel compilation by
defining FEEDER_RATE_PRESETS in /etc/make.conf.
Kernel sysctls:
- hw.snd.feeder_rate_quality.
0 - Zero-order Hold (ZOH). Fastest, bad quality.
1 - Linear Interpolation (LINEAR). Slightly slower than ZOH,
better quality but still does not eliminate aliasing.
2 - (and above) - Sinc Interpolation(SINC). Best quality. SINC
quality always start from 2 and above.
Rough quality comparisons:
- http://people.freebsd.org/~ariff/z_comparison/
3 Bit-perfect mode. Bypasses all feeder/dsp effects. Pure sound will be
directly fed into the hardware.
4 Parametric (compile time) Software Equalizer (Bass/Treble mixer). Can
be customized by defining FEEDER_EQ_PRESETS in /etc/make.conf.
5 Transparent/Adaptive Virtual Channel. Now you don't have to disable
vchans in order to make digital format pass through. It also makes
vchans more dynamic by choosing a better format/rate among all the
concurrent streams, which means that dev.pcm.X.play.vchanformat/rate
becomes sort of optional.
6 Exclusive Stream, with special open() mode O_EXCL. This will "mute"
other concurrent vchan streams and only allow a single channel with
O_EXCL set to keep producing sound.
Other Changes:
* most feeder_* stuffs are compilable in userland. Let's not
speculate whether we should go all out for it (save that for
FreeBSD 16.0-RELEASE).
* kobj signature fixups, thanks to Andriy Gapon <avg@freebsd.org>
* pull out channel mixing logic out of vchan.c and create its own
feeder_mixer for world justice.
* various refactoring here and there, for good or bad.
* activation of few more OSSv4 ioctls() (see [1] above).
* opt_snd.h for possible compile time configuration:
(mostly for debugging purposes, don't try these at home)
SND_DEBUG
SND_DIAGNOSTIC
SND_FEEDER_MULTIFORMAT
SND_FEEDER_FULL_MULTIFORMAT
SND_FEEDER_RATE_HP
SND_PCM_64
SND_OLDSTEREO
Manual page updates are on the way.
Tested by: joel, Olivier SMEDTS <olivier at gid0 d org>, too many
unsung / unnamed heroes.
2009-06-07 19:12:08 +00:00
|
|
|
drate = ch->spd * sndbuf_getalign(ch->buffer);
|
2003-08-23 13:00:48 +00:00
|
|
|
blocksize = roundup2((drate << 8) / DS1_IRQHZ, 4);
|
|
|
|
sndbuf_resize(ch->buffer, sc->bufsz / blocksize, blocksize);
|
2001-01-24 01:22:53 +00:00
|
|
|
|
2000-06-06 22:34:09 +00:00
|
|
|
return blocksize;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* semantic note: must start at beginning of buffer */
|
|
|
|
static int
|
2000-12-18 01:36:41 +00:00
|
|
|
ds1rchan_trigger(kobj_t obj, void *data, int go)
|
2000-06-06 22:34:09 +00:00
|
|
|
{
|
|
|
|
struct sc_rchinfo *ch = data;
|
|
|
|
struct sc_info *sc = ch->parent;
|
|
|
|
u_int32_t x;
|
|
|
|
|
2007-06-11 00:49:46 +00:00
|
|
|
if (!PCMTRIG_COMMON(go))
|
2000-06-06 22:34:09 +00:00
|
|
|
return 0;
|
|
|
|
if (go == PCMTRIG_START) {
|
|
|
|
ch->run = 1;
|
|
|
|
ds_setuprch(ch);
|
2001-03-24 23:10:29 +00:00
|
|
|
snd_mtxlock(sc->lock);
|
2000-06-06 22:34:09 +00:00
|
|
|
x = ds_rd(sc, YDSXGR_MAPOFREC, 4);
|
|
|
|
x |= (ch->num == DS1_RECPRIMARY)? 0x02 : 0x01;
|
|
|
|
ds_wr(sc, YDSXGR_MAPOFREC, x, 4);
|
|
|
|
ds_wr(sc, YDSXGR_MODE, 0x00000003, 4);
|
2001-03-24 23:10:29 +00:00
|
|
|
snd_mtxunlock(sc->lock);
|
2000-06-06 22:34:09 +00:00
|
|
|
} else {
|
|
|
|
ch->run = 0;
|
2001-03-24 23:10:29 +00:00
|
|
|
snd_mtxlock(sc->lock);
|
2000-06-06 22:34:09 +00:00
|
|
|
x = ds_rd(sc, YDSXGR_MAPOFREC, 4);
|
|
|
|
x &= ~((ch->num == DS1_RECPRIMARY)? 0x02 : 0x01);
|
|
|
|
ds_wr(sc, YDSXGR_MAPOFREC, x, 4);
|
2001-03-24 23:10:29 +00:00
|
|
|
snd_mtxunlock(sc->lock);
|
2000-06-06 22:34:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
Sound Mega-commit. Expect further cleanup until code freeze.
For a slightly thorough explaination, please refer to
[1] http://people.freebsd.org/~ariff/SOUND_4.TXT.html .
Summary of changes includes:
1 Volume Per-Channel (vpc). Provides private / standalone volume control
unique per-stream pcm channel without touching master volume / pcm.
Applications can directly use SNDCTL_DSP_[GET|SET][PLAY|REC]VOL, or for
backwards compatibility, SOUND_MIXER_PCM through the opened dsp device
instead of /dev/mixer. Special "bypass" mode is enabled through
/dev/mixer which will automatically detect if the adjustment is made
through /dev/mixer and forward its request to this private volume
controller. Changes to this volume object will not interfere with
other channels.
Requirements:
- SNDCTL_DSP_[GET|SET][PLAY|REC]_VOL are newer ioctls (OSSv4) which
require specific application modifications (preferred).
- No modifications required for using bypass mode, so applications
like mplayer or xmms should work out of the box.
Kernel hints:
- hint.pcm.%d.vpc (0 = disable vpc).
Kernel sysctls:
- hw.snd.vpc_mixer_bypass (default: 1). Enable or disable /dev/mixer
bypass mode.
- hw.snd.vpc_autoreset (default: 1). By default, closing/opening
/dev/dsp will reset the volume back to 0 db gain/attenuation.
Setting this to 0 will preserve its settings across device
closing/opening.
- hw.snd.vpc_reset (default: 0). Panic/reset button to reset all
volume settings back to 0 db.
- hw.snd.vpc_0db (default: 45). 0 db relative to linear mixer value.
2 High quality fixed-point Bandlimited SINC sampling rate converter,
based on Julius O'Smith's Digital Audio Resampling -
http://ccrma.stanford.edu/~jos/resample/. It includes a filter design
script written in awk (the clumsiest joke I've ever written)
- 100% 32bit fixed-point, 64bit accumulator.
- Possibly among the fastest (if not fastest) of its kind.
- Resampling quality is tunable, either runtime or during kernel
compilation (FEEDER_RATE_PRESETS).
- Quality can be further customized during kernel compilation by
defining FEEDER_RATE_PRESETS in /etc/make.conf.
Kernel sysctls:
- hw.snd.feeder_rate_quality.
0 - Zero-order Hold (ZOH). Fastest, bad quality.
1 - Linear Interpolation (LINEAR). Slightly slower than ZOH,
better quality but still does not eliminate aliasing.
2 - (and above) - Sinc Interpolation(SINC). Best quality. SINC
quality always start from 2 and above.
Rough quality comparisons:
- http://people.freebsd.org/~ariff/z_comparison/
3 Bit-perfect mode. Bypasses all feeder/dsp effects. Pure sound will be
directly fed into the hardware.
4 Parametric (compile time) Software Equalizer (Bass/Treble mixer). Can
be customized by defining FEEDER_EQ_PRESETS in /etc/make.conf.
5 Transparent/Adaptive Virtual Channel. Now you don't have to disable
vchans in order to make digital format pass through. It also makes
vchans more dynamic by choosing a better format/rate among all the
concurrent streams, which means that dev.pcm.X.play.vchanformat/rate
becomes sort of optional.
6 Exclusive Stream, with special open() mode O_EXCL. This will "mute"
other concurrent vchan streams and only allow a single channel with
O_EXCL set to keep producing sound.
Other Changes:
* most feeder_* stuffs are compilable in userland. Let's not
speculate whether we should go all out for it (save that for
FreeBSD 16.0-RELEASE).
* kobj signature fixups, thanks to Andriy Gapon <avg@freebsd.org>
* pull out channel mixing logic out of vchan.c and create its own
feeder_mixer for world justice.
* various refactoring here and there, for good or bad.
* activation of few more OSSv4 ioctls() (see [1] above).
* opt_snd.h for possible compile time configuration:
(mostly for debugging purposes, don't try these at home)
SND_DEBUG
SND_DIAGNOSTIC
SND_FEEDER_MULTIFORMAT
SND_FEEDER_FULL_MULTIFORMAT
SND_FEEDER_RATE_HP
SND_PCM_64
SND_OLDSTEREO
Manual page updates are on the way.
Tested by: joel, Olivier SMEDTS <olivier at gid0 d org>, too many
unsung / unnamed heroes.
2009-06-07 19:12:08 +00:00
|
|
|
static u_int32_t
|
2000-12-18 01:36:41 +00:00
|
|
|
ds1rchan_getptr(kobj_t obj, void *data)
|
2000-06-06 22:34:09 +00:00
|
|
|
{
|
|
|
|
struct sc_rchinfo *ch = data;
|
|
|
|
struct sc_info *sc = ch->parent;
|
|
|
|
|
|
|
|
return ch->slot[sc->currbank].PgStart;
|
|
|
|
}
|
|
|
|
|
2001-03-24 23:10:29 +00:00
|
|
|
static struct pcmchan_caps *
|
2000-12-18 01:36:41 +00:00
|
|
|
ds1rchan_getcaps(kobj_t obj, void *data)
|
2000-06-06 22:34:09 +00:00
|
|
|
{
|
|
|
|
return &ds_reccaps;
|
2000-05-31 03:21:36 +00:00
|
|
|
}
|
|
|
|
|
2000-12-18 01:36:41 +00:00
|
|
|
static kobj_method_t ds1rchan_methods[] = {
|
|
|
|
KOBJMETHOD(channel_init, ds1rchan_init),
|
|
|
|
KOBJMETHOD(channel_setformat, ds1rchan_setformat),
|
|
|
|
KOBJMETHOD(channel_setspeed, ds1rchan_setspeed),
|
|
|
|
KOBJMETHOD(channel_setblocksize, ds1rchan_setblocksize),
|
|
|
|
KOBJMETHOD(channel_trigger, ds1rchan_trigger),
|
|
|
|
KOBJMETHOD(channel_getptr, ds1rchan_getptr),
|
|
|
|
KOBJMETHOD(channel_getcaps, ds1rchan_getcaps),
|
Sound Mega-commit. Expect further cleanup until code freeze.
For a slightly thorough explaination, please refer to
[1] http://people.freebsd.org/~ariff/SOUND_4.TXT.html .
Summary of changes includes:
1 Volume Per-Channel (vpc). Provides private / standalone volume control
unique per-stream pcm channel without touching master volume / pcm.
Applications can directly use SNDCTL_DSP_[GET|SET][PLAY|REC]VOL, or for
backwards compatibility, SOUND_MIXER_PCM through the opened dsp device
instead of /dev/mixer. Special "bypass" mode is enabled through
/dev/mixer which will automatically detect if the adjustment is made
through /dev/mixer and forward its request to this private volume
controller. Changes to this volume object will not interfere with
other channels.
Requirements:
- SNDCTL_DSP_[GET|SET][PLAY|REC]_VOL are newer ioctls (OSSv4) which
require specific application modifications (preferred).
- No modifications required for using bypass mode, so applications
like mplayer or xmms should work out of the box.
Kernel hints:
- hint.pcm.%d.vpc (0 = disable vpc).
Kernel sysctls:
- hw.snd.vpc_mixer_bypass (default: 1). Enable or disable /dev/mixer
bypass mode.
- hw.snd.vpc_autoreset (default: 1). By default, closing/opening
/dev/dsp will reset the volume back to 0 db gain/attenuation.
Setting this to 0 will preserve its settings across device
closing/opening.
- hw.snd.vpc_reset (default: 0). Panic/reset button to reset all
volume settings back to 0 db.
- hw.snd.vpc_0db (default: 45). 0 db relative to linear mixer value.
2 High quality fixed-point Bandlimited SINC sampling rate converter,
based on Julius O'Smith's Digital Audio Resampling -
http://ccrma.stanford.edu/~jos/resample/. It includes a filter design
script written in awk (the clumsiest joke I've ever written)
- 100% 32bit fixed-point, 64bit accumulator.
- Possibly among the fastest (if not fastest) of its kind.
- Resampling quality is tunable, either runtime or during kernel
compilation (FEEDER_RATE_PRESETS).
- Quality can be further customized during kernel compilation by
defining FEEDER_RATE_PRESETS in /etc/make.conf.
Kernel sysctls:
- hw.snd.feeder_rate_quality.
0 - Zero-order Hold (ZOH). Fastest, bad quality.
1 - Linear Interpolation (LINEAR). Slightly slower than ZOH,
better quality but still does not eliminate aliasing.
2 - (and above) - Sinc Interpolation(SINC). Best quality. SINC
quality always start from 2 and above.
Rough quality comparisons:
- http://people.freebsd.org/~ariff/z_comparison/
3 Bit-perfect mode. Bypasses all feeder/dsp effects. Pure sound will be
directly fed into the hardware.
4 Parametric (compile time) Software Equalizer (Bass/Treble mixer). Can
be customized by defining FEEDER_EQ_PRESETS in /etc/make.conf.
5 Transparent/Adaptive Virtual Channel. Now you don't have to disable
vchans in order to make digital format pass through. It also makes
vchans more dynamic by choosing a better format/rate among all the
concurrent streams, which means that dev.pcm.X.play.vchanformat/rate
becomes sort of optional.
6 Exclusive Stream, with special open() mode O_EXCL. This will "mute"
other concurrent vchan streams and only allow a single channel with
O_EXCL set to keep producing sound.
Other Changes:
* most feeder_* stuffs are compilable in userland. Let's not
speculate whether we should go all out for it (save that for
FreeBSD 16.0-RELEASE).
* kobj signature fixups, thanks to Andriy Gapon <avg@freebsd.org>
* pull out channel mixing logic out of vchan.c and create its own
feeder_mixer for world justice.
* various refactoring here and there, for good or bad.
* activation of few more OSSv4 ioctls() (see [1] above).
* opt_snd.h for possible compile time configuration:
(mostly for debugging purposes, don't try these at home)
SND_DEBUG
SND_DIAGNOSTIC
SND_FEEDER_MULTIFORMAT
SND_FEEDER_FULL_MULTIFORMAT
SND_FEEDER_RATE_HP
SND_PCM_64
SND_OLDSTEREO
Manual page updates are on the way.
Tested by: joel, Olivier SMEDTS <olivier at gid0 d org>, too many
unsung / unnamed heroes.
2009-06-07 19:12:08 +00:00
|
|
|
KOBJMETHOD_END
|
2000-12-18 01:36:41 +00:00
|
|
|
};
|
|
|
|
CHANNEL_DECLARE(ds1rchan);
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
2000-05-31 03:21:36 +00:00
|
|
|
/* The interrupt handler */
|
|
|
|
static void
|
|
|
|
ds_intr(void *p)
|
|
|
|
{
|
|
|
|
struct sc_info *sc = (struct sc_info *)p;
|
|
|
|
u_int32_t i, x;
|
|
|
|
|
2001-03-24 23:10:29 +00:00
|
|
|
snd_mtxlock(sc->lock);
|
2000-05-31 03:21:36 +00:00
|
|
|
i = ds_rd(sc, YDSXGR_STATUS, 4);
|
2000-06-06 22:34:09 +00:00
|
|
|
if (i & 0x00008000)
|
|
|
|
device_printf(sc->dev, "timeout irq\n");
|
2000-05-31 03:21:36 +00:00
|
|
|
if (i & 0x80008000) {
|
|
|
|
ds_wr(sc, YDSXGR_STATUS, i & 0x80008000, 4);
|
|
|
|
sc->currbank = ds_rd(sc, YDSXGR_CTRLSELECT, 4) & 0x00000001;
|
|
|
|
|
|
|
|
x = 0;
|
2000-06-06 22:34:09 +00:00
|
|
|
for (i = 0; i < DS1_CHANS; i++) {
|
2000-05-31 03:21:36 +00:00
|
|
|
if (sc->pch[i].run) {
|
|
|
|
x = 1;
|
2006-01-11 08:02:15 +00:00
|
|
|
snd_mtxunlock(sc->lock);
|
2000-05-31 03:21:36 +00:00
|
|
|
chn_intr(sc->pch[i].channel);
|
2006-01-11 08:02:15 +00:00
|
|
|
snd_mtxlock(sc->lock);
|
2000-05-31 03:21:36 +00:00
|
|
|
}
|
2000-06-06 22:34:09 +00:00
|
|
|
}
|
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
if (sc->rch[i].run) {
|
|
|
|
x = 1;
|
2006-01-11 08:02:15 +00:00
|
|
|
snd_mtxunlock(sc->lock);
|
2000-06-06 22:34:09 +00:00
|
|
|
chn_intr(sc->rch[i].channel);
|
2006-01-11 08:02:15 +00:00
|
|
|
snd_mtxlock(sc->lock);
|
2000-06-06 22:34:09 +00:00
|
|
|
}
|
|
|
|
}
|
2000-05-31 03:21:36 +00:00
|
|
|
i = ds_rd(sc, YDSXGR_MODE, 4);
|
|
|
|
if (x)
|
|
|
|
ds_wr(sc, YDSXGR_MODE, i | 0x00000002, 4);
|
|
|
|
|
|
|
|
}
|
2001-03-24 23:10:29 +00:00
|
|
|
snd_mtxunlock(sc->lock);
|
2000-05-31 03:21:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Probe and attach the card
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
ds_setmap(void *arg, bus_dma_segment_t *segs, int nseg, int error)
|
|
|
|
{
|
|
|
|
struct sc_info *sc = arg;
|
|
|
|
|
|
|
|
sc->ctrlbase = error? 0 : (u_int32_t)segs->ds_addr;
|
|
|
|
|
|
|
|
if (bootverbose) {
|
2000-05-31 19:04:12 +00:00
|
|
|
printf("ds1: setmap (%lx, %lx), nseg=%d, error=%d\n",
|
|
|
|
(unsigned long)segs->ds_addr, (unsigned long)segs->ds_len,
|
|
|
|
nseg, error);
|
2000-05-31 03:21:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-02-23 19:41:16 +00:00
|
|
|
ds_init(struct sc_info *sc)
|
2000-05-31 03:21:36 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
u_int32_t *ci, r, pcs, rcs, ecs, ws, memsz, cb;
|
|
|
|
u_int8_t *t;
|
|
|
|
void *buf;
|
|
|
|
|
|
|
|
ci = ds_devs[sc->type].mcode;
|
|
|
|
|
|
|
|
ds_wr(sc, YDSXGR_NATIVEDACOUTVOL, 0x00000000, 4);
|
|
|
|
ds_enadsp(sc, 0);
|
|
|
|
ds_wr(sc, YDSXGR_MODE, 0x00010000, 4);
|
|
|
|
ds_wr(sc, YDSXGR_MODE, 0x00000000, 4);
|
|
|
|
ds_wr(sc, YDSXGR_MAPOFREC, 0x00000000, 4);
|
|
|
|
ds_wr(sc, YDSXGR_MAPOFEFFECT, 0x00000000, 4);
|
|
|
|
ds_wr(sc, YDSXGR_PLAYCTRLBASE, 0x00000000, 4);
|
|
|
|
ds_wr(sc, YDSXGR_RECCTRLBASE, 0x00000000, 4);
|
|
|
|
ds_wr(sc, YDSXGR_EFFCTRLBASE, 0x00000000, 4);
|
|
|
|
r = ds_rd(sc, YDSXGR_GLOBALCTRL, 2);
|
|
|
|
ds_wr(sc, YDSXGR_GLOBALCTRL, r & ~0x0007, 2);
|
|
|
|
|
|
|
|
for (i = 0; i < YDSXG_DSPLENGTH; i += 4)
|
|
|
|
ds_wr(sc, YDSXGR_DSPINSTRAM + i, DspInst[i >> 2], 4);
|
|
|
|
|
|
|
|
for (i = 0; i < YDSXG_CTRLLENGTH; i += 4)
|
|
|
|
ds_wr(sc, YDSXGR_CTRLINSTRAM + i, ci[i >> 2], 4);
|
|
|
|
|
|
|
|
ds_enadsp(sc, 1);
|
|
|
|
|
2000-06-01 01:29:05 +00:00
|
|
|
pcs = 0;
|
|
|
|
for (i = 100; i > 0; i--) {
|
|
|
|
pcs = ds_rd(sc, YDSXGR_PLAYCTRLSIZE, 4) << 2;
|
|
|
|
if (pcs == sizeof(struct pbank))
|
|
|
|
break;
|
2000-06-09 16:44:30 +00:00
|
|
|
DELAY(1000);
|
2000-06-01 01:29:05 +00:00
|
|
|
}
|
|
|
|
if (pcs != sizeof(struct pbank)) {
|
|
|
|
device_printf(sc->dev, "preposterous playctrlsize (%d)\n", pcs);
|
|
|
|
return -1;
|
|
|
|
}
|
2000-05-31 03:21:36 +00:00
|
|
|
rcs = ds_rd(sc, YDSXGR_RECCTRLSIZE, 4) << 2;
|
|
|
|
ecs = ds_rd(sc, YDSXGR_EFFCTRLSIZE, 4) << 2;
|
|
|
|
ws = ds_rd(sc, YDSXGR_WORKSIZE, 4) << 2;
|
|
|
|
|
|
|
|
memsz = 64 * 2 * pcs + 2 * 2 * rcs + 5 * 2 * ecs + ws;
|
|
|
|
memsz += (64 + 1) * 4;
|
|
|
|
|
2000-08-29 20:50:42 +00:00
|
|
|
if (sc->regbase == NULL) {
|
2007-02-23 19:41:16 +00:00
|
|
|
if (bus_dma_tag_create(bus_get_dma_tag(sc->dev), 2, 0,
|
2007-02-23 13:47:34 +00:00
|
|
|
BUS_SPACE_MAXADDR_32BIT,
|
|
|
|
BUS_SPACE_MAXADDR,
|
2006-01-18 01:01:37 +00:00
|
|
|
NULL, NULL, memsz, 1, memsz, 0, NULL,
|
|
|
|
NULL, &sc->control_dmat))
|
2000-08-29 20:50:42 +00:00
|
|
|
return -1;
|
2001-10-08 06:01:13 +00:00
|
|
|
if (bus_dmamem_alloc(sc->control_dmat, &buf, BUS_DMA_NOWAIT, &sc->map))
|
|
|
|
return -1;
|
|
|
|
if (bus_dmamap_load(sc->control_dmat, sc->map, buf, memsz, ds_setmap, sc, 0) || !sc->ctrlbase) {
|
2000-08-29 20:50:42 +00:00
|
|
|
device_printf(sc->dev, "pcs=%d, rcs=%d, ecs=%d, ws=%d, memsz=%d\n",
|
2001-10-08 06:01:13 +00:00
|
|
|
pcs, rcs, ecs, ws, memsz);
|
2000-08-29 20:50:42 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
sc->regbase = buf;
|
|
|
|
} else
|
|
|
|
buf = sc->regbase;
|
2000-05-31 03:21:36 +00:00
|
|
|
|
|
|
|
cb = 0;
|
|
|
|
t = buf;
|
|
|
|
ds_wr(sc, YDSXGR_WORKBASE, sc->ctrlbase + cb, 4);
|
|
|
|
cb += ws;
|
|
|
|
sc->pbase = (u_int32_t *)(t + cb);
|
|
|
|
/* printf("pbase = %p -> 0x%x\n", sc->pbase, sc->ctrlbase + cb); */
|
|
|
|
ds_wr(sc, YDSXGR_PLAYCTRLBASE, sc->ctrlbase + cb, 4);
|
|
|
|
cb += (64 + 1) * 4;
|
2000-06-06 22:34:09 +00:00
|
|
|
sc->rbank = (struct rbank *)(t + cb);
|
2000-05-31 03:21:36 +00:00
|
|
|
ds_wr(sc, YDSXGR_RECCTRLBASE, sc->ctrlbase + cb, 4);
|
|
|
|
cb += 2 * 2 * rcs;
|
|
|
|
ds_wr(sc, YDSXGR_EFFCTRLBASE, sc->ctrlbase + cb, 4);
|
|
|
|
cb += 5 * 2 * ecs;
|
|
|
|
|
|
|
|
sc->pbankbase = sc->ctrlbase + cb;
|
|
|
|
sc->pbanksize = pcs;
|
|
|
|
for (i = 0; i < 64; i++) {
|
|
|
|
wrl(sc, &sc->pbase[i + 1], 0);
|
|
|
|
sc->pbank[i * 2] = (struct pbank *)(t + cb);
|
|
|
|
/* printf("pbank[%d] = %p -> 0x%x; ", i * 2, (struct pbank *)(t + cb), sc->ctrlbase + cb - vtophys(t + cb)); */
|
|
|
|
cb += pcs;
|
|
|
|
sc->pbank[i * 2 + 1] = (struct pbank *)(t + cb);
|
|
|
|
/* printf("pbank[%d] = %p -> 0x%x\n", i * 2 + 1, (struct pbank *)(t + cb), sc->ctrlbase + cb - vtophys(t + cb)); */
|
|
|
|
cb += pcs;
|
|
|
|
}
|
|
|
|
wrl(sc, &sc->pbase[0], DS1_CHANS * 2);
|
|
|
|
|
|
|
|
sc->pchn = sc->rchn = 0;
|
|
|
|
ds_wr(sc, YDSXGR_NATIVEDACOUTVOL, 0x3fff3fff, 4);
|
2000-06-06 22:34:09 +00:00
|
|
|
ds_wr(sc, YDSXGR_NATIVEADCINVOL, 0x3fff3fff, 4);
|
|
|
|
ds_wr(sc, YDSXGR_NATIVEDACINVOL, 0x3fff3fff, 4);
|
2000-12-25 01:42:13 +00:00
|
|
|
|
2000-05-31 03:21:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-09-01 20:09:24 +00:00
|
|
|
static int
|
|
|
|
ds_uninit(struct sc_info *sc)
|
|
|
|
{
|
|
|
|
ds_wr(sc, YDSXGR_NATIVEDACOUTVOL, 0x00000000, 4);
|
|
|
|
ds_wr(sc, YDSXGR_NATIVEADCINVOL, 0, 4);
|
|
|
|
ds_wr(sc, YDSXGR_NATIVEDACINVOL, 0, 4);
|
|
|
|
ds_enadsp(sc, 0);
|
|
|
|
ds_wr(sc, YDSXGR_MODE, 0x00010000, 4);
|
|
|
|
ds_wr(sc, YDSXGR_MAPOFREC, 0x00000000, 4);
|
|
|
|
ds_wr(sc, YDSXGR_MAPOFEFFECT, 0x00000000, 4);
|
|
|
|
ds_wr(sc, YDSXGR_PLAYCTRLBASE, 0x00000000, 4);
|
|
|
|
ds_wr(sc, YDSXGR_RECCTRLBASE, 0x00000000, 4);
|
|
|
|
ds_wr(sc, YDSXGR_EFFCTRLBASE, 0x00000000, 4);
|
|
|
|
ds_wr(sc, YDSXGR_GLOBALCTRL, 0, 2);
|
|
|
|
|
2001-10-08 06:01:13 +00:00
|
|
|
bus_dmamap_unload(sc->control_dmat, sc->map);
|
|
|
|
bus_dmamem_free(sc->control_dmat, sc->regbase, sc->map);
|
2000-09-01 20:09:24 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-05-31 03:21:36 +00:00
|
|
|
static int
|
|
|
|
ds_finddev(u_int32_t dev, u_int32_t subdev)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; ds_devs[i].dev; i++) {
|
|
|
|
if (ds_devs[i].dev == dev &&
|
|
|
|
(ds_devs[i].subdev == subdev || ds_devs[i].subdev == 0))
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ds_pci_probe(device_t dev)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
u_int32_t subdev;
|
|
|
|
|
|
|
|
subdev = (pci_get_subdevice(dev) << 16) | pci_get_subvendor(dev);
|
|
|
|
i = ds_finddev(pci_get_devid(dev), subdev);
|
|
|
|
if (i >= 0) {
|
|
|
|
device_set_desc(dev, ds_devs[i].name);
|
2005-03-01 08:58:06 +00:00
|
|
|
return BUS_PROBE_DEFAULT;
|
2000-05-31 03:21:36 +00:00
|
|
|
} else
|
|
|
|
return ENXIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ds_pci_attach(device_t dev)
|
|
|
|
{
|
|
|
|
u_int32_t subdev, i;
|
|
|
|
struct sc_info *sc;
|
2000-09-09 19:21:04 +00:00
|
|
|
struct ac97_info *codec = NULL;
|
2000-05-31 03:21:36 +00:00
|
|
|
char status[SND_STATUSLEN];
|
|
|
|
|
2007-06-17 06:10:43 +00:00
|
|
|
sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK | M_ZERO);
|
Fix severe out-of-bound mtx "type" pointer, causing WITNESS refcount
confusions and panic provided that the following conditions are met:
1) WITNESS is enabled (watch/trace).
2) Using modules, instead of statically linked (Not a strict
requirement, but easier to reproduce this way).
3) 2 or more modules share the same mtx type ("sound softc").
- They might share the same name (strcmp() == 0), but it always
point to different address.
4) Repetitive kldunload/load on any module that shares the same mtx
type (Not a strict requirement, but easier to reproduce this way).
Consider module A and module B:
- From enroll() - subr_witness.c:
* Load module A. Everything seems fine right now.
wA-w_refcount == 1 ; wA-w_name = "sound softc"
* Load module B.
* w->w_name == description will always fail.
("sound softc" from A and B point to different address).
* wA->w_refcount > 0 && strcmp(description, wA->w_name) == 0
* enroll() will return wA instead of returning (possibly unique)
wB.
wA->w_refcount++ , == 2.
* Unload module A, mtx_destroy(), wA->w_name become invalid,
but wA->w_refcount-- become 1 instead of 0. wA will not be
removed from witness list.
* Some other places call mtx_init(), iterating witness list,
found wA, failed on wA->w_name == description
* wA->w_refcount > 0 && strcmp(description, wA->w_name)
* Panic on strcmp() since wA->w_name no longer point to valid
address.
Note that this could happened in other places as well, not just sound
(eg. consider lots of drivers that share simmilar MTX_NETWORK_LOCK).
Solutions (for sound case):
1) Provide unique mtx type string for each mutex creation (chosen)
or
2) Put "sound softc" global variable somewhere and use it.
2007-03-15 16:41:27 +00:00
|
|
|
sc->lock = snd_mtxcreate(device_get_nameunit(dev), "snd_ds1 softc");
|
2000-05-31 03:21:36 +00:00
|
|
|
sc->dev = dev;
|
|
|
|
subdev = (pci_get_subdevice(dev) << 16) | pci_get_subvendor(dev);
|
|
|
|
sc->type = ds_finddev(pci_get_devid(dev), subdev);
|
|
|
|
sc->rev = pci_get_revid(dev);
|
|
|
|
|
2013-08-12 23:30:01 +00:00
|
|
|
pci_enable_busmaster(dev);
|
2000-05-31 03:21:36 +00:00
|
|
|
|
2003-09-02 17:30:40 +00:00
|
|
|
sc->regid = PCIR_BAR(0);
|
2004-03-17 17:50:55 +00:00
|
|
|
sc->reg = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->regid,
|
|
|
|
RF_ACTIVE);
|
2000-05-31 03:21:36 +00:00
|
|
|
if (!sc->reg) {
|
|
|
|
device_printf(dev, "unable to map register space\n");
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
|
|
|
sc->st = rman_get_bustag(sc->reg);
|
|
|
|
sc->sh = rman_get_bushandle(sc->reg);
|
|
|
|
|
2001-10-08 06:01:13 +00:00
|
|
|
sc->bufsz = pcm_getbuffersize(dev, 4096, DS1_BUFFSIZE, 65536);
|
|
|
|
|
2007-02-23 13:47:34 +00:00
|
|
|
if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(dev), /*alignment*/2,
|
|
|
|
/*boundary*/0,
|
2000-05-31 03:21:36 +00:00
|
|
|
/*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
|
|
|
|
/*highaddr*/BUS_SPACE_MAXADDR,
|
|
|
|
/*filter*/NULL, /*filterarg*/NULL,
|
2001-10-08 06:01:13 +00:00
|
|
|
/*maxsize*/sc->bufsz, /*nsegments*/1, /*maxsegz*/0x3ffff,
|
2006-01-18 01:01:37 +00:00
|
|
|
/*flags*/0, /*lockfunc*/NULL,
|
|
|
|
/*lockarg*/NULL, &sc->buffer_dmat) != 0) {
|
2000-05-31 03:21:36 +00:00
|
|
|
device_printf(dev, "unable to create dma tag\n");
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
2000-08-29 20:50:42 +00:00
|
|
|
sc->regbase = NULL;
|
2007-02-23 19:41:16 +00:00
|
|
|
if (ds_init(sc) == -1) {
|
2000-05-31 03:21:36 +00:00
|
|
|
device_printf(dev, "unable to initialize the card\n");
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
2000-12-18 01:36:41 +00:00
|
|
|
codec = AC97_CREATE(dev, sc, ds_ac97);
|
2000-05-31 03:21:36 +00:00
|
|
|
if (codec == NULL)
|
|
|
|
goto bad;
|
2006-01-11 08:02:15 +00:00
|
|
|
/*
|
|
|
|
* Turn on inverted external amplifier sense flags for few
|
|
|
|
* 'special' boards.
|
|
|
|
*/
|
|
|
|
switch (subdev) {
|
|
|
|
case 0x81171033: /* NEC ValueStar (VT550/0) */
|
|
|
|
ac97_setflags(codec, ac97_getflags(codec) | AC97_F_EAPD_INV);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2000-12-18 01:36:41 +00:00
|
|
|
mixer_init(dev, ac97_getmixerclass(), codec);
|
2000-05-31 03:21:36 +00:00
|
|
|
|
|
|
|
sc->irqid = 0;
|
2004-03-17 17:50:55 +00:00
|
|
|
sc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->irqid,
|
|
|
|
RF_ACTIVE | RF_SHAREABLE);
|
2006-01-11 08:02:15 +00:00
|
|
|
if (!sc->irq || snd_setup_intr(dev, sc->irq, INTR_MPSAFE, ds_intr, sc, &sc->ih)) {
|
2000-05-31 03:21:36 +00:00
|
|
|
device_printf(dev, "unable to map interrupt\n");
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
Use uintmax_t (typedef'd to rman_res_t type) for rman ranges.
On some architectures, u_long isn't large enough for resource definitions.
Particularly, powerpc and arm allow 36-bit (or larger) physical addresses, but
type `long' is only 32-bit. This extends rman's resources to uintmax_t. With
this change, any resource can feasibly be placed anywhere in physical memory
(within the constraints of the driver).
Why uintmax_t and not something machine dependent, or uint64_t? Though it's
possible for uintmax_t to grow, it's highly unlikely it will become 128-bit on
32-bit architectures. 64-bit architectures should have plenty of RAM to absorb
the increase on resource sizes if and when this occurs, and the number of
resources on memory-constrained systems should be sufficiently small as to not
pose a drastic overhead. That being said, uintmax_t was chosen for source
clarity. If it's specified as uint64_t, all printf()-like calls would either
need casts to uintmax_t, or be littered with PRI*64 macros. Casts to uintmax_t
aren't horrible, but it would also bake into the API for
resource_list_print_type() either a hidden assumption that entries get cast to
uintmax_t for printing, or these calls would need the PRI*64 macros. Since
source code is meant to be read more often than written, I chose the clearest
path of simply using uintmax_t.
Tested on a PowerPC p5020-based board, which places all device resources in
0xfxxxxxxxx, and has 8GB RAM.
Regression tested on qemu-system-i386
Regression tested on qemu-system-mips (malta profile)
Tested PAE and devinfo on virtualbox (live CD)
Special thanks to bz for his testing on ARM.
Reviewed By: bz, jhb (previous)
Relnotes: Yes
Sponsored by: Alex Perez/Inertial Computing
Differential Revision: https://reviews.freebsd.org/D4544
2016-03-18 01:28:41 +00:00
|
|
|
snprintf(status, SND_STATUSLEN, "at memory 0x%jx irq %jd %s",
|
2004-03-06 15:52:42 +00:00
|
|
|
rman_get_start(sc->reg), rman_get_start(sc->irq),PCM_KLDSTRING(snd_ds1));
|
2000-05-31 03:21:36 +00:00
|
|
|
|
2000-06-06 22:34:09 +00:00
|
|
|
if (pcm_register(dev, sc, DS1_CHANS, 2))
|
2000-05-31 03:21:36 +00:00
|
|
|
goto bad;
|
|
|
|
for (i = 0; i < DS1_CHANS; i++)
|
2000-12-18 01:36:41 +00:00
|
|
|
pcm_addchan(dev, PCMDIR_PLAY, &ds1pchan_class, sc);
|
2000-06-06 22:34:09 +00:00
|
|
|
for (i = 0; i < 2; i++)
|
2000-12-18 01:36:41 +00:00
|
|
|
pcm_addchan(dev, PCMDIR_REC, &ds1rchan_class, sc);
|
2000-05-31 03:21:36 +00:00
|
|
|
pcm_setstatus(dev, status);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
bad:
|
2000-09-09 19:21:04 +00:00
|
|
|
if (codec)
|
|
|
|
ac97_destroy(codec);
|
2000-05-31 03:21:36 +00:00
|
|
|
if (sc->reg)
|
|
|
|
bus_release_resource(dev, SYS_RES_MEMORY, sc->regid, sc->reg);
|
|
|
|
if (sc->ih)
|
|
|
|
bus_teardown_intr(dev, sc->irq, sc->ih);
|
|
|
|
if (sc->irq)
|
|
|
|
bus_release_resource(dev, SYS_RES_IRQ, sc->irqid, sc->irq);
|
2001-10-08 06:01:13 +00:00
|
|
|
if (sc->buffer_dmat)
|
|
|
|
bus_dma_tag_destroy(sc->buffer_dmat);
|
|
|
|
if (sc->control_dmat)
|
|
|
|
bus_dma_tag_destroy(sc->control_dmat);
|
2001-03-24 23:10:29 +00:00
|
|
|
if (sc->lock)
|
|
|
|
snd_mtxfree(sc->lock);
|
2000-05-31 03:21:36 +00:00
|
|
|
free(sc, M_DEVBUF);
|
|
|
|
return ENXIO;
|
|
|
|
}
|
|
|
|
|
2000-08-29 20:50:42 +00:00
|
|
|
static int
|
|
|
|
ds_pci_resume(device_t dev)
|
|
|
|
{
|
|
|
|
struct sc_info *sc;
|
|
|
|
|
|
|
|
sc = pcm_getdevinfo(dev);
|
|
|
|
|
2007-02-23 19:41:16 +00:00
|
|
|
if (ds_init(sc) == -1) {
|
2000-08-29 20:50:42 +00:00
|
|
|
device_printf(dev, "unable to reinitialize the card\n");
|
|
|
|
return ENXIO;
|
|
|
|
}
|
2000-09-01 20:09:24 +00:00
|
|
|
if (mixer_reinit(dev) == -1) {
|
2000-08-29 20:50:42 +00:00
|
|
|
device_printf(dev, "unable to reinitialize the mixer\n");
|
|
|
|
return ENXIO;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-09-01 20:09:24 +00:00
|
|
|
static int
|
|
|
|
ds_pci_detach(device_t dev)
|
|
|
|
{
|
|
|
|
int r;
|
|
|
|
struct sc_info *sc;
|
|
|
|
|
|
|
|
r = pcm_unregister(dev);
|
|
|
|
if (r)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
sc = pcm_getdevinfo(dev);
|
|
|
|
ds_uninit(sc);
|
2000-09-09 19:21:04 +00:00
|
|
|
bus_release_resource(dev, SYS_RES_MEMORY, sc->regid, sc->reg);
|
|
|
|
bus_teardown_intr(dev, sc->irq, sc->ih);
|
|
|
|
bus_release_resource(dev, SYS_RES_IRQ, sc->irqid, sc->irq);
|
2001-10-08 06:01:13 +00:00
|
|
|
bus_dma_tag_destroy(sc->buffer_dmat);
|
|
|
|
bus_dma_tag_destroy(sc->control_dmat);
|
2001-03-24 23:10:29 +00:00
|
|
|
snd_mtxfree(sc->lock);
|
2000-09-01 20:09:24 +00:00
|
|
|
free(sc, M_DEVBUF);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-05-31 03:21:36 +00:00
|
|
|
static device_method_t ds1_methods[] = {
|
|
|
|
/* Device interface */
|
|
|
|
DEVMETHOD(device_probe, ds_pci_probe),
|
|
|
|
DEVMETHOD(device_attach, ds_pci_attach),
|
2000-09-01 20:09:24 +00:00
|
|
|
DEVMETHOD(device_detach, ds_pci_detach),
|
|
|
|
DEVMETHOD(device_resume, ds_pci_resume),
|
2000-05-31 03:21:36 +00:00
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static driver_t ds1_driver = {
|
|
|
|
"pcm",
|
|
|
|
ds1_methods,
|
2001-08-23 11:30:52 +00:00
|
|
|
PCM_SOFTC_SIZE,
|
2000-05-31 03:21:36 +00:00
|
|
|
};
|
|
|
|
|
2000-07-03 20:52:27 +00:00
|
|
|
DRIVER_MODULE(snd_ds1, pci, ds1_driver, pcm_devclass, 0, 0);
|
2004-07-16 04:00:08 +00:00
|
|
|
MODULE_DEPEND(snd_ds1, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER);
|
2000-07-03 20:52:27 +00:00
|
|
|
MODULE_VERSION(snd_ds1, 1);
|