Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(386)

Side by Side Diff: third_party/hwcplus/src/hardware.c

Issue 262153002: Revert of Make it possible to build libhardware. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@hwc2
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/hwcplus/include/system/graphics.h ('k') | third_party/hwcplus/src/hwcplus_util.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <dlfcn.h> 21 #include <dlfcn.h>
22 #include <string.h> 22 #include <string.h>
23 #include <pthread.h> 23 #include <pthread.h>
24 #include <errno.h> 24 #include <errno.h>
25 #include <limits.h> 25 #include <limits.h>
26 #include <stdlib.h>
27 26
28 #define LOG_TAG "HAL" 27 #define LOG_TAG "HAL"
29 #ifdef ANDROID
30 #include <utils/Log.h> 28 #include <utils/Log.h>
31 #else
32 #include <stdio.h>
33 #include <unistd.h>
34 #include <log/log.h>
35 #endif
36
37 #if defined(__LP64__)
38 #define _64 "64"
39 #else
40 #define _64 ""
41 #endif
42 29
43 /** Base path of the hal modules */ 30 /** Base path of the hal modules */
44 #ifndef HAL_LIBRARY_PATH1 31 #if defined(__LP64__)
45 #define HAL_LIBRARY_PATH1 "/system/lib" _64 "/hw" 32 #define HAL_LIBRARY_PATH1 "/system/lib64/hw"
46 #endif 33 #define HAL_LIBRARY_PATH2 "/vendor/lib64/hw"
47 #ifndef HAL_LIBRARY_PATH2 34 #else
48 #define HAL_LIBRARY_PATH2 "/vendor/lib" _64 "/hw" 35 #define HAL_LIBRARY_PATH1 "/system/lib/hw"
36 #define HAL_LIBRARY_PATH2 "/vendor/lib/hw"
49 #endif 37 #endif
50 38
51 /** 39 /**
52 * There are a set of variant filename for modules. The form of the filename 40 * There are a set of variant filename for modules. The form of the filename
53 * is "<MODULE_ID>.variant.so" so for the led module the Dream variants 41 * is "<MODULE_ID>.variant.so" so for the led module the Dream variants
54 * of base "ro.product.board", "ro.board.platform" and "ro.arch" would be: 42 * of base "ro.product.board", "ro.board.platform" and "ro.arch" would be:
55 * 43 *
56 * led.trout.so 44 * led.trout.so
57 * led.msm7k.so 45 * led.msm7k.so
58 * led.ARMV6.so 46 * led.ARMV6.so
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 return status; 122 return status;
135 } 123 }
136 124
137 /* 125 /*
138 * Check if a HAL with given name and subname exists, if so return 0, otherwise 126 * Check if a HAL with given name and subname exists, if so return 0, otherwise
139 * otherwise return negative. On success path will contain the path to the HAL. 127 * otherwise return negative. On success path will contain the path to the HAL.
140 */ 128 */
141 static int hw_module_exists(char *path, size_t path_len, const char *name, 129 static int hw_module_exists(char *path, size_t path_len, const char *name,
142 const char *subname) 130 const char *subname)
143 { 131 {
144 char *hal_library_path = getenv("HAL_LIBRARY_PATH");
145 if (hal_library_path) {
146 snprintf(path, path_len, "%s/%s.%s.so",
147 hal_library_path, name, subname);
148 if (access(path, R_OK) == 0)
149 return 0;
150 }
151
152 snprintf(path, path_len, "%s/%s.%s.so", 132 snprintf(path, path_len, "%s/%s.%s.so",
153 HAL_LIBRARY_PATH2, name, subname); 133 HAL_LIBRARY_PATH2, name, subname);
154 if (access(path, R_OK) == 0) 134 if (access(path, R_OK) == 0)
155 return 0; 135 return 0;
156 136
157 snprintf(path, path_len, "%s/%s.%s.so", 137 snprintf(path, path_len, "%s/%s.%s.so",
158 HAL_LIBRARY_PATH1, name, subname); 138 HAL_LIBRARY_PATH1, name, subname);
159 if (access(path, R_OK) == 0) 139 if (access(path, R_OK) == 0)
160 return 0; 140 return 0;
161 141
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 found: 191 found:
212 /* load the module, if this fails, we're doomed, and we should not try 192 /* load the module, if this fails, we're doomed, and we should not try
213 * to load a different variant. */ 193 * to load a different variant. */
214 return load(class_id, path, module); 194 return load(class_id, path, module);
215 } 195 }
216 196
217 int hw_get_module(const char *id, const struct hw_module_t **module) 197 int hw_get_module(const char *id, const struct hw_module_t **module)
218 { 198 {
219 return hw_get_module_by_class(id, NULL, module); 199 return hw_get_module_by_class(id, NULL, module);
220 } 200 }
OLDNEW
« no previous file with comments | « third_party/hwcplus/include/system/graphics.h ('k') | third_party/hwcplus/src/hwcplus_util.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698