History log of /freebsd-current/sys/dev/sound/pci/maestro3.c
Revision Date Author Comments
# c597c557 06-May-2024 Christos Margiolis <christos@FreeBSD.org>

sound: Use nitems() where possible

No functional change intended.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Reviewed by: markj, emaste
Differential Revision: https://reviews.freebsd.org/D45014


# 837cd192 16-Jan-2024 Christos Margiolis <christos@FreeBSD.org>

sound: remove PCM_KLDSTRING() and fix status strings

PCM_KLDSTRING() prints the kernel module associated with a given audio
device only when that module is not compiled in. Get rid of
PCM_KLDSTRING() altogether and print the driver name (even for modules
that are compiled in) instead, as it implies the module as well.

While here, convert all status strings to the following dmesg-like
format:

[<port|mem> <irq>] on <driver>

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: markj, imp
Differential Revision: https://reviews.freebsd.org/D43349


# 5aacf339 18-Aug-2023 John Baldwin <jhb@FreeBSD.org>

sys: Remove SND_DECLARE_FILE

Reviewed by: kbowling, imp, emaste
Differential Revision: https://reviews.freebsd.org/D41499


# 82a265ad 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: sound driver version

Remove /SND_DECLARE_FILE\("\$FreeBSD\$"\);/


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# 2287364e 06-May-2022 John Baldwin <jhb@FreeBSD.org>

Remove pcm_devclass from DRIVER_MODULE invocations.


# 378503af 01-Sep-2020 Mateusz Guzik <mjg@FreeBSD.org>

sound: clean up empty lines in .c and .h files


# 33f4bcca 27-Jul-2018 Eitan Adler <eadler@FreeBSD.org>

Use https over http for FreeBSD pages


# 718cf2cc 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

sys/dev: further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.


# da1b038a 17-Mar-2016 Justin Hibbits <jhibbits@FreeBSD.org>

Use uintmax_t (typedef'd to rman_res_t type) for rman ranges.

On some architectures, u_long isn't large enough for resource definitions.
Particularly, powerpc and arm allow 36-bit (or larger) physical addresses, but
type `long' is only 32-bit. This extends rman's resources to uintmax_t. With
this change, any resource can feasibly be placed anywhere in physical memory
(within the constraints of the driver).

Why uintmax_t and not something machine dependent, or uint64_t? Though it's
possible for uintmax_t to grow, it's highly unlikely it will become 128-bit on
32-bit architectures. 64-bit architectures should have plenty of RAM to absorb
the increase on resource sizes if and when this occurs, and the number of
resources on memory-constrained systems should be sufficiently small as to not
pose a drastic overhead. That being said, uintmax_t was chosen for source
clarity. If it's specified as uint64_t, all printf()-like calls would either
need casts to uintmax_t, or be littered with PRI*64 macros. Casts to uintmax_t
aren't horrible, but it would also bake into the API for
resource_list_print_type() either a hidden assumption that entries get cast to
uintmax_t for printing, or these calls would need the PRI*64 macros. Since
source code is meant to be read more often than written, I chose the clearest
path of simply using uintmax_t.

Tested on a PowerPC p5020-based board, which places all device resources in
0xfxxxxxxxx, and has 8GB RAM.
Regression tested on qemu-system-i386
Regression tested on qemu-system-mips (malta profile)

Tested PAE and devinfo on virtualbox (live CD)

Special thanks to bz for his testing on ARM.

Reviewed By: bz, jhb (previous)
Relnotes: Yes
Sponsored by: Alex Perez/Inertial Computing
Differential Revision: https://reviews.freebsd.org/D4544


# c68534f1 12-Aug-2013 Scott Long <scottl@FreeBSD.org>

Update PCI drivers to no longer look at the MEMIO-enabled bit in the PCI
command register. The lazy BAR allocation code in FreeBSD sometimes
disables this bit when it detects a range conflict, and will re-enable
it on demand when a driver allocates the BAR. Thus, the bit is no longer
a reliable indication of capability, and should not be checked. This
results in the elimination of a lot of code from drivers, and also gives
the opportunity to simplify a lot of drivers to use a helper API to set
the busmaster enable bit.

This changes fixes some recent reports of disk controllers and their
associated drives/enclosures disappearing during boot.

Submitted by: jhb
Reviewed by: jfv, marius, achadd, achim
MFC after: 1 day


# 5dcd37b1 20-Jan-2012 Pedro F. Giffuni <pfg@FreeBSD.org>

Replace GPLd headers from the Maestro3 driver with BSD licensed
versions derived from /usr/ports/audio/oss.

The particular headers used were taken from the
attic/drv/oss_allegro directory and are mostly identical
to the previous files.

The Maestro3 driver is now free from the GPL.

NOTE: due to lack of testers this driver is being
considered for deprecation and removal.

PR: kern/153920
Approved by: jhb (mentor)
MFC after: 2 weeks


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# 7733cf8f 11-Feb-2010 Matt Jacob <mjacob@FreeBSD.org>

MFC a number of changes from head for ISP (203478,203463,203444,202418,201758,
201408,201325,200089,198822,197373,197372,197214,196162). Since one of those
changes was a semicolon cleanup from somebody else, this touches a lot more.


# c2ede4b3 07-Jan-2010 Martin Blapp <mbr@FreeBSD.org>

Remove extraneous semicolons, no functional changes.

Submitted by: Marc Balmer <marc@msys.ch>
MFC after: 1 week


# 90da2b28 07-Jun-2009 Ariff Abdullah <ariff@FreeBSD.org>

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.


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 082f6383 17-Jun-2007 Ariff Abdullah <ariff@FreeBSD.org>

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


# bdfbdcec 10-Jun-2007 Ariff Abdullah <ariff@FreeBSD.org>

Filter/compress the amount of channel trigger. This should reduce
much of lock/unlock contentions within the interrupt handler. Most
of these drivers only need PCMTRIG_START or STOP (ABORT).

Discussed with: scottl


# 2e334adf 18-Apr-2007 Ariff Abdullah <ariff@FreeBSD.org>

sndbuf_alloc() now accept dmaflags argument which will be forwarded to
internal bus_dmammem_alloc() for greater flexibility on setting up DMA /
page attributes.


# 4582b3a1 15-Mar-2007 Ariff Abdullah <ariff@FreeBSD.org>

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.


# 018b991e 08-Mar-2007 Ariff Abdullah <ariff@FreeBSD.org>

Fix long standing multi playback/recording issues, caused by
excessive interrupt clock timer reset, screwing interrupt generation
for already active channels. Track moving DMA pointer and call buffer
interrupt on each blocksize boundary.

PR: kern/109791
MFC after: 3 days


# 0b989078 23-Feb-2007 Alexander Leidinger <netchild@FreeBSD.org>

MFp4 (114068):
Use bus_get_dma_tag() to obtain the parent DMA tag to make the drivers
a little bit more non-ia32/amd64 friendly.

There is no man page for bus_get_dma_tag, so this is modelled after
rev. 1.62 of src/sys/dev/sound/pci/es137x.c by marius.

Inspired by: commit by marius


# 7535accf 13-Sep-2005 Pyun YongHyeon <yongari@FreeBSD.org>

Unlock driver lock before calling resource_int_value(9).
This should fix LOR(in fact it's not LOR) in device attach.


# c21880a7 23-May-2005 Pyun YongHyeon <yongari@FreeBSD.org>

Make snd_maestro3(4) mpsafe
- Let m3_pchan_trigger()/m3_rchan_trigger() acquire lock and call
m3_pchan_trigger_locked()/m3_rchan_trigger_locked() respectivly.
- Mark interrupt handler INTR_MPSAFE.
- Add locks in sound/channel interface.

Tested by: nork


# d2b677bb 01-Mar-2005 Warner Losh <imp@FreeBSD.org>

Use BUS_PROBE_DEFAULT in preference to 0 and BUS_PROBE_LOW_PRIORITY in
preference to some random negative number to allow other drivers a
bite at the apple.


# eba1cb6e 12-Oct-2004 Pyun YongHyeon <yongari@FreeBSD.org>

Audio drivers failed to detect failure condition and attempted to
assign DMA address to the wrong address. It can cause system lockup
or other mysterious errors. Since most sound cards requires low DMA
address(BUS_SPACE_MAXADDR_24BIT) sndbuf_alloc() would fail when the
audio driver is loaded after long running of operations.

Approved by: jake (mentor)
Reviewed by: truckman, matk


# 0739ea1d 15-Jul-2004 Seigo Tanimura <tanimura@FreeBSD.org>

Rename the sound device drivers:

- `sound'
The generic sound driver, always required.

- `snd_*'
Device-dependent drivers, named after the sound module names.
Configure accordingly to your hardware.

In addition, rename the `snd_pcm' module to `sound' in order to sync
with the driver names.

Suggested by: cg


# 5f96beb9 17-Mar-2004 Nate Lawson <njl@FreeBSD.org>

Convert callers to the new bus_alloc_resource_any(9) API.

Submitted by: Mark Santcroos <marks@ripe.net>
Reviewed by: imp, dfr, bde


# 0d8ed52e 06-Mar-2004 Mathew Kanner <matk@FreeBSD.org>

Augment /dev/sndstat with the module names, if applicable.

Approved by: tanimura (mentor)


# e27951b2 02-Sep-2003 John Baldwin <jhb@FreeBSD.org>

Use PCIR_BAR(x) instead of PCIR_MAPS.

Glanced over by: imp, gibbs
Tested by: i386 LINT


# 90cf0136 22-Aug-2003 Warner Losh <imp@FreeBSD.org>

Prefer new location of pci include files (which have only been in the
tree for two or more years now), except in a few places where there's
code to be compatible with older versions of FreeBSD.


# f6b1c44d 01-Jul-2003 Scott Long <scottl@FreeBSD.org>

Mega busdma API commit.

Add two new arguments to bus_dma_tag_create(): lockfunc and lockfuncarg.
Lockfunc allows a driver to provide a function for managing its locking
semantics while using busdma. At the moment, this is used for the
asynchronous busdma_swi and callback mechanism. Two lockfunc implementations
are provided: busdma_lock_mutex() performs standard mutex operations on the
mutex that is specified from lockfuncarg. dftl_lock() is a panic
implementation and is defaulted to when NULL, NULL are passed to
bus_dma_tag_create(). The only time that NULL, NULL should ever be used is
when the driver ensures that bus_dmamap_load() will not be deferred.
Drivers that do not provide their own locking can pass
busdma_lock_mutex,&Giant args in order to preserve the former behaviour.

sparc64 and powerpc do not provide real busdma_swi functions, so this is
largely a noop on those platforms. The busdma_swi on is64 is not properly
locked yet, so warnings will be emitted on this platform when busdma
callback deferrals happen.

If anyone gets panics or warnings from dflt_lock() being called, please
let me know right away.

Reviewed by: tmm, gibbs


# 38cc9942 20-Feb-2003 Olivier Houchard <cognet@FreeBSD.org>

Implement a "sndbuf_getbufaddr" function and use it instead of vtophys().

Reviewed by: orion


# 5ffa65f9 04-Sep-2002 Scott Long <scottl@FreeBSD.org>

Sigh. The fix to the suspend code wasn't complete, since the resume
code was broken in the same way.

Submitted by: co9@xs4all.nl
MFC after: 3 days


# c02a39a1 29-Aug-2002 Scott Long <scottl@FreeBSD.org>

Fix a silly off my one error that caused crashes on resume in certain
circumstances. The problem was only reported with -stable, but it's
obviously wrong in -current also. MFC is forthcoming.

Submitted by: doconnor@dsoft.com.au


# 0a17f47b 08-Jul-2002 Robert Drehmel <robert@FreeBSD.org>

Reenable the m3 interrupts in m3_pci_resume() and do not
enable them in m3_pci_attach().


# 63393eea 28-Jun-2002 Scott Long <scottl@FreeBSD.org>

Fix a botched flag clear operation. Rumor has it that this also fixes
the funky-volume-settings-on-startup problem.

Reviewed by: the channel that shall not be named
MFC after: 7 days


# 9ce4f543 24-Jun-2002 Robert Drehmel <robert@FreeBSD.org>

Enable mixer interrupts after the mixer is initialized,
otherwise we might get interrupts and are unable to
handle them properly, which results in a page fault.

PR: kern/39549
Submitted by: Gil Kloepfer <gil@arlut.utexas.edu>


# 60d1d686 27-Jan-2002 Scott Long <scottl@FreeBSD.org>

Recent changes to newpcm require that the CHANNEL_SETFORMAT op return 0
for success, non-zero otherwise. The maestro and maestro3 drivers were
returning the format code, which was being interpreted as a failure code.
Fixed. No one seems to have noticed that the maestro driver was broken,
but I'll fix it anyways.

MFC after: 2 weeks


# 3068bdba 05-Dec-2001 Guido van Rooij <guido@FreeBSD.org>

Fix resume for HP Omnibook 500's.

MFC after: 1 week


# 73b9d66d 14-Oct-2001 Scott Long <scottl@FreeBSD.org>

Turn on the hardware volume buttons that are present on most laptops with
these chips. There is a new hint, hint.pcm.N.hwvol_config, that can be set
to 1 or 0 to select which pins the buttons are connected to. I'm open to
suggestions on where to document this. Also bump the number of playback
channels up to 4.

MFC after: 3 days


# baadfb4c 09-Oct-2001 Scott Long <scottl@FreeBSD.org>

Update to using the pcm_getbuffersize() method.
Fix an off-by-one error in the saving of the dsp memory.
Up the play channels to 2.

MFC after: 3 days


# 67b1dce3 23-Aug-2001 Cameron Grant <cg@FreeBSD.org>

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.


# 19f2be11 19-Jul-2001 Scott Long <scottl@FreeBSD.org>

Limit the device to only one playback channel until I can figure out why
a) newpcm insists on using only the highest number channel available, and
b) the maestro3 driver no longer likes anything above channel 0.


# e93d24c2 19-Jul-2001 Scott Long <scottl@FreeBSD.org>

Fix an off-by-one error in the dma tag. This was causing the VM system to
freak out occasionally.

MFC after: 1 week


# d95502a8 16-Jun-2001 Cameron Grant <cg@FreeBSD.org>

use a global devclass for all drivers - i'm not entirely sure why this
worked before.

mixer, dsp and sndstat are seperate devices - give them their own cdevsws
instead of demuxing requests sent to a single cdevsw.

use the si_drv1/si_drv2 fields in dev_t structures for holding information
specific to an open instance of mixer/dsp.

nuke /dev/{dsp,dspW,audio}[0-9]* links - this functionality is now provided
using cloning.

various locking fixes.


# 7edce08a 25-May-2001 Scott Long <scottl@FreeBSD.org>

Fix DMA on machines with more than 128MB.

Obtained from: cg
MFC after: 5 days


# 26799605 25-Mar-2001 Cameron Grant <cg@FreeBSD.org>

fix whitespace bogons


# 66ef8af5 24-Mar-2001 Cameron Grant <cg@FreeBSD.org>

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.


# ea0e6ecf 27-Feb-2001 Scott Long <scottl@FreeBSD.org>

Don't re-init the mixer on resume. This keeps the channel volumes from
being trashed when you suspend, though this may need to be revisited if we
ever get suspend-to-disk implememted.


# a5108eae 01-Feb-2001 Scott Long <scottl@FreeBSD.org>

Driver for the ESS Maestro3 and Allegro sound chips. Note that due to the
amount of GPL'd firmware in the driver, it will only be built as a module.

Approved by: cg