RE: Detecting Supported VESA Video Modes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I wrote up a shell script that takes read-edid and creates an Xconfig
file on the fly. Basically I took my xconfig script and copied
everything above the "Monitor" section to one file, and everything below
the "Monitor" section to another file. Then I parsed the output of
read-edid-1.4.1 (from http://john.fremlin.de/programs/linux/read-edid/)
so that it worked as a proper modeline entry for xconfig. This script
may take some editing (some paths and such need to be changed). I also
wrote this for my embedded environment in which we only want to auto
detect monitors whose resolution is 1024x768 or 1280x1024. If it isn't
either of those (our program doesn't look good in higher or lower
resolution) I copy over a default 1024, lower color xconfig file. You
will possibly want to change that part of the script. This works
particularly well for me as I am using ramdisk and my xconfig file is in
ramdisk (as is /tmp). Let me know your thoughts.

-Michael


-----Original Message-----
From: Michael Hamilton 
Sent: Tuesday, October 26, 2004 1:58 PM
To: xfree86@xxxxxxxxxxx
Subject: RE:  Detecting Supported VESA Video Modes

That's a great suggestion! Thank you so much, I am now able to
intelligently pick which configuration to use for multiple monitors.

-----Original Message-----
From: Ryan Underwood [mailto:nemesis-lists@xxxxxxxxxxxx] 
Sent: Tuesday, October 26, 2004 12:58 PM
To: xfree86@xxxxxxxxxxx
Subject: Re:  Detecting Supported VESA Video Modes


You could use the standalone read-edid utility.

On Tue, Oct 26, 2004 at 10:34:20AM -0700, Michael Hamilton wrote:
> Is there an X command which lists the supported VESA Video Modes for a
> monitor? I am trying to find any information about a monitor before X
> starts. Thanks.
> 
> Michael
> 
> 
> _______________________________________________
> XFree86 mailing list
> XFree86@xxxxxxxxxxx
> http://XFree86.Org/mailman/listinfo/xfree86
> 

-- 
Ryan Underwood, <nemesis@xxxxxxxxxxxx>


_______________________________________________
XFree86 mailing list
XFree86@xxxxxxxxxxx
http://XFree86.Org/mailman/listinfo/xfree86

#!/bin/bash
TOP_X=/path/to/top_x_file
BOTTOM_X=/path/to/bottom_x_file
DEFAULT_X=/path/to/XF86Config.default
G_EDID=/path/to/get-edid
P_EDID=/path/to/parse-edid
X_DEST=/etc/X11/XF86Config
######################
#Loading Data        #
######################
$G_EDID 2>/tmp/tmp_error | $P_EDID 2>>/tmp/tmp_error | /bin/sed -e 's/Mode 	/Modeline /g' -e 's/Identifier \".*/Identifier \"Monitor0\"/g' -e '/	EndMode/d' -e 's/DotClock	//g' -e 's/HTimings	//g' -e 's/VTimings	//g' -e 's/Flags	\"+HSync\" \"+VSync\"/+hsync +vsync/g' -e 's/Flags	\"-HSync\" \"-VSync\"/-hsync -vsync/g' > /tmp/x_mid
######################
#Begin Error Checking#
######################
if [[ ! -s /tmp/tmp_error ]]
then
  #The error File is zero Length
  #We will just load defaults and exit.
  echo "STARTUPX: I was unable to get an error status. Loading default Xconfig file" >> /var/log/messages
  cp $DEFAULT_X $X_DEST
  exit 0
fi
if [[ ! -s /tmp/x_mid ]]
then
  #The Monitor File is zero Length
  #We will just load defaults and exit.
  echo "STARTUPX: I was unable to store any information in /tmp/x_mid. Loading default Xconfig file" >> /var/log/messages
  cp $DEFAULT_X $X_DEST
  exit 0
fi
if [[ `/bin/grep "output block unchanged" /tmp/tmp_error` ]]
then
  #This means that the get EDID call to the BIOS didn't work: you didn't get the EDID data.
  #We will just load defaults and exit.
  echo "STARTUPX: The Get-EDID call to BIOS did not work, no EDID data. Loading default Xconfig file" >> /var/log/messages
  cp $DEFAULT_X $X_DEST
  exit 0
fi
if [[ `/bin/grep "first bytes*match EDID version 1 header" /tmp/tmp_error` ]]
then
  #The EDID did not start with the EDID version 1 header. Try getting the EDID some other way
  #We will just load defaults and exit.
  echo "STARTUPX: Did not have EDID Version 1 header. Loading default Xconfig file" >> /var/log/messages
  cp $DEFAULT_X $X_DEST
  exit 0
fi
if [[ `/bin/grep "checksum failed" /tmp/tmp_error` ]]
then
  #The EDID is probably corrupt. Do not blindly trust any modelines generated.
  #We will just load defaults and exit.
  echo "STARTUPX:The EDID is probably corrupt. Do not blindly trust any modelines generated. Loading default Xconfig file" >> /var/log/messages
  cp $DEFAULT_X $X_DEST
  exit 0
fi

if [[ `/bin/grep "do not trust output" /tmp/tmp_error` ]]
then
  #Dont Trust it - well thats what it told me!
  #We will just load defaults and exit.
  echo "STARTUPX: parse-edid or get-edid told me I had unreliable data. Loading default Xconfig file" >> /var/log/messages
  cp $DEFAULT_X $X_DEST
  exit 0
fi
if [[ `/bin/grep "Modeline " /tmp/x_mid | cut -f2 | cut -f2 -d\"` != "1024x768" ]]
then
  if [[ `/bin/grep "Modeline " /tmp/x_mid | cut -f2 | cut -f2 -d\"` != "1280x1024" ]]
  then
    #We are either too low or too high!
    #We will just load defaults and exit.
    echo "STARTUPX: My resolution was not one of the two supported resolutions. Loading default Xconfig file" >> /var/log/messages
    cp $DEFAULT_X $X_DEST
    exit 0
  fi
fi

######################
#No Errors So we     #
#Continue on to      #
#write out to Xfig   #
######################
cat $TOP_X > $X_DEST
cat /tmp/x_mid >> $X_DEST
cat $BOTTOM_X >> $X_DEST
rm -rf /tmp/x_mid
rm -rf /tmp/tmp_error
echo "STARTUPX: Properly Built X config file on the FLY" >> /var/log/messages
exit 1

[Index of Archives]     [X Forum]     [Xorg]     [XFree86 Newbie]     [IETF Announce]     [Security]     [Font Config]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux Kernel]

  Powered by Linux