external/drm_hwcomposer
Revision | efbe9752bb685a138c4fadf96f199e173278e328 (tree) |
---|---|
Time | 2019-10-17 13:24:14 |
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 { |
@@ -74,6 +75,19 @@ bool DrmConnector::built_in() const { | ||
74 | 75 | } |
75 | 76 | |
76 | 77 | int DrmConnector::UpdateModes() { |
78 | + char value[PROPERTY_VALUE_MAX]; | |
79 | + uint32_t xres = 0, yres = 0, rate = 0; | |
80 | + if (property_get("debug.drm.mode.force", value, NULL)) { | |
81 | + // parse <xres>x<yres>[@<refreshrate>] | |
82 | + if (sscanf(value, "%dx%d@%d", &xres, &yres, &rate) != 3) { | |
83 | + rate = 0; | |
84 | + if (sscanf(value, "%dx%d", &xres, &yres) != 2) { | |
85 | + xres = yres = 0; | |
86 | + } | |
87 | + } | |
88 | + ALOGI_IF(xres && yres, "force mode to %dx%d@%dHz", xres, yres, rate); | |
89 | + } | |
90 | + | |
77 | 91 | int fd = drm_->fd(); |
78 | 92 | |
79 | 93 | drmModeConnectorPtr c = drmModeGetConnector(fd, id_); |
@@ -98,8 +112,14 @@ int DrmConnector::UpdateModes() { | ||
98 | 112 | continue; |
99 | 113 | |
100 | 114 | DrmMode m(&c->modes[i]); |
115 | + if (xres && yres) { | |
116 | + if (m.h_display() != xres || m.v_display() != yres || | |
117 | + (rate && uint32_t(m.v_refresh()) != rate)) | |
118 | + continue; | |
119 | + } | |
101 | 120 | m.set_id(drm_->next_mode_id()); |
102 | 121 | new_modes.push_back(m); |
122 | + ALOGD("add new mode %dx%d@%.1f id %d for display %d", m.h_display(), m.v_display(), m.v_refresh(), m.id(), display_); | |
103 | 123 | } |
104 | 124 | modes_.swap(new_modes); |
105 | 125 | return 0; |