• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

external/gbm_gralloc


Commit MetaInfo

Revision27763e0d43cc16387d6de8ad89eafba33d5072e3 (tree)
Zeit2018-07-03 07:50:01
AutorRob Herring <robh@kern...>
CommiterRob Herring

Log Message

Switch to use gralloc handle defined in libdrm

Remove our custom handle definition and use the one defined in libdrm.

Signed-off-by: Rob Herring <robh@kernel.org>

Ändern Zusammenfassung

Diff

--- a/Android.mk
+++ b/Android.mk
@@ -27,6 +27,7 @@ LOCAL_SRC_FILES := \
2727 gralloc.cpp
2828
2929 LOCAL_SHARED_LIBRARIES := \
30+ libdrm \
3031 libgbm \
3132 liblog \
3233 libcutils
--- a/gralloc_drm_handle.h
+++ /dev/null
@@ -1,99 +0,0 @@
1-/*
2- * Copyright (C) 2010-2011 Chia-I Wu <olvaffe@gmail.com>
3- * Copyright (C) 2010-2011 LunarG Inc.
4- * Copyright (C) 2016 Linaro, Ltd., Rob Herring <robh@kernel.org>
5- *
6- * Permission is hereby granted, free of charge, to any person obtaining a
7- * copy of this software and associated documentation files (the "Software"),
8- * to deal in the Software without restriction, including without limitation
9- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10- * and/or sell copies of the Software, and to permit persons to whom the
11- * Software is furnished to do so, subject to the following conditions:
12- *
13- * The above copyright notice and this permission notice shall be included
14- * in all copies or substantial portions of the Software.
15- *
16- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22- * DEALINGS IN THE SOFTWARE.
23- */
24-
25-#ifndef _GRALLOC_DRM_HANDLE_H_
26-#define _GRALLOC_DRM_HANDLE_H_
27-
28-#include <cutils/log.h>
29-#include <cutils/native_handle.h>
30-#include <system/graphics.h>
31-
32-#ifdef __cplusplus
33-extern "C" {
34-#endif
35-
36-struct gralloc_drm_handle_t {
37- native_handle_t base;
38-
39- /* file descriptors */
40- int prime_fd;
41-
42- /* integers */
43- int magic;
44-
45- int width;
46- int height;
47- int format;
48- int usage;
49-
50- int name; /* the name of the bo */
51- int stride; /* the stride in bytes */
52- int data_owner; /* owner of data (for validation) */
53-
54- uint64_t modifier __attribute__((aligned(8))); /* buffer modifiers */
55- union {
56- void *data; /* pointer to struct gralloc_gbm_bo_t */
57- uint64_t reserved;
58- } __attribute__((aligned(8)));
59-};
60-#define GRALLOC_GBM_HANDLE_MAGIC 0x5f47424d
61-#define GRALLOC_GBM_HANDLE_NUM_FDS 1
62-#define GRALLOC_GBM_HANDLE_NUM_INTS ( \
63- ((sizeof(struct gralloc_drm_handle_t) - sizeof(native_handle_t))/sizeof(int)) \
64- - GRALLOC_GBM_HANDLE_NUM_FDS)
65-
66-static inline struct gralloc_drm_handle_t *gralloc_drm_handle(buffer_handle_t _handle)
67-{
68- struct gralloc_drm_handle_t *handle =
69- (struct gralloc_drm_handle_t *) _handle;
70-
71- if (handle && (handle->base.version != sizeof(handle->base) ||
72- handle->base.numInts != GRALLOC_GBM_HANDLE_NUM_INTS ||
73- handle->base.numFds != GRALLOC_GBM_HANDLE_NUM_FDS ||
74- handle->magic != GRALLOC_GBM_HANDLE_MAGIC)) {
75- ALOGE("invalid handle: version=%d, numInts=%d, numFds=%d, magic=%x",
76- handle->base.version, handle->base.numInts,
77- handle->base.numFds, handle->magic);
78- handle = NULL;
79- }
80-
81- return handle;
82-}
83-
84-static inline int gralloc_drm_get_prime_fd(buffer_handle_t _handle)
85-{
86- struct gralloc_drm_handle_t *handle = gralloc_drm_handle(_handle);
87- return (handle) ? handle->prime_fd : -1;
88-}
89-
90-static inline int gralloc_drm_get_gem_handle(buffer_handle_t handle)
91-{
92- (void)handle;
93- return 0; /* Not supported, return invalid handle. */
94-}
95-
96-#ifdef __cplusplus
97-}
98-#endif
99-#endif /* _GRALLOC_DRM_HANDLE_H_ */
--- a/gralloc_gbm.cpp
+++ b/gralloc_gbm.cpp
@@ -41,7 +41,7 @@
4141 #include <gbm.h>
4242
4343 #include "gralloc_gbm_priv.h"
44-#include "gralloc_drm_handle.h"
44+#include <android/gralloc_handle.h>
4545
4646 #include <unordered_map>
4747
@@ -152,9 +152,10 @@ static unsigned int get_pipe_bind(int usage)
152152 }
153153
154154 static struct gbm_bo *gbm_import(struct gbm_device *gbm,
155- struct gralloc_gbm_handle_t *handle)
155+ buffer_handle_t _handle)
156156 {
157157 struct gbm_bo *bo;
158+ struct gralloc_handle_t *handle = gralloc_handle(_handle);
158159 #ifdef GBM_BO_IMPORT_FD_MODIFIER
159160 struct gbm_import_fd_modifier_data data;
160161 #else
@@ -191,9 +192,10 @@ static struct gbm_bo *gbm_import(struct gbm_device *gbm,
191192 }
192193
193194 static struct gbm_bo *gbm_alloc(struct gbm_device *gbm,
194- struct gralloc_gbm_handle_t *handle)
195+ buffer_handle_t _handle)
195196 {
196197 struct gbm_bo *bo;
198+ struct gralloc_handle_t *handle = gralloc_handle(_handle);
197199 int format = get_gbm_format(handle->format);
198200 int usage = get_pipe_bind(handle->usage);
199201 int width, height;
@@ -241,6 +243,7 @@ void gbm_free(buffer_handle_t handle)
241243 if (!bo)
242244 return;
243245
246+ gbm_bo_handle_map.erase(handle);
244247 gbm_bo_destroy(bo);
245248 }
246249
@@ -257,7 +260,7 @@ static int gbm_map(buffer_handle_t handle, int x, int y, int w, int h,
257260 {
258261 int err = 0;
259262 int flags = GBM_BO_TRANSFER_READ;
260- struct gralloc_gbm_handle_t *gbm_handle = gralloc_gbm_handle(handle);
263+ struct gralloc_gbm_handle_t *gbm_handle = gralloc_handle(handle);
261264 struct gbm_bo *bo = gralloc_gbm_bo_from_handle(handle);
262265 struct bo_data_t *bo_data = gbm_bo_data(bo);
263266 uint32_t stride;
@@ -267,7 +270,7 @@ static int gbm_map(buffer_handle_t handle, int x, int y, int w, int h,
267270
268271 if (gbm_handle->format == HAL_PIXEL_FORMAT_YV12) {
269272 if (x || y)
270- ALOGE("can't map with offset for planar %p - fmt %x", bo, gbm_handle->format);
273+ ALOGE("can't map with offset for planar %p", bo);
271274 w /= 2;
272275 h += h / 2;
273276 }
@@ -329,15 +332,14 @@ struct gbm_device *gbm_dev_create(void)
329332 int gralloc_gbm_handle_register(buffer_handle_t _handle, struct gbm_device *gbm)
330333 {
331334 struct gbm_bo *bo;
332- struct gralloc_gbm_handle_t *handle = gralloc_gbm_handle(_handle);
333335
334- if (!handle)
336+ if (!_handle)
335337 return -EINVAL;
336338
337339 if (gbm_bo_handle_map.count(_handle))
338340 return -EINVAL;
339341
340- bo = gbm_import(gbm, handle);
342+ bo = gbm_import(gbm, _handle);
341343 if (!bo)
342344 return -EINVAL;
343345
@@ -352,58 +354,35 @@ int gralloc_gbm_handle_register(buffer_handle_t _handle, struct gbm_device *gbm)
352354 int gralloc_gbm_handle_unregister(buffer_handle_t handle)
353355 {
354356 gbm_free(handle);
355- gbm_bo_handle_map.erase(handle);
356357
357358 return 0;
358359 }
359360
360361 /*
361- * Create a buffer handle.
362- */
363-static struct gralloc_gbm_handle_t *create_bo_handle(int width,
364- int height, int format, int usage)
365-{
366- struct gralloc_gbm_handle_t *handle;
367-
368- handle = (gralloc_gbm_handle_t *)native_handle_create(GRALLOC_GBM_HANDLE_NUM_FDS, GRALLOC_GBM_HANDLE_NUM_INTS);
369- if (!handle)
370- return NULL;
371-
372- handle->magic = GRALLOC_GBM_HANDLE_MAGIC;
373- handle->width = width;
374- handle->height = height;
375- handle->format = format;
376- handle->usage = usage;
377- handle->prime_fd = -1;
378-
379- return handle;
380-}
381-
382-/*
383362 * Create a bo.
384363 */
385364 buffer_handle_t gralloc_gbm_bo_create(struct gbm_device *gbm,
386365 int width, int height, int format, int usage, int *stride)
387366 {
388367 struct gbm_bo *bo;
389- struct gralloc_gbm_handle_t *handle;
368+ native_handle_t *handle;
390369
391- handle = create_bo_handle(width, height, format, usage);
370+ handle = gralloc_handle_create(width, height, format, usage);
392371 if (!handle)
393372 return NULL;
394373
395374 bo = gbm_alloc(gbm, handle);
396375 if (!bo) {
397- native_handle_delete(&handle->base);
376+ native_handle_delete(handle);
398377 return NULL;
399378 }
400379
401- gbm_bo_handle_map.emplace(&handle->base, bo);
380+ gbm_bo_handle_map.emplace(handle, bo);
402381
403382 /* in pixels */
404- *stride = handle->stride / gralloc_gbm_get_bpp(format);
383+ *stride = gralloc_handle(handle)->stride / gralloc_gbm_get_bpp(format);
405384
406- return &handle->base;
385+ return handle;
407386 }
408387
409388 /*
@@ -413,14 +392,14 @@ int gralloc_gbm_bo_lock(buffer_handle_t handle,
413392 int usage, int x, int y, int w, int h,
414393 void **addr)
415394 {
416- struct gralloc_gbm_handle_t *gbm_handle = gralloc_gbm_handle(handle);
395+ struct gralloc_handle_t *gbm_handle = gralloc_handle(handle);
417396 struct gbm_bo *bo = gralloc_gbm_bo_from_handle(handle);
418397 struct bo_data_t *bo_data;
419398
420399 if (!bo)
421400 return -EINVAL;
422401
423- if ((gbm_handle->usage & usage) != usage) {
402+ if ((gbm_handle->usage & usage) != (uint32_t)usage) {
424403 /* make FB special for testing software renderer with */
425404
426405 if (!(gbm_handle->usage & GRALLOC_USAGE_SW_READ_OFTEN) &&
--- a/gralloc_gbm_priv.h
+++ b/gralloc_gbm_priv.h
@@ -32,9 +32,6 @@ extern "C" {
3232 struct gbm_device;
3333 struct gbm_bo;
3434
35-#define gralloc_gbm_handle_t gralloc_drm_handle_t
36-#define gralloc_gbm_handle gralloc_drm_handle
37-
3835 int gralloc_gbm_handle_register(buffer_handle_t handle, struct gbm_device *gbm);
3936 int gralloc_gbm_handle_unregister(buffer_handle_t handle);
4037