diff mbox

ASoC: rt5677: make volume TLV closer to reality

Message ID 1412888409-4650-1-git-send-email-dgreid@chromium.org (mailing list archive)
State New, archived
Headers show

Commit Message

Dylan Reid Oct. 9, 2014, 9 p.m. UTC
The volume blocks have an step of 0.375dB, but TLV uses 0.01dB for
units.  Approximate 0.375 as 0.37.  It leaves the minimum value off by
1.15dB, but that is better than being off by ~500 as it was with 37.5
as the step.

Signed-off-by: Dylan Reid <dgreid@chromium.org>
---
Just a suggestion.  It seems to me to be the lesser of two evils.
This probably won't be the last codec that has a higher resolution
than 0.01dB, should we come up with a way to express that?
---
 sound/soc/codecs/rt5677.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Takashi Iwai Oct. 9, 2014, 9:51 p.m. UTC | #1
At Thu,  9 Oct 2014 14:00:09 -0700,
Dylan Reid wrote:
> 
> The volume blocks have an step of 0.375dB, but TLV uses 0.01dB for
> units.  Approximate 0.375 as 0.37.  It leaves the minimum value off by
> 1.15dB, but that is better than being off by ~500 as it was with 37.5
> as the step.
> 
> Signed-off-by: Dylan Reid <dgreid@chromium.org>
> ---
> Just a suggestion.  It seems to me to be the lesser of two evils.
> This probably won't be the last codec that has a higher resolution
> than 0.01dB, should we come up with a way to express that?

How about using TLV_DB_MINMAX instead?


Takashi

> ---
>  sound/soc/codecs/rt5677.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c
> index 16aa4d9..f139d5a 100644
> --- a/sound/soc/codecs/rt5677.c
> +++ b/sound/soc/codecs/rt5677.c
> @@ -538,9 +538,11 @@ static bool rt5677_readable_register(struct device *dev, unsigned int reg)
>  }
>  
>  static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0);
> -static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -65625, 375, 0);
> +/* Actual min=-65.625dB and step=0.375dB but only have 0.01 resolution. */
> +static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -6475, 37, 0);
>  static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0);
> -static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -17625, 375, 0);
> +/* Actual min=-17.625dB and step=0.375dB but only have 0.01 resolution. */
> +static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -1739, 37, 0);
>  static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0);
>  static const DECLARE_TLV_DB_SCALE(st_vol_tlv, -4650, 150, 0);
>  
> -- 
> 2.1.2.330.g565301e
>
Dylan Reid Oct. 9, 2014, 10:10 p.m. UTC | #2
On Thu, Oct 9, 2014 at 2:51 PM, Takashi Iwai <tiwai@suse.de> wrote:
> At Thu,  9 Oct 2014 14:00:09 -0700,
> Dylan Reid wrote:
>>
>> The volume blocks have an step of 0.375dB, but TLV uses 0.01dB for
>> units.  Approximate 0.375 as 0.37.  It leaves the minimum value off by
>> 1.15dB, but that is better than being off by ~500 as it was with 37.5
>> as the step.
>>
>> Signed-off-by: Dylan Reid <dgreid@chromium.org>
>> ---
>> Just a suggestion.  It seems to me to be the lesser of two evils.
>> This probably won't be the last codec that has a higher resolution
>> than 0.01dB, should we come up with a way to express that?
>
> How about using TLV_DB_MINMAX instead?

That sounds like the right idea.  It'll only be off by 0.005dB.  I'll
replace this change with that one.

Thanks!

-dg

>
>
> Takashi
>
>> ---
>>  sound/soc/codecs/rt5677.c | 6 ++++--
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c
>> index 16aa4d9..f139d5a 100644
>> --- a/sound/soc/codecs/rt5677.c
>> +++ b/sound/soc/codecs/rt5677.c
>> @@ -538,9 +538,11 @@ static bool rt5677_readable_register(struct device *dev, unsigned int reg)
>>  }
>>
>>  static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0);
>> -static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -65625, 375, 0);
>> +/* Actual min=-65.625dB and step=0.375dB but only have 0.01 resolution. */
>> +static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -6475, 37, 0);
>>  static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0);
>> -static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -17625, 375, 0);
>> +/* Actual min=-17.625dB and step=0.375dB but only have 0.01 resolution. */
>> +static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -1739, 37, 0);
>>  static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0);
>>  static const DECLARE_TLV_DB_SCALE(st_vol_tlv, -4650, 150, 0);
>>
>> --
>> 2.1.2.330.g565301e
>>
diff mbox

Patch

diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c
index 16aa4d9..f139d5a 100644
--- a/sound/soc/codecs/rt5677.c
+++ b/sound/soc/codecs/rt5677.c
@@ -538,9 +538,11 @@  static bool rt5677_readable_register(struct device *dev, unsigned int reg)
 }
 
 static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0);
-static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -65625, 375, 0);
+/* Actual min=-65.625dB and step=0.375dB but only have 0.01 resolution. */
+static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -6475, 37, 0);
 static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0);
-static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -17625, 375, 0);
+/* Actual min=-17.625dB and step=0.375dB but only have 0.01 resolution. */
+static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -1739, 37, 0);
 static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0);
 static const DECLARE_TLV_DB_SCALE(st_vol_tlv, -4650, 150, 0);