How to install Archlinux on MacBook Pro 8,2[Part.2]

In Part 2, we are going to discuss how to install Xorg-server and work nicely with it. (Part 1) The problem is that, currently (if you have followed as Part.1) Xorg-server will run with framebuffer, not from the video card you have inside Mac. In Macbook Pro 8,2 there are two video cards ATI radeon and Intel. We are going to use ATI even though two graphical cards should work nicely with the strategy below.

The issue of not using video card without any tweak is because of KMSmode. On EFI system, it is using EFI system bootloader, which is different from bios one as in any os booting CD or Windows system. This will prevent the KMS mode to be on, otherwise the system won’t boot. Last time, we turn off the KMS setup by doing ‘nomodeset’ on the grub setting and this made the KMS to be turned off. However without KMS, Xorg-server won’t work with the video card, rather it will complain that the modeset is wrong for itself.

So what we need to do is
1. apply patches for Radeon video card on Linux kernel
2. compile the kernel for that
3. Create a vbios emulation which will be copied from any bootable CD
4. Set modeset to the other way around; turn on the KMS mode.

So I will go step by step.

1. Apply patches for radeon video card on Linux kernel.

Thankfully, there is a github of patches+kernel of ‘fooblahblah’ so that you can download.

There is PKGBUILD file included so that you can patch them. However I wanted to add some patches for macbook pro so that I
corrected the PKGBUILD a bit and added some patches. The patches can be found here with explanations.

2. Compile the kernel

Before doing this, make a back of your files /boot/initramfs-linux.img and /boot/vmlinuz-linux (no need if you compile those files with different name, which is recommended)

Now we can compile. If you have made the pkg correctly, then you can use

pacman -U filename.tar.bz

to apply the patch, and it will create a new linux-mainline img file for you.

3. Create a vbios emulation which will be copied from any bootable CD

Now we are going to make video bios from any of bootable bios cd.
I used archlinux liveCD for that.

This is how to;
-boot from the CD
-type 
 dd if=/dev/mem of=vbios.bin bs=65536 skip=12 count=1
 dd if=/dev/mem of=/boot/int10.bin bs=4 skip=16 count=1
-copy the vbios.bin and int10.bin into /lib/firmware/radeon and /boot
That's all.

4. Now we are going to correct the grub.cfg file.

This is a part of my grub.cfg file. Go down through the file and find the right place.

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Arch Linux GNU/Linux, with Linux mainline kernel' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-mainline kernel-true-a8ca6c35-c261-4b1c-9858-88a12804302d' {
 load_video
 set gfxpayload=keep
 insmod gzio
 insmod part_gpt
 insmod ext2
 set root='hd0,gpt4'
 if [ x$feature_platform_search_hint = xy ]; then
 search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt4 --hint-efi=hd0,gpt4 --hint-baremetal=ahci0,gpt4 a8ca6c35-c261-4b1c-9858-88a12804302d
 else
 search --no-floppy --fs-uuid --set=root a8ca6c35-c261-4b1c-9858-88a12804302d
 fi
 loadbios /boot/vbios.bin /boot/int10.bin
 echo 'Loading Linux mainline kernel ...'
 linux /boot/vmlinuz-linux-mainline root=/dev/sda4 ro loglevel=7 radeon.modeset=1 i915_lvds_channels=2 i915.modeset=1 i915.lvds_use_ssc=0 acpi_backlight=vendor vt.handoff=7
 echo 'Loading initial ramdisk ...'
 initrd /boot/initramfs-linux-mainline.img
}

Then you will be able to boot and your video card should work now with KMS mode. If you have an external monitor, your now it will
automatically work as well.

To install Xorg-server and setting up the monitor, there are many documents for instance, here

Some Remarks

– Do not update your linux kernel after you compile it. Freeze pacman into a certain date. I closed up ‘core’ repository on the mirror file for pacman. (/etc/pacman.d/mirrorlist)
– If anyone with another model of macbook pro with nVidia video card there is a patch for that too.
-Do not forget to install the video driver from pacman : xf86-video-ati, xf86-video-intel
-On the video card setup for Xorg-server, two videos are not working together so far. I use radeon.

References:
http://ubuntuforums.org/showthread.php?t=1695746&page=85
https://bugs.freedesktop.org/show_bug.cgi?id=26891
https://help.ubuntu.com/community/UEFIBooting#Apple_Mac_EFI_systems
http://www.b1c1l1.com/blog/
http://cgit.freedesktop.org/nouveau/linux-2.6/commit/?id=c9b07e9e85e5b7fe38c9f009967e8bed51d3760b