On 17/12/2025 14:47, Charles Keepax wrote:
On Wed, Dec 17, 2025 at 02:06:23PM +0200, Peter Ujfalusi wrote:
sound/soc/soc-ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c index ce86978c158d..6a18c56a9746 100644 --- a/sound/soc/soc-ops.c +++ b/sound/soc/soc-ops.c @@ -148,7 +148,7 @@ static int soc_mixer_reg_to_ctl(struct soc_mixer_control *mc, unsigned int reg_v if (mc->sign_bit) val = sign_extend32(val, mc->sign_bit);
- val = clamp(val, mc->min, mc->max);
- val = clamp(val, mc->min, mc->min + max);
This won't work, for an SX control it is perfectly valid for the value read from the register to be smaller than the minimum value specified in the control.
Hrm, so an SX control returns sort of rand() and the value have no correlation to min or max?
The info() gives this explanation: SX TLV controls have a range that represents both positive and negative values either side of zero but without a sign bit. min is the minimum register value, max is the number of steps.
which kind of makes some sense, but really fuzzy.
The minimum value gives the register value that equates to the smallest possible control value.
right, so min is min, OK
From there the values increase but the register field can overflow and end up lower than the min.
smaller value than min is then bigger than min, right? The value can wrap at any random value to 0 and continue from 0 up to some value, which is the max? max (which is the number of steps) = vrap_point-min + some_value (where the value is likely less than min, but not specified)
How this is in practice for the cs42l43' Headphone Digital Volume? SOC_DOUBLE_SX_TLV("Headphone Digital Volume", CS42L43_HPPATHVOL, CS42L43_AMP3_PATH_VOL_SHIFT, CS42L43_AMP4_PATH_VOL_SHIFT, 0x11B, 229, cs42l43_headphone_tlv),
min=283 max=229 shifts: 0 and 16 masks are 0x1ff
if you step 229 from 283 then you reach 0x1ff, this is the max the mask can cover.
I often think of it in terms of a 2's compliement number with an implicit sign bit.
I see, but why???
Thanks, Charles