]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android/external-libkmsxx.git/blobdiff - kms++/src/connector.cpp
Improve mode finding
[android/external-libkmsxx.git] / kms++ / src / connector.cpp
index 92700af0961440919fd7e0a43605cca9b6e2c69d..7c6c179ebff4616b22187aec14c3927688cfcce1 100644 (file)
@@ -132,7 +132,24 @@ Videomode Connector::get_mode(unsigned xres, unsigned yres, float vrefresh, bool
                if (ilace != m.interlace())
                        continue;
 
-               if (vrefresh && std::abs(m.calculated_vrefresh() - vrefresh) >= 0.001)
+               if (vrefresh && vrefresh != m.calculated_vrefresh())
+                       continue;
+
+               return m;
+       }
+
+       // If not found, do another round using rounded vrefresh
+
+       for (int i = 0; i < c->count_modes; i++) {
+               Videomode m = drm_mode_to_video_mode(c->modes[i]);
+
+               if (m.hdisplay != xres || m.vdisplay != yres)
+                       continue;
+
+               if (ilace != m.interlace())
+                       continue;
+
+               if (vrefresh && vrefresh != roundf(m.calculated_vrefresh()))
                        continue;
 
                return m;