0001-revert-dpi-calculation.patch 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
  2. index 0389945a7cf0e18545cbe101639b62cd01f1e276..d03382d263399bba67dc77f6525480f751674bcc 100644
  3. --- a/hw/xfree86/common/xf86Helper.c
  4. +++ b/hw/xfree86/common/xf86Helper.c
  5. @@ -55,6 +55,7 @@
  6. #include "xf86Xinput.h"
  7. #include "xf86InPriv.h"
  8. #include "mivalidate.h"
  9. +#include "xf86Crtc.h"
  10. /* For xf86GetClocks */
  11. #if defined(CSRG_BASED) || defined(__GNU__)
  12. @@ -851,8 +852,9 @@ xf86SetDpi(ScrnInfoPtr pScrn, int x, int y)
  13. {
  14. MessageType from = X_DEFAULT;
  15. xf86MonPtr DDC = (xf86MonPtr) (pScrn->monitor->DDC);
  16. - int ddcWidthmm, ddcHeightmm;
  17. + int probedWidthmm, probedHeightmm;
  18. int widthErr, heightErr;
  19. + xf86OutputPtr compat = xf86CompatOutput(pScrn);
  20. /* XXX Maybe there is no need for widthmm/heightmm in ScrnInfoRec */
  21. pScrn->widthmm = pScrn->monitor->widthmm;
  22. @@ -862,11 +864,15 @@ xf86SetDpi(ScrnInfoPtr pScrn, int x, int y)
  23. /* DDC gives display size in mm for individual modes,
  24. * but cm for monitor
  25. */
  26. - ddcWidthmm = DDC->features.hsize * 10; /* 10mm in 1cm */
  27. - ddcHeightmm = DDC->features.vsize * 10; /* 10mm in 1cm */
  28. + probedWidthmm = DDC->features.hsize * 10; /* 10mm in 1cm */
  29. + probedHeightmm = DDC->features.vsize * 10; /* 10mm in 1cm */
  30. + }
  31. + else if (compat && compat->mm_width > 0 && compat->mm_height > 0) {
  32. + probedWidthmm = compat->mm_width;
  33. + probedHeightmm = compat->mm_height;
  34. }
  35. else {
  36. - ddcWidthmm = ddcHeightmm = 0;
  37. + probedWidthmm = probedHeightmm = 0;
  38. }
  39. if (monitorResolution > 0) {
  40. @@ -892,15 +898,15 @@ xf86SetDpi(ScrnInfoPtr pScrn, int x, int y)
  41. pScrn->widthmm, pScrn->heightmm);
  42. /* Warn if config and probe disagree about display size */
  43. - if (ddcWidthmm && ddcHeightmm) {
  44. + if (probedWidthmm && probedHeightmm) {
  45. if (pScrn->widthmm > 0) {
  46. - widthErr = abs(ddcWidthmm - pScrn->widthmm);
  47. + widthErr = abs(probedWidthmm - pScrn->widthmm);
  48. }
  49. else {
  50. widthErr = 0;
  51. }
  52. if (pScrn->heightmm > 0) {
  53. - heightErr = abs(ddcHeightmm - pScrn->heightmm);
  54. + heightErr = abs(probedHeightmm - pScrn->heightmm);
  55. }
  56. else {
  57. heightErr = 0;
  58. @@ -909,17 +915,17 @@ xf86SetDpi(ScrnInfoPtr pScrn, int x, int y)
  59. /* Should include config file name for monitor here */
  60. xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
  61. "Probed monitor is %dx%d mm, using Displaysize %dx%d mm\n",
  62. - ddcWidthmm, ddcHeightmm, pScrn->widthmm,
  63. + probedWidthmm, probedHeightmm, pScrn->widthmm,
  64. pScrn->heightmm);
  65. }
  66. }
  67. }
  68. - else if (ddcWidthmm && ddcHeightmm) {
  69. + else if (probedWidthmm && probedHeightmm) {
  70. from = X_PROBED;
  71. xf86DrvMsg(pScrn->scrnIndex, from, "Display dimensions: (%d, %d) mm\n",
  72. - ddcWidthmm, ddcHeightmm);
  73. - pScrn->widthmm = ddcWidthmm;
  74. - pScrn->heightmm = ddcHeightmm;
  75. + probedWidthmm, probedHeightmm);
  76. + pScrn->widthmm = probedWidthmm;
  77. + pScrn->heightmm = probedHeightmm;
  78. if (pScrn->widthmm > 0) {
  79. pScrn->xDpi =
  80. (int) ((double) pScrn->virtualX * MMPERINCH / pScrn->widthmm);
  81. diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
  82. index c6e89e66f690cd7e2a26a3d4b663f9f146cd84e0..202791774b31d6c349f27ed692c1b4ea7f1fdca4 100644
  83. --- a/hw/xfree86/modes/xf86Crtc.c
  84. +++ b/hw/xfree86/modes/xf86Crtc.c
  85. @@ -3256,8 +3256,10 @@ xf86OutputSetEDID(xf86OutputPtr output, xf86MonPtr edid_mon)
  86. free(output->MonInfo);
  87. output->MonInfo = edid_mon;
  88. - output->mm_width = 0;
  89. - output->mm_height = 0;
  90. + if (edid_mon) {
  91. + output->mm_width = 0;
  92. + output->mm_height = 0;
  93. + }
  94. if (debug_modes) {
  95. xf86DrvMsg(scrn->scrnIndex, X_INFO, "EDID for output %s\n",
  96. diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
  97. index 50cbd043edc8380a3307dfcd5dee9cb280a50ba9..d4651f4e856f9fbe8b87086405401e4c0989b409 100644
  98. --- a/hw/xfree86/modes/xf86RandR12.c
  99. +++ b/hw/xfree86/modes/xf86RandR12.c
  100. @@ -806,6 +806,12 @@ xf86RandR12CreateScreenResources(ScreenPtr pScreen)
  101. mmWidth = output->conf_monitor->mon_width;
  102. mmHeight = output->conf_monitor->mon_height;
  103. }
  104. + else if (output &&
  105. + (output->mm_width > 0 &&
  106. + output->mm_height > 0)) {
  107. + mmWidth = output->mm_width;
  108. + mmHeight = output->mm_height;
  109. + }
  110. else {
  111. /*
  112. * Otherwise, just set the screen to DEFAULT_DPI