summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2008-10-10 13:41:50 -0400
committerAdam Jackson <ajax@redhat.com>2008-10-10 14:12:57 -0400
commit75504517a30f1bdd593c2a32af81084b59b398a5 (patch)
tree232dd50f5e1f74fe773f08d0211503dd04a4680d
parentb595b65e54b1e15fbce872fe3719da14cfae5b92 (diff)
EDID: Catch monitors that encode aspect ratio for physical size.
This is not legal in either EDID 1.3 or 1.4, but hey, when did a little thing like legality stop anyone. (cherry picked from commit 0660dd9d7009147c395b9ea904539f76f55b9a7f)
-rw-r--r--hw/xfree86/ddc/interpret_edid.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/hw/xfree86/ddc/interpret_edid.c b/hw/xfree86/ddc/interpret_edid.c
index 21391dd66..958247c95 100644
--- a/hw/xfree86/ddc/interpret_edid.c
+++ b/hw/xfree86/ddc/interpret_edid.c
@@ -85,6 +85,47 @@ handle_edid_quirks(xf86MonPtr m)
}
}
}
+
+ /*
+ * some monitors encode the aspect ratio instead of the physical size.
+ * try to find the largest detailed timing that matches that aspect
+ * ratio and use that to fill in the feature section.
+ */
+ if ((m->features.hsize == 16 && m->features.vsize == 9) ||
+ (m->features.hsize == 16 && m->features.vsize == 10) ||
+ (m->features.hsize == 4 && m->features.vsize == 3) ||
+ (m->features.hsize == 5 && m->features.vsize == 4)) {
+ int real_hsize = 0, real_vsize = 0;
+ float target_aspect, timing_aspect;
+
+ target_aspect = (float)m->features.hsize / (float)m->features.vsize;
+ for (i = 0; i < 4; i++) {
+ if (m->det_mon[i].type == DT) {
+ struct detailed_timings *timing;
+ timing = &m->det_mon[i].section.d_timings;
+
+ if (!timing->v_size)
+ continue;
+
+ timing_aspect = (float)timing->h_size / (float)timing->v_size;
+ if (fabs(1 - (timing_aspect / target_aspect)) < 0.05) {
+ real_hsize = max(real_hsize, timing->h_size);
+ real_vsize = max(real_vsize, timing->v_size);
+ }
+ }
+ }
+
+ if (real_hsize && real_vsize) {
+ /* convert mm to cm */
+ m->features.hsize = (real_hsize + 5) / 10;
+ m->features.vsize = (real_vsize + 5) / 10;
+ } else {
+ m->features.hsize = m->features.vsize = 0;
+ }
+
+ xf86Msg(X_INFO, "Quirked EDID physical size to %dx%d cm\n",
+ m->features.hsize, m->features.vsize);
+ }
}
xf86MonPtr