-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsensors.c
86 lines (63 loc) · 2.29 KB
/
sensors.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
* Copyright (C) 2008 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.
*/
#define LOG_TAG "Sensors_Init"
#include <cutils/log.h>
#include <hardware/sensors.h>
#include <linux/hwmsensor.h>
#include <hwmsen_chip_info.h>
#include "nusensors.h"
/*****************************************************************************/
/*
* The SENSORS Module
*/
/*
* the AK8973 has a 8-bit ADC but the firmware seems to average 16 samples,
* or at least makes its calibration on 12-bits values. This increases the
* resolution by 4 bits.
*/
extern struct sensor_t sSensorList[MAX_NUM_SENSOR];
static int open_sensors(const struct hw_module_t* module, const char* name,
struct hw_device_t** device);
static int sensors__get_sensors_list(struct sensors_module_t* module,
struct sensor_t const** list)
{
ALOGD(" sSensorList addr =%x\r\n",sSensorList);
ALOGD(" ARRAY_SIZE(sSensorList) =%d\r\n",ARRAY_SIZE(sSensorList));
*list = sSensorList;
return ARRAY_SIZE(sSensorList);
}
static struct hw_module_methods_t sensors_module_methods = {
.open = open_sensors
};
struct sensors_module_t HAL_MODULE_INFO_SYM = {
.common = {
.tag = HARDWARE_MODULE_TAG,
.version_major = 1,
.version_minor = 0,
.id = SENSORS_HARDWARE_MODULE_ID,
.name = "MTK SENSORS Module",
.author = "The Android Open Source Project",
.methods = &sensors_module_methods,
},
.get_sensors_list = sensors__get_sensors_list,
};
/*****************************************************************************/
static int open_sensors(const struct hw_module_t* module, const char* name,
struct hw_device_t** device)
{
ALOGD("%s: name: %s! fwq debug\r\n", __func__, name);
return init_nusensors(module, device);
}