Bug 71861

Summary: Dell Inspiron 7537 Intel HDA Realtek ALC3223: Loud Pops at startup/shutdown and No Sound [Solved]
Product: Drivers Reporter: Chris M (cmanougian)
Component: Sound(ALSA)Assignee: Jaroslav Kysela (perex)
Status: RESOLVED CODE_FIX    
Severity: normal CC: francescopontillo, tiwai
Priority: P1    
Hardware: x86-64   
OS: Linux   
Kernel Version: 3.14-rc7 Subsystem:
Regression: No Bisected commit-id:
Attachments: alsa-info.sh with --no-upload option
Fix patch
modified patch_realtek.c
Patched patch_realtek.c
Original rc6 patch_realtek.com
Modified rc6 patch_realtek.c
Difference Patch
Fix patch for ALC283 & co
Kailang restore default value for alc283

Description Chris M 2014-03-11 05:25:29 UTC
Created attachment 128911 [details]
alsa-info.sh with --no-upload option

Continuation from https://bugzilla.kernel.org/show_bug.cgi?id=71511

This fairly new Dell Inspiron 15 7000 Series (Inspiron 7537) is having the same issues as the IdeaPad410Y owner was having. There are loud speaker pops at startup and shutdown, and there is no sound at all.

$ cat /proc/asound/cards
 0 [HDMI           ]: HDA-Intel - HDA Intel HDMI
                      HDA Intel HDMI at 0xe3610000 irq 64
 1 [PCH            ]: HDA-Intel - HDA Intel PCH
                      HDA Intel PCH at 0xe3614000 irq 58

$ inxi -A
Audio:     Card-1: Intel Lynx Point-LP HD Audio Controller driver: snd_hda_intel Sound: ALSA ver: k3.14.0-rc6
           Card-2: Intel Haswell-ULT HD Audio Controller driver: snd_hda_intel 


$ speaker-test

speaker-test 1.0.27.2

Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
Using 16 octaves of pink noise
ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
Playback open error: -2,No such file or directory


$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: HDMI [HDA Intel HDMI], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: HDMI [HDA Intel HDMI], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: HDMI [HDA Intel HDMI], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 0: ALC3223 Analog [ALC3223 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0


Please see the attached alsa-info.sh with --no-upload option.

This has been a consistent problem no matter which kernel I've used from 3.12 thru 3.14-rc6.  I'm running Debian Testing/Jessie.
 
Passing model=,generic (note the comma) as a test gets rid of the speaker pops on bootup and shutdown.

Thanks
Comment 1 Takashi Iwai 2014-03-11 09:23:20 UTC
The error from aplay is expected behavior.  The first card is HDMI, and it doesn't match with "default" PCM definition of alsa-lib.  Set the default card to 1, or pass index=1,0 option to snd-hda-intel to swap the devices.

For the noise problem, please try the patch below.  You need the patch in bug 71511 before applying this one.
Comment 2 Takashi Iwai 2014-03-11 09:23:43 UTC
Created attachment 128931 [details]
Fix patch
Comment 3 Chris M 2014-03-12 06:31:20 UTC
Adding "options snd-hda-intel index=1,0" to the alsa-base.conf worked. I have sound.

I tried to manually modify your latest https://github.com/tiwai/sound/blob/master/sound/pci/hda/patch_realtek.c file. The line numbers matched your patches. Then I replaced the RC6 file with my modified file, and got this error at deb creation at the end of compilation:

sound/pci/hda/patch_realtek.c: In function ‘alc_auto_parse_customize_define’:
sound/pci/hda/patch_realtek.c:410:3: error: implicit declaration of function ‘codec_info’ [-Werror=implicit-function-declaration]
   codec_info(codec, "%s: SKU not ready 0x%08x\n",
   ^
sound/pci/hda/patch_realtek.c:435:2: error: implicit declaration of function ‘codec_dbg’ [-Werror=implicit-function-declaration]
  codec_dbg(codec, "SKU: Nid=0x%x sku_cfg=0x%08x\n",
  ^
sound/pci/hda/patch_realtek.c: In function ‘alc272_fixup_mario’:
sound/pci/hda/patch_realtek.c:4967:3: error: implicit declaration of function ‘codec_warn’ [-Werror=implicit-function-declaration]
   codec_warn(codec, "failed to override amp caps for NID 0x2\n");
   ^
cc1: some warnings being treated as errors
make[5]: *** [sound/pci/hda/patch_realtek.o] Error 1
make[4]: *** [sound/pci/hda] Error 2
make[3]: *** [sound/pci] Error 2
make[2]: *** [sound] Error 2
make[1]: *** [deb-pkg] Error 2
make: *** [deb-pkg] Error 2


So I'm assuming manually modifying won't work (or I screwed it up).

Long way of asking how to apply the patch. What's the easiest way to apply the patch(s) prior to compilation?

Thanks again. For a short term fix, I'll apply the options snd-hda-intel model=,generic.
Comment 4 Takashi Iwai 2014-03-12 06:52:28 UTC
You just need to apply two patches on the top of 3.14-rc6 (or later).
    https://bugzilla.kernel.org/attachment.cgi?id=128271
and
    https://bugzilla.kernel.org/attachment.cgi?id=128931

The model=,generic option will lose some quirks for your microphone, so it's not perfect, I guess.
Comment 5 Chris M 2014-03-12 06:57:50 UTC
Created attachment 129101 [details]
modified patch_realtek.c

snd-hda-intel model=,generic didn't work.

If I restart, I get pops. If I shut down and then hard reboot, there are no pops.

I'll have to work on applying the patch. My modified patch is attached.
Comment 6 Takashi Iwai 2014-03-12 07:14:33 UTC
(In reply to Chris M from comment #5)
> snd-hda-intel model=,generic didn't work.
> 
> If I restart, I get pops. If I shut down and then hard reboot, there are no
> pops.

This sounds like a contradiction to the original bug description.  What is the correct state?
Comment 7 Chris M 2014-03-12 14:27:33 UTC
I thought I was home free last night. The compilation error screwed me up.  I'll need to run it a few ways and report back.  After getting the sound to work, but failing on the compilation, I remarked out the snd-hda-intel model=,generic. Then I threw it back in, and then got no sound (but flash video played with no sound). It was late (early this AM), and I'm pushing to get this in before the kernel goes stable. I'll have to not worry about that and take my time.

Your latest at https://github.com/tiwai/sound/blob/master/sound/pci/hda/patch_realtek.c already included the 1st patch. So I used that, and only applied the 2nd patch. To save time, can you attach a fully modified patch_realtek.c ?  I'll compile with that in place of what's in the RC6. I think my modified file was faulty.

If I fresh compile with a good patch_realtek.c, and the compilation works, do you want me to comment out snd-hda-intel model=,generic (or any variation like model=generic) before re-booting?
Comment 8 Takashi Iwai 2014-03-12 14:31:02 UTC
The master branch contains all changes including the changes for 3.15.  It's incompatible with 3.14-base.  If any, you could pick up for-linus branch instead.
Comment 9 Chris M 2014-03-13 04:27:27 UTC
Takashi, I needed a good night sleep. I grabbed this https://raw.github.com/torvalds/linux/master/sound/pci/hda/patch_realtek.c, and then applied your patch for the Inspiron 7537. It compiled without a problem.

I installed the rc6 kernel, and reestablished "options snd-hda-intel model=,generic".

I rebooted multiple times. It's all good. No speaker pops at all, and sound works great.

Good to go. Thanks for helping me catch the right fish.
Comment 10 Chris M 2014-03-13 06:35:04 UTC
Takashi, is the patch supposed to take care of the popping without passing options snd-hda-intel model=,generic ?

If so, and I remark out options snd-hda-intel model=,generic , there is no pop on startup. But if I reboot, it pops on the way out on reboot. Also, if I try to shutdown completely, the computer hangs at halt.

I think the patch was intended to replace options snd-hda-intel model=,generic.
Comment 11 Chris M 2014-03-13 15:30:58 UTC
Created attachment 129291 [details]
Patched patch_realtek.c

Takashi, I saw that you posted the patch at http://blog.gmane.org/gmane.linux.alsa.devel

Sorry if I jumped the gun. I don't think the hang on shutdown is related to this. No errors were observed related to sound during compilation. There may be something else in the rc6 kernel at play.

I have attached the patched patch_realtek.c file.

Again, if the patch is supposed to obviate the need for passing options snd-hda-intel model=,generic, there's a pop on shutdown, but not bootup/startup.

As far as my shutdown issue is concerned, alsa seems to be unloading fine. I'll look at my /var/log/ logs later.
Comment 12 Takashi Iwai 2014-03-13 15:36:55 UTC
So, it reduces only the noise at booting?  (I don't know why you mention "the hang on shutdown".  No such thing is written in the patch at all...)

Please don't paste the full patch_realtek.c.  It's almost useless.  Please give the real "patch", the diff between patched and unpatched files.
Comment 13 Chris M 2014-03-14 06:12:40 UTC
Yes, it reduces the noise at booting, only.

I'll have to read up of posting a Diff. But I installed KDiff3 just to double check this, and I'm pretty sure I got it right.

My line number are different than yours:

3864	ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
3865	ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
3866	ALC269_FIXUP_HEADSET_MODE,

vs.

3864	ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
3865	ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
3866	ALC283_FIXUP_DELL1_SHUTUP,
3867    ALC269_FIXUP_HEADSET_MODE,

and...

4085		.chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
4086	},
4087	[ALC269_FIXUP_HEADSET_MODE] = {

vs.

4085		.chained = true,
4086		.chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
4087	},
4088     [ALC283_FIXUP_DELL1_SHUTUP] = {
4089            .type = HDA_FIXUP_FUNC,
4090            .v.func = alc_fixup_no_shutup,
4091            .chained = true,
4092            .chain_id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
4093    },
4094    [ALC269_FIXUP_HEADSET_MODE] = {

and...

4309   SND_PCI_QUIRK(0x1028, 0x05f9, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),

vs.

4316   SND_PCI_QUIRK(0x1028, 0x05f9, "Dell Inspiron 7537", ALC283_FIXUP_DELL1_SHUTUP),


The lines don't exactly line up in the last one (4309 vs. 4316), but they don't in yours (4343 vs. 4350).

Not sure what's going on.
Comment 14 Takashi Iwai 2014-03-14 07:25:42 UTC
A proper patch is created by the "diff" program.
   % diff -up oldfile newfile > file.patch
Comment 15 Chris M 2014-03-15 20:05:29 UTC
Created attachment 129521 [details]
Original rc6 patch_realtek.com

Original patch_realtek.com that came with the rc6.
Comment 16 Chris M 2014-03-15 20:07:07 UTC
Created attachment 129531 [details]
Modified rc6 patch_realtek.c

Modified rc6 patch_realtek.c
Comment 17 Chris M 2014-03-15 20:47:13 UTC
Created attachment 129541 [details]
Difference Patch

Test patch from unmodified rc6 and modified rc6
Comment 18 Chris M 2014-03-15 21:04:19 UTC
Takashi, after hacking away at it (I used Meld to create a diff between the unmodified rc6 patch_realtek.c and modified rc6 patch_realtek.c), I was able to create a diff - see above Comment 17. Since I used the "virgin" patch, I applied both patches you created for the IdeaPad410Y and the Inspiron 7537.

I recompiled the rc6 kernel - no problem. I'm still getting the pop on shutdown/reboot. Again, the pop is not happening at startup.

One thing I noticed was the ALC283_FIXUP_DELL1_SHUTUP. When I boot up Xubuntu, alsamixer also shows ALC283, but should ours reference ALC3223?

options snd-hda-intel model=,generic has been commented out.
Comment 19 Takashi Iwai 2014-03-17 10:45:37 UTC
OK, then could you try the patch below?  Apply it to 3.14-rc6 (or rc7) cleanly without other patches, and see whether this alone fixes the issue.  At least, the boot noise issue might be fixed by this.

You can combine with the previous patch if the new patch doesn't suffice alone.  They don't conflict with each other.
Comment 20 Takashi Iwai 2014-03-17 10:48:07 UTC
Created attachment 129701 [details]
Fix patch for ALC283 & co
Comment 21 Chris M 2014-03-18 04:57:26 UTC
Created attachment 129891 [details]
Kailang restore default value for alc283

Takashi, that patch alone worked perfectly. I applied it to the rc7 kernel.

You're good to go.

Thanks, and thanks to Kailang.
Comment 22 Takashi Iwai 2014-03-18 07:09:28 UTC
Thanks, good to hear.  The merge of the patch to the upstream will be likely postponed to 3.15-rc1, but it won't be lost :)
Comment 23 Chris M 2014-03-18 17:41:36 UTC
Takashi, OK.  If it's possible to get this into 3.14, it would be great if you would.

I don't need this now, for sure. The concern is that Debian freezes the Testing kernel before the general Testing freeze (scheduled for 11/05/14), and it's looking likely that 3.14 will be the kernel for Jessie.  If so, the embedded fix will be a year or so off.

3.13 just came into Testing on 3/14. It's possible 3.15 just makes it into Testing, but I'm guessing not.

No problem if you can't do that.

Thanks again.
Comment 24 Francesco 2015-03-20 21:20:10 UTC
Has this fix been included in kernel 3.16? My Realtek ALC3223 can't output audio to speakers, only headphones work.