drivers/media/rc/rc-main.c
Source file repositories/reference/linux-study-clean/drivers/media/rc/rc-main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/rc/rc-main.c- Extension
.c- Size
- 54657 bytes
- Lines
- 2093
- Domain
- Driver Families
- Bucket
- drivers/media
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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
media/rc-core.hlinux/bsearch.hlinux/spinlock.hlinux/delay.hlinux/input.hlinux/leds.hlinux/slab.hlinux/idr.hlinux/device.hlinux/module.hrc-core-priv.h
Detected Declarations
struct rc_filter_attributefunction rc_map_registerfunction rc_map_unregisterfunction scancode_to_u64function ir_create_tablefunction ir_free_tablefunction ir_resize_tablefunction ir_update_mappingfunction ir_establish_scancodefunction ir_setkeycodefunction ir_setkeytablefunction rc_map_cmpfunction ir_lookup_by_scancodefunction ir_getkeycodefunction rc_g_keycode_from_tablefunction ir_do_keyupfunction rc_keyupfunction ir_timer_keyupfunction ir_timer_repeatfunction repeat_periodfunction rc_repeatfunction ir_do_keydownfunction rc_keydownfunction rc_keydown_notimeoutfunction rc_validate_scancodefunction rc_validate_filterfunction rc_openfunction ir_openfunction rc_closefunction ir_closefunction show_protocolsfunction parse_protocol_changefunction ir_raw_load_modulesfunction store_protocolsfunction protocolfunction show_filterfunction store_filterfunction show_wakeup_protocolsfunction store_wakeup_protocolsfunction rc_dev_releasefunction rc_dev_ueventfunction rc_free_devicefunction devm_rc_alloc_releasefunction rc_prepare_rx_devicefunction rc_setup_rx_devicefunction rc_free_rx_devicefunction rc_register_devicefunction rc_open
Annotated Snippet
rc = device_add(&dev->dev);
if (rc)
goto out_rx_free;
path = kobject_get_path(&dev->dev.kobj, GFP_KERNEL);
dev_info(&dev->dev, "%s as %s\n",
dev->device_name ?: "Unspecified device", path ?: "N/A");
kfree(path);
/*
* once the input device is registered in rc_setup_rx_device,
* userspace can open the input device and rc_open() will be called
* as a result. This results in driver code being allowed to submit
* keycodes with rc_keydown, so lirc must be registered first.
*/
if (dev->allowed_protocols != RC_PROTO_BIT_CEC) {
rc = lirc_register(dev);
if (rc < 0)
goto out_dev;
}
if (dev->driver_type != RC_DRIVER_IR_RAW_TX) {
rc = rc_setup_rx_device(dev);
if (rc)
goto out_lirc;
}
if (dev->driver_type == RC_DRIVER_IR_RAW) {
rc = ir_raw_event_register(dev);
if (rc < 0)
goto out_rx;
}
dev_dbg(&dev->dev, "Registered rc%u (driver: %s)\n", dev->minor,
dev->driver_name ? dev->driver_name : "unknown");
return 0;
out_rx:
rc_free_rx_device(dev);
out_lirc:
if (dev->allowed_protocols != RC_PROTO_BIT_CEC)
lirc_unregister(dev);
out_dev:
device_del(&dev->dev);
out_rx_free:
ir_free_table(&dev->rc_map);
out_raw:
ir_raw_event_free(dev);
out_minor:
ida_free(&rc_ida, minor);
return rc;
}
EXPORT_SYMBOL_GPL(rc_register_device);
static void devm_rc_release(struct device *dev, void *res)
{
rc_unregister_device(*(struct rc_dev **)res);
}
int devm_rc_register_device(struct device *parent, struct rc_dev *dev)
{
struct rc_dev **dr;
int ret;
dr = devres_alloc(devm_rc_release, sizeof(*dr), GFP_KERNEL);
if (!dr)
return -ENOMEM;
ret = rc_register_device(dev);
if (ret) {
devres_free(dr);
return ret;
}
*dr = dev;
devres_add(parent, dr);
return 0;
}
EXPORT_SYMBOL_GPL(devm_rc_register_device);
void rc_unregister_device(struct rc_dev *dev)
{
if (!dev)
return;
if (dev->driver_type == RC_DRIVER_IR_RAW)
ir_raw_event_unregister(dev);
Annotation
- Immediate include surface: `media/rc-core.h`, `linux/bsearch.h`, `linux/spinlock.h`, `linux/delay.h`, `linux/input.h`, `linux/leds.h`, `linux/slab.h`, `linux/idr.h`.
- Detected declarations: `struct rc_filter_attribute`, `function rc_map_register`, `function rc_map_unregister`, `function scancode_to_u64`, `function ir_create_table`, `function ir_free_table`, `function ir_resize_table`, `function ir_update_mapping`, `function ir_establish_scancode`, `function ir_setkeycode`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.