#!/bin/sh
#

# new header not using prereqs
if [ "$1" = "prereqs" ]; then
  echo ""
  exit 0
fi


quiet=n

. /scripts/functions
. /conf/tcos.conf
. /conf/tcos-run-functions

test1=0
#geode 100B:0030
#geode 1022:2081
test1=$(lspci -n |grep -c -e "100B:0030" -e "1022:2081")

test2=0
test2=$(cat /conf/xorg.version | sed '/^$/d' | head -1 | awk '{print $NF}' | awk -F"." '{if ($1 <= 1 && $2 > 3) printf "1"}')


if [ "$test1" = "0" ] || [ "$test2" = "1" ] ; then
   # no client with chip amd geode or Xorg with amd fixes
   exit 0
fi

[ "$TCOS_XORG_VIDEO_DRIVER" = "fullauto" ] && exit 0

log_begin_msg "Loading xserver AMD Geode Support"

    if [ -f /usr/lib/xorg/modules/drivers/amd_drv.so ]; then
      configurexorg --newsettings --xdriver=amd --outputfile=/etc/X11/xorg.conf 2>> /tmp/initramfs.debug
    elif [ -f /usr/lib/xorg/modules/drivers/geode_drv.so ]; then
      configurexorg --newsettings --xdriver=geode --outputfile=/etc/X11/xorg.conf 2>> /tmp/initramfs.debug
    fi

log_end_msg $?

