2 * Copyright (C) 2015 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include "drmresources.h"
23 #include <xf86drmMode.h>
27 DrmMode::DrmMode(drmModeModeInfoPtr m)
30 h_display_(m->hdisplay),
31 h_sync_start_(m->hsync_start),
32 h_sync_end_(m->hsync_end),
35 v_display_(m->vdisplay),
36 v_sync_start_(m->vsync_start),
37 v_sync_end_(m->vsync_end),
40 v_refresh_(m->vrefresh),
68 bool DrmMode::operator==(const drmModeModeInfo &m) const {
69 return clock_ == m.clock && h_display_ == m.hdisplay &&
70 h_sync_start_ == m.hsync_start && h_sync_end_ == m.hsync_end &&
71 h_total_ == m.htotal && h_skew_ == m.hskew &&
72 v_display_ == m.vdisplay && v_sync_start_ == m.vsync_start &&
73 v_sync_end_ == m.vsync_end && v_total_ == m.vtotal &&
74 v_scan_ == m.vscan && v_refresh_ == m.vrefresh && flags_ == m.flags &&
78 void DrmMode::ToModeModeInfo(drmModeModeInfo *m) const {
80 m->hdisplay = h_display_;
81 m->hsync_start = h_sync_start_;
82 m->hsync_end = h_sync_end_;
85 m->vdisplay = v_display_;
86 m->vsync_start = v_sync_start_;
87 m->vsync_end = v_sync_end_;
90 m->vrefresh = v_refresh_;
93 strncpy(m->name, name_.c_str(), DRM_DISPLAY_MODE_LEN);
96 uint32_t DrmMode::id() const {
100 void DrmMode::set_id(uint32_t id) {
104 uint32_t DrmMode::clock() const {
108 uint32_t DrmMode::h_display() const {
112 uint32_t DrmMode::h_sync_start() const {
113 return h_sync_start_;
116 uint32_t DrmMode::h_sync_end() const {
120 uint32_t DrmMode::h_total() const {
124 uint32_t DrmMode::h_skew() const {
128 uint32_t DrmMode::v_display() const {
132 uint32_t DrmMode::v_sync_start() const {
133 return v_sync_start_;
136 uint32_t DrmMode::v_sync_end() const {
140 uint32_t DrmMode::v_total() const {
144 uint32_t DrmMode::v_scan() const {
148 uint32_t DrmMode::v_refresh() const {
152 uint32_t DrmMode::flags() const {
156 uint32_t DrmMode::type() const {
160 std::string DrmMode::name() const {