drivers/input/mouse/amimouse.c
Source file repositories/reference/linux-study-clean/drivers/input/mouse/amimouse.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/mouse/amimouse.c- Extension
.c- Size
- 3462 bytes
- Lines
- 151
- Domain
- Driver Families
- Bucket
- drivers/input
- 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.
- 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/init.hlinux/input.hlinux/interrupt.hlinux/platform_device.hasm/irq.hasm/setup.hlinux/uaccess.hasm/amigahw.hasm/amigaints.h
Detected Declarations
function amimouse_interruptfunction amimouse_openfunction amimouse_closefunction amimouse_probefunction amimouse_remove
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Amiga mouse driver for Linux/m68k
*
* Copyright (c) 2000-2002 Vojtech Pavlik
*
* Based on the work of:
* Michael Rausch James Banks
* Matther Dillon David Giller
* Nathan Laredo Linus Torvalds
* Johan Myreen Jes Sorensen
* Russell King
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/input.h>
#include <linux/interrupt.h>
#include <linux/platform_device.h>
#include <asm/irq.h>
#include <asm/setup.h>
#include <linux/uaccess.h>
#include <asm/amigahw.h>
#include <asm/amigaints.h>
MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
MODULE_DESCRIPTION("Amiga mouse driver");
MODULE_LICENSE("GPL");
static int amimouse_lastx, amimouse_lasty;
static irqreturn_t amimouse_interrupt(int irq, void *data)
{
struct input_dev *dev = data;
unsigned short joy0dat, potgor;
int nx, ny, dx, dy;
joy0dat = amiga_custom.joy0dat;
nx = joy0dat & 0xff;
ny = joy0dat >> 8;
dx = nx - amimouse_lastx;
dy = ny - amimouse_lasty;
if (dx < -127) dx = (256 + nx) - amimouse_lastx;
if (dx > 127) dx = (nx - 256) - amimouse_lastx;
if (dy < -127) dy = (256 + ny) - amimouse_lasty;
if (dy > 127) dy = (ny - 256) - amimouse_lasty;
amimouse_lastx = nx;
amimouse_lasty = ny;
potgor = amiga_custom.potgor;
input_report_rel(dev, REL_X, dx);
input_report_rel(dev, REL_Y, dy);
input_report_key(dev, BTN_LEFT, ciaa.pra & 0x40);
input_report_key(dev, BTN_MIDDLE, potgor & 0x0100);
input_report_key(dev, BTN_RIGHT, potgor & 0x0400);
input_sync(dev);
return IRQ_HANDLED;
}
static int amimouse_open(struct input_dev *dev)
{
unsigned short joy0dat;
int error;
joy0dat = amiga_custom.joy0dat;
amimouse_lastx = joy0dat & 0xff;
amimouse_lasty = joy0dat >> 8;
error = request_irq(IRQ_AMIGA_VERTB, amimouse_interrupt, 0, "amimouse",
dev);
if (error)
dev_err(&dev->dev, "Can't allocate irq %d\n", IRQ_AMIGA_VERTB);
return error;
}
static void amimouse_close(struct input_dev *dev)
{
free_irq(IRQ_AMIGA_VERTB, dev);
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/input.h`, `linux/interrupt.h`, `linux/platform_device.h`, `asm/irq.h`, `asm/setup.h`, `linux/uaccess.h`.
- Detected declarations: `function amimouse_interrupt`, `function amimouse_open`, `function amimouse_close`, `function amimouse_probe`, `function amimouse_remove`.
- Atlas domain: Driver Families / drivers/input.
- Implementation status: source implementation candidate.
- 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.