aboutsummaryrefslogtreecommitdiff
path: root/backend/drm
diff options
context:
space:
mode:
authorScott Anderson <ascent12@hotmail.com>2017-05-02 18:13:17 +1200
committerScott Anderson <ascent12@hotmail.com>2017-05-02 18:13:17 +1200
commite446a5300b742dd8a7f403bf96d1137e91ba1b11 (patch)
tree8869c45edca511f3743046003725fecbc5d77c9d /backend/drm
parente9d716fc0c294849b627b35f6ea15f60fbdeb522 (diff)
Added example.
Diffstat (limited to 'backend/drm')
-rw-r--r--backend/drm/backend.c17
-rw-r--r--backend/drm/drm.c10
-rw-r--r--backend/drm/session.c2
-rw-r--r--backend/drm/udev.c8
4 files changed, 29 insertions, 8 deletions
diff --git a/backend/drm/backend.c b/backend/drm/backend.c
index 73e57bfa..7db6e9a1 100644
--- a/backend/drm/backend.c
+++ b/backend/drm/backend.c
@@ -12,7 +12,9 @@
#include "backend/drm/udev.h"
#include "common/log.h"
-struct wlr_drm_backend *wlr_drm_backend_init(void)
+struct wlr_drm_backend *wlr_drm_backend_init(struct wl_listener *add,
+ struct wl_listener *rem,
+ struct wl_listener *render)
{
struct wlr_drm_backend *backend = calloc(1, sizeof *backend);
if (!backend) {
@@ -57,6 +59,13 @@ struct wlr_drm_backend *wlr_drm_backend_init(void)
wl_signal_init(&backend->signals.display_rem);
wl_signal_init(&backend->signals.display_render);
+ if (add)
+ wl_signal_add(&backend->signals.display_add, add);
+ if (rem)
+ wl_signal_add(&backend->signals.display_rem, rem);
+ if (render)
+ wl_signal_add(&backend->signals.display_render, render);
+
wlr_drm_scan_connectors(backend);
return backend;
@@ -80,6 +89,7 @@ static void free_display(void *item)
{
struct wlr_drm_display *disp = item;
wlr_drm_display_free(disp, true);
+ free(disp);
}
void wlr_drm_backend_free(struct wlr_drm_backend *backend)
@@ -95,9 +105,14 @@ void wlr_drm_backend_free(struct wlr_drm_backend *backend)
wlr_session_end(&backend->session);
wl_event_source_remove(backend->event_src.drm);
+ wl_event_source_remove(backend->event_src.udev);
wl_event_loop_destroy(backend->event_loop);
list_free(backend->displays);
free(backend);
}
+struct wl_event_loop *wlr_drm_backend_get_event_loop(struct wlr_drm_backend *backend)
+{
+ return backend->event_loop;
+}
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index 226c79fb..470a76bb 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -281,6 +281,7 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *backend)
continue;
}
+ disp->renderer = &backend->renderer;
disp->state = DRM_DISP_DISCONNECTED;
disp->connector = res->connectors[i];
snprintf(disp->name, sizeof disp->name, "%s-%"PRIu32,
@@ -288,6 +289,7 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *backend)
conn->connector_type_id);
list_add(backend->displays, disp);
+ wlr_log(L_INFO, "Found display '%s'", disp->name);
} else {
disp = backend->displays->items[index];
}
@@ -295,12 +297,14 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *backend)
if (disp->state == DRM_DISP_DISCONNECTED &&
conn->connection == DRM_MODE_CONNECTED) {
disp->state = DRM_DISP_NEEDS_MODESET;
+ wlr_log(L_INFO, "Sending modesetting signal for '%s'", disp->name);
wl_signal_emit(&backend->signals.display_add, disp);
} else if (disp->state == DRM_DISP_CONNECTED &&
conn->connection != DRM_MODE_CONNECTED) {
disp->state = DRM_DISP_DISCONNECTED;
wlr_drm_display_free(disp, false);
+ wlr_log(L_INFO, "Sending destruction signal for '%s'", disp->name);
wl_signal_emit(&backend->signals.display_rem, disp);
}
@@ -430,9 +434,9 @@ static drmModeModeInfo *select_mode(size_t num_modes,
return NULL;
}
-bool wlr_drm_display_modeset(struct wlr_drm_backend *backend,
- struct wlr_drm_display *disp, const char *str)
+bool wlr_drm_display_modeset(struct wlr_drm_display *disp, const char *str)
{
+ struct wlr_drm_backend *backend = disp->renderer->backend;
wlr_log(L_INFO, "Modesetting %s with '%s'", disp->name, str);
drmModeConnector *conn = drmModeGetConnector(backend->fd, disp->connector);
@@ -519,7 +523,7 @@ bool wlr_drm_display_modeset(struct wlr_drm_backend *backend,
drmModeFreeConnector(conn);
- wlr_log(L_INFO, "Configuring %s with mode %"PRIu16"x%"PRIu16"@%"PRIu32"\n",
+ wlr_log(L_INFO, "Configuring %s with mode %"PRIu16"x%"PRIu16"@%"PRIu32"",
disp->name, disp->active_mode->hdisplay, disp->active_mode->vdisplay,
disp->active_mode->vrefresh);
diff --git a/backend/drm/session.c b/backend/drm/session.c
index 49223334..073f822b 100644
--- a/backend/drm/session.c
+++ b/backend/drm/session.c
@@ -194,7 +194,7 @@ bool wlr_session_start(struct wlr_session *session)
sprintf(session->path, fmt, session->id);
- ret = sd_bus_open_system(&session->bus);
+ ret = sd_bus_default_system(&session->bus);
if (ret < 0) {
wlr_log(L_ERROR, "Failed to open DBus connection: %s", strerror(-ret));
goto error;
diff --git a/backend/drm/udev.c b/backend/drm/udev.c
index 6c4aa074..ae99bcfc 100644
--- a/backend/drm/udev.c
+++ b/backend/drm/udev.c
@@ -94,9 +94,10 @@ int wlr_udev_find_gpu(struct wlr_udev *udev, struct wlr_session *session)
const char *id = udev_device_get_sysattr_value(pci, "boot_vga");
if (id && strcmp(id, "1") == 0)
is_boot_vga = true;
- udev_device_unref(pci);
+ //udev_device_unref(pci);
}
+ // We already have a valid GPU
if (!is_boot_vga && fd >= 0) {
udev_device_unref(dev);
continue;
@@ -107,9 +108,10 @@ int wlr_udev_find_gpu(struct wlr_udev *udev, struct wlr_session *session)
continue;
}
- if (is_boot_vga) {
+ udev_device_unref(dev);
+
+ if (is_boot_vga)
break;
- }
}
udev_enumerate_unref(en);