[03:11] * shriekout $decode(s60gwKe068fRILDHtOPAzLTZISEhDQpuaWNrILDHtOMNCnF1aXQgOrDHtOMgx9ewocfXsKE=,m) === yofel_ is now known as yofel === mac_v is now known as \vish [22:16] (sorry, waylaid by travel wifi) [22:17] Welcome to this $timeofday's impromptu session on triaging ALSA bugs in Ubuntu and submitting fixes upstream [22:17] A couple things to note: you'll need ubuntu-dev-tools, patchutils, git-core installed [22:18] you'll also need some familiarity with C, though it doesn't need to be deep magic guru stuff [22:19] Agendum: 1. Low-hanging fruit: bugs with known-working quirks commented in the bug reports [22:19] 2. Not really fruit: Powerdown bugs [22:19] 3. Submitting patches upstream [22:21] Some required reading: https://wiki.ubuntu.com/DebuggingSoundProblems, in particular https://wiki.ubuntu.com/DebuggingSoundProblems/KarmicCaveats [22:22] Next, free space requirements: you'll need about 300 MB free for git trees [22:24] We'll be checking out three git trees: upstream linux-2.6 (Linus's tree), sound-2.6 (upstream ALSA kernel tree), ubuntu-lucid [22:24] After ensuring that you have the prerequisites above installed, you'll do: [22:24] git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git linux-2.6.git [22:25] then: [22:25] git clone --referenc linux-2.6.git/ git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6.git [22:25] sorry, that's --reference [22:26] then: git clone --reference linux-2.6.git/ git://kernel.ubuntu.com/ubuntu/ubuntu-lucid.git [22:27] Let's look at examples in the meantime (if you're waiting for them to complete) [22:28] crimsun: can I interrupt [22:28] https://bugs.launchpad.net/bugs/487884 [22:28] Launchpad bug 487884 in linux "No sound driver for Gateway 4525GZ" [Low,Fix committed] [22:28] Ubuntu bug 487884 in linux "No sound driver for Gateway 4525GZ" [Low,Fix committed] [22:28] Ubuntu bug 487884 in linux "No sound driver for Gateway 4525GZ" [Low,Fix committed] https://launchpad.net/bugs/487884 [22:28] Launchpad bug 487884 in linux "No sound driver for Gateway 4525GZ" [Low,Fix committed] https://launchpad.net/bugs/487884 [22:28] Launchpad bug 487884 in linux "No sound driver for Gateway 4525GZ" [Low,Fix committed] https://launchpad.net/bugs/487884 [22:29] apparle: can it wait for about 10 minutes? [22:29] crimsun: no problem... [22:30] apparle: thanks [22:30] So, some background: [22:30] there are a lot of AC'97 codecs that need some sort of quirk applied [22:31] About four to five years ago, I spent a good long while getting the most common ones applied [22:32] Those were mostly binding of 'Master' and 'Headphone' mixer controls and binding 'Headphone' to an indicator LED (for mute status) [22:32] These days, for AC'97, we'll see a few stragglers that need inverted external amplifier power down (EAPD) applied [22:33] This symptom most frequently manifests itself in needing 'External Amplifier' to be muted for sound to be audible. [22:33] There's an existing quirk for this called inv_eapd [22:34] If you were to pass this option on the command line or in /etc/modprobe.d/alsa-base.conf, it would look similar to: [22:34] ac97_quirk=inv_eapd [22:34] e.g., modprobe snd-intel8x0 ac97_quirk=inv_eapd [22:35] [after which point you could use 'External Amplifier' being unmuted for sound to be audible, which is the accepted norm] [22:36] most AC'97 quirks live in their respective drivers [22:37] the three most common ones are sound/pci/intel8x0.c, sound/pci/atiixp.c, and sound/pci/via82xx.c [though there are numerous others in sound/pci/] [22:37] so, for bug 487884, we're looking specifically at applying this quirk [22:37] Launchpad bug 487884 in linux "No sound driver for Gateway 4525GZ" [Low,Fix committed] https://launchpad.net/bugs/487884 [22:37] Launchpad bug 487884 in linux "No sound driver for Gateway 4525GZ" [Low,Fix committed] https://launchpad.net/bugs/487884 [22:37] Launchpad bug 487884 in linux "No sound driver for Gateway 4525GZ" [Low,Fix committed] https://launchpad.net/bugs/487884 [22:37] Ubuntu bug 487884 in linux "No sound driver for Gateway 4525GZ" [Low,Fix committed] [22:37] Launchpad bug 487884 in linux "No sound driver for Gateway 4525GZ" [Low,Fix committed] [22:37] Launchpad bug 487884 in linux "No sound driver for Gateway 4525GZ" [Low,Fix committed] https://launchpad.net/bugs/487884 [22:37] Ubuntu bug 487884 in linux "No sound driver for Gateway 4525GZ" [Low,Fix committed] https://launchpad.net/bugs/487884 [22:38] http://launchpadlibrarian.net/36040747/Card0.Codecs.codec97.0.ac97.0.0.txt has the important information [22:39] Namely, we need the PCI SSID, which in this case is 0x161f203a [22:39] we next look at the source file that needs to be modified, which is sound/pci/intel8x0.c [22:40] at this point, we should change working directories to wherever we cloned ubuntu-lucid.git [22:40] next, we'll create a separate branch (some people use topic namespace) [22:40] $ git checkout -b lp487884 [22:41] then, we'll edit the source file [22:41] $ $EDITOR sound/pci/intel8x0.c [22:41] AC'97 quirks live in the ac97_quirks[] struct, and they should be ordered by subvendor ID [22:42] From this point the addition should be fairly straightforward. Add another stanza, fill in the human-friendly model name, add the quirk type [22:42] $ git commit -a -e -s [22:43] The first line of your commit message should briefly describe the change [22:43] ALSA: intel8x0: Mute External Amplifier by default for Gateway 4525GZ [22:44] the next line (delimited by a blank line) should be the BugLink id, which is something that is Ubuntu syntax-specific for the kernel team [22:44] BugLink: https://bugs.launchpad.net/bugs/487884 [22:44] Launchpad bug 487884 in linux "No sound driver for Gateway 4525GZ" [Low,Fix committed] [22:44] Ubuntu bug 487884 in linux "No sound driver for Gateway 4525GZ" [Low,Fix committed] [22:44] Ubuntu bug 487884 in linux "No sound driver for Gateway 4525GZ" [Low,Fix committed] https://launchpad.net/bugs/487884 [22:44] Launchpad bug 487884 in linux "No sound driver for Gateway 4525GZ" [Low,Fix committed] https://launchpad.net/bugs/487884 [22:44] Launchpad bug 487884 in linux "No sound driver for Gateway 4525GZ" [Low,Fix committed] https://launchpad.net/bugs/487884 [22:44] Next, describe the change: [22:44] This Gateway model needs External Amplifier muted for audible playback, [22:44] so set the inv_eapd quirk for it. [22:45] . [22:45] Make sure that you keep lines wrapped at 80 characters; many maintainers prefer 72 characters. [22:46] Finally, if the change is very simple (like this one), then you should submit it to the stable tree so that it ends up in Ubuntu [22:46] Above your Signed-off-by line you should have: [22:46] CC: stable@kernel.org [22:47] . [22:47] After saving your commit message, the change will be committed, and you can generate a patch to send upstream. [22:47] There are several ways of doing this, but upstream ALSA likes separate patches. [22:48] So, we'll use: [22:48] git format-patch -o ~ master [22:48] You'll end up with ~/0001-ALSA-... [22:50] This is the patch that you'll attach to your e-mail message. The e-mail should be sent to alsa-devel@alsa-project.org, with Takashi Iwai and myself CCed [22:50] And that's pretty much the process for bite-sized fixes. [22:51] apparle: you're up [22:51] got it clear [22:51] but I am having a problem [22:51] what to do abt this [22:51] git.kernel.org[0: 149.20.20.136]: errno=Connection refused git.kernel.org[0: 199.6.1.166]: errno=Connection refused git.kernel.org[0: 204.152.191.40]: errno=Connection refused git.kernel.org[0: 130.239.17.7]: errno=Connection refused fatal: unable to connect a socket (Connection refused) [22:52] I am behing a stringent firewall(university) [22:52] apparle: you'll need to use another protocol, then, like http [22:53] (which is unfortunate, because it's less optimized, but it's one of the few ways to continue if you're behind a firewall) [22:54] Initialized empty Git repository in /home/apparle/linux-2.6.git/.git/ fatal: http://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git/info/refs download error - Failed connect to git.kernel.org:80; Operation now in progress [22:54] what to do? [22:55] apparle: firewalls are a bit beyond the scope of this discussion [22:55] in brief, see git-clone(1)'s "GIT URLS" section for a description [22:56] crimsun: you mean in the man page? [22:56] apparle: yes [22:56] Okay, continuing. [22:57] The next bug we'll consider is no more difficult, but it moves into problematic areas of HDA. [22:58] In bug 461062, we need to ensure that the reporter's hardware doesn't suffer from distortion when the PCM volume is set to max. [22:58] Launchpad bug 461062 in linux "0x11d41981 on 0x103c30d8 misreports dB information, needs PCM capped at 0 dB" [Undecided,Fix committed] https://launchpad.net/bugs/461062 [22:58] Launchpad bug 461062 in linux "0x11d41981 on 0x103c30d8 misreports dB information, needs PCM capped at 0 dB" [Undecided,Fix committed] https://launchpad.net/bugs/461062 [22:58] Launchpad bug 461062 in linux "0x11d41981 on 0x103c30d8 misreports dB information, needs PCM capped at 0 dB" [Undecided,Fix committed] [22:58] Ubuntu bug 461062 in linux "0x11d41981 on 0x103c30d8 misreports dB information, needs PCM capped at 0 dB" [Undecided,Fix committed] [22:58] Launchpad bug 461062 in linux "0x11d41981 on 0x103c30d8 misreports dB information, needs PCM capped at 0 dB" [Undecided,Fix committed] https://launchpad.net/bugs/461062 [22:58] Launchpad bug 461062 in linux "0x11d41981 on 0x103c30d8 misreports dB information, needs PCM capped at 0 dB" [Undecided,Fix committed] https://launchpad.net/bugs/461062 [22:58] Ubuntu bug 461062 in linux "0x11d41981 on 0x103c30d8 misreports dB information, needs PCM capped at 0 dB" [Undecided,Fix committed] https://launchpad.net/bugs/461062 [22:59] To do this, we need to inspect the reporter's HDA codec, which is attached at http://launchpadlibrarian.net/34413094/Card0.Codecs.codec.0.txt [23:00] So, I'll walk through doing this from the top. [23:00] Firstly, we need to know which codec patch to modify. That information is given at the beginning of the codec information, so, Analog Devices AD1981 [23:01] When you've triaged enough bugs, you no longer look at the ^Codec line but at the ^Vendor Id line [23:01] So, knowing that it's an Analog Devices HDA codec, we'll need to look at sound/pci/hda/patch_analog.c [23:03] Next, we look at the ^Vendor Id line and match it with the entry in the snd_hda_preset_analog[] struct [23:03] (which is located toward the end of the file) [23:03] { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 }, [23:04] so, now we know which function to inspect (patch_ad1981()) [23:04] We need one more piece of information: whether the reporter's hardware is using a specific model quirk. [23:05] To do that, we look at the ^Subsystem Id in the codec output [23:05] In this case, it's 0x103c30d8 [23:06] Now, in patch_ad1981(), ad1981_cfg_tbl[] is used to see if any quirks are necessary [23:07] So we scroll up in the source file to it, and we see that there's a vendor mask already applied: [23:07] SND_PCI_QUIRK_VENDOR(0x103c, "HP nx", AD1981_HP), [23:07] This tells us that we need to look at the AD1981_HP model quirk in patch_ad1981() [23:07] So we return to patch_ad1981() and look at the section for that model. [23:08] Sure enough, there's no existing cap being set for that model. [23:08] Next, we verify our finding again by looking at the codec output [23:10] To do this, we need to look a bit more closely at the pin routing. So, back to the source file, where we look for the mixer setup for the AD1981_HP model quirk [23:10] mixer setups are of type struct snd_kcontrol_new [23:11] so we're looking at ad1981_hp_mixers[] [23:11] Next, find the PCM Playback elements [23:11] The brief version, without referring to the AD1981 data sheet, is that we're looking at the 0x11 node id [23:12] So, go back to the codec output and look at Node 0x11 [23:13] The critical piece of information is in: [23:13] Amp-Out caps: ofs=0x17, nsteps=0x1f, [23:13] so, we need to override the amp setup by using snd_hda_override_amp_caps() [23:14] note that 0x1f will give distortion over and beyond 0x17 [23:14] so we need to cap the nsteps at the offset value [23:14] (the offset value is known as 0 dB) [23:15] so, this function ends up looking like: [23:15] snd_hda_override_amp_caps(codec, 0x11, HDA_INPUT, [23:15] (0x17 << AC_AMPCAP_OFFSET_SHIFT) | [23:15] (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) | [23:15] (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | [23:15] (1 << AC_AMPCAP_MUTE_SHIFT)); [23:16] so we take this addition, put it in the AD1981_HP case of patch_ad1981(), commit the change, and so on. [23:16] (to complicate things, you can also do this from alsactl init, but that's a story for another day) [23:17] For the sake of time, I'm going to skip the powerdown stuff and just send an e-mail to ubuntu-devel@ . [23:17] Anyhow, that's it.