aboutsummaryrefslogtreecommitdiffhomepage
path: root/video/out/opengl/hwdec_drmprime_drm.c
diff options
context:
space:
mode:
authorGravatar LongChair <longchair@hotmail.com>2018-04-29 15:09:16 +0200
committerGravatar Jan Ekström <jeebjp@gmail.com>2018-05-01 20:48:02 +0300
commit9f2970f28a28076897fda1100de2b6eb9a92be79 (patch)
tree7cd8db166d6b6c621684cdd9750866c9842c454a /video/out/opengl/hwdec_drmprime_drm.c
parent11f915f5ef7d622a225bee6ab98ee6a9da34991f (diff)
drm/atomic: refactor hwdec_drmprime_drm with native resources
That new API was introduced and allows to have several native resources. Thisuses that mechanisma for drm resources rather than the deprecated opengl-cb structs. This patch therefore add two structs that can be used with the drm atomic interop. - mpv_opengl_drm_params : which will hold all the drm handles - mpv_opengl_drm_osd_size : which will hold osd layer size This commit adds a drm-osd-size=WxH parameter to commandline which allows to define the OSD plane dimension. OSD can be upscaled to screen resolution when having OSD at video resolution is too heavy. This is especially useful for UHD modes on embedded devices where the GPU cannot handle UHD modes at a decent framerate.
Diffstat (limited to 'video/out/opengl/hwdec_drmprime_drm.c')
-rw-r--r--video/out/opengl/hwdec_drmprime_drm.c47
1 files changed, 26 insertions, 21 deletions
diff --git a/video/out/opengl/hwdec_drmprime_drm.c b/video/out/opengl/hwdec_drmprime_drm.c
index 422612287c..0c7f86a584 100644
--- a/video/out/opengl/hwdec_drmprime_drm.c
+++ b/video/out/opengl/hwdec_drmprime_drm.c
@@ -29,7 +29,7 @@
#include "video/hwdec.h"
#include "common/msg.h"
#include "options/m_config.h"
-#include "libmpv/opengl_cb.h"
+#include "libmpv/render_gl.h"
#include "video/out/drm_common.h"
#include "video/out/drm_prime.h"
#include "video/out/gpu/hwdec.h"
@@ -117,25 +117,34 @@ static int overlay_frame(struct ra_hwdec *hw, struct mp_image *hw_image,
struct drm_frame next_frame = {0};
int ret;
+ // grab atomic request from native resources
+ if (p->ctx) {
+ struct mpv_opengl_drm_params *drm_params;
+ drm_params = (mpv_opengl_drm_params *)ra_get_native_resource(hw->ra, "drm_params");
+ if (!drm_params) {
+ MP_ERR(hw, "Failed to retrieve drm params from native resources\n");
+ return -1;
+ }
+ if (drm_params->atomic_request_ptr) {
+ request = *drm_params->atomic_request_ptr;
+ } else {
+ MP_ERR(hw, "drm params pointer to atomic request is invalid");
+ return -1;
+ }
+ }
+
if (hw_image) {
- // grab opengl-cb windowing info to eventually upscale the overlay
- // as egl windows could be upscaled to primary plane.
- struct mpv_opengl_cb_window_pos *glparams =
- ra_get_native_resource(hw->ra, "opengl-cb-window-pos");
- if (glparams) {
- scale_dst_rect(hw, glparams->width, glparams->height, dst, &p->dst);
+ // grab osd windowing info to eventually upscale the overlay
+ // as egl windows could be upscaled to osd plane.
+ struct mpv_opengl_drm_osd_size *osd_size = ra_get_native_resource(hw->ra, "drm_osd_size");
+ if (osd_size) {
+ scale_dst_rect(hw, osd_size->width, osd_size->height, dst, &p->dst);
} else {
p->dst = *dst;
}
p->src = *src;
- // grab drm interop info
- struct mpv_opengl_cb_drm_params *drmparams =
- ra_get_native_resource(hw->ra, "opengl-cb-drm-params");
- if (drmparams)
- request = (drmModeAtomicReq *)drmparams->atomic_request;
-
next_frame.image = hw_image;
desc = (AVDRMFrameDescriptor *)hw_image->planes[0];
@@ -210,15 +219,11 @@ static int init(struct ra_hwdec *hw)
drm_overlay = opts->drm_overlay_id;
talloc_free(tmp);
- struct mpv_opengl_cb_drm_params *params =
- ra_get_native_resource(hw->ra, "opengl-cb-drm-params");
- if (!params) {
- MP_VERBOSE(hw, "Could not get drm interop info.\n");
- goto err;
- }
+ struct mpv_opengl_drm_params *drm_params;
- if (params->fd) {
- p->ctx = drm_atomic_create_context(p->log, params->fd, params->crtc_id,
+ drm_params = ra_get_native_resource(hw->ra, "drm_params");
+ if (drm_params) {
+ p->ctx = drm_atomic_create_context(p->log, drm_params->fd, drm_params->crtc_id,
drm_overlay);
if (!p->ctx) {
mp_err(p->log, "Failed to retrieve DRM atomic context.\n");