OSDN Git Service

Allow to force mode by a property nougat-x86 oreo-x86 pie-x86 q-x86 android-x86-7.1-r5 android-x86-8.1-r6 android-x86-9.0-r2
authorChih-Wei Huang <cwhuang@linux.org.tw>
Fri, 13 Mar 2020 11:33:56 +0000 (19:33 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Fri, 13 Mar 2020 11:33:56 +0000 (19:33 +0800)
The desired resolution could be set by property debug.drm.mode.force.

drm_framebuffer.c

index 4c9871f..2f53bd7 100644 (file)
@@ -26,6 +26,7 @@
 #include <string.h>
 #include <errno.h>
 #include <fcntl.h>
+#include <cutils/properties.h>
 #include <hardware/gralloc.h>
 #include <log/log.h>
 
@@ -90,10 +91,27 @@ static drmModeModeInfoPtr fb0_find_preferred_mode(drmModeConnectorPtr connector)
 {
        int i;
        drmModeModeInfoPtr mode = NULL;
+       char value[PROPERTY_VALUE_MAX];
+       uint32_t xres = 0, yres = 0, rate = 0;
+       if (property_get("debug.drm.mode.force", value, NULL)) {
+               /* parse <xres>x<yres>[@<refreshrate>] */
+               if (sscanf(value, "%dx%d@%d", &xres, &yres, &rate) != 3) {
+                       rate = 0;
+                       if (sscanf(value, "%dx%d", &xres, &yres) != 2) {
+                               xres = yres = 0;
+                       }
+               }
+               ALOGI_IF(xres && yres, "force mode to %dx%d@%dHz", xres, yres, rate);
+       }
 
        for (i = 0; i < connector->count_modes; ++i) {
                mode = &connector->modes[i];
-               if (mode->type & DRM_MODE_TYPE_PREFERRED) {
+               if (xres && yres) {
+                       if (mode->hdisplay == xres && mode->vdisplay == yres &&
+                                       (!rate || mode->vrefresh == rate)) {
+                               break;
+                       }
+               } else if (mode->type & DRM_MODE_TYPE_PREFERRED) {
                        break;
                }
        }