external/drm_hwcomposer
Revision | 792fa3e7ebbeef2817f9c20ea4fc692ae1ae7f67 (tree) |
---|---|
Time | 2018-11-02 16:06:15 |
Author | Chih-Wei Huang <cwhuang@linu...> |
Commiter | Chih-Wei Huang |
drm_hwcomposer: allow to force mode by a property
The desired resolution could be set by property debug.drm.mode.force.
The other modes are ignored.
@@ -23,6 +23,7 @@ | ||
23 | 23 | #include <stdint.h> |
24 | 24 | |
25 | 25 | #include <cutils/log.h> |
26 | +#include <cutils/properties.h> | |
26 | 27 | #include <xf86drmMode.h> |
27 | 28 | |
28 | 29 | namespace android { |
@@ -83,6 +84,19 @@ bool DrmConnector::valid_type() const { | ||
83 | 84 | } |
84 | 85 | |
85 | 86 | int DrmConnector::UpdateModes() { |
87 | + char value[PROPERTY_VALUE_MAX]; | |
88 | + uint32_t xres = 0, yres = 0, rate = 0; | |
89 | + if (property_get("debug.drm.mode.force", value, NULL)) { | |
90 | + // parse <xres>x<yres>[@<refreshrate>] | |
91 | + if (sscanf(value, "%dx%d@%d", &xres, &yres, &rate) != 3) { | |
92 | + rate = 0; | |
93 | + if (sscanf(value, "%dx%d", &xres, &yres) != 2) { | |
94 | + xres = yres = 0; | |
95 | + } | |
96 | + } | |
97 | + ALOGI_IF(xres && yres, "force mode to %dx%d@%dHz", xres, yres, rate); | |
98 | + } | |
99 | + | |
86 | 100 | int fd = drm_->fd(); |
87 | 101 | |
88 | 102 | drmModeConnectorPtr c = drmModeGetConnector(fd, id_); |
@@ -107,8 +121,14 @@ int DrmConnector::UpdateModes() { | ||
107 | 121 | continue; |
108 | 122 | |
109 | 123 | DrmMode m(&c->modes[i]); |
124 | + if (xres && yres) { | |
125 | + if (m.h_display() != xres || m.v_display() != yres || | |
126 | + (rate && uint32_t(m.v_refresh()) != rate)) | |
127 | + continue; | |
128 | + } | |
110 | 129 | m.set_id(drm_->next_mode_id()); |
111 | 130 | new_modes.push_back(m); |
131 | + ALOGD("add new mode %dx%d@%.1f id %d for display %d", m.h_display(), m.v_display(), m.v_refresh(), m.id(), display_); | |
112 | 132 | } |
113 | 133 | modes_.swap(new_modes); |
114 | 134 | return 0; |