OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2008 The Android Open Source Project | 2 * Copyright (C) 2008 The Android Open Source Project |
3 * | 3 * |
4 * Licensed under the Apache License, Version 2.0 (the "License"); | 4 * Licensed under the Apache License, Version 2.0 (the "License"); |
5 * you may not use this file except in compliance with 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 | 6 * You may obtain a copy of the License at |
7 * | 7 * |
8 * http://www.apache.org/licenses/LICENSE-2.0 | 8 * http://www.apache.org/licenses/LICENSE-2.0 |
9 * | 9 * |
10 * Unless required by applicable law or agreed to in writing, software | 10 * Unless required by applicable law or agreed to in writing, software |
11 * distributed under the License is distributed on an "AS IS" BASIS, | 11 * distributed under the License is distributed on an "AS IS" BASIS, |
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 * See the License for the specific language governing permissions and | 13 * See the License for the specific language governing permissions and |
14 * limitations under the License. | 14 * limitations under the License. |
15 */ | 15 */ |
16 | 16 |
17 #include <hardware/hardware.h> | 17 #include <hardware/hardware.h> |
18 | 18 |
19 #include <cutils/properties.h> | 19 #include <cutils/properties.h> |
20 | 20 |
21 #include <stdlib.h> | |
21 #include <dlfcn.h> | 22 #include <dlfcn.h> |
22 #include <string.h> | 23 #include <string.h> |
23 #include <pthread.h> | 24 #include <pthread.h> |
24 #include <errno.h> | 25 #include <errno.h> |
25 #include <limits.h> | 26 #include <limits.h> |
26 | 27 |
27 #define LOG_TAG "HAL" | 28 #define LOG_TAG "HAL" |
28 #include <utils/Log.h> | 29 #include <utils/Log.h> |
29 | 30 |
30 /** Base path of the hal modules */ | 31 /** Base path of the hal modules */ |
31 #if defined(__LP64__) | 32 #if !defined(DEFAULT_HAL_LIBRARY_PATH) |
32 #define HAL_LIBRARY_PATH1 "/system/lib64/hw" | 33 #define DEFAULT_HAL_LIBRARY_PATH "/usr/lib/hwcplus" |
33 #define HAL_LIBRARY_PATH2 "/vendor/lib64/hw" | |
34 #else | |
35 #define HAL_LIBRARY_PATH1 "/system/lib/hw" | |
36 #define HAL_LIBRARY_PATH2 "/vendor/lib/hw" | |
37 #endif | 34 #endif |
38 | 35 |
39 /** | 36 /** |
40 * There are a set of variant filename for modules. The form of the filename | 37 * There are a set of variant filename for modules. The form of the filename |
41 * is "<MODULE_ID>.variant.so" so for the led module the Dream variants | 38 * is "<MODULE_ID>.variant.so" so for the led module the Dream variants |
42 * of base "ro.product.board", "ro.board.platform" and "ro.arch" would be: | 39 * of base "ro.product.board", "ro.board.platform" and "ro.arch" would be: |
43 * | 40 * |
44 * led.trout.so | 41 * led.trout.so |
45 * led.msm7k.so | 42 * led.msm7k.so |
46 * led.ARMV6.so | 43 * led.ARMV6.so |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 return status; | 119 return status; |
123 } | 120 } |
124 | 121 |
125 /* | 122 /* |
126 * Check if a HAL with given name and subname exists, if so return 0, otherwise | 123 * Check if a HAL with given name and subname exists, if so return 0, otherwise |
127 * otherwise return negative. On success path will contain the path to the HAL. | 124 * otherwise return negative. On success path will contain the path to the HAL. |
128 */ | 125 */ |
129 static int hw_module_exists(char *path, size_t path_len, const char *name, | 126 static int hw_module_exists(char *path, size_t path_len, const char *name, |
130 const char *subname) | 127 const char *subname) |
131 { | 128 { |
132 snprintf(path, path_len, "%s/%s.%s.so", | 129 char *base = getenv("HAL_LIBRARY_PATH"); |
rjkroege
2014/04/25 21:28:07
you could be less intrusive and preserve more of t
| |
133 HAL_LIBRARY_PATH2, name, subname); | 130 if (!base) |
131 base = DEFAULT_HAL_LIBRARY_PATH; | |
132 snprintf(path, path_len, "%s/%s.%s.so", base, name, subname); | |
134 if (access(path, R_OK) == 0) | 133 if (access(path, R_OK) == 0) |
135 return 0; | 134 return 0; |
136 | 135 |
137 snprintf(path, path_len, "%s/%s.%s.so", | |
138 HAL_LIBRARY_PATH1, name, subname); | |
139 if (access(path, R_OK) == 0) | |
140 return 0; | |
141 | |
142 return -ENOENT; | 136 return -ENOENT; |
143 } | 137 } |
144 | 138 |
145 int hw_get_module_by_class(const char *class_id, const char *inst, | 139 int hw_get_module_by_class(const char *class_id, const char *inst, |
146 const struct hw_module_t **module) | 140 const struct hw_module_t **module) |
147 { | 141 { |
148 int i; | 142 int i; |
149 char prop[PATH_MAX]; | 143 char prop[PATH_MAX]; |
150 char path[PATH_MAX]; | 144 char path[PATH_MAX]; |
151 char name[PATH_MAX]; | 145 char name[PATH_MAX]; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 found: | 185 found: |
192 /* load the module, if this fails, we're doomed, and we should not try | 186 /* load the module, if this fails, we're doomed, and we should not try |
193 * to load a different variant. */ | 187 * to load a different variant. */ |
194 return load(class_id, path, module); | 188 return load(class_id, path, module); |
195 } | 189 } |
196 | 190 |
197 int hw_get_module(const char *id, const struct hw_module_t **module) | 191 int hw_get_module(const char *id, const struct hw_module_t **module) |
198 { | 192 { |
199 return hw_get_module_by_class(id, NULL, module); | 193 return hw_get_module_by_class(id, NULL, module); |
200 } | 194 } |
OLD | NEW |