[Sound-open-firmware] jack detection via input/event on linux
Hi all,
I don't know where to ask this question so please point me to the right direction if I'm wrong here and if you know a better place to ask this questions. I tried to ask it on the alsa-user list but there was not a single response - not even a negative one.
I'm using a chromebook Lenovo IdeaPad i3 with Debian 11. Intel Jasper Lake platform, alsa modules snd_soc_rt5682, snd_soc_rt1015, etc.
The sound generally works, except I have to manually set mixer settings to have sound and it's making click-noises with every new stream and the headphone jack detection doesn't work. And the internal microphone has 4 channels with gray noise on channels 3+4, because there are onle two channels connected in this device (there are two mono microphones / one stereo... don't know).
The kernel is Linux 5.10 from the ChromeOS/chromiumOS project, the SOF firmware is sof-v2.1.1 (sof-jsl.*) from thesofproject, the alsa ucm is copied from the device filesystem (ChromeOS).
For jack detection there is some input event device /dev/input/event9 "sof-rt5682 Headset Jack" which works. I can see input events via evtest if I insert or remove the headset.
This device belongs to: cat /sys/devices/pci0000:00/0000:00:1f.3/jsl_rt5682_rt1015/driver/jsl_rt5682_rt1015/modalias platform:jsl_rt5682_rt1015
I don't know if there should be some "device-internal" jack-detection-service for this besides the input event device the kernel offers to userland and how headphone jack detection works in general for alsa/pulseaudio. The documentation neither for SOF nor alsa nor pulseaudio was eye-opening for me, sorry :-(
Everything I tried to modify the alsa ucm failed so far.
For ChromeOS it seems the ChromeOS sound server "CRAS" is responsible for headphone jack detection. The alsa ucm seems to have special functionality for CRAS? (see below for the Hifi.conf) And the functionality which is offered by the SOF firmware+driver is not compatible with alsa/pulseaudio?
Or does anybody know how to tell alsa or pulseaudio or maybe pipewire to listen to the input event device to enable headset output and switch to the headset device?
regards hede
### evtest while inserting and removing the headset ### evtest No device specified, trying to scan all of /dev/input/event* Available devices: /dev/input/event0: Lid Switch /dev/input/event1: Power Button /dev/input/event2: AT Translated Set 2 keyboard /dev/input/event3: cros_ec_buttons /dev/input/event4: PRP0001:00 /dev/input/event5: ELAN901C:00 04F3:2D70 /dev/input/event6: ELAN901C:00 04F3:2D70 UNKNOWN /dev/input/event7: ELAN901C:00 04F3:2D70 UNKNOWN /dev/input/event8: Elan Touchpad /dev/input/event9: sof-rt5682 Headset Jack /dev/input/event10: sof-rt5682 HDMI/DP,pcm=2 /dev/input/event11: sof-rt5682 HDMI/DP,pcm=3 /dev/input/event12: sof-rt5682 HDMI/DP,pcm=4 Select the device event number [0-12]: 9 Input driver version is 1.0.1 Input device ID: bus 0x0 vendor 0x0 product 0x0 version 0x0 Input device name: "sof-rt5682 Headset Jack" Supported events: Event type 0 (EV_SYN) Event type 1 (EV_KEY) Event code 114 (KEY_VOLUMEDOWN) Event code 115 (KEY_VOLUMEUP) Event code 164 (KEY_PLAYPAUSE) Event code 582 (KEY_VOICECOMMAND) Event type 5 (EV_SW) Event code 2 (SW_HEADPHONE_INSERT) state 0 Event code 4 (SW_MICROPHONE_INSERT) state 0 Properties: Testing ... (interrupt to exit) Event: time 1654246154.225165, type 5 (EV_SW), code 2 (SW_HEADPHONE_INSERT), value 1 Event: time 1654246154.225165, -------------- SYN_REPORT ------------ Event: time 1654246156.347444, type 5 (EV_SW), code 2 (SW_HEADPHONE_INSERT), value 0 Event: time 1654246156.347444, -------------- SYN_REPORT ------------ ####
#### amixer -c0 contents #### numid=20,iface=CARD,name='HDMI/DP,pcm=2 Jack' ; type=BOOLEAN,access=r-------,values=1 : values=off numid=26,iface=CARD,name='HDMI/DP,pcm=3 Jack' ; type=BOOLEAN,access=r-------,values=1 : values=off numid=32,iface=CARD,name='HDMI/DP,pcm=4 Jack' ; type=BOOLEAN,access=r-------,values=1 : values=off numid=16,iface=MIXER,name='Headphone Jack Switch' ; type=BOOLEAN,access=rw------,values=1 : values=on numid=69,iface=MIXER,name='ADCDAT Mux' ; type=ENUMERATED,access=rw------,values=1,items=2 ; Item #0 'ADCDAT1' ; Item #1 'ADCDAT2' : values=0 numid=21,iface=MIXER,name='IEC958 Playback Con Mask' ; type=IEC958,access=r-------,values=1 : values=[AES0=0x0f AES1=0xff AES2=0x00 AES3=0x00] numid=27,iface=MIXER,name='IEC958 Playback Con Mask',index=1 ; type=IEC958,access=r-------,values=1 : values=[AES0=0x0f AES1=0xff AES2=0x00 AES3=0x00] numid=33,iface=MIXER,name='IEC958 Playback Con Mask',index=2 ; type=IEC958,access=r-------,values=1 : values=[AES0=0x0f AES1=0xff AES2=0x00 AES3=0x00] numid=22,iface=MIXER,name='IEC958 Playback Pro Mask' ; type=IEC958,access=r-------,values=1 : values=[AES0=0x0f AES1=0x00 AES2=0x00 AES3=0x00] numid=28,iface=MIXER,name='IEC958 Playback Pro Mask',index=1 ; type=IEC958,access=r-------,values=1 : values=[AES0=0x0f AES1=0x00 AES2=0x00 AES3=0x00] numid=34,iface=MIXER,name='IEC958 Playback Pro Mask',index=2 ; type=IEC958,access=r-------,values=1 : values=[AES0=0x0f AES1=0x00 AES2=0x00 AES3=0x00] numid=23,iface=MIXER,name='IEC958 Playback Default' ; type=IEC958,access=rw------,values=1 : values=[AES0=0x04 AES1=0x00 AES2=0x00 AES3=0x00] numid=29,iface=MIXER,name='IEC958 Playback Default',index=1 ; type=IEC958,access=rw------,values=1 : values=[AES0=0x04 AES1=0x00 AES2=0x00 AES3=0x00] numid=35,iface=MIXER,name='IEC958 Playback Default',index=2 ; type=IEC958,access=rw------,values=1 : values=[AES0=0x04 AES1=0x00 AES2=0x00 AES3=0x00] numid=24,iface=MIXER,name='IEC958 Playback Switch' ; type=BOOLEAN,access=rw------,values=1 : values=on numid=30,iface=MIXER,name='IEC958 Playback Switch',index=1 ; type=BOOLEAN,access=rw------,values=1 : values=on numid=36,iface=MIXER,name='IEC958 Playback Switch',index=2 ; type=BOOLEAN,access=rw------,values=1 : values=on numid=2,iface=MIXER,name='CBJ Boost Volume' ; type=INTEGER,access=rw---R--,values=1,min=0,max=8,step=0 : values=3 | dBrange- rangemin=0,,rangemax=0 | dBscale-min=0.00dB,step=0.00dB,mute=0 rangemin=1,,rangemax=1 | dBscale-min=20.00dB,step=0.00dB,mute=0 rangemin=2,,rangemax=2 | dBscale-min=24.00dB,step=0.00dB,mute=0 rangemin=3,,rangemax=5 | dBscale-min=30.00dB,step=5.00dB,mute=0 rangemin=6,,rangemax=6 | dBscale-min=44.00dB,step=0.00dB,mute=0 rangemin=7,,rangemax=7 | dBscale-min=50.00dB,step=0.00dB,mute=0 rangemin=8,,rangemax=8 | dBscale-min=52.00dB,step=0.00dB,mute=0
numid=70,iface=MIXER,name='DAC L Mux' ; type=ENUMERATED,access=rw------,values=1,items=2 ; Item #0 'IF1' ; Item #1 'SOUND' : values=0 numid=76,iface=MIXER,name='DAC L1 Source' ; type=ENUMERATED,access=rw------,values=1,items=2 ; Item #0 'Stereo1 DAC Mixer' ; Item #1 'DAC1' : values=1 numid=71,iface=MIXER,name='DAC R Mux' ; type=ENUMERATED,access=rw------,values=1,items=2 ; Item #0 'IF1' ; Item #1 'SOUND' : values=0 numid=77,iface=MIXER,name='DAC R1 Source' ; type=ENUMERATED,access=rw------,values=1,items=2 ; Item #0 'Stereo1 DAC Mixer' ; Item #1 'DAC1' : values=1 numid=73,iface=MIXER,name='DAC1 MIXL DAC1 Switch' ; type=BOOLEAN,access=rw------,values=1 : values=on numid=72,iface=MIXER,name='DAC1 MIXL Stereo ADC Switch' ; type=BOOLEAN,access=rw------,values=1 : values=off numid=75,iface=MIXER,name='DAC1 MIXR DAC1 Switch' ; type=BOOLEAN,access=rw------,values=1 : values=on numid=74,iface=MIXER,name='DAC1 MIXR Stereo ADC Switch' ; type=BOOLEAN,access=rw------,values=1 : values=off numid=1,iface=MIXER,name='DAC1 Playback Volume' ; type=INTEGER,access=rw---R--,values=2,min=0,max=87,step=0 : values=79,79 | dBscale-min=-65.25dB,step=0.75dB,mute=0 numid=49,iface=MIXER,name='DETECT12.0 Detector Config' ; type=BYTES,access=-----RW-,values=304 ; ASoC TLV Byte control, skipping bytes dump numid=50,iface=MIXER,name='DETECT12.0 Hotword Model' ; type=BYTES,access=-----RW-,values=300000 ; ASoC TLV Byte control, skipping bytes dump numid=84,iface=MIXER,name='HPO Signal Demux' ; type=ENUMERATED,access=rw------,values=1,items=2 ; Item #0 'Legacy' ; Item #1 'OneBit' : values=1 numid=82,iface=MIXER,name='HPOL Playback Switch' ; type=BOOLEAN,access=rw------,values=1 : values=on numid=83,iface=MIXER,name='HPOR Playback Switch' ; type=BOOLEAN,access=rw------,values=1 : values=on numid=17,iface=MIXER,name='Headset Mic Switch' ; type=BOOLEAN,access=rw------,values=1 : values=on numid=64,iface=MIXER,name='IF1 01 ADC Swap Mux' ; type=ENUMERATED,access=rw------,values=1,items=4 ; Item #0 'L/R' ; Item #1 'R/L' ; Item #2 'L/L' ; Item #3 'R/R' : values=2 numid=65,iface=MIXER,name='IF1 23 ADC Swap Mux' ; type=ENUMERATED,access=rw------,values=1,items=4 ; Item #0 'L/R' ; Item #1 'R/L' ; Item #2 'L/L' ; Item #3 'R/R' : values=0 numid=66,iface=MIXER,name='IF1 45 ADC Swap Mux' ; type=ENUMERATED,access=rw------,values=1,items=4 ; Item #0 'L/R' ; Item #1 'R/L' ; Item #2 'L/L' ; Item #3 'R/R' : values=0 numid=67,iface=MIXER,name='IF1 67 ADC Swap Mux' ; type=ENUMERATED,access=rw------,values=1,items=4 ; Item #0 'L/R' ; Item #1 'R/L' ; Item #2 'L/L' ; Item #3 'R/R' : values=0 numid=59,iface=MIXER,name='IF1_ADC Mux' ; type=ENUMERATED,access=rw------,values=1,items=4 ; Item #0 'Slot 0' ; Item #1 'Slot 2' ; Item #2 'Slot 4' ; Item #3 'Slot 6' : values=0 numid=68,iface=MIXER,name='IF2 ADC Swap Mux' ; type=ENUMERATED,access=rw------,values=1,items=4 ; Item #0 'L/R' ; Item #1 'R/L' ; Item #2 'L/L' ; Item #3 'R/R' : values=0 numid=48,iface=MIXER,name='KPBM11.0 KPB' ; type=BYTES,access=-----RW-,values=304 ; ASoC TLV Byte control, skipping bytes dump numid=8,iface=MIXER,name='Left Boost Mode' ; type=ENUMERATED,access=rw------,values=1,items=3 ; Item #0 'Bypass' ; Item #1 'Adaptive' ; Item #2 'Fixed Adaptive' : values=0 numid=10,iface=MIXER,name='Left Bypass Boost' ; type=BOOLEAN,access=rw------,values=1 : values=on numid=7,iface=MIXER,name='Left DAC Playback Switch' ; type=BOOLEAN,access=rw------,values=2 : values=on,on numid=6,iface=MIXER,name='Left DAC Playback Volume' ; type=INTEGER,access=rw---R--,values=1,min=0,max=127,step=0 : values=127 | dBscale-min=-95.25dB,step=0.75dB,mute=0 numid=9,iface=MIXER,name='Left Mono LR Select' ; type=ENUMERATED,access=rw------,values=1,items=3 ; Item #0 'Left' ; Item #1 'Right' ; Item #2 'Left + Right average' : values=0 numid=18,iface=MIXER,name='Left Spk Switch' ; type=BOOLEAN,access=rw------,values=1 : values=on numid=41,iface=MIXER,name='PGA1.0 1 Master Playback Volume' ; type=INTEGER,access=rw---R--,values=2,min=0,max=32,step=0 : values=32,32 | dBscale-min=-64.00dB,step=2.00dB,mute=1 numid=47,iface=MIXER,name='PGA11.0 11 KWD Capture Volume' ; type=INTEGER,access=rw---R--,values=2,min=0,max=80,step=0 : values=50,50 | dBscale-min=-50.00dB,step=1.00dB,mute=1 numid=42,iface=MIXER,name='PGA2.0 2 Master Playback Volume' ; type=INTEGER,access=rw---R--,values=2,min=0,max=32,step=0 : values=32,32 | dBscale-min=-64.00dB,step=2.00dB,mute=1 numid=43,iface=MIXER,name='PGA3.0 3 Master Capture Volume' ; type=INTEGER,access=rw---R--,values=2,min=0,max=80,step=0 : values=50,50 | dBscale-min=-50.00dB,step=1.00dB,mute=1 numid=44,iface=MIXER,name='PGA5.0 5 Master Playback Volume' ; type=INTEGER,access=rw---R--,values=2,min=0,max=32,step=0 : values=32,32 | dBscale-min=-64.00dB,step=2.00dB,mute=1 numid=45,iface=MIXER,name='PGA6.0 6 Master Playback Volume' ; type=INTEGER,access=rw---R--,values=2,min=0,max=32,step=0 : values=32,32 | dBscale-min=-64.00dB,step=2.00dB,mute=1 numid=46,iface=MIXER,name='PGA7.0 7 Master Playback Volume' ; type=INTEGER,access=rw---R--,values=2,min=0,max=32,step=0 : values=32,32 | dBscale-min=-64.00dB,step=2.00dB,mute=1 numid=52,iface=MIXER,name='RECMIX1L CBJ Switch' ; type=BOOLEAN,access=rw------,values=1 : values=on numid=13,iface=MIXER,name='Right Boost Mode' ; type=ENUMERATED,access=rw------,values=1,items=3 ; Item #0 'Bypass' ; Item #1 'Adaptive' ; Item #2 'Fixed Adaptive' : values=0 numid=15,iface=MIXER,name='Right Bypass Boost' ; type=BOOLEAN,access=rw------,values=1 : values=on numid=12,iface=MIXER,name='Right DAC Playback Switch' ; type=BOOLEAN,access=rw------,values=2 : values=on,on numid=11,iface=MIXER,name='Right DAC Playback Volume' ; type=INTEGER,access=rw---R--,values=1,min=0,max=127,step=0 : values=127 | dBscale-min=-95.25dB,step=0.75dB,mute=0 numid=14,iface=MIXER,name='Right Mono LR Select' ; type=ENUMERATED,access=rw------,values=1,items=3 ; Item #0 'Left' ; Item #1 'Right' ; Item #2 'Left + Right average' : values=1 numid=19,iface=MIXER,name='Right Spk Switch' ; type=BOOLEAN,access=rw------,values=1 : values=on numid=51,iface=MIXER,name='SELECTOR12.0 SELECTOR' ; type=BYTES,access=-----RW-,values=304 ; ASoC TLV Byte control, skipping bytes dump numid=5,iface=MIXER,name='STO1 ADC Boost Gain Volume' ; type=INTEGER,access=rw---R--,values=2,min=0,max=3,step=0 : values=0,0 | dBscale-min=0.00dB,step=12.00dB,mute=0 numid=3,iface=MIXER,name='STO1 ADC Capture Switch' ; type=BOOLEAN,access=rw------,values=2 : values=off,off numid=4,iface=MIXER,name='STO1 ADC Capture Volume' ; type=INTEGER,access=rw---R--,values=2,min=0,max=63,step=0 : values=23,23 | dBscale-min=-17.25dB,step=0.75dB,mute=0 numid=57,iface=MIXER,name='Stereo1 ADC L Mux' ; type=ENUMERATED,access=rw------,values=1,items=2 ; Item #0 'ADC1 L' ; Item #1 'ADC1 R' : values=0 numid=53,iface=MIXER,name='Stereo1 ADC L1 Mux' ; type=ENUMERATED,access=rw------,values=1,items=2 ; Item #0 'DAC MIX' ; Item #1 'ADC' : values=1 numid=55,iface=MIXER,name='Stereo1 ADC L2 Mux' ; type=ENUMERATED,access=rw------,values=1,items=2 ; Item #0 'DAC MIX' ; Item #1 'DMIC' : values=0 numid=60,iface=MIXER,name='Stereo1 ADC MIXL ADC1 Switch' ; type=BOOLEAN,access=rw------,values=1 : values=on numid=61,iface=MIXER,name='Stereo1 ADC MIXL ADC2 Switch' ; type=BOOLEAN,access=rw------,values=1 : values=off numid=62,iface=MIXER,name='Stereo1 ADC MIXR ADC1 Switch' ; type=BOOLEAN,access=rw------,values=1 : values=on numid=63,iface=MIXER,name='Stereo1 ADC MIXR ADC2 Switch' ; type=BOOLEAN,access=rw------,values=1 : values=off numid=58,iface=MIXER,name='Stereo1 ADC R Mux' ; type=ENUMERATED,access=rw------,values=1,items=2 ; Item #0 'ADC1 L' ; Item #1 'ADC1 R' : values=1 numid=54,iface=MIXER,name='Stereo1 ADC R1 Mux' ; type=ENUMERATED,access=rw------,values=1,items=2 ; Item #0 'DAC MIX' ; Item #1 'ADC' : values=1 numid=56,iface=MIXER,name='Stereo1 ADC R2 Mux' ; type=ENUMERATED,access=rw------,values=1,items=2 ; Item #0 'DAC MIX' ; Item #1 'DMIC' : values=0 numid=78,iface=MIXER,name='Stereo1 DAC MIXL DAC L1 Switch' ; type=BOOLEAN,access=rw------,values=1 : values=off numid=79,iface=MIXER,name='Stereo1 DAC MIXL DAC R1 Switch' ; type=BOOLEAN,access=rw------,values=1 : values=off numid=80,iface=MIXER,name='Stereo1 DAC MIXR DAC L1 Switch' ; type=BOOLEAN,access=rw------,values=1 : values=off numid=81,iface=MIXER,name='Stereo1 DAC MIXR DAC R1 Switch' ; type=BOOLEAN,access=rw------,values=1 : values=off numid=25,iface=PCM,name='ELD',device=2 ; type=BYTES,access=r--v----,values=0 : values= numid=38,iface=PCM,name='Playback Channel Map',device=2 ; type=INTEGER,access=rw---R--,values=8,min=0,max=36,step=0 : values=0,0,0,0,0,0,0,0 | container | chmap-variable=FL,FR numid=31,iface=PCM,name='ELD',device=3 ; type=BYTES,access=r--v----,values=0 : values= numid=39,iface=PCM,name='Playback Channel Map',device=3 ; type=INTEGER,access=rw---R--,values=8,min=0,max=36,step=0 : values=0,0,0,0,0,0,0,0 | container | chmap-variable=FL,FR numid=37,iface=PCM,name='ELD',device=4 ; type=BYTES,access=r--v----,values=0 : values= numid=40,iface=PCM,name='Playback Channel Map',device=4 ; type=INTEGER,access=rw---R--,values=8,min=0,max=36,step=0 : values=0,0,0,0,0,0,0,0 | container | chmap-variable=FL,FR ####
#### /usr/share/alsa/ucm/sof-rt5682.rt1015p.1mic.botenflex/HiFi.conf #### SectionVerb { Value { FullySpecifiedUCM "1" } EnableSequence [ cdev "hw:sofrt5682" cset "name='Headphone Jack Switch' off" cset "name='HPOL Playback Switch' 1" cset "name='HPOR Playback Switch' 1" cset "name='Headset Mic Switch' off" cset "name='CBJ Boost Volume' 3" cset "name='RECMIX1L CBJ Switch' 1" cset "name='Stereo1 ADC L Mux' 0" cset "name='Stereo1 ADC L1 Mux' 1" cset "name='Stereo1 ADC R1 Mux' 1" cset "name='IF1 01 ADC Swap Mux' 2" cset "name='Left Spk Switch' off" cset "name='Right Spk Switch' off" ] DisableSequence [ ] } SectionDevice."Speaker".0 { Value { PlaybackPCM "hw:sofrt5682,0" DspName "speaker_eq" } EnableSequence [ cdev "hw:sofrt5682" cset "name='Left Spk Switch' on" cset "name='Right Spk Switch' on" ] DisableSequence [ cdev "hw:sofrt5682" cset "name='Left Spk Switch' off" cset "name='Right Spk Switch' off" ] } SectionDevice."Headphone".0 { Value { PlaybackPCM "hw:sofrt5682,1" PlaybackMixerElem "DAC1" JackDev "sof-rt5682 Headset Jack" JackSwitch "2" } EnableSequence [ cdev "hw:sofrt5682" cset "name='Stereo1 DAC MIXL DAC L1 Switch' 1" cset "name='Stereo1 DAC MIXR DAC R1 Switch' 1" cset "name='Headphone Jack Switch' on" ] DisableSequence [ cdev "hw:sofrt5682" cset "name='Headphone Jack Switch' off" cset "name='Stereo1 DAC MIXL DAC L1 Switch' 0" cset "name='Stereo1 DAC MIXR DAC R1 Switch' 0" ] } SectionDevice."Line Out".0 { Value { PlaybackPCM "hw:sofrt5682,1" PlaybackMixerElem "DAC1" JackDev "sof-rt5682 Headset Jack" JackSwitch "6" } EnableSequence [ cdev "hw:sofrt5682" cset "name='Stereo1 DAC MIXL DAC L1 Switch' 1" cset "name='Stereo1 DAC MIXR DAC R1 Switch' 1" cset "name='Headphone Jack Switch' on" ] DisableSequence [ cdev "hw:sofrt5682" cset "name='Headphone Jack Switch' off" cset "name='Stereo1 DAC MIXL DAC L1 Switch' 0" cset "name='Stereo1 DAC MIXR DAC R1 Switch' 0" ] } SectionDevice."Mic".0 { Value { CapturePCM "hw:sofrt5682,1" CaptureMixerElem "Headset Mic" JackDev "sof-rt5682 Headset Jack" } EnableSequence [ cdev "hw:sofrt5682" cset "name='Stereo1 ADC MIXL ADC1 Switch' 1" cset "name='Stereo1 ADC MIXR ADC1 Switch' 1" cset "name='Headset Mic Switch' on" ] DisableSequence [ cdev "hw:sofrt5682" cset "name='Headset Mic Switch' off" cset "name='Stereo1 ADC MIXL ADC1 Switch' 0" cset "name='Stereo1 ADC MIXR ADC1 Switch' 0" ] } SectionDevice."Front Mic".0 { Value { CapturePCM "hw:sofrt5682,5" CaptureChannelMap "0 1 -1 -1 -1 -1 -1 -1 -1 -1 -1" IntrinsicSensitivity "-2600" DspName "dmic_eq" } } SectionDevice."Rear Mic".0 { Value { CapturePCM "hw:sofrt5682,5" CaptureChannelMap "2 3 -1 -1 -1 -1 -1 -1 -1 -1 -1" IntrinsicSensitivity "-2600" DspName "dmic_eq" } } SectionDevice."HDMI1".0 { Value { PlaybackPCM "hw:sofrt5682,2" JackDev "sof-rt5682 HDMI/DP,pcm=2" } EnableSequence [ ] DisableSequence [ ] } SectionDevice."HDMI2".0 { Value { PlaybackPCM "hw:sofrt5682,3" JackDev "sof-rt5682 HDMI/DP,pcm=3" } EnableSequence [ ] DisableSequence [ ] } SectionDevice."HDMI3".0 { Value { PlaybackPCM "hw:sofrt5682,4" JackDev "sof-rt5682 HDMI/DP,pcm=4" } EnableSequence [ ] DisableSequence [ ] } ####
On 03. 06. 22 11:16, hede wrote:
Or does anybody know how to tell alsa or pulseaudio or maybe pipewire to listen to the input event device to enable headset output and switch to the headset device?
PA/PW use only ALSA controls at the moment - thus you should define JackControl as defined in use-case.h. But it seems that the driver does not create or publish the ALSA jack control (I see only "iface=CARD,name='HDMI/DP,pcm=2 Jack'" jack controls for HDMI).
Jaroslav
Am 03.06.2022 11:34, schrieb Jaroslav Kysela:
PA/PW use only ALSA controls at the moment - thus you should define JackControl as defined in use-case.h. But it seems that the driver does not create or publish the ALSA jack control (I see only "iface=CARD,name='HDMI/DP,pcm=2 Jack'" jack controls for HDMI).
Jaroslav
Ah, thank you Jaroslav. That's the hint I was searching for atm. JackDev vs. JackControl. I had a vague guess on this but now you made it certain.
Maybe I should take a look into the driver directly.
many thanks hede
On 03. 06. 22 13:17, hede wrote:
Am 03.06.2022 11:34, schrieb Jaroslav Kysela:
PA/PW use only ALSA controls at the moment - thus you should define JackControl as defined in use-case.h. But it seems that the driver does not create or publish the ALSA jack control (I see only "iface=CARD,name='HDMI/DP,pcm=2 Jack'" jack controls for HDMI).
Jaroslav
Ah, thank you Jaroslav. That's the hint I was searching for atm. JackDev vs. JackControl. I had a vague guess on this but now you made it certain.
Maybe I should take a look into the driver directly.
It seems that many ASoC drivers do not create kctls - the argument pins is zero in the snd_soc_card_jack_new() call. The SND_JACK_HEADSET should be remapped to kctl in sound/soc/intel/boards/sof_rt5682.c, too.
Jaroslav
[Adding alsa-devel, Mark and Takashi to this thread]
On 6/3/22 08:33, Jaroslav Kysela wrote:
On 03. 06. 22 13:17, hede wrote:
Am 03.06.2022 11:34, schrieb Jaroslav Kysela:
PA/PW use only ALSA controls at the moment - thus you should define JackControl as defined in use-case.h. But it seems that the driver does not create or publish the ALSA jack control (I see only "iface=CARD,name='HDMI/DP,pcm=2 Jack'" jack controls for HDMI).
Jaroslav
Ah, thank you Jaroslav. That's the hint I was searching for atm. JackDev vs. JackControl. I had a vague guess on this but now you made it certain.
Maybe I should take a look into the driver directly.
It seems that many ASoC drivers do not create kctls - the argument pins is zero in the snd_soc_card_jack_new() call. The SND_JACK_HEADSET should be remapped to kctl in sound/soc/intel/boards/sof_rt5682.c, too.
Did you mean something like the patch below Jaroslav? If yes, most of the Chromebook machine drivers are missing this remapping. That would also explain why the jack detection didn't work on my GLK test device, despite a UCM file that looked good...
diff --git a/sound/soc/intel/boards/sof_rt5682.c b/sound/soc/intel/boards/sof_rt5682.c index 5d67a2c87a1d4..1db17ebd26f63 100644 --- a/sound/soc/intel/boards/sof_rt5682.c +++ b/sound/soc/intel/boards/sof_rt5682.c @@ -85,6 +85,17 @@ struct sof_card_private { bool idisp_codec; };
+static struct snd_soc_jack_pin sof_jack_pins[] = { + { + .pin = "Headphone", + .mask = SND_JACK_HEADPHONE, + }, + { + .pin = "Headset Mic", + .mask = SND_JACK_MICROPHONE, + }, +}; + static int sof_rt5682_quirk_cb(const struct dmi_system_id *id) { sof_rt5682_quirk = (unsigned long)id->driver_data; @@ -295,11 +306,13 @@ static int sof_rt5682_codec_init(struct snd_soc_pcm_runtime *rtd) * Headset buttons map to the google Reference headset. * These can be configured by userspace. */ - ret = snd_soc_card_jack_new(rtd->card, "Headset Jack", - SND_JACK_HEADSET | SND_JACK_BTN_0 | - SND_JACK_BTN_1 | SND_JACK_BTN_2 | - SND_JACK_BTN_3, - &ctx->sof_headset); + ret = snd_soc_card_jack_new_pins(rtd->card, "Headset Jack", + SND_JACK_HEADSET | SND_JACK_BTN_0 | + SND_JACK_BTN_1 | SND_JACK_BTN_2 | + SND_JACK_BTN_3, + &ctx->sof_headset, + sof_jack_pins, + ARRAY_SIZE(sof_jack_pins)); if (ret) { dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret); return ret; @@ -481,7 +494,7 @@ static int sof_card_late_probe(struct snd_soc_card *card) }
static const struct snd_kcontrol_new sof_controls[] = { - SOC_DAPM_PIN_SWITCH("Headphone Jack"), + SOC_DAPM_PIN_SWITCH("Headphone"), SOC_DAPM_PIN_SWITCH("Headset Mic"), SOC_DAPM_PIN_SWITCH("Left Spk"), SOC_DAPM_PIN_SWITCH("Right Spk"), @@ -489,7 +502,7 @@ static const struct snd_kcontrol_new sof_controls[] = { };
static const struct snd_soc_dapm_widget sof_widgets[] = { - SND_SOC_DAPM_HP("Headphone Jack", NULL), + SND_SOC_DAPM_HP("Headphone", NULL), SND_SOC_DAPM_MIC("Headset Mic", NULL), SND_SOC_DAPM_SPK("Left Spk", NULL), SND_SOC_DAPM_SPK("Right Spk", NULL), @@ -501,8 +514,8 @@ static const struct snd_soc_dapm_widget dmic_widgets[] = {
static const struct snd_soc_dapm_route sof_map[] = { /* HP jack connectors - unknown if we have jack detection */ - { "Headphone Jack", NULL, "HPOL" }, - { "Headphone Jack", NULL, "HPOR" }, + { "Headphone", NULL, "HPOL" }, + { "Headphone", NULL, "HPOR" },
/* other jacks */ { "IN1P", NULL, "Headset Mic" },
On 03. 06. 22 17:48, Pierre-Louis Bossart wrote:
[Adding alsa-devel, Mark and Takashi to this thread]
On 6/3/22 08:33, Jaroslav Kysela wrote:
On 03. 06. 22 13:17, hede wrote:
Am 03.06.2022 11:34, schrieb Jaroslav Kysela:
PA/PW use only ALSA controls at the moment - thus you should define JackControl as defined in use-case.h. But it seems that the driver does not create or publish the ALSA jack control (I see only "iface=CARD,name='HDMI/DP,pcm=2 Jack'" jack controls for HDMI).
Jaroslav
Ah, thank you Jaroslav. That's the hint I was searching for atm. JackDev vs. JackControl. I had a vague guess on this but now you made it certain.
Maybe I should take a look into the driver directly.
It seems that many ASoC drivers do not create kctls - the argument pins is zero in the snd_soc_card_jack_new() call. The SND_JACK_HEADSET should be remapped to kctl in sound/soc/intel/boards/sof_rt5682.c, too.
Did you mean something like the patch below Jaroslav? If yes, most of the Chromebook machine drivers are missing this remapping. That would also explain why the jack detection didn't work on my GLK test device, despite a UCM file that looked good...
Yes, it looks like a way to go. It seems that the drivers were tested only with the CRAS audio server. Note that pulseaudio can be run with the user permissions only - thus the input devices may not be reachable.
Thanks, Jaroslav
Jaroslav, would it help if we made our UCMs closer to upstream so we could just send them directly so pulse could test them easier? (this is a goal I have, it just unfortunately really low priority)
Curtis Malainey | Chrome OS Audio Senior Software Engineer | cujomalainey@google.com | We're Hiring!
Curtis Malainey | Chrome OS Audio Senior Software Engineer | cujomalainey@google.com | We're Hiring!
On Fri, Jun 3, 2022 at 8:58 AM Jaroslav Kysela perex@perex.cz wrote:
On 03. 06. 22 17:48, Pierre-Louis Bossart wrote:
[Adding alsa-devel, Mark and Takashi to this thread]
On 6/3/22 08:33, Jaroslav Kysela wrote:
On 03. 06. 22 13:17, hede wrote:
Am 03.06.2022 11:34, schrieb Jaroslav Kysela:
PA/PW use only ALSA controls at the moment - thus you should define JackControl as defined in use-case.h. But it seems that the driver does not create or publish the ALSA jack control (I see only "iface=CARD,name='HDMI/DP,pcm=2 Jack'" jack controls for HDMI).
Jaroslav
Ah, thank you Jaroslav. That's the hint I was searching for atm. JackDev vs. JackControl. I had a vague guess on this but now you made it certain.
Maybe I should take a look into the driver directly.
It seems that many ASoC drivers do not create kctls - the argument pins is zero in the snd_soc_card_jack_new() call. The SND_JACK_HEADSET should be remapped to kctl in sound/soc/intel/boards/sof_rt5682.c, too.
Did you mean something like the patch below Jaroslav? If yes, most of the Chromebook machine drivers are missing this remapping. That would also explain why the jack detection didn't work on my GLK test device, despite a UCM file that looked good...
Yes, it looks like a way to go. It seems that the drivers were tested only with the CRAS audio server. Note that pulseaudio can be run with the user permissions only - thus the input devices may not be reachable.
Thanks, Jaroslav
-- Jaroslav Kysela perex@perex.cz Linux Sound Maintainer; ALSA Project; Red Hat, Inc. _______________________________________________ Sound-open-firmware mailing list Sound-open-firmware@alsa-project.org https://mailman.alsa-project.org/mailman/listinfo/sound-open-firmware
It seems that many ASoC drivers do not create kctls - the argument pins is zero in the snd_soc_card_jack_new() call. The SND_JACK_HEADSET should be remapped to kctl in sound/soc/intel/boards/sof_rt5682.c, too.
Did you mean something like the patch below Jaroslav? If yes, most of the Chromebook machine drivers are missing this remapping. That would also explain why the jack detection didn't work on my GLK test device, despite a UCM file that looked good...
Yes, it looks like a way to go. It seems that the drivers were tested only with the CRAS audio server. Note that pulseaudio can be run with the user permissions only - thus the input devices may not be reachable.
I added a similar patch on a GeminiLake device, and it does help with jack detection (along with an update in https://github.com/alsa-project/alsa-ucm-conf/pull/150).
I can see PulseAudio detecting the changes, but for some reason the automatic switch only happens when the jack is unplugged. I still have to manually select the headphone/headset after plugging it in. Likely still missing something in the UCM file?
D: [pulseaudio] module-alsa-card.c: Jack 'Headphone Jack' is now unplugged
D: [pulseaudio] device-port.c: Setting port [Out] Headphone to status no
D: [pulseaudio] module-switch-on-port-available.c: Trying to switch away from port [Out] Headphone, found [Out] Speaker
D: [pulseaudio] module-alsa-card.c: Jack 'Headset Mic Jack' is now unplugged
D: [pulseaudio] device-port.c: Setting port [In] Headset to status no
D: [pulseaudio] core-subscribe.c: Dropped redundant event due to change event.
D: [pulseaudio] module-switch-on-port-available.c: Trying to switch away from port [In] Headset, found [In] InternalMic
<<< AUTOMATIC SWITCH DONE
D: [pulseaudio] module-alsa-card.c: Jack 'Headphone Jack' is now plugged in
D: [pulseaudio] device-port.c: Setting port [Out] Headphone to status yes
D: [pulseaudio] module-alsa-card.c: Jack 'Headset Mic Jack' is now plugged in
D: [pulseaudio] device-port.c: Setting port [In] Headset to status yes
<<< NOTHING HAPPENS HERE
D: [pulseaudio] module-alsa-card.c: Jack 'Headphone Jack' is now unplugged
D: [pulseaudio] device-port.c: Setting port [Out] Headphone to status no
D: [pulseaudio] module-switch-on-port-available.c: Trying to switch away from port [Out] Headphone, found [Out] Speaker
D: [pulseaudio] module-alsa-card.c: Jack 'Headset Mic Jack' is now unplugged
D: [pulseaudio] device-port.c: Setting port [In] Headset to status no
D: [pulseaudio] core-subscribe.c: Dropped redundant event due to change event.
D: [pulseaudio] module-switch-on-port-available.c: Trying to switch away from port [In] Headset, found [In] InternalMic
On Fri, 3 Jun 2022 10:48:19 -0500 Pierre-Louis Bossart pierre-louis.bossart@linux.intel.com wrote:
Did you mean something like the patch below Jaroslav? If yes, most of the Chromebook machine drivers are missing this remapping. That would also explain why the jack detection didn't work on my GLK test device, despite a UCM file that looked good...
diff --git a/sound/soc/intel/boards/sof_rt5682.c b/sound/soc/intel/boards/sof_rt5682.c index 5d67a2c87a1d4..1db17ebd26f63 100644 --- a/sound/soc/intel/boards/sof_rt5682.c +++ b/sound/soc/intel/boards/sof_rt5682.c [...]
I can confirm this patch works for me (adapted, because I obviously use some different kernel version). It seems I do have some bugs within my UCM file currently as the activation works but not deactivation of the headset. But "alsactl monitor" is fine and shows both events, insert and remove. *thumbup*
Next thing is the 4ch capture which hits me, too, like you described in your pull request.
Curtis' goal to have their UCMs upstream also sounds promising.
Thank you all! My question here was more productive than I would dream of. hede
participants (4)
-
Curtis Malainey
-
hede
-
Jaroslav Kysela
-
Pierre-Louis Bossart