File indexing completed on 2025-04-20 10:57:33
0001 /* 0002 KWin - the KDE window manager 0003 This file is part of the KDE project. 0004 0005 SPDX-FileCopyrightText: 2016 Roman Gilg <subdiff@gmail.com> 0006 SPDX-FileCopyrightText: 2021 Xaver Hugl <xaver.hugl@gmail.com> 0007 0008 SPDX-License-Identifier: GPL-2.0-or-later 0009 */ 0010 #pragma once 0011 0012 #include <QPoint> 0013 #include <QSize> 0014 0015 #include <QSize> 0016 0017 #include "core/output.h" 0018 #include "drm_object.h" 0019 #include "drm_pointer.h" 0020 #include "utils/edid.h" 0021 0022 namespace KWin 0023 { 0024 0025 class DrmPipeline; 0026 class DrmConnector; 0027 class DrmCrtc; 0028 0029 /** 0030 * The DrmConnectorMode class represents a native mode and the associated blob. 0031 */ 0032 class DrmConnectorMode : public OutputMode 0033 { 0034 public: 0035 DrmConnectorMode(DrmConnector *connector, drmModeModeInfo nativeMode); 0036 ~DrmConnectorMode() override; 0037 0038 uint32_t blobId(); 0039 drmModeModeInfo *nativeMode(); 0040 0041 bool operator==(const DrmConnectorMode &otherMode); 0042 0043 private: 0044 DrmConnector *m_connector; 0045 drmModeModeInfo m_nativeMode; 0046 uint32_t m_blobId = 0; 0047 }; 0048 0049 class DrmConnector : public DrmObject 0050 { 0051 public: 0052 DrmConnector(DrmGpu *gpu, uint32_t connectorId); 0053 0054 enum class PropertyIndex : uint32_t { 0055 CrtcId = 0, 0056 NonDesktop = 1, 0057 Dpms = 2, 0058 Edid = 3, 0059 Overscan = 4, 0060 VrrCapable = 5, 0061 Underscan = 6, 0062 Underscan_vborder = 7, 0063 Underscan_hborder = 8, 0064 Broadcast_RGB = 9, 0065 MaxBpc = 10, 0066 LinkStatus = 11, 0067 ContentType = 12, 0068 PanelOrientation = 13, 0069 HdrMetadata = 14, 0070 ScalingMode = 15, 0071 Count 0072 }; 0073 0074 enum class UnderscanOptions : uint32_t { 0075 Off = 0, 0076 On = 1, 0077 Auto = 2, 0078 }; 0079 enum class LinkStatus : uint32_t { 0080 Good = 0, 0081 Bad = 1 0082 }; 0083 enum class DrmContentType : uint64_t { 0084 None = 0, 0085 Graphics = 1, 0086 Photo = 2, 0087 Cinema = 3, 0088 Game = 4 0089 }; 0090 enum class PanelOrientation : uint32_t { 0091 Normal = 0, 0092 UpsideDown = 1, 0093 LeftUp = 2, 0094 RightUp = 3 0095 }; 0096 enum class ScalingMode : uint32_t { 0097 None = 0, 0098 Full = 1, 0099 Center = 2, 0100 Full_Aspect = 3 0101 }; 0102 0103 bool init() override; 0104 bool updateProperties() override; 0105 void disable() override; 0106 0107 bool isCrtcSupported(DrmCrtc *crtc) const; 0108 bool isConnected() const; 0109 bool isNonDesktop() const; 0110 bool isInternal() const; 0111 DrmPipeline *pipeline() const; 0112 0113 const Edid *edid() const; 0114 QString connectorName() const; 0115 QString modelName() const; 0116 QSize physicalSize() const; 0117 0118 QList<std::shared_ptr<DrmConnectorMode>> modes() const; 0119 std::shared_ptr<DrmConnectorMode> findMode(const drmModeModeInfo &modeInfo) const; 0120 0121 Output::SubPixel subpixel() const; 0122 bool hasOverscan() const; 0123 uint32_t overscan() const; 0124 bool vrrCapable() const; 0125 bool hasRgbRange() const; 0126 Output::RgbRange rgbRange() const; 0127 LinkStatus linkStatus() const; 0128 PanelOrientation panelOrientation() const; 0129 0130 static DrmContentType kwinToDrmContentType(ContentType type); 0131 static Output::Transform toKWinTransform(PanelOrientation orientation); 0132 0133 private: 0134 QList<std::shared_ptr<DrmConnectorMode>> generateCommonModes(); 0135 std::shared_ptr<DrmConnectorMode> generateMode(const QSize &size, float refreshRate); 0136 0137 std::unique_ptr<DrmPipeline> m_pipeline; 0138 DrmUniquePtr<drmModeConnector> m_conn; 0139 Edid m_edid; 0140 QSize m_physicalSize = QSize(-1, -1); 0141 QList<std::shared_ptr<DrmConnectorMode>> m_driverModes; 0142 QList<std::shared_ptr<DrmConnectorMode>> m_modes; 0143 uint32_t m_possibleCrtcs = 0; 0144 0145 friend QDebug &operator<<(QDebug &s, const KWin::DrmConnector *obj); 0146 }; 0147 0148 QDebug &operator<<(QDebug &s, const KWin::DrmConnector *obj); 0149 0150 }