Skip to content

Commit d7ae8ff

Browse files
committed
Merge branch 'for-6.1/rc-controllers' into for-linus
- Support for various RC controllers (Marcus Folkesson)
2 parents b0400ff + acc3e34 commit d7ae8ff

File tree

6 files changed

+237
-0
lines changed

6 files changed

+237
-0
lines changed

MAINTAINERS

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9053,6 +9053,12 @@ L: [email protected]
90539053
S: Supported
90549054
F: drivers/hid/hid-playstation.c
90559055

9056+
HID PHOENIX RC FLIGHT CONTROLLER
9057+
M: Marcus Folkesson <[email protected]>
9058+
9059+
S: Maintained
9060+
F: drivers/hid/hid-pxrc.c
9061+
90569062
HID SENSOR HUB DRIVERS
90579063
M: Jiri Kosina <[email protected]>
90589064
M: Jonathan Cameron <[email protected]>
@@ -9065,6 +9071,12 @@ F: drivers/hid/hid-sensor-*
90659071
F: drivers/iio/*/hid-*
90669072
F: include/linux/hid-sensor-*
90679073

9074+
HID VRC-2 CAR CONTROLLER DRIVER
9075+
M: Marcus Folkesson <[email protected]>
9076+
9077+
S: Maintained
9078+
F: drivers/hid/hid-vrc2.c
9079+
90689080
HID WACOM DRIVER
90699081
M: Ping Cheng <[email protected]>
90709082
M: Jason Gerecke <[email protected]>

drivers/hid/Kconfig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,16 @@ config HID_VIEWSONIC
454454
help
455455
Support for ViewSonic/Signotec PD1011 signature pad.
456456

457+
config HID_VRC2
458+
tristate "VRC-2 Car Controller"
459+
depends on HID
460+
help
461+
Support for VRC-2 which is a 2-axis controller often used in
462+
car simulators.
463+
464+
To compile this driver as a module, choose M here: the
465+
module will be called hid-vrc2.
466+
457467
config HID_XIAOMI
458468
tristate "Xiaomi"
459469
help
@@ -899,6 +909,15 @@ config PLAYSTATION_FF
899909
Say Y here if you would like to enable force feedback support for
900910
PlayStation game controllers.
901911

912+
config HID_PXRC
913+
tristate "PhoenixRC HID Flight Controller"
914+
depends on HID
915+
help
916+
Support for PhoenixRC HID Flight Controller, a 8-axis flight controller.
917+
918+
To compile this driver as a module, choose M here: the
919+
module will be called hid-pxrc.
920+
902921
config HID_RAZER
903922
tristate "Razer non-fully HID-compliant devices"
904923
help

drivers/hid/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ hid-picolcd-$(CONFIG_DEBUG_FS) += hid-picolcd_debugfs.o
101101
obj-$(CONFIG_HID_PLANTRONICS) += hid-plantronics.o
102102
obj-$(CONFIG_HID_PLAYSTATION) += hid-playstation.o
103103
obj-$(CONFIG_HID_PRIMAX) += hid-primax.o
104+
obj-$(CONFIG_HID_PXRC) += hid-pxrc.o
104105
obj-$(CONFIG_HID_RAZER) += hid-razer.o
105106
obj-$(CONFIG_HID_REDRAGON) += hid-redragon.o
106107
obj-$(CONFIG_HID_RETRODE) += hid-retrode.o
@@ -137,6 +138,7 @@ obj-$(CONFIG_HID_XINMO) += hid-xinmo.o
137138
obj-$(CONFIG_HID_ZEROPLUS) += hid-zpff.o
138139
obj-$(CONFIG_HID_ZYDACRON) += hid-zydacron.o
139140
obj-$(CONFIG_HID_VIEWSONIC) += hid-viewsonic.o
141+
obj-$(CONFIG_HID_VRC2) += hid-vrc2.o
140142

141143
wacom-objs := wacom_wac.o wacom_sys.o
142144
obj-$(CONFIG_HID_WACOM) += wacom.o

drivers/hid/hid-ids.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,6 +1389,7 @@
13891389

13901390
#define USB_VENDOR_ID_MULTIPLE_1781 0x1781
13911391
#define USB_DEVICE_ID_RAPHNET_4NES4SNES_OLD 0x0a9d
1392+
#define USB_DEVICE_ID_PHOENIXRC 0x0898
13921393

13931394
#define USB_VENDOR_ID_DRACAL_RAPHNET 0x289b
13941395
#define USB_DEVICE_ID_RAPHNET_2NES2SNES 0x0002

drivers/hid/hid-pxrc.c

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
/*
3+
* HID driver for PhoenixRC 8-axis flight controller
4+
*
5+
* Copyright (C) 2022 Marcus Folkesson <[email protected]>
6+
*/
7+
8+
#include <linux/device.h>
9+
#include <linux/hid.h>
10+
#include <linux/module.h>
11+
12+
#include "hid-ids.h"
13+
14+
struct pxrc_priv {
15+
u8 slider;
16+
u8 dial;
17+
bool alternate;
18+
};
19+
20+
static __u8 pxrc_rdesc_fixed[] = {
21+
0x05, 0x01, // Usage Page (Generic Desktop Ctrls)
22+
0x09, 0x04, // Usage (Joystick)
23+
0xA1, 0x01, // Collection (Application)
24+
0x09, 0x01, // Usage (Pointer)
25+
0xA1, 0x00, // Collection (Physical)
26+
0x09, 0x30, // Usage (X)
27+
0x09, 0x36, // Usage (Slider)
28+
0x09, 0x31, // Usage (Y)
29+
0x09, 0x32, // Usage (Z)
30+
0x09, 0x33, // Usage (Rx)
31+
0x09, 0x34, // Usage (Ry)
32+
0x09, 0x35, // Usage (Rz)
33+
0x09, 0x37, // Usage (Dial)
34+
0x15, 0x00, // Logical Minimum (0)
35+
0x26, 0xFF, 0x00, // Logical Maximum (255)
36+
0x35, 0x00, // Physical Minimum (0)
37+
0x46, 0xFF, 0x00, // Physical Maximum (255)
38+
0x75, 0x08, // Report Size (8)
39+
0x95, 0x08, // Report Count (8)
40+
0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
41+
0xC0, // End Collection
42+
0xC0, // End Collection
43+
};
44+
45+
static __u8 *pxrc_report_fixup(struct hid_device *hdev, __u8 *rdesc,
46+
unsigned int *rsize)
47+
{
48+
hid_info(hdev, "fixing up PXRC report descriptor\n");
49+
*rsize = sizeof(pxrc_rdesc_fixed);
50+
return pxrc_rdesc_fixed;
51+
}
52+
53+
static int pxrc_raw_event(struct hid_device *hdev, struct hid_report *report,
54+
u8 *data, int size)
55+
{
56+
struct pxrc_priv *priv = hid_get_drvdata(hdev);
57+
58+
if (priv->alternate)
59+
priv->slider = data[7];
60+
else
61+
priv->dial = data[7];
62+
63+
data[1] = priv->slider;
64+
data[7] = priv->dial;
65+
66+
priv->alternate = !priv->alternate;
67+
return 0;
68+
}
69+
70+
static int pxrc_probe(struct hid_device *hdev, const struct hid_device_id *id)
71+
{
72+
int ret;
73+
struct pxrc_priv *priv;
74+
75+
priv = devm_kzalloc(&hdev->dev, sizeof(*priv), GFP_KERNEL);
76+
if (!priv)
77+
return -ENOMEM;
78+
hid_set_drvdata(hdev, priv);
79+
80+
ret = hid_parse(hdev);
81+
if (ret) {
82+
hid_err(hdev, "parse failed\n");
83+
return ret;
84+
}
85+
86+
ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
87+
if (ret) {
88+
hid_err(hdev, "hw start failed\n");
89+
return ret;
90+
}
91+
92+
return 0;
93+
}
94+
95+
static const struct hid_device_id pxrc_devices[] = {
96+
{ HID_USB_DEVICE(USB_VENDOR_ID_MULTIPLE_1781, USB_DEVICE_ID_PHOENIXRC) },
97+
{ /* sentinel */ }
98+
};
99+
MODULE_DEVICE_TABLE(hid, pxrc_devices);
100+
101+
static struct hid_driver pxrc_driver = {
102+
.name = "hid-pxrc",
103+
.id_table = pxrc_devices,
104+
.report_fixup = pxrc_report_fixup,
105+
.probe = pxrc_probe,
106+
.raw_event = pxrc_raw_event,
107+
};
108+
module_hid_driver(pxrc_driver);
109+
110+
MODULE_AUTHOR("Marcus Folkesson <[email protected]>");
111+
MODULE_DESCRIPTION("HID driver for PXRC 8-axis flight controller");
112+
MODULE_LICENSE("GPL");

drivers/hid/hid-vrc2.c

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
/*
3+
* HID driver for VRC-2 2-axis Car controller
4+
*
5+
* Copyright (C) 2022 Marcus Folkesson <[email protected]>
6+
*/
7+
8+
#include <linux/device.h>
9+
#include <linux/hid.h>
10+
#include <linux/module.h>
11+
12+
/*
13+
* VID/PID are probably "borrowed", so keep them locally and
14+
* do not populate hid-ids.h with those.
15+
*/
16+
#define USB_VENDOR_ID_VRC2 (0x07c0)
17+
#define USB_DEVICE_ID_VRC2 (0x1125)
18+
19+
static __u8 vrc2_rdesc_fixed[] = {
20+
0x05, 0x01, // Usage Page (Generic Desktop Ctrls)
21+
0x09, 0x04, // Usage (Joystick)
22+
0xA1, 0x01, // Collection (Application)
23+
0x09, 0x01, // Usage (Pointer)
24+
0xA1, 0x00, // Collection (Physical)
25+
0x09, 0x30, // Usage (X)
26+
0x09, 0x31, // Usage (Y)
27+
0x15, 0x00, // Logical Minimum (0)
28+
0x26, 0xFF, 0x07, // Logical Maximum (2047)
29+
0x35, 0x00, // Physical Minimum (0)
30+
0x46, 0xFF, 0x00, // Physical Maximum (255)
31+
0x75, 0x10, // Report Size (16)
32+
0x95, 0x02, // Report Count (2)
33+
0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
34+
0xC0, // End Collection
35+
0x75, 0x08, // Report Size (8)
36+
0x95, 0x03, // Report Count (3)
37+
0x81, 0x03, // Input (Cnst,Var,Abs)
38+
0xC0, // End Collection
39+
};
40+
41+
static __u8 *vrc2_report_fixup(struct hid_device *hdev, __u8 *rdesc,
42+
unsigned int *rsize)
43+
{
44+
hid_info(hdev, "fixing up VRC-2 report descriptor\n");
45+
*rsize = sizeof(vrc2_rdesc_fixed);
46+
return vrc2_rdesc_fixed;
47+
}
48+
49+
static int vrc2_probe(struct hid_device *hdev, const struct hid_device_id *id)
50+
{
51+
int ret;
52+
53+
/*
54+
* The device gives us 2 separate USB endpoints.
55+
* One of those (the one with report descriptor size of 23) is just bogus so ignore it
56+
*/
57+
if (hdev->dev_rsize == 23)
58+
return -ENODEV;
59+
60+
ret = hid_parse(hdev);
61+
if (ret) {
62+
hid_err(hdev, "parse failed\n");
63+
return ret;
64+
}
65+
66+
ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
67+
if (ret) {
68+
hid_err(hdev, "hw start failed\n");
69+
return ret;
70+
}
71+
72+
return 0;
73+
}
74+
75+
static const struct hid_device_id vrc2_devices[] = {
76+
{ HID_USB_DEVICE(USB_VENDOR_ID_VRC2, USB_DEVICE_ID_VRC2) },
77+
{ /* sentinel */ }
78+
};
79+
MODULE_DEVICE_TABLE(hid, vrc2_devices);
80+
81+
static struct hid_driver vrc2_driver = {
82+
.name = "vrc2",
83+
.id_table = vrc2_devices,
84+
.report_fixup = vrc2_report_fixup,
85+
.probe = vrc2_probe,
86+
};
87+
module_hid_driver(vrc2_driver);
88+
89+
MODULE_AUTHOR("Marcus Folkesson <[email protected]>");
90+
MODULE_DESCRIPTION("HID driver for VRC-2 2-axis Car controller");
91+
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)