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.)
This commit is contained in:
rr- 2016-10-03 23:56:35 +02:00 committed by wm4
parent abbc8fc84a
commit 1648ff8a0f
4 changed files with 8 additions and 10 deletions

View File

@ -215,6 +215,11 @@ void kms_destroy(struct kms *kms)
talloc_free(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 ---------------------------------------------------------------- // VT switcher ----------------------------------------------------------------

View File

@ -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); struct kms *kms_create(struct mp_log *log);
bool kms_setup(struct kms *kms, const char *device_path, int conn_id, int mode_id); bool kms_setup(struct kms *kms, const char *device_path, int conn_id, int mode_id);
void kms_destroy(struct kms *kms); void kms_destroy(struct kms *kms);
double kms_get_display_fps(const struct kms *kms);
#endif #endif

View File

@ -370,11 +370,7 @@ static int drm_egl_control(struct MPGLContext *ctx, int *events, int request,
struct priv *p = ctx->priv; struct priv *p = ctx->priv;
switch (request) { switch (request) {
case VOCTRL_GET_DISPLAY_FPS: { case VOCTRL_GET_DISPLAY_FPS: {
double fps = double fps = kms_get_display_fps(p->kms);
p->kms->mode.clock
* 1000.0
/ p->kms->mode.htotal
/ p->kms->mode.vtotal;
if (fps <= 0) if (fps <= 0)
break; break;
*(double*)arg = fps; *(double*)arg = fps;

View File

@ -482,11 +482,7 @@ static int control(struct vo *vo, uint32_t request, void *arg)
reconfig(vo, vo->params); reconfig(vo, vo->params);
return VO_TRUE; return VO_TRUE;
case VOCTRL_GET_DISPLAY_FPS: { case VOCTRL_GET_DISPLAY_FPS: {
double fps = double fps = kms_get_display_fps(p->kms);
p->kms->mode.clock
* 1000.0
/ p->kms->mode.htotal
/ p->kms->mode.vtotal;
if (fps <= 0) if (fps <= 0)
break; break;
*(double*)arg = fps; *(double*)arg = fps;