Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ if features['direct3d']
sources += files('video/out/vo_direct3d.c')
endif

drm = dependency('libdrm', version: '>= 2.4.105', required: get_option('drm'))
drm = dependency('libdrm', version: '>= 2.4.114', required: get_option('drm'))
libdisplay_info = dependency('libdisplay-info', version: '>= 0.1.1', required: get_option('drm'))
features += {'drm': drm.found() and libdisplay_info.found() and
(features['vt.h'] or features['consio.h'] or features['wsdisplay-usl-io.h'])}
Expand Down
2 changes: 1 addition & 1 deletion video/out/drm_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ struct framebuffer {
uint32_t width;
uint32_t height;
uint32_t stride;
uint32_t size;
uint64_t size;
uint32_t handle;
uint8_t *map;
uint32_t id;
Expand Down
2 changes: 1 addition & 1 deletion video/out/drm_prime.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void drm_prime_destroy_framebuffer(struct mp_log *log, int fd,
framebuffer->gem_handles[i]);
if (!drm_prime_get_handle_ref_count(handle_refs,
framebuffer->gem_handles[i])) {
drmIoctl(fd, DRM_IOCTL_GEM_CLOSE, &framebuffer->gem_handles[i]);
drmCloseBufferHandle(fd, framebuffer->gem_handles[i]);
}
}
}
Expand Down
28 changes: 6 additions & 22 deletions video/out/vo_drm.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,7 @@ static void destroy_framebuffer(int fd, struct framebuffer *fb)
drmModeRmFB(fd, fb->id);
}
if (fb->handle) {
struct drm_mode_destroy_dumb dreq = {
.handle = fb->handle,
};
drmIoctl(fd, DRM_IOCTL_MODE_DESTROY_DUMB, &dreq);
drmModeDestroyDumbBuffer(fd, fb->handle);
}
}

Expand All @@ -91,24 +88,13 @@ static struct framebuffer *setup_framebuffer(struct vo *vo)
fb->width = drm->mode.mode.hdisplay;
fb->height = drm->mode.mode.vdisplay;
fb->fd = drm->fd;
fb->handle = 0;

// create dumb buffer
struct drm_mode_create_dumb creq = {
.width = fb->width,
.height = fb->height,
.bpp = BITS_PER_PIXEL,
};

if (drmIoctl(drm->fd, DRM_IOCTL_MODE_CREATE_DUMB, &creq) < 0) {
if (drmModeCreateDumbBuffer(drm->fd, fb->width, fb->height, BITS_PER_PIXEL, 0,
&fb->handle, &fb->stride, &fb->size) < 0) {
MP_ERR(vo, "Cannot create dumb buffer: %s\n", mp_strerror(errno));
goto err;
}

fb->stride = creq.pitch;
fb->size = creq.size;
fb->handle = creq.handle;

// select format
switch (drm->opts->drm_format) {
case DRM_OPTS_FORMAT_XRGB2101010:
Expand Down Expand Up @@ -150,17 +136,15 @@ static struct framebuffer *setup_framebuffer(struct vo *vo)
}

// prepare buffer for memory mapping
struct drm_mode_map_dumb mreq = {
.handle = fb->handle,
};
if (drmIoctl(drm->fd, DRM_IOCTL_MODE_MAP_DUMB, &mreq)) {
uint64_t offset = 0;
if (drmModeMapDumbBuffer(drm->fd, fb->handle, &offset)) {
MP_ERR(vo, "Cannot map dumb buffer: %s\n", mp_strerror(errno));
goto err;
}

// perform actual memory mapping
fb->map = mmap(0, fb->size, PROT_READ | PROT_WRITE, MAP_SHARED,
drm->fd, mreq.offset);
drm->fd, offset);
if (fb->map == MAP_FAILED) {
MP_ERR(vo, "Cannot map dumb buffer: %s\n", mp_strerror(errno));
goto err;
Expand Down
Loading