int hw_get_module(const char *id, const struct hw_module_t **module)
{
typedef struct hw_module_t {
struct hw_module_methods_t* methods;
typedef struct hw_module_methods_t {
/** Open a specific device */
int (*open)(const struct hw_module_t* module, const char* id, struct hw_device_t** device);
typedef struct hw_device_t {
/** tag must be initialized to HARDWARE_DEVICE_TAG */
uint32_t tag;
/** reference to the module this device belongs to */
struct hw_module_t* module;
} hw_device_t;
} hw_module_methods_t;
/** module's dso */
void* dso;
} hw_module_t;
return hw_get_module_by_class(id, NULL, module);
int hw_get_module_by_class(const char *class_id, const char *inst,
const struct hw_module_t **module)
{
for (i=0 ; i<HAL_VARIANT_KEYS_COUNT; i++) {
static const int HAL_VARIANT_KEYS_COUNT =
(sizeof(variant_keys)/sizeof(variant_keys[0]));
property_get(variant_keys[i], prop, NULL);
static const char *variant_keys[] = {
"ro.hardware", /* This goes first so that it can pick up a different
file on the emulator. */
"ro.product.board",
"ro.board.platform",
"ro.arch"
};
hw_module_exists(path, sizeof(path), name, prop);
snprintf(path, path_len, "%s/%s.%s.so",HAL_LIBRARY_PATH2, name, subname);
access(path, R_OK) ;
snprintf(path, path_len, "%s/%s.%s.so",HAL_LIBRARY_PATH1, name, subname);
access(path, R_OK) ;
load(class_id, path, module);
void *handle;
struct hw_module_t *hmi;
handle = dlopen(path, RTLD_NOW);
const char *sym = HAL_MODULE_INFO_SYM_AS_STR;
hmi = (struct hw_module_t *)dlsym(handle, sym);
{
typedef struct hw_module_t {
struct hw_module_methods_t* methods;
typedef struct hw_module_methods_t {
/** Open a specific device */
int (*open)(const struct hw_module_t* module, const char* id, struct hw_device_t** device);
typedef struct hw_device_t {
/** tag must be initialized to HARDWARE_DEVICE_TAG */
uint32_t tag;
/** reference to the module this device belongs to */
struct hw_module_t* module;
} hw_device_t;
} hw_module_methods_t;
/** module's dso */
void* dso;
} hw_module_t;
return hw_get_module_by_class(id, NULL, module);
int hw_get_module_by_class(const char *class_id, const char *inst,
const struct hw_module_t **module)
{
for (i=0 ; i<HAL_VARIANT_KEYS_COUNT; i++) {
static const int HAL_VARIANT_KEYS_COUNT =
(sizeof(variant_keys)/sizeof(variant_keys[0]));
property_get(variant_keys[i], prop, NULL);
static const char *variant_keys[] = {
"ro.hardware", /* This goes first so that it can pick up a different
file on the emulator. */
"ro.product.board",
"ro.board.platform",
"ro.arch"
};
hw_module_exists(path, sizeof(path), name, prop);
snprintf(path, path_len, "%s/%s.%s.so",HAL_LIBRARY_PATH2, name, subname);
access(path, R_OK) ;
snprintf(path, path_len, "%s/%s.%s.so",HAL_LIBRARY_PATH1, name, subname);
access(path, R_OK) ;
load(class_id, path, module);
void *handle;
struct hw_module_t *hmi;
handle = dlopen(path, RTLD_NOW);
const char *sym = HAL_MODULE_INFO_SYM_AS_STR;
hmi = (struct hw_module_t *)dlsym(handle, sym);