Commit Graph

1622 Commits

Author SHA1 Message Date
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
Vladimir Kondratyev
67de2db262 Factor-out hardware-independent part of USB HID support to new module
It will be used by the upcoming HID-over-i2C implementation.  Should be
no-op, except hid.ko module dependency is to be added to affected drivers.

Reviewed by:	hselasky, manu
Differential revision:	https://reviews.freebsd.org/D27867
2021-01-08 02:18:42 +03:00
Konstantin Belousov
77602e977e Unlock channels when any of them are locked, when returning for non-busy state.
Reported and tested by:	"Wall, Stephen" <stephen.wall@redcom.com>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2020-11-20 14:02:43 +00:00
Hans Petter Selasky
f14436adc6 Add a tunable sysctl, hw.usb.uaudio.handle_hid, to allow disabling the
the HID volume keys support in the USB audio driver.

While at it re-organize the USB audio sysctls a bit.

Differential Revision:	https://reviews.freebsd.org/D27180
MFC after:	1 week
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2020-11-12 09:26:01 +00:00
Alexander Motin
cd3d0f8c19 Drop unsolicited responses to the still attaching CODECs.
It is reported to fix kernel panics when early unsolicited responses
delivered to the CODEC device not having driver attached yet.

PR:		250248
Reported by:	Rajeev Pillai <rajeev_v_pillai@yahoo.com>
Reviewed by:	avg
MFC after:	2 weeks
2020-10-15 17:40:02 +00:00
Mateusz Guzik
378503af2e sound: clean up empty lines in .c and .h files 2020-09-01 21:27:34 +00:00
Mark Johnston
555e998919 snd_ich(4): Handle errors from ich_init() properly during resume.
ich_init() returns an errno value or 0, but ich_pci_resume() was
comparing the return value with -1 to determine whether an error had
occurred.

PR:		248941
Submitted by:	Tong Zhang <ztong0001@gmail.com>
MFC after:	1 week
2020-08-27 16:36:07 +00:00
Hans Petter Selasky
42a18f328e Print current buffer latency in dmesg for the USB audio driver and not just
the maximum.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2020-08-19 08:05:37 +00:00
Mark Johnston
94140f4781 usb(4): Stop checking for failures from malloc(M_WAITOK).
Handle the fact that parts of usb(4) can be compiled into the boot
loader, where M_WAITOK does not guarantee a successful allocation.

PR:		240545
Submitted by:	Andrew Reiter <arr@watson.org> (original version)
Reviewed by:	hselasky
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D25706
2020-07-22 14:32:47 +00:00
Andriy Gapon
4302208388 sound/hda: fix interrupt handler endless loop after r362294
Not all interrupt sources that affect CIS bit were acknowledged.
Specifically, bits in STATESTS (aka WAKESTS) were left set.

The fix is to disable WAKEEN and clear STATESTS bits before the HDA
interrupt is enabled.  This way we should never get any STATESTS bits.

I also added placeholders for all event bits that we currently do not
enable, do not handle and do not clear.  This might get useful when / if
we enable any of them.

Reported by:	kib (Apollo Lake hardware)
Tested by:	kib (earlier, different change)
MFC after:	2 weeks
X-MFC with:	r362294
2020-06-26 09:46:03 +00:00
Hans Petter Selasky
75dc9c41ab Improve debug message to be more precise and clear.
For the sake of the record, this is the last use of the words master and slave
in the FreeBSD's USB stack, drivers and subsystems.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2020-06-20 14:16:24 +00:00
Andriy Gapon
4c7d1ab06d hdac_intr_handler: keep working until global interrupt status clears
It is plausible that the hardware interrupts a host only when GIS goes
from zero to one.  GIS is formed by OR-ing multiple hardware statuses,
so it's possible that a previously cleared status gets set again while
another status has not been cleared yet.  Thus, there will be no new
interrupt as GIS always stayed set.  If we don't re-examine GIS then we
can leave it set and never get another interrupt again.

Without this change I frequently saw a problem where snd_hda would stop
working.  Setting dev.hdac.1.polling=1 would bring it back to life and
afterwards I could set polling back to zero.  Sometimes the problem
started right after a boot, sometimes it happened after resuming from
S3, frequently it would occur when sound output and input are active
concurrently (such as during conferencing).  I looked at HDAC_INTSTS
while the sound was not working and I saw that both HDAC_INTSTS_GIS and
HDAC_INTSTS_CIS were set, but there were no interrupts.

I have collected some statistics over a period of several days about how
many loops (calls to hdac_one_intr) the new code did for a single
interrupt:
+--------+--------------+
|Loops   |Times Happened|
+--------+--------------+
|0       |301           |
|1       |12857746      |
|2       |280           |
|3       |2             |
|4+      |0             |
+--------+--------------+
I believe that previously the sound would get stuck each time we had to loop
more than once.

The tested hardware is:
hdac1: <AMD (0x15e3) HDA Controller> mem 0xfe680000-0xfe687fff at device 0.6 on pci4
hdacc1: <Realtek ALC269 HDA CODEC> at cad 0 on hdac1

No objections:	mav
MFC after:	5 weeks
Differential Revision: https://reviews.freebsd.org/D25128
2020-06-18 06:12:06 +00:00
Alexander Motin
fc68af7962 Add bunch of HDA controller and codec IDs.
MFC after:	2 weeks
2020-06-05 15:06:58 +00:00
Andriy Gapon
5c96a7b2a5 snd_hda: fix typos related to quirks set via 'config' tunable
One wrong quirk bit, one wrong variable name.

MFC after:	1 week
2020-05-13 06:26:30 +00:00
Andriy Gapon
317cb28090 sound/hda: newer AMD devices still require the same PCIe snoop
So, replicate the ATI vendor snoop configuration for the AMD vendor.
I think that this should fix a number of cases where users currently
have to resort to polling or disabling MSI.

MFC after:	1 week
2020-05-13 06:24:54 +00:00
Hans Petter Selasky
40d59cd731 Set PCM_CAP_VIRTUAL for virtual DSP devices.
Submitted by:	Kevin Zheng <kevinz5000@gmail.com>
PR:		246206
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2020-05-07 18:15:35 +00:00
Ed Maste
258ba4c027 snd_hda: use bool for hdac_reset's boolean wakeup param 2020-04-26 22:08:47 +00:00
Ed Maste
0ae64ae4c9 hdac: remove unused macro 2020-04-20 15:41:40 +00:00
Ed Maste
944a64087e snd_hda: whitespace and style(9) cleanups 2020-04-19 17:53:44 +00:00
Ed Maste
cdf1703846 hda: remove hda*_lockowned macros
These are not used anywhere.
2020-04-18 18:25:30 +00:00
Ed Maste
f64485243f hdac: replace printf for unowned lock with a lock assertion
Reviewed by:	markj, mav
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D24479
2020-04-18 01:16:30 +00:00
Ed Maste
a449a1eb9b hdac: update comment to match function name
snd_hda was rewritten in r230130; one function retained a comment
referencing the previous name.

MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2020-04-17 19:14:05 +00:00
Mark Johnston
bd136d88f0 snd_hda(4): Recognize the ALC257 codec.
PR:		245524
Submitted by:	Jose Luis Duran <jlduran@gmail.com>
MFC after:	1 week
2020-04-13 19:45:45 +00:00
Ed Maste
b75e561a4a hda: if a CODEC is not responding, report which one
PR:		229190
MFC after:	1 week
2020-04-10 21:27:49 +00:00
Ed Maste
8fe63c2af8 hdac: show which command timed out
There are several reports of "hdac0: Command timeout on address 2"
messages emitted during playback on a variety of contemporary machines.
Show the command that timed out in case it might provide a clue in
finding the cause.

PR:		229190
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2020-04-10 18:38:42 +00:00
Ed Maste
e41841f04e hdac: update comment on reset duration
The comment previously stated the delay must be at least 250us but that
was insufficient and so should be doubled, but the delay was actually
1000.  The HDA spec actually says the delay must be 521 us (25 frames)
so update the comment to match.
2020-04-10 18:13:29 +00:00
Hans Petter Selasky
86c9b3f3a6 Add support for multiple playback and recording devices per physical USB audio
device. This requires some structural refactoring inside the driver, mostly
about converting existing audio channel structures into arrays.

The main audio mixer is provided by the first PCM instance.
The non-first audio instances may only have a software mixer for PCM playback.

Tested by:	Horse Ma <Shichun.Ma@dell.com>
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2020-03-30 16:50:32 +00:00
Hans Petter Selasky
93e39e2325 Implement new mixer API to return the device pointer based on the mixer pointer.
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2020-03-30 15:36:38 +00:00
Konstantin Belousov
f30cf5588a hdaa: remove verbosity from the normal driver operations.
If hdaa is used in polling mode, it logs each change to the poll
interval under bootverbose, which makes it unusable (slow).  These
messages are arguably useless or are a debugging leftovers at best.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2020-03-28 16:26:47 +00:00
Hans Petter Selasky
9211468fc2 Change default microphone level from 0 to 25.
Discussed with:	Horse Ma <Shichun.Ma@dell.com>
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2020-03-27 10:28:15 +00:00
Hans Petter Selasky
c2bc9ff72a Improve USB audio mixer support for USB audio class 1 and 2.
- make sure volume controls are correctly mapped to "pcm" and "rec" depending
  on how they deliver audio to the USB host.
- make sure there are no duplicate record selections.
- remove internal only mixer class type.
- don't add software volume controls for recording only.
- some minor mixer code cleanup.

Tested by:	Horse Ma <Shichun.Ma@dell.com>
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2020-03-27 10:22:35 +00:00
Hans Petter Selasky
a0be362828 Be more intelligent when classifying USB audio terminal types, so that we
don't end up using SOUND_MIXER_VOLUME for all undefined types.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2020-03-26 07:52:04 +00:00
Hans Petter Selasky
91feacd19e Make mute controls available for USB audio mixers.
Submitted by:	Horse Ma <Shichun.Ma@dell.com>
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2020-03-26 07:46:16 +00:00
Hans Petter Selasky
edabe1ee6d Factor out USB audio mixer value range check.
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2020-03-26 07:42:36 +00:00
Hans Petter Selasky
7e88777b24 Avoid scaling USB audio mixer values twice.
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2020-03-26 07:37:00 +00:00
Hans Petter Selasky
cc1efc23c8 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
2020-03-04 17:23:20 +00:00
Pawel Biernacki
7029da5c36 Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)
r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are
still not MPSAFE (or already are but aren’t properly marked).
Use it in preparation for a general review of all nodes.

This is non-functional change that adds annotations to SYSCTL_NODE and
SYSCTL_PROC nodes using one of the soon-to-be-required flags.

Mark all obvious cases as MPSAFE.  All entries that haven't been marked
as MPSAFE before are by default marked as NEEDGIANT

Approved by:	kib (mentor, blanket)
Commented by:	kib, gallatin, melifaro
Differential Revision:	https://reviews.freebsd.org/D23718
2020-02-26 14:26:36 +00:00
Pawel Biernacki
f8d2b1f3f7 Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (2 of many)
r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are
still not MPSAFE (or already are but aren’t properly marked). Use it in
preparation for a general review of all nodes.
This is non-functional change that adds annotations to SYSCTL_NODE and
SYSCTL_PROC nodes using one of the soon-to-be-required flags.

Reviewed by:	hselasky, kib
Approved by:	kib (mentor)
Differential Revision:	https://reviews.freebsd.org/D23632
2020-02-15 18:52:12 +00:00
Warner Losh
58aa35d429 Remove sparc64 kernel support
Remove all sparc64 specific files
Remove all sparc64 ifdefs
Removee indireeect sparc64 ifdefs
2020-02-03 17:35:11 +00:00
John Baldwin
c73222d0e6 Fix some misleading indentation warnings reported by recent clang.
These should not be any functional change.  While the change in
emul10kx-pcm.c looks like a real bug fix (as opposed to inconsistent
whitespace), the extra statements were not harmful.

Reviewed by:	kib
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D23363
2020-01-26 14:20:57 +00:00
Mark Johnston
d3eca31ea6 Configure headphone redirection for the Dell L780 and X1 Carbon 7th gen.
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.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2019-12-09 19:25:15 +00:00
Scott Long
35228417b2 Add support for new sound HDA hardware
Sponsored by:	Intel
2019-12-05 19:39:51 +00:00
Scott Long
a6c2525c49 Add device IDs for the next generation of Intel HDA audio.
MFC after:	3 days
2019-10-28 23:31:22 +00:00
Ed Maste
b7d6b3ffec snd_hda: style(9) whitespace fixup
PR:		241299
Submitted by:	Neel Chauhan
2019-10-17 14:58:03 +00:00
Oleksandr Tymoshenko
17b984a638 snd_hda: Add Intel Cannon Lake support
Add missing header change ommitted in r352775

MFC after:	2 weeks
X-MFC-with:	352775
2019-09-26 21:04:36 +00:00
Oleksandr Tymoshenko
c314e2aff2 snd_hda: Add Intel Cannon Lake support
Add PCI ids for Intel Cannon Lake PCH

Tested on:	HP Spectre x360 13-p0043dx
PR:		240574
Submitted by:	Neel Chauhan <neel@neelc.org>
Reviewed by:	imp, mizhka, ray
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D21789
2019-09-26 21:02:21 +00:00
Hans Petter Selasky
a48a37bee2 Decrease the default audio playback latency to a maximum of 21.3ms.
This significantly improves the audio playback response time.

Discussed with:	mav@
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2019-09-05 10:49:12 +00:00
Mark Johnston
7da9377b0d Properly check for an interrupted cv_wait_sig().
The returned error number may be EINTR or ERESTART depending on
whether or not the signal is supposed to interrupt the system call.

Reported and tested by:	pho
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2019-08-30 15:40:31 +00:00
Xin LI
5473ef874e Fix sound on headset jack for ThinkPad T51. 2019-08-21 08:01:43 +00:00
Mark Johnston
35fd0fc409 Use a sleepable lock for midistat functions.
Otherwise the mutex needs to be dropped when copying out the midistat
sbuf, leading to a race which allows one to read kernel memory beyond
the end of the sbuf buffer.

Reported and tested by:	pho
Security:	CVE-2019-5612
2019-08-20 17:52:12 +00:00