drivers/hid/hid-corsair.c
Source file repositories/reference/linux-study-clean/drivers/hid/hid-corsair.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hid/hid-corsair.c- Extension
.c- Size
- 18874 bytes
- Lines
- 757
- Domain
- Driver Families
- Bucket
- drivers/hid
- 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/hid.hlinux/module.hlinux/usb.hlinux/leds.hhid-ids.h
Detected Declarations
struct k90_ledstruct k90_drvdatastruct corsair_drvdatafunction corsair_usage_to_gkeyfunction k90_backlight_getfunction k90_record_led_getfunction k90_brightness_setfunction k90_backlight_workfunction k90_record_led_workfunction k90_show_macro_modefunction k90_store_macro_modefunction k90_show_current_profilefunction k90_store_current_profilefunction k90_init_backlightfunction k90_init_macro_functionsfunction k90_cleanup_backlightfunction k90_cleanup_macro_functionsfunction corsair_probefunction corsair_removefunction corsair_eventfunction corsair_input_mappingfunction Page
Annotated Snippet
struct k90_led {
struct led_classdev cdev;
int brightness;
struct work_struct work;
bool removed;
};
struct k90_drvdata {
struct k90_led record_led;
};
struct corsair_drvdata {
unsigned long quirks;
struct k90_drvdata *k90;
struct k90_led *backlight;
};
#define K90_GKEY_COUNT 18
static int corsair_usage_to_gkey(unsigned int usage)
{
/* G1 (0xd0) to G16 (0xdf) */
if (usage >= 0xd0 && usage <= 0xdf)
return usage - 0xd0 + 1;
/* G17 (0xe8) to G18 (0xe9) */
if (usage >= 0xe8 && usage <= 0xe9)
return usage - 0xe8 + 17;
return 0;
}
static unsigned short corsair_gkey_map[K90_GKEY_COUNT] = {
BTN_TRIGGER_HAPPY1,
BTN_TRIGGER_HAPPY2,
BTN_TRIGGER_HAPPY3,
BTN_TRIGGER_HAPPY4,
BTN_TRIGGER_HAPPY5,
BTN_TRIGGER_HAPPY6,
BTN_TRIGGER_HAPPY7,
BTN_TRIGGER_HAPPY8,
BTN_TRIGGER_HAPPY9,
BTN_TRIGGER_HAPPY10,
BTN_TRIGGER_HAPPY11,
BTN_TRIGGER_HAPPY12,
BTN_TRIGGER_HAPPY13,
BTN_TRIGGER_HAPPY14,
BTN_TRIGGER_HAPPY15,
BTN_TRIGGER_HAPPY16,
BTN_TRIGGER_HAPPY17,
BTN_TRIGGER_HAPPY18,
};
module_param_array_named(gkey_codes, corsair_gkey_map, ushort, NULL, S_IRUGO);
MODULE_PARM_DESC(gkey_codes, "Key codes for the G-keys");
static unsigned short corsair_record_keycodes[2] = {
BTN_TRIGGER_HAPPY19,
BTN_TRIGGER_HAPPY20
};
module_param_array_named(recordkey_codes, corsair_record_keycodes, ushort,
NULL, S_IRUGO);
MODULE_PARM_DESC(recordkey_codes, "Key codes for the MR (start and stop record) button");
static unsigned short corsair_profile_keycodes[3] = {
BTN_TRIGGER_HAPPY21,
BTN_TRIGGER_HAPPY22,
BTN_TRIGGER_HAPPY23
};
module_param_array_named(profilekey_codes, corsair_profile_keycodes, ushort,
NULL, S_IRUGO);
MODULE_PARM_DESC(profilekey_codes, "Key codes for the profile buttons");
#define CORSAIR_USAGE_SPECIAL_MIN 0xf0
#define CORSAIR_USAGE_SPECIAL_MAX 0xff
#define CORSAIR_USAGE_MACRO_RECORD_START 0xf6
#define CORSAIR_USAGE_MACRO_RECORD_STOP 0xf7
#define CORSAIR_USAGE_PROFILE 0xf1
#define CORSAIR_USAGE_M1 0xf1
#define CORSAIR_USAGE_M2 0xf2
#define CORSAIR_USAGE_M3 0xf3
#define CORSAIR_USAGE_PROFILE_MAX 0xf3
#define CORSAIR_USAGE_META_OFF 0xf4
#define CORSAIR_USAGE_META_ON 0xf5
#define CORSAIR_USAGE_LIGHT 0xfa
#define CORSAIR_USAGE_LIGHT_OFF 0xfa
Annotation
- Immediate include surface: `linux/hid.h`, `linux/module.h`, `linux/usb.h`, `linux/leds.h`, `hid-ids.h`.
- Detected declarations: `struct k90_led`, `struct k90_drvdata`, `struct corsair_drvdata`, `function corsair_usage_to_gkey`, `function k90_backlight_get`, `function k90_record_led_get`, `function k90_brightness_set`, `function k90_backlight_work`, `function k90_record_led_work`, `function k90_show_macro_mode`.
- Atlas domain: Driver Families / drivers/hid.
- 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.