2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
11 #include "DRMConnector.h"
13 #include "DRMEncoder.h"
15 #include "windowing/Resolution.h"
16 #include "windowing/gbm/GBMUtils.h"
33 struct gbm_bo
*bo
= nullptr;
41 CDRMUtils() = default;
43 virtual void FlipPage(struct gbm_bo
* bo
, bool rendered
, bool videoLayer
, bool async
) {}
44 virtual bool SetVideoMode(const RESOLUTION_INFO
& res
, struct gbm_bo
* bo
) { return false; }
45 virtual bool SetActive(bool active
) { return false; }
46 virtual bool InitDrm();
47 virtual void DestroyDrm();
49 int GetFileDescriptor() const { return m_fd
; }
50 int GetRenderNodeFileDescriptor() const { return m_renderFd
; }
51 const char* GetRenderDevicePath() const { return m_renderDevicePath
; }
52 CDRMPlane
* GetVideoPlane() const { return m_video_plane
; }
53 CDRMPlane
* GetGuiPlane() const { return m_gui_plane
; }
54 CDRMCrtc
* GetCrtc() const { return m_crtc
; }
55 CDRMConnector
* GetConnector() const { return m_connector
; }
57 std::vector
<std::string
> GetConnectedConnectorNames();
59 virtual RESOLUTION_INFO
GetCurrentMode();
60 virtual std::vector
<RESOLUTION_INFO
> GetModes();
61 virtual bool SetMode(const RESOLUTION_INFO
& res
);
63 static uint32_t FourCCWithAlpha(uint32_t fourcc
);
64 static uint32_t FourCCWithoutAlpha(uint32_t fourcc
);
66 void SetInFenceFd(int fd
) { m_inFenceFd
= fd
; }
70 return std::exchange(m_outFenceFd
, fd
);
74 bool OpenDrm(bool needConnector
);
75 drm_fb
* DrmFbGetFromBo(struct gbm_bo
*bo
);
78 CDRMConnector
* m_connector
{nullptr};
79 CDRMEncoder
* m_encoder
{nullptr};
80 CDRMCrtc
* m_crtc
{nullptr};
81 CDRMCrtc
* m_orig_crtc
{nullptr};
82 CDRMPlane
* m_video_plane
{nullptr};
83 CDRMPlane
* m_gui_plane
{nullptr};
84 drmModeModeInfo
*m_mode
= nullptr;
92 std::vector
<std::unique_ptr
<CDRMPlane
>> m_planes
;
99 bool FindPreferredMode();
100 bool RestoreOriginalMode();
101 RESOLUTION_INFO
GetResolutionInfo(drmModeModeInfoPtr mode
);
102 void PrintDrmDeviceInfo(drmDevicePtr device
);
105 const char* m_renderDevicePath
{nullptr};
107 std::vector
<std::unique_ptr
<CDRMConnector
>> m_connectors
;
108 std::vector
<std::unique_ptr
<CDRMEncoder
>> m_encoders
;
109 std::vector
<std::unique_ptr
<CDRMCrtc
>> m_crtcs
;