summaryrefslogtreecommitdiffstats
path: root/xbmc/windowing/gbm/drm/DRMConnector.h
blob: 5a29222f12015dc641d7a360abf6201e4652fea8 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
 *  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.
 */

#pragma once

#include "DRMObject.h"

#include <string>

namespace KODI
{
namespace WINDOWING
{
namespace GBM
{

class CDRMConnector : public CDRMObject
{
public:
  explicit CDRMConnector(int fd, uint32_t connector);
  CDRMConnector(const CDRMConnector&) = delete;
  CDRMConnector& operator=(const CDRMConnector&) = delete;
  ~CDRMConnector() = default;

  std::string GetType();
  std::string GetStatus();
  std::string GetName();

  uint32_t GetEncoderId() const { return m_connector->encoder_id; }
  uint32_t* GetConnectorId() const { return &m_connector->connector_id; }
  int GetModesCount() const { return m_connector->count_modes; }
  drmModeModeInfoPtr GetModeForIndex(int index) const { return &m_connector->modes[index]; }

  bool IsConnected() { return m_connector->connection == DRM_MODE_CONNECTED; }
  bool CheckConnector();

private:
  struct DrmModeConnectorDeleter
  {
    void operator()(drmModeConnector* p) { drmModeFreeConnector(p); }
  };

  std::unique_ptr<drmModeConnector, DrmModeConnectorDeleter> m_connector;
};

} // namespace GBM
} // namespace WINDOWING
} // namespace KODI