[DM/Input] Add ADC joystick, keyboard, and touchscreen drivers - #11679
[DM/Input] Add ADC joystick, keyboard, and touchscreen drivers#11679GuEe-GUI wants to merge 2 commits into
Conversation
Add polling input drivers for ADC-connected joysticks and resistor- ladder keys. Parse Linux-compatible device-tree bindings, acquire ADC channels through the IIO framework, and report absolute-axis and key events. Add an SPI touchscreen driver for ADS7843, ADS7845, ADS7846, ADS7873, TSC2046, and XPT2046-compatible controllers. Support pen interrupts, coordinate and pressure reporting, sample filtering, regulator control, power management, and common touchscreen properties. Add an I2C touchscreen driver for Goodix GT9xx controllers with multi-touch reporting, GPIO-based reset and address selection, interrupt handling with polling fallback, regulator control, panel configuration, and alternate-address recovery. Adapt the drivers to the RT-Thread device model and input framework, following the corresponding Linux input drivers and device-tree bindings. Signed-off-by: GuEe-GUI <2991707448@qq.com>
📌 Code Review Assignment🏷️ Tag: componentsReviewers: @Maihuanyi Changed Files (Click to expand)
📊 Current Review Status (Last Updated: 2026-08-07 00:16 CST)
📝 Review Instructions
|
|
👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread! 为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。 🛠 操作步骤 | Steps
完成后,提交将自动更新至 如有问题欢迎联系我们,再次感谢您的贡献!💐 |
|
There was a problem hiding this comment.
Pull request overview
This PR adds several new Device Model (DM) input drivers to RT-Thread, targeting Linux-compatible device-tree bindings and integrating with RT-Thread’s input/touch frameworks.
Changes:
- Add a Goodix GT9xx-series I2C capacitive touchscreen driver with multi-touch reporting.
- Add an ADS784x/XPT2046/TSC2046 SPI resistive touchscreen driver with filtering, pen IRQ handling, and optional PM hooks.
- Add polling input drivers for ADC ladder keys and ADC joysticks, plus corresponding Kconfig/SConscript integration.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| components/drivers/input/touchscreen/ts-goodix.c | New Goodix GT9xx I2C touchscreen driver implementation |
| components/drivers/input/touchscreen/ts-ads7846.c | New ADS784x/XPT2046/TSC2046 SPI touchscreen driver implementation |
| components/drivers/input/touchscreen/SConscript | Build integration for new touchscreen drivers |
| components/drivers/input/touchscreen/Kconfig | Kconfig options for new touchscreen drivers |
| components/drivers/input/keyboard/SConscript | Build integration for ADC keyboard driver |
| components/drivers/input/keyboard/keys-adc.c | New ADC ladder-button (resistor ladder) keyboard driver |
| components/drivers/input/keyboard/Kconfig | Kconfig option for ADC keyboard driver |
| components/drivers/input/joystick/SConscript | Build integration for ADC joystick driver |
| components/drivers/input/joystick/Kconfig | Kconfig option for ADC joystick driver |
| components/drivers/input/joystick/js-adc.c | New ADC joystick driver |
Suppressed comments (4)
components/drivers/input/touchscreen/ts-ads7846.c:403
- [bug/缺陷]: Wrong success/failure handling for rt_spi_transfer_message()
English: rt_spi_transfer_message() returns RT_NULL on success and a non-NULL pointer on failure (dev_spi.h). The current code converts that to 0/1 and returns 1 on failure, which can be misinterpreted as a valid sample. Return a negative error on failure.
中文:rt_spi_transfer_message() 成功返回 RT_NULL,失败返回非空指针(见 dev_spi.h)。当前代码将其转换为 0/1,失败时返回 1,可能被误认为是有效采样值。应在失败时返回负错误码。
status = rt_spi_transfer_message(ts->spi, &req.msg[0]) != RT_NULL;
components/drivers/input/touchscreen/ts-ads7846.c:442
- [bug/缺陷]: Wrong success/failure handling for rt_spi_transfer_message() (main sample transfer)
English: Same issue as above: the transfer result is converted to 0/1 instead of 0/negative errno. On failure, return -RT_EIO so callers don’t treat it as a small ADC value.
中文:同上问题:SPI 传输结果被转换成 0/1,而不是 0/负错误码。失败时应返回 -RT_EIO,避免被当作较小的 ADC 采样值。
status = rt_spi_transfer_message(ts->spi, &req.msg[0]) != RT_NULL;
components/drivers/input/touchscreen/ts-ads7846.c:469
- [bug/缺陷]: Wrong success/failure handling for rt_spi_transfer_message() in ads7845_read12_ser()
English: ads7845_read12_ser() returns 1 on SPI failure due to != RT_NULL. Return a negative error instead.
中文:ads7845_read12_ser() 由于使用 != RT_NULL,在 SPI 失败时会返回 1。建议改为返回负错误码。
status = rt_spi_transfer_message(ts->spi, &req.msg[0]) != RT_NULL;
components/drivers/input/touchscreen/Kconfig:16
- [bug/缺陷]: Missing Kconfig dependencies for Goodix touchscreen driver
English: ts-goodix.c uses OFW/PIN helpers and regulator types/APIs. Add depends on RT_USING_OFW, RT_USING_PIN, and RT_USING_REGULATOR to avoid build break when those components are off.
中文:ts-goodix.c 使用了 OFW/PIN 辅助接口以及 regulator 相关类型/接口。建议增加 depends on RT_USING_OFW、RT_USING_PIN、RT_USING_REGULATOR,避免在这些组件未开启时编译失败。
config RT_INPUT_TOUCHSCREEN_GOODIX
bool "Goodix GT9xx capacitive touch screen support"
depends on RT_INPUT_TOUCHSCREEN
depends on RT_USING_I2C
default n
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| int *touch_num_out) | ||
| { | ||
| rt_uint16_t addr = GOODIX_READ_COOR_ADDR; | ||
| rt_size_t header_size = 1 + ts->contact_size + 1; |
|
|
||
| packet->last_cmd_idx = 0; | ||
|
|
||
| while (true) |
| rt_inline void ads7846_disable(struct ads7846 *ts) | ||
| { | ||
| ads7846_stop(ts); | ||
| rt_regulator_disable(ts->supply); | ||
| } | ||
|
|
||
| rt_inline void ads7846_enable(struct ads7846 *ts) | ||
| { | ||
| if (rt_regulator_enable(ts->supply)) | ||
| { | ||
| LOG_E("%s: Failed to enable supply", rt_dm_dev_get_name(&ts->spi->parent)); | ||
| } | ||
|
|
||
| ads7846_restart(ts); | ||
| } |
| if ((err = rt_regulator_enable(ts->supply))) | ||
| { | ||
| goto _free_regulator; | ||
| } |
| config RT_INPUT_TOUCHSCREEN_ADS7846 | ||
| bool "TI ADS7843/45/46/73 XPT/TSC2046 touch screen support" | ||
| depends on RT_INPUT_TOUCHSCREEN | ||
| depends on RT_USING_SPI | ||
| default n |
| config RT_INPUT_JOYSTICK_ADC | ||
| bool "Simple joystick connected over ADC" | ||
| depends on RT_INPUT_JOYSTICK | ||
| depends on RT_USING_ADC | ||
| default n |
| LOG_E("%s: Key with invalid or missing %s", | ||
| rt_ofw_node_full_name(key_np), "voltage"); |
拉取/合并请求描述:(PR description)
[
Add polling input drivers for ADC-connected joysticks and resistor- ladder keys. Parse Linux-compatible device-tree bindings, acquire ADC channels through the IIO framework, and report absolute-axis and key events.
Add an SPI touchscreen driver for ADS7843, ADS7845, ADS7846, ADS7873, TSC2046, and XPT2046-compatible controllers. Support pen interrupts, coordinate and pressure reporting, sample filtering, regulator control, power management, and common touchscreen properties.
Add an I2C touchscreen driver for Goodix GT9xx controllers with multi-touch reporting, GPIO-based reset and address selection, interrupt handling with polling fallback, regulator control, panel configuration, and alternate-address recovery.
Adapt the drivers to the RT-Thread device model and input framework, following the corresponding Linux input drivers and device-tree bindings.
]
当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up