Importing into DRM.
This commit is contained in:
parent
66511514d4
commit
4e324dd6eb
3 changed files with 18 additions and 0 deletions
11
src/drm.c
11
src/drm.c
|
@ -456,3 +456,14 @@ int drm_atomic_commit(struct drm_t *drm, uint32_t fb_id, uint32_t flags)
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint32_t drm_fbid_from_dmabuf( struct drm_t *drm, struct wlr_dmabuf_attributes *dma_buf )
|
||||
{
|
||||
uint32_t ret = 0;
|
||||
uint32_t handles[4] = { 0 };
|
||||
drmPrimeFDToHandle( drm->fd, dma_buf->fd[0], &handles[0] );
|
||||
|
||||
drmModeAddFB2( drm->fd, dma_buf->width, dma_buf->height, dma_buf->format, handles, dma_buf->stride, dma_buf->offset, &ret, 0 );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#include <xf86drm.h>
|
||||
#include <xf86drmMode.h>
|
||||
|
||||
#include <wlr/render/dmabuf.h>
|
||||
|
||||
struct plane {
|
||||
drmModePlane *plane;
|
||||
drmModeObjectProperties *props;
|
||||
|
@ -49,6 +51,7 @@ extern struct drm_t g_DRM;
|
|||
|
||||
int init_drm(struct drm_t *drm, const char *device, const char *mode_str, unsigned int vrefresh);
|
||||
int drm_atomic_commit(struct drm_t *drm, uint32_t fb_id, uint32_t flags);
|
||||
uint32_t drm_fbid_from_dmabuf( struct drm_t *drm, struct wlr_dmabuf_attributes *dma_buf );
|
||||
|
||||
#ifndef C_SIDE
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
|
||||
#include "main.hpp"
|
||||
#include "wlserver.h"
|
||||
#include "drm.h"
|
||||
|
||||
#define WAFFLE_API_VERSION 0x0106
|
||||
#include <waffle.h>
|
||||
|
@ -105,6 +106,7 @@ typedef struct _win {
|
|||
struct wlr_surface *wlrsurface;
|
||||
Bool dmabuf_attribs_valid;
|
||||
struct wlr_dmabuf_attributes dmabuf_attribs;
|
||||
uint32_t fb_id;
|
||||
} win;
|
||||
|
||||
static win *list;
|
||||
|
@ -377,6 +379,8 @@ ensure_win_resources (Display *dpy, win *w)
|
|||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
w->fb_id = drm_fbid_from_dmabuf( &g_DRM, &w->dmabuf_attribs );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue