Skip to contentSkip to conversation

input: pxrc: new driver for PhoenixRC Flight Controller Adapter

PATCH Superseded Marcus Folkesson 2 participants 4 messages Jan 17, 2018

Subsystems (4)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Marcus Folkesson

author maintainer
#0 lore raw

PATCH v4 1/1 input: pxrc: new driver for PhoenixRC Flight Controller Adapter

This driver let you plug in your RC controller to the adapter and use it as input device in various RC simulators.

---

v4:
- Add call to usb_mark_last_busy() in irq
- Move code from pxrc_resume() to pxrc_reset_resume()
v3:
- Use RUDDER and MISC instead of TILT_X and TILT_Y
- Drop kref and anchor
- Rework URB handling
- Add PM support
v2:
- Change module license to GPLv2 to match SPDX tag

 Documentation/input/devices/pxrc.rst |  57 +++++++
 drivers/input/joystick/Kconfig       |   9 +
 drivers/input/joystick/Makefile      |   1 +
 drivers/input/joystick/pxrc.c        | 318 +++++++++++++++++++++++++++++++++++
 4 files changed, 385 insertions(+)
 create mode 100644 Documentation/input/devices/pxrc.rst
 create mode 100644 drivers/input/joystick/pxrc.c
Documentation/input/devices/pxrc.rst new file +57 -0
new file mode 100644
index 000000000000..ca11f646bae8
@@ -0,0 +1,57 @@
+=======================================================
+pxrc - PhoenixRC Flight Controller Adapter
+=======================================================
+
+:Author: Marcus Folkesson <[email protected]>
+
+This driver let you use your own RC controller plugged into the
+adapter that comes with PhoenixRC [1]_ or other compatible adapters.
+
+The adapter supports 7 analog channels and 1 digital input switch.
+
+Notes
+=====
+
+Many RC controllers is able to configure which stick goes to which channel.
+This is also configurable in most simulators, so a matching is not necessary.
+
+The driver is generating the following input event for analog channels:
+
++---------+----------------+
+| Channel |      Event     |
++=========+================+
+|     1   |  ABS_X         |
++---------+----------------+
+|     2   |  ABS_Y         |
++---------+----------------+
+|     3   |  ABS_RX        |
++---------+----------------+
+|     4   |  ABS_RY        |
++---------+----------------+
+|     5   |  ABS_RUDDER    |
++---------+----------------+
+|     6   |  ABS_THROTTLE  |
++---------+----------------+
+|     7   |  ABS_MISC      |
++---------+----------------+
+
+The digital input switch is generated as an `BTN_A` event.
+
+Manual Testing
+==============
+
+To test this driver's functionality you may use `input-event` which is part of
+the `input layer utilities` suite [2]_.
+
+For example::
+
+    > modprobe pxrc
+    > input-events <devnr>
+
+To print all input events from input `devnr`.
+
+References
+==========
+
+.. [1] http://www.phoenix-sim.com/
+.. [2] https://www.kraxel.org/cgit/input/
drivers/input/joystick/Kconfig +9 -0
index f3c2f6ea8b44..18ab6dafff41 100644
@@ -351,4 +351,13 @@ config JOYSTICK_PSXPAD_SPI_FF
 
 	  To drive rumble motor a dedicated power supply is required.
 
+config JOYSTICK_PXRC
+	tristate "PhoenixRC Flight Controller Adapter"
+	depends on USB_ARCH_HAS_HCD
+	select USB
+	help
+	  Say Y here if you want to use the PhoenixRC Flight Controller Adapter.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called pxrc.
 endif
drivers/input/joystick/Makefile +1 -0
index 67651efda2e1..dd0492ebbed7 100644
@@ -23,6 +23,7 @@ obj-$(CONFIG_JOYSTICK_JOYDUMP)		+= joydump.o
 obj-$(CONFIG_JOYSTICK_MAGELLAN)		+= magellan.o
 obj-$(CONFIG_JOYSTICK_MAPLE)		+= maplecontrol.o
 obj-$(CONFIG_JOYSTICK_PSXPAD_SPI)	+= psxpad-spi.o
+obj-$(CONFIG_JOYSTICK_PXRC)			+= pxrc.o
 obj-$(CONFIG_JOYSTICK_SIDEWINDER)	+= sidewinder.o
 obj-$(CONFIG_JOYSTICK_SPACEBALL)	+= spaceball.o
 obj-$(CONFIG_JOYSTICK_SPACEORB)		+= spaceorb.o
drivers/input/joystick/pxrc.c new file +318 -0

318 lines not on this page · raw message

Signature · 1 line
2.15.1
reviewer
#1 lore raw
Quoted 11 lines · Marcus Folkesson

This driver let you plug in your RC controller to the adapter and use it as input device in various RC simulators.

---

drivers/input/joystick/Kconfig +0 -0
index f3c2f6ea8b44..18ab6dafff41 100644

drivers/input/joystick/Kconfig config JOYSTICK_PSXPAD_SPI_FF · line 357

Quoted 7 lines
drivers/input/joystick/Kconfig +4 -0
@@ -351,4 +351,13 @@ config JOYSTICK_PSXPAD_SPI_FF
 
 	  To drive rumble motor a dedicated power supply is required.
 
+config JOYSTICK_PXRC
+	tristate "PhoenixRC Flight Controller Adapter"
+	depends on USB_ARCH_HAS_HCD
+	select USB

Drop the (first) depends and change "select USB" to "depends on USB".

Argh, there are lots of input/ drivers that do that. That's bad/wrong. A driver should not select (enable) an entire subsystem. If the user had the subsystem disabled, it should stay that way.

Dmitry, you can expect some patches...

Quoted 6 lines
drivers/input/joystick/Kconfig +5 -0
+	help
+	  Say Y here if you want to use the PhoenixRC Flight Controller Adapter.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called pxrc.
 endif
Signature · 1 line
~Randy
author maintainer
#2 lore raw

Hi Randy!

Quoted 22 lines · Randy Dunlap
Quoted 11 lines · Marcus Folkesson

This driver let you plug in your RC controller to the adapter and use it as input device in various RC simulators.

---

drivers/input/joystick/Kconfig +0 -0
index f3c2f6ea8b44..18ab6dafff41 100644

drivers/input/joystick/Kconfig config JOYSTICK_PSXPAD_SPI_FF · line 357

Quoted 7 lines
drivers/input/joystick/Kconfig +4 -0
@@ -351,4 +351,13 @@ config JOYSTICK_PSXPAD_SPI_FF
 
 	  To drive rumble motor a dedicated power supply is required.
 
+config JOYSTICK_PXRC
+	tristate "PhoenixRC Flight Controller Adapter"
+	depends on USB_ARCH_HAS_HCD
+	select USB

Drop the (first) depends and change "select USB" to "depends on USB".

Quoted 6 lines

Argh, there are lots of input/ drivers that do that. That's bad/wrong. A driver should not select (enable) an entire subsystem. If the user had the subsystem disabled, it should stay that way.

Dmitry, you can expect some patches...

Hah, of course it should be "depends on" :-)
Other drivers fooled me...

Should I fix the other drivers too when I'm on it, or do you?

Quoted 9 lines
Quoted 6 lines
drivers/input/joystick/Kconfig +5 -0
+	help
+	  Say Y here if you want to use the PhoenixRC Flight Controller Adapter.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called pxrc.
 endif
Signature · 1 line
~Randy

Best regards
Marcus Folkesson

reviewer
#3 lore raw
Quoted 29 lines · Marcus Folkesson

Hi Randy!

Quoted 26 lines · Randy Dunlap
Quoted 11 lines · Marcus Folkesson

This driver let you plug in your RC controller to the adapter and use it as input device in various RC simulators.

---

drivers/input/joystick/Kconfig +0 -0
index f3c2f6ea8b44..18ab6dafff41 100644

drivers/input/joystick/Kconfig config JOYSTICK_PSXPAD_SPI_FF · line 357

Quoted 7 lines
drivers/input/joystick/Kconfig +4 -0
@@ -351,4 +351,13 @@ config JOYSTICK_PSXPAD_SPI_FF
 
 	  To drive rumble motor a dedicated power supply is required.
 
+config JOYSTICK_PXRC
+	tristate "PhoenixRC Flight Controller Adapter"
+	depends on USB_ARCH_HAS_HCD
+	select USB

Drop the (first) depends and change "select USB" to "depends on USB".

Argh, there are lots of input/ drivers that do that. That's bad/wrong. A driver should not select (enable) an entire subsystem. If the user had the subsystem disabled, it should stay that way.

Quoted 7 lines
Quoted 2 lines

Dmitry, you can expect some patches...

Hah, of course it should be "depends on" :-)
Other drivers fooled me...

Should I fix the other drivers too when I'm on it, or do you?

Either way. If you are up for it, please go ahead.

thanks,

Signature · 1 line
~Randy