mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 00:37:23 +01:00
DisplayServer (Linux): use libdrm
Which correctly detects current mode ( instead of preferred mode ) and supports refresh rate
This commit is contained in:
@@ -46,13 +46,13 @@ jobs:
|
||||
run: uname -a
|
||||
|
||||
- name: install required packages
|
||||
run: sudo apt-get update && sudo apt-get install -y musl-dev musl-tools linux-headers-generic libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev directx-headers-dev
|
||||
run: sudo apt-get update && sudo apt-get install -y musl-dev musl-tools linux-headers-generic libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev directx-headers-dev libdrm-dev
|
||||
|
||||
- name: configure project
|
||||
env:
|
||||
CC: ${{ matrix.compiler.cc }}
|
||||
CXX: ${{ matrix.compiler.cxx }}
|
||||
run: cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_LIBPCI=${{ matrix.enableFeatures }} -DENABLE_VULKAN=${{ matrix.enableFeatures }} -DENABLE_WAYLAND=${{ matrix.enableFeatures }} -DENABLE_XCB_RANDR=${{ matrix.enableFeatures }} -DENABLE_XCB=${{ matrix.enableFeatures }} -DENABLE_XRANDR=${{ matrix.enableFeatures }} -DENABLE_X11=${{ matrix.enableFeatures }} -DENABLE_GIO=${{ matrix.enableFeatures }} -DENABLE_DCONF=${{ matrix.enableFeatures }} -DENABLE_DBUS=${{ matrix.enableFeatures }} -DENABLE_XFCONF=${{ matrix.enableFeatures }} -DENABLE_SQLITE3=${{ matrix.enableFeatures }} -DENABLE_RPM=${{ matrix.enableFeatures }} -DENABLE_IMAGEMAGICK7=${{ matrix.enableFeatures }} -DENABLE_IMAGEMAGICK6=${{ matrix.enableFeatures }} -DENABLE_CHAFA=${{ matrix.enableFeatures }} -DENABLE_ZLIB=${{ matrix.enableFeatures }} -DENABLE_EGL=${{ matrix.enableFeatures }} -DENABLE_GLX=${{ matrix.enableFeatures }} -DENABLE_OSMESA=${{ matrix.enableFeatures }} -DENABLE_OPENCL=${{ matrix.enableFeatures }} -DENABLE_LIBNM=${{ matrix.enableFeatures }} -DENABLE_PULSE=${{ matrix.enableFeatures }} -DENABLE_DIRECTX_HEADERS=${{ matrix.enableFeatures }} .
|
||||
run: cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_LIBPCI=${{ matrix.enableFeatures }} -DENABLE_VULKAN=${{ matrix.enableFeatures }} -DENABLE_WAYLAND=${{ matrix.enableFeatures }} -DENABLE_XCB_RANDR=${{ matrix.enableFeatures }} -DENABLE_XCB=${{ matrix.enableFeatures }} -DENABLE_XRANDR=${{ matrix.enableFeatures }} -DENABLE_X11=${{ matrix.enableFeatures }} -DENABLE_GIO=${{ matrix.enableFeatures }} -DENABLE_DCONF=${{ matrix.enableFeatures }} -DENABLE_DBUS=${{ matrix.enableFeatures }} -DENABLE_XFCONF=${{ matrix.enableFeatures }} -DENABLE_SQLITE3=${{ matrix.enableFeatures }} -DENABLE_RPM=${{ matrix.enableFeatures }} -DENABLE_IMAGEMAGICK7=${{ matrix.enableFeatures }} -DENABLE_IMAGEMAGICK6=${{ matrix.enableFeatures }} -DENABLE_CHAFA=${{ matrix.enableFeatures }} -DENABLE_ZLIB=${{ matrix.enableFeatures }} -DENABLE_EGL=${{ matrix.enableFeatures }} -DENABLE_GLX=${{ matrix.enableFeatures }} -DENABLE_OSMESA=${{ matrix.enableFeatures }} -DENABLE_OPENCL=${{ matrix.enableFeatures }} -DENABLE_LIBNM=${{ matrix.enableFeatures }} -DENABLE_PULSE=${{ matrix.enableFeatures }} -DENABLE_DIRECTX_HEADERS=${{ matrix.enableFeatures }} -DENABLE_DRM=${{ matrix.enableFeatures }} .
|
||||
|
||||
- name: build project
|
||||
run: cmake --build .
|
||||
@@ -88,7 +88,7 @@ jobs:
|
||||
run: uname -a
|
||||
|
||||
- name: install required packages
|
||||
run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev directx-headers-dev
|
||||
run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev libdrm-dev directx-headers-dev
|
||||
|
||||
- name: install linuxbrew packages
|
||||
run: |
|
||||
|
||||
@@ -49,6 +49,7 @@ cmake_dependent_option(ENABLE_XCB_RANDR "Enable xcb-randr" ON "LINUX OR BSD" OFF
|
||||
cmake_dependent_option(ENABLE_XCB "Enable xcb" ON "LINUX OR BSD" OFF)
|
||||
cmake_dependent_option(ENABLE_XRANDR "Enable xrandr" ON "LINUX OR BSD" OFF)
|
||||
cmake_dependent_option(ENABLE_X11 "Enable x11" ON "LINUX OR BSD" OFF)
|
||||
cmake_dependent_option(ENABLE_DRM "Enable libdrm" ON "LINUX" OFF)
|
||||
cmake_dependent_option(ENABLE_GIO "Enable gio-2.0" ON "LINUX OR BSD" OFF)
|
||||
cmake_dependent_option(ENABLE_DCONF "Enable dconf" ON "LINUX OR BSD" OFF)
|
||||
cmake_dependent_option(ENABLE_DBUS "Enable dbus-1" ON "LINUX OR BSD" OFF)
|
||||
@@ -392,6 +393,7 @@ if(LINUX)
|
||||
src/detection/disk/disk_linux.c
|
||||
src/detection/diskio/diskio_linux.c
|
||||
src/detection/displayserver/linux/displayserver_linux.c
|
||||
src/detection/displayserver/linux/drm.c
|
||||
src/detection/displayserver/linux/wayland.c
|
||||
src/detection/displayserver/linux/wmde.c
|
||||
src/detection/displayserver/linux/xcb.c
|
||||
@@ -786,6 +788,10 @@ ff_lib_enable(X11
|
||||
"x11"
|
||||
"X11"
|
||||
)
|
||||
ff_lib_enable(DRM
|
||||
"libdrm"
|
||||
"Libdrm"
|
||||
)
|
||||
ff_lib_enable(GIO
|
||||
"gio-2.0"
|
||||
"GIO"
|
||||
|
||||
@@ -470,6 +470,10 @@
|
||||
"type": "string",
|
||||
"description": "X11 sessions for better display detection and faster WM detection.\nThe *randr ones provide multi monitor support The libxcb* ones usually have better performance.\n (Linux, FreeBSD)"
|
||||
},
|
||||
"drm": {
|
||||
"type": "string",
|
||||
"description": "Used for fast resolution and refresh rate detection (Linux)"
|
||||
},
|
||||
"gio": {
|
||||
"type": "string",
|
||||
"description": "Needed for values that are only stored GSettings (Linux, FreeBSD)"
|
||||
|
||||
@@ -181,6 +181,9 @@ void ffListFeatures(void)
|
||||
#ifdef FF_HAVE_X11
|
||||
"x11\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_DRM
|
||||
"drm\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_GIO
|
||||
"gio\n"
|
||||
#endif
|
||||
|
||||
@@ -675,6 +675,14 @@
|
||||
"type": "path"
|
||||
}
|
||||
},
|
||||
{
|
||||
"long": "lib-drm",
|
||||
"desc": "Used for fast resolution and refresh rate detection",
|
||||
"remark": "Linux only",
|
||||
"arg": {
|
||||
"type": "path"
|
||||
}
|
||||
},
|
||||
{
|
||||
"long": "lib-gio",
|
||||
"desc": "Needed for values that are only stored GSettings",
|
||||
|
||||
@@ -1,91 +1,5 @@
|
||||
#include "displayserver_linux.h"
|
||||
#include "common/io/io.h"
|
||||
#include "util/edidHelper.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#include <dirent.h>
|
||||
|
||||
static void parseDRM(FFDisplayServerResult* result)
|
||||
{
|
||||
const char* drmDirPath = "/sys/class/drm/";
|
||||
|
||||
FF_AUTO_CLOSE_DIR DIR* dirp = opendir(drmDirPath);
|
||||
if(dirp == NULL)
|
||||
return;
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY drmDir = ffStrbufCreateA(64);
|
||||
ffStrbufAppendS(&drmDir, drmDirPath);
|
||||
|
||||
uint32_t drmDirLength = drmDir.length;
|
||||
|
||||
struct dirent* entry;
|
||||
while((entry = readdir(dirp)) != NULL)
|
||||
{
|
||||
if(ffStrEquals(entry->d_name, ".") || ffStrEquals(entry->d_name, ".."))
|
||||
continue;
|
||||
|
||||
ffStrbufAppendS(&drmDir, entry->d_name);
|
||||
uint32_t drmDirWithDnameLength = drmDir.length;
|
||||
|
||||
ffStrbufAppendS(&drmDir, "/enabled");
|
||||
char enabled = 'd'; // disabled
|
||||
ffReadFileData(drmDir.chars, sizeof(enabled), &enabled);
|
||||
if (enabled != 'e') // enabled
|
||||
{
|
||||
ffStrbufSubstrBefore(&drmDir, drmDirLength);
|
||||
continue;
|
||||
}
|
||||
|
||||
ffStrbufSubstrBefore(&drmDir, drmDirWithDnameLength);
|
||||
ffStrbufAppendS(&drmDir, "/modes");
|
||||
|
||||
char modes[32];
|
||||
if (ffReadFileData(drmDir.chars, sizeof(modes), modes) < 3)
|
||||
{
|
||||
ffStrbufSubstrBefore(&drmDir, drmDirLength);
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32_t width = 0, height = 0;
|
||||
|
||||
int scanned = sscanf(modes, "%ux%u", &width, &height);
|
||||
if(scanned == 2 && width > 0 && height > 0)
|
||||
{
|
||||
ffStrbufSubstrBefore(&drmDir, drmDirLength);
|
||||
ffStrbufAppendS(&drmDir, entry->d_name);
|
||||
ffStrbufAppendS(&drmDir, "/edid");
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY name = ffStrbufCreate();
|
||||
uint8_t edidData[128];
|
||||
if(ffReadFileData(drmDir.chars, sizeof(edidData), edidData) == sizeof(edidData))
|
||||
ffEdidGetName(edidData, &name);
|
||||
else
|
||||
{
|
||||
const char* plainName = entry->d_name;
|
||||
if (ffStrStartsWith(plainName, "card"))
|
||||
{
|
||||
const char* tmp = strchr(plainName + strlen("card"), '-');
|
||||
if (tmp) plainName = tmp + 1;
|
||||
}
|
||||
ffStrbufAppendS(&name, plainName);
|
||||
}
|
||||
|
||||
ffdsAppendDisplay(
|
||||
result,
|
||||
width, height,
|
||||
0,
|
||||
0, 0,
|
||||
0,
|
||||
&name,
|
||||
FF_DISPLAY_TYPE_UNKNOWN,
|
||||
false,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
ffStrbufSubstrBefore(&drmDir, drmDirLength);
|
||||
}
|
||||
}
|
||||
|
||||
void ffConnectDisplayServerImpl(FFDisplayServerResult* ds)
|
||||
{
|
||||
@@ -122,7 +36,7 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds)
|
||||
//This display detection method is display server independent.
|
||||
//Use it if all connections failed
|
||||
if(ds->displays.length == 0)
|
||||
parseDRM(ds);
|
||||
ffdsConnectDrm(ds);
|
||||
|
||||
//This fills in missing information about WM / DE by using env vars and iterating processes
|
||||
ffdsDetectWMDE(ds);
|
||||
|
||||
@@ -13,6 +13,8 @@ void ffdsConnectXcb(FFDisplayServerResult* result);
|
||||
void ffdsConnectXrandr(FFDisplayServerResult* result);
|
||||
void ffdsConnectXlib(FFDisplayServerResult* result);
|
||||
|
||||
void ffdsConnectDrm(FFDisplayServerResult* result);
|
||||
|
||||
void ffdsDetectWMDE(FFDisplayServerResult* result);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,239 @@
|
||||
#include "displayserver_linux.h"
|
||||
#include "common/io/io.h"
|
||||
#include "util/edidHelper.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#include <dirent.h>
|
||||
|
||||
static const char* drmParseSysfs(FFDisplayServerResult* result)
|
||||
{
|
||||
const char* drmDirPath = "/sys/class/drm/";
|
||||
|
||||
FF_AUTO_CLOSE_DIR DIR* dirp = opendir(drmDirPath);
|
||||
if(dirp == NULL)
|
||||
return "opendir(drmDirPath) failed";
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY drmDir = ffStrbufCreateA(64);
|
||||
ffStrbufAppendS(&drmDir, drmDirPath);
|
||||
|
||||
uint32_t drmDirLength = drmDir.length;
|
||||
|
||||
struct dirent* entry;
|
||||
while((entry = readdir(dirp)) != NULL)
|
||||
{
|
||||
if(ffStrEquals(entry->d_name, ".") || ffStrEquals(entry->d_name, ".."))
|
||||
continue;
|
||||
|
||||
ffStrbufAppendS(&drmDir, entry->d_name);
|
||||
uint32_t drmDirWithDnameLength = drmDir.length;
|
||||
|
||||
ffStrbufAppendS(&drmDir, "/enabled");
|
||||
char enabled = 'd'; // disabled
|
||||
ffReadFileData(drmDir.chars, sizeof(enabled), &enabled);
|
||||
if (enabled != 'e') // enabled
|
||||
{
|
||||
ffStrbufSubstrBefore(&drmDir, drmDirLength);
|
||||
continue;
|
||||
}
|
||||
|
||||
ffStrbufSubstrBefore(&drmDir, drmDirWithDnameLength);
|
||||
ffStrbufAppendS(&drmDir, "/modes");
|
||||
|
||||
char modes[32];
|
||||
if (ffReadFileData(drmDir.chars, sizeof(modes), modes) < 3)
|
||||
{
|
||||
ffStrbufSubstrBefore(&drmDir, drmDirLength);
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32_t width = 0, height = 0;
|
||||
|
||||
int scanned = sscanf(modes, "%ux%u", &width, &height);
|
||||
if(scanned == 2 && width > 0 && height > 0)
|
||||
{
|
||||
ffStrbufSubstrBefore(&drmDir, drmDirLength);
|
||||
ffStrbufAppendS(&drmDir, entry->d_name);
|
||||
ffStrbufAppendS(&drmDir, "/edid");
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY name = ffStrbufCreate();
|
||||
uint8_t edidData[128];
|
||||
if(ffReadFileData(drmDir.chars, sizeof(edidData), edidData) == sizeof(edidData))
|
||||
ffEdidGetName(edidData, &name);
|
||||
else
|
||||
{
|
||||
const char* plainName = entry->d_name;
|
||||
if (ffStrStartsWith(plainName, "card"))
|
||||
{
|
||||
const char* tmp = strchr(plainName + strlen("card"), '-');
|
||||
if (tmp) plainName = tmp + 1;
|
||||
}
|
||||
ffStrbufAppendS(&name, plainName);
|
||||
}
|
||||
|
||||
ffdsAppendDisplay(
|
||||
result,
|
||||
width, height,
|
||||
0,
|
||||
0, 0,
|
||||
0,
|
||||
&name,
|
||||
FF_DISPLAY_TYPE_UNKNOWN,
|
||||
false,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
ffStrbufSubstrBefore(&drmDir, drmDirLength);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_DRM
|
||||
|
||||
#include "common/library.h"
|
||||
|
||||
#include <xf86drm.h>
|
||||
#include <xf86drmMode.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
static const char* drmConnectLibdrm(FFDisplayServerResult* result)
|
||||
{
|
||||
FF_LIBRARY_LOAD(libdrm, &instance.config.library.libdrm, "dlopen(libdrm)" FF_LIBRARY_EXTENSION " failed", "libdrm" FF_LIBRARY_EXTENSION, 2)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libdrm, drmGetDevices)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libdrm, drmModeGetResources)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libdrm, drmModeGetConnectorCurrent)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libdrm, drmModeGetCrtc)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libdrm, drmModeGetEncoder)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libdrm, drmModeGetProperty)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libdrm, drmModeGetPropertyBlob)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libdrm, drmModeFreeCrtc)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libdrm, drmModeFreeEncoder)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libdrm, drmModeFreeConnector)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libdrm, drmModeFreeProperty)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libdrm, drmModeFreePropertyBlob)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libdrm, drmModeGetConnectorTypeName)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libdrm, drmFreeDevices)
|
||||
|
||||
drmDevice* devices[64];
|
||||
int nDevices = ffdrmGetDevices(devices, sizeof(devices) / sizeof(devices[0]));
|
||||
if (nDevices < 0)
|
||||
return "drmGetDevices() failed";
|
||||
|
||||
for (int iDev = 0; iDev < nDevices; ++iDev)
|
||||
{
|
||||
drmDevice* dev = devices[iDev];
|
||||
|
||||
if (!(dev->available_nodes & (1 << DRM_NODE_PRIMARY)))
|
||||
continue;
|
||||
|
||||
const char* path = dev->nodes[DRM_NODE_PRIMARY];
|
||||
FF_AUTO_CLOSE_FD int fd = open(path, O_RDONLY | O_CLOEXEC);
|
||||
if (fd < 0)
|
||||
continue;
|
||||
|
||||
drmModeRes* res = ffdrmModeGetResources(fd);
|
||||
if (!res)
|
||||
continue;
|
||||
|
||||
for (int iConn = 0; iConn < res->count_connectors; ++iConn)
|
||||
{
|
||||
drmModeConnector* conn = ffdrmModeGetConnectorCurrent(fd, res->connectors[iConn]);
|
||||
if (!conn)
|
||||
continue;
|
||||
|
||||
if (conn->connection != DRM_MODE_CONNECTED)
|
||||
goto next_conn;
|
||||
|
||||
drmModeEncoder* encoder = ffdrmModeGetEncoder(fd, conn->encoder_id);
|
||||
if (!encoder)
|
||||
goto next_conn;
|
||||
|
||||
drmModeCrtc* crtc = ffdrmModeGetCrtc(fd, encoder->crtc_id);
|
||||
if (!crtc)
|
||||
goto next_encoder;
|
||||
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY name = ffStrbufCreate();
|
||||
|
||||
for (int iProp = 0; iProp < conn->count_props; ++iProp)
|
||||
{
|
||||
drmModePropertyRes *prop = ffdrmModeGetProperty(fd, conn->props[iProp]);
|
||||
if (!prop)
|
||||
continue;
|
||||
|
||||
uint32_t type = prop->flags & (DRM_MODE_PROP_LEGACY_TYPE | DRM_MODE_PROP_EXTENDED_TYPE);
|
||||
if (type == DRM_MODE_PROP_BLOB && ffStrEquals(prop->name, "EDID"))
|
||||
{
|
||||
// Stangely, prop->count_blobs is 0 and prop->blob_ids is NULL
|
||||
drmModePropertyBlobPtr blob = ffdrmModeGetPropertyBlob(fd, (uint32_t) conn->prop_values[iProp]);
|
||||
if (blob->length >= 128)
|
||||
ffEdidGetName(blob->data, &name);
|
||||
ffdrmModeFreePropertyBlob(blob);
|
||||
break;
|
||||
}
|
||||
ffdrmModeFreeProperty(prop);
|
||||
}
|
||||
|
||||
if (name.length == 0)
|
||||
{
|
||||
const char* connectorTypeName = ffdrmModeGetConnectorTypeName(conn->connector_type);
|
||||
if (connectorTypeName == NULL)
|
||||
connectorTypeName = "Unknown";
|
||||
ffStrbufSetF(&name, "%s-%d", connectorTypeName, iConn);
|
||||
}
|
||||
|
||||
uint32_t refreshRate = crtc->mode.vrefresh;
|
||||
if (refreshRate == 0)
|
||||
{
|
||||
// There are weird cases that we can't get the refresh rate from the CRTC but from the modes
|
||||
for (int iMode = 0; iMode < conn->count_modes; ++iMode)
|
||||
{
|
||||
drmModeModeInfo* mode = &conn->modes[iMode];
|
||||
if (mode->clock == crtc->mode.clock && mode->htotal == crtc->mode.htotal)
|
||||
{
|
||||
refreshRate = mode->vrefresh;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ffdsAppendDisplay(
|
||||
result,
|
||||
crtc->width, crtc->height,
|
||||
refreshRate,
|
||||
0, 0,
|
||||
0,
|
||||
&name,
|
||||
FF_DISPLAY_TYPE_UNKNOWN,
|
||||
false,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
ffdrmModeFreeCrtc(crtc);
|
||||
|
||||
next_encoder:
|
||||
ffdrmModeFreeEncoder(encoder);
|
||||
|
||||
next_conn:
|
||||
ffdrmModeFreeConnector(conn);
|
||||
}
|
||||
}
|
||||
|
||||
ffdrmFreeDevices(devices, nDevices);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void ffdsConnectDrm(FFDisplayServerResult* result)
|
||||
{
|
||||
#ifdef FF_HAVE_DRM
|
||||
if (drmConnectLibdrm(result) == NULL)
|
||||
return;
|
||||
#endif
|
||||
|
||||
drmParseSysfs(result);
|
||||
}
|
||||
+12
-54
@@ -65,6 +65,8 @@ const char* ffOptionsParseLibraryJsonConfig(FFOptionsLibrary* options, yyjson_va
|
||||
ffStrbufSetS(&options->libnm, yyjson_get_str(val));
|
||||
else if (ffStrEqualsIgnCase(key, "ddcutil"))
|
||||
ffStrbufSetS(&options->libDdcutil, yyjson_get_str(val));
|
||||
else if (ffStrEqualsIgnCase(key, "drm"))
|
||||
ffStrbufSetS(&options->libdrm, yyjson_get_str(val));
|
||||
#endif
|
||||
|
||||
else
|
||||
@@ -129,6 +131,8 @@ bool ffOptionsParseLibraryCommandLine(FFOptionsLibrary* options, const char* key
|
||||
ffOptionParseString(key, value, &options->libnm);
|
||||
else if(ffStrEqualsIgnCase(subkey, "ddcutil"))
|
||||
ffOptionParseString(key, value, &options->libDdcutil);
|
||||
else if(ffStrEqualsIgnCase(subkey, "drm"))
|
||||
ffOptionParseString(key, value, &options->libdrm);
|
||||
#endif
|
||||
|
||||
else
|
||||
@@ -142,64 +146,15 @@ bool ffOptionsParseLibraryCommandLine(FFOptionsLibrary* options, const char* key
|
||||
|
||||
void ffOptionsInitLibrary(FFOptionsLibrary* options)
|
||||
{
|
||||
ffStrbufInit(&options->libVulkan);
|
||||
ffStrbufInit(&options->libOpenCL);
|
||||
ffStrbufInit(&options->libSQLite3);
|
||||
ffStrbufInit(&options->libImageMagick);
|
||||
ffStrbufInit(&options->libChafa);
|
||||
ffStrbufInit(&options->libZ);
|
||||
|
||||
#if defined(__linux__) || defined(__FreeBSD__)
|
||||
ffStrbufInit(&options->libPCI);
|
||||
ffStrbufInit(&options->libWayland);
|
||||
ffStrbufInit(&options->libXcbRandr);
|
||||
ffStrbufInit(&options->libXcb);
|
||||
ffStrbufInit(&options->libXrandr);
|
||||
ffStrbufInit(&options->libX11);
|
||||
ffStrbufInit(&options->libGIO);
|
||||
ffStrbufInit(&options->libDConf);
|
||||
ffStrbufInit(&options->libDBus);
|
||||
ffStrbufInit(&options->libXFConf);
|
||||
ffStrbufInit(&options->librpm);
|
||||
ffStrbufInit(&options->libEGL);
|
||||
ffStrbufInit(&options->libGLX);
|
||||
ffStrbufInit(&options->libOSMesa);
|
||||
ffStrbufInit(&options->libfreetype);
|
||||
ffStrbufInit(&options->libPulse);
|
||||
ffStrbufInit(&options->libnm);
|
||||
ffStrbufInit(&options->libDdcutil);
|
||||
#endif
|
||||
static_assert(sizeof(*options) % sizeof(FFstrbuf) == 0, "FFOptionsLibrary is not aligned");
|
||||
for (FFstrbuf* pBuf = (void*) options; pBuf < (FFstrbuf*) (options + 1); pBuf++)
|
||||
ffStrbufInit(pBuf);
|
||||
}
|
||||
|
||||
void ffOptionsDestroyLibrary(FFOptionsLibrary* options)
|
||||
{
|
||||
ffStrbufDestroy(&options->libVulkan);
|
||||
ffStrbufDestroy(&options->libOpenCL);
|
||||
ffStrbufDestroy(&options->libSQLite3);
|
||||
ffStrbufDestroy(&options->libImageMagick);
|
||||
ffStrbufDestroy(&options->libChafa);
|
||||
ffStrbufDestroy(&options->libZ);
|
||||
|
||||
#if defined(__linux__) || defined(__FreeBSD__)
|
||||
ffStrbufDestroy(&options->libPCI);
|
||||
ffStrbufDestroy(&options->libWayland);
|
||||
ffStrbufDestroy(&options->libXcbRandr);
|
||||
ffStrbufDestroy(&options->libXcb);
|
||||
ffStrbufDestroy(&options->libXrandr);
|
||||
ffStrbufDestroy(&options->libX11);
|
||||
ffStrbufDestroy(&options->libGIO);
|
||||
ffStrbufDestroy(&options->libDConf);
|
||||
ffStrbufDestroy(&options->libDBus);
|
||||
ffStrbufDestroy(&options->libXFConf);
|
||||
ffStrbufDestroy(&options->librpm);
|
||||
ffStrbufDestroy(&options->libEGL);
|
||||
ffStrbufDestroy(&options->libGLX);
|
||||
ffStrbufDestroy(&options->libOSMesa);
|
||||
ffStrbufDestroy(&options->libfreetype);
|
||||
ffStrbufDestroy(&options->libPulse);
|
||||
ffStrbufDestroy(&options->libnm);
|
||||
ffStrbufDestroy(&options->libDdcutil);
|
||||
#endif
|
||||
for (FFstrbuf* pBuf = (void*) options; pBuf < (FFstrbuf*) (options + 1); pBuf++)
|
||||
ffStrbufDestroy(pBuf);
|
||||
}
|
||||
|
||||
void ffOptionsGenerateLibraryJsonConfig(FFOptionsLibrary* options, yyjson_mut_doc* doc)
|
||||
@@ -278,6 +233,9 @@ void ffOptionsGenerateLibraryJsonConfig(FFOptionsLibrary* options, yyjson_mut_do
|
||||
|
||||
if (!ffStrbufEqual(&options->libDdcutil, &defaultOptions.libDdcutil))
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "ddcutil", &options->libDdcutil);
|
||||
|
||||
if (!ffStrbufEqual(&options->libdrm, &defaultOptions.libdrm))
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "drm", &options->libdrm);
|
||||
#endif
|
||||
|
||||
if (yyjson_mut_obj_size(obj) > 0)
|
||||
|
||||
@@ -30,6 +30,7 @@ typedef struct FFOptionsLibrary
|
||||
FFstrbuf libPulse;
|
||||
FFstrbuf libnm;
|
||||
FFstrbuf libDdcutil;
|
||||
FFstrbuf libdrm;
|
||||
#endif
|
||||
} FFOptionsLibrary;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user