mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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: Re: [RFC V4 PATCH 00/19] Re: ALSA: mixer_audient: Cache rework and simplifications
Date: Sun, 15 Nov 2026 20:53:36 -0600	[thread overview]
Message-ID: <20261116025336.3718463-1-mrwillporter@gmail.com> (raw)
In-Reply-To: <20261115214336.17917-1-arc@gmx.li>

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@gmail.com>
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@gmail.com>
---
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:

  reply	other threads:[~2026-11-16  2:54 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <sashiko-outbox-201869@kernel.org>
2026-11-06 20:29 ` [RFC PATCH 13/16] ALSA: mixer_audient: Add enumerated controls 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           ` [RFC PATCH 6/6] ALSA: mixer_audient: Use the same cache for the iD14 MkI FU 12 control Will Porter
2026-11-15 21:43           ` [RFC V4 PATCH 00/19] Re: ALSA: mixer_audient: Cache rework and simplifications Christian Ruppert
2026-11-16  2:53             ` Will Porter [this message]
2026-11-15 21:43           ` [RFC V4 PATCH 01/19] ALSA: rename mixer_evo to mixer_audient Christian Ruppert
2026-11-15 21:43           ` [RFC V4 PATCH 02/19] ALSA: mixer_audient: explicitly define full control names Christian Ruppert
2026-11-15 21:43           ` [RFC V4 PATCH 03/19] ALSA: mixer_audient: clarify USB control message definition Christian Ruppert
2026-11-15 21:43           ` [RFC V4 PATCH 04/19] ALSA: mixer_audient: Add length check to USB transfer Christian Ruppert
2026-11-15 21:43           ` [RFC V4 PATCH 05/19] ALSA: mixer_audient: make USB control transfer size configurable Christian Ruppert
2026-11-15 21:43           ` [RFC V4 PATCH 06/19] ALSA: mixer_audient: Allow arbitrary boolean control values Christian Ruppert
2026-11-15 21:43           ` [RFC V4 PATCH 07/19] ALSA: mixer_audient: Add integer range checks Christian Ruppert
2026-11-15 21:43           ` [RFC V4 PATCH 08/19] ALSA: mixer_audient: Add control initialization at probe Christian Ruppert
2026-11-15 21:43           ` [RFC V4 PATCH 09/19] ALSA: mixer_audient: Add readback-free parameter set Christian Ruppert
2026-11-15 21:43           ` [RFC V4 PATCH 10/19] ALSA: mixer_audient: add control value caching Christian Ruppert
2026-11-15 21:43           ` [RFC V4 PATCH 11/19] ALSA: mixer_audient: Create matrix programmatically Christian Ruppert
2026-11-15 21:43           ` [RFC V4 PATCH 12/19] ALSA: mixer_audient: Add a step size to integer controls Christian Ruppert
2026-11-15 21:43           ` [RFC V4 PATCH 13/19] ALSA: mixer_audient: Add enumerated controls Christian Ruppert
2026-11-15 21:43           ` [RFC V4 PATCH 14/19] ALSA: usb-audio: Give the Audient iD14 MkI its own mixer map Christian Ruppert
2026-11-15 21:43           ` [RFC V4 PATCH 15/19] ALSA: mixer_audient: Add Audient iD14 MkI controls Christian Ruppert
2026-11-15 21:43           ` [RFC V4 PATCH 16/19] ALSA: mixer_audient: Replace the Audient iD14 MkI FU 12 control Christian Ruppert
2026-11-15 21:43           ` [RFC V4 PATCH 17/19] ALSA: mixer_audient: Fold in the review changes to patches 12-16 Christian Ruppert
2026-11-15 21:43           ` [RFC V4 PATCH 18/19] ALSA: mixer_audient: Unify snd_audient_*_set/get functions for different types Christian Ruppert
2026-11-15 21:43           ` [RFC V4 PATCH 19/19] ALSA: mixer_audient: Refactor FU12 special cases into generic set/get functions Christian Ruppert

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=20261116025336.3718463-1-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

all inboxes | Powered by JetHome®