aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/backend/drm/drm.h54
-rw-r--r--include/backend/drm/event.h21
-rw-r--r--include/backend/drm/otd.h44
-rw-r--r--include/backend/drm/session.h25
-rw-r--r--include/backend/drm/udev.h9
5 files changed, 153 insertions, 0 deletions
diff --git a/include/backend/drm/drm.h b/include/backend/drm/drm.h
new file mode 100644
index 00000000..8744b440
--- /dev/null
+++ b/include/backend/drm/drm.h
@@ -0,0 +1,54 @@
+#ifndef DRM_H
+#define DRM_H
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <xf86drmMode.h>
+#include <EGL/egl.h>
+#include <gbm.h>
+
+enum otd_display_state {
+ OTD_DISP_INVALID,
+ OTD_DISP_DISCONNECTED,
+ OTD_DISP_NEEDS_MODESET,
+ OTD_DISP_CONNECTED,
+};
+
+struct otd_display {
+ struct otd *otd;
+
+ enum otd_display_state state;
+ uint32_t connector;
+ char name[16];
+
+ size_t num_modes;
+ drmModeModeInfo *modes;
+ drmModeModeInfo *active_mode;
+
+ uint32_t width;
+ uint32_t height;
+
+ uint32_t crtc;
+ drmModeCrtc *old_crtc;
+
+ struct gbm_surface *gbm;
+ EGLSurface *egl;
+ uint32_t fb_id;
+
+ bool pageflip_pending;
+ bool cleanup;
+};
+
+bool init_renderer(struct otd *otd);
+void destroy_renderer(struct otd *otd);
+
+void scan_connectors(struct otd *otd);
+bool modeset_str(struct otd *otd, struct otd_display *disp, const char *str);
+void destroy_display_renderer(struct otd *otd, struct otd_display *disp);
+
+void get_drm_event(struct otd *otd);
+
+void rendering_begin(struct otd_display *disp);
+void rendering_end(struct otd_display *disp);
+
+#endif
diff --git a/include/backend/drm/event.h b/include/backend/drm/event.h
new file mode 100644
index 00000000..fc4f6f9a
--- /dev/null
+++ b/include/backend/drm/event.h
@@ -0,0 +1,21 @@
+#ifndef EVENT_H
+#define EVENT_H
+
+#include <stdbool.h>
+
+enum otd_event_type {
+ OTD_EV_NONE,
+ OTD_EV_RENDER,
+ OTD_EV_DISPLAY_REM,
+ OTD_EV_DISPLAY_ADD,
+};
+
+struct otd_event {
+ enum otd_event_type type;
+ struct otd_display *display;
+};
+
+bool otd_get_event(struct otd *otd, struct otd_event *restrict ret);
+bool event_add(struct otd *otd, struct otd_display *disp, enum otd_event_type type);
+
+#endif
diff --git a/include/backend/drm/otd.h b/include/backend/drm/otd.h
new file mode 100644
index 00000000..eef0e991
--- /dev/null
+++ b/include/backend/drm/otd.h
@@ -0,0 +1,44 @@
+#ifndef LIBOTD_H
+#define LIBOTD_H
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <EGL/egl.h>
+#include <gbm.h>
+#include <libudev.h>
+
+#include "session.h"
+
+struct otd {
+ int fd;
+ bool paused;
+
+ // Priority Queue (Max-heap)
+ size_t event_cap;
+ size_t event_len;
+ struct otd_event *events;
+
+ size_t display_len;
+ struct otd_display *displays;
+
+ uint32_t taken_crtcs;
+
+ struct gbm_device *gbm;
+ struct {
+ EGLDisplay disp;
+ EGLConfig conf;
+ EGLContext context;
+ } egl;
+
+ struct otd_session session;
+
+ struct udev *udev;
+ struct udev_monitor *mon;
+ int udev_fd;
+ char *drm_path;
+};
+
+struct otd *otd_start(void);
+void otd_finish(struct otd *otd);
+
+#endif
diff --git a/include/backend/drm/session.h b/include/backend/drm/session.h
new file mode 100644
index 00000000..c21900e9
--- /dev/null
+++ b/include/backend/drm/session.h
@@ -0,0 +1,25 @@
+#ifndef SESSION_H
+#define SESSION_H
+
+#include <systemd/sd-bus.h>
+#include <stdbool.h>
+
+struct otd_session {
+ char *id;
+ char *path;
+ char *seat;
+
+ sd_bus *bus;
+};
+
+struct otd;
+bool otd_new_session(struct otd *otd);
+void otd_close_session(struct otd *otd);
+
+int take_device(struct otd *restrict otd,
+ const char *restrict path,
+ bool *restrict paused_out);
+
+void release_device(struct otd *otd, int fd);
+
+#endif
diff --git a/include/backend/drm/udev.h b/include/backend/drm/udev.h
new file mode 100644
index 00000000..9bd4c0d0
--- /dev/null
+++ b/include/backend/drm/udev.h
@@ -0,0 +1,9 @@
+#ifndef UDEV_H
+#define UDEV_H
+
+bool otd_udev_start(struct otd *otd);
+void otd_udev_finish(struct otd *otd);
+void otd_udev_find_gpu(struct otd *otd);
+void otd_udev_event(struct otd *otd);
+
+#endif