You are not logged in.

#1 2008-05-01 11:31:36

handy
Member
From: Oz
Registered: 2008-03-26
Posts: 719

[SOLVED] An ALSA bug patch that needs converting from Ubuntu to Arch.

A problem with a solution that needs to be adapted to Arch

Due to a bug in ALSA 1.0.16, sound does not work properly on the aluminium iMacs. It does when nicfagn's patch is applied to ALSA 1.0.16 in at least (from what I have read) the following distributions: Ubuntu, Debian & someone has adapted it to Fedora.

Nicfagn's patch is at the bottom of this page it apparently fixes all of the sound problems related to the bug in ALSA 1.0.16, for the aluminium 24" iMacs.

If some kind person would like to have a look at the process that follows & if they don't have an iMac perhaps they could give me instructions regarding the changes required to meet the differences between Arch & Ubuntu, then I can do it, test it & make the information available for other Arch iMac users. 

Many thanks in advance to you...

I copied the following from the Ubuntu forum & edited it somewhat as it was initially written for ALSA version 1.0.14, then 1.0.15.
_____________________________________

Download alsa-driver-1.0.16 sources from:

    ftp://ftp.alsa-project.org/pub/drive...1.0.16.tar.bz2

Expand the sources with:

tar --bzip2 -xvf alsa-driver-1.0.16.tar.bz2

Install the libc6 developer libraries and the patch program, if missing:

sudo apt-get install libc6-dev patch

Download the attached patch, copy it into alsa-driver-1.0.16/alsa-kernel/pci/hda and cd to that directory.
Apply the patch with:

patch < alsa-1.0.16-imac.txt

Cd back to the top alsa-driver-1.0.16 dir and do a configure for the HDA intel chipset:

./configure --with-cards=hda-intel

Compile with the command:

make -j3

For Gutsy or later, a little adjustment is needed to use the compiled module instead of the one shipped with the system (in previous versions this command should fail):

sudo mv -v /lib/modules/$(uname -r)/ubuntu/media/snd-hda-intel/snd-hda-intel{,-ubuntu}.ko

Install the compiled modules:

sudo make install-modules

Reboot and you should be able to hear sound from the speakears, & from headphones and mic works now, at least according to reports from other users.

_________________________________________________

The patch for ALSA 1.0.16 is below:
_________________________________________________


diff -ru alsa-driver-1.0.16/alsa-kernel/pci/hda/patch_realtek.c alsa-driver-1.0.16-patched/alsa-kernel/pci/hda/patch_realtek.c
--- alsa-driver-1.0.16/alsa-kernel/pci/hda/patch_realtek.c    2008-02-05 10:23:24.000000000 +0100
+++ alsa-driver-1.0.16-patched/alsa-kernel/pci/hda/patch_realtek.c    2008-03-05 12:03:05.000000000 +0100
@@ -175,6 +175,7 @@
    ALC885_MACPRO,
    ALC885_MBP3,
    ALC885_IMAC24,
+    ALC885_IMAC_M07,
    ALC882_AUTO,
    ALC882_MODEL_LAST,
};
@@ -5717,6 +5718,56 @@
        alc885_imac24_automute(codec);
}

+/* iMac (mid 2007) mixer. */
+static struct snd_kcontrol_new alc885_imac_m07_mixer[] = {
+    HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
+    HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
+    { } /* end */
+};
+
+/* iMac (mid 2007) init verbs. */
+static struct hda_verb alc885_imac_m07_init_verbs[] = {
+    /* Internal speakers: output 0 (0x0c) */
+    {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
+    {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+    {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
+    /* Internal speakers: output 0 (0x0c) */
+    {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
+    {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+    {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
+    /* Headphone: output 0 (0x0c) */
+    {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP | 0x04},
+    {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+    {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
+    {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
+    /* Front Mic: input vref at 80% */
+    {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
+    {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+    { }
+};
+
+/* Toggle speaker-output according to the hp-jack state */
+static void alc885_imac_m07_automute(struct hda_codec *codec)
+{
+     unsigned int present;
+
+     present = snd_hda_codec_read(codec, 0x15, 0,
+                     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
+    snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
+                 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
+    snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
+                 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
+}
+
+/* Processes unsolicited events. */
+static void alc885_imac_m07_unsol_event(struct hda_codec *codec,
+                      unsigned int res)
+{
+    /* Headphone insertion or removal. */
+    if ((res >> 26) == ALC880_HP_EVENT)
+        alc885_imac_m07_automute(codec);
+}
+
static void alc885_mbp3_automute(struct hda_codec *codec)
{
      unsigned int present;
@@ -5861,6 +5912,13 @@
    alc885_imac24_automute(codec);
}

+/* set up GPIO and update auto-muting at initialization */
+static void alc885_imac_m07_init_hook(struct hda_codec *codec)
+{
+    alc885_macpro_init_hook(codec);
+    alc885_imac_m07_automute(codec);
+}
+
/*
  * generic initialization of ADC, input mixers and output mixers
  */
@@ -5996,6 +6054,7 @@
    [ALC885_MACPRO]        = "macpro",
    [ALC885_MBP3]        = "mbp3",
    [ALC885_IMAC24]        = "imac24",
+    [ALC885_IMAC_M07]    = "imac-m07",
    [ALC882_AUTO]        = "auto",
};

@@ -6099,6 +6158,19 @@
        .unsol_event = alc885_imac24_unsol_event,
        .init_hook = alc885_imac24_init_hook,
    },
+    [ALC885_IMAC_M07] = {
+        .mixers = { alc885_imac_m07_mixer },
+        .init_verbs = { alc885_imac_m07_init_verbs },
+        .num_dacs = ARRAY_SIZE(alc882_dac_nids),
+        .dac_nids = alc882_dac_nids,
+        .dig_out_nid = ALC882_DIGOUT_NID,
+        .dig_in_nid = ALC882_DIGIN_NID,
+        .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
+        .channel_mode = alc882_ch_modes,
+        .input_mux = &alc882_capture_source,
+        .unsol_event = alc885_imac_m07_unsol_event,
+        .init_hook = alc885_imac_m07_init_hook,
+    },
    [ALC882_TARGA] = {
        .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
                alc882_capture_mixer },
@@ -6317,13 +6389,17 @@
        case 0x106b0c00: /* Mac Pro */
            board_config = ALC885_MACPRO;
            break;
-        case 0x106b1000: /* iMac 24 */
+        case 0x106b1000: /* iMac 24'' late 2006 */
            board_config = ALC885_IMAC24;
            break;
        case 0x106b00a1: /* Macbook */
        case 0x106b2c00: /* Macbook Pro rev3 */
            board_config = ALC885_MBP3;
            break;
+        case 0x106b3000: /* iMac 20 '' mid 2007 */
+        case 0x106b3200: /* iMac 24 '' mid 2007 */
+            board_config = ALC885_IMAC_M07;
+            break;
        default:
            printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
                            "trying auto-probe from BIOS...\n");

Last edited by handy (2008-10-17 06:31:59)


I used to be surprised that I was still surprised by my own stupidity, finding it strangely refreshing.
Well, now I don't find it refreshing.
I'm over it!

Offline

#2 2008-05-01 11:52:44

dolby
Member
From: 1992
Registered: 2006-08-08
Posts: 1,581

Re: [SOLVED] An ALSA bug patch that needs converting from Ubuntu to Arch.

thats really great, but you should have made that post elsewhere and that is the alsa bug tracker


There shouldn't be any reason to learn more editor types than emacs or vi -- mg (1)
[You learn that sarcasm does not often work well in international forums.  That is why we avoid it. -- ewaller (arch linux forum moderator)

Offline

#3 2008-05-01 12:02:49

handy
Member
From: Oz
Registered: 2008-03-26
Posts: 719

Re: [SOLVED] An ALSA bug patch that needs converting from Ubuntu to Arch.

dolby wrote:

thats really great, but you should have made that post elsewhere and that is the alsa bug tracker

I'm sorry for posting in the wrong place, would you be so kind as to tell me where should I have posted it please?

The attached source for the ALSA patch has been modified & is required for the process, I have used it in Ubuntu.

Last edited by handy (2008-05-01 12:20:27)


I used to be surprised that I was still surprised by my own stupidity, finding it strangely refreshing.
Well, now I don't find it refreshing.
I'm over it!

Offline

#4 2008-05-01 12:08:21

shining
Pacman Developer
Registered: 2006-05-10
Posts: 2,043

Re: [SOLVED] An ALSA bug patch that needs converting from Ubuntu to Arch.

Why exactly are you posting ubuntu specific instructions to arch forum?
Just give the link to the thread so someone can go take the patch if he wants.

What we need to know is where this patch comes from and whether it has already been integrated / submitted to upstream.
When you have these information, you can post them in a new task on Arch bug tracker.


pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))

Offline

#5 2008-05-01 12:19:22

handy
Member
From: Oz
Registered: 2008-03-26
Posts: 719

Re: [SOLVED] An ALSA bug patch that needs converting from Ubuntu to Arch.

shining wrote:

Why exactly are you posting ubuntu specific instructions to arch forum?
Just give the link to the thread so someone can go take the patch if he wants.

What we need to know is where this patch comes from and whether it has already been integrated / submitted to upstream.
When you have these information, you can post them in a new task on Arch bug tracker.

I am trying to get sound working properly on my iMac, I have used this patch on Ubuntu on this iMac, I now want to be able to use it on Arch.  It will also be very helpful to any other iMac owners using Arch. 

I am looking for help in adapting the patching process from that of Ubuntu to suit Arch.  I am a new Arch user & therefore am requesting help, as I learn more I will be able to give more help back to the Arch community.

I have PM'd nicfagin the writer of the patch about this here thread, he has been working with the Ubuntu dev's I believe & I'm sure that his patch has gone upstream.  But it has not come down stream yet, so that is why this thread exists.

Here is a link to the post I copied & edited from the Ubuntu forums:

http://ubuntuforums.org/showpost.php?p= … ostcount=5

Last edited by handy (2008-05-01 12:23:36)


I used to be surprised that I was still surprised by my own stupidity, finding it strangely refreshing.
Well, now I don't find it refreshing.
I'm over it!

Offline

#6 2008-05-01 12:20:54

dolby
Member
From: 1992
Registered: 2006-08-08
Posts: 1,581

Re: [SOLVED] An ALSA bug patch that needs converting from Ubuntu to Arch.


There shouldn't be any reason to learn more editor types than emacs or vi -- mg (1)
[You learn that sarcasm does not often work well in international forums.  That is why we avoid it. -- ewaller (arch linux forum moderator)

Offline

#7 2008-05-01 12:25:19

handy
Member
From: Oz
Registered: 2008-03-26
Posts: 719

Re: [SOLVED] An ALSA bug patch that needs converting from Ubuntu to Arch.

I believe that it has already been presented to them, but it has not come down stream yet & I don't want to wait for it.


I used to be surprised that I was still surprised by my own stupidity, finding it strangely refreshing.
Well, now I don't find it refreshing.
I'm over it!

Offline

#8 2008-05-01 12:50:15

dolby
Member
From: 1992
Registered: 2006-08-08
Posts: 1,581

Re: [SOLVED] An ALSA bug patch that needs converting from Ubuntu to Arch.

i suggest making a bug report on the archlinux bug tracker containing a link to the alsa bug tracker with the submitted to upstream patch. thats the best chances you got. making forum posts like that dont get you anywhere

Last edited by dolby (2008-05-01 12:50:39)


There shouldn't be any reason to learn more editor types than emacs or vi -- mg (1)
[You learn that sarcasm does not often work well in international forums.  That is why we avoid it. -- ewaller (arch linux forum moderator)

Offline

#9 2008-05-01 14:57:02

handy
Member
From: Oz
Registered: 2008-03-26
Posts: 719

Re: [SOLVED] An ALSA bug patch that needs converting from Ubuntu to Arch.

dolby wrote:

i suggest making a bug report on the archlinux bug tracker containing a link to the alsa bug tracker with the submitted to upstream patch. thats the best chances you got. making forum posts like that dont get you anywhere

Thanks for your reply dolby, I'll do as you suggest.

I am waiting on a reply from nicfagin which will hopefully confirm in detail that the patch has gone upstream to the ALSA crew.  After I receive his reply I will proceed with your suggestions.

It would seem that it may not be as simple as I thought it would be to adapt the patching process to Arch; users have been adapting it to other distributions, which is why I thought it was a good idea to start this thread, I expected someone to give me the relevant paths that Arch uses with perhaps a different configuration file name or two, then I would be able to compile & install.

Last edited by handy (2008-05-01 14:58:13)


I used to be surprised that I was still surprised by my own stupidity, finding it strangely refreshing.
Well, now I don't find it refreshing.
I'm over it!

Offline

#10 2008-05-01 15:16:51

tigrmesh
IRC Op
From: Florida, US
Registered: 2007-12-11
Posts: 794

Re: [SOLVED] An ALSA bug patch that needs converting from Ubuntu to Arch.

handy wrote:

It would seem that it may not be as simple as I thought it would be to adapt the patching process to Arch; users have been adapting it to other distributions, which is why I thought it was a good idea to start this thread, I expected someone to give me the relevant paths that Arch uses with perhaps a different configuration file name or two, then I would be able to compile & install.

Ah.  What you want is abs:  http://wiki.archlinux.org/index.php/ABS … ild_System.  The abs tree has changed a bit, so do an
ls /var/abs/extra/*alsa*

to locate the alsa directories.

Offline

#11 2008-05-01 18:45:16

Misfit138
Misfit Emeritus
From: USA
Registered: 2006-11-27
Posts: 4,189

Re: [SOLVED] An ALSA bug patch that needs converting from Ubuntu to Arch.

handy wrote:

It would seem that it may not be as simple as I thought it would be to adapt the patching process to Arch; users have been adapting it to other distributions, which is why I thought it was a good idea to start this thread, I expected someone to give me the relevant paths that Arch uses with perhaps a different configuration file name or two, then I would be able to compile & install.

What you are trying to do should actually be very easy with Arch and ABS..much easier than with Ubuntu, actually. (This is the reason shining and dolby are confused as to why you posted the above inctructions on how to recompile and patch)
If you simply want to patch alsa, recompile and package it up for pacman to install, it should take you a couple of minutes. Just read up on ABS and makepkg in the wiki. Also read: http://wiki.archlinux.org/index.php/Patching_in_ABS
After you feel comfortable with how ABS and makepkg work, edit the PKGBUILD for the package you want to recompile,  put the patch in your build directory, and add a patch script to the PKGBUILD like:
patch -Np1 -i ../name-of.patch || return 1
Put this line after

  cd ${startdir}

Also add the name-of.patch to the end of the source= line in the PKGBUILD. (If you wanna get fancier, add a url for the patch to source=)

Edit: Recompiling and patching manually with 'make'' will work on any distro, but it leaves behind libraries and other files which pacman will be unaware of, which is a bad thing. Down the road, this can and will, lead to headaches. One of Arch's advantages is ABS and makepkg which will create a cleanly pacman-installable .pkg.tar.gz tarball. When you get used to the Arch Way, it will be hard to go back to anything else. wink

Last edited by Misfit138 (2008-05-01 19:06:24)

Offline

#12 2008-05-01 19:56:59

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: [SOLVED] An ALSA bug patch that needs converting from Ubuntu to Arch.

handy wrote:

I expected someone to give me the relevant paths that Arch uses with perhaps a different configuration file name or two, then I would be able to compile & install.

I can't be certain about this, but it's possible you weren't given that information because readers thought you might be able to work that out, as you have an Arch installation to work from.

Just for general clarity - the procedure you describe in the first post patches and compiles the snd_hda_intel.ko kernel module from the alsa-drivers source code, and then places the newly compiled version in /lib/modules/<kernel_version>, overwriting the module provided by the kernel package. This means the abs recommendation given above is not quite as useful, as Arch does not use the alsa-drivers source code in this way. We use the alsa drivers as they are provided by the mainline kernel.

That said, the commands given should work fine - just leave out the line with {,-ubuntu} in it. smile

Offline

#13 2008-05-02 01:25:55

handy
Member
From: Oz
Registered: 2008-03-26
Posts: 719

Re: [SOLVED] An ALSA bug patch that needs converting from Ubuntu to Arch.

A big thanks to tigrmesh, Misfit138 & tomk. cool

It never pays to take anything for granted about another forum users accumulated knowledge! wink

I am still finding my way around the Linux system & Arch is different than any other distro' I have used & it has taught me a lot already.  I expect to stay with Arch for the foreseeable  future. smile

Having received a reply from nicfagn the creator of the patch, which is at the bottom of this post, he told me to use model=mbp3 with ALSA versions 1.0.16 & later, which I am now using, it gives a full alsamixer & the headphones work & kill the sound from the internal iMac speakers.  I did not test line out or mic.

It seems that there is no need for me to compile the patch as per tomk's instructions as the model=mbp3 workaround works for my Alu' 24" iMac, for those with an iMac that it does not work for it looks to be a possibly worthwhile solution to apply the patch, compile & install.

I will update my big iMac post regarding sound in the hope that it makes life easier for another user.

Something I'm not sure about is, is there anymore I can do with the nicfagn's patch?  Should I present it to the Arch bug tracking system, or am I just wasting people's time with it there?

Thanks again for your help.

handy
____________________________________

nicfagn wrote:
handy wrote:

Hi nicfagn,

I have used your ALSA patch on my iMac in the past & am very grateful to you for your effort to help us iMacer's out.

Having recently installed Arch on my iMac I have come up against the same ALSA bug problems.  I have been able to get inferior sound by adding two lines to the /etc/modprobe.conf file, as follows:

alias snd-card-0 snd-hda-intel
options snd-hda-intel model=imac24

I have been writing an ongoing iMac post in the Arch forums, if you are interested it is Post 5:

http://bbs.archlinux.org/viewtopic.php?id=35355

The reason that I am writing to you (now that you have some background info' :-)) is that I have copied your how-to post (edited somewhat 1.0.15 to 16 & so forth) & your patch over to another thread in the Arch forums in an effort to get someone to help me adapt your patching how-to to Arch.  I hope you don't mind & of course if you do I will delete the post if that is your wish.

Here is a link to the post  in question:

http://bbs.archlinux.org/viewtopic.php? … 61#p362361

Also, could you confirm that your patch has gone upstream to the ALSA team? I am under the impression that it has.

Kind regards,

Greg

I'm glad you want to use my patch, so no problem about the arch post.

I didn't push my patch upstream since I don't have access to the specific model for which was written (I have the late 2006 iMac) so I can't reliably verify what it is really working or not, and there are been contrasting reports about the patch effectiveness (at least the 1.0.15 one) on the thread.

On top of that, there is a simpler solution to the problem, if the alsa version is at least 1.0.16: use the model=mbp3 option with the stock alsa snd-hda-intel module (see this post).

The Ubuntu devs did just that in the 8.04 snd-hda-intel module, if I'm not wrong, so you don't have to use the option, but they did that only for the 24'' model and not for the 20'' one or viceversa (these two model have the same sound subsystem), so someone has been left in the cold.

I just looked at the current alsa repository code and there is no support yet for the new Alu Macs. I found a pair of reports in the alsa bug tracker, 0003549 and 0003592 (maybe there are others) but no patch attached.

I wouldn't hold my breath waiting for an upstream solution...;-)

Ciao

Nicola

Thanks Nicola,

The model=mbp3 gave me a full alsamixer setup AND sound lol, unlike model=imac-m07 which left out the sound.:confused:

The volume is a little low & the quality is not great, but that seems to be another ALSA issue across the Linux/BSD board.  At least it can be easily improved using VLC & its equalizer.

I will post a copy of our previous email to the Arch forum & then submit your patch to the Arch bug-tracker system (as I have been asked to do) in a hope that it will apply just a little more pressure on the ALSA team to put a little time in for those affected by the iMac problem.

I'll keep you posted if anything interesting comes up Nicola.

Regards,

Greg


I used to be surprised that I was still surprised by my own stupidity, finding it strangely refreshing.
Well, now I don't find it refreshing.
I'm over it!

Offline

#14 2008-05-07 08:29:06

shining
Pacman Developer
Registered: 2006-05-10
Posts: 2,043

Re: [SOLVED] An ALSA bug patch that needs converting from Ubuntu to Arch.

handy wrote:

Something I'm not sure about is, is there anymore I can do with the nicfagn's patch?  Should I present it to the Arch bug tracking system, or am I just wasting people's time with it there?

The first step was to get more information about that patch, and you did that perfectly.
Now the author said he had his own reasons for not submitting it, so I don't think you should do anything.
If you can simply use model=mbp3 to get it working, that seems like a perfectly reasonable solution.
I also need to specify the model to get my intel chipset fully working (especially for the mic).


pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))

Offline

#15 2008-05-12 07:30:27

handy
Member
From: Oz
Registered: 2008-03-26
Posts: 719

Re: [SOLVED] An ALSA bug patch that needs converting from Ubuntu to Arch.

Thanks for your reply.

Yes, it really is a waste of everybody's time to pursue the patch any further; as it is now inconsequential.

The result of using it would be that of adding unnecessary code to Arch!


I used to be surprised that I was still surprised by my own stupidity, finding it strangely refreshing.
Well, now I don't find it refreshing.
I'm over it!

Offline

#16 2008-10-17 06:30:57

handy
Member
From: Oz
Registered: 2008-03-26
Posts: 719

Re: [SOLVED] An ALSA bug patch that needs converting from Ubuntu to Arch.

Add the following to /etc/modprobe.conf

options snd-hda-intel model=imac24

Then restart computer or the sound system.

Using the above gives a very workable alsamixer, the sound quality is still 2nd rate (as ALSA still has a way to go) so using VLC & its mixer is very helpful when watching DVD's. I have not tested the line out or mic, though I believe that they are working properly with this configuration.


I used to be surprised that I was still surprised by my own stupidity, finding it strangely refreshing.
Well, now I don't find it refreshing.
I'm over it!

Offline

Board footer

Powered by FluxBB