Commit graph

1671 commits

Author SHA1 Message Date
Ed Maste a10c85e0f9 hda: whitespace fix for realtek pin patches 2022-03-23 20:54:51 -04:00
Ed Maste da03ac41c9 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
2022-03-23 20:10:00 -04:00
Ed Maste 0a4b561f8a Remove unused snd_ds1 file ds1-fw.h
Fixes:		92e6b4712b ("Retire broken snd_ds1 and ...")
Reported by:	joel
2022-03-21 14:21:03 -04:00
Ed Maste e39ec8933b Add deprecation notices to ISA sound cards
ISA sound cards (and ISA itself) are long obsolete.  NYCBUG dmesgd has
no entries for any of these devices after 2005.

Add deprecation notices to device attach routines and man pages for:

snd_ad1816  Analog Devices AD1816 SoundPort
snd_ess     Ensoniq ESS
snd_gusc    Gravis UltraSound
snd_mss     Microsoft Sound System
snd_sbc     Creative Sound Blaster

Reviewed by:	cy, mav
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34604
2022-03-19 14:57:26 -04:00
Ed Maste 92e6b4712b Retire broken snd_ds1 and snd_maestro drivers
In 2012 joel@ reported[1] that these were not functional, and they do
not appear to have been fixed since.

[1] https://lists.freebsd.org/pipermail/freebsd-multimedia/2012-January/012751.html

Reported by:	joel
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
2022-03-18 20:33:19 -04:00
Ed Maste ef5dec7cc7 Remove snd_aureal driver source
This driver was not finished when it was committed in 1999 and was never
connected to the build.

A version of the driver used to be available in ports as
audio/aureal-kmod, but it has been removed.  It did not build on FreeBSD
10.x or later and the binary objects it required were not available
after Google Code disappeared.

PR:		124343
Reported by:	joel
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2022-03-18 16:27:35 -04:00
Ed Maste 06731139ca hda: add patch for Framework laptop headphone jack
For Framework laptops built after Oct 2021 (like mine) that have a Tempo
Semiconductor 92HD95B codec rather than Realtek ALC295 (see
https://frame.work/ca/en/blog/solving-for-silicon-shortages).

As we do for many other laptops, put the headphone jack and speakers in
the same association by default so that the generic sound device
automatically switches between them.  Also specify the jack colour and
location.

Reviewed by:	markj
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34596
2022-03-17 19:22:02 -04:00
Mark Johnston 077564cfdb hdac: Handle interrupts racing with device suspend
- Avoid looping forever if a concurrent reset causes a read of the
  interrupt status register to return all ones.
- Lock the softc before reading the interrupt status, so as to avoid a
  similar infinite loop in hdac_one_intr().

This fixes suspend-to-S3 on some laptops.

PR:		261207
Reviewed by:	mav, imp
Tested by:	uqs
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34117
2022-03-17 15:39:00 -04:00
Ed Maste e997f33700 Add Tempo Semiconductor 92HD95B HDA codec ID
This codec is found in recent versions of the Framework laptop.  Tempo
Semiconductor acquired these products from IDT's Audio Business Unit.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2022-03-16 12:22:23 -04:00
Emmanuel Vadot 6582b75a32 audio_soc: Plug set but not used variable
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2022-02-21 11:08:20 +01:00
Hans Petter Selasky f190f8d1a2 snd_uaudio(4): Set hardware buffering to the minimum by default.
Improves the audio experience when using applications like
audio/jamulus and audio/hpsjam .

MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-02-20 00:11:51 +01:00
Alexander Motin 98d59d2e0d snd_hda: Add some ATI HDMI codec IDs.
Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:	1 week
2022-02-09 16:29:23 -05:00
Philippe Michaud-Boudreault 45f0e57105 sound: add patch for Lenovo Legion 5 AMD
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D30333
2022-01-23 15:04:25 -05:00
Ed Maste 301b2b02df snd_hda: restore pin patch for headphones on Lenovo X1 7th Gen
Fixes:		ef790cc740 ("hdaa: update pin patch configurations")
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33900
2022-01-14 19:23:15 -05:00
Alexander Motin 3b4c543322 sound: Remove CTLFLAG_NEEDGIANT from some sysctls.
While there, remove some dead code.

MFC after:	2 weeks
2021-12-26 20:39:32 -05:00
Gordon Bergling d34632a235 sound(4): Fix a typo in a source code comment
- s/aggresively/aggressively/

MFC after:	3 days
2021-12-22 10:18:35 +01:00
Hans Petter Selasky 2fcd7d380b snd_uaudio(4): Loosen up the USB MIDI permissions.
This makes USB MIDI more userfriendly for desktop users.

PR:		260489
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2021-12-17 11:54:19 +01:00
Warner Losh 0adb238d20 hdda: Remove extra topo_unlock
Reported by:	Taku YAMAMOTO
Sponsored by:	Netflix
2021-12-10 10:01:21 -07:00
Warner Losh 96e500a3f9 hda: Push giant / newbus topo lock down a layer
Rather than picking up Giant at the start of these sysctl handlers, push
acquiring Giant down a layer to protect walking the children and also
to add/delete children for the reconfigure.

Sponsored by:		Netflix
Reviewed by:		mav, jhb
Differential Revision:	https://reviews.freebsd.org/D33057
2021-12-09 17:04:58 -07:00
Mateusz Guzik cf8e3ea23f pcm: plug set-but-not-used vars
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-12-09 16:37:26 +00:00
Andriy Gapon 53b356f17a audio_soc: remove useless call to pcm_getbuffersize
Its result was not used and it does not have any side-effects.

MFC after:	2 weeks
2021-11-13 11:20:59 +02:00
Hans Petter Selasky 11f09b17fe snd_uaudio(4): Fix string index computations for iFeature.
This allows the iFeature strings to be properly read by the snd_uaudio(4) driver,
when parsing the audio feature unit descriptors.

Submitted by:	Zhichao1.Li@dell.com
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2021-11-09 22:11:25 +01:00
Gordon Bergling 3d6ed119e3 usb_audio: Fix a typo in a source code comment
- s/maxium/maximum/

MFC after: 3 days
2021-11-07 14:04:26 +01:00
Alexander Motin dc238358f9 Add some of Intel Alder Lake device IDs.
MFC after:	1 week
2021-11-05 23:06:59 -04:00
Hans Petter Selasky 4a83ca1078 sound(4): Implement mixer mute control for feeder channels.
PR:	258711
Differential Revision:	https://reviews.freebsd.org/D31636
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2021-09-28 11:20:09 +02:00
Gordon Bergling 513ee901ee pcm(4): Fix a common typo in source code comments
- s/prefered/preferred/

MFC after:	3 days
2021-09-26 11:21:16 +02:00
Alexander Motin 1f7a6325fe sound(4): Remove pointless Giant from bus_dma_tag_create().
None of the drivers really implement asynchronous buffer loading, so
they don't need lock there.  The only question is which of them have
BUS_DMA_NOWAIT flag there already, and to which it should be added.
2021-09-04 18:30:36 -04:00
Alexander Motin 541699f6f6 Remove impossible checks. 2021-09-04 16:10:50 -04:00
Gordon Bergling 58d868c88d sound(4): Fix some common typos in comments
- s/doens't/doesn't/
- s/apropriate/appropriate/
- s/intepretation/interpretation/

MFC after:	5 days
2021-08-26 17:15:55 +02:00
Gordon Bergling a1581cd735 Fix a common typo in source code comments
- s/aligment/alignment/

MFC after:	5 days
2021-08-14 14:17:48 +02:00
Gordon Bergling 04389c855e Fix some common typos in comments
- s/configuraiton/configuration/
- s/specifed/specified/
- s/compatiblity/compatibility/

MFC after:	5 days
2021-08-08 10:16:06 +02:00
Hans Petter Selasky ed2196e5df sound(4): Implement playback and recording mode sysctl(8).
The dev.pcm.<N>.mode sysctl(8) gives information if a sound device
supports hardware mixing, playback or recording.

Submitted by:	Christos Margiolis <christos@freebsd.org>
Differential Revision:	https://reviews.freebsd.org/D31320
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2021-08-06 11:28:44 +02:00
Hans Petter Selasky 132fca6335 sound(4): Fix typos.
Submitted by:	Christos Margiolis <christos@freebsd.org>
Differential Revision:	https://reviews.freebsd.org/D31320
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2021-08-06 11:28:43 +02:00
Gleb Smirnoff 29b4fa7876 hdaa: add missing break in hdac_pin_patch().
Fixes driver attach on my Thinkpad X1 Carbon, and likely on
many other ALC family devices.

Fixes:	ef790cc740
2021-08-03 03:09:32 -07:00
Hans Petter Selasky 0f8dafb458 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
2021-07-21 11:10:30 +02:00
Xin LI 86d69de88d Fix blankspace anomalies, no actual code change. 2021-07-11 23:12:24 -07:00
Xin LI c43bf3f591 snd_hda(4): Fix sound on headset jack for ThinkPad T51.
sys/dev/sound/pci/hda/hdaa_patches.c:
 match_pin_patches: Use HDA_DEV_MATCH instead of regular ==

sys/dev/sound/pci/hda/pin_patch_realtek.h:
 Add quirk for Lenovo laptops when ALC298 is used.
2021-07-11 22:46:49 -07:00
K Staring ef790cc740 hdaa: update pin patch configurations
A number of structural changes:
  - Use decimal nid numbers instead of hex
  - updated the branch to incoorporate the suggestions made in the
    ALC280 pull request github thread
  - Convert magic pin values into strings.
  - Also update hdaa_patches to use clearer enums..
  - made pin patch type enum clearer, add macro for 'string' type
    patches
  - Added pin_patch structures to separate data from logic.
  - Integrated Realtek patches into new structure.

These incorporate fixes for ALC255, ALC256, ALC260, ALC262, ALC268,
ALC269, ALC280, ALC282, ALC283, ALC286, ALC290, ALC293, ALC296, ALC2880

And have definitions for a number of Dell and HP laptops.

Much of this data has been mined fromt he tables in the Linux driver.

imp squashed these into one commit because the changes from the github
pull requests no longer cleanly apply individually and made light style
changes after feedback from jhb.

Pull Request:		https://github.com/freebsd/freebsd-src/pull/139
Pull Request:		https://github.com/freebsd/freebsd-src/pull/140
Pull Request:		https://github.com/freebsd/freebsd-src/pull/141
Pull Request:		https://github.com/freebsd/freebsd-src/pull/142
Pull Request:		https://github.com/freebsd/freebsd-src/pull/143
Pull Request:		https://github.com/freebsd/freebsd-src/pull/144
Pull Request:		https://github.com/freebsd/freebsd-src/pull/145
Pull Request:		https://github.com/freebsd/freebsd-src/pull/146
Pull Request:		https://github.com/freebsd/freebsd-src/pull/147
Pull Request:		https://github.com/freebsd/freebsd-src/pull/148
Pull Request:		https://github.com/freebsd/freebsd-src/pull/149
Pull Request:		https://github.com/freebsd/freebsd-src/pull/150
Differential Revision:	https://reviews.freebsd.org/D30619
2021-07-03 00:15:49 -06:00
Warner Losh ddfc9c4c59 newbus: Move from bus_child_{pnpinfo,location}_src to bus_child_{pnpinfo,location} with sbuf
Now that the upper layers all go through a layer to tie into these
information functions that translates an sbuf into char * and len. The
current interface suffers issues of what to do in cases of truncation,
etc. Instead, migrate all these functions to using struct sbuf and these
issues go away. The caller is also in charge of any memory allocation
and/or expansion that's needed during this process.

Create a bus_generic_child_{pnpinfo,location} and make it default. It
just returns success. This is for those busses that have no information
for these items. Migrate the now-empty routines to using this as
appropriate.

Document these new interfaces with man pages, and oversight from before.

Reviewed by:		jhb, bcr
Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D29937
2021-06-22 20:52:06 -06:00
Oleksandr Tymoshenko 2cfe870acd arm64: Add Soc audio framework
This framework is initial implementation of the simple-audio-card compatible
audio driver framework. It provides glue for CPU/codec/aux device.

Differential Revision:	https://reviews.freebsd.org/D27830
2021-06-11 21:06:04 +02:00
Ruslan Bukin f81b451dcc hdspe: Support for mono sound.
This is useful when you have a single monitor speaker.
2021-05-27 21:40:21 +01:00
Philippe Michaud-Boudreault 5d698386fb hda: correct comment about Asus laptop digital mics
Reported in review D30333

MFC after:	1 week
2021-05-20 14:58:00 -04:00
Tai-hwa Liang 2acbe67787 sound(4): fixing panic for INVARIANTS kernel
3e7bae0821 turns the BUS_READ_IVAR() failure from a warning into a
KASSERT.  For certain PCI audio devices such like snd_csa(4) and
snd_emu10kx(4), the ac97_create() keeps the device handler generated
by device_add_child(pci_dev, "pcm"), which is not really a PCI device
handler.  This in turn causes the subsequent pci_get_subdevice()
inside ac97_initmixer() triggering a panic.

This patch tries to put a bandaid for the aforementioned pcm device
children such that they can use the correct PCI handler(from parent)
to avoid a KASSERT panic in the INVARIANTS kernel.

Tested with:	snd_csa(4), snd_ich(4), snd_emu10kx(4)
Reviewed by:	imp
MFC after:	1 month
2021-04-24 03:27:43 +00:00
Ka Ho Ng 4ce1ba6523 sndstat: nvlist schema and API definition changes
- SNDSTAT_LABEL_* are renamed to SNDST_DSPS_*, and SNDSTAT_LABEL_DSPS
  becomes SNDST_DSPS.
- Centralize channel number/rate/formats into a single nvlist
  The above nvlist is named "info_play" and "info_rec"
- Expose only encoding format in pfmts/rfmts. Userland has no direct
  access to AFMT_ENCODING/CHANNEL/EXTCHANNEL macros, thus it serves no
  meaning to expose too much information through this pair of labels.
  However pminrate/rminrate, pmaxrate/rmaxrate, pfmts/rfmts are
  deprecated and will be removed in future.

This commit keeps ioctls ABI compatibility with __FreeBSD_version
1400006 for now. In future the compat ABI with 1400006 will be removed
once audio/virtual_oss is rebuilt.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	hselasky
Approved by:	philip (mentor)
Differential Revision:	https://reviews.freebsd.org/D29770
2021-04-21 16:19:15 +08:00
Mark Johnston 3428b6c050 Fix several dev_clone callbacks to avoid out-of-bounds reads
Use strncmp() instead of bcmp(), so that we don't have to find the
minimum of the string lengths before comparing.

Reviewed by:	kib
Reported by:	KASAN
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D29463
2021-03-28 11:08:36 -04:00
Hans Petter Selasky 31070b5bc7 Set default alternate setting when USB audio devices are not in use,
to activate power save features.

Suggested by:	Shichun_Ma@Dell.com
MFC after:	1 week
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2021-03-25 16:49:52 +01:00
Ka Ho Ng c96151d335 Implement sndstat nvlist-based enumeration ioctls.
These ioctl commands aim to provide easier ways for user space
applications to enumerate existing audio devices and the node they can
potentially use.

The exchange of device lists between user space and kernel is done on
nv(9). Some ioctl commands are added to /dev/sndstat node:
  - SNDSTAT_REFRESH_DEVS
  - SNDSTAT_GET_DEVS
  - SNDSTAT_ADD_USER_DEVS
  - SNDSTAT_FLUSH_USER_DEVS

Bump __FreeBSD_version to reflect the addition of the ioctls.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	hselasky
Approved by:	philip (mentor)
Differential Revision:	https://reviews.freebsd.org/D26884
2021-03-17 19:05:43 +08:00
Hans Petter Selasky 12148d4300 Fix for locking order reversal in USB audio driver, when using mmap().
Locking the second lock which causes the LOR, can be skipped because
the code updating the shared variables is always executing from the
same USB thread.

lock order reversal:
  1st 0xfffff80005cc3840 pcm7:play:dsp7.p0 (pcm play channel, sleep mutex)
@ usb_transfer.c:2342
  2nd 0xfffff80005cc3860 pcm7:record:dsp7.r0 (pcm record channel, sleep mutex)
@ uaudio.c:2317

lock order pcm record channel -> pcm play channel established at:
witness_checkorder+0x461
__mtx_lock_flags+0x98
dsp_mmap_single+0x151
vm_mmap_cdev+0x65
devfs_mmap_f+0x143
kern_mmap_req+0x594
sys_mmap+0x46
amd64_syscall+0x12e
fast_syscall_common+0xf8

lock order pcm play channel -> pcm record channel attempted at:
witness_checkorder+0xd82
__mtx_lock_flags+0x98
uaudio_chan_play_callback+0xeb
usbd_callback_wrapper+0x7ec
usb_command_wrapper+0x7e
usb_callback_proc+0x8e
usb_process+0xf3
fork_exit+0x80
fork_trampoline+0xe

Found by:	Stefan Ehmann <shoesoft@gmx.net>
MFC after:	1 week
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2021-02-14 20:32:33 +01:00
Alexander Motin 510cc42126 Unify Intel CODEC naming.
Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:	1 week
2021-01-15 09:56:15 -05:00
Vladimir Kondratyev eead9017d2 hid: Chase for HID function name changes in existing USB HID drivers
Also hide shim code added in a previous commit under COMPAT_USBHID12.

Note: it is enough to add -DCOMPAT_USBHID12 to CFLAGS to compile old
code with new HID subsystem, but it is not enough to link it at runtime.
HID dependency has to be added explicitly with MODULE_DEPEND macro.

Reviewed by:	manu, hselasky (as part of D27887)
2021-01-08 02:18:42 +03:00