NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/56552: mixerctl(1) does not increment volume with ++ or +=1



The following reply was made to PR bin/56552; it has been noted by GNATS.

From: mlelstv%serpens.de@localhost (Michael van Elst)
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: bin/56552: mixerctl(1) does not increment volume with ++ or +=1
Date: Wed, 15 Dec 2021 23:24:22 -0000 (UTC)

 rvp%SDF.ORG@localhost writes:
 
 >On my HW (VIA product 8446) the volume increment delta (5) seems to be
 >an open interval rather than a closed one, so I see this:
 >     
 >$ mixerctl -w outputs.master++
 >outputs.master: 162,162 -> 162,162 
 >$ mixerctl -w outputs.master+=1
 >outputs.master: 162,162 -> 162,162 
 >$    
 >     
 >I have to use `+=2' to increment the volume by one "step". Decrementing
 >works OK however:
 >     
 >$ mixerctl -w outputs.master--
 >outputs.master: 162,162 -> 156,156 
 >$ mixerctl -w outputs.master-=1
 >outputs.master: 156,156 -> 150,150 
 >$    
 
 
 mixerctl just does what the driver tells it. If the driver says that
 a 'step' is 5. Then it increments from 162 to 167 and decrements
 from 162 to 157. Then it reads back the value from the driver.
 
 
 HD-Audio computes the delta value as:
 
     mx[index].mx_di.un.v.delta = 256 / (masterctl->ctl_step + 1);
 
 where ctl_step is a value 0..127, denoting 1..128 volume settings.
 
 So, with 43 to 51 settings (ctl_step=42..50), you get a delta value of 5.
 
 When changing a value it computes the values like:
 
     if (ctl->ctl_step == 0)
         divisor = 128; /* ??? - just avoid div by 0 */
     else
         divisor = 255 / ctl->ctl_step;  
 
     hdafg_control_amp_set(ctl, HDAUDIO_AMP_MUTE_NONE,
       mc->un.value.level[AUDIO_MIXER_LEVEL_LEFT] / divisor,
       mc->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] / divisor);
 
 But with 43 settings (ctl_step is then 42), the divisor is 6.
 
 Reading back the value is done like:
 
     if (ctl->ctl_step == 0)
         factor = 128; /* ??? - just avoid div by 0 */
     else
         factor = 255 / ctl->ctl_step;
 
     mc->un.value.level[AUDIO_MIXER_LEVEL_LEFT] = ctl->ctl_left * factor;
     mc->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = ctl->ctl_right * factor;
 
 
 So, with 43 settings:
 
 delta = 5
 
 incrementing 162 to 167
 writing a hardware value of 167/6 = 27
 reading back 27 and computing 27 *6 = 162
 
 decrementing 162 to 157
 writing a hardware value of 157/6 = 26
 reading back 26 and computing 26 * 6 = 156
 
 decrementing 156 to 151
 writing a hardware value of 151/6 = 25
 reading back 26 and computing 25 * 6 = 150
 
 


Home | Main Index | Thread Index | Old Index