mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-21 06:46:46 -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 "backend/session/dev_demi.h"
|
||||||
#include "util/signal.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) {
|
static int handle_event(int fd, uint32_t mask, void *data) {
|
||||||
struct wlr_session *session = data;
|
struct wlr_session *session = data;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,19 +20,6 @@
|
||||||
|
|
||||||
#define WAIT_GPU_TIMEOUT 10000 // ms
|
#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,
|
static void read_udev_change_event(struct wlr_device_change_event *event,
|
||||||
struct udev_device *udev_dev) {
|
struct udev_device *udev_dev) {
|
||||||
const char *hotplug = udev_device_get_property_value(udev_dev, "HOTPLUG");
|
const char *hotplug = udev_device_get_property_value(udev_dev, "HOTPLUG");
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ libseat = dependency('libseat',
|
||||||
fallback: 'seatd',
|
fallback: 'seatd',
|
||||||
default_options: ['server=disabled', 'man-pages=disabled'],
|
default_options: ['server=disabled', 'man-pages=disabled'],
|
||||||
)
|
)
|
||||||
wlr_files += files('session.c')
|
wlr_files += files('session.c', 'dev.c')
|
||||||
wlr_deps += libseat
|
wlr_deps += libseat
|
||||||
|
|
||||||
# libudev & libdemi
|
# libudev & libdemi
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include <stdbool.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <wlr/backend/session.h>
|
#include <wlr/backend/session.h>
|
||||||
#include <wayland-server-core.h>
|
#include <wayland-server-core.h>
|
||||||
|
|
@ -10,4 +11,6 @@ void dev_finish(struct wlr_session *session);
|
||||||
|
|
||||||
ssize_t dev_find_gpus(struct wlr_session *session, size_t ret_len,
|
ssize_t dev_find_gpus(struct wlr_session *session, size_t ret_len,
|
||||||
struct wlr_device **ret);
|
struct wlr_device **ret);
|
||||||
|
|
||||||
|
bool is_drm_card(const char *devname);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue