diff options
author | George Sapountzis <gsapountzis@gmail.com> | 2010-03-26 18:44:39 +0200 |
---|---|---|
committer | George Sapountzis <gsapountzis@gmail.com> | 2010-03-26 18:44:39 +0200 |
commit | 5b07257fdbb5a93f432b8eaf3a41f39b26bdb1f3 (patch) | |
tree | 83a9e7a596607f8600017bc88e05028df3c56700 /src/gallium/state_trackers/dri/drm | |
parent | 1fbfc22d8560c9d900832147f504ff64c64358de (diff) |
st/dri: factor out common init_screen code
Diffstat (limited to 'src/gallium/state_trackers/dri/drm')
-rw-r--r-- | src/gallium/state_trackers/dri/drm/dri1.c | 30 | ||||
-rw-r--r-- | src/gallium/state_trackers/dri/drm/dri2.c | 21 |
2 files changed, 20 insertions, 31 deletions
diff --git a/src/gallium/state_trackers/dri/drm/dri1.c b/src/gallium/state_trackers/dri/drm/dri1.c index 98bdb2936a..aad098bb30 100644 --- a/src/gallium/state_trackers/dri/drm/dri1.c +++ b/src/gallium/state_trackers/dri/drm/dri1.c @@ -469,8 +469,8 @@ dri1_copy_version(struct dri1_api_version *dst, const __DRIconfig ** dri1_init_screen(__DRIscreen * sPriv) { - struct dri_screen *screen; const __DRIconfig **configs; + struct dri_screen *screen; struct dri1_create_screen_arg arg; screen = CALLOC_STRUCT(dri_screen); @@ -495,32 +495,26 @@ dri1_init_screen(__DRIscreen * sPriv) dri1_copy_version(&arg.drm_version, &sPriv->drm_version); arg.api = NULL; - screen->pipe_screen = screen->api->create_screen(screen->api, screen->fd, &arg.base); - - if (!screen->pipe_screen || !arg.api) { - debug_printf("%s: failed to create dri1 screen\n", __FUNCTION__); - goto out_no_screen; - } - - __dri1_api_hooks = arg.api; - - driParseOptionInfo(&screen->optionCache, - __driConfigOptions, __driNConfigOptions); - /** * FIXME: If the driver supports format conversion swapbuffer blits, we might * want to support other color bit depths than the server is currently * using. */ - configs = dri_fill_in_modes(screen, sPriv->fbBPP); + configs = dri_init_screen_helper(screen, &arg.base, sPriv->fbBPP); if (!configs) - goto out_no_configs; + goto fail; + + if (!arg.api) { + debug_printf("%s: failed to create dri1 screen\n", __FUNCTION__); + goto fail; + } + + __dri1_api_hooks = arg.api; return configs; - out_no_configs: - screen->pipe_screen->destroy(screen->pipe_screen); - out_no_screen: +fail: + dri_destroy_screen_helper(screen); FREE(screen); return NULL; } diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c index 854801d1ea..c632f0fe4f 100644 --- a/src/gallium/state_trackers/dri/drm/dri2.c +++ b/src/gallium/state_trackers/dri/drm/dri2.c @@ -375,6 +375,7 @@ static const __DRIextension *dri_screen_extensions[] = { const __DRIconfig ** dri2_init_screen(__DRIscreen * sPriv) { + const __DRIconfig **configs; struct dri_screen *screen; struct drm_create_screen_arg arg; @@ -385,28 +386,22 @@ dri2_init_screen(__DRIscreen * sPriv) screen->api = drm_api_create(); screen->sPriv = sPriv; screen->fd = sPriv->fd; + sPriv->private = (void *)screen; sPriv->extensions = dri_screen_extensions; - arg.mode = DRM_CREATE_NORMAL; - screen->pipe_screen = screen->api->create_screen(screen->api, screen->fd, &arg); - if (!screen->pipe_screen) { - debug_printf("%s: failed to create pipe_screen\n", __FUNCTION__); - goto fail; - } + arg.mode = DRM_CREATE_NORMAL; - screen->smapi = dri_create_st_manager(screen); - if (!screen->smapi) + configs = dri_init_screen_helper(screen, &arg, 32); + if (!configs) goto fail; - driParseOptionInfo(&screen->optionCache, - __driConfigOptions, __driNConfigOptions); - screen->auto_fake_front = dri_with_format(sPriv); - return dri_fill_in_modes(screen, 32); + return configs; fail: - dri_destroy_screen(sPriv); + dri_destroy_screen_helper(screen); + FREE(screen); return NULL; } |