feat: expand Intel GPU display management
This commit is contained in:
1 parent
86de3400a9
commit
471903bafb
25 files changed
+1715
-16
No files matched your search
@@ -12,4 +12,4 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#define MONTAUK_BUILD_NUMBER 20
|
||||
#define MONTAUK_BUILD_NUMBER 24
|
||||
@@ -96,6 +96,22 @@ namespace montauk::abi {
|
||||
return GPU::Flip((int)index, (flags & 1) != 0);
|
||||
}
|
||||
|
||||
static int64_t Sys_DisplayInfo(DisplayInfo* out) {
|
||||
return Drivers::Graphics::IntelGPU::GetDisplayInfo(out) ? 0 : -1;
|
||||
}
|
||||
|
||||
static int64_t Sys_DisplayModes(DisplayModeInfo* out, int maxCount) {
|
||||
return Drivers::Graphics::IntelGPU::GetDisplayModes(out, maxCount);
|
||||
}
|
||||
|
||||
static int64_t Sys_DisplaySetMode(int modeIndex) {
|
||||
return Drivers::Graphics::IntelGPU::SetDisplayMode(modeIndex);
|
||||
}
|
||||
|
||||
static int64_t Sys_DisplayBrightness(int percent) {
|
||||
return Drivers::Graphics::IntelGPU::Brightness(percent);
|
||||
}
|
||||
|
||||
static uint64_t Sys_TermSize() {
|
||||
// If the process is redirected to a GUI terminal, return those dimensions
|
||||
auto* proc = Sched::GetCurrentProcessPtr();
|
||||
|
||||
@@ -150,6 +150,20 @@ namespace montauk::abi {
|
||||
return (int64_t)Sys_FbMap();
|
||||
case SYS_FBFLIP:
|
||||
return Sys_FbFlip(frame->arg1, frame->arg2);
|
||||
case SYS_DISPLAYINFO:
|
||||
if (!UserMemory::Writable<DisplayInfo>(frame->arg1)) return -1;
|
||||
return Sys_DisplayInfo((DisplayInfo*)frame->arg1);
|
||||
case SYS_DISPLAYMODES:
|
||||
// The Intel driver publishes at most 32 modes. Bounding this
|
||||
// here also keeps the userspace range calculation overflow-free.
|
||||
if ((int64_t)frame->arg2 < 0 || frame->arg2 > 32) return -1;
|
||||
if (!UserMemory::Range(frame->arg1,
|
||||
(uint64_t)frame->arg2 * sizeof(DisplayModeInfo), true)) return -1;
|
||||
return Sys_DisplayModes((DisplayModeInfo*)frame->arg1, (int)frame->arg2);
|
||||
case SYS_DISPLAYSETMODE:
|
||||
return Sys_DisplaySetMode((int)frame->arg1);
|
||||
case SYS_DISPLAYBRIGHTNESS:
|
||||
return Sys_DisplayBrightness((int)frame->arg1);
|
||||
case SYS_GETEXECPATH:
|
||||
if (!UserMemory::Range(frame->arg2 ? frame->arg1 : frame->arg1, frame->arg2, true)) return -1;
|
||||
return Sys_GetExecPath((char*)frame->arg1, frame->arg2);
|
||||
|
||||
@@ -291,6 +291,12 @@ namespace montauk::abi {
|
||||
static constexpr uint64_t SYS_STAT = 152;
|
||||
static constexpr uint64_t SYS_SETUNIXTIME = 153;
|
||||
|
||||
/* Graphics.hpp -- display/modesetting control */
|
||||
static constexpr uint64_t SYS_DISPLAYINFO = 154;
|
||||
static constexpr uint64_t SYS_DISPLAYMODES = 155;
|
||||
static constexpr uint64_t SYS_DISPLAYSETMODE = 156;
|
||||
static constexpr uint64_t SYS_DISPLAYBRIGHTNESS = 157;
|
||||
|
||||
// Tunable parameters (for SYS_SDR_SETPARAM / SYS_SDR_GETPARAM).
|
||||
static constexpr int SDR_PARAM_FREQ = 0; // center frequency, Hz
|
||||
static constexpr int SDR_PARAM_SAMPLE_RATE = 1; // sample rate, Hz
|
||||
@@ -351,6 +357,51 @@ namespace montauk::abi {
|
||||
uint64_t userAddr; // filled by SYS_FBMAP (0 until mapped)
|
||||
};
|
||||
|
||||
enum DisplayConnectorType : uint8_t {
|
||||
DISPLAY_CONNECTOR_UNKNOWN = 0,
|
||||
DISPLAY_CONNECTOR_EDP = 1,
|
||||
DISPLAY_CONNECTOR_DP = 2,
|
||||
DISPLAY_CONNECTOR_HDMI = 3,
|
||||
DISPLAY_CONNECTOR_DVI = 4,
|
||||
DISPLAY_CONNECTOR_VGA = 5,
|
||||
DISPLAY_CONNECTOR_LVDS = 6,
|
||||
};
|
||||
|
||||
static constexpr uint32_t DISPLAY_CAP_MODESET = 1u << 0;
|
||||
static constexpr uint32_t DISPLAY_CAP_EDID = 1u << 1;
|
||||
static constexpr uint32_t DISPLAY_CAP_BRIGHTNESS = 1u << 2;
|
||||
static constexpr uint32_t DISPLAY_CAP_PAGE_FLIP = 1u << 3;
|
||||
static constexpr uint32_t DISPLAY_CAP_VBLANK_IRQ = 1u << 4;
|
||||
static constexpr uint32_t DISPLAY_CAP_SAFE_SWITCH = 1u << 5;
|
||||
|
||||
static constexpr uint32_t DISPLAY_MODE_PREFERRED = 1u << 0;
|
||||
static constexpr uint32_t DISPLAY_MODE_CURRENT = 1u << 1;
|
||||
static constexpr uint32_t DISPLAY_MODE_DRIVER_VALID = 1u << 2;
|
||||
|
||||
struct DisplayModeInfo {
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t refreshMilliHz;
|
||||
uint32_t pixelClockKHz;
|
||||
uint32_t flags;
|
||||
uint32_t _pad;
|
||||
};
|
||||
|
||||
struct DisplayInfo {
|
||||
uint32_t capabilities;
|
||||
uint32_t modeCount;
|
||||
int32_t currentMode;
|
||||
int32_t brightness; // 0..100, or -1 when unavailable
|
||||
uint16_t deviceId;
|
||||
uint8_t generation;
|
||||
uint8_t connectorType;
|
||||
uint8_t connected;
|
||||
uint8_t _pad0[3];
|
||||
char gpuName[64];
|
||||
char connectorName[32];
|
||||
char monitorName[64];
|
||||
};
|
||||
|
||||
struct SysInfo {
|
||||
char osName[32];
|
||||
char osVersion[32];
|
||||
|
||||
Reference in new issue
Block a user