2005-01-06 01:43:34 +00:00
|
|
|
/*-
|
2003-09-07 16:28:03 +00:00
|
|
|
* Copyright (c) 1999 Cameron Grant <cg@freebsd.org>
|
1999-09-01 04:08:39 +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
|
|
|
|
|
1999-11-20 16:50:33 +00:00
|
|
|
#include <dev/sound/pcm/sound.h>
|
|
|
|
#include <dev/sound/pcm/ac97.h>
|
|
|
|
#include <dev/sound/pci/t4dwave.h>
|
1999-09-01 04:08:39 +00:00
|
|
|
|
2003-08-22 07:08:17 +00:00
|
|
|
#include <dev/pci/pcireg.h>
|
|
|
|
#include <dev/pci/pcivar.h>
|
1999-09-01 04:08:39 +00:00
|
|
|
|
2001-08-23 11:30:52 +00:00
|
|
|
SND_DECLARE_FILE("$FreeBSD$");
|
|
|
|
|
1999-09-01 04:08:39 +00:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
1999-12-12 02:16:14 +00:00
|
|
|
#define TDX_PCI_ID 0x20001023
|
|
|
|
#define TNX_PCI_ID 0x20011023
|
2001-08-29 09:04:22 +00:00
|
|
|
#define ALI_PCI_ID 0x545110b9
|
2001-08-26 19:15:28 +00:00
|
|
|
#define SPA_PCI_ID 0x70181039
|
1999-12-12 02:16:14 +00:00
|
|
|
|
2001-10-08 05:59:54 +00:00
|
|
|
#define TR_DEFAULT_BUFSZ 0x1000
|
2009-09-22 11:38:45 +00:00
|
|
|
/* For ALi M5451 the DMA transfer size appears to be fixed to 64k. */
|
|
|
|
#define ALI_BUFSZ 0x10000
|
|
|
|
#define TR_BUFALGN 0x8
|
1999-12-12 02:16:14 +00:00
|
|
|
#define TR_TIMEOUT_CDC 0xffff
|
2009-09-22 11:38:45 +00:00
|
|
|
#define TR_MAXHWCH 64
|
|
|
|
#define ALI_MAXHWCH 32
|
1999-12-12 02:16:14 +00:00
|
|
|
#define TR_MAXPLAYCH 4
|
2009-09-22 11:38:45 +00:00
|
|
|
#define ALI_MAXPLAYCH 1
|
2004-10-13 06:04:01 +00:00
|
|
|
/*
|
2009-09-22 11:38:45 +00:00
|
|
|
* Though, it's not clearly documented in the 4DWAVE datasheet, the
|
|
|
|
* DX and NX chips can't handle DMA addresses located above 1GB as the
|
|
|
|
* LBA (loop begin address) register which holds the DMA base address
|
|
|
|
* is 32-bit, but the two MSBs are used for other purposes.
|
2004-10-13 06:04:01 +00:00
|
|
|
*/
|
2009-09-22 11:38:45 +00:00
|
|
|
#define TR_MAXADDR ((1U << 30) - 1)
|
|
|
|
#define ALI_MAXADDR ((1U << 31) - 1)
|
1999-12-12 02:16:14 +00:00
|
|
|
|
1999-09-01 04:08:39 +00:00
|
|
|
struct tr_info;
|
|
|
|
|
|
|
|
/* channel registers */
|
|
|
|
struct tr_chinfo {
|
|
|
|
u_int32_t cso, alpha, fms, fmc, ec;
|
|
|
|
u_int32_t lba;
|
|
|
|
u_int32_t eso, delta;
|
|
|
|
u_int32_t rvol, cvol;
|
|
|
|
u_int32_t gvsel, pan, vol, ctrl;
|
2001-11-24 18:00:33 +00:00
|
|
|
u_int32_t active:1, was_active:1;
|
2001-01-24 01:20:04 +00:00
|
|
|
int index, bufhalf;
|
2001-03-24 23:10:29 +00:00
|
|
|
struct snd_dbuf *buffer;
|
|
|
|
struct pcm_channel *channel;
|
1999-09-01 04:08:39 +00:00
|
|
|
struct tr_info *parent;
|
|
|
|
};
|
|
|
|
|
2000-12-24 03:56:41 +00:00
|
|
|
struct tr_rchinfo {
|
|
|
|
u_int32_t delta;
|
2001-11-24 18:00:33 +00:00
|
|
|
u_int32_t active:1, was_active:1;
|
2001-03-24 23:10:29 +00:00
|
|
|
struct snd_dbuf *buffer;
|
|
|
|
struct pcm_channel *channel;
|
2000-12-24 03:56:41 +00:00
|
|
|
struct tr_info *parent;
|
|
|
|
};
|
|
|
|
|
1999-09-01 04:08:39 +00:00
|
|
|
/* device private data */
|
|
|
|
struct tr_info {
|
|
|
|
u_int32_t type;
|
2002-10-14 11:47:37 +00:00
|
|
|
u_int32_t rev;
|
1999-09-01 04:08:39 +00:00
|
|
|
|
|
|
|
bus_space_tag_t st;
|
|
|
|
bus_space_handle_t sh;
|
|
|
|
bus_dma_tag_t parent_dmat;
|
|
|
|
|
|
|
|
struct resource *reg, *irq;
|
2001-10-08 05:59:54 +00:00
|
|
|
int regtype, regid, irqid;
|
|
|
|
void *ih;
|
1999-09-01 04:08:39 +00:00
|
|
|
|
2002-11-26 18:16:27 +00:00
|
|
|
struct mtx *lock;
|
2001-03-24 23:10:29 +00:00
|
|
|
|
2009-09-22 11:38:45 +00:00
|
|
|
u_int32_t hwchns;
|
1999-09-01 04:08:39 +00:00
|
|
|
u_int32_t playchns;
|
2001-10-08 05:59:54 +00:00
|
|
|
unsigned int bufsz;
|
|
|
|
|
1999-09-01 04:08:39 +00:00
|
|
|
struct tr_chinfo chinfo[TR_MAXPLAYCH];
|
2000-12-24 03:56:41 +00:00
|
|
|
struct tr_rchinfo recchinfo;
|
1999-09-01 04:08:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
2000-08-20 22:18:56 +00:00
|
|
|
static u_int32_t tr_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
|
1999-09-01 04:08:39 +00:00
|
|
|
};
|
2001-03-24 23:10:29 +00:00
|
|
|
static struct pcmchan_caps tr_reccaps = {4000, 48000, tr_recfmt, 0};
|
2000-08-20 22:18:56 +00:00
|
|
|
|
|
|
|
static u_int32_t tr_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_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
|
1999-09-01 04:08:39 +00:00
|
|
|
};
|
2001-03-24 23:10:29 +00:00
|
|
|
static struct pcmchan_caps tr_playcaps = {4000, 48000, tr_playfmt, 0};
|
1999-09-01 04:08:39 +00:00
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/* Hardware */
|
|
|
|
|
|
|
|
static u_int32_t
|
|
|
|
tr_rd(struct tr_info *tr, int regno, int size)
|
|
|
|
{
|
|
|
|
switch(size) {
|
|
|
|
case 1:
|
|
|
|
return bus_space_read_1(tr->st, tr->sh, regno);
|
|
|
|
case 2:
|
|
|
|
return bus_space_read_2(tr->st, tr->sh, regno);
|
|
|
|
case 4:
|
|
|
|
return bus_space_read_4(tr->st, tr->sh, regno);
|
|
|
|
default:
|
|
|
|
return 0xffffffff;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tr_wr(struct tr_info *tr, int regno, u_int32_t data, int size)
|
|
|
|
{
|
|
|
|
switch(size) {
|
|
|
|
case 1:
|
|
|
|
bus_space_write_1(tr->st, tr->sh, regno, data);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
bus_space_write_2(tr->st, tr->sh, regno, data);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
bus_space_write_4(tr->st, tr->sh, regno, data);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-12-18 01:36:41 +00:00
|
|
|
/* -------------------------------------------------------------------- */
|
1999-09-01 04:08:39 +00:00
|
|
|
/* ac97 codec */
|
|
|
|
|
2000-12-18 01:36:41 +00:00
|
|
|
static int
|
|
|
|
tr_rdcd(kobj_t obj, void *devinfo, int regno)
|
1999-09-01 04:08:39 +00:00
|
|
|
{
|
|
|
|
struct tr_info *tr = (struct tr_info *)devinfo;
|
|
|
|
int i, j, treg, trw;
|
|
|
|
|
|
|
|
switch (tr->type) {
|
2001-08-26 19:15:28 +00:00
|
|
|
case SPA_PCI_ID:
|
|
|
|
treg=SPA_REG_CODECRD;
|
|
|
|
trw=SPA_CDC_RWSTAT;
|
|
|
|
break;
|
2001-08-29 09:04:22 +00:00
|
|
|
case ALI_PCI_ID:
|
2002-10-14 11:47:37 +00:00
|
|
|
if (tr->rev > 0x01)
|
|
|
|
treg=TDX_REG_CODECWR;
|
|
|
|
else
|
|
|
|
treg=TDX_REG_CODECRD;
|
|
|
|
trw=TDX_CDC_RWSTAT;
|
|
|
|
break;
|
1999-09-01 04:08:39 +00:00
|
|
|
case TDX_PCI_ID:
|
|
|
|
treg=TDX_REG_CODECRD;
|
|
|
|
trw=TDX_CDC_RWSTAT;
|
|
|
|
break;
|
|
|
|
case TNX_PCI_ID:
|
|
|
|
treg=(regno & 0x100)? TNX_REG_CODEC2RD : TNX_REG_CODEC1RD;
|
|
|
|
trw=TNX_CDC_RWSTAT;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("!!! tr_rdcd defaulted !!!\n");
|
2000-12-18 01:36:41 +00:00
|
|
|
return -1;
|
1999-09-01 04:08:39 +00:00
|
|
|
}
|
|
|
|
|
2002-10-17 03:45:34 +00:00
|
|
|
i = j = 0;
|
|
|
|
|
1999-09-01 04:08:39 +00:00
|
|
|
regno &= 0x7f;
|
2001-03-24 23:10:29 +00:00
|
|
|
snd_mtxlock(tr->lock);
|
2002-10-14 11:47:37 +00:00
|
|
|
if (tr->type == ALI_PCI_ID) {
|
|
|
|
u_int32_t chk1, chk2;
|
|
|
|
j = trw;
|
|
|
|
for (i = TR_TIMEOUT_CDC; (i > 0) && (j & trw); i--)
|
|
|
|
j = tr_rd(tr, treg, 4);
|
|
|
|
if (i > 0) {
|
|
|
|
chk1 = tr_rd(tr, 0xc8, 4);
|
|
|
|
chk2 = tr_rd(tr, 0xc8, 4);
|
|
|
|
for (i = TR_TIMEOUT_CDC; (i > 0) && (chk1 == chk2);
|
|
|
|
i--)
|
|
|
|
chk2 = tr_rd(tr, 0xc8, 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (tr->type != ALI_PCI_ID || i > 0) {
|
|
|
|
tr_wr(tr, treg, regno | trw, 4);
|
|
|
|
j=trw;
|
|
|
|
for (i=TR_TIMEOUT_CDC; (i > 0) && (j & trw); i--)
|
|
|
|
j=tr_rd(tr, treg, 4);
|
|
|
|
}
|
2001-03-24 23:10:29 +00:00
|
|
|
snd_mtxunlock(tr->lock);
|
1999-09-01 04:08:39 +00:00
|
|
|
if (i == 0) printf("codec timeout during read of register %x\n", regno);
|
|
|
|
return (j >> TR_CDC_DATA) & 0xffff;
|
|
|
|
}
|
|
|
|
|
2000-12-18 01:36:41 +00:00
|
|
|
static int
|
|
|
|
tr_wrcd(kobj_t obj, void *devinfo, int regno, u_int32_t data)
|
1999-09-01 04:08:39 +00:00
|
|
|
{
|
|
|
|
struct tr_info *tr = (struct tr_info *)devinfo;
|
|
|
|
int i, j, treg, trw;
|
|
|
|
|
|
|
|
switch (tr->type) {
|
2001-08-26 19:15:28 +00:00
|
|
|
case SPA_PCI_ID:
|
|
|
|
treg=SPA_REG_CODECWR;
|
|
|
|
trw=SPA_CDC_RWSTAT;
|
|
|
|
break;
|
2001-08-29 09:04:22 +00:00
|
|
|
case ALI_PCI_ID:
|
1999-09-01 04:08:39 +00:00
|
|
|
case TDX_PCI_ID:
|
|
|
|
treg=TDX_REG_CODECWR;
|
|
|
|
trw=TDX_CDC_RWSTAT;
|
|
|
|
break;
|
|
|
|
case TNX_PCI_ID:
|
|
|
|
treg=TNX_REG_CODECWR;
|
|
|
|
trw=TNX_CDC_RWSTAT | ((regno & 0x100)? TNX_CDC_SEC : 0);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("!!! tr_wrcd defaulted !!!");
|
2000-12-18 01:36:41 +00:00
|
|
|
return -1;
|
1999-09-01 04:08:39 +00:00
|
|
|
}
|
|
|
|
|
2002-10-17 03:45:34 +00:00
|
|
|
i = 0;
|
|
|
|
|
1999-09-01 04:08:39 +00:00
|
|
|
regno &= 0x7f;
|
|
|
|
#if 0
|
|
|
|
printf("tr_wrcd: reg %x was %x", regno, tr_rdcd(devinfo, regno));
|
|
|
|
#endif
|
|
|
|
j=trw;
|
2001-03-24 23:10:29 +00:00
|
|
|
snd_mtxlock(tr->lock);
|
2002-10-14 11:47:37 +00:00
|
|
|
if (tr->type == ALI_PCI_ID) {
|
|
|
|
j = trw;
|
|
|
|
for (i = TR_TIMEOUT_CDC; (i > 0) && (j & trw); i--)
|
|
|
|
j = tr_rd(tr, treg, 4);
|
|
|
|
if (i > 0) {
|
|
|
|
u_int32_t chk1, chk2;
|
|
|
|
chk1 = tr_rd(tr, 0xc8, 4);
|
|
|
|
chk2 = tr_rd(tr, 0xc8, 4);
|
|
|
|
for (i = TR_TIMEOUT_CDC; (i > 0) && (chk1 == chk2);
|
|
|
|
i--)
|
|
|
|
chk2 = tr_rd(tr, 0xc8, 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (tr->type != ALI_PCI_ID || i > 0) {
|
2002-11-26 18:16:27 +00:00
|
|
|
for (i=TR_TIMEOUT_CDC; (i>0) && (j & trw); i--)
|
2002-10-14 11:47:37 +00:00
|
|
|
j=tr_rd(tr, treg, 4);
|
|
|
|
if (tr->type == ALI_PCI_ID && tr->rev > 0x01)
|
|
|
|
trw |= 0x0100;
|
|
|
|
tr_wr(tr, treg, (data << TR_CDC_DATA) | regno | trw, 4);
|
|
|
|
}
|
1999-09-01 04:08:39 +00:00
|
|
|
#if 0
|
|
|
|
printf(" - wrote %x, now %x\n", data, tr_rdcd(devinfo, regno));
|
|
|
|
#endif
|
2001-03-24 23:10:29 +00:00
|
|
|
snd_mtxunlock(tr->lock);
|
1999-09-01 04:08:39 +00:00
|
|
|
if (i==0) printf("codec timeout writing %x, data %x\n", regno, data);
|
2000-12-18 01:36:41 +00:00
|
|
|
return (i > 0)? 0 : -1;
|
1999-09-01 04:08:39 +00:00
|
|
|
}
|
|
|
|
|
2000-12-18 01:36:41 +00:00
|
|
|
static kobj_method_t tr_ac97_methods[] = {
|
|
|
|
KOBJMETHOD(ac97_read, tr_rdcd),
|
|
|
|
KOBJMETHOD(ac97_write, tr_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(tr_ac97);
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
1999-09-01 04:08:39 +00:00
|
|
|
/* playback channel interrupts */
|
|
|
|
|
2001-01-24 01:20:04 +00:00
|
|
|
#if 0
|
1999-09-01 04:08:39 +00:00
|
|
|
static u_int32_t
|
2000-12-24 03:56:41 +00:00
|
|
|
tr_testint(struct tr_chinfo *ch)
|
1999-09-01 04:08:39 +00:00
|
|
|
{
|
2000-12-24 03:56:41 +00:00
|
|
|
struct tr_info *tr = ch->parent;
|
|
|
|
int bank, chan;
|
|
|
|
|
|
|
|
bank = (ch->index & 0x20) ? 1 : 0;
|
|
|
|
chan = ch->index & 0x1f;
|
|
|
|
return tr_rd(tr, bank? TR_REG_ADDRINTB : TR_REG_ADDRINTA, 4) & (1 << chan);
|
1999-09-01 04:08:39 +00:00
|
|
|
}
|
2001-01-24 01:20:04 +00:00
|
|
|
#endif
|
1999-09-01 04:08:39 +00:00
|
|
|
|
|
|
|
static void
|
2000-12-24 03:56:41 +00:00
|
|
|
tr_clrint(struct tr_chinfo *ch)
|
1999-09-01 04:08:39 +00:00
|
|
|
{
|
2000-12-24 03:56:41 +00:00
|
|
|
struct tr_info *tr = ch->parent;
|
|
|
|
int bank, chan;
|
|
|
|
|
|
|
|
bank = (ch->index & 0x20) ? 1 : 0;
|
|
|
|
chan = ch->index & 0x1f;
|
|
|
|
tr_wr(tr, bank? TR_REG_ADDRINTB : TR_REG_ADDRINTA, 1 << chan, 4);
|
1999-09-01 04:08:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-12-24 03:56:41 +00:00
|
|
|
tr_enaint(struct tr_chinfo *ch, int enable)
|
1999-09-01 04:08:39 +00:00
|
|
|
{
|
2000-12-24 03:56:41 +00:00
|
|
|
struct tr_info *tr = ch->parent;
|
|
|
|
u_int32_t i, reg;
|
|
|
|
int bank, chan;
|
|
|
|
|
2001-03-24 23:10:29 +00:00
|
|
|
snd_mtxlock(tr->lock);
|
2000-12-24 03:56:41 +00:00
|
|
|
bank = (ch->index & 0x20) ? 1 : 0;
|
|
|
|
chan = ch->index & 0x1f;
|
|
|
|
reg = bank? TR_REG_INTENB : TR_REG_INTENA;
|
|
|
|
|
|
|
|
i = tr_rd(tr, reg, 4);
|
|
|
|
i &= ~(1 << chan);
|
|
|
|
i |= (enable? 1 : 0) << chan;
|
|
|
|
|
|
|
|
tr_clrint(ch);
|
1999-09-01 04:08:39 +00:00
|
|
|
tr_wr(tr, reg, i, 4);
|
2001-03-24 23:10:29 +00:00
|
|
|
snd_mtxunlock(tr->lock);
|
1999-09-01 04:08:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* playback channels */
|
|
|
|
|
|
|
|
static void
|
2000-12-24 03:56:41 +00:00
|
|
|
tr_selch(struct tr_chinfo *ch)
|
1999-09-01 04:08:39 +00:00
|
|
|
{
|
2000-12-24 03:56:41 +00:00
|
|
|
struct tr_info *tr = ch->parent;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
i = tr_rd(tr, TR_REG_CIR, 4);
|
1999-09-01 04:08:39 +00:00
|
|
|
i &= ~TR_CIR_MASK;
|
2000-12-24 03:56:41 +00:00
|
|
|
i |= ch->index & 0x3f;
|
1999-09-01 04:08:39 +00:00
|
|
|
tr_wr(tr, TR_REG_CIR, i, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-12-24 03:56:41 +00:00
|
|
|
tr_startch(struct tr_chinfo *ch)
|
1999-09-01 04:08:39 +00:00
|
|
|
{
|
2000-12-24 03:56:41 +00:00
|
|
|
struct tr_info *tr = ch->parent;
|
|
|
|
int bank, chan;
|
|
|
|
|
|
|
|
bank = (ch->index & 0x20) ? 1 : 0;
|
|
|
|
chan = ch->index & 0x1f;
|
|
|
|
tr_wr(tr, bank? TR_REG_STARTB : TR_REG_STARTA, 1 << chan, 4);
|
1999-09-01 04:08:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-12-24 03:56:41 +00:00
|
|
|
tr_stopch(struct tr_chinfo *ch)
|
1999-09-01 04:08:39 +00:00
|
|
|
{
|
2000-12-24 03:56:41 +00:00
|
|
|
struct tr_info *tr = ch->parent;
|
|
|
|
int bank, chan;
|
|
|
|
|
|
|
|
bank = (ch->index & 0x20) ? 1 : 0;
|
|
|
|
chan = ch->index & 0x1f;
|
|
|
|
tr_wr(tr, bank? TR_REG_STOPB : TR_REG_STOPA, 1 << chan, 4);
|
1999-09-01 04:08:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-12-24 03:56:41 +00:00
|
|
|
tr_wrch(struct tr_chinfo *ch)
|
1999-09-01 04:08:39 +00:00
|
|
|
{
|
2000-12-24 03:56:41 +00:00
|
|
|
struct tr_info *tr = ch->parent;
|
1999-09-01 04:08:39 +00:00
|
|
|
u_int32_t cr[TR_CHN_REGS], i;
|
|
|
|
|
|
|
|
ch->gvsel &= 0x00000001;
|
|
|
|
ch->fmc &= 0x00000003;
|
|
|
|
ch->fms &= 0x0000000f;
|
|
|
|
ch->ctrl &= 0x0000000f;
|
|
|
|
ch->pan &= 0x0000007f;
|
|
|
|
ch->rvol &= 0x0000007f;
|
|
|
|
ch->cvol &= 0x0000007f;
|
|
|
|
ch->vol &= 0x000000ff;
|
|
|
|
ch->ec &= 0x00000fff;
|
|
|
|
ch->alpha &= 0x00000fff;
|
|
|
|
ch->delta &= 0x0000ffff;
|
2009-09-22 11:38:45 +00:00
|
|
|
if (tr->type == ALI_PCI_ID)
|
|
|
|
ch->lba &= ALI_MAXADDR;
|
|
|
|
else
|
|
|
|
ch->lba &= TR_MAXADDR;
|
1999-09-01 04:08:39 +00:00
|
|
|
|
|
|
|
cr[1]=ch->lba;
|
2001-01-24 01:20:04 +00:00
|
|
|
cr[3]=(ch->fmc<<14) | (ch->rvol<<7) | (ch->cvol);
|
|
|
|
cr[4]=(ch->gvsel<<31) | (ch->pan<<24) | (ch->vol<<16) | (ch->ctrl<<12) | (ch->ec);
|
1999-09-01 04:08:39 +00:00
|
|
|
|
|
|
|
switch (tr->type) {
|
2001-08-26 19:15:28 +00:00
|
|
|
case SPA_PCI_ID:
|
2001-08-29 09:04:22 +00:00
|
|
|
case ALI_PCI_ID:
|
1999-09-01 04:08:39 +00:00
|
|
|
case TDX_PCI_ID:
|
|
|
|
ch->cso &= 0x0000ffff;
|
|
|
|
ch->eso &= 0x0000ffff;
|
|
|
|
cr[0]=(ch->cso<<16) | (ch->alpha<<4) | (ch->fms);
|
|
|
|
cr[2]=(ch->eso<<16) | (ch->delta);
|
|
|
|
break;
|
|
|
|
case TNX_PCI_ID:
|
|
|
|
ch->cso &= 0x00ffffff;
|
|
|
|
ch->eso &= 0x00ffffff;
|
|
|
|
cr[0]=((ch->delta & 0xff)<<24) | (ch->cso);
|
2001-08-23 12:02:29 +00:00
|
|
|
cr[2]=((ch->delta>>8)<<24) | (ch->eso);
|
1999-09-01 04:08:39 +00:00
|
|
|
cr[3]|=(ch->alpha<<20) | (ch->fms<<16) | (ch->fmc<<14);
|
|
|
|
break;
|
|
|
|
}
|
2001-03-24 23:10:29 +00:00
|
|
|
snd_mtxlock(tr->lock);
|
2000-12-24 03:56:41 +00:00
|
|
|
tr_selch(ch);
|
1999-09-01 04:08:39 +00:00
|
|
|
for (i=0; i<TR_CHN_REGS; i++)
|
|
|
|
tr_wr(tr, TR_REG_CHNBASE+(i<<2), cr[i], 4);
|
2001-03-24 23:10:29 +00:00
|
|
|
snd_mtxunlock(tr->lock);
|
1999-09-01 04:08:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-12-24 03:56:41 +00:00
|
|
|
tr_rdch(struct tr_chinfo *ch)
|
1999-09-01 04:08:39 +00:00
|
|
|
{
|
2000-12-24 03:56:41 +00:00
|
|
|
struct tr_info *tr = ch->parent;
|
1999-09-01 04:08:39 +00:00
|
|
|
u_int32_t cr[5], i;
|
2000-12-24 03:56:41 +00:00
|
|
|
|
2001-03-24 23:10:29 +00:00
|
|
|
snd_mtxlock(tr->lock);
|
2000-12-24 03:56:41 +00:00
|
|
|
tr_selch(ch);
|
|
|
|
for (i=0; i<5; i++)
|
|
|
|
cr[i]=tr_rd(tr, TR_REG_CHNBASE+(i<<2), 4);
|
2001-03-24 23:10:29 +00:00
|
|
|
snd_mtxunlock(tr->lock);
|
2000-12-24 03:56:41 +00:00
|
|
|
|
|
|
|
|
2009-09-22 11:38:45 +00:00
|
|
|
if (tr->type == ALI_PCI_ID)
|
|
|
|
ch->lba=(cr[1] & ALI_MAXADDR);
|
|
|
|
else
|
|
|
|
ch->lba=(cr[1] & TR_MAXADDR);
|
1999-09-01 04:08:39 +00:00
|
|
|
ch->fmc= (cr[3] & 0x0000c000) >> 14;
|
|
|
|
ch->rvol= (cr[3] & 0x00003f80) >> 7;
|
|
|
|
ch->cvol= (cr[3] & 0x0000007f);
|
|
|
|
ch->gvsel= (cr[4] & 0x80000000) >> 31;
|
|
|
|
ch->pan= (cr[4] & 0x7f000000) >> 24;
|
|
|
|
ch->vol= (cr[4] & 0x00ff0000) >> 16;
|
|
|
|
ch->ctrl= (cr[4] & 0x0000f000) >> 12;
|
|
|
|
ch->ec= (cr[4] & 0x00000fff);
|
|
|
|
switch(tr->type) {
|
2001-08-26 19:15:28 +00:00
|
|
|
case SPA_PCI_ID:
|
2001-08-29 09:04:22 +00:00
|
|
|
case ALI_PCI_ID:
|
1999-09-01 04:08:39 +00:00
|
|
|
case TDX_PCI_ID:
|
|
|
|
ch->cso= (cr[0] & 0xffff0000) >> 16;
|
|
|
|
ch->alpha= (cr[0] & 0x0000fff0) >> 4;
|
|
|
|
ch->fms= (cr[0] & 0x0000000f);
|
|
|
|
ch->eso= (cr[2] & 0xffff0000) >> 16;
|
|
|
|
ch->delta= (cr[2] & 0x0000ffff);
|
|
|
|
break;
|
|
|
|
case TNX_PCI_ID:
|
|
|
|
ch->cso= (cr[0] & 0x00ffffff);
|
|
|
|
ch->eso= (cr[2] & 0x00ffffff);
|
2000-12-24 03:56:41 +00:00
|
|
|
ch->delta= ((cr[2] & 0xff000000) >> 16) | ((cr[0] & 0xff000000) >> 24);
|
1999-09-01 04:08:39 +00:00
|
|
|
ch->alpha= (cr[3] & 0xfff00000) >> 20;
|
|
|
|
ch->fms= (cr[3] & 0x000f0000) >> 16;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-24 01:20:04 +00:00
|
|
|
static u_int32_t
|
|
|
|
tr_fmttobits(u_int32_t fmt)
|
|
|
|
{
|
|
|
|
u_int32_t bits;
|
|
|
|
|
|
|
|
bits = 0;
|
|
|
|
bits |= (fmt & AFMT_SIGNED)? 0x2 : 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
|
|
|
bits |= (AFMT_CHANNEL(fmt) > 1)? 0x4 : 0;
|
2001-01-24 01:20:04 +00:00
|
|
|
bits |= (fmt & AFMT_16BIT)? 0x8 : 0;
|
|
|
|
|
|
|
|
return bits;
|
|
|
|
}
|
|
|
|
|
2000-12-18 01:36:41 +00:00
|
|
|
/* -------------------------------------------------------------------- */
|
1999-09-01 04:08:39 +00:00
|
|
|
/* channel interface */
|
|
|
|
|
2000-12-18 01:36:41 +00:00
|
|
|
static void *
|
2001-03-24 23:10:29 +00:00
|
|
|
trpchan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir)
|
1999-09-01 04:08:39 +00:00
|
|
|
{
|
|
|
|
struct tr_info *tr = devinfo;
|
|
|
|
struct tr_chinfo *ch;
|
2000-12-24 03:56:41 +00:00
|
|
|
|
|
|
|
KASSERT(dir == PCMDIR_PLAY, ("trpchan_init: bad direction"));
|
|
|
|
ch = &tr->chinfo[tr->playchns];
|
|
|
|
ch->index = tr->playchns++;
|
1999-09-01 04:08:39 +00:00
|
|
|
ch->buffer = b;
|
|
|
|
ch->parent = tr;
|
|
|
|
ch->channel = c;
|
2007-04-18 18:26:41 +00:00
|
|
|
if (sndbuf_alloc(ch->buffer, tr->parent_dmat, 0, tr->bufsz) != 0)
|
2000-12-24 03:56:41 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return ch;
|
1999-09-01 04:08:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2000-12-24 03:56:41 +00:00
|
|
|
trpchan_setformat(kobj_t obj, void *data, u_int32_t format)
|
1999-09-01 04:08:39 +00:00
|
|
|
{
|
|
|
|
struct tr_chinfo *ch = data;
|
2000-12-24 03:56:41 +00:00
|
|
|
|
|
|
|
ch->ctrl = tr_fmttobits(format) | 0x01;
|
|
|
|
|
|
|
|
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-24 03:56:41 +00:00
|
|
|
trpchan_setspeed(kobj_t obj, void *data, u_int32_t speed)
|
|
|
|
{
|
|
|
|
struct tr_chinfo *ch = data;
|
|
|
|
|
|
|
|
ch->delta = (speed << 12) / 48000;
|
|
|
|
return (ch->delta * 48000) >> 12;
|
|
|
|
}
|
|
|
|
|
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-24 03:56:41 +00:00
|
|
|
trpchan_setblocksize(kobj_t obj, void *data, u_int32_t blocksize)
|
|
|
|
{
|
|
|
|
struct tr_chinfo *ch = data;
|
|
|
|
|
|
|
|
sndbuf_resize(ch->buffer, 2, blocksize);
|
|
|
|
return blocksize;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
trpchan_trigger(kobj_t obj, void *data, int go)
|
|
|
|
{
|
|
|
|
struct tr_chinfo *ch = data;
|
|
|
|
|
2007-06-11 00:49:46 +00:00
|
|
|
if (!PCMTRIG_COMMON(go))
|
2000-12-24 03:56:41 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (go == PCMTRIG_START) {
|
2001-01-24 01:20:04 +00:00
|
|
|
ch->fmc = 3;
|
|
|
|
ch->fms = 0;
|
|
|
|
ch->ec = 0;
|
|
|
|
ch->alpha = 0;
|
2003-02-20 17:31:12 +00:00
|
|
|
ch->lba = sndbuf_getbufaddr(ch->buffer);
|
1999-09-01 04:08:39 +00:00
|
|
|
ch->cso = 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
|
|
|
ch->eso = (sndbuf_getsize(ch->buffer) / sndbuf_getalign(ch->buffer)) - 1;
|
2001-01-24 01:20:04 +00:00
|
|
|
ch->rvol = ch->cvol = 0x7f;
|
1999-09-01 04:08:39 +00:00
|
|
|
ch->gvsel = 0;
|
|
|
|
ch->pan = 0;
|
|
|
|
ch->vol = 0;
|
2001-01-24 01:20:04 +00:00
|
|
|
ch->bufhalf = 0;
|
2000-12-24 03:56:41 +00:00
|
|
|
tr_wrch(ch);
|
|
|
|
tr_enaint(ch, 1);
|
|
|
|
tr_startch(ch);
|
2001-11-24 18:00:33 +00:00
|
|
|
ch->active = 1;
|
|
|
|
} else {
|
2000-12-24 03:56:41 +00:00
|
|
|
tr_stopch(ch);
|
2001-11-24 18:00:33 +00:00
|
|
|
ch->active = 0;
|
|
|
|
}
|
2000-12-24 03:56:41 +00:00
|
|
|
|
1999-09-01 04:08:39 +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-24 03:56:41 +00:00
|
|
|
trpchan_getptr(kobj_t obj, void *data)
|
1999-09-01 04:08:39 +00:00
|
|
|
{
|
|
|
|
struct tr_chinfo *ch = data;
|
2000-12-24 03:56:41 +00:00
|
|
|
|
|
|
|
tr_rdch(ch);
|
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
|
|
|
return ch->cso * sndbuf_getalign(ch->buffer);
|
2000-12-24 03:56:41 +00:00
|
|
|
}
|
|
|
|
|
2001-03-24 23:10:29 +00:00
|
|
|
static struct pcmchan_caps *
|
2000-12-24 03:56:41 +00:00
|
|
|
trpchan_getcaps(kobj_t obj, void *data)
|
|
|
|
{
|
|
|
|
return &tr_playcaps;
|
|
|
|
}
|
|
|
|
|
|
|
|
static kobj_method_t trpchan_methods[] = {
|
|
|
|
KOBJMETHOD(channel_init, trpchan_init),
|
|
|
|
KOBJMETHOD(channel_setformat, trpchan_setformat),
|
|
|
|
KOBJMETHOD(channel_setspeed, trpchan_setspeed),
|
|
|
|
KOBJMETHOD(channel_setblocksize, trpchan_setblocksize),
|
|
|
|
KOBJMETHOD(channel_trigger, trpchan_trigger),
|
|
|
|
KOBJMETHOD(channel_getptr, trpchan_getptr),
|
|
|
|
KOBJMETHOD(channel_getcaps, trpchan_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-24 03:56:41 +00:00
|
|
|
};
|
|
|
|
CHANNEL_DECLARE(trpchan);
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/* rec channel interface */
|
|
|
|
|
|
|
|
static void *
|
2001-03-24 23:10:29 +00:00
|
|
|
trrchan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir)
|
2000-12-24 03:56:41 +00:00
|
|
|
{
|
|
|
|
struct tr_info *tr = devinfo;
|
|
|
|
struct tr_rchinfo *ch;
|
|
|
|
|
|
|
|
KASSERT(dir == PCMDIR_REC, ("trrchan_init: bad direction"));
|
|
|
|
ch = &tr->recchinfo;
|
|
|
|
ch->buffer = b;
|
|
|
|
ch->parent = tr;
|
|
|
|
ch->channel = c;
|
2007-04-18 18:26:41 +00:00
|
|
|
if (sndbuf_alloc(ch->buffer, tr->parent_dmat, 0, tr->bufsz) != 0)
|
2000-12-24 03:56:41 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return ch;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
trrchan_setformat(kobj_t obj, void *data, u_int32_t format)
|
|
|
|
{
|
|
|
|
struct tr_rchinfo *ch = data;
|
1999-09-01 04:08:39 +00:00
|
|
|
struct tr_info *tr = ch->parent;
|
2000-12-24 03:56:41 +00:00
|
|
|
u_int32_t i, bits;
|
|
|
|
|
|
|
|
bits = tr_fmttobits(format);
|
|
|
|
/* set # of samples between interrupts */
|
2001-01-24 01:20:04 +00:00
|
|
|
i = (sndbuf_runsz(ch->buffer) >> ((bits & 0x08)? 1 : 0)) - 1;
|
2000-12-24 03:56:41 +00:00
|
|
|
tr_wr(tr, TR_REG_SBBL, i | (i << 16), 4);
|
|
|
|
/* set sample format */
|
|
|
|
i = 0x18 | (bits << 4);
|
|
|
|
tr_wr(tr, TR_REG_SBCTRL, i, 1);
|
1999-09-01 04:08:39 +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-24 03:56:41 +00:00
|
|
|
trrchan_setspeed(kobj_t obj, void *data, u_int32_t speed)
|
1999-09-01 04:08:39 +00:00
|
|
|
{
|
2000-12-24 03:56:41 +00:00
|
|
|
struct tr_rchinfo *ch = data;
|
1999-09-01 04:08:39 +00:00
|
|
|
struct tr_info *tr = ch->parent;
|
|
|
|
|
2000-12-24 03:56:41 +00:00
|
|
|
/* setup speed */
|
|
|
|
ch->delta = (48000 << 12) / speed;
|
|
|
|
tr_wr(tr, TR_REG_SBDELTA, ch->delta, 2);
|
|
|
|
|
|
|
|
/* return closest possible speed */
|
|
|
|
return (48000 << 12) / ch->delta;
|
1999-09-01 04:08:39 +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
|
|
|
static u_int32_t
|
2000-12-24 03:56:41 +00:00
|
|
|
trrchan_setblocksize(kobj_t obj, void *data, u_int32_t blocksize)
|
1999-09-01 04:08:39 +00:00
|
|
|
{
|
2000-12-24 03:56:41 +00:00
|
|
|
struct tr_rchinfo *ch = data;
|
|
|
|
|
|
|
|
sndbuf_resize(ch->buffer, 2, blocksize);
|
|
|
|
|
|
|
|
return blocksize;
|
1999-09-01 04:08:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2000-12-24 03:56:41 +00:00
|
|
|
trrchan_trigger(kobj_t obj, void *data, int go)
|
1999-09-01 04:08:39 +00:00
|
|
|
{
|
2000-12-24 03:56:41 +00:00
|
|
|
struct tr_rchinfo *ch = data;
|
1999-09-01 04:08:39 +00:00
|
|
|
struct tr_info *tr = ch->parent;
|
2000-12-24 03:56:41 +00:00
|
|
|
u_int32_t i;
|
2000-04-17 16:57:12 +00:00
|
|
|
|
2007-06-11 00:49:46 +00:00
|
|
|
if (!PCMTRIG_COMMON(go))
|
2000-05-26 21:15:47 +00:00
|
|
|
return 0;
|
|
|
|
|
2000-12-24 03:56:41 +00:00
|
|
|
if (go == PCMTRIG_START) {
|
|
|
|
/* set up dma mode regs */
|
|
|
|
tr_wr(tr, TR_REG_DMAR15, 0, 1);
|
|
|
|
i = tr_rd(tr, TR_REG_DMAR11, 1) & 0x03;
|
|
|
|
tr_wr(tr, TR_REG_DMAR11, i | 0x54, 1);
|
|
|
|
/* set up base address */
|
2003-02-20 17:31:12 +00:00
|
|
|
tr_wr(tr, TR_REG_DMAR0, sndbuf_getbufaddr(ch->buffer), 4);
|
2000-12-24 03:56:41 +00:00
|
|
|
/* set up buffer size */
|
|
|
|
i = tr_rd(tr, TR_REG_DMAR4, 4) & ~0x00ffffff;
|
|
|
|
tr_wr(tr, TR_REG_DMAR4, i | (sndbuf_runsz(ch->buffer) - 1), 4);
|
|
|
|
/* start */
|
|
|
|
tr_wr(tr, TR_REG_SBCTRL, tr_rd(tr, TR_REG_SBCTRL, 1) | 1, 1);
|
2001-11-24 18:00:33 +00:00
|
|
|
ch->active = 1;
|
|
|
|
} else {
|
2000-12-24 03:56:41 +00:00
|
|
|
tr_wr(tr, TR_REG_SBCTRL, tr_rd(tr, TR_REG_SBCTRL, 1) & ~7, 1);
|
2001-11-24 18:00:33 +00:00
|
|
|
ch->active = 0;
|
|
|
|
}
|
2000-12-24 03:56:41 +00:00
|
|
|
|
|
|
|
/* return 0 if ok */
|
1999-09-01 04:08:39 +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-24 03:56:41 +00:00
|
|
|
trrchan_getptr(kobj_t obj, void *data)
|
1999-09-01 04:08:39 +00:00
|
|
|
{
|
2000-12-24 03:56:41 +00:00
|
|
|
struct tr_rchinfo *ch = data;
|
1999-09-01 04:08:39 +00:00
|
|
|
struct tr_info *tr = ch->parent;
|
2000-05-26 21:15:47 +00:00
|
|
|
|
2000-12-24 03:56:41 +00:00
|
|
|
/* return current byte offset of channel */
|
2003-02-20 17:31:12 +00:00
|
|
|
return tr_rd(tr, TR_REG_DMAR0, 4) - sndbuf_getbufaddr(ch->buffer);
|
1999-09-01 04:08:39 +00:00
|
|
|
}
|
|
|
|
|
2001-03-24 23:10:29 +00:00
|
|
|
static struct pcmchan_caps *
|
2000-12-24 03:56:41 +00:00
|
|
|
trrchan_getcaps(kobj_t obj, void *data)
|
1999-09-01 04:08:39 +00:00
|
|
|
{
|
2000-12-24 03:56:41 +00:00
|
|
|
return &tr_reccaps;
|
1999-09-01 04:08:39 +00:00
|
|
|
}
|
|
|
|
|
2000-12-24 03:56:41 +00:00
|
|
|
static kobj_method_t trrchan_methods[] = {
|
|
|
|
KOBJMETHOD(channel_init, trrchan_init),
|
|
|
|
KOBJMETHOD(channel_setformat, trrchan_setformat),
|
|
|
|
KOBJMETHOD(channel_setspeed, trrchan_setspeed),
|
|
|
|
KOBJMETHOD(channel_setblocksize, trrchan_setblocksize),
|
|
|
|
KOBJMETHOD(channel_trigger, trrchan_trigger),
|
|
|
|
KOBJMETHOD(channel_getptr, trrchan_getptr),
|
|
|
|
KOBJMETHOD(channel_getcaps, trrchan_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
|
|
|
};
|
2000-12-24 03:56:41 +00:00
|
|
|
CHANNEL_DECLARE(trrchan);
|
2000-12-18 01:36:41 +00:00
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
1999-09-01 04:08:39 +00:00
|
|
|
/* The interrupt handler */
|
|
|
|
|
|
|
|
static void
|
|
|
|
tr_intr(void *p)
|
|
|
|
{
|
|
|
|
struct tr_info *tr = (struct tr_info *)p;
|
2000-12-24 03:56:41 +00:00
|
|
|
struct tr_chinfo *ch;
|
2001-01-24 01:20:04 +00:00
|
|
|
u_int32_t active, mask, bufhalf, chnum, intsrc;
|
|
|
|
int tmp;
|
1999-09-01 04:08:39 +00:00
|
|
|
|
2000-12-24 03:56:41 +00:00
|
|
|
intsrc = tr_rd(tr, TR_REG_MISCINT, 4);
|
1999-09-01 04:08:39 +00:00
|
|
|
if (intsrc & TR_INT_ADDR) {
|
2001-01-24 01:20:04 +00:00
|
|
|
chnum = 0;
|
2009-09-22 11:38:45 +00:00
|
|
|
while (chnum < tr->hwchns) {
|
2001-01-24 01:20:04 +00:00
|
|
|
mask = 0x00000001;
|
|
|
|
active = tr_rd(tr, (chnum < 32)? TR_REG_ADDRINTA : TR_REG_ADDRINTB, 4);
|
|
|
|
bufhalf = tr_rd(tr, (chnum < 32)? TR_REG_CSPF_A : TR_REG_CSPF_B, 4);
|
|
|
|
if (active) {
|
|
|
|
do {
|
|
|
|
if (active & mask) {
|
|
|
|
tmp = (bufhalf & mask)? 1 : 0;
|
|
|
|
if (chnum < tr->playchns) {
|
|
|
|
ch = &tr->chinfo[chnum];
|
|
|
|
/* printf("%d @ %d, ", chnum, trpchan_getptr(NULL, ch)); */
|
|
|
|
if (ch->bufhalf != tmp) {
|
|
|
|
chn_intr(ch->channel);
|
|
|
|
ch->bufhalf = tmp;
|
2001-03-24 23:10:29 +00:00
|
|
|
}
|
2001-01-24 01:20:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
chnum++;
|
|
|
|
mask <<= 1;
|
|
|
|
} while (chnum & 31);
|
|
|
|
} else
|
|
|
|
chnum += 32;
|
|
|
|
|
|
|
|
tr_wr(tr, (chnum <= 32)? TR_REG_ADDRINTA : TR_REG_ADDRINTB, active, 4);
|
1999-09-01 04:08:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (intsrc & TR_INT_SB) {
|
|
|
|
chn_intr(tr->recchinfo.channel);
|
|
|
|
tr_rd(tr, TR_REG_SBR9, 1);
|
|
|
|
tr_rd(tr, TR_REG_SBR10, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Probe and attach the card
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int
|
|
|
|
tr_init(struct tr_info *tr)
|
|
|
|
{
|
2001-08-26 19:15:28 +00:00
|
|
|
switch (tr->type) {
|
|
|
|
case SPA_PCI_ID:
|
|
|
|
tr_wr(tr, SPA_REG_GPIO, 0, 4);
|
|
|
|
tr_wr(tr, SPA_REG_CODECST, SPA_RST_OFF, 4);
|
|
|
|
break;
|
|
|
|
case TDX_PCI_ID:
|
1999-09-01 04:08:39 +00:00
|
|
|
tr_wr(tr, TDX_REG_CODECST, TDX_CDC_ON, 4);
|
2001-08-26 19:15:28 +00:00
|
|
|
break;
|
|
|
|
case TNX_PCI_ID:
|
|
|
|
tr_wr(tr, TNX_REG_CODECST, TNX_CDC_ON, 4);
|
|
|
|
break;
|
|
|
|
}
|
1999-09-01 04:08:39 +00:00
|
|
|
|
|
|
|
tr_wr(tr, TR_REG_CIR, TR_CIR_MIDENA | TR_CIR_ADDRENA, 4);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tr_pci_probe(device_t dev)
|
|
|
|
{
|
2001-08-26 19:15:28 +00:00
|
|
|
switch (pci_get_devid(dev)) {
|
|
|
|
case SPA_PCI_ID:
|
|
|
|
device_set_desc(dev, "SiS 7018");
|
2005-03-01 08:58:06 +00:00
|
|
|
return BUS_PROBE_DEFAULT;
|
2001-08-29 09:04:22 +00:00
|
|
|
case ALI_PCI_ID:
|
|
|
|
device_set_desc(dev, "Acer Labs M5451");
|
2005-03-01 08:58:06 +00:00
|
|
|
return BUS_PROBE_DEFAULT;
|
2001-08-26 19:15:28 +00:00
|
|
|
case TDX_PCI_ID:
|
|
|
|
device_set_desc(dev, "Trident 4DWave DX");
|
2005-03-01 08:58:06 +00:00
|
|
|
return BUS_PROBE_DEFAULT;
|
2001-08-26 19:15:28 +00:00
|
|
|
case TNX_PCI_ID:
|
|
|
|
device_set_desc(dev, "Trident 4DWave NX");
|
2005-03-01 08:58:06 +00:00
|
|
|
return BUS_PROBE_DEFAULT;
|
1999-09-01 04:08:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ENXIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tr_pci_attach(device_t dev)
|
|
|
|
{
|
|
|
|
u_int32_t data;
|
|
|
|
struct tr_info *tr;
|
2000-09-17 23:46:32 +00:00
|
|
|
struct ac97_info *codec = 0;
|
2009-09-22 11:38:45 +00:00
|
|
|
bus_addr_t lowaddr;
|
2007-11-10 04:32:50 +00:00
|
|
|
int i, dacn;
|
1999-09-01 04:08:39 +00:00
|
|
|
char status[SND_STATUSLEN];
|
2009-09-22 11:38:45 +00:00
|
|
|
#ifdef __sparc64__
|
|
|
|
device_t *children;
|
|
|
|
int nchildren;
|
|
|
|
#endif
|
1999-09-01 04:08:39 +00:00
|
|
|
|
2007-06-17 06:10:43 +00:00
|
|
|
tr = malloc(sizeof(*tr), M_DEVBUF, M_WAITOK | M_ZERO);
|
1999-09-01 04:08:39 +00:00
|
|
|
tr->type = pci_get_devid(dev);
|
2002-10-14 11:47:37 +00:00
|
|
|
tr->rev = pci_get_revid(dev);
|
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
|
|
|
tr->lock = snd_mtxcreate(device_get_nameunit(dev), "snd_t4dwave softc");
|
1999-09-01 04:08:39 +00:00
|
|
|
|
2007-11-10 04:32:50 +00:00
|
|
|
if (resource_int_value(device_get_name(dev), device_get_unit(dev),
|
|
|
|
"dac", &i) == 0) {
|
|
|
|
if (i < 1)
|
|
|
|
dacn = 1;
|
|
|
|
else if (i > TR_MAXPLAYCH)
|
|
|
|
dacn = TR_MAXPLAYCH;
|
|
|
|
else
|
|
|
|
dacn = i;
|
|
|
|
} else {
|
|
|
|
switch (tr->type) {
|
|
|
|
case ALI_PCI_ID:
|
2009-09-22 11:38:45 +00:00
|
|
|
dacn = ALI_MAXPLAYCH;
|
2007-11-10 04:32:50 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
dacn = TR_MAXPLAYCH;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-09-01 04:08:39 +00:00
|
|
|
data = pci_read_config(dev, PCIR_COMMAND, 2);
|
|
|
|
data |= (PCIM_CMD_PORTEN|PCIM_CMD_MEMEN|PCIM_CMD_BUSMASTEREN);
|
|
|
|
pci_write_config(dev, PCIR_COMMAND, data, 2);
|
|
|
|
data = pci_read_config(dev, PCIR_COMMAND, 2);
|
|
|
|
|
2003-09-02 17:30:40 +00:00
|
|
|
tr->regid = PCIR_BAR(0);
|
2000-12-24 03:56:41 +00:00
|
|
|
tr->regtype = SYS_RES_IOPORT;
|
2004-03-17 17:50:55 +00:00
|
|
|
tr->reg = bus_alloc_resource_any(dev, tr->regtype, &tr->regid,
|
|
|
|
RF_ACTIVE);
|
2000-12-24 03:56:41 +00:00
|
|
|
if (tr->reg) {
|
|
|
|
tr->st = rman_get_bustag(tr->reg);
|
|
|
|
tr->sh = rman_get_bushandle(tr->reg);
|
|
|
|
} else {
|
1999-09-01 04:08:39 +00:00
|
|
|
device_printf(dev, "unable to map register space\n");
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tr_init(tr) == -1) {
|
|
|
|
device_printf(dev, "unable to initialize the card\n");
|
|
|
|
goto bad;
|
|
|
|
}
|
2001-11-24 18:00:33 +00:00
|
|
|
tr->playchns = 0;
|
1999-09-01 04:08:39 +00:00
|
|
|
|
2000-12-18 01:36:41 +00:00
|
|
|
codec = AC97_CREATE(dev, tr, tr_ac97);
|
1999-09-01 04:08:39 +00:00
|
|
|
if (codec == NULL) goto bad;
|
2000-12-18 01:36:41 +00:00
|
|
|
if (mixer_init(dev, ac97_getmixerclass(), codec) == -1) goto bad;
|
1999-09-01 04:08:39 +00:00
|
|
|
|
|
|
|
tr->irqid = 0;
|
2004-03-17 17:50:55 +00:00
|
|
|
tr->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &tr->irqid,
|
|
|
|
RF_ACTIVE | RF_SHAREABLE);
|
2004-04-14 14:57:49 +00:00
|
|
|
if (!tr->irq || snd_setup_intr(dev, tr->irq, 0, tr_intr, tr, &tr->ih)) {
|
1999-09-01 04:08:39 +00:00
|
|
|
device_printf(dev, "unable to map interrupt\n");
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
2009-09-22 11:38:45 +00:00
|
|
|
if (tr->type == ALI_PCI_ID) {
|
|
|
|
/*
|
|
|
|
* The M5451 generates 31 bit of DMA and in order to do
|
|
|
|
* 32-bit DMA, the 31st bit can be set via its accompanying
|
|
|
|
* ISA bridge. Note that we can't predict whether bus_dma(9)
|
|
|
|
* will actually supply us with a 32-bit buffer and even when
|
|
|
|
* using a low address of BUS_SPACE_MAXADDR_32BIT for both
|
|
|
|
* we might end up with the play buffer being in the 32-bit
|
|
|
|
* range while the record buffer isn't or vice versa. So we
|
|
|
|
* limit enabling the 31st bit to sparc64, where the IOMMU
|
|
|
|
* guarantees that we're using a 32-bit address (and in turn
|
|
|
|
* requires it).
|
|
|
|
*/
|
|
|
|
lowaddr = ALI_MAXADDR;
|
|
|
|
#ifdef __sparc64__
|
|
|
|
if (device_get_children(device_get_parent(dev), &children,
|
|
|
|
&nchildren) == 0) {
|
|
|
|
for (i = 0; i < nchildren; i++) {
|
|
|
|
if (pci_get_devid(children[i]) == 0x153310b9) {
|
|
|
|
lowaddr = BUS_SPACE_MAXADDR_32BIT;
|
|
|
|
data = pci_read_config(children[i],
|
|
|
|
0x7e, 1);
|
|
|
|
if (bootverbose)
|
|
|
|
device_printf(dev,
|
|
|
|
"M1533 0x7e: 0x%x -> ",
|
|
|
|
data);
|
|
|
|
data |= 0x1;
|
|
|
|
if (bootverbose)
|
|
|
|
printf("0x%x\n", data);
|
|
|
|
pci_write_config(children[i], 0x7e,
|
|
|
|
data, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free(children, M_TEMP);
|
|
|
|
#endif
|
|
|
|
tr->hwchns = ALI_MAXHWCH;
|
|
|
|
tr->bufsz = ALI_BUFSZ;
|
|
|
|
} else {
|
|
|
|
lowaddr = TR_MAXADDR;
|
|
|
|
tr->hwchns = TR_MAXHWCH;
|
|
|
|
tr->bufsz = pcm_getbuffersize(dev, 4096, TR_DEFAULT_BUFSZ,
|
|
|
|
65536);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(dev),
|
|
|
|
/*alignment*/TR_BUFALGN,
|
2007-02-23 13:47:34 +00:00
|
|
|
/*boundary*/0,
|
2009-09-22 11:38:45 +00:00
|
|
|
/*lowaddr*/lowaddr,
|
1999-09-01 04:08:39 +00:00
|
|
|
/*highaddr*/BUS_SPACE_MAXADDR,
|
|
|
|
/*filter*/NULL, /*filterarg*/NULL,
|
2009-09-22 11:38:45 +00:00
|
|
|
/*maxsize*/tr->bufsz, /*nsegments*/1, /*maxsegz*/tr->bufsz,
|
2003-07-01 15:52:06 +00:00
|
|
|
/*flags*/0, /*lockfunc*/busdma_lock_mutex,
|
|
|
|
/*lockarg*/&Giant, &tr->parent_dmat) != 0) {
|
1999-09-01 04:08:39 +00:00
|
|
|
device_printf(dev, "unable to create dma tag\n");
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
2004-03-06 15:52:42 +00:00
|
|
|
snprintf(status, 64, "at io 0x%lx irq %ld %s",
|
|
|
|
rman_get_start(tr->reg), rman_get_start(tr->irq),PCM_KLDSTRING(snd_t4dwave));
|
1999-09-01 04:08:39 +00:00
|
|
|
|
2007-11-10 04:32:50 +00:00
|
|
|
if (pcm_register(dev, tr, dacn, 1))
|
|
|
|
goto bad;
|
2000-12-24 03:56:41 +00:00
|
|
|
pcm_addchan(dev, PCMDIR_REC, &trrchan_class, tr);
|
2007-11-10 04:32:50 +00:00
|
|
|
for (i = 0; i < dacn; i++)
|
2000-12-24 03:56:41 +00:00
|
|
|
pcm_addchan(dev, PCMDIR_PLAY, &trpchan_class, tr);
|
1999-09-01 04:08:39 +00:00
|
|
|
pcm_setstatus(dev, status);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
bad:
|
2000-09-09 19:21:04 +00:00
|
|
|
if (codec) ac97_destroy(codec);
|
1999-09-01 04:08:39 +00:00
|
|
|
if (tr->reg) bus_release_resource(dev, tr->regtype, tr->regid, tr->reg);
|
|
|
|
if (tr->ih) bus_teardown_intr(dev, tr->irq, tr->ih);
|
|
|
|
if (tr->irq) bus_release_resource(dev, SYS_RES_IRQ, tr->irqid, tr->irq);
|
2000-09-09 19:21:04 +00:00
|
|
|
if (tr->parent_dmat) bus_dma_tag_destroy(tr->parent_dmat);
|
2001-03-24 23:10:29 +00:00
|
|
|
if (tr->lock) snd_mtxfree(tr->lock);
|
1999-09-01 04:08:39 +00:00
|
|
|
free(tr, M_DEVBUF);
|
|
|
|
return ENXIO;
|
|
|
|
}
|
|
|
|
|
2000-09-09 19:21:04 +00:00
|
|
|
static int
|
|
|
|
tr_pci_detach(device_t dev)
|
|
|
|
{
|
|
|
|
int r;
|
|
|
|
struct tr_info *tr;
|
|
|
|
|
|
|
|
r = pcm_unregister(dev);
|
|
|
|
if (r)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
tr = pcm_getdevinfo(dev);
|
|
|
|
bus_release_resource(dev, tr->regtype, tr->regid, tr->reg);
|
|
|
|
bus_teardown_intr(dev, tr->irq, tr->ih);
|
|
|
|
bus_release_resource(dev, SYS_RES_IRQ, tr->irqid, tr->irq);
|
|
|
|
bus_dma_tag_destroy(tr->parent_dmat);
|
2001-03-24 23:10:29 +00:00
|
|
|
snd_mtxfree(tr->lock);
|
2000-09-09 19:21:04 +00:00
|
|
|
free(tr, M_DEVBUF);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-11-24 18:00:33 +00:00
|
|
|
static int
|
|
|
|
tr_pci_suspend(device_t dev)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct tr_info *tr;
|
|
|
|
|
|
|
|
tr = pcm_getdevinfo(dev);
|
|
|
|
|
|
|
|
for (i = 0; i < tr->playchns; i++) {
|
|
|
|
tr->chinfo[i].was_active = tr->chinfo[i].active;
|
|
|
|
if (tr->chinfo[i].active) {
|
|
|
|
trpchan_trigger(NULL, &tr->chinfo[i], PCMTRIG_STOP);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tr->recchinfo.was_active = tr->recchinfo.active;
|
|
|
|
if (tr->recchinfo.active) {
|
|
|
|
trrchan_trigger(NULL, &tr->recchinfo, PCMTRIG_STOP);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tr_pci_resume(device_t dev)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct tr_info *tr;
|
|
|
|
|
|
|
|
tr = pcm_getdevinfo(dev);
|
|
|
|
|
|
|
|
if (tr_init(tr) == -1) {
|
|
|
|
device_printf(dev, "unable to initialize the card\n");
|
|
|
|
return ENXIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mixer_reinit(dev) == -1) {
|
|
|
|
device_printf(dev, "unable to initialize the mixer\n");
|
|
|
|
return ENXIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < tr->playchns; i++) {
|
|
|
|
if (tr->chinfo[i].was_active) {
|
|
|
|
trpchan_trigger(NULL, &tr->chinfo[i], PCMTRIG_START);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tr->recchinfo.was_active) {
|
|
|
|
trrchan_trigger(NULL, &tr->recchinfo, PCMTRIG_START);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-09-01 04:08:39 +00:00
|
|
|
static device_method_t tr_methods[] = {
|
|
|
|
/* Device interface */
|
|
|
|
DEVMETHOD(device_probe, tr_pci_probe),
|
|
|
|
DEVMETHOD(device_attach, tr_pci_attach),
|
2000-09-09 19:21:04 +00:00
|
|
|
DEVMETHOD(device_detach, tr_pci_detach),
|
2001-11-24 18:00:33 +00:00
|
|
|
DEVMETHOD(device_suspend, tr_pci_suspend),
|
|
|
|
DEVMETHOD(device_resume, tr_pci_resume),
|
1999-09-01 04:08:39 +00:00
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static driver_t tr_driver = {
|
|
|
|
"pcm",
|
|
|
|
tr_methods,
|
2001-08-23 11:30:52 +00:00
|
|
|
PCM_SOFTC_SIZE,
|
1999-09-01 04:08:39 +00:00
|
|
|
};
|
|
|
|
|
2000-07-03 20:52:27 +00:00
|
|
|
DRIVER_MODULE(snd_t4dwave, pci, tr_driver, pcm_devclass, 0, 0);
|
2004-07-16 04:00:08 +00:00
|
|
|
MODULE_DEPEND(snd_t4dwave, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER);
|
2000-07-03 20:52:27 +00:00
|
|
|
MODULE_VERSION(snd_t4dwave, 1);
|