Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7776d50b authored by Oliver Wang's avatar Oliver Wang
Browse files

input: sensors: add wake up interface for low power sensor



Add enable_wakeup interface in sensors calss to provide an interface
for user space applications to control the wake up flag. The wake up
flag indicates if the driver works on wake up mode, which means it
can wake up the processor even it is in suspend mode.

Change-Id: I8edf145a190093a4c5384fd948b067b788b1fb1a
Signed-off-by: default avatarOliver Wang <mengmeng@codeaurora.org>
parent 0b5fe757
Loading
Loading
Loading
Loading
+36 −0
Original line number Diff line number Diff line
@@ -349,6 +349,40 @@ static ssize_t sensors_flush_show(struct device *dev,
				? "not exist" : "exist");
}

static ssize_t sensors_enable_wakeup_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t size)
{
	struct sensors_classdev *sensors_cdev = dev_get_drvdata(dev);
	ssize_t ret;
	unsigned long enable;

	if (sensors_cdev->sensors_enable_wakeup == NULL) {
		dev_err(dev, "Invalid sensor class enable_wakeup handle\n");
		return -EINVAL;
	}

	ret = kstrtoul(buf, 10, &enable);
	if (ret)
		return ret;

	enable = enable ? 1 : 0;
	ret = sensors_cdev->sensors_enable_wakeup(sensors_cdev, enable);
	if (ret)
		return ret;

	sensors_cdev->wakeup = enable;

	return size;
}

static ssize_t sensors_enable_wakeup_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{
	struct sensors_classdev *sensors_cdev = dev_get_drvdata(dev);
	return snprintf(buf, PAGE_SIZE, "%d\n", sensors_cdev->wakeup);
}


static ssize_t sensors_calibrate_show(struct device *dev,
		struct device_attribute *atte, char *buf)
{
@@ -426,6 +460,8 @@ static struct device_attribute sensors_class_attrs[] = {
	__ATTR(self_test, 0440, sensors_test_show, NULL),
	__ATTR(batch, 0660, sensors_batch_show, sensors_batch_store),
	__ATTR(flush, 0660, sensors_flush_show, sensors_flush_store),
	__ATTR(enable_wakeup, 0660, sensors_enable_wakeup_show,
			sensors_enable_wakeup_store),
	__ATTR(calibrate, 0664, sensors_calibrate_show,
			sensors_calibrate_store),
	__ATTR_NULL,
+4 −0
Original line number Diff line number Diff line
@@ -109,6 +109,7 @@ struct cal_result_t {
 * @enabled:		Store the sensor driver enable status.
 * @delay_msec:		Store the sensor driver delay value. The data unit is
 *			millisecond.
 * @wakeup:		Indicate if the wake up interrupt has been enabled
 * @sensors_enable:	The handle for enable and disable sensor.
 * @sensors_poll_delay:	The handle for set the sensor polling delay time.
 * @params		The sensor calibrate string format params up to userspace.
@@ -133,6 +134,7 @@ struct sensors_classdev {
	unsigned int		batch_mode;
	unsigned int		delay_msec;
	unsigned int		batch_timeout_ms;
	unsigned int		wakeup;
	char			*params;
	struct cal_result_t	cal_result;
	/* enable and disable the sensor handle*/
@@ -147,6 +149,8 @@ struct sensors_classdev {
					unsigned int period_ms,
					unsigned int timeout_ms);
	int	(*sensors_flush)(struct sensors_classdev *sensors_cdev);
	int	(*sensors_enable_wakeup)(struct sensors_classdev *sensors_cdev,
			unsigned int enable);
	int	(*sensors_calibrate)(struct sensors_classdev *sensor_cdev,
					int axis, int apply_now);
	int	(*sensors_write_cal_params)(struct sensors_classdev