以backlight为例说明hal层调用

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);


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值