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

Commit e3f000e4 authored by Fenglin Wu's avatar Fenglin Wu Committed by Gerrit - the friendly Code Review server
Browse files

input: qti-haptics: Add VMAX per effect setting



Currently, property "qcom,vmax-mv" is defined as the maximum output of
the haptics module to meet the requirement of the Vrms of the motor to
prevent it from damage. However, if the playing duration is short, it's
safe to overdrive the motor for an intense effect. Add "qcom,wf-vmax-mv"
per effect configuration to achieve this.

Change-Id: I96a48356bb9959cacf5e15cf614d89c774615312
Signed-off-by: default avatarFenglin Wu <fenglinw@codeaurora.org>
parent d1a72368
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -130,6 +130,15 @@ waveforms/effects:
		 [5:1]: waveform amplitude
		 [0]: reserved.

- qcom,wf-vmax-mv
  Usage:      optional
  Value type: <u32>
  Definition: Specifies the maximum allowed output voltage in millivolts
		for this effect. Value specified here will be rounded
		off to the closest multiple of 116 mV. Allowed values:
		0 to 3596. If this is not specified, the value defined in
		"qcom,vmax-mv" will be applied.

- qcom,wf-play-rate-us
  Usage:      optional
  Value type: <u32>
+14 −4
Original line number Diff line number Diff line
@@ -175,6 +175,7 @@ struct qti_hap_effect {
	u8			*pattern;
	int			pattern_length;
	u16			play_rate_us;
	u16			vmax_mv;
	u8			wf_repeat_n;
	u8			wf_s_repeat_n;
	u8			brake[HAP_BRAKE_PATTERN_MAX];
@@ -830,10 +831,6 @@ static int qti_haptics_upload_effect(struct input_dev *dev,
			goto disable_vdd;
		}

		level = effect->u.periodic.magnitude;
		tmp = level * config->vmax_mv;
		play->vmax_mv = tmp / 0x7fff;

		if (copy_from_user(data, effect->u.periodic.custom_data,
					sizeof(s16) * CUSTOM_DATA_LEN)) {
			rc = -EFAULT;
@@ -852,6 +849,10 @@ static int qti_haptics_upload_effect(struct input_dev *dev,
			goto disable_vdd;
		}

		level = effect->u.periodic.magnitude;
		tmp = level * chip->predefined[i].vmax_mv;
		play->vmax_mv = tmp / 0x7fff;

		dev_dbg(chip->dev, "upload effect %d, vmax_mv=%d\n",
				chip->predefined[i].id, play->vmax_mv);
		rc = qti_haptics_load_predefined_effect(chip, i);
@@ -1234,6 +1235,15 @@ static int qti_haptics_parse_dt(struct qti_hap_chip *chip)
			return rc;
		}

		effect->vmax_mv = config->vmax_mv;
		rc = of_property_read_u32(child_node, "qcom,wf-vmax-mv", &tmp);
		if (rc < 0)
			dev_dbg(chip->dev, "Read qcom,wf-vmax-mv failed, rc=%d\n",
					rc);
		else
			effect->vmax_mv = (tmp > HAP_VMAX_MV_MAX) ?
				HAP_VMAX_MV_MAX : tmp;

		rc = of_property_count_elems_of_size(child_node,
				"qcom,wf-pattern", sizeof(u8));
		if (rc < 0) {