Bug 114171

Summary: I2S mode has no internal microphone, speakers and headphones out of the box on broadwell-rt286 (broadwell-audio Dell XPS 13 9343)
Product: Drivers Reporter: Enrico Tagliavini (enrico.tagliavini)
Component: Sound(ALSA)Assignee: Jaroslav Kysela (perex)
Status: NEW ---    
Severity: normal CC: cribari, darkbasic, david.ward, f3d, herald, mattia.b89, mtabolsky, superquad.vortex2
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 4.4.4 Tree: Mainline
Regression: Yes
Attachments: alsa-info.sh output for kernel 4.4.4
alsa-info.sh output for kernel 4.3.6
alsa-info.sh output for kernel 4.4.5 plus UCM config file added
screencast
alsa-info.sh output, kernel 5.3.11, alsa 1.2.1.1
Kernel patch to disable ACPI _REV override for Dell XPS 13 9343
Kernel patch to fix GPIO2 enable in rt286 driver
hda external mic recording level
i2s external mic recording level

Description Enrico Tagliavini 2016-03-09 16:26:44 UTC
Created attachment 208501 [details]
alsa-info.sh output for kernel 4.4.4

This happens on Fedora 22. Kernel 4.3.5 was running with the old HDA mode and microphone was working. With the update to 4.4.4 few days ago I noticed the microphone was not working anymore (a friend with Fedora 23 actually asked me if there was a workaround for that and I discovered the same was happening on my laptop).

As far as I understood also in pure vanilla kernel from kernel.org the HDA mode was the default for 4.3 and the ISA mode is the default for 4.4, so I marked this as a regression, feel free to edit, if I'm wrong.

Attached the output of alsa-info.sh

Pulseaudio reports only one unplugged microphone (possibly it refers to the 3.5 mm stereo + mic jack).

enrico@quantdell ~ $ pacmd list-sources
4 source(s) available.
    index: 0
        name: <alsa_output.pci-0000_00_03.0.hdmi-stereo.monitor>
        driver: <module-alsa-card.c>
        flags: DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
        state: RUNNING
        suspend cause: 
        priority: 1950
        volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
                balance 0.00
        base volume: 65536 / 100% / 0.00 dB
        volume steps: 65537
        muted: no
        current latency: 0.00 ms
        max rewind: 344 KiB
        sample spec: s16le 2ch 44100Hz
        channel map: front-left,front-right
                     Stereo
        used by: 2
        linked by: 2
        configured latency: 20.00 ms; range is 0.50 .. 1999.82 ms
        monitor_of: 0
        card: 0 <alsa_card.pci-0000_00_03.0>
        module: 6
        properties:
                device.description = "Monitor of Built-in Audio Digital Stereo (HDMI)"
                device.class = "monitor"
                alsa.card = "0"
                alsa.card_name = "HDA Intel HDMI"
                alsa.long_card_name = "HDA Intel HDMI at 0xf7418000 irq 49"
                alsa.driver_name = "snd_hda_intel"
                device.bus_path = "pci-0000:00:03.0"
                sysfs.path = "/devices/pci0000:00/0000:00:03.0/sound/card0"
                device.bus = "pci"
                device.vendor.id = "8086"
                device.vendor.name = "Intel Corporation"
                device.product.id = "160c"
                device.product.name = "Broadwell-U Audio Controller"
                device.form_factor = "internal"
                device.string = "0"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-pci"
    index: 1
        name: <alsa_output.platform-broadwell-audio.analog-stereo.monitor>
        driver: <module-alsa-card.c>
        flags: DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
        state: RUNNING
        suspend cause: 
        priority: 1000
        volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
                balance 0.00
        base volume: 65536 / 100% / 0.00 dB
        volume steps: 65537
        muted: no
        current latency: 0.00 ms
        max rewind: 256 KiB
        sample spec: s16le 2ch 48000Hz
        channel map: front-left,front-right
                     Stereo
        used by: 3
        linked by: 3
        configured latency: 20.00 ms; range is 0.50 .. 1365.33 ms
        monitor_of: 1
        card: 1 <alsa_card.platform-broadwell-audio>
        module: 7
        properties:
                device.description = "Monitor of broadwell-rt286 Analog Stereo"
                device.class = "monitor"
                alsa.card = "1"
                alsa.card_name = "broadwell-rt286"
                alsa.long_card_name = "broadwell-rt286"
                alsa.driver_name = "snd_soc_sst_broadwell"
                device.bus_path = "platform-broadwell-audio"
                sysfs.path = "/devices/pci0000:00/INT3438:00/broadwell-audio/sound/card1"
                device.vendor.name = "Interphase Corporation"
                device.string = "1"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card"
  * index: 2
        name: <alsa_input.platform-broadwell-audio.analog-stereo>
        driver: <module-alsa-card.c>
        flags: HARDWARE HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
        state: RUNNING
        suspend cause: 
        priority: 9009
        volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
                balance 0.00
        base volume: 65536 / 100% / 0.00 dB
        volume steps: 65537
        muted: no
        current latency: 0.00 ms
        max rewind: 0 KiB
        sample spec: s16le 2ch 48000Hz
        channel map: front-left,front-right
                     Stereo
        used by: 1
        linked by: 1
        configured latency: 20.00 ms; range is 0.50 .. 1365.33 ms
        card: 1 <alsa_card.platform-broadwell-audio>
        module: 7
        properties:
                alsa.resolution_bits = "16"
                device.api = "alsa"
                device.class = "sound"
                alsa.class = "generic"
                alsa.subclass = "generic-mix"
                alsa.name = ""
                alsa.id = "System Playback/Capture (*)"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "0"
                alsa.card = "1"
                alsa.card_name = "broadwell-rt286"
                alsa.long_card_name = "broadwell-rt286"
                alsa.driver_name = "snd_soc_sst_broadwell"
                device.bus_path = "platform-broadwell-audio"
                sysfs.path = "/devices/pci0000:00/INT3438:00/broadwell-audio/sound/card1"
                device.vendor.name = "Interphase Corporation"
                device.string = "hw:1"
                device.buffering.buffer_size = "262144"
                device.buffering.fragment_size = "131072"
                device.access_mode = "mmap+timer"
                device.profile.name = "analog-stereo"
                device.profile.description = "Analog Stereo"
                device.description = "broadwell-rt286 Analog Stereo"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card"
        ports:
                analog-input-mic: Microphone (priority 8700, latency offset 0 usec, available: no)
                        properties:
                                device.icon_name = "audio-input-microphone"
        active port: <analog-input-mic>
    index: 3
        name: <combined.monitor>
        driver: <module-combine-sink.c>
        flags: DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
        state: RUNNING
        suspend cause: 
        priority: 1000
        volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
                balance 0.00
        base volume: 65536 / 100% / 0.00 dB
        volume steps: 65537
        muted: no
        current latency: 0.00 ms
        max rewind: 0 KiB
        sample spec: s16le 2ch 44100Hz
        channel map: front-left,front-right
                     Stereo
        used by: 1
        linked by: 1
        configured latency: 20.00 ms; range is 0.50 .. 200.00 ms
        monitor_of: 2
        module: 14
        properties:
                device.description = "Monitor Source of Simultaneous output to Built-in Audio Digital Stereo (HDMI), broadwell-rt286 Analog Stereo"
                device.class = "monitor"
                device.icon_name = "audio-input-microphone"
Comment 1 Enrico Tagliavini 2016-03-09 16:30:38 UTC
Forgot to say I tried to record from ALSA directly using audacity for both the devices listed by arecord, hw:1,0 and hw:1,3, both are not showing any sign of sound. I checked in alsamixer, all volumes in the capture tab for the broadwell-rt286 device are high and not muted
Comment 2 Raymond 2016-03-12 09:23:37 UTC
Simple mixer control 'ADC0',0
  Capabilities: cvolume cswitch
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 127
  Front Left: Capture 127 [100%] [0.00dB] [off]
  Front Right: Capture 127 [100%] [0.00dB] [off]
Comment 3 Francisco Cribari 2016-03-18 11:27:39 UTC
I am having the same problem with kernel 4.4.5-300. Fedora 23 on a Dell XPS 13 (model 9343, bios A07).
Comment 4 Enrico Tagliavini 2016-03-18 12:33:11 UTC
I finally found a way to get microphone back, enabling capture on ADC0 is the the magic secret needed, found in http://forthescience.org/blog/2015/03/20/installing_ubuntu_14_04_on_the_new_dell_xps_13/ . It was very counter intuitive since it is a slide + a switch in alsamixer, I didn't noticed for quite a while until I found that post.

I still think this is a bug since with HDA mode it works without any user intervention and I don't expect the average user to do so. I don't think the microphone quality is at its best, there is quite a relevant background noise. Also the switch names to trigger are not obvious at all (ADC0, Front DAC, HPO L, HPO R). Finally pulseaudio still reports the microphone being unplugged.
Comment 5 Raymond 2016-03-18 14:22:38 UTC
you need to add Element ADC0 into pulseaudio conf files

when mic jack is unplugged

control.12 {
		iface CARD
		name 'Mic Jack'
		value false
		comment {
			access read
			type BOOLEAN
			count 1
		}
	}

https://cgit.freedesktop.org/pulseaudio/pulseaudio/tree/src/modules/alsa/mixer/paths/analog-input-internal-mic.conf
Comment 6 Enrico Tagliavini 2016-03-21 12:18:47 UTC
Let me understand: is the bug actually in pulseaudio as in the default configuration shipped misses a bit? Or is this just a workaround for me?
Comment 8 Raymond 2016-03-22 07:42:38 UTC
seem ucm conf tailored for Nexus 7

http://git.alsa-project.org/?p=alsa-lib.git;a=blob;f=src/conf/ucm/broadwell-rt286/HiFi;hb=HEAD
Comment 9 Raymond 2016-03-23 08:24:16 UTC
(In reply to Enrico Tagliavini from comment #6)
> Let me understand: is the bug actually in pulseaudio as in the default
> configuration shipped misses a bit? Or is this just a workaround for me?

do your dell use same UCM file of Nexus 7

https://cgit.freedesktop.org/pulseaudio/pulseaudio/log/src/modules/alsa/alsa-ucm.c


pulseaudio parse ucm conf file to get the mixer seting of "Speaker",  "Headset" and "Mainmic"
Comment 10 Enrico Tagliavini 2016-03-23 12:17:53 UTC
Mhm, ok I start understanding a bit. I didn't known about this UCM I had a quick read and roughly understood what it is about.

I checked and on Fedora config files for UCM are not installed by default (needed to install alsa-ucm manually). However no config for broadwell-rt286 is available:

# ls /usr/share/alsa/ucm/
DAISY-I2S/  GoogleNyan/  PandaBoard/  PandaBoardES/  PAZ00/  SDP4430/  tegraalc5632/

this is because Fedora (both 22 and 23) is shipping with alsa 1.0.29 and not 1.1.0 where these config files were added. I'll try to add them manually from the 1.1.0 archive I can download from the upstream website, see if anything changes.

To be clear: are those mandatory to make the card work well in I2S mode? I'm asking because I'll report that to Fedora (upstream bug https://bugzilla.redhat.com/show_bug.cgi?id=1313434 ). If alsa 1.1.0 is required they should consider enabling CONFIG_ACPI_REV_OVERRIDE_POSSIBLE again.
Comment 11 Raymond 2016-03-23 13:35:01 UTC
any alsa-info when running in 4.3 ?


https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/log/sound/pci/hda?qt=grep&q=xps+13
Comment 12 Enrico Tagliavini 2016-03-23 14:20:03 UTC
Created attachment 210431 [details]
alsa-info.sh output for kernel 4.3.6

As requested :)
Comment 13 Enrico Tagliavini 2016-03-23 14:38:08 UTC
Created attachment 210441 [details]
alsa-info.sh output for kernel 4.4.5 plus UCM config file added

I put the ucm config files for broadwell-rt286 from alsa-lib 1.1.0 archive into /usr/share/alsa/ucm (but still using Fedora stock alsa-lib 1.0.29). Now pulseaudio detects the headphones output and input correctly. In particular the input shows Ports "Main Microphone" and "Handset Microphone" (a bit misleading naming for this tbh. output says Speakers and headphones which is more appropriate for a laptop).

However automatic switch between speakers and headphones, for both input and output, when connecting the audio jack (the standard 3.5 mm port on the laptop side). But I still have to apply the config change in pulseaudio you mentioned.

Anyway switching port manually in pavucontrol seems to work as expected.
Comment 14 Raymond 2016-03-23 16:19:00 UTC
Codec: Realtek ALC3263 
Address: 0
 AFG Function Id: 0x1 (unsol 1) 
Vendor Id: 0x10ec0288
 Subsystem Id: 0x10280665 
Revision Id: 0x100003

control.6 {
 iface MIXER 
name 'Capture Source' 
value 'Internal Mic'
 comment { access 'read write' 
type ENUMERATED 
count 1 
item.0 'Headset Mic' item.1 'Headphone Mic' item.2 'Internal Mic' } }

Combo jack seem support headset mic, mic or headphone when you have this comtrol but no auto mic selection as codec cannot differentitate
Comment 16 Raymond 2016-03-24 02:14:07 UTC
You have to ask whether nexus 7 only support headset combo jack when using i2s mode
Comment 17 Raymond 2016-03-24 03:10:44 UTC
The main point is nexus 7 is a mobile phone but your laptop xps 13 with dock station,  can they really use the same ucm conf ?
Comment 18 Enrico Tagliavini 2016-03-24 09:34:04 UTC
(In reply to Raymond from comment #17)
> The main point is nexus 7 is a mobile phone but your laptop xps 13 with dock
> station,  can they really use the same ucm conf ?

Agreed. For the record there is no docking station.
Comment 19 Raymond 2016-03-25 14:16:10 UTC
In I2S mode, it seem not support mic jack but hda mode support

if it cannot differentitate headset and headphone, the combo jack is default to headset in I2S mode but headphone in HDA mode
Comment 20 Raymond 2016-03-26 02:11:06 UTC
control.12 { iface CARD name 'Mic Jack' value false comment { access read type BOOLEAN count 1 } } 

control.13 { iface CARD name 'Headphone Jack' value true comment { access read type BOOLEAN count 1 } }


If mic jack return jack state of headset mic, it should return same value as headphone
Comment 21 Raymond 2016-03-26 02:20:38 UTC
control.14 { iface CARD name 'Headset Mic Phantom Jack' value true comment { access read type BOOLEAN count 1 } } 

control.15 { iface CARD name 'Headphone Mic Jack' value false comment { access read type BOOLEAN count 1 } } 

control.16 { iface CARD name 'Internal Mic Phantom Jack' value true comment { access read type BOOLEAN count 1 } }

control.17 { iface CARD name 'Speaker Phantom Jack' value true comment { access read type BOOLEAN count 1 } }



In hda mode, there is no headphone jack, the user have to select capture source according to jack type
Comment 22 Raymond 2016-03-26 02:35:18 UTC
https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/tree/include/sound/jack.h

enum snd_jack_types { 
SND_JACK_HEADPHONE = 0x0001, 
SND_JACK_MICROPHONE = 0x0002, 
SND_JACK_HEADSET = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE,
Comment 23 Enrico Tagliavini 2016-05-02 11:04:49 UTC
Interesting update: I upgraded to Fedora 23, now jack detection works as expected! Pulseaudio will switch port automatically when I plug/unplug my hear plugs.

Notable changes between Fedora 22 and 23 are:
 - kernel upgraded from 4.4.6 to 4.4.8. No idea if anything relevant happened or was backported here
 - alsa user space upgraded to 1.1.1. I did no change to the config files as shipped by this.
 - pulseaudio upgraded from 6.0 to 7.1.

There is still one open question: does it work out of the box for a fresh install? To answer this can I get alsa to "forget" any changes I made to the mixer and roll back to the state a user would get after a fresh install? I don't mind trying.
Comment 24 Enrico Tagliavini 2016-06-29 08:36:09 UTC
According to people commenting on https://bugzilla.redhat.com/show_bug.cgi?id=1313434 even with Fedora 24 this problem is still unsolved, there is no audio working out of the box for this hardware.
Comment 25 mattia.b89 2017-01-21 14:47:09 UTC
Hi, I have a Dell XPS 9343 with Arch Linux (latest software versions).

My actual situation is:
- speaker works out-of-the-box
- microphone does not work out-of-the-box; BUT with this simple steps (see the attached screencast)

I have three question:
1- What is your actual situation?
2- How can I solve the issue?
3- Is this a kernel issue? or alsa? or pulseaudio? or ...?
Comment 26 mattia.b89 2017-01-21 14:50:29 UTC
Created attachment 252691 [details]
screencast

open `pavucontrol`
in the input tab you can see that internal mic is selected but doesn't work
I select external mic entry (notice that nothing is connected)
I select back the main mic
MAGICALLY now it works (growing blue bar)
Comment 27 mattia.b89 2017-01-21 15:01:37 UTC
I forget to say that once I close `pavucontrol`, mic returns to previous non-working status
Comment 28 David Ward 2019-11-29 18:44:58 UTC
Is this issue still occurring on the Dell XPS 9343? Can someone please attach the current output of also-info.sh? The previous logs are quite old now.

Please try with the latest kernel package and with ALSA 1.2.1.1. Please delete the ~/.config/pulse directory and then reboot in order to clear any existing PulseAudio settings. Thank you.
Comment 29 mattia.b89 2019-11-29 20:12:39 UTC
Created attachment 286121 [details]
alsa-info.sh output, kernel 5.3.11, alsa 1.2.1.1
Comment 30 mattia.b89 2019-11-29 20:18:15 UTC
I attached the output as you requested.

Currently, newer kernels config audio as HDA not I2S, thus all works "out-of-the-box".
HDA mode has not been tested; if you tell me how to switch mode, I will test it.
Comment 31 David Ward 2020-01-19 20:45:45 UTC
Created attachment 286905 [details]
Kernel patch to disable ACPI _REV override for Dell XPS 13 9343

(In reply to mattia.b89 from comment #30)
> HDA mode has not been tested; if you tell me how to switch mode, I will test
> it.

Can you please test I2S mode, by applying the attached patch to the kernel?


In particular, does jack detection work? Check the output of:

$ amixer --card broadwellrt286 cget iface=CARD,name='Headphone Jack'
$ amixer --card broadwellrt286 cget iface=CARD,name='Mic Jack'


If you plug in a headset (with a microphone) to the 3.5mm jack, then both values should change from "off" to "on". My assumption is that only the value of "Headphone Jack" will actually change.
Comment 32 mattia.b89 2020-01-28 08:31:33 UTC
(In reply to David Ward from comment #31)
> Created attachment 286905 [details]
> Kernel patch to disable ACPI _REV override for Dell XPS 13 9343
> 
> (In reply to mattia.b89 from comment #30)
> > HDA mode has not been tested; if you tell me how to switch mode, I will
> test
> > it.
> 
> Can you please test I2S mode, by applying the attached patch to the kernel?
> 
> 
> In particular, does jack detection work? Check the output of:
> 
> $ amixer --card broadwellrt286 cget iface=CARD,name='Headphone Jack'
> $ amixer --card broadwellrt286 cget iface=CARD,name='Mic Jack'
> 
> 
> If you plug in a headset (with a microphone) to the 3.5mm jack, then both
> values should change from "off" to "on". My assumption is that only the
> value of "Headphone Jack" will actually change.

@David Ward

Sorry for the delay.
Anyway, now I am here and I have recompiled the kernel with that patch.

Unfortunately, the commands above return me this error: "Invalid card number."
and I am not able to workaround this error by myself.

Can we workaround this last issue?
Comment 33 mattia.b89 2020-02-01 15:59:55 UTC
Thanks to @David Ward, I can post the desired output:


$ amixer --card broadwellrt286 cget iface=CARD,name='Headphone Jack'
numid=13,iface=CARD,name='Headphone Jack'
  ; type=BOOLEAN,access=r-------,values=1
  : values=off
$ amixer --card broadwellrt286 cget iface=CARD,name='Mic Jack'
numid=12,iface=CARD,name='Mic Jack'
  ; type=BOOLEAN,access=r-------,values=1
  : values=off

sometimes dmesg spams messages like this:

haswell-pcm-audio haswell-pcm-audio: FW loaded, mailbox readback FW info: type 01, - version: 00.00, build 77, source commit id: 876ac6906f31a43b6772b23c7c983ce9dcb18a19

then I plug in the headphone w/ mic:

$ amixer --card broadwellrt286 cget iface=CARD,name='Headphone Jack'
numid=13,iface=CARD,name='Headphone Jack'
  ; type=BOOLEAN,access=r-------,values=1
  : values=on
$ amixer --card broadwellrt286 cget iface=CARD,name='Mic Jack'
numid=12,iface=CARD,name='Mic Jack'
  ; type=BOOLEAN,access=r-------,values=1
  : values=off


--->working status recap<---
internal speakers work;
internal mic works ONLY if you switch between the available input sources in the pulseaudio utility (pavucontrol-1:4.0-1)
external headphone works;
external headphone mic does NOT work
Comment 34 David Ward 2020-02-11 04:00:53 UTC
Created attachment 287289 [details]
Kernel patch to fix GPIO2 enable in rt286 driver

(In reply to mattia.b89 from comment #33)
> --->working status recap<---
> internal speakers work;
> internal mic works ONLY if you switch between the available input sources in
> the pulseaudio utility (pavucontrol-1:4.0-1)
> external headphone works;
> external headphone mic does NOT work

Thank you Mattia for confirming.

Can you please try now with the attached patch (in addition to the other one to use I2S mode)?
Comment 35 mattia.b89 2020-02-15 09:36:56 UTC
I tested new kernel (5.5.2-1-ck) with your patches:

$ amixer --card broadwellrt286 cget iface=CARD,name='Headphone Jack'
numid=13,iface=CARD,name='Headphone Jack'
  ; type=BOOLEAN,access=r-------,values=1
  : values=off
$ amixer --card broadwellrt286 cget iface=CARD,name='Mic Jack'
numid=12,iface=CARD,name='Mic Jack'
  ; type=BOOLEAN,access=r-------,values=1
  : values=off
$ amixer --card broadwellrt286 cget iface=CARD,name='Headphone Jack'
numid=13,iface=CARD,name='Headphone Jack'
  ; type=BOOLEAN,access=r-------,values=1
  : values=on
$ amixer --card broadwellrt286 cget iface=CARD,name='Mic Jack'
numid=12,iface=CARD,name='Mic Jack'
  ; type=BOOLEAN,access=r-------,values=1
  : values=on

both internal speaker+mic and external headphone+mic work out-of-the-box now!
Thus I think this issue has been fixed.

ANYWAY, there is one flaw in comparison with "hda" kernel (5.4.18-1-lts):
sound levels, volumes, both for output from earphones and input from their mic are lower.
I attach two screenshots in which you can see the difference of recording sound level.
Comment 36 mattia.b89 2020-02-15 09:37:32 UTC
Created attachment 287405 [details]
hda external mic recording level
Comment 37 mattia.b89 2020-02-15 09:37:55 UTC
Created attachment 287407 [details]
i2s external mic recording level
Comment 38 David Ward 2020-02-24 01:54:50 UTC
(In reply to mattia.b89 from comment #35)
> sound levels, volumes, both for output from earphones and input from their
> mic are lower.

Can you please upgrade to alsa-ucm-conf 1.2.2 and see if this helps? The "AMIC Volume" mixer control is now set to its maximum value (3 instead of 1) when a headset is connected.
Comment 39 mattia.b89 2020-02-24 18:14:38 UTC
I am already with latest version of `alsa-ucm-conf`