Go to the documentation of this file.
5 #define LOC QString("NVCtrl: ")
34 LOG(VB_GENERAL, LOG_INFO,
LOC +
"No GSync support detected - cannot force");
38 if (gsync->Enabled() == Enable)
40 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"GSync already %1abled")
41 .arg(Enable ?
"en" :
"dis"));
45 gsync->SetEnabled(Enable);
50 LOG(VB_GENERAL, LOG_INFO,
LOC + (Enable ?
"Enabled" :
"Disabled"));
59 auto displayid =
Device->GetDisplayID();
63 auto * display =
Device->m_display->GetDisplay();
83 std::get<0>(Range) = minrate;
84 std::get<2>(Range) =
true;
88 return std::shared_ptr<MythVRR>(
new MythGSync(
Device, vrrtype, allowed > 0, Range));
105 m_nvControl(std::move(
Device))
113 LOG(VB_GENERAL, LOG_INFO,
LOC +
"Resetting GSync to desktop default");
123 int enable = Enable ? 1 : 0;
137 static const QStringList s_paths = {
"libXNVCtrl",
"libXNVCtrl.so.0" };
138 static bool s_available =
false;
139 static bool s_checked =
false;
140 if (s_checked && !s_available)
145 for (
const auto & path : s_paths)
147 if (QLibrary lib(path); lib.load())
150 auto isnvscreen =
reinterpret_cast<bool(*)(Display*,
int)
>(lib.resolve(
"XNVCTRLIsNvScreen"));
151 auto queryversion =
reinterpret_cast<bool(*)(Display*,
int,
int)
>(lib.resolve(
"XNVCTRLQueryVersion"));
152 if (isnvscreen && queryversion)
155 if (xdisplay && xdisplay->GetDisplay())
159 if (isnvscreen(xdisplay->GetDisplay(), xdisplay->GetScreen()) &&
160 queryversion(xdisplay->GetDisplay(), major,
minor))
162 if (
auto res = std::shared_ptr<MythNVControl>(
new MythNVControl(path, xdisplay));
163 res->m_queryBinary && res->m_queryScreen && res->m_queryTarget && res->m_setAttrib)
183 m_queryBinary(reinterpret_cast<
QueryTargetBinary>(m_lib.resolve(
"XNVCTRLQueryTargetBinaryData"))),
184 m_queryScreen(reinterpret_cast<
QueryScreenAttrib>(m_lib.resolve(
"XNVCTRLQueryAttribute"))),
185 m_queryTarget(reinterpret_cast<
QueryTargetAttrib>(m_lib.resolve(
"XNVCTRLQueryTargetAttribute"))),
186 m_setAttrib(reinterpret_cast<
SetAttribute>(m_lib.resolve(
"XNVCTRLSetAttribute")))
200 uint32_t * data =
nullptr;
204 reinterpret_cast<unsigned char **
>(&data), &size))
206 LOG(VB_GENERAL, LOG_WARNING,
LOC +
"Failed to retrieve display id for screen");
216 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"%1 display id's returned - using first")
217 .arg((size - 4) / 4));
220 return static_cast<int>(data[1]);
bool(*)(Display *, int, int, unsigned int, unsigned int, unsigned char **, int *) QueryTargetBinary
static constexpr uint NV_CTRL_VRR_ALLOWED
static constexpr uint NV_CTRL_BINARY_DATA_DISPLAYS_ENABLED_ON_XSCREEN
std::shared_ptr< class MythNVControl > NVControl
static constexpr uint NV_CTRL_DISPLAY_VRR_MIN_REFRESH_RATE
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
A device containing images (ie. USB stick, CD, storage group etc)
static constexpr uint NV_CTRL_DISPLAY_VRR_ENABLED
VERBOSE_PREAMBLE Most true
static MythXDisplay * OpenMythXDisplay(bool Warn=true)
MythNVControl(const QString &Path, MythXDisplay *MDisplay)
bool(*)(Display *, int, unsigned int, unsigned int, int *) QueryScreenAttrib
@ NV_CTRL_DISPLAY_VRR_MODE_GSYNC_COMPATIBLE_UNVALIDATED
static constexpr int NV_CTRL_TARGET_TYPE_DISPLAY
static MythVRRPtr CreateGSync(const NVControl &Device, MythVRRRange Range)
bool(*)(Display *, int, int, unsigned int, unsigned int, int *) QueryTargetAttrib
static bool s_gsyncDefaultValue
@ NV_CTRL_DISPLAY_VRR_MODE_NONE
std::tuple< int, int, bool > MythVRRRange
static constexpr uint NV_CTRL_DISPLAY_VRR_MODE
NV_CTRL_DISPLAY_VRR_MODES
@ NV_CTRL_DISPLAY_VRR_MODE_GSYNC
QueryTargetBinary m_queryBinary
static NVControl Create()
Create a valid instance of MythNVControl.
MythGSync(NVControl Device, VRRType Type, bool Enabled, MythVRRRange Range)
@ NV_CTRL_DISPLAY_VRR_MODE_GSYNC_COMPATIBLE
void(*)(Display *, int, unsigned int, unsigned int, int) SetAttribute
static bool s_gsyncResetOnExit
void SetEnabled(bool Enable=true) override
static constexpr int NV_CTRL_TARGET_TYPE_X_SCREEN
static void ForceGSync(bool Enable)
Enable or disable GSync before the main window is created.
std::shared_ptr< class MythVRR > MythVRRPtr