hardware/libsensors
Revisión | 40d6eb0404a1af7647dec78b4bf75d9949920497 (tree) |
---|---|
Tiempo | 2017-11-23 12:59:29 |
Autor | Chih-Wei Huang <cwhuang@linu...> |
Commiter | Chih-Wei Huang |
w500_sensor: update HAL version to 1_3
@@ -48,4 +48,5 @@ LOCAL_MODULE := sensors.w500 | ||
48 | 48 | LOCAL_MODULE_TAGS := optional |
49 | 49 | LOCAL_MODULE_RELATIVE_PATH := hw |
50 | 50 | LOCAL_SRC_FILES := w500_sensor.c |
51 | +LOCAL_CFLAGS := -Wno-unused-parameter | |
51 | 52 | include $(BUILD_SHARED_LIBRARY) |
@@ -16,6 +16,7 @@ | ||
16 | 16 | #include <cutils/native_handle.h> |
17 | 17 | #include <dirent.h> |
18 | 18 | #include <math.h> |
19 | +#include <inttypes.h> | |
19 | 20 | #include <hardware/sensors.h> |
20 | 21 | |
21 | 22 | #define DRIVER_DESC "Acer BMA150 accelerometer" |
@@ -37,7 +38,7 @@ | ||
37 | 38 | #define VALID_ROTATE_MASK (7 << 0) |
38 | 39 | |
39 | 40 | struct sensor_context { |
40 | - struct sensors_poll_device_t device; | |
41 | + struct sensors_poll_device_1 device; | |
41 | 42 | int accel_fd; |
42 | 43 | |
43 | 44 | struct timespec delay; |
@@ -137,17 +138,6 @@ static int context__activate(struct sensors_poll_device_t *dev, | ||
137 | 138 | return -EINVAL; |
138 | 139 | } |
139 | 140 | |
140 | -static int context__setDelay(struct sensors_poll_device_t *dev, | |
141 | - int handle, int64_t ns) | |
142 | -{ | |
143 | - struct sensor_context* ctx = (struct sensor_context *)dev; | |
144 | - | |
145 | - ctx->delay.tv_sec = 0; | |
146 | - ctx->delay.tv_nsec = ns; | |
147 | - | |
148 | - return 0; | |
149 | -} | |
150 | - | |
151 | 141 | static int context__close(struct hw_device_t *dev) |
152 | 142 | { |
153 | 143 | struct sensor_context* ctx = (struct sensor_context *)dev; |
@@ -352,6 +342,24 @@ static int context__poll(struct sensors_poll_device_t *dev, sensors_event_t *dat | ||
352 | 342 | return 0; |
353 | 343 | } |
354 | 344 | |
345 | +static int context__batch(struct sensors_poll_device_1* dev, int sensor_handle, | |
346 | + int flags, int64_t sampling_period_ns, int64_t max_report_latency_ns) | |
347 | +{ | |
348 | + ALOGD("%s: dev=%p sensor_handle=%d flags=%d sampling_period_ns=%" PRId64 " max_report_latency_ns=%" PRId64, | |
349 | + __FUNCTION__, dev, sensor_handle, flags, sampling_period_ns, max_report_latency_ns); | |
350 | + | |
351 | + struct sensor_context* ctx = (struct sensor_context *)dev; | |
352 | + ctx->delay.tv_sec = 0; | |
353 | + ctx->delay.tv_nsec = sampling_period_ns; | |
354 | + return EXIT_SUCCESS; | |
355 | +} | |
356 | + | |
357 | +static int context__flush(struct sensors_poll_device_1* dev, int sensor_handle) | |
358 | +{ | |
359 | + ALOGD("%s: dev=%p sensor_handle=%d", __FUNCTION__, dev, sensor_handle); | |
360 | + return EXIT_SUCCESS; | |
361 | +} | |
362 | + | |
355 | 363 | static const struct sensor_t sensor_list[] = { |
356 | 364 | [0] = { |
357 | 365 | .name = "W500 Ambient Light sensor", |
@@ -418,13 +426,14 @@ static int open_sensors(const struct hw_module_t *module, const char* id, | ||
418 | 426 | |
419 | 427 | /* Do common setup */ |
420 | 428 | ctx->device.common.tag = HARDWARE_DEVICE_TAG; |
421 | - ctx->device.common.version = 0; | |
429 | + ctx->device.common.version = SENSORS_DEVICE_API_VERSION_1_3; | |
422 | 430 | ctx->device.common.module = (struct hw_module_t *)module; |
423 | 431 | ctx->device.common.close = context__close; |
424 | 432 | |
425 | 433 | ctx->device.activate = context__activate; |
426 | - ctx->device.setDelay = context__setDelay; | |
427 | 434 | ctx->device.poll = context__poll; |
435 | + ctx->device.batch = context__batch; | |
436 | + ctx->device.flush = context__flush; | |
428 | 437 | |
429 | 438 | *device = &ctx->device.common; |
430 | 439 |
@@ -444,8 +453,8 @@ static struct hw_module_methods_t sensors_module_methods = { | ||
444 | 453 | struct sensors_module_t HAL_MODULE_INFO_SYM = { |
445 | 454 | .common = { |
446 | 455 | .tag = HARDWARE_MODULE_TAG, |
447 | - .version_major = 1, | |
448 | - .version_minor = 0, | |
456 | + .module_api_version = 1, | |
457 | + .hal_api_version = 0, | |
449 | 458 | .id = SENSORS_HARDWARE_MODULE_ID, |
450 | 459 | .name = "W500 SENSORS Module", |
451 | 460 | .author = "Marek Vasut", |