Message ID | 20221031190159.1341027-1-lis8215@gmail.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2492506wru; Mon, 31 Oct 2022 12:08:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7LM7kwrNeOgtdiLg0uSCqml5lrj/qGDpzNTIamRDP+teHASyJdLhFI5jyytQMiCADBEENT X-Received: by 2002:a17:906:8a63:b0:7ad:95cf:726a with SMTP id hy3-20020a1709068a6300b007ad95cf726amr14572577ejc.82.1667243306207; Mon, 31 Oct 2022 12:08:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667243306; cv=none; d=google.com; s=arc-20160816; b=nbohvn/3CvIhWMDVpznCraDAFpvOMM+a7KNs3xPfcasDsgDs32rZt9hIU7I3FBrKMh f1alKPUhHWGhhCn05lwG6WSvbHrE7+yKx2bEHx1NOE1X5AILuvii6HWYfhHNQlxA2HpO yLAzcQ0sfHl+za7RnW7Xb2zriNZEsK2azSJY4I4lyR+CV3xw62ptMBrrc65hjrm2xh/6 vv2jjdV7amMFG6FV9AI+UtrGsDjy7LwQbh0Zy4g4FeHUDBOgvQUZbzte7VDvR7j3Qycm ezrnLi1Syw3HeIZccu4yREWG1boHSTsLojzSiGtSpJs3CsIX52wjwxOlRonOHZB+bOv+ BUpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=MAKY7AptcCVQIhtmA9wqKe7QLZb3fkZHYHjCZEkjfqI=; b=lx1TwbZZZ1oQIdn+GfFcoFNLgJTwoSebxHPkRH7AK2yTUb3K7PC7Oc/Pvm9JKC/Rlr SB+lhPymCLjkjga4OMMTTOWGsBbyVDy7UaUzwbGyIXBzhXcEdcLmGGL5e4RUF/9DW4W+ gDSNQ742m4wg9demdR+2q6FrczdxyxQKDKKsFZ84mWI3nkSIvfVXuPgmycpSc0QA5ZhF 9Itfd8x3wpEY1wJpQIWd35pf2pNUubY8hmC5QAz3PxekZR9XFJR5TuUrY2VnBmkWCj3r jeYIIhTuTHDCS4uN+Dirts5LUeG53WjCYLo8eBvzb1MPyOcgWIxolSIopVMdRmF6Z82o IjSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20210112 header.b=eBYn5yVs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k8-20020a17090627c800b0073d91a38b35si6843964ejc.789.2022.10.31.12.08.00; Mon, 31 Oct 2022 12:08:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20210112 header.b=eBYn5yVs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229916AbiJaTCf (ORCPT <rfc822;kartikey406@gmail.com> + 99 others); Mon, 31 Oct 2022 15:02:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229677AbiJaTCd (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 31 Oct 2022 15:02:33 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 734E79589; Mon, 31 Oct 2022 12:02:32 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id a11-20020a05600c2d4b00b003cf6f5fd9f1so2420513wmg.2; Mon, 31 Oct 2022 12:02:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=MAKY7AptcCVQIhtmA9wqKe7QLZb3fkZHYHjCZEkjfqI=; b=eBYn5yVs3gG4F0A2V+BGvTOlxeDyXHO7zxEKqyxQzgq0MRpwiVlymwpZVQsOpyWjGj 2NfEagpA+IG5N0tWUz9phvK46FAKiPHrQKUFrjtnQGDEtjwMZffZcSTBpcSB7M3Xfhtp Y11i7ZqwOpMwNbJl/TD0JnJ2NnZO/1H0/6+tLZjl2mfRlZQLHpvzXNoPQ/K9UXoIXPNy ylg676C2UDbxJZFgEl3zmI/Ug6VihVYv+6uEDwun5raEVjT+8gSO13UukiaaQ+WQr89c GzdhAApmFOP32ukb2kPk1B3b8bfirxlZyFgPXZDlPFZmcpOcqDzfmgfTgxFc8Poyuj48 JZDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=MAKY7AptcCVQIhtmA9wqKe7QLZb3fkZHYHjCZEkjfqI=; b=hoZ67oNf4M58UC1QLyk6WhNpkeCqrTvXE27rkts+83wQQnNLh3jNqVhPt3LyuC3dwc 2YXnf/yUtkFJtbobl02+oGrqRDTOBgHWxtBrAXzUq6UI55HlQuUNawbqm2V4JlZ50MxM HEK6hoSZgxs2CFLA3N3OGklQeBQh/mQks5ndB/RrZHkboI3hpCCGWpgC1r10YmlFSx78 +BKTJ3PVILr/8WGwfymEHYNPKGcQjGveMA97h1XFJLu8aZCBXk2hmoGOxX+4R4voOfil 7hMPT3TSwQJ2TV8J4mSE0SiniubjNDrdwm7lnWrd3DOiMAjNC0JVYMZG8V3pPE//TtXu td9A== X-Gm-Message-State: ACrzQf2ZFnGQEICG/sFvHkaNStM0JqCuBCWg57a8l1n/nESal7wNpA40 AKE0I6Gko1GG+HsbraORE3o/nIWYm4Naj48b X-Received: by 2002:a05:600c:3b82:b0:3cf:6cc7:5b7b with SMTP id n2-20020a05600c3b8200b003cf6cc75b7bmr5721776wms.126.1667242950941; Mon, 31 Oct 2022 12:02:30 -0700 (PDT) Received: from hp-power-15.localdomain (mm-167-8-212-37.vitebsk.dynamic.pppoe.byfly.by. [37.212.8.167]) by smtp.gmail.com with ESMTPSA id l13-20020a05600c2ccd00b003a2f2bb72d5sm9141750wmc.45.2022.10.31.12.02.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Oct 2022 12:02:30 -0700 (PDT) From: Siarhei Volkau <lis8215@gmail.com> Cc: Paul Cercueil <paul@crapouillou.net>, Siarhei Volkau <lis8215@gmail.com>, Dmitry Torokhov <dmitry.torokhov@gmail.com>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Artur Rojek <contact@artur-rojek.eu>, linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 0/2] Input: adc-joystick: add detachable devices support Date: Mon, 31 Oct 2022 22:01:57 +0300 Message-Id: <20221031190159.1341027-1-lis8215@gmail.com> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748231317273715835?= X-GMAIL-MSGID: =?utf-8?q?1748231317273715835?= |
Series |
Input: adc-joystick: add detachable devices support
|
|
Message
Siarhei Volkau
Oct. 31, 2022, 7:01 p.m. UTC
For detachable or lock-able joysticks the ADC lanes might be biased to GND or AVDD when the joystick is detached/locked. One such kind of joystick is found in the Ritmix RZX-50 handheld. The joystick is non-detachable, although ADC lane biased to power supply when the "Hold" switch is activated. To avoid reporting old/broken measurements valid-range is introduced. When measured value is outside valid-range the driver reports safe center position for corresponding axis. Siarhei Volkau (2): dt-bindings: adc-joystick: add valid-range Input: adc-joystick - add detachable devices support .../bindings/input/adc-joystick.yaml | 62 +++++++++++++++++++ drivers/input/joystick/adc-joystick.c | 58 ++++++++++++++++- 2 files changed, 119 insertions(+), 1 deletion(-)
Comments
Hi Siarhei, Le lun. 31 oct. 2022 à 22:01:57 +0300, Siarhei Volkau <lis8215@gmail.com> a écrit : > For detachable or lock-able joysticks the ADC lanes might > be biased to GND or AVDD when the joystick is detached/locked. > > One such kind of joystick is found in the Ritmix RZX-50 handheld. > The joystick is non-detachable, although ADC lane biased to power > supply when the "Hold" switch is activated. But the RZX-50 has no joystick... Or is the d-pad actually wired to the ADC instead of GPIOs? > To avoid reporting old/broken measurements valid-range is introduced. > When measured value is outside valid-range the driver reports > safe center position for corresponding axis. First of all, you already have a "valid range", it is called "abs-range"; no need for a new one. Then, the driver has no business doing events filtering. Notice that when you activate the "hold" button and your joystick values go way off-range, you still get input events in userspace: that's because the kernel is not responsible for enforcing the deadzone, the userspace is. In your case, you need to update your userspace applications/libraries so that when the joystick values are way off-range, the assumed position is the center. Cheers, -Paul
вс, 6 нояб. 2022 г. в 02:39, Paul Cercueil <paul@crapouillou.net>: > > Hi Siarhei, > > Le lun. 31 oct. 2022 à 22:01:57 +0300, Siarhei Volkau > <lis8215@gmail.com> a écrit : > > For detachable or lock-able joysticks the ADC lanes might > > be biased to GND or AVDD when the joystick is detached/locked. > > > > One such kind of joystick is found in the Ritmix RZX-50 handheld. > > The joystick is non-detachable, although ADC lane biased to power > > supply when the "Hold" switch is activated. > > But the RZX-50 has no joystick... Well, actually there's two versions in the wild (google "RZX-50 pictures"): - with analog joystick and speakers on the back side - without the joystick and speakers on the front side I have only the first one at the moment, but I'm looking for another one. > Or is the d-pad actually wired to the ADC instead of GPIOs? The D-Pad is another kind of pain there - it's a part of the matrix-keypad but the pad's row line is shared with the LCD HSYNC signal. > > To avoid reporting old/broken measurements valid-range is introduced. > > When measured value is outside valid-range the driver reports > > safe center position for corresponding axis. > > First of all, you already have a "valid range", it is called > "abs-range"; no need for a new one. > > Then, the driver has no business doing events filtering. Notice that > when you activate the "hold" button and your joystick values go way > off-range, you still get input events in userspace: that's because the > kernel is not responsible for enforcing the deadzone, the userspace is. > > In your case, you need to update your userspace applications/libraries > so that when the joystick values are way off-range, the assumed > position is the center. Many userspace apps use SDL library to handle joystick input, the SDL unfortunately hides the fact that the joystick position is out of range - it does normalization and clamping of the abs-range to an int16_t range. I see two approaches to do that in userspace: 1. Make a quirk in the SDL library, which affects many types of joysticks and lead to a fragmentation (special userspace apps for every hardware isn't the right way in my opinion). 2. Make a special filter app which will filter out invalid joystick events and route rest to the /dev/input/uinput. Not sure how to hide the real joystick device from libraries like SDL then. Both of them don't look like a "silver bullet", however feasible. > > Cheers, > -Paul > > Thank you.
> Not sure how to hide the real joystick device from libraries like SDL
Got it, EVIOCGRAB ioctl shall do the job.
Thank you all !
BR,
Siarhei