mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-22 06:47:12 -04:00
backend/session: share is_drm_card implementation
This commit is contained in:
parent
ab2425e65f
commit
1e7867610c
5 changed files with 25 additions and 29 deletions
21
backend/session/dev.c
Normal file
21
backend/session/dev.c
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#define _POSIX_C_SOURCE 200809L
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <xf86drm.h>
|
||||
#include "backend/session/dev.h"
|
||||
|
||||
// TODO move to util?
|
||||
bool is_drm_card(const char *devname) {
|
||||
const char prefix[] = DRM_PRIMARY_MINOR_NAME;
|
||||
const char *name = strrchr(devname, '/');
|
||||
name = name ? name + 1 : devname;
|
||||
if (strncmp(name, prefix, strlen(prefix)) != 0) {
|
||||
return false;
|
||||
}
|
||||
for (size_t i = strlen(prefix); name[i] != '\0'; i++) {
|
||||
if (name[i] < '0' || name[i] > '9') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -18,21 +18,6 @@
|
|||
#include "backend/session/dev_demi.h"
|
||||
#include "util/signal.h"
|
||||
|
||||
static bool is_drm_card(const char *devname) {
|
||||
const char prefix[] = DRM_PRIMARY_MINOR_NAME;
|
||||
const char *name = strrchr(devname);
|
||||
name = name ? name + 1 : devname;
|
||||
if (strncmp(name, prefix, strlen(prefix)) != 0) {
|
||||
return false;
|
||||
}
|
||||
for (size_t i = strlen(prefix); name[i] != '\0'; i++) {
|
||||
if (name[i] < '0' || name[i] > '9') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static int handle_event(int fd, uint32_t mask, void *data) {
|
||||
struct wlr_session *session = data;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,19 +20,6 @@
|
|||
|
||||
#define WAIT_GPU_TIMEOUT 10000 // ms
|
||||
|
||||
static bool is_drm_card(const char *sysname) {
|
||||
const char prefix[] = DRM_PRIMARY_MINOR_NAME;
|
||||
if (strncmp(sysname, prefix, strlen(prefix)) != 0) {
|
||||
return false;
|
||||
}
|
||||
for (size_t i = strlen(prefix); sysname[i] != '\0'; i++) {
|
||||
if (sysname[i] < '0' || sysname[i] > '9') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static void read_udev_change_event(struct wlr_device_change_event *event,
|
||||
struct udev_device *udev_dev) {
|
||||
const char *hotplug = udev_device_get_property_value(udev_dev, "HOTPLUG");
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ libseat = dependency('libseat',
|
|||
fallback: 'seatd',
|
||||
default_options: ['server=disabled', 'man-pages=disabled'],
|
||||
)
|
||||
wlr_files += files('session.c')
|
||||
wlr_files += files('session.c', 'dev.c')
|
||||
wlr_deps += libseat
|
||||
|
||||
# libudev & libdemi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue