1.声明入口函数
(ADSP.8953.2.8.2\adsp_proc\Sensors\dd\qcom\inc\sns_dd.h)
extern sns_ddf_driver_if_s sns_dd_part_mc3413_if;1
2.添加新的驱动文件
2.1 添加驱动文件
在这个目录adsp_proc/slpi_proc>\sensors\dd\qcom\src添加新的驱动文件
并且在adsp_proc/slpi_proc>\sensors\dd\qcom\build\dd_qcom.scons 包含编译文件
2.2 添加编译选项配置
(adsp_proc/slpi_proc>\sensors\build\Sensors.scons)
3.生成 UUID 并与驱动建立联系
3.1 在sns_reg_common.h文件中更新uuid
//adsp ap端都要更新uuid
**(ADSP – ADSP.8953.2.8.2\adsp_proc\Sensors\common\inc\sns_reg_common.h)
(APSS -android\vendor\qcom\proprietary\sensors\dsps\sensordaemon\common\inc\sns_reg_common.h)**
3.2. 更新 Sensors Manager (SMGR) sensor函数指针和uuid
For MSM8974, MSM8x26, and APQ8084, modify (adsp_proc/Sensors/smgr/src/common/sns_smgr_init.c) update smgr_sensor_fn_ptr_map[]:
For MSM8994/MSM8992, MSM8952, and MSM8996, modify (adsp_proc/Sensors/smgr/src/sns_smgr_reg.c) update smgr_sensor_fn_ptr_map[]:
#ifdef CONFIG_SUPPORT_<NEW_SENSOR_MODEL>
{ SNS_REG_UUID_XXXX, &sns_xxx_xxxx_driver_fn_list}, // (UUID,sensor驱动入口函数)
#endif123
4.单独更新adsp firware
单独更新adsp bin方法如下:
adb root
adb wait-for-device
adb remount
adb shell mount -o rw,remount /firmware
adb shell rm /firmware/image/adsp*
adb push adsp* /firmware/image/ (adsp.b00 ~ adsp.b14 、adsp.mdt)
adb shell rm /persist/sensors/sns.reg
adb shell sync
adb reboot12345678910
4. 配置sensor相关配置文件 ,及push生效生成reg文件
4.1 配置sensor config文件 ☆
(vendor/qcom/proprietary /sensors/dsps/reg_defaults/sensor_def_qcomdev.conf)
—— 可以在Sensors\api\sns_reg_api_v02.h 找到对应的含义
// sns_reg_api_v02.h 中对应各sensor的数值
SNS_REG_ITEM_SSI_DEVINFO_ACCEL
SNS_REG_ITEM_SSI_DEVINFO_GYRO
SNS_REG_ITEM_SSI_DEVINFO_MAG
SNS_REG_ITEM_SSI_DEVINFO_PROX_LIGHT
SNS_REG_ITEM_SSI_DEVINFO_SAR
SNS_REG_ITEM_SSI_DEVINFO_HALL
123456789
—— 配置i2c总线、地址、及数据获取方式(irq、fifo、poll)
1
demo
// uuid 添加规则
{0x50,0xa7,0xb4,0xbd,0x8e,0x57,0x43,0x2a, 0x85,0x7f,0x3f,0xf8,0x8b,0x88,0x26,0x68
#UUID2013 0x2a43578ebdb4a750 0x00010001
#UUID2014 0x6826888bf83f7f85 0x00010001123456
4.2 push配置使其生效
For MSM8974, MSM8x26, APQ8084 – /etc/sensor_def_.conf
For MSM8994/MSM8992, MSM8952, MSM8996 – /etc/sensors/sensor_def_.conf
adb root
adb remount
adb shell rm /system/etc/sensors/sensor_def_qcomdev.conf
adb push sensor_def_qcomdev.conf /system/etc/sensors/sensor_def_qcomdev.conf
adb shell chmod 644 /system/etc/sensors/sensor_def_qcomdev.conf
adb shell rm /persist/sensor/sns.reg
adb shell sync
adb reboot 12345678
4.3 config文件生成reg文件
A registry (sns.reg) is created from the sensor_def_.conf file on boot-up time by the
sensors daemon in the following directory paths:
For MSM8974, MSM8x26, APQ8084 – /data/misc/sensors/sns.reg
For MSM8994/92, MSM8952, MSM8996 – /persist/sensors/sns.reg
4.4 根据config文件版本号决定是否更新config文件
For MSM8974, MSM8x26, APQ8084 – /etc/sensor_def_.conf
For MSM8994/MSM8992, MSM8952, MSM8996 – /etc/sensors/sensor_def_.conf
:version 0x00010002
:hardware 8974
…
# SSI SMGR Cfg 0
1903 0x11FFEEDDCCBBAA99 0x00010001 # Low UUID
1902 0x9988665544332211 0x00010001 # High UUID
1906 3 0x00010002 # I2C Bus – updating from 12 to 31234567
注意:一定要更新config版本号,产线两段式升级(不擦除persist分区)时若config配置有变化版本号未更新就会出现配置不生效的情况
5.sensor probe过程分析
// sns_smgr_reg.c
SMGR_STATIC void sns_smgr_parse_reg_devinfo_resp( uint16_t Id, const sns_reg_ssi_devinfo_group_s* devinfo)
{
…
SNS_SMGR_PRINTF2(HIGH, “ssi: probing devinfo_idx[i]: %u[%u]”, devinfo_idx, i);
SNS_SMGR_PRINTF3(HIGH, “ssi: bus_instance:%u gpio1:%u slave_addr:0x%x”,
devinfo->uuid_cfg[i].i2c_bus, devinfo->uuid_cfg[i].gpio1,
devinfo->uuid_cfg[i].i2c_address );
// 调用dd sensor驱动的probe函数
status = drv_fn_ptr->probe( &dev_access, &memhandler,
&num_sensors, &sensor_list );
if( status == SNS_DDF_SUCCESS && num_sensors != 0 )
{
SNS_SMGR_PRINTF2(HIGH, “zch—ssi: devinfo_idx[i]: %u[%u] probe success”, devinfo_idx, i);
return;
}
else
SNS_SMGR_PRINTF3(HIGH, “ssi: devinfo_idx[i]: %u[%u] probe failed error=%d”, devinfo_idx, i, status);
…
}
123456789101112131415161718192021222324252627
6.cfg各配置项说明
2202 0x564d2b94fe80aef6 0x00010001 #UUID
2203 0x90611b98d561168f 0x00010001 #UUID
2204 3000 0x00010001 #off_to_idle
2205 10000 0x00010001 #idle_to_ready
2206 44 0x00010001 #gpio1 // 中断应交
2207 1020 0x00010001 #reg_group_id // nv分区中的reg偏移值(详见KBA-160602035047 cfg文件所代表的配置.pdf)
2208 0xffff 0x00010001 #cal_grp_id // 同上
2209 0x4 0x00010001 #i2c_bus
2210 0xc 0x00010001 #i2c_addr
2211 1 0x00010001 #sens_default
2212 0x0 0x00010001 #flags
// reg_group_id 关系到nv分区中保存的sensor方向的配置!!12345678910111213
7.sensor方向
每个sensor init过程会 通过sns_ddf_axes_map_init 从nv分区中读取sensor方向设置(如下修改为强制修改方向忽略cfg文件配置)
8.获取init log
8.1方法一
adb root
adb wait-for-device
adb remount
adb shell rm /persist/sensors/sns.reg
adb shell sync
adb shell stop sensors
adb shell “echo ‘related’ > /sys/bus/msm_subsys/devices/subsys2/restart_level”
adb shell “echo ‘restart’ > /sys/kernel/debug/msm_subsys/adsp”;
adb shell start sensors’123456789
8.2方法二
1)
adb root
adb wait-for-device
adb remount
adb shell rm /persist/sensors/sns.reg
adb shell sync
adb shell stop sensors
adb shell “echo ‘related’ > /sys/bus/msm_subsys/devices/subsys2/restart_level”1234567
2) qxdm 中send cmd
send_data 75 37 03 48 001
3) adb shell start sensors
9.命令行获取sensor数据
-r : rate
-d: duration in secound
-s: Sensor ID
-t data_type // 几个数据
sns_cm_test -r 20 -d 1 -s 40 -t 1 测试prox
sns_cm_test -r 20 -d 1 -s 0 -t 0 测试G-sensor
sns_cm_test -r 20 -d 1 -s 10 -t 0测试GYRO
sns_cm_test -r 20 -d 1 -s 20 -t 0测试MAG
123456789
#check sensor registry configure:
sns_regedit_ssi -r
#check which sensor init success:
sns_dsps_tc000112345
10.conf文件解析
vendor/qcom/proprietary/sensors/dsps/sensordaemon/reg/src/sns_reg_conf_la.c
sns_reg_write_conf_item123
10.sleep 模式下capsensor无效
—— 将数据上传模式改为wakeup
1
— a/vendor/qcom/proprietary/sensors/dsps/libhalsensors/src/SAR.cpp
+++ b/vendor/qcom/proprietary/sensors/dsps/libhalsensors/src/SAR.cpp
@@ -18,6 +18,7 @@ SAR::SAR(int handle)
:SMGRSensor(handle)
{
trigger_mode = SENSOR_MODE_EVENT;
+ bWakeUp = true;
}
/*============================================================================
@@ -38,7 +39,8 @@ void SAR::setSensorInfo(sns_smgr_sensor_datatype_info_s_v01* sensor_datatype)
{
HAL_LOG_DEBUG(“%s: SAR DTy: %d”, __FUNCTION__, sensor_datatype->DataType);
setType(SENSOR_TYPE_SAR);
– setFlags(SENSOR_FLAG_ON_CHANGE_MODE);
+ setFlags(SENSOR_FLAG_ON_CHANGE_MODE|SENSOR_FLAG_WAKE_UP);
+ strlcat(name,” -Wakeup”,SNS_MAX_SENSOR_NAME_SIZE);
setResolution((float)((float)sensor_datatype->Resolution *
UNIT_CONVERT_Q16));
setMaxRange((float)((float)sensor_datatype->MaxRange *
123456789101112131415161718192021
11.SSI auto detect下允许初始化的sensor个数
#adsp_proc/Sensors/smgr/src/sns_smgr_sensor_config.h
SNS_SMGR_NUM_SENSORS_DEFINED12
12.auto detect every boottime
diff –git a/Sensors/smgr/src/sns_smgr_reg.c b/Sensors/smgr/src/sns_smgr_reg.c
index ed725ec..65aedf6 100755
— a/Sensors/smgr/src/sns_smgr_reg.c
+++ b/Sensors/smgr/src/sns_smgr_reg.c
@@ -1733,7 +1733,7 @@
0,
sizeof(sns_reg_ssi_smgr_cfg_group_s));
– ssi_cfg_ptr->maj_ver_no = 1;
+ ssi_cfg_ptr->maj_ver_no = 0;
ssi_cfg_ptr->min_ver_no = 1;
ssi_cfg_ptr->reserved1 = 0;
ssi_cfg_ptr->reserved2 = 0;
@@ -1990,7 +1990,7 @@
sns_smgr.all_init_state = SENSOR_ALL_INIT_CONFIGURED;
}
}
– else if ( (cfg_group_ptr->maj_ver_no != 1) && !valid_cfg )
+ else if ( !valid_cfg )
{
/* Only use the configuration if the major version is 1.
Otherwise autodetect sensors */
123456789101112131415161718192021222324
13.add product keyword to match different sensor configurations
add product keyword to match different sensor configurations
Change-Id: I1afbb2b23e0758bc32378330ffba3dafe27e4130
—
diff –git a/dsps/sensordaemon/reg/src/sns_reg_conf_la.c b/dsps/sensordaemon/reg/src/sns_reg_conf_la.c
old mode 100644
new mode 100755
index 831a2d9..71ac549
— a/dsps/sensordaemon/reg/src/sns_reg_conf_la.c
+++ b/dsps/sensordaemon/reg/src/sns_reg_conf_la.c
@@ -295,6 +295,7 @@
@param item_id[i]: Item ID
@param item_val[i]: Discovered item val, if any
@param hw_conf[i]: Hardware string selected in the conf file
+ @param product_conf[i]: Product string selected in the conf file
@param platform_conf[i]: Platform string selected in the conf file
@param soc_id_conf[i]: SOC ID string selected in the conf file
@param subtype_conf[i]: Platform subtype string selected in the conf file
@@ -307,6 +308,7 @@
void sns_reg_write_conf_item( int32_t item_id,
uint64_t item_val,
char (*hw_conf)[META_VAL_LEN],
+ char (*product_conf)[META_VAL_LEN],
char (*platform_conf)[META_VAL_LEN],
char (*version_conf)[META_VAL_LEN],
char (*soc_id_conf)[META_VAL_LEN],
@@ -318,6 +320,7 @@
{
int index;
static char hw_string[PROPERTY_VALUE_MAX] = “”;
+ static char product_string[20] = “”;
static char platform_string[20] = “”;
static char platform_subtype_string[20] = “”;
static char platform_subtype_id_string[20] = “”;
@@ -333,6 +336,25 @@
/* get the hw string from property */
property_get(“ro.board.platform”, hw_string, “”);
+
+ /* check the motorola product */
+ fp = sns_fsa_open(“/sys/devices/soc0/motorola_product”, “r” );
+ if( fp == NULL )
+ {
+ SNS_PRINTF_STRING_ERROR_1( SNS_MODULE_APPS_REG,
+ “motorola_product fopen failed %i”, errno );
+ strlcpy(product_string, invalid_str, sizeof(product_string));
+ }
+ else if( fgets(product_string, sizeof(product_string), fp) == NULL )
+ {
+ SNS_PRINTF_STRING_ERROR_1( SNS_MODULE_APPS_REG,
+ “product_string fgets failed %i: %i”, errno );
+ strlcpy(product_string, invalid_str, sizeof(product_string));
+ }
+ if( fp != NULL )
+ {
+ sns_fsa_close( fp );
+ }
fp = sns_fsa_open(“/sys/devices/soc0/hw_platform”, “r” );
if( fp == NULL )
@@ -452,6 +474,12 @@
/* Configuration file set a hardware string, and it doesn’t match
this hardware. Abort */
return;
+ }
+ if( ( product_conf[0][0] != 0 ) &&
+ sns_reg_match_conf_item( product_string, product_conf ) ) {
+ /* Configuration file set a product string, and it doesn’t match
+ the product string. Abort */
+ return;
}
if( ( platform_conf[0][0] != 0 ) &&
sns_reg_match_conf_item( platform_string, platform_conf ) ) {
@@ -581,6 +609,7 @@
char *buf = malloc(sz);
uint32_t file_version = 0;
char hw_conf[META_MAX_KEY][META_VAL_LEN];
+ char product_conf[META_MAX_KEY][META_VAL_LEN];
char platform_conf[META_MAX_KEY][META_VAL_LEN];
char soc_id_conf[META_MAX_KEY][META_VAL_LEN];
char subtype_conf[META_MAX_KEY][META_VAL_LEN];
@@ -592,6 +621,7 @@
for( key_var = 0; key_var < META_MAX_KEY; key_var++ ) {
hw_conf[key_var][0] = 0x00;
+ product_conf[key_var][0] = 0x00;
platform_conf[key_var][0] = 0x00;
soc_id_conf[key_var][0] = 0x00;
subtype_conf[key_var][0] = 0x00;
@@ -629,7 +659,7 @@
/* Check for an item */
if( true == sns_reg_parse_conf_item( buf, &item_id, &item_val, &item_ver ) ) {
if( item_ver > conf_info->version) {
– sns_reg_write_conf_item( item_id, item_val, hw_conf,
+ sns_reg_write_conf_item( item_id, item_val, hw_conf, product_conf,
platform_conf, version_conf, soc_id_conf,
subtype_conf, subtype_id_conf, soc_rev_conf, &property_conf );
}
@@ -642,6 +672,8 @@
if( sscanf_result > 0 ) {
if( 0 == strncmp( key_meta, “hardware”, META_KEY_LEN ) ) {
sns_reg_get_conf_key(buf, hw_conf);
+ } else if( 0 == strncmp( key_meta, “product”, META_KEY_LEN ) ) {
+ sns_reg_get_conf_key(buf, product_conf);
} else if( 0 == strncmp( key_meta, “platform”, META_KEY_LEN ) ) {
sns_reg_get_conf_key(buf, platform_conf);
} else if( 0 == strncmp( key_meta, “soc_id”, META_KEY_LEN ) ) {
今天的文章Qcom adsp sensor分享到此就结束了,感谢您的阅读。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/6919.html