概述
1、高通配置文件sensor_def_qcomdev.conf研究(主要参考高通官方文档)
During bootup, the sns.reg registry file (in /persist/sensors) is generated by the
sensors daemon using sensor_def_*.conf (located in /etc/sensors)
After the sns.reg is generated, during any further reboots, it is not updated until
the .conf file is updated with some changes with the updated version number
< base index > + 0 | UUID_HIGH | High 8 bytes of the UUID mapping to DD | Unique ID (can be generated using utility like uuidgen in Linux) |
< base index > + 1 | UUID_LOW | Low 8 bytes of the UUID mapping to DD | |
< base index > + 2 | OFF_TO_IDLE | Off to idle time (configurable delay time for SMGR in microseconds) | Defined by sensor part spec (from vendor datasheet) |
< base index > + 3 | IDLE_TO_READY | Idle to ready time (configurable delay time for SMGR in microseconds) | Defined by sensor part spec (from vendor datasheet) |
< base index > + 4 | I2C_BUS | I2C bus | Customer hardware – BLSP bus number to which sensor is connected, e.g., BLSP 1-12 on MSM8994 |
< base index > + 5 | REG_GROUP_ID | Registry items associated with this driver | Defined by SSC framework (keep same as default sensor_def_qcomdev.conf for each sensor type) |
< base index > + 6 | CAL_PRI_GROUP_ID | Registry calibration for this driver | |
< base index > + 7 | GPIO1 | GPIO for device interrupt | MSM GPIO number to which sensor interrupt is connected |
< base index > + 8 | GPIO2 | GPIO for second device interrupt | |
< base index > + 9 | SENSOR_ID | SMGR ID associated with sensor type | Defined by SSC framework for each sensor type (SNS_SMGR_ID_*_V01 in sns_smgr_common_v01.h) |
< base index > + 10 | I2C_ADDRESS | I2C address of the device (7-bit) | Defined by sensor part spec (from vendor datasheet) |
< base index > + 11 | DATA_TYPE1 | Primary data type | Primary and secondary data types provided by vendor based on driver implementation in compliance with DDF |
< base index > + 12 | DATA_TYPE2 | Secondary data type | |
< base index > + 13 | RELATED_SENSOR_INDEX | Indicates related sensor; applicable to some device drivers | Vendor software implementation (-1 by default for no related sensor) |
< base index > + 14 | SENSITIVITY_DEFAULT | Sensitivity setting | Vendor software implementation |
< base index > + 15 | FLAGS | SMGR flags to indicate DRI vs. Polling mode and other SMGR functionality | Polling 0x00 DRI 0x80 FIFO 0xD0 – Required for sensors with FIFO |
1982 to 1986; 3682 to 3686 | DEVICE_SELECT | Device select is applicable to some device drivers when multiple sensors are supported by a single driver | Vendor software implementation (0 by default) |
(0)I2C/SPI bus
Use the following information for I2C/SPI bus configurations.
I2C - 0xY
SPI - 0x100Y (bit12 is 1 mean is SPI bus)
Where Y = BLSP#
Ex I2C - BLSP5 change to SPI - BLSP3:
1922 5 0x00010001 #i2c_bus
To
1922 0x1003 0x00010001 #spi_bus
(1)、sensor_id 配置
0 Accelerometer Temperature
10 Gyro Temperature
20 Magnetometer Temperature
30 Pressure Temperature
40 Proximity Ambient light
50 Humidity Temperature
60 RGB Color Temperature/Clear
70 SAR Specific Absorption Rate
80 HallEffect none
90 HeartRate Raw data(Optional)
100 Ultra-violet Ambient light
220 Step none
222 Step Count none
224 SMD none
226 GameRV none
228 IR Gesture Proximity
230 Double-tap Single-tap
240-249 OEM-defined OEM-defined
(2)reg_group_id
Group ID's required by Accel device drivers */
#define SNS_REG_DRIVER_GROUP_ACCEL_V02 1000
#define SNS_REG_DRIVER_GROUP_ACCEL_2_V02 1001
#define SNS_REG_DRIVER_GROUP_ACCEL_3_V02 1002
#define SNS_REG_DRIVER_GROUP_ACCEL_4_V02 1003
#define SNS_REG_DRIVER_GROUP_ACCEL_5_V02 1004
/** Group ID's required by Gyro device drivers */
#define SNS_REG_DRIVER_GROUP_GYRO_V02 1010
#define SNS_REG_DRIVER_GROUP_GYRO_2_V02 1011
#define SNS_REG_DRIVER_GROUP_GYRO_3_V02 1012
#define SNS_REG_DRIVER_GROUP_GYRO_4_V02 1013
#define SNS_REG_DRIVER_GROUP_GYRO_5_V02 1014
/** Group ID's required by Mag device drivers */
#define SNS_REG_DRIVER_GROUP_MAG_V02 1020
#define SNS_REG_DRIVER_GROUP_MAG_2_V02 1021
#define SNS_REG_DRIVER_GROUP_MAG_3_V02 1022
#define SNS_REG_DRIVER_GROUP_MAG_4_V02 1023
#define SNS_REG_DRIVER_GROUP_MAG_5_V02 1024
(3)
(1) Polling (0x00) 调用一次getI2C/SPI bus
Use the following information for I2C/SPI bus configurations.
I2C - 0xY
SPI - 0x100Y (bit12 is 1 mean is SPI bus)
Where Y = BLSP#
Ex I2C - BLSP5 change to SPI - BLSP3:
1922 5 0x00010001 #i2c_bus
To
1922 0x1003 0x00010001 #spi_bus_data后启动timer,等到timer到时间后调用sns_ddf_driver_if_s中指定的handle_timer()函数上报一组传感器数据
(2) DRI (0x80) 调用enable_sched_data()启用DRI(Data ReadyInterrupt,数据完成中断),按照set_cycle_time指定的ODR(Output Data Rate,数据I2C/SPI bus
Use the following information for I2C/SPI bus configurations.
I2C - 0xY
SPI - 0x100Y (bit12 is 1 mean is SPI bus)
Where Y = BLSP#
Ex I2C - BLSP5 change to SPII2C/SPI bus
Use the following information for I2C/SPI bus configurations.
I2C - 0xY
SPI - 0x100Y (bit12 is 1 mean is SPI bus)
Where Y = BLSP#
Ex I2C - BLSP5 change to SPI - BLSP3:
1922 5 0x00010001 #i2c_bus
To
1922 0x1003 0x00010001 #spi_bus - BLSP3:
1922 5 0x00010001 #i2c_bus
To
1922 0x1003 0x00010001 #spi_bus输出速率)进行数据采集,采集完成后调用sns_ddf_driver_if_s中指定的handle_irq()函数上报传感器数据。
(3) FIFO (0xD0) 调用trigger_fifo_data()函数启动FIFO模式,当数据量到达指定的阈值,触发sns_ddf_smgr_data_notify()函数上报一批数据。
一般加速度、陀螺仪等数据量较大的使用FIFO模式,光线、距离等有数据有变化才需要上报的传感器使用DRI模式
(4)Accel reg item ID – 700, 701, 702
Gyro reg item ID – 800, 801, 802
Mag reg item ID – 900, 901, 902
# Orientation of sensors(正常是 1 2 3 第二列应该是x和y轴交换)待验证?
# accel x/y/z
700 -2 0x00010001 #accel-x-axis // 此处表示y轴
701 1 0x00010001 #accel-y-axis
702 3 0x00010001 #accel-z-axis // z轴不变
sensor包括加速度,陀螺仪和地磁都需要坐标轴的转换,存在nv的那个位置呢,在sns_reg_api_v02.h这个文件中:
/** Item ID's corresponding to group SNS_REG_DRIVER_GROUP_ACCEL (Group Id: 1000) */
#define SNS_REG_DRIVER_ACCEL_X_ORIENT_V02 700
#define SNS_REG_DRIVER_ACCEL_Y_ORIENT_V02 701
#define SNS_REG_DRIVER_ACCEL_Z_ORIENT_V02 702
/** Item ID's corresponding to group SNS_REG_DRIVER_GROUP_GYRO (Group Id: 1010) */
#define SNS_REG_DRIVER_GYRO_X_ORIENT_V02 800
#define SNS_REG_DRIVER_GYRO_Y_ORIENT_V02 801
#define SNS_REG_DRIVER_GYRO_Z_ORIENT_V02 802
/** Item ID's corresponding to group SNS_REG_DRIVER_GROUP_MAG (Group Id: 1020) */
#define SNS_REG_DRIVER_MAG_X_ORIENT_V02 900
#define SNS_REG_DRIVER_MAG_Y_ORIENT_V02 901
#define SNS_REG_DRIVER_MAG_Z_ORIENT_V02 902
(5)修改I2C频率
#define SNS_DDF_DEFAULT_I2C_BUS_FREQ 400 // or 100
(6)
通常使用gpio1中断引脚,gpio2一般为0xFFFF.
(7) data_type1 和 data_type2
定义主要的数据类型和第二数据类型,比如:gyro and temperature, or proximity and light 定义位置:sns_ddf_sensor_e (sns_ddf_common.h)
typedef enum
{
SNS_DDF_SENSOR__NONE, // 0
SNS_DDF_SENSOR_ACCEL, // 1
SNS_DDF_SENSOR_MAG, // 2
SNS_DDF_SENSOR_GYRO, // 3
SNS_DDF_SENSOR_TEMP, // 4
SNS_DDF_SENSOR_PROXIMITY, // 5
SNS_DDF_SENSOR_AMBIENT, // 6
SNS_DDF_SENSOR_PRESSURE, // 7
SNS_DDF_SENSOR_MAG_6D, // 8
SNS_DDF_SENSOR_GYRO_6D, // 9
SNS_DDF_SENSOR_DOUBLETAP, // 10
SNS_DDF_SENSOR_SINGLETAP, // 11
SNS_DDF_SENSOR_IR_GESTURE, //12
.................................................
};
(8) 灵敏度缺省值
This selects the device range to use. The value is equal to the index of the desired range in the list
of supported ranges. A typical example of sensitivity_default values as used by an accelerometer
driver is shown in the following table.
sensitivity_default value Accelerometer
range
0 ±2
1 ±4
2 ±8
3 ±16
A typical example of sensitivity_default values as used by a gyro driver is shown in the following
table.sensitivity_default value Gyro range (dps)
0 ± 200
1 ± 500
2 ± 1000
3 ± 2000
The exact meaning of each range value varies depending on the sensor.
(9)Base registry indexes
Configuration ID Base registry index
0 1902
1 1918
2 1934
3 1950
4 1966
5 3602
6 3618
7 3634
8 3650
9 3666
10 5502
11 5518
(10)
:version A positive, nonzero version number for the file. It should be equal to the largest version number of any item.
:hardware
Items from the configuration file will only be used if the hardware string value is a substring of the /proc/cpuinfo string. It can be used more than once so that one file can support more than one hardware. If set to an empty string, it indicates common item values for all hardware.
:platform The string must match the text of either /sys/devices/soc0/hw_platform or /sys/device/soc0/platform_subtype, or can be an empty string to indicate common item values for all platforms.
:property Has two inputs, a system property key and a desired property value. Items will only be applied if the system property value matches the desired value. Can be set to an empty string to indicate common item values for all properties
(11)The UUID is stored in Little Endian format.
二、bring up ssc
1. Make sure that HAL is present. for 8992/8994 platform: /system/vendor/lib/hw/sensors.msm8994.so
for 8996/8998/SDM660/8952/8976/8917/8937/8953/8940 platform /system/lib64/hw/sensors.msm89xx.so /system/vendor/lib64/sensors.ssc.so
2. Make sure sensors daemon is present ps -x |grep sensors.qcom
3. Make sure the directory /persist/sensors/ is created and registry file sns.reg is present in /persist/ sensors/ ls /persist/sensors/sns.reg
4. check sensor enable flag "sensors_settings" should be 1: cat /persist/sensors/sensors_settings
5.These changes are in the init.qcom.sh file. /device/qcom/common/rootdir/etc/init.qcom.sensors.sh start_sensors() { if [ -c /dev/msm_dsps -o -c /dev/sensors ]; then chmod -h 775 /persist/sensors chmod -h 664 /persist/sensors/sensors_settings chown -h system.root /persist/sensors/sensors_settings mkdir -p /data/misc/sensors chmod -h 775 /data/misc/sensors start sensors fi } start_sensors /system/core/rootdir/etc/init.qcom.rc service sensors /system/bin/sensors.qcom class late_start user root group root disabled
6. check sensor registry configure:
sns_regedit_ssi -r
7. check which sensor init success:
sns_dsps_tc0001
8. read sensor data:
sns_cm_test
usage)
-r : rate
-d: duration in secound
-s: Sensor ID
-t data_type
eg to read light sensor data:
# sns_cm_test -r 10 -d 10 -s 40 -t 1
最后
以上就是甜美冷风为你收集整理的qcom sensor_def_qcomdev.conf 分析的全部内容,希望文章能够帮你解决qcom sensor_def_qcomdev.conf 分析所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复