qcom sensor_def_qcomdev.conf 分析

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 > + 0UUID_HIGHHigh 8 bytes of the UUID mapping to DDUnique ID (can be generated using utility like uuidgen in
Linux)
< base index > + 1UUID_LOWLow 8 bytes of the UUID mapping to DD
< base index > + 2OFF_TO_IDLEOff to idle time (configurable delay time for
SMGR in microseconds)
Defined by sensor part spec (from vendor datasheet)
< base index > + 3IDLE_TO_READYIdle to ready time (configurable delay time for
SMGR in microseconds)
Defined by sensor part spec (from vendor datasheet)
< base index > + 4I2C_BUSI2C busCustomer hardware – BLSP bus number to which sensor
is connected, e.g., BLSP 1-12 on MSM8994
< base index > + 5REG_GROUP_IDRegistry items associated with this driverDefined by SSC framework (keep same as default
sensor_def_qcomdev.conf for each sensor type)
< base index > + 6CAL_PRI_GROUP_IDRegistry calibration for this driver
< base index > + 7GPIO1GPIO for device interruptMSM GPIO number to which sensor interrupt is
connected
< base index > + 8GPIO2GPIO for second device interrupt
< base index > + 9SENSOR_IDSMGR ID associated with sensor typeDefined by SSC framework for each sensor type
(SNS_SMGR_ID_*_V01 in sns_smgr_common_v01.h)
< base index > + 10I2C_ADDRESSI2C address of the device (7-bit)Defined by sensor part spec (from vendor datasheet)
< base index > + 11DATA_TYPE1Primary data typePrimary and secondary data types provided by vendor
based on driver implementation in compliance with DDF
< base index > + 12DATA_TYPE2Secondary data type
< base index > + 13RELATED_SENSOR_INDEXIndicates related sensor; applicable to some
device drivers
Vendor software implementation (-1 by default for no
related sensor)
< base index > + 14SENSITIVITY_DEFAULTSensitivity settingVendor software implementation
< base index > + 15FLAGSSMGR 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_SELECTDevice 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

  • 0
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
这是一个启动参数列表,用于指定 Linux 操作系统的启动选项。其中包含了一些针对特定硬件或软件的优化设置,例如: - stack_depot_disable=on:禁用堆栈存储器。 - kasan.stacktrace=off:禁用 KASan 堆栈跟踪。 - kvm-arm.mode=protected/nvhe:设置 KVM ARM 的虚拟化模式。 - cgroup_disable=pressure:禁用 cgroup 内存压力控制。 - kpti=0:禁用内核页表隔离(KPTI)。 - ssbd=force-off:禁用 Spectre 漏洞的防护措施。 - lpm_levels.sleep_disabled=1:禁用低功耗模式。 - video=vfb:640x400,bpp=32,memsize=3072000:设置虚拟帧缓冲器的分辨率、颜色深度和内存大小。 - msm_rtb.filter=0x237:设置 MSM RTB 过滤器。 - service_locator.enable=1:启用服务定位器。 - swiotlb=4096:设置 I/O 内存管理器的缓冲区大小。 - firmware_class.path=/vendor/firmware_mnt/image:设置固件文件路径。 - loop.max_part=7:设置循环设备的最大分区数。 - hibernate=nocompress:设置休眠时不压缩内存数据。 - noswap_randomize:禁用交换空间的随机化地址。 - pcie_ports=compat:设置 PCIe 接口的兼容性模式。 - console=ttyMSM0,115200n8 earlycon=qcom_geni,0xa90000 qcom_geni_serial.con_enabled=1:设置控制台终端和串口的参数。 - slub_debug=FZPU:启用 SLUB 分配器的调试模式。 - bootconfig:指定使用 Bootconfig 工具进行启动配置。 - buildvariant=userdebug:设置构建变体为用户调试版。 - rootwait ro:等待根文件系统挂载完成,以只读模式启动。 - init=/init:指定 init 进程的路径。 - resume=/dev/sda13:设置恢复分区的设备路径。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值