summaryrefslogtreecommitdiff
path: root/sys/dev/pad/pad.c
AgeCommit message (Collapse)Author
2023-05-27Revert to previous.nat
This change broke the intention of recent changes to pad(4). The solution to address PR/57436 must be done in bta2dpd(8).
2023-05-26Fix previous.nat
The previous commit was misleading due to the flag names used. The rationale for this change is that it is ok to return EAGAIN on first read as playback has not started. Then it shoud wait on every subsequent read. This is what makes the high precsision throttling of pad(4), for which these degree of fine-grained sleeps are not possible in userland. This is a requirement of users of pad(4) such as bta2dpd(8).
2023-05-26Fix logic for timing.nat
Addresses PR/57436. XXX pullup-10.
2023-05-01Don't overflow when scaling 32bit samples.mlelstv
2023-04-23No longer use AUDIO_INTERNAL_BITS but rely on passed audio format.mlelstv
2023-04-10Write slinear_le 16bit samples, independent from platform andmlelstv
AUDIO_INTERNAL_BITS.
2023-01-24Pace I/O timing to match the audio interface.mlelstv
Enable interrupts while copying buffers.
2022-03-31For device modules that provide both auto-config and /dev/xxxpgoyette
interfaces, make sure that initialization and destruction follow the proper sequence. This is triggered by the recent changes to the devsw stuff; per riastradh@ the required call sequence is: devsw_attach() config_init_component() or config_cf*_attach() ... config_fini_component() or config_cf*_detach() devsw_detach() While here, add a few missing calls to some of the detach routines. Testing of these changes has been limited to: 1. compile without build break 2. no related test failures from atf 3. modload/modunload work as well as before. No functional device testing done, since I don't have any of these devices. Let me know of any damage I might cause here! XXX Some of the modules affected by this commit are already XXX broken; see kern/56772. This commit does not break any additional modules (as far as I know).
2022-03-28driver(9): devsw_detach never fails. Make it return void.riastradh
Prune a whole lotta dead branches as a result of this. (Some logic calling this is also wrong for other reasons; devsw_detach is final -- you should never have any reason to decide to roll it back. To be cleaned up in subsequent commits...) XXX kernel ABI change to devsw_detach signature requires bump
2022-03-12pad(4): Do harmless, not harmful, integer truncation.riastradh
Reported-by: syzbot+917ff3551897f1a99cf6@syzkaller.appspotmail.com
2021-06-14pad(4): Explain what's wrong with using device pointers like this.riastradh
...and why the kernel lock is not enough.
2021-06-14pad(4): Omit unused sc_blksize.riastradh
2021-06-14pad(4): Refactor for clarity, and fix locking bugs.riastradh
- Don't touch sc_buflen outside sc_intr_lock. - Omit needless broadcast in pad_halt_output -- nothing wakes on the new condition (sc_buflen == 0), so this can't make a difference except possibly in buggy code. - Sprinkle KASSERTs.
2021-06-14pad(4): Destroy the callout when done.riastradh
Should not be possible for it to be pending or firing at this point, because we have detached the audio(4) child and so it should have halted output.
2021-06-14pad(4): Make this exclusively a cloning device.riastradh
padN numbering never corresponded with audioM numbering except by accident, so the non-cloning device never worked reliably for scripting. This simplifies the logic substantially. While here, fix drvctl detach race.
2021-06-14pad(4): Sort includes. Add missing includes to padvar.h.riastradh
2021-06-14pad(4): Fix some locking.riastradh
- No need for sc_cond_lock. - Issue cv_broadcast under the correct lock. - Use callout_halt, not haphazard callout_stop. - IPL_SOFTCLOCK for a mutex taken from a callout.
2021-06-14pad(4): Some incomplete tidying.riastradh
- Put pseudo-device softc setup/teardown back in pad_attach/detach, not in the cdev/fops operations which are about file descriptors. - Remove unnecessary sc_dying flag. - Omit needless config_deactivate(sc->sc_audiodev); the only effect of this is already done by config_detach anyway, which is done in the same context. - Issue config_detach_children and free softc stuff in the right order. - Omit needless `if (sc == NULL) return ENXIO'. Survives eight parallel t_mixerctl tests many times over on an 8-thread/4-core machine. XXX TODO: - Remove padconfig; it is not appropriate to hold a mutex over sleeping allocation or autoconf config_attach operations. This should be done another way. - Fix agreement of sc_condvar with locks: is it sc_cond_lock or sc_intr_lock? Can't be both; unclear why both exist. - Determine whether both cdev and fops are really needed -- it is confusing to have two types of paths into all this logic, and it seems to me only one of them should be necessary.
2021-06-13pad(4): Take kernel lock around autoconf stuff.riastradh
This is not really enough -- the padconfig locking logic violates rules about sleeping while holding locks, might be deadlocky, and may also be racy. But, it'll serve to make progress.
2021-06-08pad(4): run the callout if the buffer is saturated instead of returningnia
reverts to the same behavior as in -8 and -9. prevents immediate failures and device timeouts if there's a slight delay in the buffer being consumed. this is reproducible with the example in the man page that uses ffmpeg to record the output of audioplay: $ ffmpeg -f s16le -ar 44100 -ac 2 -i /dev/pad0 output.wav $ audioplay -d /dev/audio1 input.wav if output.wav already exists, ffmpeg will prompt for confirmation to overwrite as soon as audioplay starts, causing a noticable delay, followed by a write failure that causes audioplay to immediately exit.
2020-02-23Make start_input/halt_input optional if the driver has no recording,isaki
make start_output/halt_output optional if the driver has no playback. And remove such never called functions.
2020-02-22Make calling get_props() lockless.isaki
get_props() of all MD drivers now can be called without sc_lock.
2019-06-26Fix return value. fo_poll expects revents, not errno.isaki
2019-06-26Style fixes. No functional changes intended.isaki
- Rename some functions for consistency. - Rearrange some functions for readability. - Unify to struct pad_softc.
2019-06-19Don't call next callout when an error occurs in start_output.isaki
2019-06-19pad(4)'s output format is LE even on big endian arch.isaki
2019-05-08Merge isaki-audio2 branch, the overhaul of audio subsystem.isaki
- 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
2018-09-25pad(4) mixer has only 1 channel, so return EINVAL in the case other than 1.nakayama
This fixes the following strange output of mixerctl(1): outputs.master=255,0 inputs.dac=255,0
2018-09-25Revert to rev.1.53.nakayama
I accidentally committed the netbsd-8 branch file in rev.1.54.
2018-09-23Since we need an int paramater, and uio_resid is size_t cast it to intkre
to avoid warnings from the ever friendly compiler... (check that size if in range was already made).
2018-09-23Open code min() so we don't need to find its prototype ...kre
2018-09-23pad(4) mixer has only 1 channel, so return EINVAL in the case other than 1.nakayama
This fixes the following strange output of mixerctl(1): outputs.master=255,0 inputs.dac=255,0
2018-09-03Rename min/max -> uimin/uimax for better honesty.riastradh
These functions are defined on unsigned int. The generic name min/max should not silently truncate to 32 bits on 64-bit systems. This is purely a name change -- no functional change intended. HOWEVER! Some subsystems have #define min(a, b) ((a) < (b) ? (a) : (b)) #define max(a, b) ((a) > (b) ? (a) : (b)) even though our standard name for that is MIN/MAX. Although these may invite multiple evaluation bugs, these do _not_ cause integer truncation. To avoid `fixing' these cases, I first changed the name in libkern, and then compile-tested every file where min/max occurred in order to confirm that it failed -- and thus confirm that nothing shadowed min/max -- before changing it. I have left a handful of bootloaders that are too annoying to compile-test, and some dead code: cobalt ews4800mips hp300 hppa ia64 luna68k vax acorn32/if_ie.c (not included in any kernels) macppc/if_gm.c (superseded by gem(4)) It should be easy to fix the fallout once identified -- this way of doing things fails safe, and the goal here, after all, is to _avoid_ silent integer truncations, not introduce them. Maybe one day we can reintroduce min/max as type-generic things that never silently truncate. But we should avoid doing that for a while, so that existing code has a chance to be detected by the compiler for conversion to uimin/uimax without changing the semantics until we can properly audit it all. (Who knows, maybe in some cases integer truncation is actually intended!)
2018-01-26Fix typo in previous. mea culpa, mea culpa, mea maxima culpapgoyette
2018-01-26Unitialized variable - CID/1428657pgoyette
2018-01-09Fix pad on systems with many cores/cpus:nat
* Introduce a lock to serialize attach/detach of pad devices. * Forcefully detach children of pad on close. * Be more carefull in pad_open with regards to config_detach only if new instances of the pad device are created and fail to open. Addresses PR kern/52889. These changes were developed with and tested by pgoyette@.
2017-12-17If config_fini_component() fails (due to device driver busy), don'tpgoyette
discard its error value when re-attaching the devsw. If the devsw is successfully re-attached and we return success, the module will get detached anyway. And, since the device is actually busy, we'll eventually panic. Thanks to nat@ for providing the reproduction instructions. XXX A driver-busy condition will currently still trigger the error XXX message from config_fini_component() XXX configure: attachment `pad' of `pad' driver fini failed: 16 XXX This will be addresses separately by having pad maintain its own XXX ref-count and not relying on config_fini_component() to detect XXX the busy state.
2017-12-16Use config(1) and IOCONF= to generate most of the auto-config datapgoyette
structures. (Note that bin/52823 documents the reasons for still requiring hand-crafted cfattach structures.)
2017-12-16Remove the correct extra #endifpgoyette
:)
2017-12-16remove extra #endif left in previous commit.mrg
2017-12-15Replace manipulation of individual config structures with calls topgoyette
config_{init,fini}_component()
2017-12-15Rework so that module infrastructure is provided even when the modulepgoyette
is built-in to the kernel. XXX pullup-8?
2017-11-30add fo_name so we can identify the fileops in a simple way.christos
2017-07-30The pad module will now compile with WARNS=5.nat
2017-07-02If a particular pad device is opened, ie pad1 then configure and use pad1nat
if it is not already configured. This improves scriptability as you will know the particular pad(4) device you have opened. pad(4) devices still have a cloning interface if pad device (minor number 254) is opened it will attach the next free device. This action can be repeated. XXX update MAKEDEV scripts to make /dev/pad the cloning device. Ok christos@.
2017-07-02Return early from read if kpause is interrupted by a signal.nat
2017-07-01Pad is now clones its device, attaching upon open and detaching upon close.nat
This means that only one pad device is required in /dev. The code contains a compile time limit of 128 units. Ok christos@.
2017-07-01sc_audiodev should be defined as a device_t as this is what audio_attach_minat
returns.
2017-06-19Use defines to specify pad audio format. NFCI.nat
Ok christos@.
2017-06-06Style change.nat