From 76aed4b070be8950fd8ea5caff59321885ff0a06 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sat, 29 May 2010 11:33:14 +0200 Subject: gallium: Add drm driver interface This interfacre replaces the drm_api api it works very much the same way as drm_api but with the exception that its meant for the target to implement it. And it does not export a get function and neither a destroy function. --- src/gallium/include/state_tracker/drm_driver.h | 71 ++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/gallium/include/state_tracker/drm_driver.h (limited to 'src/gallium/include/state_tracker') diff --git a/src/gallium/include/state_tracker/drm_driver.h b/src/gallium/include/state_tracker/drm_driver.h new file mode 100644 index 00000000000..d94c1e6a7cf --- /dev/null +++ b/src/gallium/include/state_tracker/drm_driver.h @@ -0,0 +1,71 @@ + +#ifndef _DRM_DRIVER_H_ +#define _DRM_DRIVER_H_ + +#include "pipe/p_compiler.h" + +struct pipe_screen; +struct pipe_winsys; +struct pipe_context; +struct pipe_resource; + +#define DRM_API_HANDLE_TYPE_SHARED 0 +#define DRM_API_HANDLE_TYPE_KMS 1 + +/** + * For use with pipe_screen::{texture_from_handle|texture_get_handle}. + */ +struct winsys_handle +{ + /** + * Unused for texture_from_handle, always + * DRM_API_HANDLE_TYPE_SHARED. Input to texture_get_handle, + * use TEXTURE_USAGE to select handle for kms or ipc. + */ + unsigned type; + /** + * Input to texture_from_handle. + * Output for texture_get_handle. + */ + unsigned handle; + /** + * Input to texture_from_handle. + * Output for texture_get_handle. + */ + unsigned stride; +}; + +struct drm_driver_descriptor +{ + /** + * Identifying sufix/prefix of the binary, used by egl. + */ + const char *name; + + /** + * Kernel driver name, as accepted by drmOpenByName. + */ + const char *driver_name; + + /** + * Create a pipe srcreen. + * + * This function does any wrapping of the screen. + * For example wrapping trace or rbug debugging drivers around it. + */ + struct pipe_screen* (*create_screen)(int drm_fd); +}; + +extern struct drm_driver_descriptor driver_descriptor; + +/** + * Instantiate a drm_driver_descriptor struct. + */ +#define DRM_DRIVER_DESCRIPTOR(name_str, driver_name_str, func) \ +struct drm_driver_descriptor driver_descriptor = { \ + .name = name_str, \ + .driver_name = driver_name_str, \ + .create_screen = func, \ +}; + +#endif -- cgit v1.2.3 From e47d32d721a76b5df3b640ccdc9bad15dffb8450 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Wed, 23 Jun 2010 23:14:22 +0200 Subject: gallium: Remove drm_api and all references to it --- .../auxiliary/target-helpers/drm_api_compat.h | 46 ---------- src/gallium/drivers/identity/Makefile | 3 +- src/gallium/drivers/identity/SConscript | 1 - src/gallium/drivers/identity/id_drm.c | 93 ------------------- src/gallium/drivers/identity/id_drm.h | 35 ------- src/gallium/drivers/trace/Makefile | 1 - src/gallium/drivers/trace/SConscript | 1 - src/gallium/drivers/trace/tr_drm.c | 101 --------------------- src/gallium/drivers/trace/tr_drm.h | 35 ------- src/gallium/include/state_tracker/drm_api.h | 57 ------------ src/gallium/targets/dri-swrast/swrast_drm_api.c | 1 - 11 files changed, 1 insertion(+), 373 deletions(-) delete mode 100644 src/gallium/auxiliary/target-helpers/drm_api_compat.h delete mode 100644 src/gallium/drivers/identity/id_drm.c delete mode 100644 src/gallium/drivers/identity/id_drm.h delete mode 100644 src/gallium/drivers/trace/tr_drm.c delete mode 100644 src/gallium/drivers/trace/tr_drm.h delete mode 100644 src/gallium/include/state_tracker/drm_api.h (limited to 'src/gallium/include/state_tracker') diff --git a/src/gallium/auxiliary/target-helpers/drm_api_compat.h b/src/gallium/auxiliary/target-helpers/drm_api_compat.h deleted file mode 100644 index 324c6f2ba94..00000000000 --- a/src/gallium/auxiliary/target-helpers/drm_api_compat.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file contain a small backwards compatible shim between - * the old depricated drm_api and the drm_driver interface. - */ - -#ifndef DRM_API_COMPAT_H -#define DRM_API_COMPAT_H - -#ifdef _DRM_API_H_ -#error "Included drm_api.h before drm_api_compat.h" -#endif - -#include "state_tracker/drm_driver.h" - -/* - * XXX Hack, can't include both drm_api and drm_driver. Due to name - * collition of winsys_handle, just use a define to rename it. - */ -#define winsys_handle HACK_winsys_handle -#include "state_tracker/drm_api.h" -#undef winsys_handle - -static INLINE struct pipe_screen * -drm_api_compat_create_screen(int fd) -{ - static struct drm_api *api; - if (!api) - api = drm_api_create(); - - if (!api) - return NULL; - - return api->create_screen(api, fd); -} - -/** - * Instanciate a drm_driver descriptor. - */ -#define DRM_API_COMPAT_STRUCT(name_str, driver_name_str) \ -struct drm_driver_descriptor driver_descriptor = { \ - .name = name_str, \ - .driver_name = driver_name_str, \ - .create_screen = drm_api_compat_create_screen, \ -}; - -#endif diff --git a/src/gallium/drivers/identity/Makefile b/src/gallium/drivers/identity/Makefile index e32b9102e59..74692d97610 100644 --- a/src/gallium/drivers/identity/Makefile +++ b/src/gallium/drivers/identity/Makefile @@ -6,7 +6,6 @@ LIBNAME = identity C_SOURCES = \ id_objects.c \ id_context.c \ - id_screen.c \ - id_drm.c + id_screen.c include ../../Makefile.template diff --git a/src/gallium/drivers/identity/SConscript b/src/gallium/drivers/identity/SConscript index 2a68891c284..b364e0acc84 100644 --- a/src/gallium/drivers/identity/SConscript +++ b/src/gallium/drivers/identity/SConscript @@ -6,7 +6,6 @@ identity = env.ConvenienceLibrary( target = 'identity', source = [ 'id_context.c', - 'id_drm.c', 'id_objects.c', 'id_screen.c', ]) diff --git a/src/gallium/drivers/identity/id_drm.c b/src/gallium/drivers/identity/id_drm.c deleted file mode 100644 index 15d01519f80..00000000000 --- a/src/gallium/drivers/identity/id_drm.c +++ /dev/null @@ -1,93 +0,0 @@ -/************************************************************************** - * - * Copyright 2009 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include "state_tracker/drm_api.h" - -#include "util/u_memory.h" -#include "id_drm.h" -#include "id_screen.h" -#include "id_public.h" - -struct identity_drm_api -{ - struct drm_api base; - - struct drm_api *api; -}; - -static INLINE struct identity_drm_api * -identity_drm_api(struct drm_api *_api) -{ - return (struct identity_drm_api *)_api; -} - -static struct pipe_screen * -identity_drm_create_screen(struct drm_api *_api, int fd) -{ - struct identity_drm_api *id_api = identity_drm_api(_api); - struct drm_api *api = id_api->api; - struct pipe_screen *screen; - - screen = api->create_screen(api, fd); - - return identity_screen_create(screen); -} - -static void -identity_drm_destroy(struct drm_api *_api) -{ - struct identity_drm_api *id_api = identity_drm_api(_api); - struct drm_api *api = id_api->api; - api->destroy(api); - - FREE(id_api); -} - -struct drm_api * -identity_drm_create(struct drm_api *api) -{ - struct identity_drm_api *id_api; - - if (!api) - goto error; - - id_api = CALLOC_STRUCT(identity_drm_api); - - if (!id_api) - goto error; - - id_api->base.name = api->name; - id_api->base.driver_name = api->driver_name; - id_api->base.create_screen = identity_drm_create_screen; - id_api->base.destroy = identity_drm_destroy; - id_api->api = api; - - return &id_api->base; - -error: - return api; -} diff --git a/src/gallium/drivers/identity/id_drm.h b/src/gallium/drivers/identity/id_drm.h deleted file mode 100644 index cf2ad2ce07f..00000000000 --- a/src/gallium/drivers/identity/id_drm.h +++ /dev/null @@ -1,35 +0,0 @@ -/************************************************************************** - * - * Copyright 2009 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#ifndef ID_DRM_H -#define ID_DRM_H - -struct drm_api; - -struct drm_api* identity_drm_create(struct drm_api *api); - -#endif /* ID_DRM_H */ diff --git a/src/gallium/drivers/trace/Makefile b/src/gallium/drivers/trace/Makefile index 1b0c087a2a4..99e5fb81c22 100644 --- a/src/gallium/drivers/trace/Makefile +++ b/src/gallium/drivers/trace/Makefile @@ -8,7 +8,6 @@ C_SOURCES = \ tr_dump.c \ tr_dump_state.c \ tr_screen.c \ - tr_drm.c \ tr_texture.c include ../../Makefile.template diff --git a/src/gallium/drivers/trace/SConscript b/src/gallium/drivers/trace/SConscript index 0dc43a9ec41..06b0c4863a4 100644 --- a/src/gallium/drivers/trace/SConscript +++ b/src/gallium/drivers/trace/SConscript @@ -6,7 +6,6 @@ trace = env.ConvenienceLibrary( target = 'trace', source = [ 'tr_context.c', - 'tr_drm.c', 'tr_dump.c', 'tr_dump_state.c', 'tr_screen.c', diff --git a/src/gallium/drivers/trace/tr_drm.c b/src/gallium/drivers/trace/tr_drm.c deleted file mode 100644 index e6850332121..00000000000 --- a/src/gallium/drivers/trace/tr_drm.c +++ /dev/null @@ -1,101 +0,0 @@ -/************************************************************************** - * - * Copyright 2009 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include "state_tracker/drm_api.h" - -#include "util/u_memory.h" -#include "rbug/rbug_public.h" -#include "tr_drm.h" -#include "tr_screen.h" -#include "tr_public.h" - -struct trace_drm_api -{ - struct drm_api base; - - struct drm_api *api; -}; - -static INLINE struct trace_drm_api * -trace_drm_api(struct drm_api *_api) -{ - return (struct trace_drm_api *)_api; -} - -static struct pipe_screen * -trace_drm_create_screen(struct drm_api *_api, int fd) -{ - struct trace_drm_api *tr_api = trace_drm_api(_api); - struct drm_api *api = tr_api->api; - struct pipe_screen *screen; - - /* TODO trace call */ - - screen = api->create_screen(api, fd); - - return trace_screen_create(rbug_screen_create(screen)); -} - -static void -trace_drm_destroy(struct drm_api *_api) -{ - struct trace_drm_api *tr_api = trace_drm_api(_api); - struct drm_api *api = tr_api->api; - - if (api->destroy) - api->destroy(api); - - FREE(tr_api); -} - -struct drm_api * -trace_drm_create(struct drm_api *api) -{ - struct trace_drm_api *tr_api; - - if (!api) - goto error; - - if (!trace_enabled() && !rbug_enabled()) - goto error; - - tr_api = CALLOC_STRUCT(trace_drm_api); - - if (!tr_api) - goto error; - - tr_api->base.name = api->name; - tr_api->base.driver_name = api->driver_name; - tr_api->base.create_screen = trace_drm_create_screen; - tr_api->base.destroy = trace_drm_destroy; - tr_api->api = api; - - return &tr_api->base; - -error: - return api; -} diff --git a/src/gallium/drivers/trace/tr_drm.h b/src/gallium/drivers/trace/tr_drm.h deleted file mode 100644 index 845c66a32aa..00000000000 --- a/src/gallium/drivers/trace/tr_drm.h +++ /dev/null @@ -1,35 +0,0 @@ -/************************************************************************** - * - * Copyright 2009 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#ifndef TR_DRM_H -#define TR_DRM_H - -struct drm_api; - -struct drm_api* trace_drm_create(struct drm_api *api); - -#endif /* ID_DRM_H */ diff --git a/src/gallium/include/state_tracker/drm_api.h b/src/gallium/include/state_tracker/drm_api.h deleted file mode 100644 index 4572c7e0423..00000000000 --- a/src/gallium/include/state_tracker/drm_api.h +++ /dev/null @@ -1,57 +0,0 @@ - -#ifndef _DRM_API_H_ -#define _DRM_API_H_ - -#include "pipe/p_compiler.h" - -struct pipe_screen; -struct pipe_winsys; -struct pipe_context; -struct pipe_resource; - -#define DRM_API_HANDLE_TYPE_SHARED 0 -#define DRM_API_HANDLE_TYPE_KMS 1 - -/** - * For use with pipe_screen::{texture_from_handle|texture_get_handle}. - */ -struct winsys_handle -{ - /** - * Unused for texture_from_handle, always - * DRM_API_HANDLE_TYPE_SHARED. Input to texture_get_handle, - * use TEXTURE_USAGE to select handle for kms or ipc. - */ - unsigned type; - /** - * Input to texture_from_handle. - * Output for texture_get_handle. - */ - unsigned handle; - /** - * Input to texture_from_handle. - * Output for texture_get_handle. - */ - unsigned stride; -}; - -struct drm_api -{ - void (*destroy)(struct drm_api *api); - - const char *name; - - /** - * Kernel driver name, as accepted by drmOpenByName. - */ - const char *driver_name; - - /** - * Create a pipe srcreen. - */ - struct pipe_screen* (*create_screen)(struct drm_api *api, int drm_fd); -}; - -extern struct drm_api * drm_api_create(void); - -#endif diff --git a/src/gallium/targets/dri-swrast/swrast_drm_api.c b/src/gallium/targets/dri-swrast/swrast_drm_api.c index 84142be80c8..ddf78406d53 100644 --- a/src/gallium/targets/dri-swrast/swrast_drm_api.c +++ b/src/gallium/targets/dri-swrast/swrast_drm_api.c @@ -28,7 +28,6 @@ #include "pipe/p_compiler.h" #include "util/u_memory.h" -#include "state_tracker/drm_api.h" #include "state_tracker/sw_winsys.h" #include "dri_sw_winsys.h" #include "trace/tr_public.h" -- cgit v1.2.3