sound/firewire/motu/motu-protocol-v2.c

Source file repositories/reference/linux-study-clean/sound/firewire/motu/motu-protocol-v2.c

File Facts

System
Linux kernel
Corpus path
sound/firewire/motu/motu-protocol-v2.c
Extension
.c
Size
8541 bytes
Lines
322
Domain
Driver Families
Bucket
sound/firewire
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.

Dependency Surface

Detected Declarations

Annotated Snippet

if (motu->spec == &snd_motu_spec_896hd) {
			*src = SND_MOTU_CLOCK_SOURCE_AESEBU_ON_XLR;
		} else if (!support_iec60958_on_opt) {
			*src = SND_MOTU_CLOCK_SOURCE_SPDIF_ON_COAX;
		} else {
			__be32 reg;

			// To check the configuration of optical interface.
			int err = snd_motu_transaction_read(motu, V2_IN_OUT_CONF_OFFSET, &reg,
							    sizeof(reg));
			if (err < 0)
				return err;

			if (((data & V2_OPT_IN_IFACE_MASK) >> V2_OPT_IN_IFACE_SHIFT) ==
			    V2_OPT_IFACE_MODE_SPDIF)
				*src = SND_MOTU_CLOCK_SOURCE_SPDIF_ON_OPT;
			else
				*src = SND_MOTU_CLOCK_SOURCE_SPDIF_ON_COAX;
		}
		break;
	}
	case V2_CLOCK_SRC_SPH:
		*src = SND_MOTU_CLOCK_SOURCE_SPH;
		break;
	case V2_CLOCK_SRC_WORD_ON_BNC:
		*src = SND_MOTU_CLOCK_SOURCE_WORD_ON_BNC;
		break;
	case V2_CLOCK_SRC_ADAT_ON_DSUB:
		*src = SND_MOTU_CLOCK_SOURCE_ADAT_ON_DSUB;
		break;
	case V2_CLOCK_SRC_AESEBU_ON_XLR:
		// For Traveler.
		*src = SND_MOTU_CLOCK_SOURCE_AESEBU_ON_XLR;
		break;
	default:
		*src = SND_MOTU_CLOCK_SOURCE_UNKNOWN;
		break;
	}

	return 0;
}

int snd_motu_protocol_v2_get_clock_source(struct snd_motu *motu,
					  enum snd_motu_clock_source *src)
{
	__be32 reg;
	int err;

	err = snd_motu_transaction_read(motu, V2_CLOCK_STATUS_OFFSET, &reg,
					sizeof(reg));
	if (err < 0)
		return err;

	return get_clock_source(motu, be32_to_cpu(reg), src);
}

// Expected for Traveler, which implements Altera Cyclone EP1C3.
static int switch_fetching_mode_cyclone(struct snd_motu *motu, u32 *data,
					bool enable)
{
	*data |= V2_CLOCK_MODEL_SPECIFIC;

	return 0;
}

// For UltraLite and 8pre, which implements Xilinx Spartan XC3S200.
static int switch_fetching_mode_spartan(struct snd_motu *motu, u32 *data,
					bool enable)
{
	unsigned int rate;
	enum snd_motu_clock_source src;
	int err;

	err = get_clock_source(motu, *data, &src);
	if (err < 0)
		return err;

	err = get_clock_rate(*data, &rate);
	if (err < 0)
		return err;

	if (src == SND_MOTU_CLOCK_SOURCE_SPH && rate > 48000)
		*data |= V2_CLOCK_MODEL_SPECIFIC;

	return 0;
}

int snd_motu_protocol_v2_switch_fetching_mode(struct snd_motu *motu,
					      bool enable)
{

Annotation

Implementation Notes