Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1379772pxb; Wed, 2 Feb 2022 03:45:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJxo6hdYTyu9K+NEW93gSq1mb1VEfAnIytUqdVpQMJwjhxUHu5e0r62k1JEZGnyK2yoiAA3W X-Received: by 2002:a17:903:2305:: with SMTP id d5mr29729453plh.14.1643802336495; Wed, 02 Feb 2022 03:45:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643802336; cv=none; d=google.com; s=arc-20160816; b=JSYk7L2X8BcPaXE1bYkk3hZDS6illjJMis2DM+swsAjj1QsbvHuka3SjOSvoCfLFLF SLKZLY5ztQmv/McCLm5L91Z1j2NT2lsyDG0Ulu9Tame4fR+sAwNn/88hjMwIloSxVhsd Z3CiAAcIPegK17rLENtI8q8uHfFB5Poko/cPXYBDJg/UqoYk61TnNMx3jR5qn1rA2EeR ZMMKPYSJu5E8HJtp7HHdzXYB1zC0Uq9YGjL5fximA2HbtFodvucHjX03AdHKhf1/sJxk x9MpcGkeK2B+xEqKPb8d73ZKzneN3TgDjUnx8i3iGCEKFTEN0iylPGdlzKJgkgTAGn8a xHoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature; bh=L/knS9qPT0pMhl6zzVPCh5nuEaMQhur4Fuwvu3aIh+0=; b=M5sVKkxUpRV+44GenLYZJXv135ZX+QUZC8ouyrnIUdgNs2LfSAHAyCOVa2zH6VR81E oQpQJWd8X2iLRwDi9HhUF0V6j66+O9gM1JOa4zA8GTrs/sIdQ12DSbYBURsD5P8gJPt2 wKcgrLEGTETeLqS3LD4GDbxGBoM7xi+IWDkFfnxkGEuEgU7S3bfDBOIHQQFz0TRgkM0L LK8ShNOKy3hphsrkb+qF+KGV3IGXts/KmPOF8Oafv1IJ9c3xBEYjSL4IUANLIz9dDOFA wE1PnlrmZPB36OhimJC38jc+b6t3zHPaWS3KAKo/t4XaqR8VK42SjvAYYTRfj4+P3jsr dkHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=SMjCuZQl; 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=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g27si18863703pgb.677.2022.02.02.03.45.23; Wed, 02 Feb 2022 03:45:36 -0800 (PST) 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=pass header.i=@xff.cz header.s=mail header.b=SMjCuZQl; 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=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243183AbiBBIHU (ORCPT + 99 others); Wed, 2 Feb 2022 03:07:20 -0500 Received: from vps.xff.cz ([195.181.215.36]:38672 "EHLO vps.xff.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237918AbiBBIHT (ORCPT ); Wed, 2 Feb 2022 03:07:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xff.cz; s=mail; t=1643789237; bh=DMb83cDhQ9rKfuJDRxlbrgx/yp3Sg6TPsG7z/FqFLqM=; h=Date:From:To:Cc:Subject:X-My-GPG-KeyId:References:From; b=SMjCuZQl5MJHcizfaQRtdVjolGreh3bV4fJivIFWoZsfsEEKAP0D1DUyV4VoJ2iHq TBRUIYt2dJeggUIFbVk2gOghjgcQWHndb/PmwhQMSPnbf/pM+rmQGYtGhGGh0S9MSO 8chZOfzkHoI3bOtbVWS2bYGKvi0zx/d8JSgV5TBE= Date: Wed, 2 Feb 2022 09:07:17 +0100 From: =?utf-8?Q?Ond=C5=99ej?= Jirman To: Samuel Holland Cc: Dmitry Torokhov , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, linux-i2c@vger.kernel.org, Wolfram Sang Subject: Re: [PATCH 2/5] Input: pinephone-keyboard - Add PinePhone keyboard driver Message-ID: <20220202080717.fai74mkjxdykqhht@core.my.home> Mail-Followup-To: =?utf-8?Q?Ond=C5=99ej?= Jirman , Samuel Holland , Dmitry Torokhov , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, linux-i2c@vger.kernel.org, Wolfram Sang X-My-GPG-KeyId: EBFBDDE11FB918D44D1F56C1F9F0A873BE9777ED References: <20220129230043.12422-1-samuel@sholland.org> <20220129230043.12422-3-samuel@sholland.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220129230043.12422-3-samuel@sholland.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Samuel, On Sat, Jan 29, 2022 at 05:00:39PM -0600, Samuel Holland wrote: > The official Pine64 PinePhone keyboard case contains a matrix keypad and > a MCU which runs a libre firmware. Add support for its I2C interface. > > Signed-off-by: Samuel Holland > --- > [...] > + > + ppkb->buf_swap = !ppkb->buf_swap; > + > + keymap = ppkb->fn_state ? ppkb->fn_keymap : ppkb->input->keycode; > + for (col = 0; col < ppkb->cols; ++col) { > + u8 old = *(++old_buf); > + u8 new = *(++new_buf); > + u8 changed = old ^ new; > + > + for (row = 0; row < ppkb->rows; ++row) { > + int code = MATRIX_SCAN_CODE(row, col, ppkb->row_shift); > + int value = new & BIT(row); > + > + if (!(changed & BIT(row))) > + continue; > + > + dev_dbg(dev, "row %u col %u %sed\n", > + row, col, value ? "press" : "releas"); > + if (keymap[code] == KEY_FN) { > + dev_dbg(dev, "FN is now %sed\n", > + value ? "press" : "releas"); > + keymap = value ? ppkb->fn_keymap > + : ppkb->input->keycode; > + ppkb->fn_state = value; > + } > + input_event(ppkb->input, EV_MSC, MSC_SCAN, code); > + input_report_key(ppkb->input, keymap[code], value); I think there's a logic issue here with the Fn layer. Consider what happens when you press Fn press F1 and then release Fn and release F1. In that case input_report_key will report press of F1 (in fn layer) but release of '1' which is not in Fn layer, because Fn layer was de-activated before releasing the modified key. From the PoV of the user, this will probably lead to auto-repeat of F1 and spurious '1' release without preceding press event. So the userspace sees F1 as stuck and auto-repeats it. kind regards, o. > + } > + } > + input_sync(ppkb->input); > +} > +