1094332d3Sopenharmony_ci/*
2094332d3Sopenharmony_ci * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
3094332d3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4094332d3Sopenharmony_ci * you may not use this file except in compliance with the License.
5094332d3Sopenharmony_ci * You may obtain a copy of the License at
6094332d3Sopenharmony_ci *
7094332d3Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8094332d3Sopenharmony_ci *
9094332d3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10094332d3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11094332d3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12094332d3Sopenharmony_ci * See the License for the specific language governing permissions and
13094332d3Sopenharmony_ci * limitations under the License.
14094332d3Sopenharmony_ci */
15094332d3Sopenharmony_ci
16094332d3Sopenharmony_ci#ifndef HDI_SENSOR_CONTROLLER_H
17094332d3Sopenharmony_ci#define HDI_SENSOR_CONTROLLER_H
18094332d3Sopenharmony_ci
19094332d3Sopenharmony_ci#include <stdint.h>
20094332d3Sopenharmony_ci#include <pthread.h>
21094332d3Sopenharmony_ci#include <sys/ioctl.h>
22094332d3Sopenharmony_ci#include "sensor_if.h"
23094332d3Sopenharmony_ci#include "sensor_type.h"
24094332d3Sopenharmony_ci
25094332d3Sopenharmony_cienum SensorIoCmd {
26094332d3Sopenharmony_ci    SENSOR_IO_CMD_GET_INFO_LIST = 0,
27094332d3Sopenharmony_ci    SENSOR_IO_CMD_OPS           = 1,
28094332d3Sopenharmony_ci    SENSOR_IO_CMD_END,
29094332d3Sopenharmony_ci};
30094332d3Sopenharmony_ci
31094332d3Sopenharmony_cienum SensorOpsIoCmd {
32094332d3Sopenharmony_ci    SENSOR_OPS_IO_CMD_ENABLE     = 0,
33094332d3Sopenharmony_ci    SENSOR_OPS_IO_CMD_DISABLE    = 1,
34094332d3Sopenharmony_ci    SENSOR_OPS_IO_CMD_SET_BATCH  = 2,
35094332d3Sopenharmony_ci    SENSOR_OPS_IO_CMD_SET_MODE   = 3,
36094332d3Sopenharmony_ci    SENSOR_OPS_IO_CMD_SET_OPTION = 4,
37094332d3Sopenharmony_ci    SENSOR_OPS_IO_CMD_READ_DATA  = 5,
38094332d3Sopenharmony_ci    SENSOR_OPS_IO_CMD_END,
39094332d3Sopenharmony_ci};
40094332d3Sopenharmony_ci
41094332d3Sopenharmony_ci/* the basic description of a sensor is the same as that of the kernel of definition */
42094332d3Sopenharmony_cistruct SensorBasicInformation {
43094332d3Sopenharmony_ci    char sensorName[SENSOR_NAME_MAX_LEN]; /* Sensor name */
44094332d3Sopenharmony_ci    char vendorName[SENSOR_NAME_MAX_LEN]; /* Sensor vendor */
45094332d3Sopenharmony_ci    char firmwareVersion[SENSOR_VERSION_MAX_LEN]; /* Sensor firmware version */
46094332d3Sopenharmony_ci    char hardwareVersion[SENSOR_VERSION_MAX_LEN]; /* Sensor hardware version */
47094332d3Sopenharmony_ci    int32_t sensorTypeId;   /* Sensor type ID (described in {@link SensorTypeTag}) */
48094332d3Sopenharmony_ci    int32_t sensorId;       /* Sensor ID, defined by the sensor driver developer */
49094332d3Sopenharmony_ci    int32_t maxRange;       /* Maximum measurement range of the sensor */
50094332d3Sopenharmony_ci    int32_t accuracy;       /* Sensor accuracy */
51094332d3Sopenharmony_ci    int32_t power;          /* Sensor power */
52094332d3Sopenharmony_ci    int64_t minDelay;       /* Minimum sample period allowed in nanoseconds */
53094332d3Sopenharmony_ci    int64_t maxDelay;       /* Maxmum sample period allowed in nanoseconds */
54094332d3Sopenharmony_ci    uint32_t fifoMaxEventCount; /**< Maxmum number of events of this sensor that could be batched */
55094332d3Sopenharmony_ci    uint32_t reserved;      /**< Reserved fields */
56094332d3Sopenharmony_ci};
57094332d3Sopenharmony_ci
58094332d3Sopenharmony_civoid GetSensorDeviceMethods(struct SensorInterface *device);
59094332d3Sopenharmony_civoid ReleaseAllSensorInfo(void);
60094332d3Sopenharmony_ciint32_t *GetSensorStatus(void);
61094332d3Sopenharmony_ci
62094332d3Sopenharmony_ci#endif /* HDI_SENSOR_CONTROLLER_H */
63