sound/usb/usx2y/us144mkii_controls.c

Source file repositories/reference/linux-study-clean/sound/usb/usx2y/us144mkii_controls.c

File Facts

System
Linux kernel
Corpus path
sound/usb/usx2y/us144mkii_controls.c
Extension
.c
Size
14461 bytes
Lines
445
Domain
Driver Families
Bucket
sound/usb
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 (tascam->line_out_source != ucontrol->value.enumerated.item[0]) {
			tascam->line_out_source = ucontrol->value.enumerated.item[0];
			changed = 1;
		}
	}
	return changed;
}

/*
 * tascam_line_out_control - ALSA kcontrol definition for Line Outputs Source.
 *
 * This defines a new ALSA mixer control named "Line OUTPUTS Source" that allows
 * the user to select between "Playback 1-2" and "Playback 3-4" for the analog
 * line outputs of the device. It uses the `tascam_playback_source_info` for
 * information and `tascam_line_out_get`/`tascam_line_out_put` for value
 * handling.
 */
static const struct snd_kcontrol_new tascam_line_out_control = {
	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
	.name = "Line Playback Source",
	.info = tascam_playback_source_info,
	.get = tascam_line_out_get,
	.put = tascam_line_out_put,
};

/*
 * tascam_digital_out_get() - ALSA control get callback for Digital Outputs
 * Source.
 * @kcontrol: The ALSA kcontrol instance.
 * @ucontrol: The ALSA control element value structure to fill.
 *
 * This function retrieves the current selection for the Digital Outputs source
 * (Playback 1-2 or Playback 3-4) from the driver's private data and populates
 * the ALSA control element value.
 *
 * Return: 0 on success.
 */
static int tascam_digital_out_get(struct snd_kcontrol *kcontrol,
				  struct snd_ctl_elem_value *ucontrol)
{
	struct tascam_card *tascam = snd_kcontrol_chip(kcontrol);

	scoped_guard(spinlock_irqsave, &tascam->lock) {
		ucontrol->value.enumerated.item[0] = tascam->digital_out_source;
	}
	return 0;
}

/*
 * tascam_digital_out_put() - ALSA control put callback for Digital Outputs
 * Source.
 * @kcontrol: The ALSA kcontrol instance.
 * @ucontrol: The ALSA control element value structure containing the new value.
 *
 * This function sets the Digital Outputs source (Playback 1-2 or Playback 3-4)
 * based on the user's selection from the ALSA control element. It validates
 * the input and updates the driver's private data.
 *
 * Return: 1 if the value was changed, 0 if unchanged, or a negative error code.
 */
static int tascam_digital_out_put(struct snd_kcontrol *kcontrol,
				  struct snd_ctl_elem_value *ucontrol)
{
	struct tascam_card *tascam = snd_kcontrol_chip(kcontrol);
	int changed = 0;

	if (ucontrol->value.enumerated.item[0] > 1)
		return -EINVAL;

	scoped_guard(spinlock_irqsave, &tascam->lock) {
		if (tascam->digital_out_source != ucontrol->value.enumerated.item[0]) {
			tascam->digital_out_source = ucontrol->value.enumerated.item[0];
			changed = 1;
		}
	}
	return changed;
}

/*
 * tascam_digital_out_control - ALSA kcontrol definition for Digital Outputs
 * Source.
 *
 * This defines a new ALSA mixer control named "Digital OUTPUTS Source" that
 * allows the user to select between "Playback 1-2" and "Playback 3-4" for the
 * digital outputs of the device. It uses the `tascam_playback_source_info` for
 * information and `tascam_digital_out_get`/`tascam_digital_out_put` for value
 * handling.
 */
static const struct snd_kcontrol_new tascam_digital_out_control = {
	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,

Annotation

Implementation Notes