高通非adsp 架构下的sensor的bug调试
问题现象:
当休眠后,再次打开preesure sensor的时候,会出现隔一段时候后,APK才会出现数据;(数据有时候会很难出现)
问题分析:
从上面几节中,我们可以知道,framework到HAL是通过调用sensors.msm8909.so调用到函数PressureSensor::readEvents中取出的;
int PressureSensor::readEvents(sensors_event_t* data, int count)
{
int i = 0;
if (count < 1)
return -EINVAL;
if (mHasPendingEvent) {
mHasPendingEvent = false;
mPendingEvent.timestamp = getTimestamp();
*data = mPendingEvent;
return mEnabled ? 1 : 0;
}
if (mHasPendingMetadata) {
mHasPendingMetadata--;
meta_data.timestamp = getTimestamp();
*data = meta_data;
return mEnabled ? 1 : 0;
}
ssize_t n = mInputReader.fill(data_fd);
if (n < 0)
return n;
int numEventReceived = 0;
input_event const* event;
#if FETCH_FULL_EVENT_BEFORE_RETURN
again:
#endif
while (count && mInputReader.readEvent(&event)) {
int type = event->type;
if (type == EV_ABS) {
float value = event->value;
mPendingEvent.pressure = value * CONVERT_PRESSURE;
ALOGI("the pressure is %f\n", mPendingEvent.pressure);
} else if (type == EV_SYN) {
switch (event->code) {
case SYN_TIME_SEC:
mUseAbsTimeStamp = true;
report_time = event->value*1000000000LL;
break;
case SYN_TIME_NSEC:
mUseAbsTimeStamp = true;
mPendingEvent.timestamp = report_time+event->value;
break;
case SYN_REPORT:
if(mUseAbsTimeStamp != true) {
mPendingEvent.timestamp = timevalToNano(event->time);
}
if (mEnabled) {
// ALOGI("timestamp = %ld mEnabledTime = %ld mUseAbsTimeStamp = %d enable here\n", mPendingEvent.timestamp, mEnabledTime, mUseAbsTimeStamp);
// if (mPendingEvent.timestamp >= mEnabledTime)
{
*data = mPendingEvent;
ALOGI("data pressure is %f\n", data->pressure);
// data++;
numEventReceived++;
}
count--;
}
break;
}
} else {
ALOGE("PressureSensor: unknown event (type=%d, code=%d)",
type, event->code);
}
mInputReader.next();
}
#if FETCH_FULL_EVENT_BEFORE_RETURN
/* if we didn't read a complete event, see if we can fill and
try again instead of returning with nothing and redoing poll. */
if (numEventReceived == 0 && mEnabled == 1) {
n = mInputReader.fill(data_fd);
if (n)
goto again;
}
#endif
ALOGI("end the data the pressure is %f\n", mPendingEvent.pressure);
return numEventReceived;
}
增加if (mPendingEvent.timestamp >= mEnabledTime)判断是为了判断SYN_REPORT不延迟的情况;
mPendingEvent.timestamp在这里被赋值:
input_event const* event; //这个可以一直进来
if(mUseAbsTimeStamp != true) {
mPendingEvent.timestamp = timevalToNano(event->time);
}
event->time代表了按键时间;可以用struct timeval获取系统时间。
其中input_event和timeval结构体如下:struct input_event { struct timeval time; //按键时间 __u16 type; //类型,在下面有定义 __u16 code; //要模拟成什么按键 __s32 value;//是按下还是释放 }; struct timeval {
__kernel_time_t tv_sec; /* seconds */
__kernel_suseconds_t tv_usec; /* microseconds */
};
//将时间转换为ns
static int64_t timevalToNano(timeval const& t) {
return t.tv_sec*1000000000LL + t.tv_usec*1000;
}
通过打印可以知道问题出现的时候mPendingEvent.timestamp是小于mEnabledTime的,进不了判断,所以上层也就无法获取相应的数据;
mEnabledTime是在int PressureSensor::enable(int32_t, int en)函数中实现:
....
mEnabledTime = getTimestamp() + IGNORE_EVENT_TIME;
....
int64_t SensorBase::getTimestamp() {
struct timespec t;
t.tv_sec = t.tv_nsec = 0;
clock_gettime(CLOCK_BOOTTIME, &t);
return int64_t(t.tv_sec)*1000000000LL + t.tv_nsec;
}
//不过CLOCK_BOOTTIME计算系统suspend的时间,也就是说,不论是running还是suspend(这些都算是启动时间),CLOCK_BOOTTIME都会累积计时,直到系统reset或者shutdown。
所以在睡眠起来后mEnabledTime会大于mPendingEvent.timestamp,所以此时是没有上报数据的;将判断去掉即可;
patch地址
高通非adsp 架构下的sensor的bug调试的更多相关文章
- 高通adsp架构下sensor
一.高通sensor架构: linux驱动由浅入深系列:高通sensor架构实例分析之一(整体概览+AP侧代码分析) linux驱动由浅入深系列:高通sensor架构实例分析之二(adsp驱动代码结构 ...
- 高通Android display架构分析
目录(?)[-] Kernel Space Display架构介绍 函数和数据结构介绍 函数和数据结构介绍 函数和数据结构介绍 数据流分析 初始化过程分析 User Space display接口 K ...
- 高通camera基本代码架构【转】
本文转载自:http://blog.sina.com.cn/s/blog_c0de2be70102vyn1.html 1 camera基本代码架构 高通平台对于camera的代码组织,大体上还是遵循 ...
- 在高通平台Android环境下编译内核模块【转】
本文转载自:http://blog.xeonxu.info/blog/2012/12/04/zai-gao-tong-ping-tai-androidhuan-jing-xia-bian-yi-nei ...
- 【转】高通平台android 环境配置编译及开发经验总结
原文网址:http://blog.csdn.net/dongwuming/article/details/12784535 1.高通平台android开发总结 1.1 搭建高通平台环境开发环境 在高通 ...
- 高通安卓调试LCD几方面总结
来公司上班现在已经整整一个月了,蔽人不才,能力有限,学习进度缓慢,不过也是有一点点的收获与心得,在这里写出来与大家分享,养成良好的记录习惯也免得后忘记. 不啰嗦了,开入正题.来公司一个月左右的时间,主 ...
- linux驱动由浅入深系列:高通sensor架构实例分析之三(adsp上报数据详解、校准流程详解)【转】
本文转载自:https://blog.csdn.net/radianceblau/article/details/76180915 本系列导航: linux驱动由浅入深系列:高通sensor架构实例分 ...
- linux驱动由浅入深系列:高通sensor架构实例分析之二(驱动代码结构)【转】
本文转载自:https://blog.csdn.net/radianceblau/article/details/73498303 本系列导航: linux驱动由浅入深系列:高通sensor架构实例分 ...
- 高通HAL层之Sensor HAL
高通的HAL层其实分为两种,一种是直接从kernel这边报数据上来的,由sensor HAL层来监听,另一种是走ADSP的模式,HAL层是通过qmi的形式进行监听的: 走ADSP架构的可以看下面的博客 ...
随机推荐
- 课程四(Convolutional Neural Networks),第二 周(Deep convolutional models: case studies) —— 1.Practice questions
[解释] 应该是same padding 而不是 valid padding . [解释] 卷积操作用的应该是adding additional layers to the network ,而是应该 ...
- Intellij新安装初始化配置
自动编译开关 忽略大小写开关 IDEA默认是匹配大小写,此开关如果未关.你输入字符一定要符合大小写.比如你敲string是不会出现代码提示或智能补充.但是,如果你开了这个开关,你无论输入String或 ...
- 从零开始学 Web 之 JS 高级(二)原型链,原型的继承
大家好,这里是「 从零开始学 Web 系列教程 」,并在下列地址同步更新...... github:https://github.com/Daotin/Web 微信公众号:Web前端之巅 博客园:ht ...
- 读vue-0.6-filters.js源码
'abc' => 'Abc' function capitalize (value) { if (!value && value !== 0) return '' value = ...
- 图像处理之Retinex增强算法(SSR、MSR、MSRCR)
视网膜-大脑皮层(Retinex)理论认为世界是无色的,人眼看到的世界是光与物质相互作用的结果,也就是说,映射到人眼中的图像和光的长波(R).中波(G).短波(B)以及物体的反射性质有关 其中I是人眼 ...
- js与jQuery操作select大全
Js操作Select是很常见的,也是比较实用的,每一次操作select的时候,总是要出来翻一下资料,不如自己总结一下,以后就翻这里了. 一.js操作select部分 判断select选项中 是否存在V ...
- PHP 九九乘法表的4种表达方式
九九乘法表的四种不同表现形式 x轴对称: //第一种 for($i=1;$i<=9;$i++){ for($j=1;$j<=$i;$j++) { echo $i.'x'.$j.'='.$i ...
- C# 匿名类型序列化、反序列化
前言 现在提倡前后端分离,分离后服务全部采用接口的方式给前端提供服务,当我们处理自定义查询时必定会多表查询,而处理多表查询时我们又懒的去建view model,建的过多项目也凌乱的很,所以在dao层处 ...
- LinQ是什么?
•LINQ(发音:Link)是语言级集成查询(Language INtegrated Query) •LINQ是一种用来进行数据访问的编程模型,使得.NET语言可以直接支持数据查询 •LINQ的目标是 ...
- c# 匿名方法几种表现形式
delegate int del(int a); static void Main(string[] args) { //匿名方法的几种表现形式 del del = delegate (int x) ...