joysticks are spamming interrupts and events

Post Reply
valadaa48
Posts: 288
Joined: Mon Feb 17, 2020 1:35 pm
languages_spoken: english
ODROIDs: odroid go advance
Has thanked: 40 times
Been thanked: 96 times
Contact:

joysticks are spamming interrupts and events

Post by valadaa48 »

Hello, I noticed the analog appears to be generating a lot of events. The problem with this is that we're getting extraneous callbacks in our applications.

I tried to fix it by updating the fuzz parameter but it didn't seem to have helped. Do you know of a way to fix this issue?

Code: Select all

device /dev/input/by-path/platform-odroidgo2-joypad-event-joystick, name "odroidgo2_joypad", phys "odroidgo2_joypad/input0" event at 1585511413.833020, code 00, type 03, val 04
device /dev/input/by-path/platform-odroidgo2-joypad-event-joystick, name "odroidgo2_joypad", phys "odroidgo2_joypad/input0" event at 1585511413.833020, code 01, type 03, val 03
device /dev/input/by-path/platform-odroidgo2-joypad-event-joystick, name "odroidgo2_joypad", phys "odroidgo2_joypad/input0" event at 1585511413.833020, code 00, type 00, val 00
device /dev/input/by-path/platform-odroidgo2-joypad-event-joystick, name "odroidgo2_joypad", phys "odroidgo2_joypad/input0" event at 1585511413.845180, code 01, type 03, val 01
device /dev/input/by-path/platform-odroidgo2-joypad-event-joystick, name "odroidgo2_joypad", phys "odroidgo2_joypad/input0" event at 1585511413.845180, code 00, type 00, val 00
device /dev/input/by-path/platform-odroidgo2-joypad-event-joystick, name "odroidgo2_joypad", phys "odroidgo2_joypad/input0" event at 1585511413.857103, code 00, type 03, val 02
device /dev/input/by-path/platform-odroidgo2-joypad-event-joystick, name "odroidgo2_joypad", phys "odroidgo2_joypad/input0" event at 1585511413.857103, code 00, type 00, val 00
device /dev/input/by-path/platform-odroidgo2-joypad-event-joystick, name "odroidgo2_joypad", phys "odroidgo2_joypad/input0" event at 1585511413.869145, code 00, type 03, val 05
device /dev/input/by-path/platform-odroidgo2-joypad-event-joystick, name "odroidgo2_joypad", phys "odroidgo2_joypad/input0" event at 1585511413.869145, code 01, type 03, val 03
device /dev/input/by-path/platform-odroidgo2-joypad-event-joystick, name "odroidgo2_joypad", phys "odroidgo2_joypad/input0" event at 1585511413.869145, code 00, type 00, val 00
device /dev/input/by-path/platform-odroidgo2-joypad-event-joystick, name "odroidgo2_joypad", phys "odroidgo2_joypad/input0" event at 1585511413.881431, code 00, type 03, val 00
device /dev/input/by-path/platform-odroidgo2-joypad-event-joystick, name "odroidgo2_joypad", phys "odroidgo2_joypad/input0" event at 1585511413.881431, code 00, type 00, val 00
device /dev/input/by-path/platform-odroidgo2-joypad-event-joystick, name "odroidgo2_joypad", phys "odroidgo2_joypad/input0" event at 1585511413.893238, code 00, type 03, val 02
device /dev/input/by-path/platform-odroidgo2-joypad-event-joystick, name "odroidgo2_joypad", phys "odroidgo2_joypad/input0" event at 1585511413.893238, code 00, type 00, val 00
device /dev/input/by-path/platform-odroidgo2-joypad-event-joystick, name "odroidgo2_joypad", phys "odroidgo2_joypad/input0" event at 1585511413.929176, code 00, type 03, val 04
device /dev/input/by-path/platform-odroidgo2-joypad-event-joystick, name "odroidgo2_joypad", phys "odroidgo2_joypad/input0" event at 1585511413.929176, code 01, type 03, val 00
Thanks

crashoverride
Posts: 5484
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 485 times
Contact:

Re: joysticks are spamming interrupts and events

Post by crashoverride »

valadaa48 wrote:
Mon Mar 30, 2020 4:44 am
I noticed the analog appears to be generating a lot of events.
This is normal for an analog control in my opinion. I have many XBOX 360 controllers that do the same thing.

You can experiment with different values for the polling interval:
viewtopic.php?f=196&t=38044#p284978

It is also recommended to process input on a separate thread as demonstrated in libgo2:
https://github.com/OtherCrashOverride/l ... #L140-L272

valadaa48
Posts: 288
Joined: Mon Feb 17, 2020 1:35 pm
languages_spoken: english
ODROIDs: odroid go advance
Has thanked: 40 times
Been thanked: 96 times
Contact:

Re: joysticks are spamming interrupts and events

Post by valadaa48 »

I believe js-cal and fuzz are supposed to help with this and my ds4 doesn't generate these events unless I have the orientation on (which I turn off). I looked through the kernel code and nothing local appears to be using the fuzz attribute unless it's supposed to be done at a more generic level in the kernel. Was hoping perhaps Joy or the HK team could comment on this implementation?

User avatar
odroid
Site Admin
Posts: 38355
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 2129 times
Been thanked: 1264 times
Contact:

Re: joysticks are spamming interrupts and events

Post by odroid »

What are you doing with the analog joystick inputs in your application?

valadaa48
Posts: 288
Joined: Mon Feb 17, 2020 1:35 pm
languages_spoken: english
ODROIDs: odroid go advance
Has thanked: 40 times
Been thanked: 96 times
Contact:

Re: joysticks are spamming interrupts and events

Post by valadaa48 »

I'm not interested in the analog joystick readings directly but I'm getting lots of callbacks on these small analog input changes which is causing listening threads to spike in cpu. I checked the code of the Linux driver and it does seem to be registering the fuzz factor. I was just curious if you might have run into this issue or know why these events aren't being filtered?

Even changing to 255 didn't seem to help:

[ 1.468221] odroidgo2_joypad odroidgo2-joypad: joypad_input_setup : ABS min = -550, max = 549, fuzz = 255, flat = 10
[ 1.468235] odroidgo2_joypad odroidgo2-joypad: joypad_input_setup : ABS min = -500, max = 499, fuzz = 255, flat = 10

User avatar
odroid
Site Admin
Posts: 38355
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 2129 times
Been thanked: 1264 times
Contact:

Re: joysticks are spamming interrupts and events

Post by odroid »

We don't know how the fuzz factor works with the input device driver.
Is it increasing/decreasing the sensitivity of the analog stick movements?
If you have a well-written documentation about it, we will read it.

valadaa48
Posts: 288
Joined: Mon Feb 17, 2020 1:35 pm
languages_spoken: english
ODROIDs: odroid go advance
Has thanked: 40 times
Been thanked: 96 times
Contact:

Re: joysticks are spamming interrupts and events

Post by valadaa48 »


User avatar
odroid
Site Admin
Posts: 38355
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 2129 times
Been thanked: 1264 times
Contact:

Re: joysticks are spamming interrupts and events

Post by odroid »

It is not understandable.
How to determine the amount of noise in the data from the analog stick?

Code: Select all

int fuzz;
If the gameport supports cooked mode, this should be set to a value that represents the amount of noise in the data

valadaa48
Posts: 288
Joined: Mon Feb 17, 2020 1:35 pm
languages_spoken: english
ODROIDs: odroid go advance
Has thanked: 40 times
Been thanked: 96 times
Contact:

Re: joysticks are spamming interrupts and events

Post by valadaa48 »

The issue is at a lower level than what app I'm building considering any app listening to the device is getting spammed. For reference, a simple rust app I wrote that merely listens for certain key combinations (I wrote it for F3+power to initiate shutdown) idles at 8-12% cpu usage due to the spam. It seems crash went the length of actually listening to the events on a separate thread (another workaround all things being equal).

I hacked a simple temporary fix in my kernel with the attached patch and I now confirm that the evdev bus is clean and analog still seems to perform well. Also the same rust app now uses 0% cpu. This should help with apps' jitter a bit and help mitigate the need of extra filtering and possibly the need to spin up another thread.

Perhaps if it's indeed confirmed the "fuzz" or "flat" parameters are not being processed, then they could be used here?

Thanks!

Code: Select all

diff --git a/drivers/input/joystick/odroidgo2-joypad.c b/drivers/input/joystick/odroidgo2-joypad.c
index c24c6f45daa4..43355f2595be 100644
--- a/drivers/input/joystick/odroidgo2-joypad.c
+++ b/drivers/input/joystick/odroidgo2-joypad.c
@@ -405,6 +405,11 @@ static void joypad_adc_check(struct input_polled_dev *poll_dev)
                value = value > adc->max ? adc->max : value;
                value = value < adc->min ? adc->min : value;
 
+        if (abs(value) < 20)
+        {
+            value = 0;
+        }
+
EDIT: You can add printk logs for value around that code to see the number of events being dispatched on minute ABS_X/Y values.

User avatar
odroid
Site Admin
Posts: 38355
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 2129 times
Been thanked: 1264 times
Contact:

Re: joysticks are spamming interrupts and events

Post by odroid »

I think we need to add another Kernel parameter to the joypad driver to adjust the threshold level of the joystick input.

BTW, what happens if you change the polling interval time to 50msec from 2msec?

Code: Select all

echo 50 >  /sys/devices/platform/odroidgo2-joypad/poll_interval

valadaa48
Posts: 288
Joined: Mon Feb 17, 2020 1:35 pm
languages_spoken: english
ODROIDs: odroid go advance
Has thanked: 40 times
Been thanked: 96 times
Contact:

Re: joysticks are spamming interrupts and events

Post by valadaa48 »

That only samples the spam at 50ms instead of 2ms.

Agreed if you perhaps add a readable and writable param via /sys that would be helpful. Also, being able to set it from boot.ini would help as well.

Let me know when you have a patch for me to test. I'll be keeping my local workaround in for the time being.

Thanks

crashoverride
Posts: 5484
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 485 times
Contact:

Re: joysticks are spamming interrupts and events

Post by crashoverride »

odroid wrote:
Mon Mar 30, 2020 2:29 pm
I think we need to add another Kernel parameter to the joypad driver to adjust the threshold level of the joystick input.
This is called a "deadzone". It is an area of reported values that are excluded:
https://www.quora.com/What-does-the-ter ... dzone-mean

[edit]
The issue is inherit to all analog controls. There are springs that return the thumbstick to center. While a "deadzone" can be established, it will need to increase with use of the thumbstick as the springs stretch and fatigue. For this reason, the technique used by libgo2 is preferred to adding a "deadzone" parameter. The libgo2 code uses evdev in "blocking" mode and sleeps until an event happens. When an event does occur it is trivially recorded rather than being actionable (deterministic code execution time). When a "sync" event occurs, the input data is atomically updated.
These users thanked the author crashoverride for the post:
odroid (Tue Mar 31, 2020 8:50 am)

valadaa48
Posts: 288
Joined: Mon Feb 17, 2020 1:35 pm
languages_spoken: english
ODROIDs: odroid go advance
Has thanked: 40 times
Been thanked: 96 times
Contact:

Re: joysticks are spamming interrupts and events

Post by valadaa48 »

While a "deadzone" can be established, it will need to increase with use of the thumbstick as the springs stretch and fatigue.
What do you mean by this?

EDIT: I re-read your statement and I do agree. A current threshold of 10 seems to do the trick for me at least. Given a range of ~1200 on the axes, I would be content with setting a threshold of 50 or 100 if needed. I don't think these particular analogs require such high resolution sensitivity (i.e, I don't think an axis reading of 50 is material). You can use jstest to see how precise you're able to navigate the analog.

EDIT2: Also of note is if some apps are sensitive to drift - setting an appropriate deadzone helps with this.

User avatar
odroid
Site Admin
Posts: 38355
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 2129 times
Been thanked: 1264 times
Contact:

Re: joysticks are spamming interrupts and events

Post by odroid »

We will try to implement the deadzone control feature in the joypad driver.
The default value will be +/- 15 and it can be adjustable via sysfs nodes.

Since the ADC resolution is 10bit, the actual full range is +/- 500 approximately.

valadaa48
Posts: 288
Joined: Mon Feb 17, 2020 1:35 pm
languages_spoken: english
ODROIDs: odroid go advance
Has thanked: 40 times
Been thanked: 96 times
Contact:

Re: joysticks are spamming interrupts and events

Post by valadaa48 »

Great! Thank you very much!

User avatar
odroid
Site Admin
Posts: 38355
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 2129 times
Been thanked: 1264 times
Contact:

Re: joysticks are spamming interrupts and events

Post by odroid »

The deadzone(flat-zone) and fuzz control features seem to be already implemented in our joypad driver.

flat: values that are within this value will be discarded by joydev interface and reported as 0 instead.
fuzz: specifies fuzz value that is used to filter noise from the event stream.

Edit boot.ini file like the following lines and let us know the result. Double check the last two parameters(button-adc-fuzz, button-adc-flat) in the Kernel argument string.

Code: Select all

setenv joystick_flat "20"
setenv joystick_fuzz "15"

# Boot Arguments
setenv bootargs "root=UUID='e139ce78-9841-40fe-8823-96a304a09859' rootwait rw fsck.repair=yes net.ifnames=0 fbcon=rotate:3 console=/dev/ttyFIQ0 quiet splash plymouth.ignore-serial-consoles consoleblank=0 button-adc-fuzz=${joystick_fuzz} button-adc-flat=${joystick_flat}"
We will find optimal flat/fuzz values after fixing a wrong X-Y axis analog input range bug.

User avatar
mad_ady
Posts: 9974
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 631 times
Been thanked: 780 times
Contact:

Re: joysticks are spamming interrupts and events

Post by mad_ady »

Great! I had noticed drift while playing doom with axis used for mouselook. If I didn't touch the controls the character would slowly start to drift...
Offtopic: Thanks are disabled for this thread/subforum...
These users thanked the author mad_ady for the post:
odroid (Wed Apr 01, 2020 5:46 pm)

User avatar
odroid
Site Admin
Posts: 38355
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 2129 times
Been thanked: 1264 times
Contact:

Re: joysticks are spamming interrupts and events

Post by odroid »

mad_ady wrote:
Wed Apr 01, 2020 5:42 pm
Offtopic: Thanks are disabled for this thread/subforum...
I could give you a "Thanks".
Isn't it working for you?

User avatar
mad_ady
Posts: 9974
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 631 times
Been thanked: 780 times
Contact:

Re: joysticks are spamming interrupts and events

Post by mad_ady »

Thanks for the thanks, but I don't see it in Talpatalk. Must be some talpatalk specific setting...

hominoid
Posts: 571
Joined: Tue Feb 28, 2017 3:55 am
languages_spoken: english
ODROIDs: C2, C4, XU4, MC1, N1, N2, N2+, HC4
Location: Lake Superior Basin, USA
Has thanked: 65 times
Been thanked: 213 times
Contact:

Re: joysticks are spamming interrupts and events

Post by hominoid »

I'm on a Ubuntu 18.04 desktop using the latest Firefox and there is no Thanks icon either.

valadaa48
Posts: 288
Joined: Mon Feb 17, 2020 1:35 pm
languages_spoken: english
ODROIDs: odroid go advance
Has thanked: 40 times
Been thanked: 96 times
Contact:

Re: joysticks are spamming interrupts and events

Post by valadaa48 »

@odroid

Your suggestion didn't seem to have helped. I think I had tried forcing those values in the kernel code which is what eventually led me to doing my own filtering as I patched.

Code: Select all

$ cat /proc/cmdline
root=/dev/mmcblk0p2 rootwait rw fsck.repair=yes net.ifnames=0 fbcon=rotate:3 console=/dev/ttyFIQ0 quiet splash plymouth.ignore-serial-consoles consoleblank=0 button-adc-fuzz=15 button-adc-flat=20

User avatar
odroid
Site Admin
Posts: 38355
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 2129 times
Been thanked: 1264 times
Contact:

Re: joysticks are spamming interrupts and events

Post by odroid »

Can you try a bigger range?

Code: Select all

setenv joystick_flat "50"
setenv joystick_fuzz "50"

valadaa48
Posts: 288
Joined: Mon Feb 17, 2020 1:35 pm
languages_spoken: english
ODROIDs: odroid go advance
Has thanked: 40 times
Been thanked: 96 times
Contact:

Re: joysticks are spamming interrupts and events

Post by valadaa48 »

I suspect it won't work as I mentioned I had already tried those params directly in a patched kernel. Furthermore, my output was in the range of +/-4 and I imagine those should have been filtered by my cmdline. I assume you guys have a test harness you can perform the proper dev and testing?

User avatar
odroid
Site Admin
Posts: 38355
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 2129 times
Been thanked: 1264 times
Contact:

Re: joysticks are spamming interrupts and events

Post by odroid »

We've updated the joypad device driver with some other analog stick improvements. We tested it and there was no more spamming messages.
https://github.com/hardkernel/linux/com ... dgoA-4.4.y

After Kernel build, we used the following Kernel parameters. According to our test results, you don't need to increase the deadzone value thanks to the effective flat/fuzz feature.

Code: Select all

setenv joystick_fuzz "32"
setenv joystick_flat "32"
setenv joystick_y_range "1800"
setenv joystick_x_range "1800"
setenv joystick_scale "2"
setenv joystick_deadzone "0"

setenv joystick_config "button-adc-x-range=${joystick_x_range} button-adc-y-range=${joystick_y_range} button-adc-fuzz=${joystick_fuzz} button-adc-flat=${joystick_flat} button-adc-scale=${joystick_scale} button-adc-deadzone=${joystick_deadzone}"

# Boot Arguments
setenv bootargs "root=UUID='e139ce78-9841-40fe-8823-96a304a09859' rootwait rw fsck.repair=yes net.ifnames=0 fbcon=rotate:3 console=/dev/ttyFIQ0 quiet splash plymouth.ignore-serial-consoles consoleblank=0 ${joystick_config}"
These users thanked the author odroid for the post (total 3):
mad_ady (Fri Apr 03, 2020 6:13 pm) • kavag (Fri Apr 03, 2020 10:00 pm) • valadaa48 (Fri Apr 03, 2020 11:37 pm)

valadaa48
Posts: 288
Joined: Mon Feb 17, 2020 1:35 pm
languages_spoken: english
ODROIDs: odroid go advance
Has thanked: 40 times
Been thanked: 96 times
Contact:

Re: joysticks are spamming interrupts and events

Post by valadaa48 »

Thank you your patch works although I did have to set deadzone to 20 as I was still getting spammed.

User avatar
odroid
Site Admin
Posts: 38355
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 2129 times
Been thanked: 1264 times
Contact:

Re: joysticks are spamming interrupts and events

Post by odroid »

We've changed "deadzone" default value to 20 from 0.
https://github.com/hardkernel/linux/com ... 1097c0329d

We will make a trial Kernel update package to test our Ubuntu OS upgrade functionality within a few days.

crashoverride
Posts: 5484
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 485 times
Contact:

Re: joysticks are spamming interrupts and events

Post by crashoverride »

odroid wrote:
Tue Apr 07, 2020 5:47 pm
We will make a trial Kernel update package to test our Ubuntu OS upgrade functionality within a few days.
Looking forward to this. Please update this thread when the package is available so I can test it too.

User avatar
odroid
Site Admin
Posts: 38355
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 2129 times
Been thanked: 1264 times
Contact:

Re: joysticks are spamming interrupts and events

Post by odroid »

crashoverride wrote:
Wed Apr 08, 2020 10:13 am
odroid wrote:
Tue Apr 07, 2020 5:47 pm
We will make a trial Kernel update package to test our Ubuntu OS upgrade functionality within a few days.
Looking forward to this. Please update this thread when the package is available so I can test it too.
We will release it early next week. I'll share a ".deb" file this Friday for testing.

Post Reply

Return to “Issues”

Who is online

Users browsing this forum: No registered users and 1 guest