aboutsummaryrefslogtreecommitdiff
path: root/include/backend
diff options
context:
space:
mode:
Diffstat (limited to 'include/backend')
-rw-r--r--include/backend/drm/drm.h (renamed from include/backend/drm.h)85
-rw-r--r--include/backend/drm/iface.h35
-rw-r--r--include/backend/drm/properties.h (renamed from include/backend/drm-properties.h)0
-rw-r--r--include/backend/drm/renderer.h54
-rw-r--r--include/backend/drm/util.h (renamed from include/backend/drm-util.h)0
5 files changed, 110 insertions, 64 deletions
diff --git a/include/backend/drm.h b/include/backend/drm/drm.h
index b474e8b3..6106a85a 100644
--- a/include/backend/drm.h
+++ b/include/backend/drm/drm.h
@@ -1,5 +1,5 @@
-#ifndef BACKEND_DRM_H
-#define BACKEND_DRM_H
+#ifndef BACKEND_DRM_DRM_H
+#define BACKEND_DRM_DRM_H
#include <stdbool.h>
#include <stddef.h>
@@ -15,7 +15,9 @@
#include <wlr/egl.h>
#include <wlr/util/list.h>
-#include "drm-properties.h"
+#include "iface.h"
+#include "properties.h"
+#include "renderer.h"
struct wlr_drm_plane {
uint32_t type;
@@ -23,13 +25,8 @@ struct wlr_drm_plane {
uint32_t possible_crtcs;
- uint32_t width, height;
-
- struct gbm_surface *gbm;
- EGLSurface egl;
-
- struct gbm_bo *front;
- struct gbm_bo *back;
+ struct wlr_drm_surface surf;
+ struct wlr_drm_surface mgpu_surf;
// Only used by cursor
float matrix[16];
@@ -59,34 +56,13 @@ struct wlr_drm_crtc {
struct wl_list connectors;
};
-struct wlr_drm_connector {
- struct wlr_output *base;
- uint32_t id;
- struct wlr_drm_crtc *crtc;
-
- union wlr_drm_connector_props props;
-
- struct wl_list link;
-};
-
-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);
-
-struct wlr_drm_interface;
-
struct wlr_drm_backend {
struct wlr_backend backend;
+ struct wlr_drm_backend *parent;
const struct wlr_drm_interface *iface;
int fd;
- dev_t dev;
size_t num_crtcs;
struct wlr_drm_crtc *crtcs;
@@ -117,30 +93,30 @@ struct wlr_drm_backend {
struct wl_listener session_signal;
struct wl_listener drm_invalidated;
- uint32_t taken_crtcs;
list_t *outputs;
struct wlr_drm_renderer renderer;
struct wlr_session *session;
};
-enum wlr_drm_output_state {
- WLR_DRM_OUTPUT_DISCONNECTED,
- WLR_DRM_OUTPUT_NEEDS_MODESET,
- WLR_DRM_OUTPUT_CLEANUP,
- WLR_DRM_OUTPUT_CONNECTED,
+enum wlr_drm_connector_state {
+ WLR_DRM_CONN_DISCONNECTED,
+ WLR_DRM_CONN_NEEDS_MODESET,
+ WLR_DRM_CONN_CLEANUP,
+ WLR_DRM_CONN_CONNECTED,
};
-struct wlr_drm_output_mode {
+struct wlr_drm_mode {
struct wlr_output_mode wlr_mode;
- drmModeModeInfo mode;
+ drmModeModeInfo drm_mode;
};
-struct wlr_drm_output {
+struct wlr_drm_connector {
struct wlr_output output;
+ struct wlr_drm_backend *drm;
- enum wlr_drm_output_state state;
- uint32_t connector;
+ enum wlr_drm_connector_state state;
+ uint32_t id;
struct wlr_drm_crtc *crtc;
uint32_t possible_crtc;
@@ -152,37 +128,18 @@ struct wlr_drm_output {
drmModeCrtc *old_crtc;
- struct wlr_drm_renderer *renderer;
-
bool pageflip_pending;
struct wl_event_source *retry_pageflip;
};
-// Used to provide atomic or legacy DRM functions
-struct wlr_drm_interface {
- // Enable or disable DPMS for output
- void (*conn_enable)(struct wlr_drm_backend *backend,
- struct wlr_drm_output *output, bool enable);
- // Pageflip on crtc. If mode is non-NULL perform a full modeset using it.
- bool (*crtc_pageflip)(struct wlr_drm_backend *backend,
- struct wlr_drm_output *output, struct wlr_drm_crtc *crtc,
- uint32_t fb_id, drmModeModeInfo *mode);
- // Enable the cursor buffer on crtc. Set bo to NULL to disable
- bool (*crtc_set_cursor)(struct wlr_drm_backend *backend,
- struct wlr_drm_crtc *crtc, struct gbm_bo *bo);
- // Move the cursor on crtc
- bool (*crtc_move_cursor)(struct wlr_drm_backend *backend,
- struct wlr_drm_crtc *crtc, int x, int y);
-};
-
bool wlr_drm_check_features(struct wlr_drm_backend *drm);
bool wlr_drm_resources_init(struct wlr_drm_backend *drm);
void wlr_drm_resources_free(struct wlr_drm_backend *drm);
void wlr_drm_restore_outputs(struct wlr_drm_backend *drm);
-void wlr_drm_output_cleanup(struct wlr_drm_output *output);
+void wlr_drm_connector_cleanup(struct wlr_drm_connector *conn);
void wlr_drm_scan_connectors(struct wlr_drm_backend *state);
int wlr_drm_event(int fd, uint32_t mask, void *data);
-void wlr_drm_output_start_renderer(struct wlr_drm_output *output);
+void wlr_drm_connector_start_renderer(struct wlr_drm_connector *conn);
#endif
diff --git a/include/backend/drm/iface.h b/include/backend/drm/iface.h
new file mode 100644
index 00000000..bc61eb51
--- /dev/null
+++ b/include/backend/drm/iface.h
@@ -0,0 +1,35 @@
+#ifndef BACKEND_DRM_IFACE_H
+#define BACKEND_DRM_IFACE_H
+
+#include <stdbool.h>
+#include <stdint.h>
+
+#include <gbm.h>
+#include <xf86drm.h>
+#include <xf86drmMode.h>
+
+struct wlr_drm_backend;
+struct wlr_drm_connector;
+struct wlr_drm_crtc;
+
+// Used to provide atomic or legacy DRM functions
+struct wlr_drm_interface {
+ // Enable or disable DPMS for connector
+ void (*conn_enable)(struct wlr_drm_backend *drm,
+ struct wlr_drm_connector *conn, bool enable);
+ // Pageflip on crtc. If mode is non-NULL perform a full modeset using it.
+ bool (*crtc_pageflip)(struct wlr_drm_backend *drm,
+ struct wlr_drm_connector *conn, struct wlr_drm_crtc *crtc,
+ uint32_t fb_id, drmModeModeInfo *mode);
+ // Enable the cursor buffer on crtc. Set bo to NULL to disable
+ bool (*crtc_set_cursor)(struct wlr_drm_backend *drm,
+ struct wlr_drm_crtc *crtc, struct gbm_bo *bo);
+ // Move the cursor on crtc
+ bool (*crtc_move_cursor)(struct wlr_drm_backend *drm,
+ struct wlr_drm_crtc *crtc, int x, int y);
+};
+
+extern const struct wlr_drm_interface atomic_iface;
+extern const struct wlr_drm_interface legacy_iface;
+
+#endif
diff --git a/include/backend/drm-properties.h b/include/backend/drm/properties.h
index 7de386ea..7de386ea 100644
--- a/include/backend/drm-properties.h
+++ b/include/backend/drm/properties.h
diff --git a/include/backend/drm/renderer.h b/include/backend/drm/renderer.h
new file mode 100644
index 00000000..45127cd0
--- /dev/null
+++ b/include/backend/drm/renderer.h
@@ -0,0 +1,54 @@
+#ifndef BACKEND_DRM_RENDERER_H
+#define BACKEND_DRM_RENDERER_H
+
+#include <stdbool.h>
+#include <stdint.h>
+
+#include <EGL/egl.h>
+#include <gbm.h>
+
+#include <wlr/render.h>
+
+struct wlr_drm_backend;
+struct wlr_drm_plane;
+
+struct wlr_drm_renderer {
+ int fd;
+ struct gbm_device *gbm;
+ struct wlr_egl egl;
+
+ struct wlr_renderer *wlr_rend;
+};
+
+struct wlr_drm_surface {
+ struct wlr_drm_renderer *renderer;
+
+ uint32_t width;
+ uint32_t height;
+
+ struct gbm_surface *gbm;
+ EGLSurface egl;
+
+ struct gbm_bo *front;
+ struct gbm_bo *back;
+};
+
+bool wlr_drm_renderer_init(struct wlr_drm_backend *drm,
+ struct wlr_drm_renderer *renderer);
+void wlr_drm_renderer_finish(struct wlr_drm_renderer *renderer);
+
+bool wlr_drm_surface_init(struct wlr_drm_surface *surf,
+ struct wlr_drm_renderer *renderer, uint32_t width, uint32_t height,
+ uint32_t format, uint32_t flags);
+
+bool wlr_drm_plane_surfaces_init(struct wlr_drm_plane *plane, struct wlr_drm_backend *drm,
+ int32_t width, uint32_t height, uint32_t format);
+
+void wlr_drm_surface_finish(struct wlr_drm_surface *surf);
+void wlr_drm_surface_make_current(struct wlr_drm_surface *surf);
+struct gbm_bo *wlr_drm_surface_swap_buffers(struct wlr_drm_surface *surf);
+struct gbm_bo *wlr_drm_surface_get_front(struct wlr_drm_surface *surf);
+void wlr_drm_surface_post(struct wlr_drm_surface *surf);
+struct gbm_bo *wlr_drm_surface_mgpu_copy(struct wlr_drm_surface *dest, struct gbm_bo *src);
+
+#endif
diff --git a/include/backend/drm-util.h b/include/backend/drm/util.h
index 6818b4db..6818b4db 100644
--- a/include/backend/drm-util.h
+++ b/include/backend/drm/util.h