[PATCH 1/2] ALSA: usb-audio: Support jack detection on Dell dock

Takashi Iwai tiwai at suse.de
Mon Jul 4 14:29:05 CEST 2022


On Mon, 27 Jun 2022 19:18:54 +0200,
Jan Schär wrote:
> 
> 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.
> 
> Signed-off-by: Jan Schär <jan at jschaer.ch>
> ---
> 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 {
> 				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


More information about the Alsa-devel mailing list