* [PATCH 0/2] Input: cros-ec-keyb: Don't register keyboard if doesn't exist @ 2022-04-13 3:33 Stephen Boyd 2022-04-13 3:33 ` [PATCH 1/2] Input: cros-ec-keyb: Only register keyboard if rows/columns exist Stephen Boyd 2022-04-13 3:33 ` [RFC/PATCH 2/2] arm64: dts: qcom: sc7180-trogdor: Remove cros-ec keyboard from detachables Stephen Boyd 0 siblings, 2 replies; 6+ messages in thread From: Stephen Boyd @ 2022-04-13 3:33 UTC (permalink / raw) To: Dmitry Torokhov Cc: linux-kernel, patches, linux-input, chrome-platform, Benson Leung, Guenter Roeck, Douglas Anderson, Hsin-Yi Wang We're registering a keyboard input device on detachable chromebooks when that input device doesn't generate any events. This patch series stops doing that to save some runtime memory and to help userspace understand that there really isn't a keyboard present when the keyboard is detached. The second patch is an RFC because it should be picked up through arm-soc tree, not input tree. Stephen Boyd (2): Input: cros-ec-keyb: Only register keyboard if rows/columns exist arm64: dts: qcom: sc7180-trogdor: Remove cros-ec keyboard from detachables arch/arm64/boot/dts/qcom/sc7180-trogdor-coachz.dtsi | 5 +++++ arch/arm64/boot/dts/qcom/sc7180-trogdor-homestar.dtsi | 5 +++++ drivers/input/keyboard/cros_ec_keyb.c | 9 +++++++++ 3 files changed, 19 insertions(+) Cc: Benson Leung <bleung@chromium.org> Cc: Guenter Roeck <groeck@chromium.org> Cc: Douglas Anderson <dianders@chromium.org> Cc: Hsin-Yi Wang <hsinyi@chromium.org> base-commit: 3123109284176b1532874591f7c81f3837bbdc17 -- https://chromeos.dev ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] Input: cros-ec-keyb: Only register keyboard if rows/columns exist 2022-04-13 3:33 [PATCH 0/2] Input: cros-ec-keyb: Don't register keyboard if doesn't exist Stephen Boyd @ 2022-04-13 3:33 ` Stephen Boyd 2022-04-13 20:44 ` Doug Anderson 2022-04-25 3:47 ` Dmitry Torokhov 2022-04-13 3:33 ` [RFC/PATCH 2/2] arm64: dts: qcom: sc7180-trogdor: Remove cros-ec keyboard from detachables Stephen Boyd 1 sibling, 2 replies; 6+ messages in thread From: Stephen Boyd @ 2022-04-13 3:33 UTC (permalink / raw) To: Dmitry Torokhov Cc: linux-kernel, patches, linux-input, chrome-platform, Benson Leung, Guenter Roeck, Douglas Anderson, Hsin-Yi Wang If the device is a detachable, we may still probe this device because there are some button switches, e.g. volume buttons and power buttons, registered by this driver. Let's allow the device node to be missing row and column device properties to indicate that the keyboard matrix shouldn't be registered. This removes an input device on Trogdor devices such as Wormdingler that don't have a matrix keyboard, but still have power and volume buttons. That helps userspace understand there isn't a keyboard present when the detachable keyboard is disconnected. Cc: Benson Leung <bleung@chromium.org> Cc: Guenter Roeck <groeck@chromium.org> Cc: Douglas Anderson <dianders@chromium.org> Cc: Hsin-Yi Wang <hsinyi@chromium.org> Signed-off-by: Stephen Boyd <swboyd@chromium.org> --- I tried to use mkbp info to query the number of rows and columns, but my EC firmware doesn't have commit 8505881ed0b9 ("mkbp: Separate MKBP_INFO host command from the keyboard driver") so it always returns 8 and 13 for the rows and columns. Sigh. With updated firmware we could query it, or we could rely on DT like we do already. Originally I was setting the properties to 0, but matrix_keypad_parse_properties() spits out an error message in that case and so it seems better to delete the properties and check for their existence instead. Another alternative would be to change the compatible to be "google,cros-ec-keyb-switches" or something that indicates there are only switches and no matrix keyboard. drivers/input/keyboard/cros_ec_keyb.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/input/keyboard/cros_ec_keyb.c b/drivers/input/keyboard/cros_ec_keyb.c index 6534dfca60b4..ac9a953bff02 100644 --- a/drivers/input/keyboard/cros_ec_keyb.c +++ b/drivers/input/keyboard/cros_ec_keyb.c @@ -537,6 +537,15 @@ static int cros_ec_keyb_register_matrix(struct cros_ec_keyb *ckdev) u32 key_pos; unsigned int row, col, scancode, n_physmap; + /* + * No rows and columns? There isn't a matrix but maybe there are + * switches to register in cros_ec_keyb_register_bs() because this is a + * detachable device. + */ + if (!device_property_read_bool(dev, "keypad,num-rows") && + !device_property_read_bool(dev, "keypad,num-cols")) + return 0; + err = matrix_keypad_parse_properties(dev, &ckdev->rows, &ckdev->cols); if (err) return err; -- https://chromeos.dev ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] Input: cros-ec-keyb: Only register keyboard if rows/columns exist 2022-04-13 3:33 ` [PATCH 1/2] Input: cros-ec-keyb: Only register keyboard if rows/columns exist Stephen Boyd @ 2022-04-13 20:44 ` Doug Anderson 2022-04-25 3:47 ` Dmitry Torokhov 1 sibling, 0 replies; 6+ messages in thread From: Doug Anderson @ 2022-04-13 20:44 UTC (permalink / raw) To: Stephen Boyd Cc: Dmitry Torokhov, LKML, patches, open list:HID CORE LAYER, chrome-platform, Benson Leung, Guenter Roeck, Hsin-Yi Wang Hi, On Tue, Apr 12, 2022 at 8:33 PM Stephen Boyd <swboyd@chromium.org> wrote: > > If the device is a detachable, we may still probe this device because > there are some button switches, e.g. volume buttons and power buttons, > registered by this driver. Let's allow the device node to be missing row > and column device properties to indicate that the keyboard matrix > shouldn't be registered. This removes an input device on Trogdor devices > such as Wormdingler that don't have a matrix keyboard, but still have > power and volume buttons. That helps userspace understand there isn't > a keyboard present when the detachable keyboard is disconnected. > > Cc: Benson Leung <bleung@chromium.org> > Cc: Guenter Roeck <groeck@chromium.org> > Cc: Douglas Anderson <dianders@chromium.org> > Cc: Hsin-Yi Wang <hsinyi@chromium.org> > Signed-off-by: Stephen Boyd <swboyd@chromium.org> > --- > > I tried to use mkbp info to query the number of rows and columns, but my > EC firmware doesn't have commit 8505881ed0b9 ("mkbp: Separate MKBP_INFO > host command from the keyboard driver") so it always returns 8 and 13 > for the rows and columns. Sigh. With updated firmware we could query it, > or we could rely on DT like we do already. > > Originally I was setting the properties to 0, but > matrix_keypad_parse_properties() spits out an error message in that case > and so it seems better to delete the properties and check for their > existence instead. Another alternative would be to change the compatible > to be "google,cros-ec-keyb-switches" or something that indicates there > are only switches and no matrix keyboard. > > drivers/input/keyboard/cros_ec_keyb.c | 9 +++++++++ > 1 file changed, 9 insertions(+) I do wonder if there will be any unintentional side effects here. Specifically, even though there is truly no keyboard here, I wonder if anything in the system is relying on the EC to simulate keypresses even on tablets where the keyboard isn't actually there... OK, I guess not. While I think it _used_ to be the case that you could simulate keyboard inputs from the EC console even for devices w/out a keyboard, it doesn't seem to be the case anymore. I just tried it and nothing made it through to the AP. Seems reasonable to me: Reviewed-by: Douglas Anderson <dianders@chromium.org> ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] Input: cros-ec-keyb: Only register keyboard if rows/columns exist 2022-04-13 3:33 ` [PATCH 1/2] Input: cros-ec-keyb: Only register keyboard if rows/columns exist Stephen Boyd 2022-04-13 20:44 ` Doug Anderson @ 2022-04-25 3:47 ` Dmitry Torokhov 2022-04-25 20:12 ` Stephen Boyd 1 sibling, 1 reply; 6+ messages in thread From: Dmitry Torokhov @ 2022-04-25 3:47 UTC (permalink / raw) To: Stephen Boyd Cc: linux-kernel, patches, linux-input, chrome-platform, Benson Leung, Guenter Roeck, Douglas Anderson, Hsin-Yi Wang Hi Stephen, On Tue, Apr 12, 2022 at 08:33:33PM -0700, Stephen Boyd wrote: > If the device is a detachable, we may still probe this device because > there are some button switches, e.g. volume buttons and power buttons, > registered by this driver. Let's allow the device node to be missing row > and column device properties to indicate that the keyboard matrix > shouldn't be registered. This removes an input device on Trogdor devices > such as Wormdingler that don't have a matrix keyboard, but still have > power and volume buttons. That helps userspace understand there isn't > a keyboard present when the detachable keyboard is disconnected. > > Cc: Benson Leung <bleung@chromium.org> > Cc: Guenter Roeck <groeck@chromium.org> > Cc: Douglas Anderson <dianders@chromium.org> > Cc: Hsin-Yi Wang <hsinyi@chromium.org> > Signed-off-by: Stephen Boyd <swboyd@chromium.org> > --- > > I tried to use mkbp info to query the number of rows and columns, but my > EC firmware doesn't have commit 8505881ed0b9 ("mkbp: Separate MKBP_INFO > host command from the keyboard driver") so it always returns 8 and 13 > for the rows and columns. Sigh. With updated firmware we could query it, > or we could rely on DT like we do already. > > Originally I was setting the properties to 0, but > matrix_keypad_parse_properties() spits out an error message in that case > and so it seems better to delete the properties and check for their > existence instead. Another alternative would be to change the compatible > to be "google,cros-ec-keyb-switches" or something that indicates there > are only switches and no matrix keyboard. > > drivers/input/keyboard/cros_ec_keyb.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/drivers/input/keyboard/cros_ec_keyb.c b/drivers/input/keyboard/cros_ec_keyb.c > index 6534dfca60b4..ac9a953bff02 100644 > --- a/drivers/input/keyboard/cros_ec_keyb.c > +++ b/drivers/input/keyboard/cros_ec_keyb.c > @@ -537,6 +537,15 @@ static int cros_ec_keyb_register_matrix(struct cros_ec_keyb *ckdev) > u32 key_pos; > unsigned int row, col, scancode, n_physmap; > > + /* > + * No rows and columns? There isn't a matrix but maybe there are > + * switches to register in cros_ec_keyb_register_bs() because this is a > + * detachable device. > + */ > + if (!device_property_read_bool(dev, "keypad,num-rows") && > + !device_property_read_bool(dev, "keypad,num-cols")) Why are we abusing device_property_read_bool() for properties that are not flags instead of using device_property_present()? > + return 0; > + > err = matrix_keypad_parse_properties(dev, &ckdev->rows, &ckdev->cols); > if (err) > return err; > -- > https://chromeos.dev > Thanks. -- Dmitry ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] Input: cros-ec-keyb: Only register keyboard if rows/columns exist 2022-04-25 3:47 ` Dmitry Torokhov @ 2022-04-25 20:12 ` Stephen Boyd 0 siblings, 0 replies; 6+ messages in thread From: Stephen Boyd @ 2022-04-25 20:12 UTC (permalink / raw) To: Dmitry Torokhov Cc: linux-kernel, patches, linux-input, chrome-platform, Benson Leung, Guenter Roeck, Douglas Anderson, Hsin-Yi Wang Quoting Dmitry Torokhov (2022-04-24 20:47:03) > > > > + /* > > + * No rows and columns? There isn't a matrix but maybe there are > > + * switches to register in cros_ec_keyb_register_bs() because this is a > > + * detachable device. > > + */ > > + if (!device_property_read_bool(dev, "keypad,num-rows") && > > + !device_property_read_bool(dev, "keypad,num-cols")) > > Why are we abusing device_property_read_bool() for properties that are > not flags instead of using device_property_present()? > Because I wrote this using DT APIs first and wasn't aware that device_property_present() was a thing. I'll resend it with that API usage. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [RFC/PATCH 2/2] arm64: dts: qcom: sc7180-trogdor: Remove cros-ec keyboard from detachables 2022-04-13 3:33 [PATCH 0/2] Input: cros-ec-keyb: Don't register keyboard if doesn't exist Stephen Boyd 2022-04-13 3:33 ` [PATCH 1/2] Input: cros-ec-keyb: Only register keyboard if rows/columns exist Stephen Boyd @ 2022-04-13 3:33 ` Stephen Boyd 1 sibling, 0 replies; 6+ messages in thread From: Stephen Boyd @ 2022-04-13 3:33 UTC (permalink / raw) To: Dmitry Torokhov Cc: linux-kernel, patches, linux-input, chrome-platform, Benson Leung, Guenter Roeck, Douglas Anderson, Hsin-Yi Wang Trogdor devices that have a detachable keyboard still have a non-detachable keyboard input device present because we include the cros-ec-keyboard.dtsi snippet in the top-level sc7180-trogdor.dtsi file that every variant board includes. We do this because the keyboard-controller node also provides some buttons like the power button and volume buttons. Unfortunately, this means we register a keyboard input device that doesn't do anything on boards with a detachable keyboard. Let's delete the rows/columns properties of the device node to indicate that there isn't a matrix keyboard on these boards. Cc: Benson Leung <bleung@chromium.org> Cc: Guenter Roeck <groeck@chromium.org> Cc: Douglas Anderson <dianders@chromium.org> Cc: Hsin-Yi Wang <hsinyi@chromium.org> Signed-off-by: Stephen Boyd <swboyd@chromium.org> --- This is mostly to show an example. The patch will be picked up by qcom maintainer if the first patch is accepted. arch/arm64/boot/dts/qcom/sc7180-trogdor-coachz.dtsi | 5 +++++ arch/arm64/boot/dts/qcom/sc7180-trogdor-homestar.dtsi | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/sc7180-trogdor-coachz.dtsi b/arch/arm64/boot/dts/qcom/sc7180-trogdor-coachz.dtsi index c81805ef2250..4173623cc241 100644 --- a/arch/arm64/boot/dts/qcom/sc7180-trogdor-coachz.dtsi +++ b/arch/arm64/boot/dts/qcom/sc7180-trogdor-coachz.dtsi @@ -119,6 +119,11 @@ &i2c9 { status = "disabled"; }; +&keyboard_controller { + /delete-property/keypad,num-rows; + /delete-property/keypad,num-columns; +}; + &panel { compatible = "boe,nv110wtm-n61"; }; diff --git a/arch/arm64/boot/dts/qcom/sc7180-trogdor-homestar.dtsi b/arch/arm64/boot/dts/qcom/sc7180-trogdor-homestar.dtsi index bff2b556cc75..7205062e88b4 100644 --- a/arch/arm64/boot/dts/qcom/sc7180-trogdor-homestar.dtsi +++ b/arch/arm64/boot/dts/qcom/sc7180-trogdor-homestar.dtsi @@ -121,6 +121,11 @@ &camcc { status = "okay"; }; +&keyboard_controller { + /delete-property/keypad,num-rows; + /delete-property/keypad,num-columns; +}; + &panel { compatible = "samsung,atna33xc20"; enable-gpios = <&tlmm 12 GPIO_ACTIVE_HIGH>; -- https://chromeos.dev ^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-04-25 20:12 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-04-13 3:33 [PATCH 0/2] Input: cros-ec-keyb: Don't register keyboard if doesn't exist Stephen Boyd 2022-04-13 3:33 ` [PATCH 1/2] Input: cros-ec-keyb: Only register keyboard if rows/columns exist Stephen Boyd 2022-04-13 20:44 ` Doug Anderson 2022-04-25 3:47 ` Dmitry Torokhov 2022-04-25 20:12 ` Stephen Boyd 2022-04-13 3:33 ` [RFC/PATCH 2/2] arm64: dts: qcom: sc7180-trogdor: Remove cros-ec keyboard from detachables Stephen Boyd
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).