From d5c39c961b11b314b6d13e79036e740cdefee67b Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sun, 31 Jul 2011 17:09:11 +0900 Subject: add more functions to gralloc_drm kms interface Make it more complete. --- gralloc_drm_kms.c | 59 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 47 insertions(+), 12 deletions(-) (limited to 'gralloc_drm_kms.c') diff --git a/gralloc_drm_kms.c b/gralloc_drm_kms.c index 77115b3..6b4a63d 100644 --- a/gralloc_drm_kms.c +++ b/gralloc_drm_kms.c @@ -277,18 +277,18 @@ static struct gralloc_drm_t *drm_singleton; static void on_signal(int sig) { - struct sigaction act; - - /* wait the pending flip */ - if (drm_singleton && drm_singleton->next_front) { - /* there is race, but this function is hacky enough to ignore that */ - if (drm_singleton->waiting_flip) - usleep(100 * 1000); /* 100ms */ - else - drm_kms_page_flip(drm_singleton, NULL); - } - - exit(-1); + struct gralloc_drm_t *drm = drm_singleton; + + /* wait the pending flip */ + if (drm && drm->swap_mode == DRM_SWAP_FLIP && drm->next_front) { + /* there is race, but this function is hacky enough to ignore that */ + if (drm_singleton->waiting_flip) + usleep(100 * 1000); /* 100ms */ + else + drm_kms_page_flip(drm_singleton, NULL); + } + + exit(-1); } static void drm_kms_init_features(struct gralloc_drm_t *drm) @@ -516,6 +516,41 @@ int gralloc_drm_init_kms(struct gralloc_drm_t *drm) return 0; } +void gralloc_drm_fini_kms(struct gralloc_drm_t *drm) +{ + switch (drm->swap_mode) { + case DRM_SWAP_FLIP: + drm_kms_page_flip(drm, NULL); + break; + case DRM_SWAP_COPY: + { + struct gralloc_drm_bo_t **bo = (drm->current_front) ? + &drm->current_front : &drm->next_front; + + if (*bo) + gralloc_drm_bo_destroy(*bo); + *bo = NULL; + } + break; + default: + break; + } + + /* restore crtc? */ + + if (drm->resources) { + drmModeFreeResources(drm->resources); + drm->resources = NULL; + } + + drm_singleton = NULL; +} + +int gralloc_drm_is_kms_initialized(struct gralloc_drm_t *drm) +{ + return (drm->resources != NULL); +} + /* * Initialize a framebuffer device with KMS info. */ -- cgit v1.1