summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Kindestam <antonki@kth.se>2019-12-07 19:17:21 +0100
committerAnton Kindestam <antonki@kth.se>2019-12-07 19:23:58 +0100
commitb2b15d4e6e1d92290d0d7e772b9a5468ddea8a81 (patch)
tree9792f8bc1be5e5d5205505a286ef81e139314f36
parentd5cabf73489fe165562adea765ed7f53fd264e53 (diff)
downloadmpv-b2b15d4e6e1d92290d0d7e772b9a5468ddea8a81.tar.bz2
mpv-b2b15d4e6e1d92290d0d7e772b9a5468ddea8a81.tar.xz
vo_drm: replace drmModeAddFB usage with drmModeAddFB2
drmModeAddFB is legacy, and might not pick the pixel format you expect, depending on your driver. Use drmModeAddFB2 which specifies this explicitly using a fourcc.
-rw-r--r--video/out/vo_drm.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/video/out/vo_drm.c b/video/out/vo_drm.c
index 7eee6c66c1..96286bd30a 100644
--- a/video/out/vo_drm.c
+++ b/video/out/vo_drm.c
@@ -23,6 +23,7 @@
#include <poll.h>
#include <unistd.h>
+#include <drm_fourcc.h>
#include <libswscale/swscale.h>
#include "drm_common.h"
@@ -85,7 +86,7 @@ struct priv {
unsigned int fb_queue_len;
struct framebuffer *cur_fb;
- uint32_t depth;
+ uint32_t drm_format;
enum mp_imgfmt imgfmt;
int32_t screen_w;
@@ -139,8 +140,13 @@ static bool fb_setup_single(struct vo *vo, int fd, struct framebuffer *buf)
buf->handle = creq.handle;
// create framebuffer object for the dumb-buffer
- if (drmModeAddFB(fd, buf->width, buf->height, p->depth, creq.bpp, buf->stride,
- buf->handle, &buf->fb)) {
+ int ret = drmModeAddFB2(fd, buf->width, buf->height,
+ p->drm_format,
+ (uint32_t[4]){buf->handle, 0, 0, 0},
+ (uint32_t[4]){buf->stride, 0, 0, 0},
+ (uint32_t[4]){0, 0, 0, 0},
+ &buf->fb, 0);
+ if (ret) {
MP_ERR(vo, "Cannot create framebuffer: %s\n", mp_strerror(errno));
goto err;
}
@@ -390,7 +396,7 @@ static void draw_image(struct vo *vo, mp_image_t *mpi, struct framebuffer *front
osd_draw_on_image(vo->osd, p->osd, 0, 0, p->cur_frame);
}
- if (p->depth == 30) {
+ if (p->drm_format == DRM_FORMAT_XRGB2101010) {
// Pack GBRP10 image into XRGB2101010 for DRM
const int w = p->cur_frame->w;
const int h = p->cur_frame->h;
@@ -413,7 +419,7 @@ static void draw_image(struct vo *vo, mp_image_t *mpi, struct framebuffer *front
r_ptr += r_padding;
fbuf_ptr += fbuf_padding;
}
- } else {
+ } else { // p->drm_format == DRM_FORMAT_XRGB8888
memcpy_pic(front_buf->map, p->cur_frame->planes[0],
p->cur_frame->w * BYTES_PER_PIXEL, p->cur_frame->h,
front_buf->stride,
@@ -577,10 +583,10 @@ static int preinit(struct vo *vo)
}
if (vo->opts->drm_opts->drm_format == DRM_OPTS_FORMAT_XRGB2101010) {
- p->depth = 30;
+ p->drm_format = DRM_FORMAT_XRGB2101010;
p->imgfmt = IMGFMT_XRGB2101010;
} else {
- p->depth = 24;
+ p->drm_format = DRM_FORMAT_XRGB8888;;
p->imgfmt = IMGFMT_XRGB8888;
}