From: Will Porter <mrwillporter@gmail.com>
To: Christian Ruppert <arc@gmx.li>
Cc: Takashi Iwai <tiwai@suse.com>, Jaroslav Kysela <perex@perex.cz>,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
Neil Andrews <neil@androos.io>
Subject: [RFC PATCH 6/6] ALSA: mixer_audient: Use the same cache for the iD14 MkI FU 12 control
Date: Wed, 11 Nov 2026 20:37:20 -0600 [thread overview]
Message-ID: <20261112023720.1503814-7-mrwillporter@gmail.com> (raw)
In-Reply-To: <20261112023720.1503814-1-mrwillporter@gmail.com>
The FU 12 control keeps its own value array and valid mask on a
struct usb_mixer_elem_list. Make it a struct usb_mixer_elem_info, and
use cache_val[ch] and bit ch of cached as the other controls do. Set
channels and get_cur_broken. Remove the private struct.
The list head is the first member of struct usb_mixer_elem_info, so
snd_usb_mixer_elem_free() still frees the right pointer. The control
is still registered with is_std_info false, so the generic notify
paths do not touch it.
No functional change.
Assisted-by: Claude:claude-fable-5-2
Assisted-by: Claude:claude-sonnet-5-5
Signed-off-by: Will Porter <mrwillporter@gmail.com>
---
sound/usb/mixer_audient.c | 54 ++++++++++++++++++++-------------------
1 file changed, 28 insertions(+), 26 deletions(-)
diff --git a/sound/usb/mixer_audient.c b/sound/usb/mixer_audient.c
index edc568830366c..8c81a4c05995f 100644
--- a/sound/usb/mixer_audient.c
+++ b/sound/usb/mixer_audient.c
@@ -1074,26 +1074,26 @@ static const struct snd_audient_ctrl_type snd_audient_id14_fu12_type = {
.sel = UAC_FU_VOLUME,
};
-struct snd_audient_id14_fu12 {
- struct usb_mixer_elem_list list; /* first: snd_usb_mixer_elem_free */
- long val[ID14_FU12_CHANNELS];
- u8 valid; /* bit per channel */
-};
-
-static int snd_audient_id14_fu12_write(struct snd_audient_id14_fu12 *f,
+/*
+ * The control is a struct usb_mixer_elem_info whose list head is registered
+ * with is_std_info false. The head is the first member, as
+ * snd_usb_mixer_elem_free needs. cache_val[ch] and bit ch of cached hold
+ * the last value the device accepted.
+ */
+static int snd_audient_id14_fu12_write(struct usb_mixer_elem_info *elem,
unsigned int ch, long val)
{
__le16 buf = cpu_to_le16(val == ID14_FU12_MUTE ? -128 * 256
: (val - ID14_FU12_MAX) * 256);
int ret;
- ret = snd_audient_set_cur(f->list.mixer, &snd_audient_id14_fu12_type,
+ ret = snd_audient_set_cur(elem->head.mixer, &snd_audient_id14_fu12_type,
ch + 1, &buf);
if (ret < 0)
return ret;
- f->val[ch] = val;
- f->valid |= BIT(ch);
+ elem->cache_val[ch] = val;
+ set_bit(ch, elem->cached);
return 0;
}
@@ -1112,13 +1112,13 @@ static int snd_ctl_audient_id14_fu12_info(struct snd_kcontrol *kctl,
static int snd_ctl_audient_id14_fu12_get(struct snd_kcontrol *kctl,
struct snd_ctl_elem_value *ctl_val)
{
- struct snd_audient_id14_fu12 *f = snd_kcontrol_chip(kctl);
+ struct usb_mixer_elem_info *elem = snd_kcontrol_chip(kctl);
unsigned int ch;
/* a channel that was never written reads as mute */
for (ch = 0; ch < ID14_FU12_CHANNELS; ch++)
- ctl_val->value.integer.value[ch] = (f->valid & BIT(ch))
- ? f->val[ch]
+ ctl_val->value.integer.value[ch] = test_bit(ch, elem->cached)
+ ? elem->cache_val[ch]
: ID14_FU12_MUTE;
return 0;
@@ -1127,7 +1127,7 @@ static int snd_ctl_audient_id14_fu12_get(struct snd_kcontrol *kctl,
static int snd_ctl_audient_id14_fu12_set(struct snd_kcontrol *kctl,
struct snd_ctl_elem_value *ctl_val)
{
- struct snd_audient_id14_fu12 *f = snd_kcontrol_chip(kctl);
+ struct usb_mixer_elem_info *elem = snd_kcontrol_chip(kctl);
long *const v = ctl_val->value.integer.value;
unsigned int ch;
int changed = 0;
@@ -1136,7 +1136,7 @@ static int snd_ctl_audient_id14_fu12_set(struct snd_kcontrol *kctl,
if (v[ch] < 0 || v[ch] > ID14_FU12_MAX)
return -EINVAL;
- CLASS(snd_usb_lock, pm)(f->list.mixer->chip);
+ CLASS(snd_usb_lock, pm)(elem->head.mixer->chip);
if (pm.err < 0)
return pm.err;
@@ -1147,10 +1147,10 @@ static int snd_ctl_audient_id14_fu12_set(struct snd_kcontrol *kctl,
for (ch = 0; ch < ID14_FU12_CHANNELS; ch++) {
int ret;
- if (!(f->valid & BIT(ch)) || f->val[ch] != v[ch])
+ if (!test_bit(ch, elem->cached) || elem->cache_val[ch] != v[ch])
changed = 1;
- ret = snd_audient_id14_fu12_write(f, ch, v[ch]);
+ ret = snd_audient_id14_fu12_write(elem, ch, v[ch]);
if (ret < 0)
return ret;
}
@@ -1171,19 +1171,21 @@ static int snd_audient_id14_mk1_create(struct usb_mixer_interface *mixer)
.put = snd_ctl_audient_id14_fu12_set,
.tlv.p = snd_audient_tlv_id14_fu12,
};
- struct snd_audient_id14_fu12 *f;
+ struct usb_mixer_elem_info *elem;
struct snd_kcontrol *kctl;
unsigned int ch;
- f = kzalloc_obj(*f);
- if (!f)
+ elem = kzalloc_obj(*elem);
+ if (!elem)
return -ENOMEM;
- f->list.mixer = mixer;
- f->list.id = ID14_FU_MIX;
+ elem->head.mixer = mixer;
+ elem->head.id = ID14_FU_MIX;
+ elem->channels = ID14_FU12_CHANNELS;
+ elem->get_cur_broken = 1;
for (ch = 0; ch < ID14_FU12_CHANNELS; ch++) {
- const int ret = snd_audient_id14_fu12_write(f, ch,
+ const int ret = snd_audient_id14_fu12_write(elem, ch,
ch < ID14_FU12_MAIN_CHANNELS ? ID14_FU12_MAX
: ID14_FU12_MUTE);
@@ -1193,15 +1195,15 @@ static int snd_audient_id14_mk1_create(struct usb_mixer_interface *mixer)
ch + 1, ret);
}
- kctl = snd_ctl_new1(&knew, f);
+ kctl = snd_ctl_new1(&knew, elem);
if (!kctl) {
- kfree(f);
+ kfree(elem);
return -ENOMEM;
}
kctl->private_free = snd_usb_mixer_elem_free;
- return snd_usb_mixer_add_list(&f->list, kctl, false, true);
+ return snd_usb_mixer_add_list(&elem->head, kctl, false, true);
}
/* called from mixer_quirks.c */
--
2.47.3
next prev parent reply other threads:[~2026-11-12 2:37 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-19 23:01 [PATCH 0/5] ALSA: usb-audio: Audient iD14 MkI vendor controls Will Porter
2026-10-19 23:01 ` [PATCH 1/5] ALSA: usb-audio: Give the Audient iD14 MkI its own mixer map Will Porter
2026-10-19 23:01 ` [PATCH 2/5] ALSA: usb-audio: Add Audient iD14 MkI monitor and routing controls Will Porter
2026-10-19 23:01 ` [PATCH 3/5] ALSA: usb-audio: Add Audient iD14 MkI mixer matrix Will Porter
2026-10-19 23:01 ` [PATCH 4/5] ALSA: usb-audio: Add Audient iD14 MkI write-only controls Will Porter
2026-10-19 23:01 ` [PATCH 5/5] ALSA: usb-audio: Replace the Audient iD14 MkI FU 12 control Will Porter
2026-10-20 13:10 ` [PATCH 0/5] ALSA: usb-audio: Audient iD14 MkI vendor controls Takashi Iwai
2026-10-26 18:36 ` Christian Ruppert
2026-10-26 21:44 ` Will Porter
2026-10-27 6:35 ` Takashi Iwai
2026-10-27 23:21 ` Christian Ruppert
2026-10-28 2:36 ` Will Porter
2026-11-01 0:00 ` [RFC PATCH 00/11] " Christian Ruppert
2026-11-01 0:00 ` [RFC PATCH 01/11] ALSA: rename mixer_evo to mixer_audient Christian Ruppert
2026-11-01 0:00 ` [RFC PATCH 02/11] ALSA: mixer_audient: explicitly define full control names Christian Ruppert
2026-11-01 0:00 ` [RFC PATCH 03/11] ALSA: mixer_audient: clarify USB control message definition Christian Ruppert
2026-11-01 0:00 ` [RFC PATCH 04/11] ALSA: mixer_audient: Add length check to USB transfer Christian Ruppert
2026-11-01 0:00 ` [RFC PATCH 05/11] ALSA: mixer_audient: make USB control transfer size configurable Christian Ruppert
2026-11-01 0:00 ` [RFC PATCH 06/11] ALSA: mixer_audient: Allow arbitrary boolean control values Christian Ruppert
2026-11-01 0:00 ` [RFC PATCH 07/11] ALSA: mixer_audient: Add integer range checks Christian Ruppert
2026-11-01 0:00 ` [RFC PATCH 08/11] ALSA: mixer_audient: Add control initialization at probe Christian Ruppert
2026-11-01 0:00 ` [RFC PATCH 09/11] ALSA: mixer_audient: Add readback-free parameter set Christian Ruppert
2026-11-01 0:00 ` [RFC PATCH 10/11] ALSA: mixer_audient: add control value caching Christian Ruppert
2026-11-01 0:00 ` [RFC PATCH 11/11] ALSA: mixer_audient: Create matrix programmatically Christian Ruppert
2026-11-01 17:35 ` [RFC PATCH 00/11] Re: ALSA: usb-audio: Audient iD14 MkI vendor controls Will Porter
2026-11-02 0:32 ` [RFC V2 PATCH 00/11] Re: ALSA: usb-audio: Audient iD14 MkI vendor Christian Ruppert
2026-11-02 0:32 ` [RFC V2 PATCH 01/11] ALSA: rename mixer_evo to mixer_audient Christian Ruppert
2026-11-02 0:32 ` [RFC V2 PATCH 02/11] ALSA: mixer_audient: explicitly define full control names Christian Ruppert
2026-11-02 0:32 ` [RFC V2 PATCH 03/11] ALSA: mixer_audient: clarify USB control message definition Christian Ruppert
2026-11-02 0:32 ` [RFC V2 PATCH 04/11] ALSA: mixer_audient: Add length check to USB transfer Christian Ruppert
2026-11-02 0:32 ` [RFC V2 PATCH 05/11] ALSA: mixer_audient: make USB control transfer size configurable Christian Ruppert
2026-11-02 0:32 ` [RFC V2 PATCH 06/11] ALSA: mixer_audient: Allow arbitrary boolean control values Christian Ruppert
2026-11-02 0:32 ` [RFC V2 PATCH 07/11] ALSA: mixer_audient: Add integer range checks Christian Ruppert
2026-11-02 0:32 ` [RFC V2 PATCH 08/11] ALSA: mixer_audient: Add control initialization at probe Christian Ruppert
2026-11-02 0:32 ` [RFC V2 PATCH 09/11] ALSA: mixer_audient: Add readback-free parameter set Christian Ruppert
2026-11-02 0:32 ` [RFC V2 PATCH 10/11] ALSA: mixer_audient: add control value caching Christian Ruppert
2026-11-02 0:32 ` [RFC V2 PATCH 11/11] ALSA: mixer_audient: Create matrix programmatically Christian Ruppert
2026-11-03 2:45 ` [RFC V2 PATCH 00/11] Re: ALSA: usb-audio: Audient iD14 MkI vendor Will Porter
2026-11-03 23:01 ` Christian Ruppert
2026-11-06 16:31 ` [RFC PATCH 00/16] ALSA: usb-audio: Audient driver and iD14 MkI support Will Porter
2026-11-06 16:31 ` [RFC PATCH 01/16] ALSA: rename mixer_evo to mixer_audient Will Porter
2026-11-06 16:31 ` [RFC PATCH 02/16] ALSA: mixer_audient: explicitly define full control names Will Porter
2026-11-06 16:31 ` [RFC PATCH 03/16] ALSA: mixer_audient: clarify USB control message definition Will Porter
2026-11-06 16:31 ` [RFC PATCH 04/16] ALSA: mixer_audient: Add length check to USB transfer Will Porter
2026-11-06 16:31 ` [RFC PATCH 05/16] ALSA: mixer_audient: make USB control transfer size configurable Will Porter
2026-11-06 16:31 ` [RFC PATCH 06/16] ALSA: mixer_audient: Allow arbitrary boolean control values Will Porter
2026-11-06 16:31 ` [RFC PATCH 07/16] ALSA: mixer_audient: Add integer range checks Will Porter
2026-11-06 16:31 ` [RFC PATCH 08/16] ALSA: mixer_audient: Add control initialization at probe Will Porter
2026-11-06 16:31 ` [RFC PATCH 09/16] ALSA: mixer_audient: Add readback-free parameter set Will Porter
2026-11-06 16:31 ` [RFC PATCH 10/16] ALSA: mixer_audient: add control value caching Will Porter
2026-11-06 16:31 ` [RFC PATCH 11/16] ALSA: mixer_audient: Create matrix programmatically Will Porter
2026-11-06 16:31 ` [RFC PATCH 12/16] ALSA: mixer_audient: Add a step size to integer controls Will Porter
2026-11-06 16:31 ` [RFC PATCH 13/16] ALSA: mixer_audient: Add enumerated controls Will Porter
2026-11-06 16:53 ` sashiko-bot
2026-11-06 20:29 ` Will Porter
2026-11-09 22:30 ` Christian Ruppert
2026-11-10 2:13 ` Will Porter
2026-11-10 20:57 ` Christian Ruppert
2026-11-12 2:37 ` [RFC PATCH 0/6] ALSA: mixer_audient: Cache rework and simplifications Will Porter
2026-11-12 2:37 ` [RFC PATCH 1/6] ALSA: mixer_audient: Fold in the review changes to patches 12-16 Will Porter
2026-11-12 2:37 ` [RFC PATCH 2/6] ALSA: mixer_audient: Use the cache of usb_mixer_elem_info Will Porter
2026-11-12 2:37 ` [RFC PATCH 3/6] ALSA: mixer_audient: Replace three flags with an access mode Will Porter
2026-11-12 2:37 ` [RFC PATCH 4/6] ALSA: mixer_audient: Fill the cache on first use Will Porter
2026-11-12 2:37 ` [RFC PATCH 5/6] ALSA: mixer_audient: Use one get and one put for all control types Will Porter
2026-11-12 2:37 ` Will Porter [this message]
2026-11-06 16:31 ` [RFC PATCH 14/16] ALSA: usb-audio: Give the Audient iD14 MkI its own mixer map Will Porter
2026-11-06 16:31 ` [RFC PATCH 15/16] ALSA: mixer_audient: Add Audient iD14 MkI controls Will Porter
2026-11-06 16:31 ` [RFC PATCH 16/16] ALSA: mixer_audient: Replace the Audient iD14 MkI FU 12 control Will Porter
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=20261112023720.1503814-7-mrwillporter@gmail.com \
--to=mrwillporter@gmail.com \
--cc=arc@gmx.li \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=neil@androos.io \
--cc=perex@perex.cz \
--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