Commit graph

1834 commits

Author SHA1 Message Date
Zhenlei Huang
bfcaaff418 sound: Stop checking for failures from malloc(M_WAITOK)
Reviewed by:	emaste
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D45852

(cherry picked from commit 59121599bbda1e4c3fc3c6e887cd48cd5e3afc70)
2024-09-30 12:44:26 +08:00
Pavel Timofeev
5754008f85 hda: remove duplicate codec defines
Reviewed by:	emaste
Fixes: 35e492f3bd ("Update list of Conexant and Realtek codecs.")
Differential Revision: https://reviews.freebsd.org/D45965

(cherry picked from commit 4004e1752ec7992eeace7f0318d2ca3fc7ba9e03)
2024-09-25 09:17:26 -04:00
Dmitry Luhtionov
d01a9cceef Add some AMD device IDs.
(cherry picked from commit 4cc4b5e2b5f85f136169069559108ed7fff351f9)
2024-09-25 09:17:26 -04:00
Christos Margiolis
8156d8598f sound: Improve sndstat nvlist feederchain format
- Use snd_afmt2str() to display format conversions in feeder_format,
  instead of the plain hex value.
- Simplify feeder_rate contents.
- Print "ch" (e.g 2.1ch) after matrix values in feeder_matrix.
- Use snd_afmt2str() instead of a plain hex for the the rest of the
  feeder classes.

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

(cherry picked from commit 0864dfe6299b75e424b845c0d0e1a593da905ae3)
2024-08-26 16:53:01 +03:00
Christos Margiolis
f2372d936d sound: Fix VCHANs' starting and ending points in feeder chain
sndstat(4) falsely reports "hardware" as the starting point of
recording, and ending point of playback VCHANs. Recording VCHANs get
their input from the primary recording channel, and playback VCHANs send
their input to the primary playback channel.

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

(cherry picked from commit b58d9db4d77a6f42ac7cf3cdb2af2443666033e2)
2024-08-04 15:09:35 +03:00
Adam Retter
dbb6f488df hda: add support for Tiger Lake-H
PR:		272682
Reported by:	Miguel Salcedo
Reviewed by:	emaste

(cherry picked from commit fb1028dcd4aedc4d48dbd97314f008c663b2e711)
2024-08-01 13:34:50 -04:00
Christos Margiolis
a9e27006db sound: Simplify feeder_remove()
Sponsored by:	The FreeBSD Foundation
MFC after:	2 days
Reviewed by:	dev_submerge.ch, markj, emaste
Differential Revision:	https://reviews.freebsd.org/D46100

(cherry picked from commit 00172d20070a544e0514cce9f94475c5525fd15e)
2024-07-29 18:34:55 +03:00
Christos Margiolis
9b5e6dfe18 sound: Remove unused defines from pcm/sound.h
Sponsored by:	The FreeBSD Foundation
MFC after:	2 days
Reviewed by:	dev_submerge.ch, markj, emaste
Differential Revision:	https://reviews.freebsd.org/D45986

(cherry picked from commit f477d412530a8cb9d8e058d00189ce127584f6f6)
2024-07-29 18:34:55 +03:00
Christos Margiolis
a619d8c76c sound: Simplify chn_init()
- Remove unnecessary CHN_[UN]LOCKs.
- Improve device_printf() messages.
- Remove redundant checks.
- Remove 0 assignments, since the channel is allocated with M_ZERO.
- Re-organize sections in a more coherent way.
- Remove "out1" label, just return NULL directly.
- Rename "out2" to "fail" and simplify logic.
- Do not check the return value of dsp_unit2name(), as it is guaranteed
  not to fail (we pass a valid channel type).

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

(cherry picked from commit 5b209e153b58515c0315f5902e18ecd7d75ecd2a)
2024-07-29 18:34:55 +03:00
Christos Margiolis
cbbc1f5db1 sound: Remove unused FEEDER_DEBUG
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/D45984

(cherry picked from commit c55f995502cbaa2d38b7a7003bc27805b28a6a29)
2024-07-29 18:34:55 +03:00
Christos Margiolis
8f685b1f1f 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

(cherry picked from commit 29ff7b08be363f0d4345794bb951d5c0c8406a0a)
2024-07-29 18:34:55 +03:00
Christos Margiolis
6716cc7e27 sound: Fix memory leak in chn_init()
In case chn_init() fails, we are leaking memory by not freeing the
feeder.

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

(cherry picked from commit 16329b7b3276f09dc70bdd1ca8bc605546fe71e0)
2024-07-29 18:34:54 +03:00
Christos Margiolis
1ff260a6e1 sound: Implement dummy driver
Sponsored by:	The FreeBSD Foundation
MFC after:	2 days
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D45967

(cherry picked from commit c15c9315b2cb7601cc337f7d5a8e124f4b2d5861)
2024-07-29 18:34:54 +03:00
Christos Margiolis
188d619e45 sound: Add OSS channel capabilities to sndstat nvlist
Assignment taken from dsp_oss_engineinfo().

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

(cherry picked from commit bd5bcc848c5764229926ad27a4bd77af4f87d189)
2024-07-29 18:34:54 +03:00
Christos Margiolis
08c1cf0b52 sound: Add *vchanrate and *vchanformat to sndstat nvlist
Sponsored by:	The FreeBSD Foundation
MFC after:	2 days
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D46164

(cherry picked from commit a6283717577066b0ff6c62053145470ff4134051)
2024-07-29 18:34:54 +03:00
Christos Margiolis
894edb7cb1 sound: Add device status string to sndstat nvlist
Sponsored by:	The FreeBSD Foundation
MFC after:	2 days
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D46163

(cherry picked from commit 810530aa2648812860e84d951d9cf96dfd24e595)
2024-07-29 18:34:53 +03:00
Florian Walpen
12f6e0a4d2 snd_hdspe(4): Recognize newer firmware's PCI vendor id.
At least for HDSPe RayDAT cards, newer firmware comes with RME's own PCI
vendor id instead of the Xilinx one. Other HDSPe cards are probably also
affected. Update snd_hdspe(4) to recognize both the old Xilinx and the
new RME vendor ids.

Differential Revision:	https://reviews.freebsd.org/D44978
MFC after: 1 day

(cherry picked from commit 9718d4ab99386918f5b5c207c58289eaade20623)
2024-07-28 21:23:07 +01:00
Robert Wing
d6b6165ebb sound: drop midistat lock in error path
Fixes:          fc76e24e583d45a3a59fd7ad4e603c0679eaf572
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D45939

(cherry picked from commit 3114d55866b86ca1132923211936aa23881b0057)
2024-07-10 18:48:14 +02:00
Christos Margiolis
fab137d234 sound: Add missing CHN_[UN]LOCKs in sndstat
In sndstat_build_sound4_nvlist(), if we have INVARIANTS or
SND_DIAGNOSTIC enabled, we will hit a lock assertion panic when we call
CHN_GETVOLUME(). Also lock the channel in the sndstat_prepare_pcm() loop
for good measure.

Fixes:		bbca3a75bb41 ("sound: Include sound(4) channel information in sndstat nvlist")
Sponsored by:	The FreeBSD Foundation
MFC after:	2 days
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D45898

(cherry picked from commit e850bd36dfda98608432d2459800627d16119fec)
2024-07-10 18:48:13 +02:00
Christos Margiolis
efaa4bcc92 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

(cherry picked from commit 1a768ea9db3d66941b0dc5340ac028ef548808b8)
2024-07-10 18:48:13 +02:00
Christos Margiolis
ecb0a2ed2f sound: Refactor sndstat_get_caps()
The current implementation of sndstat_get_caps() does not work properly
when VCHANs are enabled, as it skips all information about physical
channels, and also assigns the min/max rates and channels to same
values, which is usually not the case. A device either supports any
sample rate within the [feeder_rate_min, feeder_rate_max] range, or
[hw_rate_min, hw_rate_max] range when the device is opened in exclusive
or bitperfect mode. The number of channels can also vary and is not
always the same for both min and max.

Refactor the whole function to resemble the way we handle fetching of
these values in dsp_oss_audioinfo() and dsp_oss_engineinfo().

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

(cherry picked from commit 9d8b93bc9ccea82b648ffa9354200c9e4d3f211b)
2024-07-10 18:48:13 +02:00
Christos Margiolis
95d3abff73 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

(cherry picked from commit 86585210fd5657542884b22eb52b21e960b7be6c)
2024-07-10 18:48:13 +02:00
Christos Margiolis
ff6b61a2c8 sound: Handle midistat_lock through function interface
midistat_lock is used outside midi/midi.c as well, so implement lock,
unlock and lockassert functions in order not to expose the lock in the
header file.

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

(cherry picked from commit 2d6fc24673ccc97020c94094f97ee015f1db9702)
2024-07-10 18:48:13 +02:00
Christos Margiolis
d325cd4a53 sound: Remove dead code in pcm_register()
Sponsored by:	The FreeBSD Foundation
MFC after:	2 days
Differential Revision:	https://reviews.freebsd.org/D45831

(cherry picked from commit a9f08df3e9004f431e98f67afc1ac2b2f773ec14)
2024-07-10 18:48:13 +02:00
Christos Margiolis
d4b65f3f53 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

(cherry picked from commit adc1713fb13f89a6eb33f5de840c981d0e17e4b7)
2024-07-10 18:48:13 +02:00
Christos Margiolis
6378079427 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

(cherry picked from commit be04a9d9387f6b5d4e83fc4976d8d83bb03fe5af)
2024-07-10 18:48:13 +02:00
Christos Margiolis
e687f4e40d 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

(cherry picked from commit 46e92a41cb539e327dd059d571fa381d0fbe779c)
2024-07-10 18:48:12 +02:00
Christos Margiolis
ad29342154 sound: Remove *MINOR from midi/
Sponsored by:	The FreeBSD Foundation
MFC after:	2 days
Differential Revision:	https://reviews.freebsd.org/D45772

(cherry picked from commit 8b9e1b628064daba3650d04fa83cf79808877981)
2024-07-10 18:48:12 +02:00
Christos Margiolis
2baf2b2f10 sound: Remove MIDI_TYPE
No good reason to have this. It only makes things harder to read.

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

(cherry picked from commit 526bd1d87ec997e1c090262da6f2d9b6da0e8f89)
2024-07-10 18:48:12 +02:00
Christos Margiolis
cccdc51d98 snd_uaudio: Remove unused sc_sndstat sbuf
This information is also printed to dmesg(8) on attach.

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

(cherry picked from commit 3402d474ceb8541d07689bad6960f90739129997)
2024-07-10 18:48:12 +02:00
Christos Margiolis
c9d9975cd4 sound: Fix lock order reversals in mseq_open()
Opening /dev/sequencer after a clean reboot yields:

lock order reversal: (sleepable after non-sleepable)
 1st 0xfffffe004a2c2c08 seqflq (seqflq, sleep mutex) @ /mnt/src/sys/dev/sound/midi/sequencer.c:754
 2nd 0xffffffff84197ed8 midistat lock (midistat lock, sx) @ /mnt/src/sys/dev/sound/midi/midi.c:1478
lock order seqflq -> midistat lock attempted at:
0xffffffff811c9029 at witness_checkorder+0x12b9
0xffffffff810f18a7 at _sx_xlock+0xf7
0xffffffff8417f992 at midimapper_open+0x22
0xffffffff84182770 at mseq_open+0xf0
0xffffffff80e3380f at devfs_open+0x30f
0xffffffff81b8b4b7 at VOP_OPEN_APV+0x57
0xffffffff812da1e7 at vn_open_vnode+0x397
0xffffffff812d96b3 at vn_open_cred+0xb23
0xffffffff812c2c6b at openatfp+0x52b
0xffffffff812c2711 at sys_openat+0x81
0xffffffff84110579 at filemon_wrapper_openat+0x19
0xffffffff81a223ae at amd64_syscall+0x39e
0xffffffff819dd0eb at fast_syscall_common+0xf8

Expose midistat_lock to midi/midi.c so that we can acquire the lock from
mseq_open() before we lock seq_lock, and introduce _locked variants of
midimapper_open() and midimapper_fetch_synth().

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

(cherry picked from commit fc76e24e583d45a3a59fd7ad4e603c0679eaf572)
2024-07-10 18:48:12 +02:00
Christos Margiolis
de8161712e sound: Get rid of snd_sb16 workaround in vchan_create()
The snd_sb16 driver was removed in 716924cb48 ("Retire snd_sbc ISA
sound card driver").

While here, simplify sample rate assignment a bit.

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

(cherry picked from commit d6d4586b0b7e3b01812e6c26818af78bf9b680a3)
2024-07-10 18:48:12 +02:00
Christos Margiolis
6158fa24ac 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

(cherry picked from commit f30af1f037a68947edbabebc7ab495cd1b7a4ec8)
2024-07-10 18:48:12 +02:00
Christos Margiolis
935c5a5554 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

(cherry picked from commit 914c2b3314e8f6e31833e33cfdcc4843f88fe31b)
2024-06-19 12:01:34 +02:00
Christos Margiolis
6f090333db 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

(cherry picked from commit 0f878cdfc5a46cc0dc198e12758f12558dfb1bf6)
2024-06-19 12:01:33 +02:00
Christos Margiolis
f1ee9f5425 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

(cherry picked from commit 8e36d212594b542cb0c57d549e0b57fd0f7e307c)
2024-06-19 12:01:33 +02:00
Christos Margiolis
e6ecffccde sound: Include sound(4) channel information in sndstat nvlist
Extend SNDST_DSPS_PROVIDER_INFO for sound(4) to include information
about each channel in a given device, similar to how cat'ing
/dev/sndstat with hw.snd.verbose=2 works.

While here, document all provider_info fields.

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

(cherry picked from commit bbca3a75bb412f7106a569b82c616404103be084)
2024-06-14 18:57:57 +02:00
Oleksandr Kryvulia
4987c12cb8 snd_hda: Add Lenovo X1 Carbon Gen11 support
MFC after:	2 days
Reviewed by:	christos
Differential Revision:	https://reviews.freebsd.org/D45361

(cherry picked from commit ef659a2d041c01b747ae4605160c24156cae081b)
2024-06-06 17:12:15 +02:00
Brooks Davis
38286d9f68 pcm: centralize 32-bit ioctl compat
Move all handlng of struct sndstioc_nv_arg(32) to sndstat_ioctl() and
make the functions that actually do the work take a buffer and size or
size pointer.  The 32-bit compat work is minimal so just inline it.

Remove checks that we've got a 32-bit process for 32-bit ioctls.  We
don't check that default ioctls are from 64-bit processes on 64-bit
systems.

Reviewed by:	christos
Differential Revision:	https://reviews.freebsd.org/D45307

(cherry picked from commit fb9013f215211f013eccc54786f299e39a1f8773)
2024-05-26 15:51:33 +02:00
Christos Margiolis
0aa767021c sound: Fix minchn, maxchn and fmts in sndstat_get_caps()
The current implementation (incorrectly) passes the channel encoding
value to AFMT_CHANNEL(), which will always return 0, since the channel
number bits are masked out by AFMT_ENCODING().

Also add missing fmts initialization and aggregate encoding formats into
it directly.

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

(cherry picked from commit 425a7bc465d4a6393c88c2e79c5ad77befda2a97)
2024-05-25 21:31:26 +02:00
Christos Margiolis
ab7c894154 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

(cherry picked from commit 5d980fadf73df64a1e0eda40a93170ed76ce6f14)
2024-05-25 21:30:40 +02:00
Christos Margiolis
e8a80b4e50 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

(cherry picked from commit e07f9178502b7cbc0769fc10e99ad0d013f437fd)
2024-05-25 21:30:26 +02:00
Lutz Bichler
1fb0a65ab2 snd_hda: Add patch for Asus UX331UAL
PR:		242802
MFC after:	1 day
Differential Revision:	https://reviews.freebsd.org/D45238

(cherry picked from commit 93ad59a251897431627345c287390ae134925a95)
2024-05-23 02:24:15 +02:00
Christos Margiolis
45feaa73c6 sound: Correctly check nvlist_unpack() error
The current check is never false and if nvlist_unpack() fails, we might
panic later down the road.

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

(cherry picked from commit 64f4e2db6d19d8ab520903a197fcaa8cc7ab9f9a)
2024-05-21 19:45:55 +02:00
Christos Margiolis
5830a00c2c sound: Check user-supplied size passed to SNDSTIOC_ADD_USER_DEVS*
SNDSTIOC_ADD_USER_DEVS* expects a user-supplied sndstioc_nv_arg->nbytes,
however we currently do not check whether this size is actually valid,
which results in a panic when SNDSTIOC_ADD_USER_DEVS* is called with an
invalid size. sndstat_add_user_devs() calls
sndstat_unpack_user_nvlbuf(), which then calls malloc() with that size.

PR:		266142
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	brooks
Differential Revision:	https://reviews.freebsd.org/D45236

(cherry picked from commit 074d337ad618f9cc2a1d5ab18b484928e57bd72b)
2024-05-21 19:45:49 +02:00
Christos Margiolis
bca6f391ae sound: Prevent uninitialized variable destruction in chn_init()
If dsp_unit2name() fails, we'll get to out2 with b, bs and devinfo
uninitialized, which will result in a panic.

Reported by:	Pierre Pronchery <pierre@freebsdfoundation.org>
Reported by:	Coverity Scan
CID:		1545029, 1545025
Pull-request:	https://github.com/freebsd/freebsd-src/pull/1240
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D45272

(cherry picked from commit 5d1a5d6f1f599a4fbea9634cbe5c77f7370e1a5d)
2024-05-21 19:45:41 +02:00
Christos Margiolis
8a15d5e722 sound: Get rid of redundant assignments in chn_init()
c is allocated with M_ZERO.

Reported by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D45273

(cherry picked from commit 2db2292dac7331be5414f86c3ef7863c7b6a4ac6)
2024-05-21 19:45:30 +02:00
Christos Margiolis
a19d42b08a sound: Remove ncards variable from sound_oss_card_info()
The loop counter is also the card's index, so ncards is redundant.

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

(cherry picked from commit 305db91d4b92a5d53826dcb6df39fc8a1f3b427e)
2024-05-17 21:30:36 +02:00
Christos Margiolis
7814ed2bd3 snd_hda: Rename LENOVO_I* to LENOVO_IDEAPAD*
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D45105

(cherry picked from commit 278953360e0e6187c3f7c688cb49254df1567f0b)
2024-05-17 21:30:36 +02:00
Christos Margiolis
9a620018af snd_hda: Add patch for Lenovo Ideapad 3
Reported by:	bsd-lists@bsdforge.com
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D45100

(cherry picked from commit 54cc353f505dbc5f19168b6b1417b6736433d9ae)
2024-05-17 21:30:36 +02:00