drivers/platform/surface/surfacepro3_button.c
Source file repositories/reference/linux-study-clean/drivers/platform/surface/surfacepro3_button.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/surface/surfacepro3_button.c- Extension
.c- Size
- 7823 bytes
- Lines
- 278
- 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/kernel.hlinux/module.hlinux/init.hlinux/string.hlinux/types.hlinux/input.hlinux/acpi.hlinux/platform_device.hacpi/button.h
Detected Declarations
struct surface_buttonfunction surface_button_notifyfunction surface_button_suspendfunction surface_button_resumefunction IDfunction surface_button_probefunction surface_button_remove
Annotated Snippet
struct surface_button {
unsigned int type;
struct input_dev *input;
char phys[32]; /* for input device */
unsigned long pushed;
bool suspended;
};
static void surface_button_notify(acpi_handle handle, u32 event, void *data)
{
struct device *dev = data;
struct surface_button *button = dev_get_drvdata(dev);
struct input_dev *input;
int key_code = KEY_RESERVED;
bool pressed = false;
switch (event) {
/* Power button press,release handle */
case SURFACE_BUTTON_NOTIFY_PRESS_POWER:
pressed = true;
fallthrough;
case SURFACE_BUTTON_NOTIFY_RELEASE_POWER:
key_code = KEY_POWER;
break;
/* Home button press,release handle */
case SURFACE_BUTTON_NOTIFY_PRESS_HOME:
pressed = true;
fallthrough;
case SURFACE_BUTTON_NOTIFY_RELEASE_HOME:
key_code = KEY_LEFTMETA;
break;
/* Volume up button press,release handle */
case SURFACE_BUTTON_NOTIFY_PRESS_VOLUME_UP:
pressed = true;
fallthrough;
case SURFACE_BUTTON_NOTIFY_RELEASE_VOLUME_UP:
key_code = KEY_VOLUMEUP;
break;
/* Volume down button press,release handle */
case SURFACE_BUTTON_NOTIFY_PRESS_VOLUME_DOWN:
pressed = true;
fallthrough;
case SURFACE_BUTTON_NOTIFY_RELEASE_VOLUME_DOWN:
key_code = KEY_VOLUMEDOWN;
break;
case SURFACE_BUTTON_NOTIFY_TABLET_MODE:
dev_warn_once(dev, "Tablet mode is not supported\n");
break;
default:
dev_info_ratelimited(dev, "Unsupported event [0x%x]\n", event);
break;
}
input = button->input;
if (key_code == KEY_RESERVED)
return;
if (pressed)
pm_wakeup_dev_event(dev, 0, button->suspended);
if (button->suspended)
return;
input_report_key(input, key_code, pressed?1:0);
input_sync(input);
}
#ifdef CONFIG_PM_SLEEP
static int surface_button_suspend(struct device *dev)
{
struct surface_button *button = dev_get_drvdata(dev);
button->suspended = true;
return 0;
}
static int surface_button_resume(struct device *dev)
{
struct surface_button *button = dev_get_drvdata(dev);
button->suspended = false;
return 0;
}
#endif
/*
* Surface Pro 4 and Surface Book 2 / Surface Pro 2017 use the same device
* ID (MSHW0040) for the power/volume buttons. Make sure this is the right
* device by checking for the _DSM method and OEM Platform Revision.
*
* Returns true if the driver should bind to this device, i.e. the device is
* either MSWH0028 (Pro 3) or MSHW0040 on a Pro 4 or Book 1.
*/
static bool surface_button_check_MSHW0040(struct device *dev, acpi_handle handle)
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/init.h`, `linux/string.h`, `linux/types.h`, `linux/input.h`, `linux/acpi.h`, `linux/platform_device.h`.
- Detected declarations: `struct surface_button`, `function surface_button_notify`, `function surface_button_suspend`, `function surface_button_resume`, `function ID`, `function surface_button_probe`, `function surface_button_remove`.
- 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.