Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: "Šerif Rami" <ramiserifpersia@gmail.com>
Cc: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 5/7] ALSA: usb-audio: us144mkii: Add MIDI support and mixer controls
Date: Tue, 12 Aug 2025 08:59:03 +0200	[thread overview]
Message-ID: <87qzxhyqiw.wl-tiwai@suse.de> (raw)
In-Reply-To: <20250810124958.25309-6-ramiserifpersia@gmail.com>

On Sun, 10 Aug 2025 14:49:56 +0200,
Šerif Rami wrote:
> +/**
> + * @brief Text descriptions for playback output source options.
> + *
> + * Used by ALSA kcontrol elements to provide user-friendly names for
> + * the playback routing options (e.g., "Playback 1-2", "Playback 3-4").
> + */
> +static const char *const playback_source_texts[] = { "Playback 1-2",
> +						     "Playback 3-4" };
> +
> +/**
> + * @brief Text descriptions for capture input source options.
> + *
> + * Used by ALSA kcontrol elements to provide user-friendly names for
> + * the capture routing options (e.g., "Analog In", "Digital In").
> + */
> +static const char *const capture_source_texts[] = { "Analog In", "Digital In" };
> +
> +/**
> + * tascam_playback_source_info() - ALSA control info callback for playback
> + * source.
> + * @kcontrol: The ALSA kcontrol instance.
> + * @uinfo: The ALSA control element info structure to fill.
> + *
> + * This function provides information about the enumerated playback source
> + * control, including its type, count, and available items (Playback 1-2,
> + * Playback 3-4).
> + *
> + * Return: 0 on success.
> + */
> +static int tascam_playback_source_info(struct snd_kcontrol *kcontrol,
> +				       struct snd_ctl_elem_info *uinfo)
> +{
> +	return snd_ctl_enum_info(uinfo, 1, 2, playback_source_texts);
> +}
> +
> +/**
> + * tascam_line_out_get() - ALSA control get callback for Line Outputs Source.
> + * @kcontrol: The ALSA kcontrol instance.
> + * @ucontrol: The ALSA control element value structure to fill.
> + *
> + * This function retrieves the current selection for the Line 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_line_out_get(struct snd_kcontrol *kcontrol,
> +			       struct snd_ctl_elem_value *ucontrol)
> +{
> +	struct tascam_card *tascam = snd_kcontrol_chip(kcontrol);
> +
> +	ucontrol->value.enumerated.item[0] = tascam->line_out_source;
> +	return 0;
> +}
> +
> +/**
> + * tascam_line_out_put() - ALSA control put callback for Line Outputs Source.
> + * @kcontrol: The ALSA kcontrol instance.
> + * @ucontrol: The ALSA control element value structure containing the new value.
> + *
> + * This function sets the Line 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_line_out_put(struct snd_kcontrol *kcontrol,
> +			       struct snd_ctl_elem_value *ucontrol)
> +{
> +	struct tascam_card *tascam = snd_kcontrol_chip(kcontrol);
> +
> +	if (ucontrol->value.enumerated.item[0] > 1)
> +		return -EINVAL;
> +	if (tascam->line_out_source == ucontrol->value.enumerated.item[0])
> +		return 0;
> +	tascam->line_out_source = ucontrol->value.enumerated.item[0];
> +	return 1;
> +}
> +
> +/**
> + * 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 OUTPUTS Source",

The control name is always a difficult question.
For following the standards, it'd be better to be a name like
"Line Playback Source" (i.e. prefix + direction + suffix where
direction is either "Playback" or "Capture").

> +static const struct snd_kcontrol_new tascam_digital_out_control = {
> +	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
> +	.name = "Digital OUTPUTS Source",

Ditto.

> +static const struct snd_kcontrol_new tascam_capture_12_control = {
> +	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
> +	.name = "ch1 and ch2 Source",

This should be "... Capture Source", then, and what comes at the
prefix is another difficult question.  I find better to have capital
letters, or combine like "Ch1/2 Capture Source".

> +static const struct snd_kcontrol_new tascam_capture_34_control = {
> +	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
> +	.name = "ch3 and ch4 Source",

Ditto.

> +static int tascam_samplerate_get(struct snd_kcontrol *kcontrol,
> +				 struct snd_ctl_elem_value *ucontrol)
> +{
> +	struct tascam_card *tascam =
> +		(struct tascam_card *)snd_kcontrol_chip(kcontrol);
> +	u8 *buf __free(kfree);

Don't forget NULL initialization.


thanks,

Takashi

  reply	other threads:[~2025-08-12  6:59 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-10 12:49 [PATCH 0/7] ALSA: usb-audio: Add driver for TASCAM US-144MKII Šerif Rami
2025-08-10 12:49 ` [PATCH 1/7] ALSA: usb-audio: Add initial " Šerif Rami
2025-08-12  6:41   ` Takashi Iwai
2025-08-22 12:00     ` Markus Elfring
2025-08-10 12:49 ` [PATCH 2/7] ALSA: usb-audio: us144mkii: Add PCM core infrastructure Šerif Rami
2025-08-12  6:43   ` Takashi Iwai
2025-08-10 12:49 ` [PATCH 3/7] ALSA: usb-audio: us144mkii: Implement audio playback and feedback Šerif Rami
2025-08-12  6:48   ` Takashi Iwai
2025-08-10 12:49 ` [PATCH 4/7] ALSA: usb-audio: us144mkii: Implement audio capture and decoding Šerif Rami
2025-08-10 12:49 ` [PATCH 5/7] ALSA: usb-audio: us144mkii: Add MIDI support and mixer controls Šerif Rami
2025-08-12  6:59   ` Takashi Iwai [this message]
2025-08-10 12:49 ` [PATCH 6/7] ALSA: usb-audio: us144mkii: Add deep sleep and code style alignments Šerif Rami
2025-08-12  7:00   ` Takashi Iwai
2025-08-10 12:49 ` [PATCH 7/7] ALSA: usb-audio: Add infrastructure for TASCAM US-144MKII Šerif Rami
2025-08-12  7:01 ` [PATCH 0/7] ALSA: usb-audio: Add driver " Takashi Iwai
2025-08-12 12:56 ` [PATCH v2 " Šerif Rami
2025-08-12 12:56   ` [PATCH v2 1/7] ALSA: usb-audio: Add initial " Šerif Rami
2025-08-12 12:56   ` [PATCH v2 1/6] ALSA: usb-audio: us144mkii: Add PCM core infrastructure Šerif Rami
2025-08-12 12:56   ` [PATCH v2 2/7] " Šerif Rami
2025-08-12 12:56   ` [PATCH v2 2/6] ALSA: usb-audio: us144mkii: Implement audio playback and feedback Šerif Rami
2025-08-12 12:56   ` [PATCH v2 3/6] ALSA: usb-audio: us144mkii: Implement audio capture and decoding Šerif Rami
2025-08-12 12:56   ` [PATCH v2 3/7] ALSA: usb-audio: us144mkii: Implement audio playback and feedback Šerif Rami
2025-08-12 12:56   ` [PATCH v2 4/6] ALSA: usb-audio: us144mkii: Add MIDI support and mixer controls Šerif Rami
2025-08-12 12:56   ` [PATCH v2 4/7] ALSA: usb-audio: us144mkii: Implement audio capture and decoding Šerif Rami
2025-08-12 12:56   ` [PATCH v2 5/6] ALSA: usb-audio: us144mkii: Add deep sleep command Šerif Rami
2025-08-12 12:56   ` [PATCH v2 5/7] ALSA: usb-audio: us144mkii: Add MIDI support and mixer controls Šerif Rami
2025-08-12 12:56   ` [PATCH v2 6/6] ALSA: usb-audio: Add infrastructure for TASCAM US-144MKII Šerif Rami
2025-08-12 12:56   ` [PATCH v2 6/7] ALSA: usb-audio: us144mkii: Add deep sleep command Šerif Rami
2025-08-12 12:56   ` [PATCH v2 7/7] ALSA: usb-audio: Add infrastructure for TASCAM US-144MKII Šerif Rami
2025-08-12 13:22 ` [PATCH v3 0/7] ALSA: usb-audio: Add driver " Šerif Rami
2025-08-12 13:22   ` [PATCH v3 1/7] ALSA: usb-audio: Add initial " Šerif Rami
2025-08-13  8:34     ` Takashi Iwai
2025-08-12 13:22   ` [PATCH v3 2/7] ALSA: usb-audio: us144mkii: Add PCM core infrastructure Šerif Rami
2025-08-12 13:22   ` [PATCH v3 3/7] ALSA: usb-audio: us144mkii: Implement audio playback and feedback Šerif Rami
2025-08-13  8:38     ` Takashi Iwai
2025-08-12 13:22   ` [PATCH v3 4/7] ALSA: usb-audio: us144mkii: Implement audio capture and decoding Šerif Rami
2025-08-12 13:22   ` [PATCH v3 5/7] ALSA: usb-audio: us144mkii: Add MIDI support and mixer controls Šerif Rami
2025-08-12 13:22   ` [PATCH v3 6/7] ALSA: usb-audio: us144mkii: Add deep sleep command Šerif Rami
2025-08-12 13:22   ` [PATCH v3 7/7] ALSA: usb-audio: Add infrastructure for TASCAM US-144MKII Šerif Rami
2025-08-13  8:43   ` [PATCH v3 0/7] ALSA: usb-audio: Add driver " Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87qzxhyqiw.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=ramiserifpersia@gmail.com \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox