diff mbox series

Input: cros_ec_keyb: add support for base attached event

Message ID 20240118085310.1139545-1-phoenixshen@google.com (mailing list archive)
State Superseded
Headers show
Series Input: cros_ec_keyb: add support for base attached event | expand

Commit Message

Ting Shen Jan. 18, 2024, 8:52 a.m. UTC
This CL maps ChromeOS EC's BASE_ATTACHED event to SW_DOCK,
to allow userspace detect that a keyboard is attached to the
detachable device.

Signed-off-by: Ting Shen <phoenixshen@google.com>
---

 drivers/input/keyboard/cros_ec_keyb.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Fei Shao Jan. 18, 2024, 10:01 a.m. UTC | #1
On Thu, Jan 18, 2024 at 4:54 PM Ting Shen <phoenixshen@chromium.org> wrote:
>
> This CL maps ChromeOS EC's BASE_ATTACHED event to SW_DOCK,
Hi Ting,

The change itself looks good to me, but the userspace can already
detect keyboard attachment through USB events. Can you explain why
this becomes necessary?
And the Linux community doesn't use the term "CL". Please use general
terms like "commit" or "patch" as well as imperative sentences [1] in changelog.

After that,
Reviewed-by: Fei Shao <fshao@chromium.org>

[1]: https://www.kernel.org/doc/html/latest/process/submitting-patches.html#describe-your-changes

Regards,
Fei



> to allow userspace detect that a keyboard is attached to the
> detachable device.
>
> Signed-off-by: Ting Shen <phoenixshen@google.com>
> ---
>
>  drivers/input/keyboard/cros_ec_keyb.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/drivers/input/keyboard/cros_ec_keyb.c b/drivers/input/keyboard/cros_ec_keyb.c
> index 30678a34cf647..d2e0d89d4ffdf 100644
> --- a/drivers/input/keyboard/cros_ec_keyb.c
> +++ b/drivers/input/keyboard/cros_ec_keyb.c
> @@ -128,6 +128,11 @@ static const struct cros_ec_bs_map cros_ec_keyb_bs[] = {
>                 .code           = SW_TABLET_MODE,
>                 .bit            = EC_MKBP_TABLET_MODE,
>         },
> +       {
> +               .ev_type        = EV_SW,
> +               .code           = SW_DOCK,
> +               .bit            = EC_MKBP_BASE_ATTACHED,
> +       },
>  };
>
>  /*
> --
> 2.43.0.381.gb435a96ce8-goog
>
Dmitry Torokhov Jan. 18, 2024, 5:55 p.m. UTC | #2
Hi Ting,

On Thu, Jan 18, 2024 at 04:52:43PM +0800, Ting Shen wrote:
> This CL maps ChromeOS EC's BASE_ATTACHED event to SW_DOCK,

As far as I know none of the Chrome OS devices support classic docking
station (not talking about the new USB-C/TB ones).

> to allow userspace detect that a keyboard is attached to the
> detachable device.

Are we planning to have detachable keyboard that is not USB?

EC_MKBP_BASE_ATTACHED is processed by hid-google-hammer driver and,
together with the USB connector state, is used to form SW_TABLET_MODE.
The reason just the USB state was not enough is because the keyboard
could be attached to the lid "other way around" to be used as a stand.
In that configuration USB connection was not active. However userspace
still needed to know about this to activate tablet version of the UI.

Please provide more information why you want this to be exposed via
cros_ec_keyb driver.

Thanks.
Dmitry Torokhov Jan. 19, 2024, 8:13 a.m. UTC | #3
On Fri, Jan 19, 2024 at 03:47:32PM +0800, ☆★☆ Ting ☆★☆ Shen wrote:
> On Fri, Jan 19, 2024 at 1:55 AM Dmitry Torokhov <dmitry.torokhov@gmail.com>
> wrote:
> 
> > Hi Ting,
> >
> > On Thu, Jan 18, 2024 at 04:52:43PM +0800, Ting Shen wrote:
> > > This CL maps ChromeOS EC's BASE_ATTACHED event to SW_DOCK,
> >
> > As far as I know none of the Chrome OS devices support classic docking
> > station (not talking about the new USB-C/TB ones).
> >
> > > to allow userspace detect that a keyboard is attached to the
> > > detachable device.
> >
> > Are we planning to have detachable keyboard that is not USB?
> >
> Yes this is for a non-USB keyboard. The keyboard is connected to EC, and EC
> forwards input events to the host.
> 
> >
> > EC_MKBP_BASE_ATTACHED is processed by hid-google-hammer driver and,
> > together with the USB connector state, is used to form SW_TABLET_MODE.
> > The reason just the USB state was not enough is because the keyboard
> > could be attached to the lid "other way around" to be used as a stand.
> > In that configuration USB connection was not active. However userspace
> > still needed to know about this to activate tablet version of the UI.
> >
> > Please provide more information why you want this to be exposed via
> > cros_ec_keyb driver.
> >
> > Thanks.
> >
> 
> The main purpose of this patch is to have some signal to trigger the
> firmware updater (hammerd), EC_MKBP_BASE_ATTACHED seems suitable.
> EC_MKBP_TABLET_MODE is also usable but may be too noisy, it fires whenever
> the user flips the keyboard.

I think this can be solved in userspace. You may consider emitting
uevent when seeing EC_MKBP_BASE_ATTACHED from the EC. SW_DOCK input event
is not really suitable here as it indicated a docking station being
attached.

Thanks.
diff mbox series

Patch

diff --git a/drivers/input/keyboard/cros_ec_keyb.c b/drivers/input/keyboard/cros_ec_keyb.c
index 30678a34cf647..d2e0d89d4ffdf 100644
--- a/drivers/input/keyboard/cros_ec_keyb.c
+++ b/drivers/input/keyboard/cros_ec_keyb.c
@@ -128,6 +128,11 @@  static const struct cros_ec_bs_map cros_ec_keyb_bs[] = {
 		.code		= SW_TABLET_MODE,
 		.bit		= EC_MKBP_TABLET_MODE,
 	},
+	{
+		.ev_type	= EV_SW,
+		.code		= SW_DOCK,
+		.bit		= EC_MKBP_BASE_ATTACHED,
+	},
 };
 
 /*