summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorrr- <rr-@sakuya.pl>2016-10-03 23:56:35 +0200
committerwm4 <wm4@nowhere>2016-10-04 13:23:11 +0200
commit1648ff8a0f18e1c1a5e979084148cc7ecf195984 (patch)
tree79f0b84135692d42edbb35577978c21831301f86 /video
parentabbc8fc84a99a739e2566e4f7e022b3c1bdde1f3 (diff)
downloadmpv-1648ff8a0f18e1c1a5e979084148cc7ecf195984.tar.bz2
mpv-1648ff8a0f18e1c1a5e979084148cc7ecf195984.tar.xz
vo_drm: refactor getting display fps
Reduces code duplication between OpenGL backend and DRM VO. (The control() for OpenGL backend isn't sufficiently similar to the VO's control() to consider merging it as a whole - I extracted only the FPS code.)
Diffstat (limited to 'video')
-rw-r--r--video/out/drm_common.c5
-rw-r--r--video/out/drm_common.h1
-rw-r--r--video/out/opengl/context_drm_egl.c6
-rw-r--r--video/out/vo_drm.c6
4 files changed, 8 insertions, 10 deletions
diff --git a/video/out/drm_common.c b/video/out/drm_common.c
index a39db93617..4e9f497c6c 100644
--- a/video/out/drm_common.c
+++ b/video/out/drm_common.c
@@ -215,6 +215,11 @@ void kms_destroy(struct kms *kms)
talloc_free(kms);
}
+double kms_get_display_fps(const struct kms *kms)
+{
+ return kms->mode.clock * 1000.0 / kms->mode.htotal / kms->mode.vtotal;
+}
+
// VT switcher ----------------------------------------------------------------
diff --git a/video/out/drm_common.h b/video/out/drm_common.h
index 933203496c..53ec9e35df 100644
--- a/video/out/drm_common.h
+++ b/video/out/drm_common.h
@@ -49,5 +49,6 @@ void vt_switcher_release(struct vt_switcher *s, void (*handler)(void*), void *us
struct kms *kms_create(struct mp_log *log);
bool kms_setup(struct kms *kms, const char *device_path, int conn_id, int mode_id);
void kms_destroy(struct kms *kms);
+double kms_get_display_fps(const struct kms *kms);
#endif
diff --git a/video/out/opengl/context_drm_egl.c b/video/out/opengl/context_drm_egl.c
index ef7a0b598b..a6609681d3 100644
--- a/video/out/opengl/context_drm_egl.c
+++ b/video/out/opengl/context_drm_egl.c
@@ -370,11 +370,7 @@ static int drm_egl_control(struct MPGLContext *ctx, int *events, int request,
struct priv *p = ctx->priv;
switch (request) {
case VOCTRL_GET_DISPLAY_FPS: {
- double fps =
- p->kms->mode.clock
- * 1000.0
- / p->kms->mode.htotal
- / p->kms->mode.vtotal;
+ double fps = kms_get_display_fps(p->kms);
if (fps <= 0)
break;
*(double*)arg = fps;
diff --git a/video/out/vo_drm.c b/video/out/vo_drm.c
index cf42c4ce4a..7b05def934 100644
--- a/video/out/vo_drm.c
+++ b/video/out/vo_drm.c
@@ -482,11 +482,7 @@ static int control(struct vo *vo, uint32_t request, void *arg)
reconfig(vo, vo->params);
return VO_TRUE;
case VOCTRL_GET_DISPLAY_FPS: {
- double fps =
- p->kms->mode.clock
- * 1000.0
- / p->kms->mode.htotal
- / p->kms->mode.vtotal;
+ double fps = kms_get_display_fps(p->kms);
if (fps <= 0)
break;
*(double*)arg = fps;