drivers/media/rc/xbox_remote.c
Source file repositories/reference/linux-study-clean/drivers/media/rc/xbox_remote.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/rc/xbox_remote.c- Extension
.c- Size
- 8152 bytes
- Lines
- 313
- Domain
- Driver Families
- Bucket
- drivers/media
- 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/slab.hlinux/module.hlinux/usb/input.hmedia/rc-core.h
Detected Declarations
struct xbox_remotefunction xbox_remote_rc_openfunction xbox_remote_rc_closefunction xbox_remote_input_reportfunction xbox_remote_irq_infunction xbox_remote_rc_initfunction xbox_remote_initializefunction xbox_remote_probefunction xbox_remote_disconnect
Annotated Snippet
struct xbox_remote {
struct rc_dev *rdev;
struct usb_device *udev;
struct usb_interface *interface;
struct urb *irq_urb;
u8 *inbuf;
char rc_name[NAME_BUFSIZE];
char rc_phys[NAME_BUFSIZE];
};
static int xbox_remote_rc_open(struct rc_dev *rdev)
{
struct xbox_remote *xbox_remote = rdev->priv;
/* On first open, submit the read urb which was set up previously. */
xbox_remote->irq_urb->dev = xbox_remote->udev;
if (usb_submit_urb(xbox_remote->irq_urb, GFP_KERNEL)) {
dev_err(&xbox_remote->interface->dev,
"%s: usb_submit_urb failed!\n", __func__);
return -EIO;
}
return 0;
}
static void xbox_remote_rc_close(struct rc_dev *rdev)
{
struct xbox_remote *xbox_remote = rdev->priv;
usb_kill_urb(xbox_remote->irq_urb);
}
/*
* xbox_remote_report_input
*/
static void xbox_remote_input_report(struct urb *urb)
{
struct xbox_remote *xbox_remote = urb->context;
unsigned char *data = xbox_remote->inbuf;
/*
* data[0] = 0x00
* data[1] = length - always 0x06
* data[2] = the key code
* data[3] = high part of key code
* data[4] = last_press_ms (low)
* data[5] = last_press_ms (high)
*/
/* Deal with strange looking inputs */
if (urb->actual_length != 6 || urb->actual_length != data[1]) {
dev_warn(&urb->dev->dev, "Weird data, len=%d: %*ph\n",
urb->actual_length, urb->actual_length, data);
return;
}
rc_keydown(xbox_remote->rdev, RC_PROTO_XBOX_DVD,
le16_to_cpup((__le16 *)(data + 2)), 0);
}
/*
* xbox_remote_irq_in
*/
static void xbox_remote_irq_in(struct urb *urb)
{
struct xbox_remote *xbox_remote = urb->context;
int retval;
switch (urb->status) {
case 0: /* success */
xbox_remote_input_report(urb);
break;
case -ECONNRESET: /* unlink */
case -ENOENT:
case -ESHUTDOWN:
dev_dbg(&xbox_remote->interface->dev,
"%s: urb error status, unlink?\n",
__func__);
return;
default: /* error */
dev_dbg(&xbox_remote->interface->dev,
"%s: Nonzero urb status %d\n",
__func__, urb->status);
}
retval = usb_submit_urb(urb, GFP_ATOMIC);
if (retval)
dev_err(&xbox_remote->interface->dev,
Annotation
- Immediate include surface: `linux/slab.h`, `linux/module.h`, `linux/usb/input.h`, `media/rc-core.h`.
- Detected declarations: `struct xbox_remote`, `function xbox_remote_rc_open`, `function xbox_remote_rc_close`, `function xbox_remote_input_report`, `function xbox_remote_irq_in`, `function xbox_remote_rc_init`, `function xbox_remote_initialize`, `function xbox_remote_probe`, `function xbox_remote_disconnect`.
- Atlas domain: Driver Families / drivers/media.
- 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.