History log of /freebsd-10-stable/sys/dev/sound/pcm/ac97.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

# 227293 07-Nov-2011 ed

Mark MALLOC_DEFINEs static that have no corresponding MALLOC_DECLAREs.

This means that their use is restricted to a single C file.


# 193640 07-Jun-2009 ariff

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.


# 173039 26-Oct-2007 ariff

Remap and virtualize mixer controls for HP nx6110 with
AD1981B AC97 codec, unifying master volume control.

* Remap "phout" --> SOUND_MIXER_VOLUME (internal speakers)
* Virtual "vol" --> { "phout", "ogain" (headphone) }

Tested by: Frederic Chardon
MFC after: 3 days


# 170873 17-Jun-2007 ariff

Flush remaining malloc() cleanups (M_NOWAIT -> M_WAITOK).


# 170342 05-Jun-2007 ariff

- Do triple reads on reset register to detect read register bug. 2 reads
seems not enough to verify its consistencies.
- Define AC97_MIXER_SIZE as SOUND_MIXER_NRDEVICES (25), since we
don't need more than that. Stop doing wild and random guess about
its size since we're stricly bound to it.


# 170289 04-Jun-2007 dwmalone

Despite several examples in the kernel, the third argument of
sysctl_handle_int is not sizeof the int type you want to export.
The type must always be an int or an unsigned int.

Remove the instances where a sizeof(variable) is passed to stop
people accidently cut and pasting these examples.

In a few places this was sysctl_handle_int was being used on 64 bit
types, which would truncate the value to be exported. In these
cases use sysctl_handle_quad to export them and change the format
to Q so that sysctl(1) can still print them.


# 170207 02-Jun-2007 ariff

Use standard pcm_get/setflags() rather than dereferencing softc while
enabling SD_F_SOFTPCMVOL or any flags.


# 170060 28-May-2007 ariff

Fix broken "rec" and "igain" introduced by previous commit. Convert
reg to a full blown int since there's not much gain compacting it,
and we do need its signess.


# 170032 27-May-2007 ariff

Fix broken binary issues with latest gcc 4.x due to bitfield signess
mishaps for emu10k1 [1] and few other places.

Reported/Submitted/Tested by: Ed Schouten <ed@fxq.nl> [1]


# 168861 19-Apr-2007 ariff

- AC97 quirk / patch cleanups. Most quirks doesn't work in general sense
and should only be applied on certain specific card / vendor, hence the
addition of ac97_getsubvendor().
- Fix low volume issue on several MSI laptops through ALC655 quirk.

Reported/Tested by: Christian Mueller
<raptor-freebsd-multimedia@xpls.de>
MFC after: 1 week


# 167611 15-Mar-2007 ariff

Spring cleanup on irrelevant NULL checking over M_WAITOK allocations.


# 167256 06-Mar-2007 ariff

Enable tone / 3D controls for YAMAHA YMF743, 753 and 752 (partially).

PR: kern/109599
Submitted by: Watanabe Kazuhiro <CQG00620@nifty.ne.jp>


# 164614 26-Nov-2006 ariff

Welcome to Once-a-year Sound Mega-Commit. Enjoy numerous updates and fixes
in every sense.

General
-------

- Multichannel safe, endian safe, format safe
* Large part of critical pcm filters such as vchan.c, feeder_rate.c,
feeder_volume.c, feeder_fmt.c and feeder.c has been rewritten so that
using them does not cause the pcm data to be converted to 16bit little
endian.
* Macrosses for accessing pcm data safely are defined within sound.h in
the form of PCM_READ_* / PCM_WRITE_*
* Currently, most of them are probably limited for mono/stereo handling,
but the future addition of true multichannel will be much easier.

- Low latency operation
* Well, this require lot more works to do not just within sound driver,
but we're heading towards right direction. Buffer/block sizing within
channel.c is rewritten to calculate precise allocation for various
combination of sample/data/rate size. As a result, applying correct
SNDCTL_DSP_POLICY value will achive expected latency behaviour simmilar
to what commercial 4front driver do.
* Signal handling fix. ctrl+c of "cat /dev/zero > /dev/dsp" does not
result long delay.
* Eliminate sound truncation if the sound data is too small.
DIY:
1) Download / extract
http://people.freebsd.org/~ariff/lowlatency/shortfiles.tar.gz
2) Do a comparison between "cat state*.au > /dev/dsp" and
"for x in state*.au ; do cat $x > /dev/dsp ; done"
- there should be no "perceivable" differences.
Double close for PR kern/31445.

CAVEAT: Low latency come with (unbearable) price especially for poorly
written applications. Applications that trying to act smarter
by requesting (wrong) blocksize/blockcount will suffer the most.
Fixup samples/patches can be found at:
http://people.freebsd.org/~ariff/ports/

- Switch minimum/maximum sampling rate limit to "1" and "2016000" (48k * 42)
due to closer compatibility with 4front driver.
Discussed with: marcus@ (long time ago?)

- All driver specific sysctls in the form of "hw.snd.pcm%d.*" have been
moved to their own dev sysctl nodes, notably:
hw.snd.pcm%d.vchans -> dev.pcm.%d.vchans
Bump __FreeBSD_version.

Driver specific
---------------

- Ditto for sysctls.

- snd_atiixp, snd_es137x, snd_via8233, snd_hda
* Numerous cleanups and fixes.
* _EXPERIMENTAL_ polling mode support using simple callout_* mechanisme.
This was intended for pure debugging and latency measurement, but proven
good enough in few unexpected and rare cases (such as problematic shared
IRQ with GIANT devices - USB). Polling can be enabled/disabled through
dev.pcm.0.polling. Disabled by default.

- snd_ich
* Fix possible overflow during speed calibration. Delay final
initialization (pcm_setstatus) after calibration finished.
PR: kern/100169
Tested by: Kevin Overman <oberman@es.net>
* Inverted EAPD for few Nec VersaPro.
PR: kern/104715
Submitted by: KAWATA Masahiko <kawata@mta.biglobe.ne.jp>

Thanks to various people, notably Joel Dahl, Yuriy Tsibizov, Kevin Oberman,
those at #freebsd-azalia @ freenode and others for testing.

Joel Dahl will do the manpage update.


# 162974 02-Oct-2006 ariff

Backout remaining changes that make most AD1981B users unhappy.
The exact situation is understood, and proper solution will follow
sooner.


# 162738 28-Sep-2006 ariff

Various fixups, especially for the upcomming High Definition Audio
commit.

1) sys/dev/sound/pcm/sound.h
sys/dev/sound/pcm/channel.c
* Be more specific: SD_F_SOFTVOL -> SD_F_SOFTPCMVOL
2) sys/dev/sound/pcm/mixer.[ch]
* Implement
mix_setparentchild()
mix_setrealdev()
mix_getparent()
mix_getchild()
The purpose of these functions is implement relative volume
adjustment, such as to tie two or more mixer device into a
single logical device. Usefull for the upcoming HDA driver
and few AC97 codec (such as AD1981B) where the master volume
"vol" need to be implemented using this logical manner.
3) sys/dev/sound/pcm/ac97_patch.[ch]
* Patch for AD1981B codec to enable (automuting) headphone jack sense.
4) sys/dev/sound/pcm/ac97.c
* Implement proper logical master volume for AD9181B codec
through various mix_set{parentchild,realdev}(). Tie both
"ogain" (headphone volume) and "phone" (speaker/lineout) to
a logical "vol".
5) sys/dev/sound/pcm/usb/uaudio_pcm.c
* ditto, for "vol" -> { "pcm" }.

MFC after: 1 month


# 154094 07-Jan-2006 ariff

Add codec id support for Analog Device AD1986 AC'97 codec.

Submitted by: UMENO Takashi <umeno at rr.iij4u.or.jp>
PR: kern/80234
MFC after: 2 days


# 153865 29-Dec-2005 ariff

Few codec such as Conexant CX20468-21 does have this control
register, although the only usable part is the mute bit.

Noticed by: Hans Petter Selasky <hselasky@c2i.net>


# 152939 29-Nov-2005 yongari

Add codec ID for Avance Logic ALC203


# 152815 26-Nov-2005 ariff

Added codec id for Avance Logic (ALC250)


# 152422 14-Nov-2005 ariff

ac97.c:
- Added new codec id for CX20468-21 and VIA1617A.
Submitted by: Chen Lihong <lihong.chen@gmail.com>
- Re-enable SOUND_MIXER_IGAIN, but set the default level as 0 (mute)
Suggested by: luigi

mixer.c:
- Set default value for SOUND_MIXER_IGAIN as 0 (mute) to avoid
feedback problems on some laptops (was disabled by jhb during
ac97.c revision 1.42).

Approved by: netchild (mentor)


# 150825 02-Oct-2005 netchild

sys/dev/sound/pcm/ac97.c:
* Added codec id for CMI9761.
* feeder_volume *whitelist* through ac97_fix_volume()

sys/dev/sound/pcm/ac97.h:
* Added AC97_F_SOFTVOL definition.

sys/dev/sound/pcm/channel.c:
* Slight changes for chn_setvolume() to conform with OSS.
* FEEDER_VOLUME is now part of feeder building process.

sys/dev/sound/pcm/mixer.c:
* General spl* cleanup. It doesn't serve any purpose anymore.
* Main hook for feeder_volume.

Submitted by: Ariff Abdullah <skywizard@MyBSD.org.my>
Tested by: multimedia@


# 149949 10-Sep-2005 netchild

- Few buggy codecs (STAC9704, probably others) return inconsistent
ac97_rdcd() value. Enable aggresive workaround.
- Fix mixer resolution detection for 5/6 bit register, carefully not to
overflow others.

PR: 84728
Submitted by: Ariff Abdullah <skywizard@MyBSD.org.my>


# 148602 31-Jul-2005 netchild

* Slightly new method to detect mixer capabilities and resolution.
This mostly to help CT4730, but apparently it does help other
cards too (especially via8233x). This probably need further test
and confirmation from other people with ac97 cards other than via
/ es137x.
* Aggresive dac power wake up call, again, to help CT4730 (and
probably others).

Submitted by: Ariff Abdullah <skywizard@MyBSD.org.my>
Tested by: multimedia@


# 144865 10-Apr-2005 scottl

Fix the output ports on the AD1988 codec. From the submitter:

Affects to people WITH an AD1888 codec, the system will output to the port
labeled "speaker" instead of microphone. System will work the same in
multiple operating systems.

If people are currently using their systems with this codec they will need
to swap their output ports.

I have _not_ checked audio input or line input (basically, I have checked
nothing other than line-out).

I believe this is an appropriate change, it makes us consistent with
documentation, and other operating systems. Furthermore, this feature
(playing) is the vast majority of sound activities, so if this makes is
right for playback and wrong for recording... playback is more important,
and we can fix recoding in the future without worries of screwing people
again in the future (since we'll be "right" on the playback).

Submitted by: David Cross


# 139749 05-Jan-2005 imp

Start each of the license/copyright comments with /*-, minor shuffle of lines


# 129044 08-May-2004 sanpei

Add support CS4294

PR: kern/66280
Submitted by: Christian Brueffer <chris@unixpages.org>


# 124875 23-Jan-2004 matk

Sync with DFBSD v.1.16. Add new codecs IDs, fix some spelling.

Approved by: des (interim mentor)


# 122515 11-Nov-2003 kuriyama

Add ID for ALC658 CODEC.

Tested on: GIGABYTE GA-8S655FX-L
Reviewed by: orion


# 121032 12-Oct-2003 des

Recognize the Avance Logic ALC655 codec found on some ICH4/5-based
motherboards, such as the Gigabyte I848P.

PR: kern/54176
Submitted by: Chris Keladis <chris@cmc.optus.net.au>
Forgotten by: orion


# 119853 07-Sep-2003 cg

update my email address.


# 119547 29-Aug-2003 orion

Add Creative EV1938.

Submitted by: David Xu <davidxu@FreeBSD.org>
PR: kern/54810


# 119375 23-Aug-2003 orion

When present use ogain instead of master for surround sound channels.
The latter has lead to reports of broken audio.

Do not swap ogain and master when headphones detected.


# 119250 21-Aug-2003 orion

Additional VT1616 id.

Submitted by: Greg Lewis


# 119209 21-Aug-2003 orion

Apply Rudolf Cejka's patch for:

o AD1980 hook.
o ac97_fix_auxout.

and:

o Associate AC97_MIX_AUXOUT with SOUND_MIXER_OGAIN rather than
SOUND_MIXER_MONITOR.

o Add ac97_fix_tone to remove tone controls from mixer if invalid.


# 113907 23-Apr-2003 jhb

Comment out the mixer entry for igain for the mic 20dB boost for now since
it can cause feedback problems on some laptops.

Reviewed by: orion


# 113788 21-Apr-2003 orion

Add eMicro codec ids.


# 113783 21-Apr-2003 orion

Use SOUND_MIXER_IGAIN to toggle 20dB mic boost for want of a better
place for it.

Assorted comments.

Submitted by: luigi


# 113057 04-Apr-2003 orion

Additional codec ids.


# 112434 20-Mar-2003 orion

Correct vendor id for ALC101.


# 112150 12-Mar-2003 orion

Correct CS4205 base vendor id.

Reported by: Christophe Juniet and Mark Santcroos.


# 111679 28-Feb-2003 orion

o Move vendor ids into separate table.
o Add assorted vendor and codec ids.


# 111590 27-Feb-2003 scottl

Add the ID for the CS4205 codec found in Dell laptops. Obtained from
the CS4205 spec.


# 111561 26-Feb-2003 cognet

Add SigmaTel STAC9750 entry.

Submitted by: Paulius Bulotas <paulius.bulotas@microlink.lt>


# 111119 19-Feb-2003 imp

Back out M_* changes, per decision of the TRB.

Approved by: trb


# 110258 02-Feb-2003 orion

Print ac97 name/id on normal boot.

Fix typo reported in pr misc/47794.


# 109818 25-Jan-2003 orion

Add ac97_patch.[ch] that provide space for ac97 codec specific patches.


# 109623 21-Jan-2003 alfred

Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.
Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.


# 109183 13-Jan-2003 orion

Add Realtek ALC650 id.

Submitted by: "Mikko S. Hyvarinen" <morphy@morphy.iki.fi>
MFC after: 5 days


# 107285 26-Nov-2002 cg

(hopefully) fix build breakage some people are seeing

Approved by: re


# 102302 23-Aug-2002 orion

s/AC97_MIX_PHONES/AC97_MIX_AUXOUT/ to match ac97r2.{2,3}.

Attempt to determine what function of AUX_OUT is: "True line level
out", "Headphone out", or "4-Channel out" and frig OSS mixer label
accordingly.

Addresses problem raised by Randy Bush on -multimedia of not being
able to hear audio on ich2 m/b which was eventually found to be
because the mixer monitor value was 0. On this h/w the label
"monitor" should now be presented as the marginally more intuitive
"ogain".


# 95499 26-Apr-2002 orion

Add ac97_reset function that polls ready bits in power register. One
component in tweaks required for the ICH3 controller in the thinkpad
x22 reported by Colin Perkins on -multimedia.


# 93816 04-Apr-2002 jhb

Add lock type arguments to callers of snd_mtxcreate().


# 87623 10-Dec-2001 guido

Get rid of irritating (bogus) message:
pcm0: ac97 codec failed to reset extended mode (0, got 80)
This was due to not masking off the correct extended function bits
in the read value from the extended status reg.

MFC after: 2 days


# 86707 21-Nov-2001 orion

Emit a warning if invalid mode passed to ac97_setextmode.

MFC after: 3 days


# 83612 18-Sep-2001 cg

add a method for retrieving codec capabilities


# 82180 23-Aug-2001 cg

many changes:

* add new channels to the end of the list so channels used in order of
addition

* de-globalise definition of struct snddev_info and provide accessor
functions where necessary.

* move the $FreeBSD$ tag in each .c file into a macro and allow the
/dev/sndstat handler to display these when set to maximum verbosity to aid
debugging.

* allow each device to register its own sndstat handler to reduce the amount
of groping sndstat must do in foreign structs.


# 78668 23-Jun-2001 cg

move a private struct definition from ac97.h to ac97.c

add proper handling of cards which take eapd=1 to mean 'produce sound'
instead of 'external amplifier power down'


# 74763 24-Mar-2001 cg

mega-commit.

this introduces a new buffering mechanism which results in dramatic
simplification of the channel manager.

as several structures have changed, we take the opportunity to move their
definitions into the source files where they are used, make them private and
de-typedef them.

the sound drivers are updated to use snd_setup_intr instead of
bus_setup_intr, and to comply with the de-typedefed structures.

the ac97, mixer and channel layers have been updated with finegrained
locking, as have some drivers- not all though. the rest will follow soon.


# 74696 23-Mar-2001 cg

* power up the external amplifier

* after chip reset, reapply power settings


# 74622 22-Mar-2001 cg

add/correct a bunch of codec ids

Obtained from: linux, alsa, various datasheets


# 70324 24-Dec-2000 cg

compensate for broken codecs that return 0xffff on unimplemented registers
instead of 0.


# 70134 17-Dec-2000 cg

kobjify.

this gives us several benefits, including:

* easier extensibility- new optional methods can be added to
ac97/mixer/channel classes without having to fixup every driver.

* forward compatibility for drivers, provided no new mandatory methods are
added.


# 67652 26-Oct-2000 cg

add reinit functions to mixers
unstaticize chn_start()
add reset/resetdone functions to channels


# 66307 23-Sep-2000 cg

only probe mandatory channels on known bad codecs


# 66013 17-Sep-2000 cg

dynamify- probe codec for supported channels
add channel mappings for mixer


# 65490 05-Sep-2000 cg

initial support for multiple ac97 codecs


# 65340 01-Sep-2000 cg

change mixer api slightly
change channel interface - kobj implementation coming soonish
make pcm_makelinks not panic if modular
add pcm_unregister()

these changes support newpcm kld unloading, but this is only implemented
by ds1.c


# 60960 26-May-2000 cg

if we have a codec init routine, fail the attach if init fails


# 58905 01-Apr-2000 cg

fail in attach if we seem to have no ac97 codec


# 58521 24-Mar-2000 cg

don't check extended features on codecs known to hang. should fix neomagic
problems.


# 58384 20-Mar-2000 cg

update the ac97 layer:
* add a callback for initialising the mixer interface
* support ac97 2.1 variable rate audio feature

fix ac97-using drivers for the above

add suspend/resume support for neomagic


# 56249 18-Jan-2000 cg

update ac97 layer to use device_printf when printing messages


# 53512 21-Nov-1999 cg

fix for -fno-builtin

PR: kern/14278


# 53465 20-Nov-1999 cg

repo-copied to make way for newmidi, this commit updates include paths


# 50733 01-Sep-1999 peter

$Id$ -> $FreeBSD$


# 50724 01-Sep-1999 cg

say hello to newpcm. it is not yet enabled, requiring new pnp code from dfr
to compile successfully. further details will be provided in the commit
enabling newpcm.