Page MenuHomeFreeBSD

snd_hda: Implement automatic redirection between associations
Needs ReviewPublic

Authored by christos on Tue, Apr 29, 1:13 PM.

Details

Summary

For audio to be redirected to the headphones/headset after plugging the
jack, or back to the speaker/internal mic when unplugging it, the
speaker and headphone pins need to be part of the same association
(i.e., the same PCM device). This patch makes it possible to redirect
audio even between different associations, which can reduce the need for
manual pin patching.

The idea is that we issue a devctl_notify() from within the jack
detection callback whenever a jack is (un-)plugged to redirect audio to
the appropriate device. Then the hda.conf devd script is responsible for
using virtual_oss to change the playback/recording device to whatever
snd_hda(4) selected. The reason for requiring virtual_oss is that it has
hot-swapping support, which is necessary for jack redirection.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 63775
Build 60659: arc lint + arc unit

Event Timeline

This is a WIP and needs more testing.

A few things I know already need to be addressed:

  • We are currently choosing the first association that meets our search criteria. What if there are multiple such associations? I haven't had the chance to test this yet.
  • Should we touch hw.snd.default_unit? The answer is not obvious, since we're switching either the playback or the recording device, not both, and hw.snd.default_unit affects both.
  • The devd script relies on virtual_oss running with vdsp.ctl as the control device, because this is usually the default name people choose.

I'm also planning to port virtual_oss to base in the near future.

sys/dev/sound/pci/hda/hdaa.c
6226

We're creating the PCM devices first so that the new code in hdaa_presence_handler() doesn't panic when trying to access pdevinfo in case it runs.