blob: c2def1ee0d65204e16f34a45b2de8b51b96c210d [file] [log] [blame]
Sean Paul6a55e9f2015-04-30 15:31:06 -04001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17#include "drmmode.h"
18#include "drmresources.h"
19
20#include <stdint.h>
21#include <string>
22
23#include <xf86drmMode.h>
24
25namespace android {
26
27DrmMode::DrmMode(drmModeModeInfoPtr m)
28 : id_(0),
29 clock_(m->clock),
30 h_display_(m->hdisplay),
31 h_sync_start_(m->hsync_start),
32 h_sync_end_(m->hsync_end),
33 h_total_(m->htotal),
34 h_skew_(m->hskew),
35 v_display_(m->vdisplay),
36 v_sync_start_(m->vsync_start),
37 v_sync_end_(m->vsync_end),
38 v_total_(m->vtotal),
39 v_scan_(m->vscan),
40 v_refresh_(m->vrefresh),
41 flags_(m->flags),
42 type_(m->type),
43 name_(m->name) {
44}
45
46DrmMode::DrmMode()
47 : id_(0),
48 clock_(0),
49 h_display_(0),
50 h_sync_start_(0),
51 h_sync_end_(0),
52 h_total_(0),
53 h_skew_(0),
54 v_display_(0),
55 v_sync_start_(0),
56 v_sync_end_(0),
57 v_total_(0),
58 v_scan_(0),
59 v_refresh_(0),
60 flags_(0),
61 type_(0),
62 name_("") {
63}
64
65DrmMode::~DrmMode() {
66}
67
68bool 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 &&
75 type_ == m.type;
76}
77
78void DrmMode::ToModeModeInfo(drmModeModeInfo *m) const {
79 m->clock = clock_;
80 m->hdisplay = h_display_;
81 m->hsync_start = h_sync_start_;
82 m->hsync_end = h_sync_end_;
83 m->htotal = h_total_;
84 m->hskew = h_skew_;
85 m->vdisplay = v_display_;
86 m->vsync_start = v_sync_start_;
87 m->vsync_end = v_sync_end_;
88 m->vtotal = v_total_;
89 m->vscan = v_scan_;
90 m->vrefresh = v_refresh_;
91 m->flags = flags_;
92 m->type = type_;
93 strncpy(m->name, name_.c_str(), DRM_DISPLAY_MODE_LEN);
94}
95
96uint32_t DrmMode::id() const {
97 return id_;
98}
99
100void DrmMode::set_id(uint32_t id) {
101 id_ = id;
102}
103
104uint32_t DrmMode::clock() const {
105 return clock_;
106}
107
108uint32_t DrmMode::h_display() const {
109 return h_display_;
110}
111
112uint32_t DrmMode::h_sync_start() const {
113 return h_sync_start_;
114}
115
116uint32_t DrmMode::h_sync_end() const {
117 return h_sync_end_;
118}
119
120uint32_t DrmMode::h_total() const {
121 return h_total_;
122}
123
124uint32_t DrmMode::h_skew() const {
125 return h_skew_;
126}
127
128uint32_t DrmMode::v_display() const {
129 return v_display_;
130}
131
132uint32_t DrmMode::v_sync_start() const {
133 return v_sync_start_;
134}
135
136uint32_t DrmMode::v_sync_end() const {
137 return v_sync_end_;
138}
139
140uint32_t DrmMode::v_total() const {
141 return v_total_;
142}
143
144uint32_t DrmMode::v_scan() const {
145 return v_scan_;
146}
147
148uint32_t DrmMode::v_refresh() const {
149 return v_refresh_;
150}
151
152uint32_t DrmMode::flags() const {
153 return flags_;
154}
155
156uint32_t DrmMode::type() const {
157 return type_;
158}
159
160std::string DrmMode::name() const {
161 return name_;
162}
163}