drivers/input/keyboard/lkkbd.c
Source file repositories/reference/linux-study-clean/drivers/input/keyboard/lkkbd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/keyboard/lkkbd.c- Extension
.c- Size
- 17628 bytes
- Lines
- 722
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/delay.hlinux/slab.hlinux/module.hlinux/interrupt.hlinux/input.hlinux/serio.hlinux/workqueue.h
Detected Declarations
struct lkkbdfunction volume_to_hwfunction lkkbd_detection_donefunction lkkbd_interruptfunction lkkbd_toggle_ledsfunction lkkbd_toggle_keyclickfunction lkkbd_eventfunction lkkbd_reinitfunction lkkbd_connectfunction lkkbd_disconnect
Annotated Snippet
struct lkkbd {
unsigned short keycode[LK_NUM_KEYCODES];
int ignore_bytes;
unsigned char id[LK_NUM_IGNORE_BYTES];
struct input_dev *dev;
struct serio *serio;
struct work_struct tq;
char name[64];
char phys[32];
char type;
int bell_volume;
int keyclick_volume;
int ctrlclick_volume;
};
#ifdef LKKBD_DEBUG
/*
* Responses from the keyboard and mapping back to their names.
*/
static struct {
unsigned char value;
unsigned char *name;
} lk_response[] = {
#define RESPONSE(x) { .value = (x), .name = #x, }
RESPONSE(LK_STUCK_KEY),
RESPONSE(LK_SELFTEST_FAILED),
RESPONSE(LK_ALL_KEYS_UP),
RESPONSE(LK_METRONOME),
RESPONSE(LK_OUTPUT_ERROR),
RESPONSE(LK_INPUT_ERROR),
RESPONSE(LK_KBD_LOCKED),
RESPONSE(LK_KBD_TEST_MODE_ACK),
RESPONSE(LK_PREFIX_KEY_DOWN),
RESPONSE(LK_MODE_CHANGE_ACK),
RESPONSE(LK_RESPONSE_RESERVED),
#undef RESPONSE
};
static unsigned char *response_name(unsigned char value)
{
int i;
for (i = 0; i < ARRAY_SIZE(lk_response); i++)
if (lk_response[i].value == value)
return lk_response[i].name;
return "<unknown>";
}
#endif /* LKKBD_DEBUG */
/*
* Calculate volume parameter byte for a given volume.
*/
static unsigned char volume_to_hw(int volume_percent)
{
unsigned char ret = 0;
if (volume_percent < 0)
volume_percent = 0;
if (volume_percent > 100)
volume_percent = 100;
if (volume_percent >= 0)
ret = 7;
if (volume_percent >= 13) /* 12.5 */
ret = 6;
if (volume_percent >= 25)
ret = 5;
if (volume_percent >= 38) /* 37.5 */
ret = 4;
if (volume_percent >= 50)
ret = 3;
if (volume_percent >= 63) /* 62.5 */
ret = 2; /* This is the default volume */
if (volume_percent >= 75)
ret = 1;
if (volume_percent >= 88) /* 87.5 */
ret = 0;
ret |= 0x80;
return ret;
}
static void lkkbd_detection_done(struct lkkbd *lk)
{
int i;
/*
* Reset setting for Compose key. Let Compose be KEY_COMPOSE.
Annotation
- Immediate include surface: `linux/delay.h`, `linux/slab.h`, `linux/module.h`, `linux/interrupt.h`, `linux/input.h`, `linux/serio.h`, `linux/workqueue.h`.
- Detected declarations: `struct lkkbd`, `function volume_to_hw`, `function lkkbd_detection_done`, `function lkkbd_interrupt`, `function lkkbd_toggle_leds`, `function lkkbd_toggle_keyclick`, `function lkkbd_event`, `function lkkbd_reinit`, `function lkkbd_connect`, `function lkkbd_disconnect`.
- Atlas domain: Driver Families / drivers/input.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.