}
;
2、在_defconfig中打开相应的driver文件
3、如何判断driver是否调通?
1)编译后下载后,通过adb 中getevent判断是否驱动产生了设备节点
shell@MMX:/ # getevent
getevent
could not get driver version for /dev/input/mouse0, Not a typewriter
add device 1: /dev/input/event1
name: "vnc-ts"
add device 2: /dev/input/event7
name: "map asoc Hook"
add device 3: /dev/input/event8
name: "map asoc Headset"
add device 4: /dev/input/event0
name: "pxa27x-keypad"
add device 5: /dev/input/event3
name: "88pm886_on"
add device 6: /dev/input/event2
name: "msg2238"
add device 7: /dev/input/event6
name: "APDS_proximity_sensor"
add device 8: /dev/input/event5
name: "APDS_light_sensor"
add device 9: /dev/input/event4
name: "accelerometer"
通过以上可以看出为dev/input/event5 和/dev/input/event6 ,
2)确定是否有报点上传
通过以下命令进行判断
1|shell@:/sys/class/input/input5 $ cat active
cat active
0
shell@:/sys/class/input/input5 $ echo 1 >active
echo 1 >active
shell@:/sys/class/input/input5 $ getevent
getevent
could not get driver version for /dev/input/mouse0, Not a typewriter
add device 1: /dev/input/event1
name: "vnc-ts"
add device 2: /dev/input/event7
name: "map asoc Hook"
add device 3: /dev/input/event8
name: "map asoc Headset"
add device 4: /dev/input/event0
name: "pxa27x-keypad"
add device 5: /dev/input/event3
name: "88pm886_on"
add device 6: /dev/input/event2
name: "msg2238"
add device 7: /dev/input/event6
name: "APDS_proximity_sensor"
add device 8: /dev/input/event5
name: "APDS_light_sensor"
add device 9: /dev/input/event4
name: "accelerometer"
could not get driver version for /dev/input/mice, Not a typewriter
/dev/input/event5: 0003 0018 00000066
/dev/input/event5: 0000 0000 00000000
/dev/input/event5: 0003 0018 0000006d
/dev/input/event5: 0000 0000 00000000
/dev/input/event3: 0001 0074 00000001
/dev/input/event3: 0000 0000 00000000
/dev/input/event4: 0003 0000 0000000b
/dev/input/event4: 0000 0000 00000000
/dev/input/event3: 0001 0074 00000000
/dev/input/event3: 0000 0000 00000000
/dev/input/event4: 0003 0000 fffffff5
#adb shell getevent -lr /dev/input/event5
手动验证有数据传上来,说明driver工作正常。
二、framework层调试
1) 判断framework使用那套流程,打开相应的宏开关
通过sensors_hal.cpp中查看开关那个红
BOARD_HAVE_AVAGO=true
2)驱动层有设备节点是否跟framework层一致。
Driver:
static const char ElanPsensorName[] = "APDS_proximity_sensor";
static const char ElanALsensorName[] = "APDS_light_sensor";
framework:
AvagoLightSensor::AvagoLightSensor()
: LightSensorSet("APDS_light_sensor")
{
}
3)上报的诗句是否与farmework中处理的是否一致
Driver中:
input_report_abs(epld->als_input_dev, ABS_PRESSURE, lux);
framework中:
int LightSensorSet::readEvents(sensors_event_t* data, int count)
{
… …
if ((type == EV_ABS) && (event->value > 0)) {
if (event->code == ABS_PRESSURE) {
mPendingEvent.light = event->value;
valid = true;
if (LOG_DBG)
LOGD("LightSensor: read value = %f", mPendingEvent.light);
}
} else if ( (type == EV_SYN) && valid ) {
4) 注意使能标志位是否一致。
Driver中:
static struct device_attribute dev_attr_light_enable =
__ATTR(active, S_IRWXUGO,
light_enable_show, light_enable_store);
Framework中:
int LightSensorSet::enable(int32_t handle, int en)
{
int flags = en ? 1 : 0;
if (flags != mEnabled) {
int fd;
char enablePath[PATH_MAX];
sprintf(enablePath, "%s/%s", mClassPath, "active");
if (LOG_DBG)
LOGD("LightSensor enable path is %s", enablePath);
fd = open(enablePath, O_RDWR);
if (fd >= 0) {
err = write(fd, buf, sizeof(buf));
close(fd);
return 0;
}
三、应用层调试
安装并使用测试sensor APP来判断是否能工作。