feature: sensor: add force sensor

A sensor of this type measures the force on it, and additionally
compares the force with one or more specified thresholds. The sensor
can output the force value directly. Moreover, it's usually applied
as a press key. In that case, when it detects a force greater than
some given threshold, a corresponding event is reported.

Signed-off-by: jinxudong <jinxudong@xiaomi.com>
This commit is contained in:
jinxudong 2023-02-27 14:23:46 +08:00 committed by Xiang Xiao
parent ce9f40aeb6
commit 571f52c9d3
2 changed files with 20 additions and 2 deletions

View File

@ -157,7 +157,8 @@ static const struct sensor_info_s g_sensor_info[] =
{sizeof(struct sensor_gps_satellite), "gps_satellite"},
{sizeof(struct sensor_wake_gesture), "wake_gesture"},
{sizeof(struct sensor_cap), "cap"},
{sizeof(struct sensor_gas), "gas"}
{sizeof(struct sensor_gas), "gas"},
{sizeof(struct sensor_force), "force"},
};
static const struct file_operations g_sensor_fops =

View File

@ -297,9 +297,19 @@
#define SENSOR_TYPE_GAS 33
/* Force
* A sensor of this type measures the force on it, and additionally
* compares the force with one or more specified thresholds. The sensor
* can output the force value directly. Moreover, it's usually applied
* as a press key. In that case, when it detects a force greater than
* some given threshold, a corresponding event is reported.
*/
#define SENSOR_TYPE_FORCE 34
/* The total number of sensor */
#define SENSOR_TYPE_COUNT 34
#define SENSOR_TYPE_COUNT 35
/* The additional sensor open flags */
@ -608,6 +618,13 @@ struct sensor_gas /* Type: Gas */
float gas_resistance; /* Gas resistance in kOhm */
};
struct sensor_force /* Type: Force */
{
uint64_t timestamp; /* Unit is microseconds */
float force; /* Force value, units is N */
int32_t event; /* Force event */
};
/* The sensor lower half driver interface */
struct sensor_lowerhalf_s;