Hello,

this is a patch that fixes a long-standing issue with the X server.

The X server discards EDID information and sets DPI always to 96.

This is a regression since 1.7 introduced in fff00d .

There is no option to use the information obtained from EDID.

Thanks

Michal
From 33a200fa5b670a9e479e8d9be533ec1112867213 Mon Sep 17 00:00:00 2001
From: Michal Suchanek <[email protected]>
Date: Sat, 24 Sep 2011 18:46:29 +0200
Subject: [PATCH] Add option to set default DPI

 The default DPI can be either specified as fixed value or 'auto'
 meaning DDC is used when available.

 Based on patch by Nick Bowler
---
 hw/xfree86/common/xf86Config.c  |   14 +++++++++++++-
 hw/xfree86/common/xf86Globals.c |    1 +
 hw/xfree86/common/xf86Helper.c  |    4 ++++
 hw/xfree86/common/xf86Privstr.h |    1 +
 hw/xfree86/man/xorg.conf.man    |    6 ++++++
 hw/xfree86/modes/xf86RandR12.c  |   19 ++++++++++++++++++-
 6 files changed, 43 insertions(+), 2 deletions(-)

Index: xserver/hw/xfree86/common/xf86Config.c
===================================================================
--- xserver.orig/hw/xfree86/common/xf86Config.c	2011-10-11 18:58:07.000000000 +0200
+++ xserver/hw/xfree86/common/xf86Config.c	2011-10-11 18:59:40.000000000 +0200
@@ -688,7 +688,8 @@
     FLAG_AUTO_ENABLE_DEVICES,
     FLAG_GLX_VISUALS,
     FLAG_DRI2,
-    FLAG_USE_SIGIO
+    FLAG_USE_SIGIO,
+    FLAG_DEFAULT_DPI
 } FlagValues;
 
 /**
@@ -746,6 +747,8 @@
 	{0}, FALSE },
   { FLAG_USE_SIGIO,		"UseSIGIO",			OPTV_BOOLEAN,
 	{0}, FALSE },
+  { FLAG_DEFAULT_DPI,		"DefaultDPI",			OPTV_STRING,
+	{0}, FALSE },
   { -1,				NULL,				OPTV_NONE,
 	{0}, FALSE },
 };
@@ -880,6 +883,15 @@
 	}
     }
 
+
+    xf86Info.defaultDPI = DEFAULT_DPI;
+    if ((s = xf86GetOptValString(FlagOptions, FLAG_DEFAULT_DPI))) {
+	if (!xf86NameCmp(s, "auto")) {
+	    xf86Info.defaultDPI = 0;
+	} else {
+	    xf86Info.defaultDPI = strtoul(s, NULL, 0);
+	}
+    }
 #ifdef RANDR
     xf86Info.disableRandR = FALSE;
     xf86Info.randRFrom = X_DEFAULT;
Index: xserver/hw/xfree86/common/xf86Globals.c
===================================================================
--- xserver.orig/hw/xfree86/common/xf86Globals.c	2011-10-11 18:58:07.000000000 +0200
+++ xserver/hw/xfree86/common/xf86Globals.c	2011-10-11 18:59:40.000000000 +0200
@@ -106,6 +106,7 @@
     .ShareVTs                   = FALSE,
     .dontZap                    = FALSE,
     .dontZoom                   = FALSE,
+    .defaultDPI                 = DEFAULT_DPI,
     .notrapSignals              = FALSE,
     .caughtSignal               = FALSE,
     .currentScreen              = NULL,
Index: xserver/hw/xfree86/common/xf86Helper.c
===================================================================
--- xserver.orig/hw/xfree86/common/xf86Helper.c	2011-10-11 18:58:07.000000000 +0200
+++ xserver/hw/xfree86/common/xf86Helper.c	2011-10-11 18:59:40.000000000 +0200
@@ -956,10 +956,14 @@
     } else {
 	if (x > 0)
 	    pScrn->xDpi = x;
+	else if (xf86Info.defaultDPI)
+	    pScrn->xDpi = xf86Info.defaultDPI;
 	else
 	    pScrn->xDpi = DEFAULT_DPI;
 	if (y > 0)
 	    pScrn->yDpi = y;
+	else if (xf86Info.defaultDPI)
+	    pScrn->yDpi = xf86Info.defaultDPI;
 	else
 	    pScrn->yDpi = DEFAULT_DPI;
     }
Index: xserver/hw/xfree86/common/xf86Privstr.h
===================================================================
--- xserver.orig/hw/xfree86/common/xf86Privstr.h	2011-10-11 18:58:07.000000000 +0200
+++ xserver/hw/xfree86/common/xf86Privstr.h	2011-10-11 18:59:40.000000000 +0200
@@ -69,6 +69,7 @@
     Bool		ShareVTs;
     Bool		dontZap;
     Bool		dontZoom;
+    unsigned		defaultDPI;
     Bool		notrapSignals;	/* don't exit cleanly - die at fault */
     Bool		caughtSignal;
 
Index: xserver/hw/xfree86/man/xorg.conf.man
===================================================================
--- xserver.orig/hw/xfree86/man/xorg.conf.man	2011-10-10 17:52:26.000000000 +0200
+++ xserver/hw/xfree86/man/xorg.conf.man	2011-10-11 18:59:40.000000000 +0200
@@ -544,6 +544,12 @@
 and are passed to clients.
 Default: off.
 .TP 7
+.BI "Option \*qDefaultDPI\*q  \*q" string \*q
+This option allows to set a fixed DPI which is reported for all screens or the
+special value \*qauto\*q which infers DPI from screen size read from DDC. The
+fallback in case DDC reading fails is 96.
+Default: 96.
+.TP 7
 .BI "Option \*qDisableVidModeExtension\*q  \*q" boolean \*q
 This disables the parts of the VidMode extension used by the xvidtune client
 that can be used to change the video modes.
Index: xserver/hw/xfree86/modes/xf86RandR12.c
===================================================================
--- xserver.orig/hw/xfree86/modes/xf86RandR12.c	2011-10-11 18:58:07.000000000 +0200
+++ xserver/hw/xfree86/modes/xf86RandR12.c	2011-10-11 18:59:40.000000000 +0200
@@ -807,6 +807,7 @@
 	else
 	{
 	    xf86OutputPtr   output = xf86CompatOutput(pScrn);
+	    xf86CrtcPtr     crtc   = output->crtc;
 
 	    if (output &&
 		output->conf_monitor &&
@@ -819,11 +820,27 @@
 		mmWidth = output->conf_monitor->mon_width;
 		mmHeight = output->conf_monitor->mon_height;
 	    }
-	    else
+	    else if (!xf86Info.defaultDPI && crtc && crtc->mode.HDisplay &&
+		     output->mm_width && output->mm_height)
+	    {
+		/*
+		 * If the output has a mode and a declared size, use that
+		 * to scale the screen size
+		 */
+		DisplayModePtr	mode = &crtc->mode;
+		mmWidth = output->mm_width * width / mode->HDisplay;
+		mmHeight = output->mm_height * height / mode->VDisplay;
+	    }
+	    else if (xf86Info.defaultDPI)
 	    {
 		/*
 		 * Otherwise, just set the screen to DEFAULT_DPI
 		 */
+		mmWidth = width * 25.4 / xf86Info.defaultDPI;
+		mmHeight = height * 25.4 / xf86Info.defaultDPI;
+	    }
+	    else
+	    {
 		mmWidth = width * 25.4 / DEFAULT_DPI;
 		mmHeight = height * 25.4 / DEFAULT_DPI;
 	    }
_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to