#
6d4c59e2 |
| 26-Nov-2024 |
Christos Margiolis <christos@FreeBSD.org> |
sound: Remove PCM_DETACHING(), SD_F_DETACHING and SD_F_DYING
Since SD_F_REGISTERED is cleared at the same time SD_F_DETACHING and SD_F_DYING are set, and since PCM_DETACHING() is always used in conj
sound: Remove PCM_DETACHING(), SD_F_DETACHING and SD_F_DYING
Since SD_F_REGISTERED is cleared at the same time SD_F_DETACHING and SD_F_DYING are set, and since PCM_DETACHING() is always used in conjuction with PCM_REGISTERED()/DSP_REGISTERED(), it is enough to just check SD_F_REGISTERED.
Sponsored by: The FreeBSD Foundation MFC after: 2 days Reviewed by: dev_submerge.ch, markj Differential Revision: https://reviews.freebsd.org/D47463
show more ...
|
Revision tags: release/13.4.0 |
|
#
29ff7b08 |
| 27-Jul-2024 |
Christos Margiolis <christos@FreeBSD.org> |
sound: Rename chn_* feeder functions to feeder_*
Avoid layering violation. No functional change intended.
Sponsored by: The FreeBSD Foundation MFC after: 2 days Reviewed by: dev_submerge.ch Differe
sound: Rename chn_* feeder functions to feeder_*
Avoid layering violation. No functional change intended.
Sponsored by: The FreeBSD Foundation MFC after: 2 days Reviewed by: dev_submerge.ch Differential Revision: https://reviews.freebsd.org/D45983
show more ...
|
Revision tags: release/14.1.0 |
|
#
5d980fad |
| 23-May-2024 |
Christos Margiolis <christos@FreeBSD.org> |
sound: Handle unavailable devices in various OSS IOCTLs
mixer(8)'s -a option is used to print information about all mixer devices in the system. To do this, it loops from 0 to mixer_get_nmixers(), a
sound: Handle unavailable devices in various OSS IOCTLs
mixer(8)'s -a option is used to print information about all mixer devices in the system. To do this, it loops from 0 to mixer_get_nmixers(), and tries to open "/dev/mixer%d". However, this approach doesn't work when there are disabled/unregistered mixers in the system, or when an audio device simply doesn't have a mixer.
mixer_get_nmixers() calls SNDCTL_SYSINFO and returns oss_sysinfo->nummixers, whose value is the number of currently _enabled_ mixers only. Taking the bug report mentioned below (277615) as an example, suppose a system with 8 mixer devices total, but 3 of them are either disabled or non-existent, which means they will not show up under /dev, meaning we have 5 enabled mixer devices, which is also what the value of oss_sysinfo->nummixers will be. What mixer(8) will do is loop from 0 to 5 (instead of 8), and start calling mixer_open() on /dev/mixer0, up to /dev/mixer4, and as is expected, the first call will fail right away, hence the error shown in the bug report.
To fix this, modify oss_sysinfo->nummixers to hold the value of the maximum unit in the system, which, although not necessarily "correct", is more intuitive for applications that will want to use this value to loop through all mixer devices.
Additionally, notify applications that a device is unavailable/unregistered instead of skipping it. The current implementations of SNDCTL_AUDIOINFO, SNDCTL_MIXERINFO and SNDCTL_CARDINFO break applications that expect to get information about a device that is skipped. Related discussion can be found here: https://reviews.freebsd.org/D45135#1029526
It has to be noted, that other applications, apart from mixer(8), suffer from this.
PR: 277615 Sponsored by: The FreeBSD Foundation MFC after: 1 day Reviewed by: dev_submerge.ch Differential Revision: https://reviews.freebsd.org/D45256
show more ...
|
#
e07f9178 |
| 23-May-2024 |
Christos Margiolis <christos@FreeBSD.org> |
sound: Separate implementations for SNDCTL_AUDIOINFO[_EX] and SNDCTL_ENGINEINFO
FreeBSD's implementation of SNDCTL_AUDIOINFO[_EX] and SNDCTL_ENGINEINFO does not exactly work as intended. The problem
sound: Separate implementations for SNDCTL_AUDIOINFO[_EX] and SNDCTL_ENGINEINFO
FreeBSD's implementation of SNDCTL_AUDIOINFO[_EX] and SNDCTL_ENGINEINFO does not exactly work as intended. The problem is essentially that both IOCTLs return the same information, while in fact the information returned currently by dsp_oss_audioinfo() is what _only_ SNDCTL_ENGINEINFO is meant to return.
This behavior is also noted in the OSS manual [1] (see bold paragraph in "Audio engines and device files" section), but since e8c0d15a64fa ("sound: Get rid of snd_clone and use DEVFS_CDEVPRIV(9)") we can actually fix this, because we now expose only a single device for each soundcard, and create the engines (channels) internally. SNDCTL_ENGINEINFO will now report info about all channels in a given device, and SNDCTL_AUDIOINFO[_EX] will only report information about /dev/dspX.
To make this work, we also have to modify the SNDCTL_SYSINFO IOCTL to report the number of audio devices and audio engines correctly.
While here, modernize the minimum and maximum channel counting in both SNDCTL_AUDIOINFO[_EX] and SNDCTL_ENGINEINFO. Currently these IOCTLs will report only up to 2 channels, which is no longer the case.
[1] http://manuals.opensound.com/developer/SNDCTL_AUDIOINFO.html
PR: 246231, 252761 Sponsored by: The FreeBSD Foundation MFC after: 1 day Reviewed by: dev_submerge.ch Differential Revision: https://reviews.freebsd.org/D45164
show more ...
|
#
e6df8c37 |
| 09-May-2024 |
Christos Margiolis <christos@FreeBSD.org> |
sound: Add missing oss_mixerinfo devnode and legacy_device fields
They are missing from soundcard.h and are in fact used by some applications, such as OSS' ossinfo(1): http://manuals.opensound.com/d
sound: Add missing oss_mixerinfo devnode and legacy_device fields
They are missing from soundcard.h and are in fact used by some applications, such as OSS' ossinfo(1): http://manuals.opensound.com/developer/ossinfo.c.html
The new size for filler is chosen according to the most recent official version of soundcard.h, which includes those 2 fields.
Sponsored by: The FreeBSD Foundation MFC after: 3 days Reviewed by: dev_submerge.ch Differential Revision: https://reviews.freebsd.org/D45137
show more ...
|
#
2f31a5eb |
| 09-May-2024 |
Christos Margiolis <christos@FreeBSD.org> |
sound: Remove nmix variable from mixer_oss_mixerinfo()
nmix is used to compare against oss_mixerinfo->dev, which is a user-supplied value to select the mixer device (if not -1, in which case we'll s
sound: Remove nmix variable from mixer_oss_mixerinfo()
nmix is used to compare against oss_mixerinfo->dev, which is a user-supplied value to select the mixer device (if not -1, in which case we'll select the default one) we want to fetch the information of. It is also used to set oss_mixerinfo->dev in case it is -1.
However, nmix is at best redundant, since we have the loop counter already (i), and confusing at worst.
For example, suppose a system with 3 mixer devices. We call SNDCTL_MIXERINFO with oss_mixerinfo->dev=1, meaning we want to get information for /dev/mixer1. Suppose /dev/mixer0 detaches while inside the loop, so we'll hit the loop's "continue" case, and nmix won't get incremented (i.e will stay 0 for now). At this point nmix counts 1 device less, so when it reaches 1, we'll be fetching /dev/mixer2's information instead of /dev/mixer1's.
This is also true in case the mixer device disappears prior to the call to mixer_oss_mixerinfo().
Simply remove nmix and use the loop counter to both set oss_mixerinfo->dev and check against it in case a non -1 value is supplied.
Sponsored by: The FreeBSD Foundation MFC after: 3 days Reviewed by: dev_submerge.ch Differential Revision: https://reviews.freebsd.org/D45135
show more ...
|
#
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.or
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
show more ...
|
#
25723d66 |
| 28-Apr-2024 |
Christos Margiolis <christos@FreeBSD.org> |
sound: Retire unit.*
The unit.* code is largely obsolete and imposes limits that are no longer needed nowadays.
- Capping the maximum allowed soundcards in a given machine. By default, the limit
sound: Retire unit.*
The unit.* code is largely obsolete and imposes limits that are no longer needed nowadays.
- Capping the maximum allowed soundcards in a given machine. By default, the limit is 512 (snd_max_u() in unit.c), and the maximum possible is 2048 (SND_UNIT_UMAX in unit.h). It can also be tuned through the hw.snd.maxunit loader(8) tunable. Even though these limits are large enough that they should never cause problems, there is no need for this limit to exist in the first place. - Capping the available device/channel types. By default, this is 32 (snd_max_d() in unit.c). However, these types are pre-defined in pcm/sound.h (see SND_DEV_*), so the cap is unnecessary when we know that their number is constant. - Capping the number of channels per-device. By default, the limit 1024 (snd_max_c() in unit.c). This is probably the most problematic of the limits mentioned, because this limit can never be reached, as the maximum is hard-capped at either hw.snd.maxautovchans (16 by default), or SND_MAXHWCHAN and SND_MAXVCHANS.
These limtits are encoded in masks (see SND_U_MASK, SND_D_MASK, SND_C_MASK in unit.h) and are used to construct a bitfield of the form [dsp_unit, type, channel_unit] in snd_mkunit() which is assigned to pcm_channel->unit.
This patch gets rid of everything unit.*-related and makes a slightly different use of the "unit" field to only contain the channel unit number. The channel type is stored in a new pcm_channel->type field, and the DSP unit number need not be stored at all, since we can fetch it from device_get_unit(pcm_channel->dev). This change has the effect that we no longer need to impose caps on the number of soundcards, device/channel types and per-device channels. As a result the code is noticeably simplified and more readable.
Apart from the fact that the hw.snd.maxunit loader(8) tunable is also retired as a side-effect of this patch, sound(4)'s behavior remains the same.
Sponsored by: The FreeBSD Foundation MFC after: 1 week Reviewed by: dev_submerge.ch Differential Revision: https://reviews.freebsd.org/D44912
show more ...
|
#
b18b990d |
| 28-Apr-2024 |
Christos Margiolis <christos@FreeBSD.org> |
sound: Wrap dsp_clone() and mixer_clone() with bus_topo_lock()
Make sure that the softc isn't freed in between the checks.
Sponsored by: The FreeBSD Foundation MFC after; 1 day Reviewed by: markj D
sound: Wrap dsp_clone() and mixer_clone() with bus_topo_lock()
Make sure that the softc isn't freed in between the checks.
Sponsored by: The FreeBSD Foundation MFC after; 1 day Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D44991
show more ...
|
#
074d6fbe |
| 28-Apr-2024 |
Christos Margiolis <christos@FreeBSD.org> |
sound: Fix NULL dereference in dsp_clone() and mixer_clone()
If we only have a single soundcard attached and we detach it right before entering [dsp|mixer]_clone(), there is a chance pcm_unregister(
sound: Fix NULL dereference in dsp_clone() and mixer_clone()
If we only have a single soundcard attached and we detach it right before entering [dsp|mixer]_clone(), there is a chance pcm_unregister() will have returned already, meaning it will have set snd_unit to -1, and thus devclass_get_softc() will return NULL here.
While here, 1) move the calls to dsp_destroy_dev() and mixer_uninit() below the point where we unset SD_F_REGISTERED, and 2) follow what mixer_clone() does and make sure we don't use a NULL d->dsp_dev in dsp_clone().
Reported by: KASAN Sponsored by: The FreeBSD Foundation MFC after: 1 day Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D44924
show more ...
|
#
8b97dce6 |
| 18-Apr-2024 |
Christos Margiolis <christos@FreeBSD.org> |
sound: Remove PCMMINOR()
It's a NO-OP.
Sponsored by: The FreeBSD Foundation MFC after: 1 week Reviewed by: markj, emaste Differential Revision: https://reviews.freebsd.org/D44854
|
#
41ab202f |
| 18-Apr-2024 |
Christos Margiolis <christos@FreeBSD.org> |
sound: Call device_get_name() and device_get_unit() only once in mixer_init()
No functional change intended.
Sponsored by: The FreeBSD Foundation MFC after: 1 week Reviewed by: markj, emaste Differ
sound: Call device_get_name() and device_get_unit() only once in mixer_init()
No functional change intended.
Sponsored by: The FreeBSD Foundation MFC after: 1 week Reviewed by: markj, emaste Differential Revision: https://reviews.freebsd.org/D44840
show more ...
|
#
44e128fe |
| 11-Apr-2024 |
Christos Margiolis <christos@FreeBSD.org> |
sound: Implement asynchronous device detach
Hot-unplugging a sound device, such as a USB sound card, whilst being consumed by an application, results in an infinite loop until either the application
sound: Implement asynchronous device detach
Hot-unplugging a sound device, such as a USB sound card, whilst being consumed by an application, results in an infinite loop until either the application closes the device's file descriptor, or the channel automatically times out after hw.snd.timeout seconds. In the case of a detach however, the timeout approach is still not ideal, since we want all resources to be released immediatelly, without waiting for N seconds until we can use the bus again.
The timeout mechanism works by calling chn_sleep() in chn_read() and chn_write() (see pcm/channel.c) in order to send the thread to sleep, using cv_timedwait_sig(). Since chn_sleep() sets the CHN_F_SLEEPING flag while waiting for cv_timedwait_sig() to return, we can test this flag in pcm_unregister() (called during detach) and wakeup the sleeping thread(s) to immediately kill the channel(s) being consumed.
Sponsored by: The FreeBSD Foundation MFC after: 2 months PR: 194727 Reviewed by: dev_submerge.ch, bapt, markj Differential Revision: https://reviews.freebsd.org/D43545
show more ...
|
#
365067e9 |
| 05-Apr-2024 |
Christos Margiolis <christos@FreeBSD.org> |
Revert "sound: Implement asynchronous device detach"
This reverts commit 9eff58c6d52b66eb8abe7f724dabcd804a566df4.
We are reverting dc831e93bad6 ("sound: Get rid of snd_clone and use DEVFS_CDEVPRIV
Revert "sound: Implement asynchronous device detach"
This reverts commit 9eff58c6d52b66eb8abe7f724dabcd804a566df4.
We are reverting dc831e93bad6 ("sound: Get rid of snd_clone and use DEVFS_CDEVPRIV(9)"), so revert this commit as well since it depends dc831e93bad6.
show more ...
|
#
9eff58c6 |
| 31-Mar-2024 |
Christos Margiolis <christos@FreeBSD.org> |
sound: Implement asynchronous device detach
Hot-unplugging a sound device, such as a USB sound card, whilst being consumed by an application, results in an infinite loop until either the application
sound: Implement asynchronous device detach
Hot-unplugging a sound device, such as a USB sound card, whilst being consumed by an application, results in an infinite loop until either the application closes the device's file descriptor, or the channel automatically times out after hw.snd.timeout seconds. In the case of a detach however, the timeout approach is still not ideal, since we want all resources to be released immediatelly, without waiting for N seconds until we can use the bus again.
The timeout mechanism works by calling chn_sleep() in chn_read() and chn_write() (see pcm/channel.c) in order to send the thread to sleep, using cv_timedwait_sig(). Since chn_sleep() sets the CHN_F_SLEEPING flag while waiting for cv_timedwait_sig() to return, we can test this flag in pcm_unregister() (called during detach) and wakeup the sleeping thread(s) to immediately kill the channel(s) being consumed.
Sponsored by: The FreeBSD Foundation MFC after: 2 months PR: 194727, 278055, 202275, 220949, 272286 Reviewed by: dev_submerge.ch, markj Differential Revision: https://reviews.freebsd.org/D43545
show more ...
|
Revision tags: release/13.3.0, release/14.0.0 |
|
#
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
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
show more ...
|
Revision tags: release/13.2.0, release/12.4.0, release/13.1.0 |
|
#
da03ac41 |
| 21-Mar-2022 |
Ed Maste <emaste@FreeBSD.org> |
sound: test PCM_REGISTERED before PCM_DETACHING
PCM_REGISTERED(d) tests that d is not NULL, so perform that check first as we may have cases where devclass_get_softc has a null entry.
PR: 262671 R
sound: test PCM_REGISTERED before PCM_DETACHING
PCM_REGISTERED(d) tests that d is not NULL, so perform that check first as we may have cases where devclass_get_softc has a null entry.
PR: 262671 Reviewed by: hselasky MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D34648
show more ...
|
Revision tags: release/12.3.0 |
|
#
0f8dafb4 |
| 20-Jul-2021 |
Hans Petter Selasky <hselasky@FreeBSD.org> |
Implement the SOUND_MIXER_WRITE_MUTE and SOUND_MIXER_READ_MUTE ioctl(9)s.
These two ioctls are not part of the current version of OSS and were considered obsolete. However, their behaviour is not th
Implement the SOUND_MIXER_WRITE_MUTE and SOUND_MIXER_READ_MUTE ioctl(9)s.
These two ioctls are not part of the current version of OSS and were considered obsolete. However, their behaviour is not the same as their old one, so this implementation is specific to FreeBSD.
Older OSS versions had the MUTE ioctls take and return an integer with a value of 0 or 1, which meant that the _whole_ mixer is unmuted or muted respectively. In my implementation, the ioctl takes and returns a bitmask that tells us which devices are muted.
This allows us to mute and unmute only the devices we want, instead of the whole mixer. The bitmask works the same way as in DEVMASK, RECMASK and RECSRC.
Integrated the hardware volume feature with the new mute system.
Submitted by: Christos Margiolis <christos@freebsd.org> Differential Revision: https://reviews.freebsd.org/D31130 MFC after: 1 week Sponsored by: NVIDIA Networking
show more ...
|
Revision tags: release/13.0.0, release/12.2.0 |
|
#
378503af |
| 01-Sep-2020 |
Mateusz Guzik <mjg@FreeBSD.org> |
sound: clean up empty lines in .c and .h files
|
Revision tags: release/11.4.0 |
|
#
93e39e23 |
| 30-Mar-2020 |
Hans Petter Selasky <hselasky@FreeBSD.org> |
Implement new mixer API to return the device pointer based on the mixer pointer.
MFC after: 1 week Sponsored by: Mellanox Technologies
|
#
9211468f |
| 27-Mar-2020 |
Hans Petter Selasky <hselasky@FreeBSD.org> |
Change default microphone level from 0 to 25.
Discussed with: Horse Ma <Shichun.Ma@dell.com> MFC after: 1 week Sponsored by: Mellanox Technologies
|
#
e43d33d2 |
| 05-Mar-2020 |
Dimitry Andric <dim@FreeBSD.org> |
Merge ^/head r358466 through r358677.
|
#
cc1efc23 |
| 04-Mar-2020 |
Hans Petter Selasky <hselasky@FreeBSD.org> |
Implement a detaching flag for the sound(4) subsystem to take appropriate actions when we are trying to detach an audio device, but cannot because someone is using it.
This avoids applications havin
Implement a detaching flag for the sound(4) subsystem to take appropriate actions when we are trying to detach an audio device, but cannot because someone is using it.
This avoids applications having to wait for the DSP read data timeout before they receive any error indication. Tested with virtual_oss(8).
Remove some unused definitions while at it.
PR: 194727 MFC after: 1 week Sponsored by: Mellanox Technologies
show more ...
|