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.

Dependency Surface

Detected Declarations

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

Implementation Notes