drivers/platform/x86/system76_acpi.c
Source file repositories/reference/linux-study-clean/drivers/platform/x86/system76_acpi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/x86/system76_acpi.c- Extension
.c- Size
- 19479 bytes
- Lines
- 833
- Domain
- Driver Families
- Bucket
- drivers/platform
- 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/acpi.hlinux/hwmon.hlinux/hwmon-sysfs.hlinux/init.hlinux/input.hlinux/kernel.hlinux/leds.hlinux/module.hlinux/pci_ids.hlinux/platform_device.hlinux/power_supply.hlinux/sysfs.hlinux/types.hacpi/battery.h
Detected Declarations
struct system76_dataenum kbled_typefunction system76_getfunction system76_get_indexfunction system76_get_objectfunction system76_setfunction battery_get_thresholdfunction battery_set_thresholdfunction charge_control_start_threshold_showfunction charge_control_start_threshold_storefunction charge_control_end_threshold_showfunction charge_control_end_threshold_storefunction system76_battery_addfunction system76_battery_removefunction system76_battery_initfunction system76_battery_exitfunction ap_led_getfunction ap_led_setfunction kb_led_getfunction kb_led_setfunction kb_led_color_showfunction kb_led_color_storefunction kb_led_notifyfunction kb_led_hotkey_hardwarefunction kb_led_hotkey_togglefunction kb_led_hotkey_downfunction kb_led_hotkey_upfunction kb_led_hotkey_colorfunction thermal_is_visiblefunction thermal_readfunction thermal_read_stringfunction input_keyfunction system76_notifyfunction system76_probefunction system76_remove
Annotated Snippet
struct system76_data {
struct acpi_device *acpi_dev;
struct led_classdev ap_led;
struct led_classdev kb_led;
enum led_brightness kb_brightness;
enum led_brightness kb_toggle_brightness;
int kb_color;
struct device *therm;
union acpi_object *nfan;
union acpi_object *ntmp;
struct input_dev *input;
bool has_open_ec;
enum kbled_type kbled_type;
};
static const struct acpi_device_id device_ids[] = {
{"17761776", 0},
{"", 0},
};
MODULE_DEVICE_TABLE(acpi, device_ids);
// Array of keyboard LED brightness levels
static const enum led_brightness kb_levels[] = {
48,
72,
96,
144,
192,
255
};
// Array of keyboard LED colors in 24-bit RGB format
static const int kb_colors[] = {
0xFFFFFF,
0x0000FF,
0xFF0000,
0xFF00FF,
0x00FF00,
0x00FFFF,
0xFFFF00
};
// Get a System76 ACPI device value by name
static int system76_get(struct system76_data *data, char *method)
{
acpi_handle handle;
acpi_status status;
unsigned long long ret = 0;
handle = acpi_device_handle(data->acpi_dev);
status = acpi_evaluate_integer(handle, method, NULL, &ret);
if (ACPI_SUCCESS(status))
return ret;
return -ENODEV;
}
// Get a System76 ACPI device value by name with index
static int system76_get_index(struct system76_data *data, char *method, int index)
{
union acpi_object obj;
struct acpi_object_list obj_list;
acpi_handle handle;
acpi_status status;
unsigned long long ret = 0;
obj.type = ACPI_TYPE_INTEGER;
obj.integer.value = index;
obj_list.count = 1;
obj_list.pointer = &obj;
handle = acpi_device_handle(data->acpi_dev);
status = acpi_evaluate_integer(handle, method, &obj_list, &ret);
if (ACPI_SUCCESS(status))
return ret;
return -ENODEV;
}
// Get a System76 ACPI device object by name
static int system76_get_object(struct system76_data *data, char *method, union acpi_object **obj)
{
acpi_handle handle;
acpi_status status;
struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER, NULL };
handle = acpi_device_handle(data->acpi_dev);
status = acpi_evaluate_object(handle, method, NULL, &buf);
if (ACPI_SUCCESS(status)) {
*obj = buf.pointer;
return 0;
}
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/hwmon.h`, `linux/hwmon-sysfs.h`, `linux/init.h`, `linux/input.h`, `linux/kernel.h`, `linux/leds.h`, `linux/module.h`.
- Detected declarations: `struct system76_data`, `enum kbled_type`, `function system76_get`, `function system76_get_index`, `function system76_get_object`, `function system76_set`, `function battery_get_threshold`, `function battery_set_threshold`, `function charge_control_start_threshold_show`, `function charge_control_start_threshold_store`.
- Atlas domain: Driver Families / drivers/platform.
- 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.