summaryrefslogtreecommitdiffstats
path: root/xbmc/windowing/gbm/drm/DRMCrtc.cpp
blob: 426fd953bbb77f0c66998c3fad5c25e0f992ee0a (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
/*
 *  Copyright (C) 2005-2020 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#include "DRMCrtc.h"

#include <cstring>
#include <errno.h>
#include <stdexcept>
#include <string>

using namespace KODI::WINDOWING::GBM;

CDRMCrtc::CDRMCrtc(int fd, uint32_t crtc) : CDRMObject(fd), m_crtc(drmModeGetCrtc(m_fd, crtc))
{
  if (!m_crtc)
    throw std::runtime_error("drmModeGetCrtc failed: " + std::string{strerror(errno)});

  if (!GetProperties(m_crtc->crtc_id, DRM_MODE_OBJECT_CRTC))
    throw std::runtime_error("failed to get properties for crtc: " +
                             std::to_string(m_crtc->crtc_id));
}