drivers/hid/hid-apple.c
Source file repositories/reference/linux-study-clean/drivers/hid/hid-apple.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hid/hid-apple.c- Extension
.c- Size
- 43504 bytes
- Lines
- 1247
- 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/device.hlinux/hid.hlinux/jiffies.hlinux/module.hlinux/slab.hlinux/timer.hlinux/string.hlinux/leds.hdt-bindings/leds/common.hhid-ids.h
Detected Declarations
struct apple_non_apple_keyboardstruct apple_sc_backlightstruct apple_backlight_config_reportstruct apple_backlight_set_reportstruct apple_magic_backlightstruct apple_scstruct apple_key_translationfunction apple_is_non_apple_keyboardfunction apple_is_omoton_kb066function apple_setup_key_translationfunction input_event_with_scancodefunction hidinput_apple_eventfunction apple_eventfunction apple_fetch_batteryfunction apple_battery_timer_tickfunction apple_setup_inputfunction apple_input_mappingfunction apple_input_mappedfunction apple_input_configuredfunction apple_backlight_check_supportfunction list_for_each_entryfunction apple_backlight_setfunction apple_backlight_led_setfunction apple_backlight_initfunction apple_magic_backlight_report_setfunction apple_magic_backlight_setfunction apple_magic_backlight_led_setfunction apple_magic_backlight_initfunction apple_probefunction apple_remove
Annotated Snippet
struct apple_non_apple_keyboard {
char *name;
};
struct apple_sc_backlight {
struct led_classdev cdev;
struct hid_device *hdev;
};
struct apple_backlight_config_report {
u8 report_id;
u8 version;
u16 backlight_off, backlight_on_min, backlight_on_max;
};
struct apple_backlight_set_report {
u8 report_id;
u8 version;
u16 backlight;
u16 rate;
};
struct apple_magic_backlight {
struct led_classdev cdev;
struct hid_report *brightness;
struct hid_report *power;
};
struct apple_sc {
struct hid_device *hdev;
unsigned long quirks;
unsigned int fn_on;
unsigned int fn_found;
DECLARE_BITMAP(pressed_numlock, KEY_CNT);
struct timer_list battery_timer;
struct apple_sc_backlight *backlight;
};
struct apple_key_translation {
u16 from;
u16 to;
unsigned long flags;
};
static const struct apple_key_translation magic_keyboard_alu_fn_keys[] = {
{ KEY_BACKSPACE, KEY_DELETE },
{ KEY_ENTER, KEY_INSERT },
{ KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
{ KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
{ KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY },
{ KEY_F4, KEY_DASHBOARD, APPLE_FLAG_FKEY },
{ KEY_F6, KEY_NUMLOCK, APPLE_FLAG_FKEY },
{ KEY_F7, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY },
{ KEY_F8, KEY_PLAYPAUSE, APPLE_FLAG_FKEY },
{ KEY_F9, KEY_NEXTSONG, APPLE_FLAG_FKEY },
{ KEY_F10, KEY_MUTE, APPLE_FLAG_FKEY },
{ KEY_F11, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
{ KEY_F12, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
{ KEY_UP, KEY_PAGEUP },
{ KEY_DOWN, KEY_PAGEDOWN },
{ KEY_LEFT, KEY_HOME },
{ KEY_RIGHT, KEY_END },
{ }
};
static const struct apple_key_translation magic_keyboard_2015_fn_keys[] = {
{ KEY_BACKSPACE, KEY_DELETE },
{ KEY_ENTER, KEY_INSERT },
{ KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
{ KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
{ KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY },
{ KEY_F4, KEY_DASHBOARD, APPLE_FLAG_FKEY },
{ KEY_F7, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY },
{ KEY_F8, KEY_PLAYPAUSE, APPLE_FLAG_FKEY },
{ KEY_F9, KEY_NEXTSONG, APPLE_FLAG_FKEY },
{ KEY_F10, KEY_MUTE, APPLE_FLAG_FKEY },
{ KEY_F11, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
{ KEY_F12, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
{ KEY_UP, KEY_PAGEUP },
{ KEY_DOWN, KEY_PAGEDOWN },
{ KEY_LEFT, KEY_HOME },
{ KEY_RIGHT, KEY_END },
{ }
};
static const struct apple_key_translation magic_keyboard_2021_and_2024_fn_keys[] = {
{ KEY_BACKSPACE, KEY_DELETE },
{ KEY_ENTER, KEY_INSERT },
{ KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
{ KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
Annotation
- Immediate include surface: `linux/device.h`, `linux/hid.h`, `linux/jiffies.h`, `linux/module.h`, `linux/slab.h`, `linux/timer.h`, `linux/string.h`, `linux/leds.h`.
- Detected declarations: `struct apple_non_apple_keyboard`, `struct apple_sc_backlight`, `struct apple_backlight_config_report`, `struct apple_backlight_set_report`, `struct apple_magic_backlight`, `struct apple_sc`, `struct apple_key_translation`, `function apple_is_non_apple_keyboard`, `function apple_is_omoton_kb066`, `function apple_setup_key_translation`.
- 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.