History log of /freebsd/sys/dev/sound/pcm/dsp.c (Results 1 – 25 of 324)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 9a6cf275 25-Oct-2024 Christos Margiolis <christos@FreeBSD.org>

sound: Retire channel refcount

No longer used.

Sponsored by: The FreeBSD Foundation
MFC after: 2 days
Reviewed by: dev_submerge.ch
Differential Revision: https://reviews.freebsd.org/D47269


# 802c78f5 24-Oct-2024 Christos Margiolis <christos@FreeBSD.org>

sound: Untangle dsp_cdevs[] and dsp_unit2name() confusion

Before de8c0d15a64fa ("sound: Get rid of snd_clone and use
DEVFS_CDEVPRIV(9)"), sound(4) would create one device for each allocated
channel.

sound: Untangle dsp_cdevs[] and dsp_unit2name() confusion

Before de8c0d15a64fa ("sound: Get rid of snd_clone and use
DEVFS_CDEVPRIV(9)"), sound(4) would create one device for each allocated
channel. The device names would be chosen from dsp_cdevs[], and created
with dsp_unit2name(). Additionally, dsp_cdevs[] was also used to match
these devices names, as well as OSSv4 aliases in dsp_clone().

Since sound(4) does not create separate devices for each channel
anymore, the meaning and use dsp_cdevs[] has changed. Part of it no
longer corresponds to devices at all, but instead is used to create
channel names, and another part is used to match only OSSv4 aliases in
dsp_clone().

To address this confusion, separate dsp_cdevs[] into a dsp_aliases[]
array, and move dsp_unit2name() to pcm/channel.c and rename it to
chn_mkname().

While here, get rid of the SND_DEV_DSPHW_* channel types, and simply use
the existing PCMDIR_* constants as the channel types. There is no need
to duplicate the same meaning twice.

Sponsored by: The FreeBSD Foundation
MFC after: 2 days
Reviewed by: dev_submerge.ch
Differential Revision: https://reviews.freebsd.org/D47199

show more ...


# bb5e3ac1 24-Oct-2024 Christos Margiolis <christos@FreeBSD.org>

sound: Use DSP_REGISTERED in dsp_clone()

DSP_REGISTERED calls PCM_REGISTERED, and already contains all the checks
we are doing.

No functional change intended.

Sponsored by: The FreeBSD Foundation

sound: Use DSP_REGISTERED in dsp_clone()

DSP_REGISTERED calls PCM_REGISTERED, and already contains all the checks
we are doing.

No functional change intended.

Sponsored by: The FreeBSD Foundation
MFC after: 2 days
Reviewed by: dev_submerge.ch, markj
Differential Revision: https://reviews.freebsd.org/D47196

show more ...


# 96932411 24-Oct-2024 Christos Margiolis <christos@FreeBSD.org>

sound: Call DSP_REGISTERED before PCM_DETACHING

DSP_REGISTERED first checks if the softc is not null, through
PCM_REGISTERED, which in turn calls PCM_ALIVE, whereas PCM_DETACHING
accesses the softc

sound: Call DSP_REGISTERED before PCM_DETACHING

DSP_REGISTERED first checks if the softc is not null, through
PCM_REGISTERED, which in turn calls PCM_ALIVE, whereas PCM_DETACHING
accesses the softc flags directly.

Sponsored by: The FreeBSD Foundation
MFC after: 2 days
Reviewed by: dev_submerge.ch, markj, emaste
Differential Revision: https://reviews.freebsd.org/D47195

show more ...


# 3cc01caa 18-Oct-2024 Christos Margiolis <christos@FreeBSD.org>

sound: Do not cast return value of malloc(9)

No functional change intended.

Sponsored by: The FreeBSD Foundation
MFC after: 2 days
Reviewed by: dev_submerge.ch, zlei, markj, emaste
Differential Rev

sound: Do not cast return value of malloc(9)

No functional change intended.

Sponsored by: The FreeBSD Foundation
MFC after: 2 days
Reviewed by: dev_submerge.ch, zlei, markj, emaste
Differential Revision: https://reviews.freebsd.org/D46844

show more ...


# c30f531d 18-Oct-2024 Christos Margiolis <christos@FreeBSD.org>

sound: Shorten channel names

The current channel naming convention is:
pcmX:[virtual_]play|record:dspX.[v]p|rY

- pcmX and dspX share the same unit numbers
- "[v]p|r" gives us the same information a

sound: Shorten channel names

The current channel naming convention is:
pcmX:[virtual_]play|record:dspX.[v]p|rY

- pcmX and dspX share the same unit numbers
- "[v]p|r" gives us the same information as "[virtual_]play|record"

Remove the redundant information, so that the channel names become more
readable: dspX.[virtual_]play|record.Y

Sponsored by: The FreeBSD Foundation
MFC after: 2 days
Reviewed by: dev_submerge.ch
Differential Revision: https://reviews.freebsd.org/D46836

show more ...


Revision tags: release/13.4.0
# 1a768ea9 06-Jul-2024 Christos Margiolis <christos@FreeBSD.org>

sound: Add min_rate and min_channels safety check in SNDCTL_AUDIOINFO

If the channel list is empty, min_rate and min_channels will be INT_MAX.
Instead, assign them to 0, like we do in sndstat_get_ca

sound: Add min_rate and min_channels safety check in SNDCTL_AUDIOINFO

If the channel list is empty, min_rate and min_channels will be INT_MAX.
Instead, assign them to 0, like we do in sndstat_get_caps().

Sponsored by: The FreeBSD Foundation
MFC after: 2 days
Reviewed by: dev_submerge.ch
Differential Revision: https://reviews.freebsd.org/D45876

show more ...


# 86585210 06-Jul-2024 Christos Margiolis <christos@FreeBSD.org>

sound: Fix min/max rate for SNDCTL_AUDIOINFO and SNDCTL_ENGINEINFO

Since we allow feeding of any rate within the [feeder_rate_min,
feeder_rate_max] range, report this as the min/max rate as well. On

sound: Fix min/max rate for SNDCTL_AUDIOINFO and SNDCTL_ENGINEINFO

Since we allow feeding of any rate within the [feeder_rate_min,
feeder_rate_max] range, report this as the min/max rate as well. Only
exceptions are when we the device is opened in exclusive or bitperfect
mode.

Sponsored by: The FreeBSD Foundation
MFC after: 2 days
Reviewed by: dev_submerge.ch
Differential Revision: https://reviews.freebsd.org/D45862

show more ...


# adc1713f 06-Jul-2024 Christos Margiolis <christos@FreeBSD.org>

sound: Make DSP_FIXUP_ERROR() regular code

No reason to have this as a macro.

While here, change the second case to an "else if" as there is no reason
to check it if the open flags are invalid.

Sp

sound: Make DSP_FIXUP_ERROR() regular code

No reason to have this as a macro.

While here, change the second case to an "else if" as there is no reason
to check it if the open flags are invalid.

Sponsored by: The FreeBSD Foundation
MFC after: 2 days
Reviewed by: dev_submerge.ch, markj, emaste
Differential Revision: https://reviews.freebsd.org/D45776

show more ...


# be04a9d9 06-Jul-2024 Christos Margiolis <christos@FreeBSD.org>

sound: Improve simplex handling in dsp_open()

If we are in simplex mode, make sure we do not open in both directions
(read/write) and also that we do not open in a direction opposite of
what is alre

sound: Improve simplex handling in dsp_open()

If we are in simplex mode, make sure we do not open in both directions
(read/write) and also that we do not open in a direction opposite of
what is already opened. For example, if the device is already doing
playback, we cannot open the device for recording at the same time, and
vice-versa.

While here, remove dsp_cdevpriv->simplex as it's no longer needed.

Sponsored by: The FreeBSD Foundation
MFC after: 2 days
Reviewed by: dev_submerge.ch
Differential Revision: https://reviews.freebsd.org/D45835

show more ...


# 46e92a41 06-Jul-2024 Christos Margiolis <christos@FreeBSD.org>

sound: Simplify getchns()

Remove all special handling for SIMPLEX, since we can just fetch the
channel directly.

While here:
- Get rid of a no-op getchns() call in dsp_ioctl().
- Rename getchns() t

sound: Simplify getchns()

Remove all special handling for SIMPLEX, since we can just fetch the
channel directly.

While here:
- Get rid of a no-op getchns() call in dsp_ioctl().
- Rename getchns() to dsp_lock_chans(), and relchns() to
dsp_unlock_chans().
- Simplify DSP_FIXUP_ERROR(), as we do not longer assign SD_F_PRIO*
flags to the softc.

Sponsored by: The FreeBSD Foundation
MFC after: 2 days
Reviewed by: dev_submerge.ch
Differential Revision: https://reviews.freebsd.org/D45775

show more ...


# f30af1f0 06-Jul-2024 Christos Margiolis <christos@FreeBSD.org>

sound: SNDCTL_AUDIOINFO: Do not skip physical channels if VCHANs are disabled

Currently, we are skipping physical channels when servicing
SNDCTL_AUDIOINFO, and VCHANs when servicing SNDCTL_AUDIOINFO

sound: SNDCTL_AUDIOINFO: Do not skip physical channels if VCHANs are disabled

Currently, we are skipping physical channels when servicing
SNDCTL_AUDIOINFO, and VCHANs when servicing SNDCTL_AUDIOINFO_EX.
However, if we call SNDCTL_AUDIOINFO with VCHANs disabled, we'll
eventually skip all channels, resulting in some of oss_audioinfo's
fields containing wrong information (e.g min/max_channels).

Fix this by adding an exception to SNDCTL_AUDIOINFO not to skip physical
channels when VCHANs are disabled.

Sponsored by: The FreeBSD Foundation
MFC after: 2 days
Reviewed by: dev_submerge.ch, emaste
Differential Revision: https://reviews.freebsd.org/D45722

show more ...


# 914c2b33 18-Jun-2024 Christos Margiolis <christos@FreeBSD.org>

sound: Remove outdated comment in dsp_oss_engineinfo()

Since we e07f9178502b ("sound: Separate implementations for
SNDCTL_AUDIOINFO[_EX] and SNDCTL_ENGINEINFO") support more than
mono/stereo.

Spons

sound: Remove outdated comment in dsp_oss_engineinfo()

Since we e07f9178502b ("sound: Separate implementations for
SNDCTL_AUDIOINFO[_EX] and SNDCTL_ENGINEINFO") support more than
mono/stereo.

Sponsored by: The FreeBSD Foundation
MFC after: 1 day
Reviewed by: dev_submerge.ch, markj, emaste
Differential Revision: https://reviews.freebsd.org/D45605

show more ...


# 0f878cdf 18-Jun-2024 Christos Margiolis <christos@FreeBSD.org>

sound: Fix oss_audioinfo's card_number, port_number and legacy_device

Although the docs advise against using them, it doesn't hurt to fill
them out correctly.

Sponsored by: The FreeBSD Foundation
M

sound: Fix oss_audioinfo's card_number, port_number and legacy_device

Although the docs advise against using them, it doesn't hurt to fill
them out correctly.

Sponsored by: The FreeBSD Foundation
MFC after: 1 day
Reviewed by: dev_submerge.ch, markj
Differential Revision: https://reviews.freebsd.org/D45604

show more ...


# 8e36d212 18-Jun-2024 Christos Margiolis <christos@FreeBSD.org>

sound: Support oss_audioinfo->cmd

Sponsored by: The FreeBSD Foundation
MFC after: 1 day
Reviewed by: dev_submerge.ch, markj
Differential Revision: https://reviews.freebsd.org/D45603


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 ...


# 24d5cc14 09-May-2024 Christos Margiolis <christos@FreeBSD.org>

sound: Rename oss_audioinfo->real_device to oss_audioinfo->legacy_device

The OSS manual now documents this field as "legacy_device".

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed

sound: Rename oss_audioinfo->real_device to oss_audioinfo->legacy_device

The OSS manual now documents this field as "legacy_device".

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: dev_submerge.ch
Differential Revision: https://reviews.freebsd.org/D45138

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 ...


# 72cbd381 06-May-2024 Christos Margiolis <christos@FreeBSD.org>

sound: Remove unused dsp_cdevs[] fields and devices

These fields and devices are unused as of e8c0d15a64fa ("sound: Get rid
of snd_clone and use DEVFS_CDEVPRIV(9)").

While here, remove unused SND_D

sound: Remove unused dsp_cdevs[] fields and devices

These fields and devices are unused as of e8c0d15a64fa ("sound: Get rid
of snd_clone and use DEVFS_CDEVPRIV(9)").

While here, remove unused SND_DEV_* defines from pcm/sound.h and convert
the list to an enum.

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

show more ...


# a24050e2 28-Apr-2024 Christos Margiolis <christos@FreeBSD.org>

sound: Move pcm_chnref() and pcm_chnrelease() to pcm/channel.c

Improve code layering. These are channel functions, and so they do not
belong in pcm/sound.c.

While here, assert in chn_ref() that new

sound: Move pcm_chnref() and pcm_chnrelease() to pcm/channel.c

Improve code layering. These are channel functions, and so they do not
belong in pcm/sound.c.

While here, assert in chn_ref() that new refcount won't be negative.

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

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 ...


# a44c45c7 18-Apr-2024 Christos Margiolis <christos@FreeBSD.org>

sound: Simplify unit fetching in dsp_oss_audioinfo()

"i" keeps the value of the current unit, so we do not have to call
PCMUNIT() and device_get_unit() to fetch it.

In the mixer case, I think it is

sound: Simplify unit fetching in dsp_oss_audioinfo()

"i" keeps the value of the current unit, so we do not have to call
PCMUNIT() and device_get_unit() to fetch it.

In the mixer case, I think it is more correct to do it like this, since
mixer and DSP device units have a 1-1 relationship (i.e the mixer unit
is always the same as the corresponding DSP device one) and that way we
can make it more clear.

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

show more ...


12345678910>>...13