diff --git a/gfx/common/drm_common.c b/gfx/common/drm_common.c index 1741302460..4f91a28724 100644 --- a/gfx/common/drm_common.c +++ b/gfx/common/drm_common.c @@ -41,3 +41,14 @@ void drm_restore_crtc(void) drmModeFreeCrtc(g_orig_crtc); g_orig_crtc = NULL; } + +void drm_free(void) +{ + if (g_drm_encoder) + drmModeFreeEncoder(g_drm_encoder); + if (g_drm_connector) + drmModeFreeConnector(g_drm_connector); + if (g_drm_resources) + drmModeFreeResources(g_drm_resources); + +} diff --git a/gfx/common/drm_common.h b/gfx/common/drm_common.h index 2a6c6498e1..3fc3fe4b93 100644 --- a/gfx/common/drm_common.h +++ b/gfx/common/drm_common.h @@ -38,6 +38,8 @@ extern drmModeModeInfo *g_drm_mode; /* Restore the original CRTC. */ void drm_restore_crtc(void); +void drm_free(void); + #ifdef __cplusplus } #endif diff --git a/gfx/drivers/exynos_gfx.c b/gfx/drivers/exynos_gfx.c index bb79c25a86..b6d77ad9a6 100644 --- a/gfx/drivers/exynos_gfx.c +++ b/gfx/drivers/exynos_gfx.c @@ -197,19 +197,6 @@ static int exynos_get_device_index(void) return index; } - -static void exynos_clean_up_drm(void) -{ - if (g_drm_encoder) - drmModeFreeEncoder(g_drm_encoder); - if (g_drm_connector) - drmModeFreeConnector(g_drm_connector); - if (g_drm_resources) - drmModeFreeResources(g_drm_resources); - - close(g_drm_fd); -} - /* The main pageflip handler, which the DRM executes * when it flips to the page. * @@ -657,7 +644,8 @@ static int exynos_open(struct exynos_data *pdata) fail: free(fliphandler); - exynos_clean_up_drm(); + drm_free(); + close(g_drm_fd); return -1; } @@ -670,7 +658,8 @@ static void exynos_close(struct exynos_data *pdata) memset(pdata->drmname, 0, sizeof(char) * 32); - exynos_clean_up_drm(); + drm_free(); + close(g_drm_fd); g_drm_fd = -1; } diff --git a/gfx/drivers_context/drm_egl_ctx.c b/gfx/drivers_context/drm_egl_ctx.c index 944000c5f2..46089dfa56 100644 --- a/gfx/drivers_context/drm_egl_ctx.c +++ b/gfx/drivers_context/drm_egl_ctx.c @@ -298,14 +298,7 @@ static void free_drm_resources(gfx_ctx_drm_egl_data_t *drm) if (drm->g_gbm_dev) gbm_device_destroy(drm->g_gbm_dev); - if (g_drm_encoder) - drmModeFreeEncoder(g_drm_encoder); - - if (g_drm_connector) - drmModeFreeConnector(g_drm_connector); - - if (g_drm_resources) - drmModeFreeResources(g_drm_resources); + drm_free(); if (g_drm_fd >= 0) retro_fclose(drm->g_drm);