summaryrefslogtreecommitdiff
path: root/sys/dev/audio
AgeCommit message (Collapse)Author
2021-12-12fix various typos, mainly in comments.andvar
2021-12-10s/occured/occurred/ in comments, log messages and man pages.andvar
2021-12-05s/faciliate/facilitate/ in comment.msaitoh
2021-10-10audio(9): Issue pserialize_perform outside sc_lock in audiodetach.riastradh
Breaks another deadlock between sc_lock and high-priority xcalls at softint serial. With any luck, this should be the last such softint deadlock in audio!
2021-10-10audio(9): Call hw_if->getdev without sc_lock.riastradh
Holding sc_lock is not necessary -- I reviewed all ~70 cases in-tree, and none of them rely on state protected by sc_lock. Essentially everything just copies from static data or data initialized at attach time. (Exceptions: tms320av110.c issues a bus_space_read_1, but I don't see any reason why that needs to be serialized; and uaudio.c reads from sc_dying, but that's not necessary and also not protected by sc_lock anyway.) Holding sc_lock is harmful because at least hdafg(4) can trigger module autoload that leads to pserialize_perform, which waits for logic to run at softint serial on all CPUs; at the same time, audio_softintr_rd/wr run at softint serial and take sc_lock, so this leads to deadlock.
2021-09-26Change the kqueue filterops::f_isfd field to filterops::f_flags, andthorpej
define a flag FILTEROP_ISFD that has the meaning of the prior f_isfd. Field and flag name aligned with OpenBSD. This does not constitute a functional or ABI change, as the field location and size, and the value placed in that field, are the same as the previous code, but we're bumping __NetBSD_Version__ so 3rd-party module source code can adapt, as needed. NetBSD 9.99.89
2021-09-07s/aquire/acquire/ in comments, also one typo fix acqure->acquire.andvar
2021-08-21s/recoding/recording/ in comments where it didn't actually mean recoding.andvar
2021-08-07Merge thorpej-cfargs2.thorpej
2021-07-21need <sys/param.h> for COHERENCY_UNITskrll
Minor KNF along the way.
2021-07-21AUDIO_SETINFO: fix a bug that the gain and the balance could not be setisaki
at the same time. Fix PR kern/56308.
2021-06-08audio(4): Revert revision 1.96 and redo it another way.riastradh
Instead of refusing to open /dev/audioN for writes when the device doesn't support playback, just refuse to issue writes. Although it seems more sensible to me to reject writable opens early on, and it seems Solaris does so, this makes querying device properties a little trickier and is a change to the NetBSD semantics.
2021-06-04audio(4): When closing /dev/audioN, drain before removing from list.riastradh
Previously, in revision 1.100, I factored the SLIST_REMOVE out of audio_unlink and audio_close up into audioclose since it is now used by /dev/audio, /dev/audioctl, and /dev/mixer alike. But I didn't realize that the order 1. audio_track_drain 2. SLIST_REMOVE from sc_files was significant; it matters because audio_track_drain waits for wakeups that are delivered by hardware interrupts only to files listed in sc_files. This also fixes a bug introduced with the audiobell -- it was missing the SLIST_REMOVE altogether. For now, duplicate the SLIST_REMOVE calls in a few more places -- this is suboptimal but I want to make sure the logic works before factoring it all out to tidy up.
2021-06-01audio(4): audio_unlink never fails, so make it return void.riastradh
2021-06-01audio(4): Insert mixers and audioctls into sc_files on open too.riastradh
This is necessary so that on detach we set file->dying before any operations, particularly audioclose, try to acquire a psref by the time the audio softc is gone. Candidate fix for PR kern/56164.
2021-06-01audio(4): No need to set file->dying when closing the file.riastradh
No other file operations are possible by the time we get to audioclose.
2021-06-01audio(4): Grab sc->sc_cred under sc->sc_lock before freeing.riastradh
Otherwise we may race with open, leaking a cred no longer in use and freeing a cred still in use.
2021-06-01audio(4): Use kmem_alloc(sizeof(*p)) style.riastradh
2021-06-01audio(4): Make sure to return ENXIO if device is being detached.riastradh
Don't return 0 indicating successful open of an unusable device!
2021-06-01audio(4): Set AUMODE_PLAY/RECORD only if asked _and_ supported.riastradh
If one is requested and _not_ supported, fail; otherwise we might enter audio_write with a null play track and crash on KASSERT.
2021-05-02audio: Only score hardware formats by channel count at count<=2nia
Scoring by channel count makes sense when you are using hardware that supports mono and stereo formats. However, if your hardware also supports surround formats, defaulting to those might be confusing. So, don't prefer them. Problem reported and fix tested by tcmart14 with a 2015 model Macbook Pro.
2021-04-26audioprint(): handle AUDIODEV_TYPE_AUX.thorpej
2021-04-26audio_attach_mi(): Be explicit about using the "audiobus" interface attribute,thorpej
as the caller may be a device that carries more than one.
2021-04-24Merge thorpej-cfargs branch:thorpej
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?).
2021-03-20Fix and improve the buffer length calculation to avoid zero lengthisaki
even if blk_ms is small. This fixes PR kern/56059.
2021-02-14Add missing curlwp_bindx() corresponding to curlwp_bind().isaki
Pointed out by riastradh@.
2021-02-09Protect also audioopen() and audiobellopen() from audiodetach() withisaki
psref(9), as well as others(audioread, audiowrite, etc..). - Rename audio_file_enter to audio_sc_acquire_fromfile, audio_file_exit to audio_sc_release, for clarify. These are the reference counter for this sc. - Introduce audio_sc_acquire_foropen for audio{,bell}open. - audio_open needs to examine sc_dying again before inserting it into sc_files, in order to keep sc_files consistency. The race between audiodetach and audioopen is pointed out by riastradh@. Thank you for many advices.
2021-02-09Change the lock conditions to call audio_unlink().isaki
This can remove a different copy of audio_exlock_enter() in audio_unlink() and can use normal one. Also, in audiodetach(), this can set the exlock at more natual order (before calling audio_unlink()). No noticeable functional changes are intended. Thanks for comments, riastradh@.
2021-01-15Improve error messages.isaki
- prefix MD device name if it's considered to be related to the MD driver. - revise some messages.
2021-01-15Change (harmless) zero-length debug messages.isaki
sys/modules is compiled with -Wzero-length-format and this makes sys/modules compilable even if AUDIO_DEBUG is defined.
2020-12-19Use sel{record,remove}_knote().thorpej
2020-12-13Revise comments.isaki
2020-12-13Fix a return value of audiopoll().isaki
fo_poll is expected to return revents rather than errno on error.
2020-12-13Avoid a dead lock in audiodetach, since rev 1.63.isaki
audio_unlink() must be called without exlock held (and audio_mixer_destroy() must be called with exlock held). This makes unplugging during playing/recording work (again). Reported by Julian Coleman on current-users: http://mail-index.netbsd.org/current-users/2020/12/10/msg040050.html
2020-12-13Add missing newline.isaki
2020-12-09Rewrite error handling on audio_open().isaki
This also fixes a few resource leaks on error case.
2020-12-09Fix that audio_open() didn't halt the recording mixer correctlyisaki
if fd_allocfile() failed, since rev 1.65. Will fix PR kern/55848.
2020-09-13Support audio descriptor for fstat(1).isaki
sys/dev/audio/*.h: export only what we need for fstat.
2020-09-12Improve slinear16-to-mulaw conversion calculation.isaki
It's about 2~3 times faster on my amd64 and x68k(68030).
2020-09-07Fix misspellings in comment.isaki
2020-08-23Improve debug messages.isaki
2020-08-23Improve and update comments.isaki
2020-08-23Style fixes.isaki
2020-05-29Fix suspend/resume.isaki
- Revert temporary usage of sc_[pr]busy during suspend. These indicate whether the mixer needs to be restarted or not. - Avoid timeout error when about to suspend.
2020-05-26audio: Only restart recording mixer on resume if it's already been startednia
2020-05-26audio: remove comment that is no longer validnia
2020-05-26audio: Restore compat with Solaris for 8-bit LINEAR.nia
It's always signed, unless it's LINEAR8. PR kern/55175
2020-05-26audio: Fix logic for resuming when the device is in use.nia
audio_[r/p]mixer_start should never be called when the device is marked busy. Resolves a panic on resume when audio is playing, PR kern/55301
2020-05-23Move proc_lock into the data segment. It was dynamically allocated becausead
at the time we had mutex_obj_alloc() but not __cacheline_aligned.
2020-05-01Move machine dependent AUDIO_BLK_MS default value to <machine/param.h>.isaki
If the port has __AUDIO_BLK_MS in <machine/param.h>, it will be used. Otherwise the default value (currently 10 msec) defined in audio.c will be used. This mechanism is for very old ports which cannot satisfactorily handle 10 msec block. Currently hppa, m68k, sh3, sparc(!64) and vax are. For port maintainers, if general models in your port cannot satisfactorily handle 10 msec block, please consider to define your suitable longer period (40 msec would be a good first choice). But please don't be eager to make the default value shorter. <machine/param.h> was discussed in source-changes-d. It's better than ifdef storm, or adding 60+ new header files in every arch/*/include/ directories for this. Thanks mrg@, ad@, and everyone. http://mail-index.netbsd.org/source-changes-d/2020/05/01/msg012572.html