1/*
2 * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef HDI_SENSOR_CONTROLLER_H
17#define HDI_SENSOR_CONTROLLER_H
18
19#include <stdint.h>
20#include <pthread.h>
21#include <sys/ioctl.h>
22#include "sensor_if.h"
23#include "sensor_type.h"
24
25enum SensorIoCmd {
26    SENSOR_IO_CMD_GET_INFO_LIST = 0,
27    SENSOR_IO_CMD_OPS           = 1,
28    SENSOR_IO_CMD_END,
29};
30
31enum SensorOpsIoCmd {
32    SENSOR_OPS_IO_CMD_ENABLE     = 0,
33    SENSOR_OPS_IO_CMD_DISABLE    = 1,
34    SENSOR_OPS_IO_CMD_SET_BATCH  = 2,
35    SENSOR_OPS_IO_CMD_SET_MODE   = 3,
36    SENSOR_OPS_IO_CMD_SET_OPTION = 4,
37    SENSOR_OPS_IO_CMD_READ_DATA  = 5,
38    SENSOR_OPS_IO_CMD_END,
39};
40
41/* the basic description of a sensor is the same as that of the kernel of definition */
42struct SensorBasicInformation {
43    char sensorName[SENSOR_NAME_MAX_LEN]; /* Sensor name */
44    char vendorName[SENSOR_NAME_MAX_LEN]; /* Sensor vendor */
45    char firmwareVersion[SENSOR_VERSION_MAX_LEN]; /* Sensor firmware version */
46    char hardwareVersion[SENSOR_VERSION_MAX_LEN]; /* Sensor hardware version */
47    int32_t sensorTypeId;   /* Sensor type ID (described in {@link SensorTypeTag}) */
48    int32_t sensorId;       /* Sensor ID, defined by the sensor driver developer */
49    int32_t maxRange;       /* Maximum measurement range of the sensor */
50    int32_t accuracy;       /* Sensor accuracy */
51    int32_t power;          /* Sensor power */
52    int64_t minDelay;       /* Minimum sample period allowed in nanoseconds */
53    int64_t maxDelay;       /* Maxmum sample period allowed in nanoseconds */
54    uint32_t fifoMaxEventCount; /**< Maxmum number of events of this sensor that could be batched */
55    uint32_t reserved;      /**< Reserved fields */
56};
57
58void GetSensorDeviceMethods(struct SensorInterface *device);
59void ReleaseAllSensorInfo(void);
60int32_t *GetSensorStatus(void);
61
62#endif /* HDI_SENSOR_CONTROLLER_H */
63