diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-05-10 06:57:56 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-05-10 06:57:56 +0000 |
commit | c46e5ac36dade363153b2daabc54b8558753f8b6 (patch) | |
tree | 8e2c640be06a05fdc28ced0de956702c43663f1d /drm/DrmMode.cpp | |
parent | 67918b114ec7f5f4a7832018026a6c8f92712874 (diff) | |
parent | 42f13403a20257cfa97dd490a67681117a6da1b2 (diff) | |
download | drm_hwcomposer-c46e5ac36dade363153b2daabc54b8558753f8b6.tar.gz |
Snap for 8564071 from 42f13403a20257cfa97dd490a67681117a6da1b2 to mainline-tethering-releaseaml_tet_331910040aml_tet_331820050aml_tet_331711040aml_tet_331511160aml_tet_331511000aml_tet_331412030aml_tet_331312080aml_tet_331117000aml_tet_331012080aml_tet_330911010aml_tet_330812150android13-mainline-tethering-release
Change-Id: Ie322106babbf0e41fc9dadc2fc7b1da0064b7a82
Diffstat (limited to 'drm/DrmMode.cpp')
-rw-r--r-- | drm/DrmMode.cpp | 83 |
1 files changed, 43 insertions, 40 deletions
diff --git a/drm/DrmMode.cpp b/drm/DrmMode.cpp index 6de671a..010ea1b 100644 --- a/drm/DrmMode.cpp +++ b/drm/DrmMode.cpp @@ -16,13 +16,14 @@ #include "DrmMode.h" +#include <cstring> + #include "DrmDevice.h" namespace android { DrmMode::DrmMode(drmModeModeInfoPtr m) - : id_(0), - clock_(m->clock), + : clock_(m->clock), h_display_(m->hdisplay), h_sync_start_(m->hsync_start), h_sync_end_(m->hsync_end), @@ -48,79 +49,56 @@ bool DrmMode::operator==(const drmModeModeInfo &m) const { v_scan_ == m.vscan && flags_ == m.flags && type_ == m.type; } -void DrmMode::ToDrmModeModeInfo(drm_mode_modeinfo *m) const { - m->clock = clock_; - m->hdisplay = h_display_; - m->hsync_start = h_sync_start_; - m->hsync_end = h_sync_end_; - m->htotal = h_total_; - m->hskew = h_skew_; - m->vdisplay = v_display_; - m->vsync_start = v_sync_start_; - m->vsync_end = v_sync_end_; - m->vtotal = v_total_; - m->vscan = v_scan_; - m->vrefresh = v_refresh_; - m->flags = flags_; - m->type = type_; - strncpy(m->name, name_.c_str(), DRM_DISPLAY_MODE_LEN); -} - -uint32_t DrmMode::id() const { - return id_; -} - -void DrmMode::set_id(uint32_t id) { - id_ = id; -} - uint32_t DrmMode::clock() const { return clock_; } -uint32_t DrmMode::h_display() const { +uint16_t DrmMode::h_display() const { return h_display_; } -uint32_t DrmMode::h_sync_start() const { +uint16_t DrmMode::h_sync_start() const { return h_sync_start_; } -uint32_t DrmMode::h_sync_end() const { +uint16_t DrmMode::h_sync_end() const { return h_sync_end_; } -uint32_t DrmMode::h_total() const { +uint16_t DrmMode::h_total() const { return h_total_; } -uint32_t DrmMode::h_skew() const { +uint16_t DrmMode::h_skew() const { return h_skew_; } -uint32_t DrmMode::v_display() const { +uint16_t DrmMode::v_display() const { return v_display_; } -uint32_t DrmMode::v_sync_start() const { +uint16_t DrmMode::v_sync_start() const { return v_sync_start_; } -uint32_t DrmMode::v_sync_end() const { +uint16_t DrmMode::v_sync_end() const { return v_sync_end_; } -uint32_t DrmMode::v_total() const { +uint16_t DrmMode::v_total() const { return v_total_; } -uint32_t DrmMode::v_scan() const { +uint16_t DrmMode::v_scan() const { return v_scan_; } float DrmMode::v_refresh() const { + if (clock_ == 0) { + return v_refresh_; + } // Always recalculate refresh to report correct float rate - return clock_ / (float)(v_total_ * h_total_) * 1000.0f; + return static_cast<float>(clock_) / (float)(v_total_ * h_total_) * 1000.0F; } uint32_t DrmMode::flags() const { @@ -132,6 +110,31 @@ 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) + -> DrmModeUserPropertyBlobUnique { + struct drm_mode_modeinfo drm_mode = { + .clock = clock_, + .hdisplay = h_display_, + .hsync_start = h_sync_start_, + .hsync_end = h_sync_end_, + .htotal = h_total_, + .hskew = h_skew_, + .vdisplay = v_display_, + .vsync_start = v_sync_start_, + .vsync_end = v_sync_end_, + .vtotal = v_total_, + .vscan = v_scan_, + .vrefresh = v_refresh_, + .flags = flags_, + .type = type_, + }; + strncpy(drm_mode.name, name_.c_str(), DRM_DISPLAY_MODE_LEN); + + return drm.RegisterUserPropertyBlob(&drm_mode, + sizeof(struct drm_mode_modeinfo)); } + } // namespace android |