Re: [PATCH v12 4/7] input: keyboard: Add driver for ASUS Transformer dock multimedia keys

From: Dmitry Torokhov

Date: Tue Oct 20 2026 - 14:54:57 EST


On Mon, Oct 19, 2026 at 01:04:03PM +0300, Svyatoslav Ryhel wrote:
> From: Michał Mirosław <mirq-linux@xxxxxxxxxxxx>
>
> Add support for multimedia top button row of ASUS Transformer's Mobile
> Dock keyboard. Driver is made that function keys (F1-F12) are used by
> default which suits average Linux use better and with pressing
> ScreenLock + AltGr function keys layout is switched to multimedia keys.
> Only Dock keyboard input events are tracked for AltGr pressing.
>
> Co-developed-by: Ion Agorria <ion@xxxxxxxxxxx>
> Signed-off-by: Ion Agorria <ion@xxxxxxxxxxx>
> Signed-off-by: Michał Mirosław <mirq-linux@xxxxxxxxxxxx>
> Signed-off-by: Svyatoslav Ryhel <clamor95@xxxxxxxxx>

Acked-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>

> +
> +static void asus_ec_keys_setup_keymap(struct asus_ec_keys_data *priv)
> +{
> + struct input_dev *dev = priv->xidev;
> + unsigned int i;
> +
> + BUILD_BUG_ON(ARRAY_SIZE(priv->keymap) < ARRAY_SIZE(asus_ec_dock_ext_keys));
> +
> + dev->keycode = priv->keymap;
> + dev->keycodesize = sizeof(*priv->keymap);
> + dev->keycodemax = ARRAY_SIZE(priv->keymap);
> +
> + input_set_capability(dev, EV_MSC, MSC_SCAN);
> + input_set_capability(dev, EV_KEY, KEY_UNKNOWN);
> +
> + for (i = 0; i < ARRAY_SIZE(asus_ec_dock_ext_keys); i++) {
> + unsigned int code = asus_ec_dock_ext_keys[i];
> +
> + if (!code)
> + continue;

Nit: this check is not needed, input core will remove KEY_RESERVED (0)
from the keybit when device is registered.

> +
> + __set_bit(code, dev->keybit);
> + priv->keymap[i] = code;
> + }
> +}
> +
> +static int asus_ec_keys_probe(struct platform_device *pdev)
> +{
> + struct i2c_client *parent = to_i2c_client(pdev->dev.parent);
> + struct asusec_core *ec = dev_get_drvdata(pdev->dev.parent);
> + struct device *dev = &pdev->dev;
> + struct asus_ec_keys_data *priv;
> + int error;
> +
> + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> + if (!priv)
> + return -ENOMEM;
> +
> + platform_set_drvdata(pdev, priv);
> + priv->ec = ec;
> +
> + priv->xidev = devm_input_allocate_device(dev);
> + if (!priv->xidev)
> + return -ENOMEM;
> +
> + priv->xidev->name = devm_kasprintf(dev, GFP_KERNEL, "%s Keyboard Ext",
> + ec->model);
> + priv->xidev->phys = devm_kasprintf(dev, GFP_KERNEL, "i2c-%u-%04x",
> + i2c_adapter_id(parent->adapter),
> + parent->addr);
> +
> + if (!priv->xidev->name || !priv->xidev->phys)
> + return -ENOMEM;
> +
> + asus_ec_keys_setup_keymap(priv);
> +
> + error = input_register_device(priv->xidev);
> + if (error)
> + return dev_err_probe(dev, error,
> + "failed to register extension keys\n");
> +
> + priv->nb.notifier_call = asus_ec_keys_notify;
> +
> + error = blocking_notifier_chain_register(&ec->notify_list, &priv->nb);
> + if (error)
> + return error;
> +
> + ec->ext_keys_enabled = true;

I think this block (after input_register_device()) can go into open()
method for the input device.

> +
> + return 0;
> +}
> +
> +static void asus_ec_keys_remove(struct platform_device *pdev)
> +{
> + struct asus_ec_keys_data *priv = platform_get_drvdata(pdev);
> + struct asusec_core *ec = priv->ec;
> +
> + ec->ext_keys_enabled = false;
> + blocking_notifier_chain_unregister(&ec->notify_list, &priv->nb);

And this into close().

Thanks.

--
Dmitry