#!/bin/sh
# vi: noet:
# Horst Burkhardt <horst@adelielinux.org> 2018
# Max Rees <maxcrees@me.com> 2019
#
# AGP acceleration in the Radeon KMS driver has been broken on Apple PPC
# since the 2.6 series, and most developers are in agreement that since
# UniNorth is underdocumented, it probably won't ever be fixed. Disable
# it on all Apple machines except ones where it is known not to apply.
#
# https://bts.adelielinux.org/show_bug.cgi?id=49
set -e

case "$(uname -m)" in
ppc|ppc64)
	if grep -q 'MacRISC[23]' /proc/cpuinfo; then
		case "$(awk '$1 == "machine" { print $3 }' /proc/cpuinfo)" in
		PowerBook1,1) ;;
		PowerMac1,1) ;;
		PowerMac1,2) ;;
		PowerMac11,2) ;;
		PowerMac12,1) ;;
		RackMac3,1) ;;
		iMac,1) ;;
		*) export GRUB_CMDLINE_LINUX="radeon.agpmode=-1 $GRUB_CMDLINE_LINUX";;
		esac
	fi;;
esac