Files
android_device_google_conte…/sensorhal/sensors.h
Peng Xu cf5df9cf40 Implement sensor direct report mode
This change implements direct report for accel, gyro and mag at normal
and fast rate level. It supports ashmem shared memory.

The direct report and traditional sensor subscription are still
tangled up in this implementation.

Bug: 30985702
Bug: 33588372
Test: tested via demo app

Change-Id: Idc4f626dfe624558718c1b04f16898a0ea247e62
2017-01-24 22:50:14 +00:00

84 lines
2.6 KiB
C++

/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SENSORS_H_
#define SENSORS_H_
#include <hardware/hardware.h>
#include <hardware/sensors.h>
#include <media/stagefright/foundation/ABase.h>
#include "hubconnection.h"
struct SensorContext {
struct sensors_poll_device_1 device;
explicit SensorContext(const struct hw_module_t *module);
bool getHubAlive();
private:
android::sp<android::HubConnection> mHubConnection;
bool mHubAlive;
int close();
int activate(int handle, int enabled);
int setDelay(int handle, int64_t delayNs);
int poll(sensors_event_t *data, int count);
int batch(int handle, int64_t sampling_period_ns,
int64_t max_report_latency_ns);
int flush(int handle);
int register_direct_channel(
const struct sensors_direct_mem_t* mem, int channel_handle);
int config_direct_report(
int sensor_handle, int channel_handle, const struct sensors_direct_cfg_t * config);
// static wrappers
static int CloseWrapper(struct hw_device_t *dev);
static int ActivateWrapper(
struct sensors_poll_device_t *dev, int handle, int enabled);
static int SetDelayWrapper(
struct sensors_poll_device_t *dev, int handle, int64_t delayNs);
static int PollWrapper(
struct sensors_poll_device_t *dev, sensors_event_t *data, int count);
static int BatchWrapper(
struct sensors_poll_device_1 *dev,
int handle,
int flags,
int64_t sampling_period_ns,
int64_t max_report_latency_ns);
static int FlushWrapper(struct sensors_poll_device_1 *dev, int handle);
static int RegisterDirectChannelWrapper(struct sensors_poll_device_1 *dev,
const struct sensors_direct_mem_t* mem, int channel_handle);
static int ConfigDirectReportWrapper(struct sensors_poll_device_1 *dev,
int sensor_handle, int channel_handle, const struct sensors_direct_cfg_t * config);
DISALLOW_EVIL_CONSTRUCTORS(SensorContext);
};
#endif // SENSORS_H_