OSDN Git Service

Fix LOCAL_MODULE for auto-detected targets
[android-x86/hardware-intel-libsensors.git] / entry.c
diff --git a/entry.c b/entry.c
index 5868c4c..96925f7 100644 (file)
--- a/entry.c
+++ b/entry.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 Intel Corporation.
+ * Copyright (C) 2014-2015 Intel Corporation.
  */
 
 #include <hardware/sensors.h>
@@ -12,7 +12,8 @@
 
 static int init_count;
 
-static int activate(struct sensors_poll_device_t* dev, int handle, int enabled)
+static int activate (__attribute__((unused)) struct sensors_poll_device_t* dev,
+                    int handle, int enabled)
 {
        if (init_count == 0 || handle < 0 || handle >= sensor_count)
                return -EINVAL;
@@ -26,31 +27,43 @@ static int activate(struct sensors_poll_device_t* dev, int handle, int enabled)
         * a workaround for this behavior. We set the initial sampling rate to
         * 10 events per second when the sensor is enabled for the first time.
         */
+
        if (enabled && sensor_get_quirks(handle) & QUIRK_INITIAL_RATE) {
                ALOGI("Forcing initial sampling rate\n");
-               sensor_activate(handle, 1);
-               sensor_set_delay(handle, 100000000L);   /* Start with 100 ms */
-               sensor_activate(handle, 0);
+               sensor_activate(handle, 1, 0);
+               sensor_set_delay(handle, 100000000);    /* Start with 100 ms */
+               sensor_activate(handle, 0, 0);
 
                /* Clear flag for this sensor as do this only once */
-               sensor_info[handle].quirks ^= QUIRK_INITIAL_RATE;
+               sensor[handle].quirks ^= QUIRK_INITIAL_RATE;
        }
 
-       return sensor_activate(handle, enabled);
+       return sensor_activate(handle, enabled, 0);
 }
 
 
-static int set_delay(struct sensors_poll_device_t* dev, int handle, int64_t ns)
+static int set_delay (__attribute__((unused)) struct sensors_poll_device_t* dev,
+                     int handle, int64_t ns)
 {
+       int i;
+
        if (init_count == 0 || handle < 0 || handle >= sensor_count)
                return -EINVAL;
 
+       /*
+        * If this sensor relies on other sensors, try to propagate the
+        * requested sampling rate to the base sensors.
+        */
+
+       for (i=0; i<sensor[handle].base_count; i++)
+               sensor_set_delay(sensor[handle].base[i], ns);
+
        return sensor_set_delay(handle, ns);
 }
 
 
-static int poll(struct sensors_poll_device_t* dev, sensors_event_t* data,
-               int count)
+static int poll (__attribute__((unused)) struct sensors_poll_device_t* dev,
+                sensors_event_t* data, int count)
 {
        if (init_count == 0 || !data || count < 1)
                return -EINVAL;
@@ -58,19 +71,24 @@ static int poll(struct sensors_poll_device_t* dev, sensors_event_t* data,
        return sensor_poll(data, count);
 }
 
-static int batch (struct sensors_poll_device_1* dev,
-            int sensor_handle, int flags, int64_t sampling_period_ns,
-            int64_t max_report_latency_ns)
+
+static int batch (__attribute__((unused)) struct sensors_poll_device_1* dev,
+                 int sensor_handle, __attribute__((unused)) int flags,
+                 int64_t sampling_period_ns,
+                 __attribute__((unused)) int64_t max_report_latency_ns)
 {
        return set_delay ((struct sensors_poll_device_t*)dev,
                sensor_handle, sampling_period_ns);
 }
 
-static int flush(struct sensors_poll_device_1* dev, int handle)
+static int flush (__attribute__((unused)) struct sensors_poll_device_1* dev,
+                 int handle)
 {
        return sensor_flush (handle);
 }
-static int close_module(hw_device_t *device)
+
+
+static int close_module (__attribute__((unused)) hw_device_t *device)
 {
        if (init_count == 0)
                return -EINVAL;