aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew F. Davis2018-09-04 12:07:31 -0500
committerAndrew F. Davis2018-09-04 12:19:51 -0500
commite84ee704d09d3b37fcb3df4973cb8fd35d33d950 (patch)
treeeb14ba4e00aefd4fa8aa13024381aea316d86d13
parent8cf51d34e36a427895be520510ed49de4a7e3277 (diff)
downloadexternal-libgbm-e84ee704d09d3b37fcb3df4973cb8fd35d33d950.tar.gz
external-libgbm-e84ee704d09d3b37fcb3df4973cb8fd35d33d950.tar.xz
external-libgbm-e84ee704d09d3b37fcb3df4973cb8fd35d33d950.zip
Add support for building as an Android library
Signed-off-by: Andrew F. Davis <afd@ti.com>
-rw-r--r--Android.bp33
-rw-r--r--backend.c13
-rw-r--r--gbm.c3
3 files changed, 42 insertions, 7 deletions
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 00000000..5faaa476
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,33 @@
1// Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
2// Andrew F. Davis <afd@ti.com>
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16cc_library_shared {
17 name: "libgbm",
18
19 vendor: true,
20
21 srcs: [
22 "gbm.c",
23 "backend.c",
24 ],
25
26 cflags: [
27 "-DLOG_TAG=\"ti_gbm\"",
28 ],
29
30 shared_libs: [
31 "liblog",
32 ],
33}
diff --git a/backend.c b/backend.c
index 2dbacabe..cdaab68a 100644
--- a/backend.c
+++ b/backend.c
@@ -25,17 +25,20 @@
25 * Benjamin Franzke <benjaminfranzke@googlemail.com> 25 * Benjamin Franzke <benjaminfranzke@googlemail.com>
26 */ 26 */
27 27
28#include <stdio.h>
29#include <stddef.h> 28#include <stddef.h>
30#include <stdlib.h> 29#include <stdlib.h>
31#include <string.h> 30#include <string.h>
32#include <limits.h> 31#include <limits.h>
33#include <dlfcn.h> 32#include <dlfcn.h>
34 33
34#include <log/log.h>
35
35#include "backend.h" 36#include "backend.h"
36 37
37#define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0])) 38#define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
38 39
40#define MODULEDIR "/vendor/lib"
41
39/* a more clever scheme would be to discover backends in a certain 42/* a more clever scheme would be to discover backends in a certain
40 * directory.. 43 * directory..
41 */ 44 */
@@ -57,11 +60,11 @@ load_backend(const char *name)
57 60
58 module = dlopen(path, RTLD_NOW | RTLD_GLOBAL); 61 module = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
59 if (!module) { 62 if (!module) {
60 fprintf(stderr, "failed to load module: %s\n", dlerror()); 63 ALOGE("failed to load module: %s\n", dlerror());
61 return NULL; 64 return NULL;
62 } 65 }
63 else { 66 else {
64 fprintf(stderr, "loaded module : %s\n", name); 67 ALOGE("loaded module : %s\n", name);
65 } 68 }
66 69
67 return dlsym(module, entrypoint); 70 return dlsym(module, entrypoint);
@@ -72,7 +75,7 @@ _gbm_create_device(int fd)
72{ 75{
73 const struct gbm_backend *backend = NULL; 76 const struct gbm_backend *backend = NULL;
74 struct gbm_device *dev = NULL; 77 struct gbm_device *dev = NULL;
75 int i; 78 unsigned int i;
76 const char *b; 79 const char *b;
77 80
78 b = getenv("GBM_BACKEND"); 81 b = getenv("GBM_BACKEND");
@@ -86,7 +89,7 @@ _gbm_create_device(int fd)
86 backend = load_backend(backends[i]); 89 backend = load_backend(backends[i]);
87 if (backend == NULL) 90 if (backend == NULL)
88 continue; 91 continue;
89 fprintf(stderr, "found valid GBM backend : %s\n", backends[i]); 92 ALOGE("found valid GBM backend : %s\n", backends[i]);
90 dev = backend->create_device(fd); 93 dev = backend->create_device(fd);
91 } 94 }
92 95
diff --git a/gbm.c b/gbm.c
index 6466ae05..be34bdff 100644
--- a/gbm.c
+++ b/gbm.c
@@ -29,7 +29,6 @@
29#define _DEFAULT_SOURCE 29#define _DEFAULT_SOURCE
30 30
31#include <stddef.h> 31#include <stddef.h>
32#include <stdio.h>
33#include <stdlib.h> 32#include <stdlib.h>
34#include <string.h> 33#include <string.h>
35#include <stdint.h> 34#include <stdint.h>
@@ -47,7 +46,7 @@
47 46
48static struct gbm_device *devices[16]; 47static struct gbm_device *devices[16];
49 48
50static int device_num = 0; 49static unsigned int device_num = 0;
51 50
52/** Returns the file description for the gbm device 51/** Returns the file description for the gbm device
53 * 52 *