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

Bug#179455: xserver-xfree86: buglet in modeline processing in r128_drv.o



Package: xserver-xfree86
Version: 4.1.0-16
Severity: normal

Hi - I noticed that the 4.1 r128_drv.o module was ignoring everything
except the X and Y resolutions of the modes in my X86Config file -
the module seems to grab just the X and Y resolutions, and throw
away all the other data, including the dotclock supplied by the user.

This means that you get misleading errors in your X logs as the module
silently throws away your dotclock and timings, substitutes its own
(often generating ridiculously high refresh rates) and the xserver
then rejects the mode as being out of range.

a) it dumps a list of known modes, with suitable dot clocks for a 60Hz
   display, in your Xlogs

b) It respects your modeline, provided it meets the usual "monitor can
   cope" requirements.

c) you get a more verbose commentary on which modes were accepted/rejected
   and why.

On my thinkpad A20p this allows me to get at the lower resolution modes,
esp 720x576 @ 60Hz, which then allows me to get S-Video output going to
the TV. (Yay).

There's still a slight bug: switching modes often leaves the display
scrambled, but prodding the "lid closed" cutout switch cures this.

The 4.2 r128_driver.c appears to do pretty much the same thing wrt to
modelines.

Hope this is of some use.

############################################################################

01:00.0 VGA compatible controller: ATI Technologies Inc Rage Mobility M3 AGP
2x
(rev 02)
01:00.0 Class 0300: 1002:4c46 (rev 02)

# File generated by xf86config.

#
# Copyright (c) 1999 by The XFree86 Project, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
# THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
# OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# Except as contained in this notice, the name of the XFree86 Project shall
# not be used in advertising or otherwise to promote the sale, use or other
# dealings in this Software without prior written authorization from the
# XFree86 Project.
#

# **********************************************************************
# Refer to the XF86Config(4/5) man page for details about the format of
# this file.
# **********************************************************************

# **********************************************************************
# Module section -- this  section  is used to specify
# which dynamically loadable modules to load.
# **********************************************************************
#
Section "Module"

# This loads the DBE extension module.

    Load        "dbe"   # Double buffer extension

# This loads the miscellaneous extensions module, and disables
# initialisation of the XFree86-DGA extension within that module.
    #SubSection  "extmod"
    #    Option    "omit xfree86-dga"   # don't initialise the DGA extension
    #EndSubSection

    Load  "extmod"
    Load  "xie"
    #Load  "pex5"
    Load  "glx"
    Load  "dri"
    Load  "GLcore"
    Load  "record"

    Load  "freetype"
    Load  "type1"
    Load  "speedo"
EndSection

# **********************************************************************
# Files section.  This allows default font and rgb paths to be set
# **********************************************************************

Section "DRI"
    Group "users"
    Mode  0660
EndSection

Section "Files"

# The location of the RGB database.  Note, this is the name of the
# file minus the extension (like ".txt" or ".db").  There is normally
# no need to change the default.

    RgbPath     "/usr/X11R6/lib/X11/rgb"

# Multiple FontPath entries are allowed (which are concatenated together),
# as well as specifying multiple comma-separated entries in one FontPath
# command (or a combination of both methods)
#
# If you don't have a floating point coprocessor and emacs, Mosaic or other
# programs take long to start up, try moving the Type1 and Speedo directory
# to the end of this list (or comment them out).
#

#    FontPath   "/usr/X11R6/lib/X11/fonts/local/"
    FontPath   "/usr/X11R6/lib/X11/fonts/misc/"
    FontPath   "/usr/X11R6/lib/X11/fonts/75dpi/:unscaled"
    FontPath   "/usr/X11R6/lib/X11/fonts/100dpi/:unscaled"
    FontPath   "/usr/X11R6/lib/X11/fonts/Type1/"
    FontPath   "/usr/X11R6/lib/X11/fonts/Speedo/"
    FontPath   "/usr/X11R6/lib/X11/fonts/75dpi/"
    FontPath   "/usr/X11R6/lib/X11/fonts/100dpi/"
    FontPath   "/usr/X11R6/lib/X11/fonts/truetype/"


# The module search path.  The default path is shown here.

#    ModulePath "/usr/X11R6/lib/modules"

EndSection

# **********************************************************************
# Server flags section.
# **********************************************************************

Section "ServerFlags"

# Uncomment this to cause a core dump at the spot where a signal is
# received.  This may leave the console in an unusable state, but may
# provide a better stack trace in the core dump to aid in debugging

#    Option "NoTrapSignals"

# Uncomment this to disable the <Crtl><Alt><BS> server abort sequence
# This allows clients to receive this key event.

#    Option "DontZap"

# Uncomment this to disable the <Crtl><Alt><KP_+>/<KP_-> mode switching
# sequences.  This allows clients to receive these key events.

#    Option "Dont Zoom"

# Uncomment this to disable tuning with the xvidtune client. With
# it the client can still run and fetch card and monitor attributes,
# but it will not be allowed to change them. If it tries it will
# receive a protocol error.

#    Option "DisableVidModeExtension"

# Uncomment this to enable the use of a non-local xvidtune client.

#    Option "AllowNonLocalXvidtune"

# Uncomment this to disable dynamically modifying the input device
# (mouse and keyboard) settings.

#    Option "DisableModInDev"

# Uncomment this to enable the use of a non-local client to
# change the keyboard or mouse settings (currently only xset).

#    Option "AllowNonLocalModInDev"

EndSection

# **********************************************************************
# Input devices
# **********************************************************************

# **********************************************************************
# Core keyboard's InputDevice section
# **********************************************************************

Section "InputDevice"

    Identifier  "Keyboard0"
    Driver      "Keyboard"
# For most OSs the protocol can be omitted (it defaults to "Standard").
# When using XQUEUE (only for SVR3 and SVR4, but not Solaris),
# uncomment the following line.

#    Option     "Protocol"      "Xqueue"

    Option "AutoRepeat" "500 30"

# Specify which keyboard LEDs can be user-controlled (eg, with xset(1))
#    Option     "Xleds"      "1 2 3"

#    Option "LeftAlt"     "Meta"
#    Option "RightAlt"    "ModeShift"

# To customise the XKB settings to suit your keyboard, modify the
# lines below (which are the defaults).  For example, for a non-U.S.
# keyboard, you will probably want to use:
#    Option "XkbModel"    "pc102"
# If you have a US Microsoft Natural keyboard, you can use:
#    Option "XkbModel"    "microsoft"
#
# Then to change the language, change the Layout setting.
# For example, a german layout can be obtained with:
#    Option "XkbLayout"   "de"
# or:
#    Option "XkbLayout"   "de"
#    Option "XkbVariant"  "nodeadkeys"
#
# If you'd like to switch the positions of your capslock and
# control keys, use:
#    Option "XkbOptions"  "ctrl:swapcaps"

# These are the default XKB settings for XFree86
#    Option "XkbRules"    "xfree86"
#    Option "XkbModel"    "pc101"
#    Option "XkbLayout"   "us"
#    Option "XkbVariant"  ""
#    Option "XkbOptions"  ""

#    Option "XkbDisable"

    Option "XkbRules"   "xfree86"
    Option "XkbModel"   "pc102"
    Option "XkbLayout"  "gb"

EndSection


# **********************************************************************
# Core Pointer's InputDevice section
# **********************************************************************

Section "InputDevice"

# Identifier and driver

    Identifier  "Mouse0"
    Driver      "mouse"
    Option "Protocol"    "PS/2"
    Option "Device"      "/dev/psaux"

EndSection

# **********************************************************************
# Modes section
# **********************************************************************

# the r128 driver does not allow modes to be defined when an LCD is present
# you must use a built in mode. for this chipset, it is:
Section "Modes"
    Identifier "narf"
   ModeLine "720x576" 35.81 720 768 782 1008 576 576 579 592
    ModeLine "1400x1050" 108.00 1400 1448 1462 1688 1050 1050 1053 1066
EndSection

# **********************************************************************
# Monitor section
# **********************************************************************

# Any number of monitor sections may be present

Section "Monitor"
    Identifier  "Monitor0"
    Gamma       0.7
    HorizSync   30-100
    VertRefresh 50-100
    UseModes    "narf"
    Option      "NoDPMS"
EndSection

# **********************************************************************
# Graphics device section
# **********************************************************************

# Any number of graphics device sections may be present

# Standard VGA Device:

Section "Device"
    Identifier  "Card0"
    Driver      "r128"
    VideoRam    16384
    BusID       "PCI:1:0:0"
EndSection


# **********************************************************************
# Screen sections
# **********************************************************************

# Any number of screen sections may be present.  Each describes
# the configuration of a single screen.  A single specific screen section
# may be specified from the X server command line with the "-screen"
# option.
Section "Screen"
    Identifier  "Screen0"
    Device      "Card0"
    Monitor     "Monitor0"
    DefaultDepth 16

    #Subsection "Display"
    #    Depth       8
    #    Modes       "1400x1050"
    #    ViewPort    0 0
    #EndSubsection
    Subsection "Display"
        Depth       16
        Modes       "1400x1050" "720x576"
        ViewPort    0 0
    EndSubsection
    Subsection "Display"
        Depth       24
        Modes       "1400x1050" "848x480" "720x576" "720x480" "512x384"
        ViewPort    0 0
    EndSubsection
EndSection

# **********************************************************************
# ServerLayout sections.
# **********************************************************************

# Any number of ServerLayout sections may be present.  Each describes
# the way multiple screens are organised.  A specific ServerLayout
# section may be specified from the X server command line with the
# "-layout" option.  In the absence of this, the first section is used.
# When now ServerLayout section is present, the first Screen section
# is used alone.

Section "ServerLayout"

# The Identifier line must be present
    Identifier  "Simple Layout"

# Each Screen line specifies a Screen section name, and optionally
# the relative position of other screens.  The four names after
# primary screen name are the screens to the top, bottom, left and right
# of the primary screen.  In this example, screen 2 is located to the
# right of screen 1.

    Screen "Screen0"

# Each InputDevice line specifies an InputDevice section name and
# optionally some options to specify the way the device is to be
# used.  Those options include "CorePointer", "CoreKeyboard" and
# "SendCoreEvents".

    InputDevice "Mouse0"    "CorePointer"
    InputDevice "Keyboard0" "CoreKeyboard"

EndSection

-rw-r-----    1 root     root        30332 Feb  2 11:59
/var/log/XFree86.0.log


-- System Information
Debian Release: 3.0
Kernel Version: Linux narf 2.4.20 #1 Tue Dec 24 22:15:29 GMT 2002 i686
unknown

Versions of the packages xserver-xfree86 depends on:
ii  debconf        1.0.32         Debian configuration management system
ii  libc6          2.2.5-11.2     GNU C Library: Shared libraries and Timezone
ii  xserver-common 4.1.0-16       files and utilities common to all X servers
ii  zlib1g         1.1.4-1        compression library - runtime


--- r128_driver.debian-orig.c	Sun Feb  2 12:23:14 2003
+++ r128_driver.c	Sun Feb  2 11:59:12 2003
@@ -616,6 +616,56 @@
 	}
     }
 
+    /************************************************************************
+     * Ok, if we're on an LCD, dump the available modes, assuming the freq  *
+     * is 60Hz ( Rage Mobility M3 forces the dotclock to 108Mhz - this is   *
+     * not required or usually even correct ) One note: When changing modes,*
+     * it may be necessary to close the lid and reopen it, or at least prod *
+     * the lid-closed cutout switch - this seems to wake the chipset up     *
+     * properly - the display may be scrambled till you do this             *
+     ************************************************************************/
+    if( info->HasPanelRegs                         &&
+	info->BIOSDisplay != R128_BIOS_DISPLAY_CRT &&
+        info->VBIOS                                 )
+    {
+        int i;
+	for (i = info->FPBIOSstart+64; R128_BIOS16(i) != 0; i += 2)
+        {
+            float clock;
+            int freq;
+            int hdispl, hsyncs, hsynce, htotal;
+            int vdispl, vsyncs, vsynce, vtotal;
+	    int j = R128_BIOS16(i);
+            if( R128_BIOS16(j+5) ) { j  = R128_BIOS16(j+5); }
+            else                   { j += 9;                }
+
+            clock  = (CARD32)R128_BIOS16(j) * 10;            
+            hdispl = ( (R128_BIOS16(j + 10) & 0x01ff ) + 1 ) * 8;
+            hsyncs = ( (R128_BIOS16(j + 12) & 0x01ff ) + 1 ) * 8;
+            hsynce = hsyncs + ( R128_BIOS8(j + 14) & 0x1f );
+            htotal = ( (R128_BIOS16(j + 8) & 0x01ff) + 1 ) * 8;
+            vdispl = ( R128_BIOS16(j + 17) & 0x07ff ) + 1;
+            vsyncs = ( R128_BIOS16(j + 19) & 0x07ff ) + 1;
+            vsynce = vsyncs + ( (R128_BIOS16(j + 19) >> 11) & 0x1f );
+            vtotal = ( R128_BIOS16(j + 15) & 0x07ff ) + 1;
+            /* throw away the clock, it's usually wrong */
+            freq   = 60; /* refresh rate, Hz */
+            clock  = freq * htotal * vtotal /  1000;
+            
+            xf86DrvMsg( pScrn->scrnIndex, X_PROBED,
+                        "VBIOS mode: \"%dx%d@%d\""
+                        " %.2f %d %d %d %d %d %d %d %d\n",
+                        hdispl, vdispl, freq  ,
+                        (clock / 1000),
+                        hdispl, hsyncs, hsynce, htotal ,
+                        vdispl, vsyncs, vsynce, vtotal );
+        }
+    }
+    else
+    {
+        xf86DrvMsg( pScrn->scrnIndex, X_PROBED, "Where's the BIOS?\n" );
+    }
+    
     return TRUE;
 }
 
@@ -2854,12 +2904,16 @@
 
 	    if (mode->CrtcHDisplay == R128_BIOS16(j) &&
 		mode->CrtcVDisplay == R128_BIOS16(j+2)) {
+                int bios_clk = 0;
+                
 		/* Assume we are using expanded mode */
 		if (R128_BIOS16(j+5)) j  = R128_BIOS16(j+5);
 		else                  j += 9;
 
-		mode->Clock = (CARD32)R128_BIOS16(j) * 10;
-
+                bios_clk = (CARD32)R128_BIOS16(j) * 10;
+                if( !mode->Clock )
+                    mode->Clock = bios_clk;
+                
 		mode->HDisplay   = mode->CrtcHDisplay   =
 		    ((R128_BIOS16(j+10) & 0x01ff)+1)*8;
 		mode->HSyncStart = mode->CrtcHSyncStart =
@@ -2877,10 +2931,23 @@
 		    mode->CrtcVSyncStart + ((R128_BIOS16(j+19) >> 11) & 0x1f);
 		mode->VTotal     = mode->CrtcVTotal     =
 		    (R128_BIOS16(j+15) & 0x07ff)+1;
-
+                xf86DrvMsg( pScrn->scrnIndex, X_INFO,
+                            "ATI VBIOS ACCEPTED mode %dx%d "
+                            "(listed: clock %d <BIOS:%d>, (h|v)sync %d|%d)\n",
+                            mode->CrtcHDisplay                               ,
+                            mode->CrtcVDisplay                               ,
+                            mode->Clock                                      ,
+                            bios_clk                                         ,
+                            mode->Clock / ( mode->HTotal  )                  ,
+                            ( mode->Clock * 1000 ) /
+                              ( mode->HTotal * mode->VTotal )                );
 		return MODE_OK;
 	    }
 	}
+        xf86DrvMsg( pScrn->scrnIndex, X_INFO,
+                    "ATI VBIOS REJECTED mode %dx%d (not listed)\n",
+                    mode->CrtcHDisplay     ,
+                    mode->CrtcVDisplay     );
 	return MODE_NOMODE;
     }
 

Reply to: