sound/firewire/cmp.c
Source file repositories/reference/linux-study-clean/sound/firewire/cmp.c
File Facts
- System
- Linux kernel
- Corpus path
sound/firewire/cmp.c- Extension
.c- Size
- 8567 bytes
- Lines
- 352
- Domain
- Driver Families
- Bucket
- sound/firewire
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device.hlinux/firewire.hlinux/firewire-constants.hlinux/module.hlinux/sched.hlib.hiso-resources.hcmp.h
Detected Declarations
enum bus_reset_handlingfunction __printffunction mpr_addressfunction pcr_addressfunction pcr_modifyfunction cmp_connection_initfunction cmp_connection_check_usedfunction cmp_connection_destroyfunction cmp_connection_reservefunction cmp_connection_releasefunction ipcr_set_modifyfunction get_overhead_idfunction opcr_set_modifyfunction pcr_set_checkfunction resourcesfunction pcr_break_modifyfunction cmp_connection_breakexport cmp_connection_initexport cmp_connection_check_usedexport cmp_connection_destroyexport cmp_connection_reserveexport cmp_connection_releaseexport cmp_connection_establishexport cmp_connection_break
Annotated Snippet
if (err < 0) {
if (err == -EAGAIN &&
bus_reset_handling == SUCCEED_ON_BUS_RESET)
err = 0;
return err;
}
if (buffer[0] == old_arg) /* success? */
break;
if (check) {
err = check(c, buffer[0]);
if (err < 0)
return err;
}
}
c->last_pcr_value = buffer[1];
return 0;
}
/**
* cmp_connection_init - initializes a connection manager
* @c: the connection manager to initialize
* @unit: a unit of the target device
* @direction: input or output
* @pcr_index: the index of the iPCR/oPCR on the target device
*/
int cmp_connection_init(struct cmp_connection *c,
struct fw_unit *unit,
enum cmp_direction direction,
unsigned int pcr_index)
{
__be32 mpr_be;
u32 mpr;
int err;
c->direction = direction;
err = snd_fw_transaction(unit, TCODE_READ_QUADLET_REQUEST,
mpr_address(c), &mpr_be, 4, 0);
if (err < 0)
return err;
mpr = be32_to_cpu(mpr_be);
if (pcr_index >= (mpr & MPR_PLUGS_MASK))
return -EINVAL;
err = fw_iso_resources_init(&c->resources, unit);
if (err < 0)
return err;
c->connected = false;
mutex_init(&c->mutex);
c->last_pcr_value = cpu_to_be32(0x80000000);
c->pcr_index = pcr_index;
c->max_speed = (mpr & MPR_SPEED_MASK) >> MPR_SPEED_SHIFT;
if (c->max_speed == SCODE_BETA)
c->max_speed += (mpr & MPR_XSPEED_MASK) >> MPR_XSPEED_SHIFT;
return 0;
}
EXPORT_SYMBOL(cmp_connection_init);
/**
* cmp_connection_check_used - check connection is already esablished or not
* @c: the connection manager to be checked
* @used: the pointer to store the result of checking the connection
*/
int cmp_connection_check_used(struct cmp_connection *c, bool *used)
{
__be32 pcr;
int err;
err = snd_fw_transaction(
c->resources.unit, TCODE_READ_QUADLET_REQUEST,
pcr_address(c), &pcr, 4, 0);
if (err >= 0)
*used = !!(pcr & cpu_to_be32(PCR_BCAST_CONN |
PCR_P2P_CONN_MASK));
return err;
}
EXPORT_SYMBOL(cmp_connection_check_used);
/**
* cmp_connection_destroy - free connection manager resources
* @c: the connection manager
*/
void cmp_connection_destroy(struct cmp_connection *c)
Annotation
- Immediate include surface: `linux/device.h`, `linux/firewire.h`, `linux/firewire-constants.h`, `linux/module.h`, `linux/sched.h`, `lib.h`, `iso-resources.h`, `cmp.h`.
- Detected declarations: `enum bus_reset_handling`, `function __printf`, `function mpr_address`, `function pcr_address`, `function pcr_modify`, `function cmp_connection_init`, `function cmp_connection_check_used`, `function cmp_connection_destroy`, `function cmp_connection_reserve`, `function cmp_connection_release`.
- Atlas domain: Driver Families / sound/firewire.
- Implementation status: integration 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.