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"
22 #include <xf86drmMode.h>
26 DrmMode::DrmMode(drmModeModeInfoPtr m)
29 h_display_(m->hdisplay),
30 h_sync_start_(m->hsync_start),
31 h_sync_end_(m->hsync_end),
34 v_display_(m->vdisplay),
35 v_sync_start_(m->vsync_start),
36 v_sync_end_(m->vsync_end),
39 v_refresh_(m->vrefresh),
67 bool DrmMode::operator==(const drmModeModeInfo &m) const {
68 return clock_ == m.clock && h_display_ == m.hdisplay &&
69 h_sync_start_ == m.hsync_start && h_sync_end_ == m.hsync_end &&
70 h_total_ == m.htotal && h_skew_ == m.hskew &&
71 v_display_ == m.vdisplay && v_sync_start_ == m.vsync_start &&
72 v_sync_end_ == m.vsync_end && v_total_ == m.vtotal &&
73 v_scan_ == m.vscan && v_refresh_ == m.vrefresh && flags_ == m.flags &&
77 void DrmMode::ToDrmModeModeInfo(drm_mode_modeinfo *m) const {
79 m->hdisplay = h_display_;
80 m->hsync_start = h_sync_start_;
81 m->hsync_end = h_sync_end_;
84 m->vdisplay = v_display_;
85 m->vsync_start = v_sync_start_;
86 m->vsync_end = v_sync_end_;
89 m->vrefresh = v_refresh_;
92 strncpy(m->name, name_.c_str(), DRM_DISPLAY_MODE_LEN);
95 uint32_t DrmMode::id() const {
99 void DrmMode::set_id(uint32_t id) {
103 uint32_t DrmMode::clock() const {
107 uint32_t DrmMode::h_display() const {
111 uint32_t DrmMode::h_sync_start() const {
112 return h_sync_start_;
115 uint32_t DrmMode::h_sync_end() const {
119 uint32_t DrmMode::h_total() const {
123 uint32_t DrmMode::h_skew() const {
127 uint32_t DrmMode::v_display() const {
131 uint32_t DrmMode::v_sync_start() const {
132 return v_sync_start_;
135 uint32_t DrmMode::v_sync_end() const {
139 uint32_t DrmMode::v_total() const {
143 uint32_t DrmMode::v_scan() const {
147 uint32_t DrmMode::v_refresh() const {
151 uint32_t DrmMode::flags() const {
155 uint32_t DrmMode::type() const {
159 std::string DrmMode::name() const {