// SPDX-License-Identifier: GPL-2.0-only /* * Generic support for sparse keymaps * * Copyright (c) 2009 Dmitry Torokhov * * Derived from wistron button driver: * Copyright (C) 2005 Miloslav Trmac <[email protected]> * Copyright (C) 2005 Bernhard Rosenkraenzer <[email protected]> * Copyright (C) 2005 Dmitry Torokhov <[email protected]> */ #include <linux/input.h> #include <linux/input/sparse-keymap.h> #include <linux/module.h> #include <linux/slab.h> MODULE_AUTHOR(…) …; MODULE_DESCRIPTION(…) …; MODULE_LICENSE(…) …; static unsigned int sparse_keymap_get_key_index(struct input_dev *dev, const struct key_entry *k) { … } static struct key_entry *sparse_keymap_entry_by_index(struct input_dev *dev, unsigned int index) { … } /** * sparse_keymap_entry_from_scancode - perform sparse keymap lookup * @dev: Input device using sparse keymap * @code: Scan code * * This function is used to perform &struct key_entry lookup in an * input device using sparse keymap. */ struct key_entry *sparse_keymap_entry_from_scancode(struct input_dev *dev, unsigned int code) { … } EXPORT_SYMBOL(…); /** * sparse_keymap_entry_from_keycode - perform sparse keymap lookup * @dev: Input device using sparse keymap * @keycode: Key code * * This function is used to perform &struct key_entry lookup in an * input device using sparse keymap. */ struct key_entry *sparse_keymap_entry_from_keycode(struct input_dev *dev, unsigned int keycode) { … } EXPORT_SYMBOL(…); static struct key_entry *sparse_keymap_locate(struct input_dev *dev, const struct input_keymap_entry *ke) { … } static int sparse_keymap_getkeycode(struct input_dev *dev, struct input_keymap_entry *ke) { … } static int sparse_keymap_setkeycode(struct input_dev *dev, const struct input_keymap_entry *ke, unsigned int *old_keycode) { … } /** * sparse_keymap_setup - set up sparse keymap for an input device * @dev: Input device * @keymap: Keymap in form of array of &key_entry structures ending * with %KE_END type entry * @setup: Function that can be used to adjust keymap entries * depending on device's needs, may be %NULL * * The function calculates size and allocates copy of the original * keymap after which sets up input device event bits appropriately. * The allocated copy of the keymap is automatically freed when it * is no longer needed. */ int sparse_keymap_setup(struct input_dev *dev, const struct key_entry *keymap, int (*setup)(struct input_dev *, struct key_entry *)) { … } EXPORT_SYMBOL(…); /** * sparse_keymap_report_entry - report event corresponding to given key entry * @dev: Input device for which event should be reported * @ke: key entry describing event * @value: Value that should be reported (ignored by %KE_SW entries) * @autorelease: Signals whether release event should be emitted for %KE_KEY * entries right after reporting press event, ignored by all other * entries * * This function is used to report input event described by given * &struct key_entry. */ void sparse_keymap_report_entry(struct input_dev *dev, const struct key_entry *ke, unsigned int value, bool autorelease) { … } EXPORT_SYMBOL(…); /** * sparse_keymap_report_event - report event corresponding to given scancode * @dev: Input device using sparse keymap * @code: Scan code * @value: Value that should be reported (ignored by %KE_SW entries) * @autorelease: Signals whether release event should be emitted for %KE_KEY * entries right after reporting press event, ignored by all other * entries * * This function is used to perform lookup in an input device using sparse * keymap and report corresponding event. Returns %true if lookup was * successful and %false otherwise. */ bool sparse_keymap_report_event(struct input_dev *dev, unsigned int code, unsigned int value, bool autorelease) { … } EXPORT_SYMBOL(…);