Skip to contentSkip to conversation

ALSA: usb-audio: Support jack detection on Dell dock

PATCH Takashi Iwai 1 participant 1 message Jul 4, 2022 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 81 lines · Jan Schär

The Dell WD15 dock has a headset and a line out port. Add support for detecting if a jack is inserted into one of these ports. For the headset jack, additionally determine if a mic is present.

The WD15 contains an ALC4020 USB audio controller and ALC3263 audio codec from Realtek. It is a UAC 1 device, and UAC 1 does not support jack detection. Instead, jack detection works by sending HD Audio commands over vendor-type USB messages.

I found out how it works by looking at USB captures on Windows. The audio codec is very similar to the one supported by sound/soc/codecs/rt298.c / rt298.h, some constant names and the mic detection are adapted from there. The realtek_add_jack function is adapted from build_connector_control in sound/usb/mixer.c.

I tested this on a WD15 dock with the latest firmware.

---
For testing this patch, you need to change the content of the file /usr/share/alsa/ucm2/USB-Audio/Dell-WD15-Dock-HiFi.conf to the following:

```
SectionDevice."Headphones" {
	Comment "Headphones"

	Value {
		PlaybackPriority 100
		PlaybackPCM "hw:${CardId}"
		JackControl "Headphone Jack"

		If.Headphone_ctl {
			Condition {
				Type ControlExists
				Control "name='Headphone Playback Switch'"
			}
			True {
				PlaybackMixerElem "Headphone"
				PlaybackVolume "Headphone Playback Volume"
				PlaybackSwitch "Headphone Playback Switch"
			}
		}
	}
}

SectionDevice."Line" {
	Comment "Line Out"

	Value {
		PlaybackPriority 200
		PlaybackPCM "hw:${CardId},1"
		JackControl "Line Out Jack"

		If.Line_ctl {
			Condition {
				Type ControlExists
				Control "name='Line Playback Switch'"
			}
			True {
				PlaybackMixerElem "Line"
				PlaybackVolume "Line Playback Volume"
				PlaybackSwitch "Line Playback Switch"
			}
		}
	}
}

SectionDevice."Headset" {
	Comment "Headset Microphone"

	Value {
		CapturePriority 100
		CapturePCM "hw:${CardId}"
		JackControl "Headset Mic Jack"

		If.Mic_ctl {
			Condition {
				Type ControlExists
				Control "name='Mic Capture Switch'"
			}
			True {
Quoted 8 lines
				CaptureMixerElem "Mic"
				CaptureVolume "Mic Capture Volume"
				CaptureSwitch "Mic Capture Switch"
			}
		}
	}
}
```

This is an interesting finding.
Applied both patches to for-next branch now.

Thanks!

Takashi