Linux Input/HID development
 help / color / mirror / Atom feed
From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
To: Fenglin Wu <fenglin.wu@oss.qualcomm.com>,
	linux-arm-msm@vger.kernel.org,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>, Lee Jones <lee@kernel.org>,
	Stephen Boyd <sboyd@kernel.org>,
	Bjorn Andersson <andersson@kernel.org>,
	Konrad Dybcio <konradybcio@kernel.org>
Cc: David Collins <david.collins@oss.qualcomm.com>,
	Subbaraman Narayanamurthy
	<subbaraman.narayanamurthy@oss.qualcomm.com>,
	Kamal Wadhwa <kamal.wadhwa@oss.qualcomm.com>,
	kernel@oss.qualcomm.com, linux-input@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/4] input: misc: Add Qualcomm SPMI PMIC haptics driver
Date: Thu, 25 Jun 2026 10:25:32 +0200	[thread overview]
Message-ID: <7d8064bc-4dfa-4990-ae36-d68cbc9cdc9a@oss.qualcomm.com> (raw)
In-Reply-To: <82253653-bd85-45b8-8520-e2bb213ca48f@oss.qualcomm.com>

On 6/17/26 12:12 PM, Fenglin Wu wrote:
> 
> On 6/17/2026 5:30 PM, Konrad Dybcio wrote:
>> On 6/17/26 4:31 AM, Fenglin Wu wrote:
>>>>> +        ret = ptn_bulk_write(h, HAP_PTN_FIFO_DIN_0_REG, &data[i], 4);
>>>>> +        if (ret)
>>>>> +            return ret;
>>>>> +    }
>>>>> +
>>>>> +    for (; i < len; i++) {
>>>>> +        ret = ptn_write(h, HAP_PTN_FIFO_DIN_1B_REG, (u8)data[i]);
>>>>> +        if (ret)
>>>>> +            return ret;
>>>>> +    }
>>>> So if i'm reading this right, the first loop will always write
>>>> 4*(len//4) bytes and the second one will be entered at most once,
>>>> to write len rem 4 bytes.. should this be an if instead?
>>> I should put a comment for clarification. Here’s some background: FIFO data writing supports both 4-byte bulk writes using registers [HAP_PTN_FIFO_DIN_0_REG ... HAP_PTN_FIFO_DIN_3_REG], and 1-byte writes using the HAP_PTN_FIFO_DIN_1B_REG register. The 4-byte bulk write is more efficient, especially for waveform which has several Kb data, and it helps to reduce software latency when loading effects and reduce the delay in triggering vibration. It also helps prevent the FIFO from running dry during data refill in FIFO-empty interrupts. Typically, we use 4-byte writes for the initial 4-byte aligned data, and 1-byte writes for any trailing remainder.
>>>
>>> So it still needs a 'for' loop here since the remainder could be more than 1 byte.
>> Right, I mentioned len rem 4 but failed to notice it's a
>> single-byte write.. anyway, a comment here would be good
>>
>>>>> +
>>>>> +    return 0;
>>>>> +}
>>>>> +
>>>>> +/*
>>>>> + * Configure the hardware FIFO memory boundary.
>>>>> + * FIFO occupies addresses [0, fifo_len).
>>>>> + */
>>>>> +static int haptics_configure_fifo_mmap(struct qcom_haptics *h)
>>>>> +{
>>>>> +    u32 fifo_len, fifo_units;
>>>>> +
>>>>> +    /* Config all memory space for FIFO usage for now */
>>>> What's the not-"for now" endgame for this?
>>> The hardware supports more modes than the two currently supported in the driver. One of these, called 'PAT_MEM' mode, also shares memory space with FIFO mode. However, 'PAT_MEM' requires memory to be pre-reserved and waveform data to be pre-loaded. The entire 8K bytes of memory can be divided into partitions, and it is configurable, with FIFO mode always using the first partition [0, fifo_len], where 'fifo_len' is set via the 'MMAP_FIFO_REG' register. 'PAT_MEM' mode plays waveform using data preloaded in a memory bank defined by the registers 'PATX_MEM_START_ADDR_REG' and 'PATTERN_SPMI_PATX_LEN_REG' (they are not defined in the driver). Since PAT_MEM is mainly intended for hardware-triggered vibrations, such as a signal from a dedicated GPIO triggering a short vibration with a preloaded waveform, and although it also supports software triggers, I haven't found a suitable way to support it well into the driver under input FF framework yet. So, I am currently allocating the
>>> entire 8K FIFO memory for FIFO mode only. We can adjust this later if we find a better way to incorporate 'PAT_MEM' mode into the driver.
>> Sounds like a plan.
>>
>> For the other mode, would that GPIO trigger need any OS intervention?
>> Could you speak a bit more about how that works?
>>
>> Konrad
> 
> I'll try to clarify the 'PAT_MEM' mode further. 'PAT_MEM' is useful for latency-sensitive vibrations because it preloads the waveform into a fixed memory bank, then it doesn't need to load the data of the effect in the HW before triggering the play. When playback is triggered, it plays the waveform from the specified memory address and length. This memory should be preserved, and the data is preloaded during boot. Unlike FIFO mode, it doesn't allow data refilling. The trigger can come from hardware via dedicated GPIOs—currently, three are supported, each mapping to a memory bank set through specific registers. Software configuration can be done in the bootloader or in the driver probe, but the 'fifo_len' should be adjusted accordingly. After setup, software doesn't need to manage it further, relying on the GPIO signal to activate the playback (for example, a pressure sensor triggering vibration to simulate a physical key press). The trigger can also come from software using
> SPMI commands by setting the play mode, start address, and data length. I previously tried using the 'FF_HAPTIC' effect by mapping 'hid_usage' to a predefined effect in the devicetree, but later I found it unsuitable since 'FF_HAPTIC' is mainly for USB HID touch devices and not general vibration usage. If you have any suggestions for supporting 'PAT_MEM' mode through the input FF framework, please let me know.

I don't really know much about this part of the kernel, but at a glance
FF_HAPTIC seems to be roughly what we're after - quoting the cover letter
of the series that introduced it:

<quote>
Haptic control
..............

The HID protocol described in HUTRR63[3] must be used.

The following waveforms should be supported:

| WAVEFORMNONE             | Implicit waveforms required by protocol           |
| WAVEFORMSTOP             |                                                   |
| ------------------------ | ------------------------------------------------- |
| WAVEFORMPRESS            | To be used to simulate button press. In device-   |
|                          | controlled mode, it will also be used to simulate |
|                          | button release.                                   |
| ------------------------ | ------------------------------------------------- |
| WAVEFORMRELEASE          | To be used to simulate button release.            |

All waveforms will have an associated duration; continuous waveforms will be
ignored by the kernel.
</quote>

(i.e. reword 'press' to 'trigger' and we're mostly there?)

I'd start prototyping in that area (maybe taking it out of drivers/hid/)
and see where it goes. However as I mentioned, this may as well be my
wishful thinking.

Konrad

  reply	other threads:[~2026-06-25  8:25 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-16 10:08 [PATCH 0/4] input: misc: Add an initial driver for haptics inside Qcom PMIH010x PMIC Fenglin Wu
2026-06-16 10:08 ` [PATCH 1/4] dt-bindings: input: Add binding for Qualcomm SPMI PMIC haptics Fenglin Wu
2026-06-16 10:11   ` Konrad Dybcio
2026-06-16 10:18   ` sashiko-bot
2026-06-17 10:35   ` Krzysztof Kozlowski
2026-06-17 11:02     ` Fenglin Wu
2026-06-19  4:18       ` Krzysztof Kozlowski
2026-06-22  2:28         ` Fenglin Wu
2026-06-22 12:43           ` Krzysztof Kozlowski
2026-06-16 10:08 ` [PATCH 2/4] dt-bindings: mfd: qcom,spmi-pmic: Document haptics device Fenglin Wu
2026-06-16 10:17   ` sashiko-bot
2026-06-16 10:08 ` [PATCH 3/4] input: misc: Add Qualcomm SPMI PMIC haptics driver Fenglin Wu
2026-06-16 10:23   ` sashiko-bot
2026-06-16 10:25   ` Konrad Dybcio
2026-06-16 19:22     ` Dmitry Torokhov
2026-06-17  2:31     ` Fenglin Wu
2026-06-17  9:30       ` Konrad Dybcio
2026-06-17 10:12         ` Fenglin Wu
2026-06-25  8:25           ` Konrad Dybcio [this message]
2026-06-16 14:37   ` Julian Braha
2026-06-16 10:08 ` [PATCH 4/4] arm64: dts: qcom: Add PMIH0108 haptics device node Fenglin Wu
2026-06-16 10:27   ` Konrad Dybcio
2026-06-17  1:30     ` Fenglin Wu
2026-06-17 10:42 ` [PATCH 0/4] input: misc: Add an initial driver for haptics inside Qcom PMIH010x PMIC Krzysztof Kozlowski
2026-06-24  7:20   ` Fenglin Wu
2026-06-24 10:05     ` Krzysztof Kozlowski
2026-06-25  1:41       ` Fenglin Wu
2026-06-25  6:19         ` Krzysztof Kozlowski
2026-06-25  7:09           ` Fenglin Wu
2026-06-25  7:22             ` Krzysztof Kozlowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7d8064bc-4dfa-4990-ae36-d68cbc9cdc9a@oss.qualcomm.com \
    --to=konrad.dybcio@oss.qualcomm.com \
    --cc=andersson@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=david.collins@oss.qualcomm.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=fenglin.wu@oss.qualcomm.com \
    --cc=kamal.wadhwa@oss.qualcomm.com \
    --cc=kernel@oss.qualcomm.com \
    --cc=konradybcio@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=subbaraman.narayanamurthy@oss.qualcomm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox