• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #ifndef SENSOR_DEVICE_MANAGER_H
10 #define SENSOR_DEVICE_MANAGER_H
11 
12 #include "hdf_base.h"
13 #include "hdf_device_desc.h"
14 #include "hdf_workqueue.h"
15 #include "osal_mutex.h"
16 #include "sensor_device_type.h"
17 #include "sensor_device_if.h"
18 
19 #define HDF_SENSOR_EVENT_QUEUE_NAME    "hdf_sensor_event_queue"
20 
21 enum SensorCmd {
22     SENSOR_CMD_GET_INFO_LIST = 0,
23     SENSOR_CMD_OPS           = 1,
24     SENSOR_CMD_END,
25 };
26 enum SensorOpsCmd {
27     SENSOR_OPS_CMD_ENABLE        = 0,
28     SENSOR_OPS_CMD_DISABLE       = 1,
29     SENSOR_OPS_CMD_SET_BATCH     = 2,
30     SENSOR_OPS_CMD_SET_MODE      = 3,
31     SENSOR_OPS_CMD_SET_OPTION    = 4,
32     SENSOR_OPS_CMD_READ_DATA     = 5,
33     SENSOR_OPS_CMD_BUTT,
34 };
35 
36 struct SensorDevInfoNode {
37     struct SensorDeviceInfo devInfo;
38     struct DListHead node;
39 };
40 
41 typedef int32_t (*SensorCmdHandle)(struct SensorDeviceInfo *info, struct HdfSBuf *data, struct HdfSBuf *reply);
42 int32_t ReportSensorEvent(const struct SensorReportEvent *events);
43 
44 struct SensorCmdHandleList {
45     enum SensorOpsCmd cmd;
46     SensorCmdHandle func;
47 };
48 
49 struct SensorDevMgrData {
50     struct IDeviceIoService ioService;
51     struct HdfDeviceObject *device;
52     struct DListHead sensorDevInfoHead;
53     struct OsalMutex mutex;
54     struct OsalMutex eventMutex;
55 };
56 
57 #endif /* SENSOR_DEVICE_MANAGER_H */
58