Created attachment 244441 [details] patch with ALC3276 HID This device is based on intel atom x5-z8350. According to DSDT there is sound card with HID 10EC3276 Device (RTKC) { Name (_ADR, Zero) // _ADR: Address Name (_HID, "10EC3276") // _HID: Hardware ID Name (_CID, "10EC3276") // _CID: Compatible ID Name (_DDN, "ALC3276") // _DDN: DOS Device Name Name (_SUB, "103C827C") // _SUB: Subsystem ID Name (_PR0, Package (0x01) // _PR0: Power Resources for D0 which in fact is rt5640. So, i added this HID to rt5640.c and sst_acpi.c (see atttached patch). Sound card is now detected and speakers and headphones (but not microphone yet) working fine with amixer settings from here https://github.com/burzumishi/linux-baytrail-flexx10/tree/master/sound/alsa_ctrl aplay -l **** List of PLAYBACK Hardware Devices **** card 0: bytcrrt5640 [bytcr-rt5640], device 0: 1 [] Subdevices: 0/1 Subdevice #0: subdevice #0 card 0: bytcrrt5640 [bytcr-rt5640], device 1: Deep-Buffer Audio (*) [] Subdevices: 1/1 Subdevice #0: subdevice #0
Created attachment 244451 [details] dsdt acpi table from HP x2 10-p000
(In reply to Alexandrov Stanislav from comment #0) > Created attachment 244441 [details] > patch with ALC3276 HID > > This device is based on intel atom x5-z8350. > > According to DSDT there is sound card with HID 10EC3276 > > Device (RTKC) > { > Name (_ADR, Zero) // _ADR: Address > Name (_HID, "10EC3276") // _HID: Hardware ID > Name (_CID, "10EC3276") // _CID: Compatible ID > Name (_DDN, "ALC3276") // _DDN: DOS Device Name > Name (_SUB, "103C827C") // _SUB: Subsystem ID > Name (_PR0, Package (0x01) // _PR0: Power Resources for D0 > > > which in fact is rt5640. > > So, i added this HID to rt5640.c and sst_acpi.c (see atttached patch). Sound > card is now detected and speakers and headphones (but not microphone yet) > working fine with amixer settings from here > https://github.com/burzumishi/linux-baytrail-flexx10/tree/master/sound/ > alsa_ctrl > > aplay -l > **** List of PLAYBACK Hardware Devices **** > card 0: bytcrrt5640 [bytcr-rt5640], device 0: 1 [] > Subdevices: 0/1 > Subdevice #0: subdevice #0 > card 0: bytcrrt5640 [bytcr-rt5640], device 1: Deep-Buffer Audio (*) [] > Subdevices: 1/1 > Subdevice #0: subdevice #0 the patch looks fine to me, can you send these change to alsa-devel please and CC me and Pierre
First time I see this one, thanks for the information. Can you share a human-readable version of your DSDT? Somehow I can't extract the information from the attachment but I do see 10E5640 in the binary. Also send the result of cat /sys/bus/acpi/devices/10EC*/status Last for all kernel patches you need to add the --signoff information to the git-format-patch command or we won't touch your changes. Thanks!
Created attachment 249981 [details] decompiled dsdt table
# cat /sys/bus/acpi/devices/10EC 10EC3276:00/ 10EC5640:00/ 10EC5670:00/ # cat /sys/bus/acpi/devices/10EC*/status 15 0 0
(In reply to Pierre Bossart from comment #3) > First time I see this one, thanks for the information. > Can you share a human-readable version of your DSDT? Somehow I can't extract > the information from the attachment but I do see 10E5640 in the binary. > Also send the result of cat /sys/bus/acpi/devices/10EC*/status > Last for all kernel patches you need to add the --signoff information to the > git-format-patch command or we won't touch your changes. > > Thanks! Thanks for replying. I will resend patch to mailing list with signoff information. Also, internal microphone works fine too, just needed to tweak UCM config. One note here is when sound card is initializing there is some errors in dmesg: [ 2.905339] rt5640 i2c-10EC3276:00: ASoC: no source widget found for DAC L2 Power [ 2.905342] rt5640 i2c-10EC3276:00: ASoC: Failed to add route DAC L2 Power -> direct -> IF2 DAC L [ 2.905350] rt5640 i2c-10EC3276:00: ASoC: no source widget found for DAC R2 Power [ 2.905352] rt5640 i2c-10EC3276:00: ASoC: Failed to add route DAC R2 Power -> direct -> IF2 DAC R But however, this doesn't generate any issues.
Created attachment 250011 [details] dmesg log with patch applied
Can you share the UCM changes? If you are using DMIC this was never tested on my side so it's interesting. For the errors I have no idea, you are not using AIF2 so no sure what it complains. Maybe Bard @ Realtek has an idea.
Created attachment 250041 [details] ucm config
(In reply to Pierre Bossart from comment #8) > Can you share the UCM changes? If you are using DMIC this was never tested > on my side so it's interesting. > > For the errors I have no idea, you are not using AIF2 so no sure what it > complains. Maybe Bard @ Realtek has an idea. I have attached my ucm config, it was slightly modified (added HP/Speaker Channel switch) Umm... looks like i am not using Digital MIC, but internal MIC. Well, if i change in pulseaudio audio input source from internal mic to digital then nothing happens.
you seen to be using a very old UCM file, and I can't figure out which changes were made. Can you try comparing with https://github.com/plbossart/UCM/blob/master/bytcr-rt5640/HiFi and let me know which changes are really necessary? The HP/Speaker Channel switches are already handled, not sure what else you need?
(In reply to Pierre Bossart from comment #11) > you seen to be using a very old UCM file, and I can't figure out which > changes were made. Can you try comparing with > https://github.com/plbossart/UCM/blob/master/bytcr-rt5640/HiFi and let me > know which changes are really necessary? > > The HP/Speaker Channel switches are already handled, not sure what else you > need? With this ucm config Speakers and Headphone playback is working, but for some reason internal microphone is not: i just can't enable microphone in pulseaudio. I'll try to find out what is difference.
you need to try with either INP1 internal mic or INP3 internal mic, they are not equivalent and correspond to different hardware wirings
(In reply to Pierre Bossart from comment #13) > you need to try with either INP1 internal mic or INP3 internal mic, they are > not equivalent and correspond to different hardware wirings do you mean remove/comment INP3 or INP1 from ucm onfig? or just set it as active audio source? Strange, after reboot and series of alsaucm reset/reload/pulseaudio -k microphone works now, but it uses DigitalMics for some reason, and if i change audio input to another microphone and switch it back then it is doesn't work anymore until i kill pulseaudio. I have tried to do next things: 1) Remove all mics from config except DigitalMics: mic works 2) Remove everything except IN1: mic doesn't work 3) Remove everything except IN1, but i have commented out this line:
I am sorry for incomplete post. 3) Remove everything except IN1, but i have commented out this line: cset "name='Mono ADC Capture Switch' on" and microphone works. 4) Remove everything except IN3 and mic doesn't work, but after removing line cset "name='Mono ADC Capture Switch' on" microphone works again. This sound card is definitely not so simple..
(In reply to Alexandrov Stanislav from comment #15) > 4) Remove everything except IN3 and mic doesn't work, but after removing > line > cset "name='Mono ADC Capture Switch' on" microphone works again. That's strange. In theory, 'Mono ADC Capture Switch' should be on if you are using Mono ADC Mixer. Can you dump registers while recording with both 'Mono ADC Capture Switch'on and off cases?
Created attachment 250091 [details] move DAC2 Power to rt5640_dapm_widgets (In reply to Alexandrov Stanislav from comment #6) > One note here is when sound card is initializing there is some errors in > dmesg: > > [ 2.905339] rt5640 i2c-10EC3276:00: ASoC: no source widget found for DAC > L2 Power > [ 2.905342] rt5640 i2c-10EC3276:00: ASoC: Failed to add route DAC L2 > Power -> direct -> IF2 DAC L > [ 2.905350] rt5640 i2c-10EC3276:00: ASoC: no source widget found for DAC > R2 Power > [ 2.905352] rt5640 i2c-10EC3276:00: ASoC: Failed to add route DAC R2 > Power -> direct -> IF2 DAC R > > But however, this doesn't generate any issues. Thanks for the information. It is due to "DAC L2 Power" and "DAC R2 Power" is used by rt5639_specific_dapm_routes[], but is defined in rt5640_specific_dapm_widgets[]. Please apply the attached patch. It should remove the error messages. Thanks.
(In reply to Bard Liao from comment #16) > (In reply to Alexandrov Stanislav from comment #15) > > 4) Remove everything except IN3 and mic doesn't work, but after removing > > line > > cset "name='Mono ADC Capture Switch' on" microphone works again. > > That's strange. In theory, 'Mono ADC Capture Switch' should be on if you are > using Mono ADC Mixer. Can you dump registers while recording with both 'Mono > ADC Capture Switch'on and off cases? Actually, i think this is because i'm using 4.9.0 kernel and "Mono ADC Capture switch" doesn't exist here. Already compiling latest kernel...
(In reply to Bard Liao from comment #17) > > Thanks for the information. It is due to "DAC L2 Power" and "DAC R2 Power" > is used by rt5639_specific_dapm_routes[], but is defined in > rt5640_specific_dapm_widgets[]. Please apply the attached patch. It should > remove the error messages. > > Thanks. Yes. this patch indeed removed that error messages, thanks.
Well, now i have removed digitalmics and handset section in ucm config. Only in1 and in3 mics here. i can change audio source between in1 and in3, microphone works on both of them. This is correct behavior? I thought that this is some kind of hardware ports where microphone connected? then i've added headset section, looks like everything is fine for now: i can switch between in1, in3 and headset microphone. and after that i've added digitalmics section.. i can switch between in1, in3 and headset audio source, but if i switch to digital mic, microphone is still working! After that in1 or in3 doesn't work anymore, but i can switch again to digital mic. Also there is new error in dmesg when enabling/disabling digitalmic on 4.10-rc2 [ 27.801512] rt5640 i2c-10EC3276:00: Failed to set DMIC clock [ 27.801518] rt5640 i2c-10EC3276:00: ASoC: PRE_PMU: DMIC CLK event failed: -22
Created attachment 250111 [details] small diff to HiFi small diff to HiFi ucm config
The patch looks ok, can you send an updated version with your signoff? I don't think you can have Analog and digital mics enabled on the same device, and you should use the configuration matching what the quirk logs tells you in dmesg. If you have analog working with INP1 or INP3 maybe it's because the default mixer value is fine or that I don't disable the input when switching to another. Anyway it's a good problem to have :-) In case there is a dmic, then there is a fix needed, I used to set the sysclk to zero on idle and that should be 24567000. if you want to try replace the zero at this line https://github.com/plbossart/sound/blob/experimental/codecs/sound/soc/intel/boards/bytcr_rt5640.c#L145 by 24576000
(In reply to Pierre Bossart from comment #22) > The patch looks ok, can you send an updated version with your signoff? > > I don't think you can have Analog and digital mics enabled on the same > device, and you should use the configuration matching what the quirk logs > tells you in dmesg. > > If you have analog working with INP1 or INP3 maybe it's because the default > mixer value is fine or that I don't disable the input when switching to > another. Anyway it's a good problem to have :-) > Yes, mic worked because "Stereo ADC MIXL ADC2" and "Stereo ADC MIXR ADC2" were switched on by default and for some reason if i switch between in1, in3 or headset this settings won't switched to 'off'. Only if i switch to dmic and then switch back they switched off. This is strange, because when switching to another audio source pulseaudio executing "DisableSequence" for conflicting devices where "Stereo ADC MIX(L/R) ADC2 Switch off" is present. I'm not sure but this looks like bug inside pulseaudio or maybe alsaucm. Anyway, both microphones: internal digital, and external headset is ok at kernel level. > In case there is a dmic, then there is a fix needed, I used to set the > sysclk to zero on idle and that should be 24567000. if you want to try > replace the zero at this line > https://github.com/plbossart/sound/blob/experimental/codecs/sound/soc/intel/ > boards/bytcr_rt5640.c#L145 > by 24576000 After changing this to 24576000 there is no more errors. But i wonder, there is comment about jack detection... should this feature work already or it is not implemented yet for rt5640?
Created attachment 250261 [details] minor fix for ucm config for rt5640
Jack detection needs multiple quirks and it's not something I have time to work on. But you are welcome to send patches :-) If you want to look https://github.com/plbossart/sound/commits/byt-jack-detection or https://github.com/plbossart/sound/pull/1 Disclaimer: these patches are not been looked at for a while and you will need of manual work to rebase them. Also it's not clear if they can be upstreamed, in general the jack detection is now part of the codec not of the machine driver.
(In reply to Pierre Bossart from comment #25) > Jack detection needs multiple quirks and it's not something I have time to > work on. But you are welcome to send patches :-) > > If you want to look > https://github.com/plbossart/sound/commits/byt-jack-detection or > https://github.com/plbossart/sound/pull/1 > > Disclaimer: these patches are not been looked at for a while and you will > need of manual work to rebase them. Also it's not clear if they can be > upstreamed, in general the jack detection is now part of the codec not of > the machine driver. Thanks, i'll look at this patches and try at least make jack detection work on my notebook.
Any plans to include the sound chip detection patch in mainline? The jack detection part can be added later, I'd imagine.
Oh, I just noticed that the detection part was in fact added in kernel 4.11. It works for me too, but only after I execute the amixer commands mentioned in the first post and try to `aplay` a file on the sound card. I wonder why; before doing that, PulseAudio simply fails to start the ALSA card. And there are a whole bunch of knobs in alsamixer that I can't even begin to understand...
After doing a bit more research, now I know that this audio chip is quite something... And has a whole bunch of variants. The chip is identified as Baytrail CR, even though this hardware (HP x2 210 here, DSDT identical to OP) is Cherry Trail. And ACPI notes an rt5670 as well. That's pretty confusing. But the bytcr-rt5640 driver seems to work. And so far my audio hardware has not spontaneously combusted, either, thankfully! Though while trying things out I did mess with a few knobs in alsamixer, which got me a bit uneasy now. Hopefully `alsaucm reset` and `reload` is enough to clear anything that may be unsafe? And now I also figured out that we're supposed to follow the readme of https://github.com/plbossart/UCM/tree/master/bytcr-rt5640 to set the audio up. Good to know! PulseAudio now has some useful configuration. Speakers work fine here (better than on Windows, even!). The mic doesn't seem to work when set to IN1 or IN3, but it now works with "DigitalMics capture, NOT TESTED", though the sound captured appears to be pretty low even at 100% in pavucontrol. I haven't tested headphones yet.