drivers/char/sonypi.c
Source file repositories/reference/linux-study-clean/drivers/char/sonypi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/char/sonypi.c- Extension
.c- Size
- 41336 bytes
- Lines
- 1548
- Domain
- Driver Families
- Bucket
- drivers/char
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/sched.hlinux/input.hlinux/pci.hlinux/init.hlinux/interrupt.hlinux/miscdevice.hlinux/poll.hlinux/delay.hlinux/wait.hlinux/acpi.hlinux/dmi.hlinux/err.hlinux/kfifo.hlinux/platform_device.hlinux/gfp.hlinux/string_choices.hlinux/uaccess.hasm/io.hlinux/sonypi.h
Detected Declarations
struct sonypi_ioport_liststruct sonypi_irq_liststruct sonypi_eventstruct sonypi_keypressfunction sonypi_ec_writefunction sonypi_ec_readfunction ec_read16function sonypi_type1_srsfunction sonypi_type2_srsfunction sonypi_type3_srsfunction sonypi_type1_disfunction sonypi_type2_disfunction sonypi_type3_disfunction sonypi_call1function sonypi_call2function sonypi_call3function sonypi_readfunction sonypi_setfunction sonypi_camera_readyfunction sonypi_camera_offfunction sonypi_camera_onfunction sonypi_setbluetoothpowerfunction input_keyreleasefunction sonypi_report_input_eventfunction sonypi_irqfunction sonypi_misc_fasyncfunction sonypi_misc_releasefunction sonypi_misc_openfunction sonypi_misc_readfunction sonypi_misc_pollfunction sonypi_misc_ioctlfunction sonypi_enablefunction sonypi_disablefunction sonypi_acpi_probefunction sonypi_acpi_removefunction sonypi_create_input_devicesfunction sonypi_setup_ioportsfunction sonypi_setup_irqfunction sonypi_display_infofunction sonypi_probefunction sonypi_removefunction sonypi_suspendfunction sonypi_resumefunction sonypi_shutdownfunction sonypi_initfunction sonypi_exitmodule init sonypi_init
Annotated Snippet
static const struct file_operations sonypi_misc_fops = {
.owner = THIS_MODULE,
.read = sonypi_misc_read,
.poll = sonypi_misc_poll,
.open = sonypi_misc_open,
.release = sonypi_misc_release,
.fasync = sonypi_misc_fasync,
.unlocked_ioctl = sonypi_misc_ioctl,
};
static struct miscdevice sonypi_misc_device = {
.minor = MISC_DYNAMIC_MINOR,
.name = "sonypi",
.fops = &sonypi_misc_fops,
};
static void sonypi_enable(unsigned int camera_on)
{
switch (sonypi_device.model) {
case SONYPI_DEVICE_MODEL_TYPE1:
sonypi_type1_srs();
break;
case SONYPI_DEVICE_MODEL_TYPE2:
sonypi_type2_srs();
break;
case SONYPI_DEVICE_MODEL_TYPE3:
sonypi_type3_srs();
break;
}
sonypi_call1(0x82);
sonypi_call2(0x81, 0xff);
sonypi_call1(compat ? 0x92 : 0x82);
/* Enable ACPI mode to get Fn key events */
if (!SONYPI_ACPI_ACTIVE && fnkeyinit)
outb(0xf0, 0xb2);
if (camera && camera_on)
sonypi_camera_on();
}
static int sonypi_disable(void)
{
sonypi_call2(0x81, 0); /* make sure we don't get any more events */
if (camera)
sonypi_camera_off();
/* disable ACPI mode */
if (!SONYPI_ACPI_ACTIVE && fnkeyinit)
outb(0xf1, 0xb2);
switch (sonypi_device.model) {
case SONYPI_DEVICE_MODEL_TYPE1:
sonypi_type1_dis();
break;
case SONYPI_DEVICE_MODEL_TYPE2:
sonypi_type2_dis();
break;
case SONYPI_DEVICE_MODEL_TYPE3:
sonypi_type3_dis();
break;
}
return 0;
}
#ifdef CONFIG_ACPI
static int sonypi_acpi_probe(struct platform_device *pdev)
{
struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
sonypi_acpi_device = device;
strcpy(acpi_device_name(device), "Sony laptop hotkeys");
strcpy(acpi_device_class(device), "sony/hotkey");
return 0;
}
static void sonypi_acpi_remove(struct platform_device *pdev)
{
sonypi_acpi_device = NULL;
}
static const struct acpi_device_id sonypi_device_ids[] = {
{"SNY6001", 0},
{"", 0},
};
static struct platform_driver sonypi_acpi_driver = {
.probe = sonypi_acpi_probe,
Annotation
- Immediate include surface: `linux/module.h`, `linux/sched.h`, `linux/input.h`, `linux/pci.h`, `linux/init.h`, `linux/interrupt.h`, `linux/miscdevice.h`, `linux/poll.h`.
- Detected declarations: `struct sonypi_ioport_list`, `struct sonypi_irq_list`, `struct sonypi_event`, `struct sonypi_keypress`, `function sonypi_ec_write`, `function sonypi_ec_read`, `function ec_read16`, `function sonypi_type1_srs`, `function sonypi_type2_srs`, `function sonypi_type3_srs`.
- Atlas domain: Driver Families / drivers/char.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.