mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
d5cabf7348
commit
b2b15d4e6e
|
@ -23,6 +23,7 @@
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <drm_fourcc.h>
|
||||||
#include <libswscale/swscale.h>
|
#include <libswscale/swscale.h>
|
||||||
|
|
||||||
#include "drm_common.h"
|
#include "drm_common.h"
|
||||||
|
@ -85,7 +86,7 @@ struct priv {
|
||||||
unsigned int fb_queue_len;
|
unsigned int fb_queue_len;
|
||||||
struct framebuffer *cur_fb;
|
struct framebuffer *cur_fb;
|
||||||
|
|
||||||
uint32_t depth;
|
uint32_t drm_format;
|
||||||
enum mp_imgfmt imgfmt;
|
enum mp_imgfmt imgfmt;
|
||||||
|
|
||||||
int32_t screen_w;
|
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;
|
buf->handle = creq.handle;
|
||||||
|
|
||||||
// create framebuffer object for the dumb-buffer
|
// create framebuffer object for the dumb-buffer
|
||||||
if (drmModeAddFB(fd, buf->width, buf->height, p->depth, creq.bpp, buf->stride,
|
int ret = drmModeAddFB2(fd, buf->width, buf->height,
|
||||||
buf->handle, &buf->fb)) {
|
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));
|
MP_ERR(vo, "Cannot create framebuffer: %s\n", mp_strerror(errno));
|
||||||
goto err;
|
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);
|
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
|
// Pack GBRP10 image into XRGB2101010 for DRM
|
||||||
const int w = p->cur_frame->w;
|
const int w = p->cur_frame->w;
|
||||||
const int h = p->cur_frame->h;
|
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;
|
r_ptr += r_padding;
|
||||||
fbuf_ptr += fbuf_padding;
|
fbuf_ptr += fbuf_padding;
|
||||||
}
|
}
|
||||||
} else {
|
} else { // p->drm_format == DRM_FORMAT_XRGB8888
|
||||||
memcpy_pic(front_buf->map, p->cur_frame->planes[0],
|
memcpy_pic(front_buf->map, p->cur_frame->planes[0],
|
||||||
p->cur_frame->w * BYTES_PER_PIXEL, p->cur_frame->h,
|
p->cur_frame->w * BYTES_PER_PIXEL, p->cur_frame->h,
|
||||||
front_buf->stride,
|
front_buf->stride,
|
||||||
|
@ -577,10 +583,10 @@ static int preinit(struct vo *vo)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vo->opts->drm_opts->drm_format == DRM_OPTS_FORMAT_XRGB2101010) {
|
if (vo->opts->drm_opts->drm_format == DRM_OPTS_FORMAT_XRGB2101010) {
|
||||||
p->depth = 30;
|
p->drm_format = DRM_FORMAT_XRGB2101010;
|
||||||
p->imgfmt = IMGFMT_XRGB2101010;
|
p->imgfmt = IMGFMT_XRGB2101010;
|
||||||
} else {
|
} else {
|
||||||
p->depth = 24;
|
p->drm_format = DRM_FORMAT_XRGB8888;;
|
||||||
p->imgfmt = IMGFMT_XRGB8888;
|
p->imgfmt = IMGFMT_XRGB8888;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue