30 April 2008

Having issues with an i945 & Compiz on Hardy?

On IRC a couple days ago, someone popped up with an Intel i945 unable to get Compiz to start. He'd get output like this:

/usr/bin/compiz.real (core) - Fatal: No GLXFBConfig for default depth, this isn't going to work.
/usr/bin/compiz.real (core) - Error: Failed to manage screen: 0
/usr/bin/compiz.real (core) - Fatal: No manageable screens found on display :0.0

That's pretty confusing and un-helpful. To top it off, I have an i945GM which has always worked perfectly. It seemed a lot of people agreed with "but...it's Intel. Intel always just works with Compiz...that's not right!" JDong said something had to be seriously wrong if an i945 wasn't working with Compiz. He was kind of right. I'd say anything in the kernel falls into the category of "serious," but what was actually wrong in the kernel was, thankfully, not huge. He found Bug #204762, which applies to this case. He linked to an upstream change in the Linux kernel which shows the exact problem. The bug has been marked for 8.04.1, due in July.

There are two cards called i945. Go figure. The version in my laptop is the GMA. The version in his computer is the GME. Guess what else? The kernel in Hardy knows what mine is. It has no idea what his is, beyond that it uses the intel driver. That git change makes it really obvious how you fix this: recompile the kernel with that change. Now, asking someone to recompile their kernel on the 2nd day they've been using Linux is just a little too sadistic for me, so I ended up SSH-ing into his computer and doing it for him. It worked! Yay!

So that all you who are stuck in this boat can get yours working too (without waiting til July), I've made a little script to automate it. Daniel Chen gave me some help because I don't understand how kernel ABIs work like he does, so thank you Dan. Here's what you do:

cd ~/Desktop
wget http://student.seas.gwu.edu/~mac/files/945correct.sh
chmod +x 945correct.sh

The first thing the script does is check to see if your hardware is affected by this bug. It will exit if the answer is no. Then it'll download the build dependencies and the source code, modify it, update the version just a bit so that Update Manager doesn't try to undo it, compile the new kernel (this part will take an hour or two depending on your machine), make debs of it, and then install those debs. Finally, it'll ask you to reboot. You don't have to reboot immediately; it simply won't go into effect until you do.

I'm not making any guarantees about this script, but the patch is known to work and worked on his computer. I turned off the "do you need this?" check and ran it on my computer without any problems. So, I think it should work for you, but if it doesn't, let me know where it screws up, OK? And pasting just "Error 2" in the comments is not enough info to debug.


SEJeff said...

grep + awk are redundant, use awk '/pattern/{commands}'.

Also... gnu sed supports -i, but anything immediately following -i becomes the backup file. This leaves you with files like:
drivers/char/drm/i915_drv.he. Here is an example:
jeff@jschroeder2:/tmp$ ls file*
ls: cannot access file*: No such file or directory
jeff@jschroeder2:/tmp$ echo foobarbaz > file
jeff@jschroeder2:/tmp$ sed -ie 's/bar/bunny/' file
jeff@jschroeder2:/tmp$ ls file*
file filee

You might also look into creating a temp directory using mktemp instead of mkdir -p ~/src. Just a thought.

Try this patch if blogger doesn't shred it too badly

--- 945correct.sh 2008-04-30 05:59:04.000000000 -0700
+++ 945correct.sh.new 2008-04-30 06:01:01.000000000 -0700
@@ -16,7 +16,7 @@
echo "5. Install the kernel"

# Check to see if they have an i945GME
-VGADEV=$(lspci -vn | grep VGA | awk '{ print $3 }')
+VGADEV=$(lspci -vn | awk '/VGA/{ print $3 }')
if [ "$VGADEV" != "8086:27ae" ]
echo "You don't need this. Exiting."
@@ -55,10 +55,10 @@
# -#define IS_I945GM(dev) ((dev)->pci_device == 0x27A2)
# +#define IS_I945GM(dev) ((dev)->pci_device == 0x27A2 ||\
# + (dev)->pci_device == 0x27AE)
-sed -ie 's/#define IS_I945GM(dev) ((dev)->pci_device == 0x27A2)/#define IS_I945GM(dev) ((dev)->pci_device == 0x27A2 || \\ \n (dev)->pci_device == 0x27AE)/' drivers/char/drm/i915_drv.h
+sed -i -e 's/#define IS_I945GM(dev) ((dev)->pci_device == 0x27A2)/#define IS_I945GM(dev) ((dev)->pci_device == 0x27A2 || \\ \n (dev)->pci_device == 0x27AE)/' drivers/char/drm/i915_drv.h

# bump version so update manager isn't confused
-sed -ie '1ilinux (2.6.24-16.30+1) hardy; urgency=low\n\n * Make kernel aware that pci device 0x27AE is Intel i945GME\n\n -- Mackenzie Morgan maco.m@ubuntu.com Tue, 29 Apr 2008 15:48:34 -0400\n' debian/changelog
+sed -i -e '1ilinux (2.6.24-16.30+1) hardy; urgency=low\n\n * Make kernel aware that pci device 0x27AE is Intel i945GME\n\n -- Mackenzie Morgan maco.m@ubuntu.com Tue, 29 Apr 2008 15:48:34 -0400\n' debian/changelog

Mackenzie said...

Thanks! Awk apparently has more magic than I thought it did O_O And thanks for the tip on sed thinking its a backup. I just edited it to match the changes you suggested.


hi all!
can't enable visual effects with a intel 950 GMA on a vaio (fresh hardy) ..
any idea ?
thanks alot

Mackenzie said...

Guebre, can you run this in a terminal?
lspci -vn | awk '/VGA/{ print $3 }'

What's the output? Is it

If so, you need this script.


oh no !!
it seems that i don't need ur script:
result of ur command
lspci -vn | awk '/VGA/{ print $3 }'


AlejandroCaro said...

HI, man I Tried to download your script but the link seems to be broken. I would like to try to fix the compiz with mY i945. Can you upload again the link please.


Mackenzie said...

This is an old post. That script is just for the -16 kernel. A working -17 was in someone's PPA (mentioned in a later post), and -19 (which was in the Proposed official repo a couple weeks ago and might be standard now) has it fixed. Just install your updates if you've got the problematic version of 945.

abhibera said...

hey mackenzie

nifty script.

i tried ur script. it said my i945 h/w wouldn't create any issues but it still was freezing on compiz.

turns out this is a problem with the i810 drivers which come with hardy by default.

in my case because the i810 drivers were present, it was using them instead of the intel drivers.

so i did a sudo apt-get remove xserver-xorg-video-i810

the problem was solved!! :)

Mackenzie said...

i810 is not the default in Hardy. In both Gutsy and Hardy, intel is the default. If yours was using i810, it's because you had your xorg.conf set for i810 back in Feisty or earlier and you've just been upgrading. On a fresh install, it would've been intel. I manually switched to the intel driver in Gutsy to get the advantages of the intel driver (like having a resolution above 1024x768 without using 915resolution)