drivers/input/keyboard/cros_ec_keyb.c
Source file repositories/reference/linux-study-clean/drivers/input/keyboard/cros_ec_keyb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/keyboard/cros_ec_keyb.c- Extension
.c- Size
- 25188 bytes
- Lines
- 948
- Domain
- Driver Families
- Bucket
- drivers/input
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/acpi.hlinux/bitops.hlinux/i2c.hlinux/input.hlinux/input/vivaldi-fmap.hlinux/interrupt.hlinux/kernel.hlinux/notifier.hlinux/platform_device.hlinux/slab.hlinux/sysrq.hlinux/input/matrix_keypad.hlinux/platform_data/cros_ec_commands.hlinux/platform_data/cros_ec_proto.hlinux/unaligned.h
Detected Declarations
struct cros_ec_keybstruct cros_ec_bs_mapfunction cros_ec_keyb_has_ghostingfunction cros_ec_emit_fn_keyfunction cros_ec_keyb_process_key_plainfunction cros_ec_keyb_process_key_fn_mapfunction cros_ec_keyb_process_colfunction cros_ec_keyb_processfunction cros_ec_keyb_report_bsfunction cros_ec_keyb_workfunction cros_ec_keyb_compute_valid_keysfunction cros_ec_keyb_infofunction cros_ec_keyb_query_switchesfunction cros_ec_keyb_resumefunction cros_ec_keyb_register_bsfunction cros_ec_keyb_parse_vivaldi_physmapfunction cros_ec_keyb_has_fn_keyfunction cros_ec_keyb_has_fn_mapfunction cros_ec_keyb_setkeycodefunction cros_ec_keyb_register_matrixfunction function_row_physmap_showfunction cros_ec_keyb_attr_is_visiblefunction cros_ec_keyb_probefunction cros_ec_keyb_remove
Annotated Snippet
struct cros_ec_keyb {
unsigned int rows;
unsigned int cols;
int row_shift;
bool ghost_filter;
u8 valid_keys[CROS_EC_KEYBOARD_COLS_MAX];
u8 old_kb_state[CROS_EC_KEYBOARD_COLS_MAX];
struct device *dev;
struct cros_ec_device *ec;
struct input_dev *idev;
struct input_dev *bs_idev;
struct notifier_block notifier;
struct vivaldi_data vdata;
bool has_fn_map;
bool fn_active;
bool fn_combo_active;
};
/**
* struct cros_ec_bs_map - Mapping between Linux keycodes and EC button/switch
* bitmap #defines
*
* @ev_type: The type of the input event to generate (e.g., EV_KEY).
* @code: A linux keycode
* @bit: A #define like EC_MKBP_POWER_BUTTON or EC_MKBP_LID_OPEN
* @inverted: If the #define and EV_SW have opposite meanings, this is true.
* Only applicable to switches.
*/
struct cros_ec_bs_map {
unsigned int ev_type;
unsigned int code;
u8 bit;
bool inverted;
};
/* cros_ec_keyb_bs - Map EC button/switch #defines into kernel ones */
static const struct cros_ec_bs_map cros_ec_keyb_bs[] = {
/* Buttons */
{
.ev_type = EV_KEY,
.code = KEY_POWER,
.bit = EC_MKBP_POWER_BUTTON,
},
{
.ev_type = EV_KEY,
.code = KEY_VOLUMEUP,
.bit = EC_MKBP_VOL_UP,
},
{
.ev_type = EV_KEY,
.code = KEY_VOLUMEDOWN,
.bit = EC_MKBP_VOL_DOWN,
},
{
.ev_type = EV_KEY,
.code = KEY_BRIGHTNESSUP,
.bit = EC_MKBP_BRI_UP,
},
{
.ev_type = EV_KEY,
.code = KEY_BRIGHTNESSDOWN,
.bit = EC_MKBP_BRI_DOWN,
},
{
.ev_type = EV_KEY,
.code = KEY_SCREENLOCK,
.bit = EC_MKBP_SCREEN_LOCK,
},
/* Switches */
{
.ev_type = EV_SW,
.code = SW_LID,
.bit = EC_MKBP_LID_OPEN,
.inverted = true,
},
{
.ev_type = EV_SW,
.code = SW_TABLET_MODE,
.bit = EC_MKBP_TABLET_MODE,
},
};
/*
* Returns true when there is at least one combination of pressed keys that
* results in ghosting.
Annotation
- Immediate include surface: `linux/module.h`, `linux/acpi.h`, `linux/bitops.h`, `linux/i2c.h`, `linux/input.h`, `linux/input/vivaldi-fmap.h`, `linux/interrupt.h`, `linux/kernel.h`.
- Detected declarations: `struct cros_ec_keyb`, `struct cros_ec_bs_map`, `function cros_ec_keyb_has_ghosting`, `function cros_ec_emit_fn_key`, `function cros_ec_keyb_process_key_plain`, `function cros_ec_keyb_process_key_fn_map`, `function cros_ec_keyb_process_col`, `function cros_ec_keyb_process`, `function cros_ec_keyb_report_bs`, `function cros_ec_keyb_work`.
- Atlas domain: Driver Families / drivers/input.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.