aboutsummaryrefslogtreecommitdiff
path: root/drm
diff options
context:
space:
mode:
authorRoman Stratiienko <roman.o.stratiienko@globallogic.com>2021-11-16 18:23:18 +0200
committerRoman Stratiienko <roman.o.stratiienko@globallogic.com>2021-12-02 14:35:08 +0200
commita148f21336adb103964fea1d2cacc3f408715c4b (patch)
treecb25cc6537424661b03473469608760abc3e82a5 /drm
parent0ee8f58b93a037c5a54bb0a05c12228845a70a76 (diff)
downloaddrm_hwcomposer-a148f21336adb103964fea1d2cacc3f408715c4b.tar.gz
drm_hwcomposer: Rework display modes handling
Android likes to adapt display output frequency to match window context frequency. Unfortunately platform code has some limitations, therefore hwcomposer HAL should be careful with reporting supported display modes. Known platform limitations: 1: Framework doesn't distinguish between interlaced/progressive modes. 2. Framework will not switch display frequency in case margin in FPS rate is very small (<1FPS or so). Not a big issue, but that is causing some CTS tests to fail. In addition to that VRR technology (or seamless mode switching) require hwcomposer to group modes which tells the framework that seamless mode configuration change is supported within a group of display modes. By this commit do the following: 1. Group modes by the resolution: E.g. Group 1: 1024x768i@60 1024x768i@90 1024x768@50 1024x768@50.1 Group 2: 1920x1080@60 1920x1080@24.3 1920x1080i@60 1920x1080i@120 2. Disable modes in a way that each group keeps only interlaced or proressive modes enabled. In case KMS reported preferred mode is interlaced - prefer interlaced for the whole group, otherwise prefer progressive. 3. Disable mode in case different mode in the same group has similar frequency with delta less than 1FPS. 4. Report only modes which remain enabled to the framework. Test: atest CtsGraphicsTestCases Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
Diffstat (limited to 'drm')
-rw-r--r--drm/DrmConnector.cpp26
-rw-r--r--drm/DrmConnector.h6
-rw-r--r--drm/DrmMode.cpp10
-rw-r--r--drm/DrmMode.h8
4 files changed, 8 insertions, 42 deletions
diff --git a/drm/DrmConnector.cpp b/drm/DrmConnector.cpp
index b3179c7..5b3c697 100644
--- a/drm/DrmConnector.cpp
+++ b/drm/DrmConnector.cpp
@@ -159,43 +159,27 @@ std::string DrmConnector::name() const {
}
int DrmConnector::UpdateModes() {
- int fd = drm_->fd();
-
- drmModeConnectorPtr c = drmModeGetConnector(fd, id_);
+ drmModeConnectorPtr c = drmModeGetConnector(drm_->fd(), id_);
if (!c) {
ALOGE("Failed to get connector %d", id_);
return -ENODEV;
}
- state_ = c->connection;
-
- bool preferred_mode_found = false;
- std::vector<DrmMode> new_modes;
+ modes_.clear();
for (int i = 0; i < c->count_modes; ++i) {
bool exists = false;
for (const DrmMode &mode : modes_) {
if (mode == c->modes[i]) {
- new_modes.push_back(mode);
exists = true;
break;
}
}
+
if (!exists) {
- DrmMode m(&c->modes[i]);
- m.set_id(drm_->next_mode_id());
- new_modes.push_back(m);
+ modes_.emplace_back(DrmMode(&c->modes[i]));
}
- // Use only the first DRM_MODE_TYPE_PREFERRED mode found
- if (!preferred_mode_found &&
- (new_modes.back().type() & DRM_MODE_TYPE_PREFERRED)) {
- preferred_mode_id_ = new_modes.back().id();
- preferred_mode_found = true;
- }
- }
- modes_.swap(new_modes);
- if (!preferred_mode_found && !modes_.empty()) {
- preferred_mode_id_ = modes_[0].id();
}
+
return 0;
}
diff --git a/drm/DrmConnector.h b/drm/DrmConnector.h
index e2789ea..f2305aa 100644
--- a/drm/DrmConnector.h
+++ b/drm/DrmConnector.h
@@ -82,10 +82,6 @@ class DrmConnector {
uint32_t mm_width() const;
uint32_t mm_height() const;
- uint32_t get_preferred_mode_id() const {
- return preferred_mode_id_;
- }
-
private:
DrmDevice *drm_;
@@ -111,8 +107,6 @@ class DrmConnector {
DrmProperty writeback_out_fence_;
std::vector<DrmEncoder *> possible_encoders_;
-
- uint32_t preferred_mode_id_{};
};
} // namespace android
diff --git a/drm/DrmMode.cpp b/drm/DrmMode.cpp
index 971c327..1c8bd0f 100644
--- a/drm/DrmMode.cpp
+++ b/drm/DrmMode.cpp
@@ -49,14 +49,6 @@ bool DrmMode::operator==(const drmModeModeInfo &m) const {
v_scan_ == m.vscan && flags_ == m.flags && type_ == m.type;
}
-uint32_t DrmMode::id() const {
- return id_;
-}
-
-void DrmMode::set_id(uint32_t id) {
- id_ = id;
-}
-
uint32_t DrmMode::clock() const {
return clock_;
}
@@ -115,7 +107,7 @@ uint32_t DrmMode::type() const {
}
std::string DrmMode::name() const {
- return name_;
+ return name_ + "@" + std::to_string(v_refresh());
}
auto DrmMode::CreateModeBlob(const DrmDevice &drm)
diff --git a/drm/DrmMode.h b/drm/DrmMode.h
index 0974b5a..41b9e15 100644
--- a/drm/DrmMode.h
+++ b/drm/DrmMode.h
@@ -17,9 +17,10 @@
#ifndef ANDROID_DRM_MODE_H_
#define ANDROID_DRM_MODE_H_
-#include <stdint.h>
+#include <stdio.h>
#include <xf86drmMode.h>
+#include <cstdint>
#include <string>
#include "DrmUnique.h"
@@ -35,9 +36,6 @@ class DrmMode {
bool operator==(const drmModeModeInfo &m) const;
- uint32_t id() const;
- void set_id(uint32_t id);
-
uint32_t clock() const;
uint16_t h_display() const;
@@ -61,8 +59,6 @@ class DrmMode {
auto CreateModeBlob(const DrmDevice &drm) -> DrmModeUserPropertyBlobUnique;
private:
- uint32_t id_ = 0;
-
uint32_t clock_ = 0;
uint16_t h_display_ = 0;