From 08c5fb247cc593ec3e6ab1a56f8e7e8a99d210b1 Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Sat, 4 Apr 2009 16:26:39 -0500
Subject: LinHES-config: xconfig.sh add concept of forcing DISPLAYCARD and
 DISPLAYRES using ENV variables.

can also use displayres=xxxx on the kernel commandline.
---
 .../LinHES-config/install_functions.sh             | 10 +++
 abs/core-testing/LinHES-config/xconfig.sh          | 76 +++++++++++++++++++---
 2 files changed, 76 insertions(+), 10 deletions(-)

diff --git a/abs/core-testing/LinHES-config/install_functions.sh b/abs/core-testing/LinHES-config/install_functions.sh
index a57e1bd..c26b6e3 100755
--- a/abs/core-testing/LinHES-config/install_functions.sh
+++ b/abs/core-testing/LinHES-config/install_functions.sh
@@ -35,6 +35,16 @@ echo "Selected $pick as the theme"
 update_db_settings Theme "$pick"
 }
 
+function parse_cmdline_2_db(){
+    echo $CMDLINE | grep -q displayres
+    if [ $? = 0 ]
+    then
+        TEMPVAR=${CMDLINE#*displayres=}
+        update_db_settings HostXres $TEMPVAR
+    fi
+
+}
+
 
 function splash_setup (){
     echo $CMDLINE | grep -q splash=silent
diff --git a/abs/core-testing/LinHES-config/xconfig.sh b/abs/core-testing/LinHES-config/xconfig.sh
index e2a48ed..4f5fc62 100755
--- a/abs/core-testing/LinHES-config/xconfig.sh
+++ b/abs/core-testing/LinHES-config/xconfig.sh
@@ -1,4 +1,7 @@
 #!/bin/bash
+#SET DISPLAYCARD to force a cardtype
+#SET DISPLAYRES to force Xres, ENV takes precendent over cmdline
+#displayres=cmdline
 #NVPKGS="ati-dri xf86-video-ati xf86-video-radeonhd intel-dri xf86-video-intel unichrome-dri xf86-video-unichrome xf86-video-mga xf86-video-savage xf86-video-trident"
 NVPKGS="ati-dri xf86-video-ati xf86-video-radeonhd intel-dri xf86-video-intel xf86-video-mga xf86-video-savage xf86-video-trident"
 BASE=""
@@ -10,16 +13,23 @@ MYTHHOME=$BASE/home/mythtv
 function Xvalues {
     CMDLINE=$(cat /proc/cmdline)
     echo "$CMDLINE" | grep -q forceXvesa
-    if [ $? = 0 ]
+    if [ $? = 0  ]
     then
         VGACARDTYPE=vesa
+        Xcardtype=$VGACARDTYPE
     else
         VGACARDTYPE=`lspci | grep -i vga | sort -r | head -n 1 | cut -d: -f3 | cut -d" " -f2`
         VGAPCIID=`lspci | grep -i vga | sort -r | head -n 1 | cut -d" " -f1`
         CARDID=`lspci -n | grep "$VGAPCIID" | grep 10de | cut -d" " -f3 | cut -d: -f2`
         VENDORID=`lspci -n | grep "$VGAPCIID" | grep 10de | cut -d" " -f3 | cut -d: -f1`
     fi
-    echo "$VGACARDTYPE"
+    #force VGACARDTYPE
+    if [ ! x$DISPLAYCARD = x ]
+    then
+        VGACARDTYPE=$DISPLAYCARD
+        Xcardtype=$VGACARDTYPE
+    fi
+    echo "Will use $VGACARDTYPE"
     currentmode=`cat "$BASE/etc/X11/xorg.conf" | grep Modes | awk -Fs '{ print $2 }'`
 }
 
@@ -82,7 +92,7 @@ function setupAdvancedX {
     fi
 #    echo $ML
     case $Xcardtype in
-        NVIDIA|nVidia)
+        NVIDIA|nVidia|nvidia)
             case $Xconnection in
                 DVI)    ConnectedMonitor=DFP ;;
                 vga)    ConnectedMonitor=CRT;;
@@ -178,7 +188,12 @@ function setupX {
     then
         case $VGACARDTYPE in
             nVidia)
-                sed -e "s/^.*Modes.*$/\t Modes \"${Xres}\"/" "$TEMPLATES/xorg/xorg.conf.nvidia" > "$XORG_CONF"
+                if [ ${Xres} = Auto ]
+                then
+                    sed -e "/^.*Modes.*$/d" "$TEMPLATES/xorg/xorg.conf.nvidia" > "$XORG_CONF"
+                else
+                    sed -e "s/^.*Modes.*$/\t Modes \"${Xres}\"/" "$TEMPLATES/xorg/xorg.conf.nvidia" > "$XORG_CONF"
+                fi
                 if [ "$TESTMODE" != "test" ]
                 then
                     #nvidia check right here
@@ -208,7 +223,12 @@ function setupX {
                 # xf86-video-openchrome
                 # xf86-video-unichrome
                 # There is also a seperate driver for the Unichrome Pro
-                sed -e "s/^.*Modes.*$/\t Modes \"${Xres}\"/" "$TEMPLATES/xorg/xorg.conf.via" > "$XORG_CONF"
+                if [ ${Xres} = Auto ]
+                then
+                    sed -e "/^.*Modes.*$/d" "$TEMPLATES/xorg/xorg.conf.via" > "$XORG_CONF"
+                else
+                    sed -e "s/^.*Modes.*$/\t Modes \"${Xres}\"/" "$TEMPLATES/xorg/xorg.conf.via" > "$XORG_CONF"
+                fi
                 if [ "$TESTMODE" != "test" ]
                 then
                     if [ "$OPENCHROME" = "1" ]
@@ -239,8 +259,13 @@ function setupX {
                 fi
                 ;;
 
-            Intel)
-                sed -e "s/^.*Modes.*$/\t Modes \"${Xres}\"/" "$TEMPLATES/xorg/xorg.conf.intel" > "$XORG_CONF"
+            Intel|intel)
+               if [ ${Xres} = Auto ]
+                then
+                    sed -e "/^.*Modes.*$/d" "$TEMPLATES/xorg/xorg.conf.intel" > "$XORG_CONF"
+                else
+                    sed -e "s/^.*Modes.*$/\t Modes \"${Xres}\"/" "$TEMPLATES/xorg/xorg.conf.intel" > "$XORG_CONF"
+                fi
                 if [ "$TESTMODE" != "test" ]
                 then
                     pacman --noconfirm -R nvidia-utils > /dev/null 2>&1
@@ -250,7 +275,12 @@ function setupX {
                 ;;
 
             vesa|InnoTek)
-                sed -e "s/^.*Modes.*$/\t Modes \"${Xres}\"/" "$TEMPLATES/xorg/xorg.conf.vesa" > "$XORG_CONF"
+                if [ ${Xres} = Auto ]
+                then
+                    sed -e "/^.*Modes.*$/d" "$TEMPLATES/xorg/xorg.conf.vesa" > "$XORG_CONF"
+                else
+                    sed -e "s/^.*Modes.*$/\t Modes \"${Xres}\"/" "$TEMPLATES/xorg/xorg.conf.vesa" > "$XORG_CONF"
+                fi
                 ;;
 
             *)
@@ -260,11 +290,21 @@ function setupX {
                 if [ -f "$XCONF" ]
                 then
                     echo "Using $XCONF"
-                    grep -v Modes "$XCONF" | sed -e "/Depth.*16/a Modes \"${Xres}\" " -e "/Depth.*24/a Modes \"${Xres}\""     -e 's/dev\/mouse/dev\/psaux/g'> "$XORG_CONF"
+                    if [ ${Xres} = Auto ]
+                    then
+                        grep -v Modes "$XCONF" | sed -e 's/dev\/mouse/dev\/psaux/g'> "$XORG_CONF"
+                    else
+                        grep -v Modes "$XCONF" | sed -e "/Depth.*16/a Modes \"${Xres}\" " -e "/Depth.*24/a Modes \"${Xres}\""     -e 's/dev\/mouse/dev\/psaux/g'> "$XORG_CONF"
+                    fi
                 elif [ -f "$XCONFB" ]
                 then
                     echo "Using $XCONFB"
-                    sed -e "s/^.*Modes.*$/\t Modes \"${Xres}\"/" "$XCONFB" > "$XORG_CONF"
+                    if [ ${Xres} = Auto ]
+                    then
+                        sed -e "/^.*Modes.*$/d" "$XCONFB" > "$XORG_CONF"
+                    else
+                        sed -e "s/^.*Modes.*$/\t Modes \"${Xres}\"/" "$XCONFB" > "$XORG_CONF"
+                    fi
                 else
                     echo "Xorg configuration failed"
                 fi
@@ -299,6 +339,22 @@ else
     else
         Xres="800x600"
     fi
+    CMDLINE=$(cat /proc/cmdline)
+    echo $CMDLINE | grep -q displayres
+    if [ $? = 0 ]
+    then
+        TEMPVAR=${CMDLINE#*displayres=}
+        DSR=${TEMPVAR%% *}
+    fi
+    if [ ! x$DSR = x ]
+    then
+        Xres=$DSR
+    fi
+    if [ ! x$DISPLAYRES = x ]
+    then
+        Xres=$DISPLAYRES
+    fi
+
     XORG_CONF="/etc/X11/xorg.conf"
     XVMC_CONFIG="/etc/X11/XvMCConfig"
 fi
-- 
cgit v0.12

