diff options
author | Dudemanguy <random342@airmail.cc> | 2023-11-02 15:54:01 -0500 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-11-06 15:44:45 +0000 |
commit | a96d04f19d7393db1371ecd8301e764f7ee13c96 (patch) | |
tree | 3a3bcf5e734b4ca4360e0185cb23a0c506f9573c /video/out/vo_drm.c | |
parent | f629d7a2ff67902c2ac5ed1a91dd7ade5164e723 (diff) | |
download | mpv-a96d04f19d7393db1371ecd8301e764f7ee13c96.tar.bz2 mpv-a96d04f19d7393db1371ecd8301e764f7ee13c96.tar.xz |
drm: use present_sync mechanism for presentation feedback
A ton of code and drm-specific abstractions can be dropped with this.
One important thing to note is that the usage of sbc is completely
dropped here. The utility of that is not particularly clear since the
sbc value was manually incremented before the flip and it's not as if
the drm page flip event gives it to us like it does with the msec and
ust. It can be reintroduced later if there is a need. For drm, we also
add a present_sync_clear_values helper since all presentation feedback
needs to be cleared on pause/resume for it.
Diffstat (limited to 'video/out/vo_drm.c')
-rw-r--r-- | video/out/vo_drm.c | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/video/out/vo_drm.c b/video/out/vo_drm.c index 1128a0dd4f..aae73f7be1 100644 --- a/video/out/vo_drm.c +++ b/video/out/vo_drm.c @@ -33,6 +33,7 @@ #include "sub/osd.h" #include "video/fmt-conversion.h" #include "video/mp_image.h" +#include "video/out/present_sync.h" #include "video/sws_utils.h" #include "vo.h" @@ -48,7 +49,6 @@ struct drm_frame { struct framebuffer *fb; - struct drm_vsync_tuple vsync; }; struct priv { @@ -200,10 +200,6 @@ static int reconfig(struct vo *vo, struct mp_image_params *params) if (mp_sws_reinit(p->sws) < 0) return -1; - drm->vsync_info.vsync_duration = 0; - drm->vsync_info.skipped_vsyncs = -1; - drm->vsync_info.last_queue_display_time = -1; - vo->want_redraw = true; return 0; } @@ -283,12 +279,9 @@ static void draw_image(struct vo *vo, mp_image_t *mpi, struct framebuffer *buf) static void enqueue_frame(struct vo *vo, struct framebuffer *fb) { struct priv *p = vo->priv; - struct vo_drm_state *drm = vo->drm; - drm->vsync.sbc++; struct drm_frame *new_frame = talloc(p, struct drm_frame); new_frame->fb = fb; - new_frame->vsync = drm->vsync; MP_TARRAY_APPEND(p, p->fb_queue, p->fb_queue_len, new_frame); } @@ -332,25 +325,14 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame) static void queue_flip(struct vo *vo, struct drm_frame *frame) { - struct priv *p = vo->priv; struct vo_drm_state *drm = vo->drm; drm->fb = frame->fb; - // Alloc and fill the data struct for the page flip callback - struct drm_pflip_cb_closure *data = talloc(p, struct drm_pflip_cb_closure); - data->frame_vsync = &frame->vsync; - data->vsync = &drm->vsync; - data->vsync_info = &drm->vsync_info; - data->waiting_for_flip = &drm->waiting_for_flip; - data->log = vo->log; - int ret = drmModePageFlip(drm->fd, drm->crtc_id, - drm->fb->id, DRM_MODE_PAGE_FLIP_EVENT, data); - if (ret) { + drm->fb->id, DRM_MODE_PAGE_FLIP_EVENT, drm); + if (ret) MP_WARN(vo, "Failed to queue page flip: %s\n", mp_strerror(errno)); - talloc_free(data); - } drm->waiting_for_flip = !ret; } @@ -379,6 +361,12 @@ static void flip_page(struct vo *vo) } } +static void get_vsync(struct vo *vo, struct vo_vsync_info *info) +{ + struct vo_drm_state *drm = vo->drm; + present_sync_get_info(drm->present, info); +} + static void uninit(struct vo *vo) { struct priv *p = vo->priv; @@ -462,7 +450,7 @@ const struct vo_driver video_out_drm = { .control = control, .draw_frame = draw_frame, .flip_page = flip_page, - .get_vsync = vo_drm_get_vsync, + .get_vsync = get_vsync, .uninit = uninit, .wait_events = vo_drm_wait_events, .wakeup = vo_drm_wakeup, |