mirror of https://github.com/mpv-player/mpv
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:
parent
abbc8fc84a
commit
1648ff8a0f
|
@ -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 ----------------------------------------------------------------
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue