Tizen HAL API  1.0
Common

The Common is a special module providing functions for implementing other hal modules.

Required Header

#include <hal-common.h>

Overview

The Common module is a special HAL module. It encapsulates loading and unloading of the hal backend. And it provides methods to get metadata of the hal backend such as name, vendor, version.

The Common module defines common interface hal_backend that associates platform hal module and hal backend. On top of the interface hal_backend, it provides functions for loading and unloading hal backend. The hal_common_get_backend() family functions internally invoke hal_backend.init which has been defined and registered by hal backend provider, and likewise hal_common_put_backend() family function invokes hal_backend.exit.

The Common module provides functions to load or unload the HAL backend.

 #include <hal-common.h>

 static hal_backend_foo_funcs *g_foo_funcs = NULL; // module interface defined by the hal module foo

 int hal_foo_get_backend(void)
 {
     int ret;

     g_foo_funcs = calloc(1, sizeof(hal_backend_foo_funcs));
     if (!g_foo_funcs)
         return -ENOMEM;

     ret = hal_common_get_backend(HAL_MODULE_FOO, &g_foo_funcs); // calls hal_backend.init(&g_foo_funcs) at the hal backend
     if (ret < 0)
         return -ENOTSUP;

     return 0;
 }

 int hal_foo_put_backend(void)
 {
     int ret;

     ret = hal_common_put_backend(HAL_MODULE_FOO, g_foo_funcs); // calls hal_backend.exit(g_foo_funcs) at the hal backend
     if (ret < 0)
         return ret;

     free(g_foo_funcs);
     g_foo_funcs = NULL;

     return 0;
 }

 int hal_foo_do_something(int data)
 {
     int ret;

     if (!hal_device_foo_funcs) {
         ret = hal_foo_get_backend();
         if (ret < 0)
             return ret;
     }

     if (!hal_device_foo_funcs || !hal_device_foo_funcs->do_something)
         return -ENOTSUP;

     return hal_device_foo_funcs->do_something(data);
 }

And the Common module provides functions to get metadata of the HAL backend.

For more information on the Common features and the macros, see HAL Common programming guides and tutorials.

Typedefs

typedef struct __hal_backend hal_backend
 Structure for HAL module backend.

Data Structure Documentation

struct __hal_backend

Structure for HAL module backend.

Since:
HAL_MODULE_COMMON 1.0

Data Fields

const char * name
const char * vendor
int(* init )(void **data)
int(* exit )(void *data)
const unsigned int major_version
const unsigned int minor_version

Field Documentation

int(* __hal_backend::exit)(void *data)

Function for deinitializing HAL Backend

int(* __hal_backend::init)(void **data)

Function for initializing HAL Backend

const unsigned int __hal_backend::major_version

Major version of HAL interface

const unsigned int __hal_backend::minor_version

Minor version of HAL interface

const char* __hal_backend::name

Name of HAL Backend

const char* __hal_backend::vendor

Vendor name of HAL Backend


Typedef Documentation

typedef struct __hal_backend hal_backend

Structure for HAL module backend.

Since:
HAL_MODULE_COMMON 1.0