drivers/staging/nvec/nvec_kbd.c
Source file repositories/reference/linux-study-clean/drivers/staging/nvec/nvec_kbd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/nvec/nvec_kbd.c- Extension
.c- Size
- 4545 bytes
- Lines
- 190
- Domain
- Driver Families
- Bucket
- drivers/staging
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/slab.hlinux/input.hlinux/delay.hlinux/platform_device.hnvec-keytable.hnvec.h
Detected Declarations
struct nvec_keysenum kbd_subcmdsfunction nvec_kbd_toggle_ledfunction nvec_keys_notifierfunction nvec_kbd_eventfunction nvec_kbd_probefunction nvec_kbd_remove
Annotated Snippet
struct nvec_keys {
struct input_dev *input;
struct notifier_block notifier;
struct nvec_chip *nvec;
bool caps_lock;
};
static struct nvec_keys keys_dev;
static void nvec_kbd_toggle_led(void)
{
char buf[] = { NVEC_KBD, SET_LEDS, 0 };
keys_dev.caps_lock = !keys_dev.caps_lock;
if (keys_dev.caps_lock)
/* should be BIT(0) only, firmware bug? */
buf[2] = BIT(0) | BIT(1) | BIT(2);
nvec_write_async(keys_dev.nvec, buf, sizeof(buf));
}
static int nvec_keys_notifier(struct notifier_block *nb,
unsigned long event_type, void *data)
{
int code, state;
unsigned char *msg = data;
if (event_type == NVEC_KB_EVT) {
int _size = (msg[0] & (3 << 5)) >> 5;
/* power on/off button */
if (_size == NVEC_VAR_SIZE)
return NOTIFY_STOP;
if (_size == NVEC_3BYTES)
msg++;
code = msg[1] & 0x7f;
state = msg[1] & 0x80;
if (code_tabs[_size][code] == KEY_CAPSLOCK && state)
nvec_kbd_toggle_led();
input_report_key(keys_dev.input, code_tabs[_size][code],
!state);
input_sync(keys_dev.input);
return NOTIFY_STOP;
}
return NOTIFY_DONE;
}
static int nvec_kbd_event(struct input_dev *dev, unsigned int type,
unsigned int code, int value)
{
struct nvec_chip *nvec = keys_dev.nvec;
char buf[] = { NVEC_KBD, SET_LEDS, 0 };
if (type == EV_REP)
return 0;
if (type != EV_LED)
return -1;
if (code != LED_CAPSL)
return -1;
buf[2] = !!value;
nvec_write_async(nvec, buf, sizeof(buf));
return 0;
}
static int nvec_kbd_probe(struct platform_device *pdev)
{
struct nvec_chip *nvec = dev_get_drvdata(pdev->dev.parent);
int i, j, err;
struct input_dev *idev;
char clear_leds[] = { NVEC_KBD, SET_LEDS, 0 },
enable_kbd[] = { NVEC_KBD, ENABLE_KBD },
cnfg_wake[] = { NVEC_KBD, CNFG_WAKE, true, true },
cnfg_wake_key_reporting[] = { NVEC_KBD, CNFG_WAKE_KEY_REPORTING,
true };
j = 0;
for (i = 0; i < ARRAY_SIZE(code_tab_102us); ++i)
keycodes[j++] = code_tab_102us[i];
Annotation
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `linux/input.h`, `linux/delay.h`, `linux/platform_device.h`, `nvec-keytable.h`, `nvec.h`.
- Detected declarations: `struct nvec_keys`, `enum kbd_subcmds`, `function nvec_kbd_toggle_led`, `function nvec_keys_notifier`, `function nvec_kbd_event`, `function nvec_kbd_probe`, `function nvec_kbd_remove`.
- Atlas domain: Driver Families / drivers/staging.
- 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.