MythTV  master
mythdrmdevice.h
Go to the documentation of this file.
1 #ifndef MYTHDRMDEVICE_H
2 #define MYTHDRMDEVICE_H
3 
4 // MythTV
5 #include "mythlogging.h"
6 #include "mythdisplay.h"
7 #if defined (USING_QTPRIVATEHEADERS)
9 #endif
14 
15 // Std
16 #include <memory>
17 
18 using MythDRMPtr = std::shared_ptr<class MythDRMDevice>;
19 using MythAtomic = std::tuple<uint32_t,uint32_t,uint64_t>;
20 using MythAtomics = std::vector<MythAtomic>;
21 
22 #define DRM_QUIET "Shush"
23 
25 {
26  public:
27  static std::tuple<QString,QStringList> GetDeviceList();
28  static MythDRMPtr Create(QScreen *qScreen, const QString& Device = QString(), bool NeedPlanes = true);
29  ~MythDRMDevice();
30 
31  bool Authenticated () const;
32  bool Atomic () const;
33  int GetFD () const;
34  QString GetSerialNumber() const;
35  QScreen* GetScreen () const;
36  QSize GetResolution () const;
37  QSize GetPhysicalSize() const;
38  double GetRefreshRate () const;
39  MythEDID GetEDID () const;
40  DRMCrtc GetCrtc () const;
41  DRMConn GetConnector () const;
42  const DRMModes& GetModes() const;
43  bool CanSwitchModes () const;
44  bool SwitchMode (int ModeIndex);
45 
46 #if defined (USING_QTPRIVATEHEADERS)
47  static inline bool s_mythDRMVideo = qEnvironmentVariableIsSet("MYTHTV_DRM_VIDEO");
48  static inline bool s_planarRequested = false;
49  static inline bool s_planarSetup = false;
50 #if QT_VERSION < QT_VERSION_CHECK(5,10,0)
51  static inline QString s_mythDRMDevice = QString(qgetenv("MYTHTV_DRM_DEVICE"));
52  static inline QString s_mythDRMConnector = QString(qgetenv("MYTHTV_DRM_CONNECTOR"));
53  static inline QString s_mythDRMVideoMode = QString(qgetenv("MYTHTV_DRM_MODE"));
54 #else
55  static inline QString s_mythDRMDevice = qEnvironmentVariable("MYTHTV_DRM_DEVICE");
56  static inline QString s_mythDRMConnector = qEnvironmentVariable("MYTHTV_DRM_CONNECTOR");
57  static inline QString s_mythDRMVideoMode = qEnvironmentVariable("MYTHTV_DRM_MODE");
58 #endif
59  static MythDRMPtr FindDevice(bool NeedPlanes = true);
60  static void SetupDRM (const MythCommandLineParser& CmdLine);
61  DRMPlane GetVideoPlane () const;
62  DRMPlane GetGUIPlane () const;
63  bool QueueAtomics (const MythAtomics& Atomics);
64  void DisableVideoPlane();
65  void MainWindowReady ();
66 
67  protected:
68  MythDRMDevice(const QString& Device, bool NeedPlanes);
69  MythDRMDevice(int Fd, uint32_t CrtcId, uint32_t ConnectorId, bool Atomic);
70 
71  private:
72  void AnalysePlanes ();
73  DRMPlane m_videoPlane { nullptr };
74  DRMPlane m_guiPlane { nullptr };
75 #endif
76 
77  protected:
78  explicit MythDRMDevice(QScreen* qScreen, const QString& Device = QString());
79 
80  private:
81  Q_DISABLE_COPY(MythDRMDevice)
82  bool Open ();
83  void Authenticate ();
84  void Load ();
85  bool Initialise ();
86  QString FindBestDevice ();
87  static bool ConfirmDevice(const QString& Device);
88 
89  bool m_valid { false };
90  QScreen* m_screen { nullptr };
91  QString m_deviceName { };
92  bool m_openedDevice { true };
93  int m_fd { -1 };
94  bool m_atomic { false };
95  bool m_authenticated { false };
100  DRMConn m_connector { nullptr };
101  DRMCrtc m_crtc { nullptr };
102  QSize m_resolution { };
103  QSize m_physicalSize { };
104  double m_refreshRate { 0.0 };
105  double m_adjustedRefreshRate { 0.0 };
106  QString m_serialNumber { };
107  LogLevel_t m_verbose { LOG_INFO };
108  MythEDID m_edid { };
109 };
110 
111 #endif
MythCommandLineParser
Parent class for defining application command line parsers.
Definition: mythcommandlineparser.h:116
MUI_PUBLIC
#define MUI_PUBLIC
Definition: mythuiexp.h:9
Device
A device containing images (ie. USB stick, CD, storage group etc)
Definition: imagemanager.cpp:33
DRMCrtc
std::shared_ptr< class MythDRMCrtc > DRMCrtc
Definition: mythdrmcrtc.h:8
DRMCrtcs
std::vector< DRMCrtc > DRMCrtcs
Definition: mythdrmcrtc.h:9
MythDRMDevice::m_crtcs
DRMCrtcs m_crtcs
Definition: mythdrmdevice.h:98
mythdisplay.h
mythlogging.h
MythDRMPtr
std::shared_ptr< class MythDRMDevice > MythDRMPtr
Definition: mythdrmdevice.h:18
MythDRMDevice
Definition: mythdrmdevice.h:24
mythdrmconnector.h
mythdrmplane.h
DRMPlanes
std::vector< DRMPlane > DRMPlanes
Definition: mythdrmplane.h:51
MythDRMDevice::m_encoders
DRMEncs m_encoders
Definition: mythdrmdevice.h:97
DRMConn
std::shared_ptr< class MythDRMConnector > DRMConn
Definition: mythdrmconnector.h:10
MythDRMDevice::m_connectors
DRMConns m_connectors
Definition: mythdrmdevice.h:96
MythAtomic
std::tuple< uint32_t, uint32_t, uint64_t > MythAtomic
Definition: mythdrmdevice.h:19
DRMModes
std::vector< DRMMode > DRMModes
Definition: mythdrmmode.h:8
MythDRMDevice::m_planes
DRMPlanes m_planes
Definition: mythdrmdevice.h:99
mythdrmcrtc.h
DRMConns
std::vector< DRMConn > DRMConns
Definition: mythdrmconnector.h:11
DRMPlane
std::shared_ptr< class MythDRMPlane > DRMPlane
Definition: mythdrmplane.h:50
MythAtomics
std::vector< MythAtomic > MythAtomics
Definition: mythdrmdevice.h:20
DRMEncs
std::vector< DRMEnc > DRMEncs
Definition: mythdrmencoder.h:8
mythcommandlineparser.h
mythdrmencoder.h
MythEDID
Definition: mythedid.h:21