summaryrefslogtreecommitdiffstats
path: root/ui/ozone/platform/drm/gpu/drm_display_mode.cc
blob: b97d2d8cbf94695ee9e66fdf445dffb68d3b53ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/ozone/platform/drm/gpu/drm_display_mode.h"

namespace ui {

namespace {

float GetRefreshRate(const drmModeModeInfo& mode) {
  if (!mode.htotal || !mode.vtotal)
    return mode.vrefresh;

  float clock = mode.clock;
  float htotal = mode.htotal;
  float vtotal = mode.vtotal;

  return (clock * 1000.0f) / (htotal * vtotal);
}

}  // namespace

DrmDisplayMode::DrmDisplayMode(const drmModeModeInfo& mode)
    : DisplayMode(gfx::Size(mode.hdisplay, mode.vdisplay),
                  mode.flags & DRM_MODE_FLAG_INTERLACE,
                  GetRefreshRate(mode)),
      mode_info_(mode) {
}

DrmDisplayMode::~DrmDisplayMode() {
}

}  // namespace ui