drm: Branch 'master' - 5 commits
[email protected] (Robert Foss) Wed, 14 Feb 2018 16:37:34 +0000 (UTC)
| Newsgroups | gmane.comp.video.dri.patches |
|---|---|
| Message-ID | <[email protected]> |
Android.mk | 8 ++- Makefile.sources | 3 + android/gralloc_handle.h | 108 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+), 2 deletions(-) New commits: commit e75e0ea2e3e29aa65dff868b1088bd41d9405781 Author: Robert Foss <[email protected]> Date: Tue Jan 16 18:07:15 2018 +0100 android: Change gralloc_handle_t members to be fixed width In order to lessen future alignment issues, lets switch to fixed width integers where possible. This excludes the data_owner since it is a pid_t which in theory could be larger than 32 bits. Signed-off-by: Robert Foss <[email protected]> Reviewed-by: Rob Herring <[email protected]> diff --git a/android/gralloc_handle.h b/android/gralloc_handle.h index 9648b006..b47bee19 100644 --- a/android/gralloc_handle.h +++ b/android/gralloc_handle.h @@ -51,15 +51,15 @@ struct gralloc_handle_t { int prime_fd; /* api variables */ - const int magic; /* differentiate between allocator impls */ + const uint32_t magic; /* differentiate between allocator impls */ const uint32_t version; /* api version */ - int width; /* width of buffer in pixels */ - int height; /* height of buffer in pixels */ - int format; /* pixel format (Android) */ - int usage; /* android libhardware usage flags */ + uint32_t width; /* width of buffer in pixels */ + uint32_t height; /* height of buffer in pixels */ + uint32_t format; /* pixel format (Android) */ + uint32_t usage; /* android libhardware usage flags */ - int stride; /* the stride in bytes */ + uint32_t stride; /* the stride in bytes */ uint64_t modifier; /* buffer modifiers */ int data_owner; /* owner of data (for validation) */ @@ -69,7 +69,7 @@ struct gralloc_handle_t { } __attribute__((aligned(8))); }; -#define GRALLOC_HANDLE_VERSION 2 +#define GRALLOC_HANDLE_VERSION 3 #define GRALLOC_HANDLE_MAGIC 0x60585350 #define GRALLOC_HANDLE_NUM_FDS 1 #define GRALLOC_HANDLE_NUM_INTS ( \ @@ -79,8 +79,10 @@ struct gralloc_handle_t { /** * Create a buffer handle. */ -static struct gralloc_handle_t gralloc_handle_create(int width, int height, - int format, int usage) +static struct gralloc_handle_t gralloc_handle_create(int32_t width, + int32_t height, + int32_t format, + int32_t usage) { struct alloc_handle_t handle = { .magic = GRALLOC_HANDLE_MAGIC, commit 8e00d5ffbda7ae7ef6e33aa51aa71a0bf347f488 Author: Robert Foss <[email protected]> Date: Tue Jan 16 14:38:41 2018 +0100 android: Remove member name from gralloc_handle_t The name member of gralloc_handle_t is no longer needed and has been removed. The version field has also been bumped. Signed-off-by: Robert Foss <[email protected]> Reviewed-by: Rob Herring <[email protected]> diff --git a/android/gralloc_handle.h b/android/gralloc_handle.h index 5d8a19ea..9648b006 100644 --- a/android/gralloc_handle.h +++ b/android/gralloc_handle.h @@ -59,7 +59,6 @@ struct gralloc_handle_t { int format; /* pixel format (Android) */ int usage; /* android libhardware usage flags */ - int name; /* the name of the bo */ int stride; /* the stride in bytes */ uint64_t modifier; /* buffer modifiers */ @@ -70,7 +69,7 @@ struct gralloc_handle_t { } __attribute__((aligned(8))); }; -#define GRALLOC_HANDLE_VERSION 1 +#define GRALLOC_HANDLE_VERSION 2 #define GRALLOC_HANDLE_MAGIC 0x60585350 #define GRALLOC_HANDLE_NUM_FDS 1 #define GRALLOC_HANDLE_NUM_INTS ( \ commit ed0ed55f3e6c2e1a460d72fed270f6243dcf92a5 Author: Robert Foss <[email protected]> Date: Tue Jan 16 15:19:15 2018 +0100 android: Mark gralloc_handle_t magic variable as const Mark magic member of gralloc_handle_t as const. Signed-off-by: Robert Foss <[email protected]> Reviewed-by: Rob Herring <[email protected]> diff --git a/android/gralloc_handle.h b/android/gralloc_handle.h index 7cbc8ee7..5d8a19ea 100644 --- a/android/gralloc_handle.h +++ b/android/gralloc_handle.h @@ -51,7 +51,7 @@ struct gralloc_handle_t { int prime_fd; /* api variables */ - int magic; /* differentiate between allocator impls */ + const int magic; /* differentiate between allocator impls */ const uint32_t version; /* api version */ int width; /* width of buffer in pixels */ commit 76cd0af39960d0c36e7aacd4fe8d6a08f4af8ecc Author: Robert Foss <[email protected]> Date: Tue Jan 16 14:36:13 2018 +0100 android: Add version variable to gralloc_handle_t The version variable will be used for versioning of this struct and the corresponding accessor functions. Signed-off-by: Robert Foss <[email protected]> Reviewed-by: Rob Herring <[email protected]> diff --git a/android/gralloc_handle.h b/android/gralloc_handle.h index 45b9f2e9..7cbc8ee7 100644 --- a/android/gralloc_handle.h +++ b/android/gralloc_handle.h @@ -27,6 +27,7 @@ #define __ANDROID_GRALLOC_HANDLE_H__ #include <cutils/native_handle.h> +#include <stdint.h> /* support users of drm_gralloc/gbm_gralloc */ #define gralloc_gbm_handle_t gralloc_handle_t @@ -49,7 +50,9 @@ struct gralloc_handle_t { */ int prime_fd; + /* api variables */ int magic; /* differentiate between allocator impls */ + const uint32_t version; /* api version */ int width; /* width of buffer in pixels */ int height; /* height of buffer in pixels */ @@ -67,6 +70,7 @@ struct gralloc_handle_t { } __attribute__((aligned(8))); }; +#define GRALLOC_HANDLE_VERSION 1 #define GRALLOC_HANDLE_MAGIC 0x60585350 #define GRALLOC_HANDLE_NUM_FDS 1 #define GRALLOC_HANDLE_NUM_INTS ( \ @@ -79,7 +83,9 @@ struct gralloc_handle_t { static struct gralloc_handle_t gralloc_handle_create(int width, int height, int format, int usage) { - struct gralloc_handle_t handle = { .magic = GRALLOC_HANDLE_MAGIC }; + struct alloc_handle_t handle = { + .magic = GRALLOC_HANDLE_MAGIC, + .version = GRALLOC_HANDLE_VERSION }; native_handle_t *nhandle = native_handle_create(GRALLOC_HANDLE_NUM_FDS, GRALLOC_HANDLE_NUM_INTS); commit a4b6fd651f1b34f13eb3a3bc101a34adfa3b54a5 Author: Robert Foss <[email protected]> Date: Wed Dec 6 19:28:13 2017 +0100 android: Move gralloc handle struct to libdrm This struct is used in mesa and drm_hwcomposer. Versions of if have been implemented in several grallocs: drm_gralloc, gbm_gralloc, minigbm and intel-minigbm. Other than the 1:1 move of the struct a new generic name has been chosen and variables have had comments added to them. Signed-off-by: Robert Foss <[email protected]> Reviewed-by: Rob Herring <[email protected]> diff --git a/Android.mk b/Android.mk index 292be236..8611c5e3 100644 --- a/Android.mk +++ b/Android.mk @@ -28,7 +28,7 @@ LIBDRM_TOP := $(LOCAL_PATH) include $(CLEAR_VARS) -# Import variables LIBDRM_{,H_,INCLUDE_H_,INCLUDE_VMWGFX_H_}FILES +# Import variables LIBDRM_{,H,INCLUDE_H,INCLUDE_ANDROID_H,INCLUDE_VMWGFX_H}_FILES include $(LOCAL_PATH)/Makefile.sources #static library for the device (recovery) @@ -38,7 +38,8 @@ LOCAL_MODULE := libdrm LOCAL_SRC_FILES := $(LIBDRM_FILES) LOCAL_EXPORT_C_INCLUDE_DIRS := \ $(LOCAL_PATH) \ - $(LOCAL_PATH)/include/drm + $(LOCAL_PATH)/include/drm \ + $(LOCAL_PATH)/android LOCAL_C_INCLUDES := \ $(LOCAL_PATH)/include/drm @@ -54,6 +55,9 @@ LOCAL_SRC_FILES := $(LIBDRM_FILES) LOCAL_EXPORT_C_INCLUDE_DIRS := \ $(LOCAL_PATH)/include/drm +LOCAL_SHARED_LIBRARIES := \ + libcutils + LOCAL_C_INCLUDES := \ $(LOCAL_PATH)/include/drm diff --git a/Makefile.sources b/Makefile.sources index 10aa1d0f..1f8372bc 100644 --- a/Makefile.sources +++ b/Makefile.sources @@ -37,5 +37,8 @@ LIBDRM_INCLUDE_H_FILES := \ include/drm/via_drm.h \ include/drm/virtgpu_drm.h +LIBDRM_INCLUDE_ANDROID_H_FILES := \ + android/gralloc_handle.h + LIBDRM_INCLUDE_VMWGFX_H_FILES := \ include/drm/vmwgfx_drm.h diff --git a/android/gralloc_handle.h b/android/gralloc_handle.h new file mode 100644 index 00000000..45b9f2e9 --- /dev/null +++ b/android/gralloc_handle.h @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2010-2011 Chia-I Wu <[email protected]> + * Copyright (C) 2010-2011 LunarG Inc. + * Copyright (C) 2016 Linaro, Ltd., Rob Herring <[email protected]> + * Copyright (C) 2018 Collabora, Robert Foss <[email protected]> + * + * 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, sublicense, + * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS 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 __ANDROID_GRALLOC_HANDLE_H__ +#define __ANDROID_GRALLOC_HANDLE_H__ + +#include <cutils/native_handle.h> + +/* support users of drm_gralloc/gbm_gralloc */ +#define gralloc_gbm_handle_t gralloc_handle_t +#define gralloc_drm_handle_t gralloc_handle_t + +struct gralloc_handle_t { + native_handle_t base; + + /* dma-buf file descriptor + * Must be located first since, native_handle_t is allocated + * using native_handle_create(), which allocates space for + * sizeof(native_handle_t) + sizeof(int) * (numFds + numInts) + * numFds = GRALLOC_HANDLE_NUM_FDS + * numInts = GRALLOC_HANDLE_NUM_INTS + * Where numFds represents the number of FDs and + * numInts represents the space needed for the + * remainder of this struct. + * And the FDs are expected to be found first following + * native_handle_t. + */ + int prime_fd; + + int magic; /* differentiate between allocator impls */ + + int width; /* width of buffer in pixels */ + int height; /* height of buffer in pixels */ + int format; /* pixel format (Android) */ + int usage; /* android libhardware usage flags */ + + int name; /* the name of the bo */ + int stride; /* the stride in bytes */ + uint64_t modifier; /* buffer modifiers */ + + int data_owner; /* owner of data (for validation) */ + union { + void *data; /* pointer to struct gralloc_gbm_bo_t */ + uint64_t reserved; + } __attribute__((aligned(8))); +}; + +#define GRALLOC_HANDLE_MAGIC 0x60585350 +#define GRALLOC_HANDLE_NUM_FDS 1 +#define GRALLOC_HANDLE_NUM_INTS ( \ + ((sizeof(struct alloc_handle_t) - sizeof(native_handle_t))/sizeof(int)) \ + - GRALLOC_HANDLE_NUM_FDS) + +/** + * Create a buffer handle. + */ +static struct gralloc_handle_t gralloc_handle_create(int width, int height, + int format, int usage) +{ + struct gralloc_handle_t handle = { .magic = GRALLOC_HANDLE_MAGIC }; + + native_handle_t *nhandle = native_handle_create(GRALLOC_HANDLE_NUM_FDS, + GRALLOC_HANDLE_NUM_INTS); + handle.base = *nhandle; + native_handle_delete(nhandle); + + handle.width = width; + handle.height = height; + handle.format = format; + handle.usage = usage; + handle.prime_fd = -1; + + handle->data_owner = getpid(); + handle->data = bo; + + return handle; +} + +#endif ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot --