Home | History | Annotate | Download | only in pci
History log of /src/sys/dev/pci/cmpci.c
RevisionDateAuthorComments
 1.61  08-Jan-2024  chs mpu / opl: add an interface attribute to config_found() calls for these

specify an interface attribute when attaching mpu and opl devices.
the PCI devices that are the parents of these midi devices
(cmpci, eso, fms, sv, yds) have two interface attributes:
"audiobus", and also one named the same as the parent device,
eg. "cmpci" has an interface attribute named "cmpci".
we must specify the latter one to attach these children.
 1.60  31-May-2022  andvar branches: 1.60.4;
fix various typos in comments, documentation and messages.
 1.59  07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.58  24-Apr-2021  thorpej branches: 1.58.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.57  29-Feb-2020  isaki branches: 1.57.8;
Remove rounding by 4 bytes on round_blocksize().
For drivers which supports only 16bit * 2channels sampling,
rounding by 4 bytes no longer meaningful.
 1.56  08-Jun-2019  isaki branches: 1.56.4;
Clean get_props().
- Make get_props() return AUDIO_PROP_{PLAYBACK,CAPTURE} properly.
This eliminates need for audio.c to take care of such (old)
drivers which don't return both of PLAYBACK and CAPTURE.
- All get_props() doesn't need to return AUDIO_PROP_MMAP.
It is handled in the audio layer now.
 1.55  12-May-2019  maya Remove unused function following isaki-audio2 merge.

Shows up when doing clang builds. From a.rin.
 1.54  08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.53  16-Mar-2019  isaki branches: 1.53.2;
White space.
 1.52  16-Mar-2019  isaki Use C99 style struct initializer to audio_hw_if.
 1.51  09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.50  01-Jun-2017  chs branches: 1.50.8; 1.50.10;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.49  15-Aug-2016  maxv Use the exact same argument for kmem_alloc and kmem_free; from brainy
 1.48  07-Jul-2016  msaitoh KNF. Remove extra spaces. No functional change.
 1.47  29-Mar-2014  christos branches: 1.47.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.46  27-Oct-2012  chs branches: 1.46.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.45  30-Jan-2012  drochner branches: 1.45.6;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.44  24-Nov-2011  mrg branches: 1.44.2;
put back IPL_AUDIO and splaudio(), at the request of rmind. they are
aliases and now we can easily revert audio to IPL_VM if necessary,
without having to revert the whole branch.
 1.43  23-Nov-2011  jmcneill Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.42  26-Nov-2009  njoly branches: 1.42.12; 1.42.14;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.41  12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.40  06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.39  06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.38  10-Apr-2008  cegger branches: 1.38.4; 1.38.16; 1.38.18;
use aprint_*_dev and device_xname
 1.37  01-Apr-2008  xtraeme Fix fallout from device_t/softc split to mpu(4):
always pass the mpu_softc to mpu_intr(). Found by Takeshi Nakayama.
 1.36  19-Oct-2007  ad branches: 1.36.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.35  04-Mar-2007  christos branches: 1.35.2; 1.35.14; 1.35.16; 1.35.20;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.34  16-Nov-2006  christos branches: 1.34.4; 1.34.6;
__unused removal on arguments; approved by core.
 1.33  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.32  29-Aug-2006  christos branches: 1.32.2; 1.32.4;
fix incomplete initializer.
 1.31  11-May-2006  mrg quell GCC 4.1 uninitialised variable warnings.
 1.30  24-Dec-2005  perry branches: 1.30.4; 1.30.6; 1.30.8; 1.30.12;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.29  11-Dec-2005  christos merge ktrace-lwp.
 1.28  15-Jan-2005  kent branches: 1.28.10;
ansify and KNF
 1.27  10-Jan-2005  kent merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework


Summary of changes:

* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.

* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()

* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t

* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.

* add `struct device *' parameter to ac97_attach()

* all of audio HW drivers follow audio_hw_if and ac97 changes
 1.26  29-Oct-2004  yamt branches: 1.26.2;
constify audio_hw_if, midi_hw_if, and radio_hw_if.
 1.25  26-Oct-2004  xtraeme Fix typo in a comment: alalog -> analog.
 1.24  23-Apr-2004  itojun pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.23  06-Dec-2003  itohy Back out the following commit and apply the real fix.
A variable was actually used in a wrong way.

> revision 1.20
> date: 2003/10/25 21:31:43; author: christos; state: Exp; lines: +3 -3
> Fix uninitialized variable warnings.
 1.22  04-Dec-2003  keihan netbsd.org -> NetBSD.org

This was the last commit of this kind to src/sys, which is now totally
"NetBSD.org clean". Thanks for the patiance, and sorry for all the commits.
 1.21  22-Nov-2003  itohy - Correctly handle bit 24 of miscellaneous control register, which has
different meanings for read and write.
This fixes 48kHz playback to SPDIF.
- Fix the problem where the SPDIF output voltage setting (0.5V, 5V)
was swapped. The default value is changed from 0.5V to 5V, which
correctly selects 5V (so the default physical behavior is unchanged).

Should fix PRs kern/16047 and kern/16817
(but not tested since I don't have other SPDIF hardware to test with).
Approved by tshiozak.
 1.20  25-Oct-2003  christos Fix uninitialized variable warnings.
 1.19  25-Oct-2003  christos Fix uninitialized variable warnings
 1.18  01-Feb-2003  thorpej branches: 1.18.2;
Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
 1.17  31-Jan-2003  thorpej Use aprint_*().
 1.16  02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.15  30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.14  27-Sep-2002  thorpej Declare all cfattach structures const.
 1.13  02-Feb-2002  augustss Fix typo so that 48kHz can be set. From Stephen Ma in kern/15456.
 1.12  27-Dec-2001  itohy Fix comment.
 1.11  13-Nov-2001  lukem add RCSID
 1.10  04-Nov-2001  itohy Re-implement the mixer
o Implement SPDIF selection/monitoring function.
Now, say, playback to both analog output and SPDIF is possible.

o Implement support of AUX input, MIC preamp and MIC recording gain.

o L-R selection of record source doesn't seem to work on cmpci.
Therefore, the *.swap mixer functions are and deleted.

o Following SB mixer registers don't exist on cmpci, and they are removed.
input gain, output gain, AGC, equalization (bass, treble)

o Other mixer changes, including
inputs.XXX.mute -> (deleted)
outputs.XXX.mute -> inputs.XXX.mute
inputs.pc_speaker -> inputs.speaker
spdif.* -> reorganized to spdif.input.*, spdif.output.*

o Current status:
I have tested these and confirmed to work fine.
- Output and recording from Line-in, AUX, CD and MIC analog inputs,
- Output and recording from FM synthesizer,
- Output from PC speaker input,
- Output wave playback.
- SPDIF (44.1kHz) input selection (#1, #2 (6ch version only),
wave to spdin), phase selection, monitoring and recording,
- SPDIF (44.1kHz) playback, through (SPDIF in to SPDIF out)
and monitoring.

I haven't tested these but may work.
- SPDIF 48kHz input and output,
- Full-duplex operation,
- Recording wave output.

I don't think these are working.
- Legacy (wave + FM synthesizer) to SPDIF output (and the monitoring),
- Exchanging front and rear outputs,
- Surround.

These are not implemented.
- 4ch / 6ch support,
- Joystick port support.
 1.9  03-Oct-2001  augustss branches: 1.9.2;
Add a new optional method, dev_ioctl, to the audio hardware driver interface.
It is called when an unrecognized ioctl() is performed on a device,
thus allowing ioctl()s that frob the hardware driver (like loading
microcode).
 1.8  04-Sep-2001  itohy branches: 1.8.2;
- Add opl at cmpci attachment.
- Add mpu at cmpci attachment.
- Fix panic during attach on alpha.
- Change register of SPDIF input phase (but undocumented, either).
- Change code for mixer initialization.
- Return 1, not 0, when an interrupt is processed.

More changes to the mixer are pending....
 1.7  12-Feb-2001  tshiozak branches: 1.7.2; 1.7.4;
some improvement for cmpci; SPDIF supports, etc.
 1.6  18-Jan-2001  jdolecek constify
 1.5  28-Dec-2000  sommerfeld Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.4  26-Jun-2000  simonb branches: 1.4.2;
Change the kernel mmap interface so that the offset to map is an
"off_t" and the return value is a "paddr_t" to allow mappings
at offsets past 2^31 bytes. Somewhat inspired by FreeBSD, which
only changed the offset to a "vm_offset_t".

Includes updates for the i386, pc532 and sh3 mmmmap from Jason Thorpe.
 1.3  08-Jun-2000  gmcgarry branches: 1.3.2;
Make attach messages consistent with PCI drivers. Make function pointer
usage consistent with other drivers.
 1.2  30-Apr-2000  augustss branches: 1.2.2;
Remove unneeded #include "mpu.h"
 1.1  30-Apr-2000  augustss Add driver for C-Media CMI8x38 Audio Chip. From Takuya SHIOZAKI <AoiMoe@imou.to>
 1.2.2.1  22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.3.2.1  30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.4.2.5  12-Mar-2001  bouyer Sync with HEAD.
 1.4.2.4  11-Feb-2001  bouyer Sync with HEAD.
 1.4.2.3  05-Jan-2001  bouyer Sync with HEAD
 1.4.2.2  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.2.1  26-Jun-2000  bouyer file cmpci.c was added on branch thorpej_scsipi on 2000-11-20 11:42:15 +0000
 1.7.4.4  10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.7.4.3  11-Feb-2002  jdolecek Sync w/ -current.
 1.7.4.2  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.7.4.1  13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.7.2.6  18-Oct-2002  nathanw Catch up to -current.
 1.7.2.5  28-Feb-2002  nathanw Catch up to -current.
 1.7.2.4  08-Jan-2002  nathanw Catch up to -current.
 1.7.2.3  14-Nov-2001  nathanw Catch up to -current.
 1.7.2.2  08-Oct-2001  nathanw Catch up to -current.
 1.7.2.1  21-Sep-2001  nathanw Catch up to -current.
 1.8.2.1  11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.9.2.1  12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.18.2.5  17-Jan-2005  skrll Sync with HEAD.
 1.18.2.4  02-Nov-2004  skrll Sync with HEAD.
 1.18.2.3  21-Sep-2004  skrll Fix the sync with head I botched.
 1.18.2.2  18-Sep-2004  skrll Sync with HEAD.
 1.18.2.1  03-Aug-2004  skrll Sync with HEAD
 1.26.2.2  09-Jan-2005  kent audio_hw_if change
* make open() and close() optional
* add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
 1.26.2.1  02-Jan-2005  kent * adopt the filter pipeline framework
* follow ac97_attach() change
 1.28.10.4  27-Oct-2007  yamt sync with head.
 1.28.10.3  03-Sep-2007  yamt sync with head.
 1.28.10.2  30-Dec-2006  yamt sync with head.
 1.28.10.1  21-Jun-2006  yamt sync with head.
 1.30.12.1  24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.30.8.2  03-Sep-2006  yamt sync with head.
 1.30.8.1  24-May-2006  yamt sync with head.
 1.30.6.1  01-Jun-2006  kardel Sync with head.
 1.30.4.1  09-Sep-2006  rpaulo sync with head
 1.32.4.2  10-Dec-2006  yamt sync with head.
 1.32.4.1  22-Oct-2006  yamt sync with head
 1.32.2.1  18-Nov-2006  ad Sync with head.
 1.34.6.1  27-Feb-2007  ad Add MP locking for audio drivers.
 1.34.4.1  12-Mar-2007  rmind Sync with HEAD.
 1.35.20.1  25-Oct-2007  bouyer Sync with HEAD.
 1.35.16.1  06-Nov-2007  matt sync with HEAD
 1.35.14.1  26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.35.2.1  23-Oct-2007  ad Sync with head.
 1.36.16.2  02-Jun-2008  mjf Sync with HEAD.
 1.36.16.1  03-Apr-2008  mjf Sync with HEAD.
 1.38.18.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.38.16.1  11-Dec-2008  ad Checkpoint work in progress.
 1.38.4.2  11-Mar-2010  yamt sync with head
 1.38.4.1  16-May-2009  yamt sync with head
 1.42.14.2  22-Nov-2011  jmcneill get rid of unused 'powerstate' callback in audio_hw_if
 1.42.14.1  19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.42.12.3  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.42.12.2  30-Oct-2012  yamt sync with head
 1.42.12.1  17-Apr-2012  yamt sync with head
 1.44.2.1  18-Feb-2012  mrg merge to -current.
 1.45.6.3  03-Dec-2017  jdolecek update from HEAD
 1.45.6.2  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.45.6.1  20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.46.2.1  18-May-2014  rmind sync with head
 1.47.6.3  28-Aug-2017  skrll Sync with HEAD
 1.47.6.2  05-Oct-2016  skrll Sync with HEAD
 1.47.6.1  09-Jul-2016  skrll Sync with HEAD
 1.50.10.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.50.10.1  10-Jun-2019  christos Sync with HEAD
 1.50.8.1  26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.53.2.3  04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.53.2.2  28-Apr-2019  isaki Adapt to audio2.
 1.53.2.1  21-Apr-2019  isaki Use C99 style struct initializer to audio_format.
 1.56.4.1  29-Feb-2020  ad Sync with head.
 1.57.8.1  21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.58.8.1  04-Aug-2021  thorpej Adapt to CFARGS().
 1.60.4.1  14-Jan-2024  martin Pull up following revision(s) (requested by chs in ticket #542):

sys/dev/pci/yds.c: revision 1.69
sys/dev/pci/cmpci.c: revision 1.61
sys/dev/pci/sv.c: revision 1.62
sys/dev/pci/fms.c: revision 1.50

mpu / opl: add an interface attribute to config_found() calls for these

specify an interface attribute when attaching mpu and opl devices.
the PCI devices that are the parents of these midi devices
(cmpci, eso, fms, sv, yds) have two interface attributes:
"audiobus", and also one named the same as the parent device,
eg. "cmpci" has an interface attribute named "cmpci".
we must specify the latter one to attach these children.

RSS XML Feed