Android Sensor driver 架構
以下是我目前自行研讀+網路教學的認知
由上層到下層的順序:
Java APP => Java Jni =>HAL Interface => Link HAL (so file) => Mapping Driver Interface => sensor Driver

HAL Interface 指的是 sensors.h 其中重點內容如下:
//sensors_module_t 可以得到Sensor data
struct sensors_module_t {
struct hw_module_t common;
/**
* Enumerate all available sensors. The list is returned in "list".
* @return number of sensors in the list
*/
int (*get_sensors_list)(struct sensors_module_t* module,
struct sensor_t const** list);
};
//sensors_poll_device_t 內有可以對sensor的操作
struct sensors_poll_device_t {
struct hw_device_t common;

/** Activate/deactivate one sensor.
*
* @param handle is the handle of the sensor to change.
* @param enabled set to 1 to enable, or 0 to disable the sensor.
*
* @return 0 on success, negative errno code otherwise
*/
int (*activate)(struct sensors_poll_device_t *dev,
int handle, int enabled);

/**
* Set the delay between sensor events in nanoseconds for a given sensor.
*
* If the requested value is less than sensor_t::minDelay, then it's
* silently clamped to sensor_t::minDelay unless sensor_t::minDelay is
* 0, in which case it is clamped to >= 1ms.
*
* @return 0 if successful, < 0 on error
*/
int (*setDelay)(struct sensors_poll_device_t *dev,
int handle, int64_t ns);

/**
* Returns an array of sensor data.
* This function must block until events are available.
*
* @return the number of events read on success, or -errno in case of an error.
* This function should never return 0 (no event).
*
*/
int (*poll)(struct sensors_poll_device_t *dev,
sensors_event_t* data, int count);
};

Mapping Driver Interface 也會提供類似 sensor.h 給 sensor Driver
sensor driver只要針對需要的功能做延伸開發

HAL.so 如何操作 Driver部分,我也 不知道如何運作
而且網上資料非常少再討論這塊,如果有人了解,歡迎留言
其他詳細請參考http://blog.csdn.net/zhenwenxian/article/details/6260364

arrow
arrow
    創作者介紹
    創作者 傑克便便 的頭像
    傑克便便

    傑克便便的部落格~抒發一下

    傑克便便 發表在 痞客邦 留言(0) 人氣()