diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/backend/drm/drm.h (renamed from include/backend/drm.h) | 85 | ||||
-rw-r--r-- | include/backend/drm/iface.h | 35 | ||||
-rw-r--r-- | include/backend/drm/properties.h (renamed from include/backend/drm-properties.h) | 0 | ||||
-rw-r--r-- | include/backend/drm/renderer.h | 54 | ||||
-rw-r--r-- | include/backend/drm/util.h (renamed from include/backend/drm-util.h) | 0 | ||||
-rw-r--r-- | include/wlr/backend/drm.h | 2 | ||||
-rw-r--r-- | include/wlr/backend/session.h | 5 | ||||
-rw-r--r-- | include/wlr/render.h | 9 | ||||
-rw-r--r-- | include/wlr/render/interface.h | 4 |
9 files changed, 125 insertions, 69 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 diff --git a/include/wlr/backend/drm.h b/include/wlr/backend/drm.h index fa63df0a..b3475703 100644 --- a/include/wlr/backend/drm.h +++ b/include/wlr/backend/drm.h @@ -6,7 +6,7 @@ #include <wlr/backend.h> struct wlr_backend *wlr_drm_backend_create(struct wl_display *display, - struct wlr_session *session, int gpu_fd); + struct wlr_session *session, int gpu_fd, struct wlr_backend *parent); bool wlr_backend_is_drm(struct wlr_backend *backend); diff --git a/include/wlr/backend/session.h b/include/wlr/backend/session.h index 52cf13b7..94002bc5 100644 --- a/include/wlr/backend/session.h +++ b/include/wlr/backend/session.h @@ -72,12 +72,13 @@ int wlr_session_open_file(struct wlr_session *session, const char *path); void wlr_session_close_file(struct wlr_session *session, int fd); void wlr_session_signal_add(struct wlr_session *session, int fd, - struct wl_listener *listener); + struct wl_listener *listener); /* * Changes the virtual terminal. */ bool wlr_session_change_vt(struct wlr_session *session, unsigned vt); -int wlr_session_find_gpu(struct wlr_session *session); +size_t wlr_session_find_gpus(struct wlr_session *session, + size_t ret_len, int ret[static ret_len]); #endif diff --git a/include/wlr/render.h b/include/wlr/render.h index 325f8c01..2fbfb476 100644 --- a/include/wlr/render.h +++ b/include/wlr/render.h @@ -2,6 +2,8 @@ #define WLR_RENDER_H #include <stdint.h> +#include <EGL/egl.h> +#include <EGL/eglext.h> #include <wayland-server-protocol.h> #include <wlr/types/wlr_output.h> @@ -93,8 +95,11 @@ bool wlr_texture_upload_shm(struct wlr_texture *tex, uint32_t format, * texture. The wl_resource is not used after this call. * Will fail (return false) if the given resource is no drm buffer. */ - bool wlr_texture_upload_drm(struct wlr_texture *tex, - struct wl_resource *drm_buffer); +bool wlr_texture_upload_drm(struct wlr_texture *tex, + struct wl_resource *drm_buffer); + +bool wlr_texture_upload_eglimage(struct wlr_texture *tex, + EGLImageKHR image, uint32_t width, uint32_t height); /** * Copies a rectangle of pixels from a wl_shm_buffer onto the texture. The diff --git a/include/wlr/render/interface.h b/include/wlr/render/interface.h index e3ba0414..cbe33822 100644 --- a/include/wlr/render/interface.h +++ b/include/wlr/render/interface.h @@ -2,6 +2,8 @@ #define WLR_RENDER_INTERFACE_H #include <wayland-server-protocol.h> +#include <EGL/egl.h> +#include <EGL/eglext.h> #include <stdbool.h> #include <wlr/render.h> #include <wlr/types/wlr_output.h> @@ -45,6 +47,8 @@ struct wlr_texture_impl { int x, int y, int width, int height, struct wl_shm_buffer *shm); bool (*upload_drm)(struct wlr_texture *texture, struct wl_resource *drm_buf); + bool (*upload_eglimage)(struct wlr_texture *texture, EGLImageKHR image, + uint32_t width, uint32_t height); void (*get_matrix)(struct wlr_texture *state, float (*matrix)[16], const float (*projection)[16], int x, int y); void (*get_buffer_size)(struct wlr_texture *texture, |