Re: [RFC V4 PATCH 00/19] Re: ALSA: mixer_audient: Cache rework and simplifications
From: Will Porter
Date: Sun Nov 15 2026 - 21:54:23 EST
Hi Christian,
Thank you for V4. Your plan works for me. I would like to take patch
19 with one functional change, and I have a question on patch 18.
I squashed patch 17 into patches 12, 13, 15 and 16 (patch 12 got the
inline changes). With the diff below, each patch builds with W=1
without warnings. checkpatch --strict reports no new errors or
warnings, and the diff adds no new checks. On the iD14, with the diff
on a 7.2.15 kernel, our read and write checks pass, and every enum
item reads back as written.
> Please double-check the new patch 10 to make sure I didn't miss
> anything
It looks right to me. The cache bit and the cache_val[] index are both
the channel number of the request, and the probe sends no GET. I found
only the bound check in the list below.
> There is also a subtle behavioural change when initializing
> write-only cache values.
On the iD14 this changes nothing. Its write-only booleans have init
equal to min, and its write-only enums already read as init. On the
hardware, all of them read their init value after the load.
Patch 19
--------
I like it. One thing: the FU 12 type has INIT_HW and CACHE, but not
GET_BROKEN. On the iD14, GET CUR on FU 12 does not return the FU 12
value. It returns a reply buffer that the device shares with other
units.
If the probe write of a Cue channel fails, that channel has no cache
entry, so the next get or put sends this GET and caches the reply.
The control can then show a value that is not the value of that
channel. A later put whose device value matches that reply sends no
SET for the channel: for example, a stale 0 dB shows as 127, and a put
of 127 sends nothing. A stale value below -127 dB can also show as a
negative control value.
So FU 12 looks to me like a write-only control with an init value.
With GET_BROKEN, an unknown channel reads as init (mute), and every
put sends all four channels, as the comment above ID14_FU12_* says.
I checked this with a test build that skips the probe write of Cue L.
With V4, the first access after the load sent one GET for Cue L. The
reply was 0x8000, matching the value just written to Cue R, so Cue L
showed 0. Puts of the shown values then sent no SET, also not for Cue
L, which the driver had never written. With the diff, the driver sent
no GET, Cue L showed 0, and each put sent all four channels.
Does that match how you read the flags?
> We could even get rid of the FU12 specific value type if the iD14
> accepts -127 * 256 as a volume setting
The device accepts a SET of -127 dB without a stall, but I tested
that only on Main L, which the firmware ignores. On Cue, -126 dB and
mute (0x8000) both measure at the same small residual level that the
headphone output keeps. I have not tested a SET of -127 dB on Cue.
The type also has to stay for now, because it holds Main at 0 dB. So
I would keep value 0 as mute in this series. Could we do the plain
integer together with your don't-touch channel mask as a follow-up?
Patch 18
--------
The old gets read only the channels below hwchannels and filled in the
rest. The new get reads every channel and then ignores the value of
the channels at or above hwchannels, so an error on such a channel
fails the whole get. I think this affects only the EVO4 "Mic Playback
Switch" (4 channels, 2 on the device): it now also sends GET for CN 2
and 3. Does the EVO4 answer those? Either way, the diff skips the
transfer for those channels and keeps the values they show now.
Small things, also in the diff:
- raw_get_one() and raw_set_one() accept cidx == MAX_CHANNELS, but
cache_val[] has MAX_CHANNELS entries. No table reaches it (the
highest channel is 55), so ">=" is only a guard.
- Two comments from patch 10 still say FORCE_SET.
- Patch 19 removes extra_init but keeps its comment.
Next steps
----------
After patch 19, nothing of patch 16's own FU 12 code is left. So I
would drop patch 16 and send one FU 12 patch after patch 18: the
control as patch 16 describes it, built on the unified get and put
with your code from patch 19. Would you like to be its author, with a
Co-developed-by for me, or the other way round?
A note on trailers: V4 dropped "Assisted-by: Claude:claude-opus-5-5"
from patches 8, 11 and 12 to 16. I put it back on them, and I added it
to patch 10, because patch 10 now holds code from my cache patch.
May I fold the diff into your patches 10, 18 and 19 for the final
series? I would send it as a normal series, not as another RFC.
Should it wait for Takashi's answer on your four mixer_evo fixes, or
carry them at the front?
Thanks,
Will
-- >8 --
From: Will Porter <mrwillporter@xxxxxxxxx>
Subject: [RFC PATCH] ALSA: mixer_audient: Fix FU 12 reads and the get loop
Proposed changes to patches 10, 18 and 19 of RFC V4:
- Patch 19: mark the iD14 FU 12 type GET_BROKEN. GET CUR on FU 12
returns a reply buffer that the device shares with other units, so
the driver must not read a channel that has no cache entry. A
stale value can also convert to a negative control value: 0x8001
shows as -1.
- Patch 18: send no GET for a channel at or above hwchannels. The
type-specific gets did not read these channels either. Also correct
the comment on -ENODATA: an unknown value now reads as init, not as
off.
- Patch 10: reject cidx == MAX_CHANNELS (cache_val[] has MAX_CHANNELS
entries), and say GET_BROKEN in two comments that still say
FORCE_SET.
- Patch 19: remove the comment left from extra_init.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Will Porter <mrwillporter@xxxxxxxxx>
---
Applies on top of RFC V4 patch 19.
diff --git a/sound/usb/mixer_audient.c b/sound/usb/mixer_audient.c
index e24a6e9facc1d..93fad4b74e18d 100644
--- a/sound/usb/mixer_audient.c
+++ b/sound/usb/mixer_audient.c
@@ -408,6 +408,7 @@ static const struct snd_audient_ctrl_type {
.type = SNDRV_AUDIENT_CTL_ELEM_TYPE_ID14_FU12,
.flags = SND_AUDIENT_CTYPE_FLAGS_SIGNED
| SND_AUDIENT_CTYPE_FLAGS_INIT_HW
+ | SND_AUDIENT_CTYPE_FLAGS_GET_BROKEN
| SND_AUDIENT_CTYPE_FLAGS_CACHE,
.len = 2,
.min.integer = -127 * 256,
@@ -540,7 +541,6 @@ static const struct audient_devinfo {
const struct snd_audient_ctrl *controls;
const char *const *const matrix_names;
const unsigned int matrix_channels;
- /* optional: controls the tables cannot describe, created after them */
} audient_devinfo[] = {
{
.usb_id = USB_ID(USB_AUDIENT_VID, USB_EVO4_PID),
@@ -649,7 +649,7 @@ static int snd_audient_raw_get_one(struct usb_mixer_elem_info *const elem,
__le32 buf = 0;
s32 val;
- if (cidx > MAX_CHANNELS)
+ if (cidx >= MAX_CHANNELS)
return -EINVAL;
if (ctype->flags & SND_AUDIENT_CTYPE_FLAGS_CACHE) {
@@ -659,8 +659,8 @@ static int snd_audient_raw_get_one(struct usb_mixer_elem_info *const elem,
return ctype->len;
} else if (ctype->flags & SND_AUDIENT_CTYPE_FLAGS_GET_BROKEN) {
/*
- * Cached FORCE_SET controls are treated as write-only:
- * an invalid cache entry does not trigger a GET.
+ * GET_BROKEN controls are write-only: an invalid
+ * cache entry does not trigger a GET.
*/
return -ENODATA;
}
@@ -692,14 +692,14 @@ static int snd_audient_raw_set_one(struct usb_mixer_elem_info *const elem,
int ret;
u32 val;
- if (cidx > MAX_CHANNELS)
+ if (cidx >= MAX_CHANNELS)
return -EINVAL;
if (force) {
val = !value; /* just make it different */
} else {
ret = snd_audient_raw_get_one(elem, ctype, cidx, &val);
- if (ret == -ENODATA) /* FORCE_SET and not cached yet */
+ if (ret == -ENODATA) /* GET_BROKEN and not cached yet */
val = !value; /* just make it different */
else if (ret < 0)
return ret;
@@ -825,14 +825,18 @@ static int snd_ctl_audient_get(struct snd_kcontrol *kctl,
guard(mutex)(&mixer->lock);
for (i = 0; i < nchan; i++) {
- u32 buf;
+ u32 buf = 0;
long ret;
- ret = snd_audient_raw_get_one(elem, ctype, base + i, &buf);
- if (ret == -ENODATA) /* unknown write-only value: off */
- buf = ctype->init;
- else if (ret < 0)
- return ret;
+ /* channels the device does not have are not read */
+ if (i < hwchan) {
+ ret = snd_audient_raw_get_one(elem, ctype, base + i,
+ &buf);
+ if (ret == -ENODATA) /* unknown write-only value */
+ buf = ctype->init;
+ else if (ret < 0)
+ return ret;
+ }
switch (ctype->type) {
case SNDRV_CTL_ELEM_TYPE_BOOLEAN: