Bug 20931 - Wrong DPI calculation
Summary: Wrong DPI calculation
Status: NEW
Alias: None
Product: xorg
Classification: Unclassified
Component: Server/General (show other bugs)
Version: 7.6 (2010.12)
Hardware: x86 (IA32) Linux (All)
: medium normal
Assignee: Xorg Project Team
QA Contact: Xorg Project Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-29 00:04 UTC by Nico R.
Modified: 2017-08-28 08:54 UTC (History)
4 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Xorg server logfile (29.55 KB, text/plain)
2009-03-29 00:06 UTC, Nico R.
no flags Details
Xorg configuration file (3.87 KB, text/plain)
2009-03-29 00:10 UTC, Nico R.
no flags Details
Xorg log file (37.09 KB, text/plain)
2011-09-09 04:42 UTC, Andrey Kiselev
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nico R. 2009-03-29 00:04:42 UTC
On a computer using xorg-7.4 with xorg-server-1.6.0, xf86-video-intel-2.6.99.902 and libXrandr-1.2.99.4 and randrproto-1.2.99.4 (do not know whether the last two are relevant), the DPI values seem to be incorrectly calculated.

The screen is 331x207 millimeters (measured and given as DisplaySize in xorg.conf). The mode set in xorg.conf is 1680x1050.

Grepping the Xorg logfile for that stuff results in the following lines:

(II) intel(0): Output LVDS using initial mode 1680x1050
(**) intel(0): Display dimensions: (331, 207) mm
(**) intel(0): DPI set to (128, 206)
(II) intel(0): Setting screen physical size to 331 x 207


It seems that the vertical DPI value is calculated using the horizontal resolution:

xDPI = 1680/(331/25.4) ~= 128.9    (OK)
yDPI = 1050/(207/25.4) ~= 128.8    (should be that value)
yDPIwrong = 1680/(207/25.4) ~= 206.1    (is that value instead)


I filed this bug for the Driver/intel component, but it may belong to Server/general (or even App/xrandr?). Someone who knows better than me should properly set the component.

This bug might also be related to bug 16789; that looks a bit different, though.
Comment 1 Nico R. 2009-03-29 00:06:57 UTC
Created attachment 24349 [details]
Xorg server logfile
Comment 2 Nico R. 2009-03-29 00:10:37 UTC
Created attachment 24350 [details]
Xorg configuration file
Comment 3 MaLing 2009-03-30 01:26:21 UTC
hi

This is indeed set by xserver, it chose the largest one between HDislay and VDislay of mode as virtuaX/Y of screen.

Thanks
Ma Ling
Comment 4 Michael Fu 2009-04-01 00:19:39 UTC
if it's a xserver bug, please correct the component field then.
Comment 5 Andrey Kiselev 2011-09-09 04:41:19 UTC
I have the very same problem with XOrg 7.6 and radeon 6.14.2 driver.

$ xdpyinfo | egrep "resolution|dimension"
  dimensions:    1680x1050 pixels (444x277 millimeters)
  resolution:    96x96 dots per inch

$ xrandr -q|egrep "Screen| connected"
Screen 0: minimum 320 x 200, current 1680 x 1050, maximum 8192 x 8192
DVI-0 connected 1680x1050+0+0 (normal left inverted right x axis y axis) 473mm x 296mm

xrandr reports the right physical display size and xdpyinfo does not.

Xorg.0.log contains:

[  1357.413] (II) RADEON(0): clock: 146.2 MHz   Image Size:  473 x 296 mm
[  1357.414] (==) RADEON(0): DPI set to (96, 96)

...and following:

[  1357.425] (II) RADEON(0): Setting screen physical size to 444 x 277

I have a single display connected to DVI output and resolution must be 90 dpi, not 96 for my display. If the physical size is detected properly why the DPI value is wrong?

Also it is somewhat similar to bug #25615.
Comment 6 Andrey Kiselev 2011-09-09 04:42:38 UTC
Created attachment 50997 [details]
Xorg log file
Comment 7 Andrey Kiselev 2011-09-09 05:07:23 UTC
If the proper display size is forced in xorg.conf ("DisplaySize 473 296"), xdpyinfo still does not report correct numbers:

$ xdpyinfo | egrep "resolution|dimension"
  dimensions:    1680x1050 pixels (444x277 millimeters)
  resolution:    96x96 dots per inch

From Xorg.log:

[    16.547] (II) RADEON(0): clock: 146.2 MHz   Image Size:  473 x 296 mm
[    16.547] (**) RADEON(0): Display dimensions: (473, 296) mm
[    16.547] (**) RADEON(0): DPI set to (90, 90)

...but later still comes:

[    17.620] (II) RADEON(0): Setting screen physical size to 444 x 277
Comment 8 Andrey Kiselev 2011-09-09 06:44:27 UTC
Even more info: if DPI setting is forced through the command line with option "-dpi 90" (90 is the right value for my case) everything works as it should:

$ xdpyinfo | egrep "resolution|dimension"
  dimensions:    1680x1050 pixels (474x296 millimeters)
  resolution:    90x90 dots per inch

$ xrandr -q|egrep "Screen| connected"
Screen 0: minimum 320 x 200, current 1680 x 1050, maximum 8192 x 8192
DVI-0 connected 1680x1050+0+0 (normal left inverted right x axis y axis) 473mm x 296mm

[  5909.821] (II) RADEON(0): clock: 146.2 MHz   Image Size:  473 x 296 mm
...
[  5909.833] (II) RADEON(0): Setting screen physical size to 474 x 296

So I can suppose that the problem located somewhere in the following code from xf86RandR12.c:

    if (width && height)
    {
	/*
	 * Compute physical size of screen
	 */
	if (monitorResolution) 
	{
	    mmWidth = width * 25.4 / monitorResolution;
	    mmHeight = height * 25.4 / monitorResolution;
	}
	else
	{
	    xf86OutputPtr   output = xf86CompatOutput(pScrn);

	    if (output &&
		output->conf_monitor &&
		(output->conf_monitor->mon_width  > 0 &&
		 output->conf_monitor->mon_height > 0))
	    {
		/*
		 * Prefer user configured DisplaySize
		 */
		mmWidth = output->conf_monitor->mon_width;
		mmHeight = output->conf_monitor->mon_height;
	    }
	    else
	    {
		/*
		 * Otherwise, just set the screen to DEFAULT_DPI
		 */
		mmWidth = width * 25.4 / DEFAULT_DPI;
		mmHeight = height * 25.4 / DEFAULT_DPI;
	    }
	}
	xf86DrvMsg(pScrn->scrnIndex, X_INFO,
		   "Setting screen physical size to %d x %d\n",
		   mmWidth, mmHeight);

or the monitorResolution is being incorrectly set somewhere before that. Though I am not ready to debug it myself.
Comment 9 Michal Suchanek 2012-04-25 03:17:15 UTC
There are two issues here.

The first issue was that the X server calculated wrong DPI, the latter that it sets DPI to 96 (bug 23705).


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct.