We need these so that we can upgrade the HAL.
Even if we don't have batch yet, the 1_3 API is requiring them.
Change-Id: I47da935b38bf1b051e3b5a18951d8f4724a82e31
Signed-off-by: Adriana Reus <adriana.reus@intel.com>
int report_pending;
/*
+ * This flag is set if we have a meta data event pending
+ */
+ volatile int meta_data_pending;
+
+ /*
* Timestamp closely matching the date of sampling, preferably retrieved
* from a iio channel alongside sample data. Value zero indicates that
* we couldn't get such a closely correlated timestamp, and that one
static pthread_cond_t thread_release_cond [MAX_SENSORS];
static pthread_mutex_t thread_release_mutex [MAX_SENSORS];
+
/*
* We associate tags to each of our poll set entries. These tags have the
* following values:
returned_events = 0;
/* Check our sensor collection for available reports */
- for (s=0; s<sensor_count && returned_events < count; s++)
+ for (s=0; s<sensor_count && returned_events < count; s++) {
if (sensor_info[s].report_pending) {
event_count = 0;
/* Lower flag */
* value for a 'on change' sensor, silently drop it.
*/
}
-
+ while (sensor_info[s].meta_data_pending) {
+ /* See sensors.h on these */
+ data[returned_events].version = META_DATA_VERSION;
+ data[returned_events].sensor = 0;
+ data[returned_events].type = SENSOR_TYPE_META_DATA;
+ data[returned_events].reserved0 = 0;
+ data[returned_events].timestamp = 0;
+ data[returned_events].meta_data.sensor = s;
+ data[returned_events].meta_data.what = META_DATA_FLUSH_COMPLETE;
+ returned_events++;
+ sensor_info[s].meta_data_pending--;
+ }
+ }
if (returned_events)
return returned_events;
return 0;
}
+int sensor_flush (int s)
+{
+ /* If one shot or not enabled return -EINVAL */
+ if (sensor_desc[s].flags & SENSOR_FLAG_ONE_SHOT_MODE ||
+ sensor_info[s].enable_count == 0)
+ return -EINVAL;
+
+ sensor_info[s].meta_data_pending++;
+ return 0;
+}
int allocate_control_data (void)
{
int sensor_activate (int handle, int enabled);
int sensor_set_delay (int handle, int64_t ns);
-int sensor_poll (sensors_event_t* data, int count);
+int sensor_poll (sensors_event_t* data, int count);
+int sensor_flush (int handle);
int allocate_control_data (void);
void delete_control_data (void);
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)
+{
+ 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)
+{
+ return sensor_flush (handle);
+}
static int close_module(hw_device_t *device)
{
if (init_count == 0)
static int initialize_module(const struct hw_module_t *module, const char *id,
struct hw_device_t** device)
{
- static struct sensors_poll_device_t poll_device;
+ static struct sensors_poll_device_1 poll_device;
if (strcmp(id, SENSORS_HARDWARE_POLL))
return -EINVAL;
poll_device.activate = activate;
poll_device.setDelay = set_delay;
poll_device.poll = poll;
+ poll_device.batch = batch;
+ poll_device.flush = flush;
*device = &poll_device.common;
sensor_info[s].thread_data_fd[1] = -1;
sensor_info[s].acquisition_thread = -1;
+ sensor_info[s].meta_data_pending = 0;
+
/* Check if we have a special ordering property on this sensor */
if (sensor_get_order(s, sensor_info[s].order))
sensor_info[s].quirks |= QUIRK_FIELD_ORDERING;