aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2017-05-10 10:37:29 -0400
committerGitHub <noreply@github.com>2017-05-10 10:37:29 -0400
commitc436e76240ab190a07afcd961ca2dd279af72968 (patch)
treeaab4f835e5341cd44b5937e0cd0dbb012c2369e8 /include
parent1aed98730194aa80b5954ae1d6370162041b56e2 (diff)
parent42878b45a1dba582feb5ec75762d66ede51fdc98 (diff)
Merge pull request #2 from ascent12/master
DRM backend + Session interface + EGL
Diffstat (limited to 'include')
-rw-r--r--include/backend.h17
-rw-r--r--include/backend/drm/backend.h34
-rw-r--r--include/backend/drm/drm.h58
-rw-r--r--include/backend/drm/udev.h24
-rw-r--r--include/backend/egl.h17
-rw-r--r--include/session/interface.h21
-rw-r--r--include/wayland.h18
-rw-r--r--include/wlr/backend.h26
-rw-r--r--include/wlr/backend/drm.h16
-rw-r--r--include/wlr/common/log.h1
-rw-r--r--include/wlr/session.h12
-rw-r--r--include/wlr/wayland.h41
12 files changed, 260 insertions, 25 deletions
diff --git a/include/backend.h b/include/backend.h
new file mode 100644
index 00000000..d42c6f17
--- /dev/null
+++ b/include/backend.h
@@ -0,0 +1,17 @@
+#ifndef _WLR_BACKEND_INTERNAL_H
+#define _WLR_BACKEND_INTERNAL_H
+
+#include <stdbool.h>
+#include <wlr/backend.h>
+
+struct wlr_backend_state;
+
+struct wlr_backend_impl {
+ bool (*init)(struct wlr_backend_state *state);
+ void (*destroy)(struct wlr_backend_state *state);
+};
+
+struct wlr_backend *wlr_backend_create(const struct wlr_backend_impl *impl,
+ struct wlr_backend_state *state);
+
+#endif
diff --git a/include/backend/drm/backend.h b/include/backend/drm/backend.h
new file mode 100644
index 00000000..0c725ccb
--- /dev/null
+++ b/include/backend/drm/backend.h
@@ -0,0 +1,34 @@
+#ifndef DRM_BACKEND_H
+#define DRM_BACKEND_H
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <EGL/egl.h>
+#include <gbm.h>
+#include <libudev.h>
+#include <wayland-server.h>
+
+#include <wlr/session.h>
+#include <wlr/common/list.h>
+#include <wlr/backend/drm.h>
+
+#include "backend.h"
+#include "udev.h"
+#include "event.h"
+#include "drm.h"
+
+struct wlr_backend_state {
+ int fd;
+
+ struct wlr_backend *backend;
+ struct wl_event_source *drm_event;
+
+ uint32_t taken_crtcs;
+ list_t *outputs;
+
+ struct wlr_drm_renderer renderer;
+ struct wlr_session *session;
+ struct wlr_udev udev;
+};
+
+#endif
diff --git a/include/backend/drm/drm.h b/include/backend/drm/drm.h
new file mode 100644
index 00000000..4b42aa68
--- /dev/null
+++ b/include/backend/drm/drm.h
@@ -0,0 +1,58 @@
+#ifndef DRM_H
+#define DRM_H
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <xf86drmMode.h>
+#include <EGL/egl.h>
+#include <gbm.h>
+
+#include "backend/egl.h"
+#include "backend.h"
+
+struct wlr_drm_renderer {
+ int fd;
+ struct gbm_device *gbm;
+ struct wlr_egl egl;
+};
+
+bool wlr_drm_renderer_init(struct wlr_drm_renderer *renderer, int fd);
+void wlr_drm_renderer_free(struct wlr_drm_renderer *renderer);
+
+enum wlr_drm_output_state {
+ DRM_OUTPUT_DISCONNECTED,
+ DRM_OUTPUT_NEEDS_MODESET,
+ DRM_OUTPUT_CONNECTED,
+};
+
+struct wlr_output_mode_state {
+ struct wlr_wl_output_mode *wlr_mode;
+ drmModeModeInfo mode;
+};
+
+struct wlr_output_state {
+ struct wlr_output *wlr_output;
+ enum wlr_drm_output_state state;
+ uint32_t connector;
+ char name[16];
+
+ uint32_t width;
+ uint32_t height;
+
+ uint32_t crtc;
+ drmModeCrtc *old_crtc;
+
+ struct wlr_drm_renderer *renderer;
+ struct gbm_surface *gbm;
+ EGLSurface *egl;
+
+ bool pageflip_pending;
+ bool cleanup;
+};
+
+void wlr_drm_output_cleanup(struct wlr_output_state *output, bool restore);
+
+void wlr_drm_scan_connectors(struct wlr_backend_state *state);
+int wlr_drm_event(int fd, uint32_t mask, void *data);
+
+#endif
diff --git a/include/backend/drm/udev.h b/include/backend/drm/udev.h
new file mode 100644
index 00000000..99c2c403
--- /dev/null
+++ b/include/backend/drm/udev.h
@@ -0,0 +1,24 @@
+#ifndef UDEV_H
+#define UDEV_H
+
+#include <libudev.h>
+
+#include <wlr/session.h>
+#include <wayland-server.h>
+
+struct wlr_udev {
+ struct udev *udev;
+ struct udev_monitor *mon;
+ char *drm_path;
+
+ struct wl_event_source *event;
+};
+
+struct wlr_drm_backend;
+bool wlr_udev_init(struct wl_display *display, struct wlr_udev *udev);
+void wlr_udev_free(struct wlr_udev *udev);
+int wlr_udev_find_gpu(struct wlr_udev *udev, struct wlr_session *session);
+
+void wlr_udev_event(struct wlr_drm_backend *backend);
+
+#endif
diff --git a/include/backend/egl.h b/include/backend/egl.h
new file mode 100644
index 00000000..8cef36b7
--- /dev/null
+++ b/include/backend/egl.h
@@ -0,0 +1,17 @@
+#ifndef WLR_BACKEND_EGL_H
+#define WLR_BACKEND_EGL_H
+
+#include <EGL/egl.h>
+#include <stdbool.h>
+
+struct wlr_egl {
+ EGLDisplay display;
+ EGLConfig config;
+ EGLContext context;
+};
+
+bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, void *display);
+void wlr_egl_free(struct wlr_egl *egl);
+EGLSurface wlr_egl_create_surface(struct wlr_egl *egl, void *window);
+
+#endif
diff --git a/include/session/interface.h b/include/session/interface.h
new file mode 100644
index 00000000..a815718f
--- /dev/null
+++ b/include/session/interface.h
@@ -0,0 +1,21 @@
+#ifndef WLR_SESSION_INTERFACE_H
+#define WLR_SESSION_INTERFACE_H
+
+struct wlr_session;
+
+struct session_interface {
+ struct wlr_session *(*start)(void);
+ void (*finish)(struct wlr_session *session);
+ int (*open)(struct wlr_session *restrict session,
+ const char *restrict path);
+ void (*close)(struct wlr_session *session, int fd);
+};
+
+struct wlr_session {
+ struct session_interface iface;
+};
+
+extern const struct session_interface session_logind_iface;
+extern const struct session_interface session_direct_iface;
+
+#endif
diff --git a/include/wayland.h b/include/wayland.h
new file mode 100644
index 00000000..68817936
--- /dev/null
+++ b/include/wayland.h
@@ -0,0 +1,18 @@
+#ifndef _WLR_WAYLAND_INTERNAL_H
+#define _WLR_WAYLAND_INTERNAL_H
+
+#include <wayland-server.h>
+#include <wlr/wayland.h>
+#include <stdbool.h>
+
+struct wlr_output_impl {
+ bool (*set_mode)(struct wlr_output_state *state, struct wlr_output_mode *mode);
+ void (*destroy)(struct wlr_output_state *state);
+};
+
+struct wlr_output *wlr_output_create(struct wlr_output_impl *impl,
+ struct wlr_output_state *state);
+
+void wlr_output_free(struct wlr_output *output);
+
+#endif
diff --git a/include/wlr/backend.h b/include/wlr/backend.h
index 527efa05..b424c29f 100644
--- a/include/wlr/backend.h
+++ b/include/wlr/backend.h
@@ -1,7 +1,29 @@
#ifndef _WLR_BACKEND_H
#define _WLR_BACKEND_H
-struct wlr_backend *wlr_backend_init();
-void wlr_backend_free(struct wlr_backend *backend);
+#include <wayland-server.h>
+
+struct wlr_backend_impl;
+struct wlr_backend_state;
+
+struct wlr_backend {
+ const struct wlr_backend_impl *impl;
+ struct wlr_backend_state *state;
+
+ struct {
+ struct wl_signal output_add;
+ struct wl_signal output_remove;
+ struct wl_signal keyboard_add;
+ struct wl_signal keyboard_remove;
+ struct wl_signal pointer_add;
+ struct wl_signal pointer_remove;
+ struct wl_signal touch_add;
+ struct wl_signal touch_remove;
+ } events;
+};
+
+struct wlr_backend *wlr_backend_autocreate();
+bool wlr_backend_init(struct wlr_backend *backend);
+void wlr_backend_destroy(struct wlr_backend *backend);
#endif
diff --git a/include/wlr/backend/drm.h b/include/wlr/backend/drm.h
new file mode 100644
index 00000000..2d9bf879
--- /dev/null
+++ b/include/wlr/backend/drm.h
@@ -0,0 +1,16 @@
+#ifndef WLR_BACKEND_DRM_H
+#define WLR_BACKEND_DRM_H
+
+#include <wayland-server.h>
+#include <wlr/session.h>
+#include <wlr/backend.h>
+#include <xf86drmMode.h> // drmModeModeInfo
+#include <wlr/wayland.h>
+
+struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
+ struct wlr_session *session);
+
+void wlr_drm_output_begin(struct wlr_output *out);
+void wlr_drm_output_end(struct wlr_output *out);
+
+#endif
diff --git a/include/wlr/common/log.h b/include/wlr/common/log.h
index 5b4d5a53..079f989a 100644
--- a/include/wlr/common/log.h
+++ b/include/wlr/common/log.h
@@ -1,6 +1,7 @@
#ifndef _WLR_COMMON_LOG_H
#define _WLR_COMMON_LOG_H
#include <stdbool.h>
+#include <stdarg.h>
typedef enum {
L_SILENT = 0,
diff --git a/include/wlr/session.h b/include/wlr/session.h
new file mode 100644
index 00000000..cf04f1da
--- /dev/null
+++ b/include/wlr/session.h
@@ -0,0 +1,12 @@
+#ifndef WLR_SESSION_H
+#define WLR_SESSION_H
+
+struct wlr_session;
+
+struct wlr_session *wlr_session_start(void);
+void wlr_session_finish(struct wlr_session *session);
+int wlr_session_open_file(struct wlr_session *restrict session,
+ const char *restrict path);
+void wlr_session_close_file(struct wlr_session *session, int fd);
+
+#endif
diff --git a/include/wlr/wayland.h b/include/wlr/wayland.h
index bbbd2457..158acc33 100644
--- a/include/wlr/wayland.h
+++ b/include/wlr/wayland.h
@@ -3,26 +3,26 @@
#include <wayland-server.h>
#include <wlr/common/list.h>
+#include <stdbool.h>
-struct wlr_wl_seat {
- struct wl_seat *wl_seat;
- uint32_t capabilities;
- char *name;
- list_t *keyboards;
- list_t *pointers;
-};
-
-void wlr_wl_seat_free(struct wlr_wl_seat *seat);
+struct wlr_output_mode_state;
-struct wlr_wl_output_mode {
+struct wlr_output_mode {
+ struct wlr_output_mode_state *state;
uint32_t flags; // enum wl_output_mode
int32_t width, height;
int32_t refresh; // mHz
};
-struct wlr_wl_output {
- struct wl_output *wl_output;
+struct wlr_output_impl;
+struct wlr_output_state;
+
+struct wlr_output {
+ const struct wlr_output_impl *impl;
+ struct wlr_output_state *state;
+
uint32_t flags;
+ char *name;
char *make;
char *model;
uint32_t scale;
@@ -30,20 +30,15 @@ struct wlr_wl_output {
int32_t phys_width, phys_height; // mm
int32_t subpixel; // enum wl_output_subpixel
int32_t transform; // enum wl_output_transform
- list_t *modes;
- struct wlr_wl_output_mode *current_mode;
-};
-void wlr_wl_output_free(struct wlr_wl_output *output);
+ list_t *modes;
+ struct wlr_output_mode *current_mode;
-struct wlr_wl_keyboard {
- struct wl_keyboard *wl_keyboard;
+ struct {
+ struct wl_signal frame;
+ } events;
};
-struct wlr_wl_pointer {
- struct wl_pointer *wl_pointer;
- struct wl_surface *current_surface;
- wl_fixed_t x, y;
-};
+bool wlr_output_set_mode(struct wlr_output *output, struct wlr_output_mode *mode);
#endif