[alsa-devel] [PATCH 14/39] firewire-lib: Add handling output connection by CMP

Clemens Ladisch clemens at ladisch.de
Sun Mar 9 22:27:17 CET 2014


Takashi Sakamoto wrote:
> This patch adds some macros, codes with condition of direction and new functions
> to handle output connection. Once cmp_connection_init() is executed with its
> direction, CMP input and output connection can be handled by the same way.

> +++ b/sound/firewire/cmp.c
> +static unsigned long long get_offset(struct cmp_connection *c, bool master)
> +{
> +	unsigned long long offset = CSR_REGISTER_BASE;
> +
> +	if (!master) {
> +		if (c->direction == CMP_INPUT)
> +			offset += CSR_IPCR(c->pcr_index);
> +		else
> +			offset += CSR_OPCR(c->pcr_index);
> +	} else {
> +		if (c->direction == CMP_INPUT)
> +			offset += CSR_IMPR;
> +		else
> +			offset += CSR_OMPR;
> +	}
> +
> +	return offset;
> +}

This function is always used with a constant master parameter, and the
two branches don't really share much code.  Two functions would be simpler:

static u64 mpr_address(struct cmp_connection *c)
{
	if (c->direction == CMP_INPUT)
		return CSR_REGISTER_BASE + CSR_IMPR;
	else
		return CSR_REGISTER_BASE + CSR_OMPR;
}

static u64 pcr_address(struct cmp_connection *c)
{
	if (c->direction == CMP_INPUT)
		return CSR_REGISTER_BASE + CSR_IPCR(c->pcr_index);
	else
		return CSR_REGISTER_BASE + CSR_OPCR(c->pcr_index);
}


Regards,
Clemens


More information about the Alsa-devel mailing list