All of lore.kernel.org
 help / color / mirror / Atom feed
* ASoC: How to declare volume TLV dB scale?
@ 2015-06-12 12:02 Sergej Sawazki
  2015-06-12 16:28 ` Clemens Ladisch
  0 siblings, 1 reply; 8+ messages in thread
From: Sergej Sawazki @ 2015-06-12 12:02 UTC (permalink / raw)
  To: alsa-devel

Dear all,
 
could someone please help me to understand the mixer controls TLV scale?
What would be the DECLARE_TLV_DB_SCALE values for the following example?
 
reg. value:  0    ..  0x3ff
phys. value: 0dB  .. -128dB
volume:      100% ..  0%(mute)

What does TLV actually stand for?

Many thanks in advance,
Sergej Sawazki
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: ASoC: How to declare volume TLV dB scale?
  2015-06-12 12:02 ASoC: How to declare volume TLV dB scale? Sergej Sawazki
@ 2015-06-12 16:28 ` Clemens Ladisch
  2015-06-12 19:26   ` Sergej Sawazki
  0 siblings, 1 reply; 8+ messages in thread
From: Clemens Ladisch @ 2015-06-12 16:28 UTC (permalink / raw)
  To: Sergej Sawazki, alsa-devel

Sergej Sawazki wrote:
> could someone please help me to understand the mixer controls TLV scale?
> What would be the DECLARE_TLV_DB_SCALE values for the following example?
>
> reg. value:  0    ..  0x3ff
> phys. value: 0dB  .. -128dB
> volume:      100% ..  0%(mute)

0% volume would be -∞ dB.

And how are the register values mapped between the min/max values?
Does 0x200 correspond to -64 dB, or 50 % of the sample value, or
50 % of the volume?

> What does TLV actually stand for?

Type-length-value.  It's an implementation detail.


Regards,
Clemens
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: ASoC: How to declare volume TLV dB scale?
  2015-06-12 16:28 ` Clemens Ladisch
@ 2015-06-12 19:26   ` Sergej Sawazki
  2015-06-12 19:47     ` Clemens Ladisch
  0 siblings, 1 reply; 8+ messages in thread
From: Sergej Sawazki @ 2015-06-12 19:26 UTC (permalink / raw)
  To: Clemens Ladisch, alsa-devel

On Fri, 12 Jun 2015 18:28:54 +0200, Clemens Ladisch wrote:
> Sergej Sawazki wrote:
>> could someone please help me to understand the mixer controls TLV scale?
>> What would be the DECLARE_TLV_DB_SCALE values for the following example?
>>
>> reg. value:  0    ..  0x3ff
>> phys. value: 0dB  .. -128dB
>> volume:      100% ..  0%(mute)
>
> 0% volume would be -∞ dB.
>
> And how are the register values mapped between the min/max values?
> Does 0x200 correspond to -64 dB, or 50 % of the sample value, or
> 50 % of the volume?
>

The output of the DAC can be attenuated in 0.125dB steps, so 0x200
would be -64dB.

register value | attenuation level (dB) | volume (%)
---------------+------------------------+-----------
   0x000        |     0.0                |  100
   0x001        |    -0.125              |
    ...         |    ...                 |  ...
   0x200        |   -64.0                |
    ...         |    ...                 |  ...
   0x3fe        |  -127.75               |
   0x3ff        |    -∞ (mute)           |    0

Thanks,
Sergej
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: ASoC: How to declare volume TLV dB scale?
  2015-06-12 19:26   ` Sergej Sawazki
@ 2015-06-12 19:47     ` Clemens Ladisch
  2015-06-13  7:15       ` Takashi Iwai
  0 siblings, 1 reply; 8+ messages in thread
From: Clemens Ladisch @ 2015-06-12 19:47 UTC (permalink / raw)
  To: Sergej Sawazki, alsa-devel

Sergej Sawazki wrote:
> On Fri, 12 Jun 2015 18:28:54 +0200, Clemens Ladisch wrote:
>> Sergej Sawazki wrote:
>>> could someone please help me to understand the mixer controls TLV scale?
>>> What would be the DECLARE_TLV_DB_SCALE values for the following example?
>>>
>>> reg. value:  0    ..  0x3ff
>>> phys. value: 0dB  .. -128dB
>>> volume:      100% ..  0%(mute)
>>
>> 0% volume would be -∞ dB.
>>
>> And how are the register values mapped between the min/max values?
>> Does 0x200 correspond to -64 dB, or 50 % of the sample value, or
>> 50 % of the volume?
>
> The output of the DAC can be attenuated in 0.125dB steps, so 0x200
> would be -64dB.
>
> register value | attenuation level (dB) | volume (%)
> ---------------+------------------------+-----------
>   0x000        |     0.0                |  100
>   0x001        |    -0.125              |
>    ...         |    ...                 |  ...
>   0x200        |   -64.0                |
>    ...         |    ...                 |  ...
>   0x3fe        |  -127.75               |
>   0x3ff        |    -∞ (mute)           |    0

0.125 dB is too small for the 0.01 dB resolution of DECLARE_TLV_DB_SCALE,
so you have to use DB_MINMAX instead:  TLV_DB_MINMAX_MUTE_ITEM(-128, 0)


Regards,
Clemens
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: ASoC: How to declare volume TLV dB scale?
  2015-06-12 19:47     ` Clemens Ladisch
@ 2015-06-13  7:15       ` Takashi Iwai
  2015-06-13 10:10         ` Sergej Sawazki
  0 siblings, 1 reply; 8+ messages in thread
From: Takashi Iwai @ 2015-06-13  7:15 UTC (permalink / raw)
  To: Clemens Ladisch; +Cc: Sergej Sawazki, alsa-devel

At Fri, 12 Jun 2015 21:47:46 +0200,
Clemens Ladisch wrote:
> 
> Sergej Sawazki wrote:
> > On Fri, 12 Jun 2015 18:28:54 +0200, Clemens Ladisch wrote:
> >> Sergej Sawazki wrote:
> >>> could someone please help me to understand the mixer controls TLV scale?
> >>> What would be the DECLARE_TLV_DB_SCALE values for the following example?
> >>>
> >>> reg. value:  0    ..  0x3ff
> >>> phys. value: 0dB  .. -128dB
> >>> volume:      100% ..  0%(mute)
> >>
> >> 0% volume would be -∞ dB.
> >>
> >> And how are the register values mapped between the min/max values?
> >> Does 0x200 correspond to -64 dB, or 50 % of the sample value, or
> >> 50 % of the volume?
> >
> > The output of the DAC can be attenuated in 0.125dB steps, so 0x200
> > would be -64dB.
> >
> > register value | attenuation level (dB) | volume (%)
> > ---------------+------------------------+-----------
> >   0x000        |     0.0                |  100
> >   0x001        |    -0.125              |
> >    ...         |    ...                 |  ...
> >   0x200        |   -64.0                |
> >    ...         |    ...                 |  ...
> >   0x3fe        |  -127.75               |
> >   0x3ff        |    -∞ (mute)           |    0
> 
> 0.125 dB is too small for the 0.01 dB resolution of DECLARE_TLV_DB_SCALE,
> so you have to use DB_MINMAX instead:  TLV_DB_MINMAX_MUTE_ITEM(-128, 0)

And you need to implement the ctl get/put callback to revert the value
as (0x3ff - raw value).  An decrement value isn't supposed to work.


Takashi
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: ASoC: How to declare volume TLV dB scale?
  2015-06-13  7:15       ` Takashi Iwai
@ 2015-06-13 10:10         ` Sergej Sawazki
  2015-06-13 10:29           ` Clemens Ladisch
  0 siblings, 1 reply; 8+ messages in thread
From: Sergej Sawazki @ 2015-06-13 10:10 UTC (permalink / raw)
  To: Takashi Iwai, Clemens Ladisch; +Cc: alsa-devel

On Sat, 13 Jun 2015 09:15:49 +0200, Takashi Iwai wrote:
> At Fri, 12 Jun 2015 21:47:46 +0200,
> Clemens Ladisch wrote:
>>
>> Sergej Sawazki wrote:
>>>
>>> The output of the DAC can be attenuated in 0.125dB steps, so 0x200
>>> would be -64dB.
>>
>> 0.125 dB is too small for the 0.01 dB resolution of DECLARE_TLV_DB_SCALE,
>> so you have to use DB_MINMAX instead:  TLV_DB_MINMAX_MUTE_ITEM(-128, 0)
>
> And you need to implement the ctl get/put callback to revert the value
> as (0x3ff - raw value).  An decrement value isn't supposed to work.
>

Clemens, Takashi, thanks for your answers.

I am getting the expected dB scaling with:
DECLARE_TLV_DB_MINMAX_MUTE(vol_tlv, -12800, 0)
does it make sense?

Regards,
Sergej

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: ASoC: How to declare volume TLV dB scale?
  2015-06-13 10:10         ` Sergej Sawazki
@ 2015-06-13 10:29           ` Clemens Ladisch
  2015-06-13 10:45             ` Sergej Sawazki
  0 siblings, 1 reply; 8+ messages in thread
From: Clemens Ladisch @ 2015-06-13 10:29 UTC (permalink / raw)
  To: Sergej Sawazki, Takashi Iwai; +Cc: alsa-devel

Sergej Sawazki wrote:
> On Sat, 13 Jun 2015 09:15:49 +0200, Takashi Iwai wrote:
>> Clemens Ladisch wrote:
>>> 0.125 dB is too small for the 0.01 dB resolution of DECLARE_TLV_DB_SCALE,
>>> so you have to use DB_MINMAX instead:  TLV_DB_MINMAX_MUTE_ITEM(-128, 0)
>>
>> And you need to implement the ctl get/put callback to revert the value
>> as (0x3ff - raw value).  An decrement value isn't supposed to work.

If you're using one of the SOC_xxx_TLV macros, you would set the 'invert'
parameter.

> I am getting the expected dB scaling with:
> DECLARE_TLV_DB_MINMAX_MUTE(vol_tlv, -12800, 0)
> does it make sense?

Yes.  (-128 would have been -1.28 dB.)


Regards,
Clemens

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: ASoC: How to declare volume TLV dB scale?
  2015-06-13 10:29           ` Clemens Ladisch
@ 2015-06-13 10:45             ` Sergej Sawazki
  0 siblings, 0 replies; 8+ messages in thread
From: Sergej Sawazki @ 2015-06-13 10:45 UTC (permalink / raw)
  To: Clemens Ladisch, Takashi Iwai; +Cc: alsa-devel

On Sat, 13 Jun 2015 12:29:35 +0200, Clemens Ladisch wrote:
> Sergej Sawazki wrote:
>> On Sat, 13 Jun 2015 09:15:49 +0200, Takashi Iwai wrote:

>>> And you need to implement the ctl get/put callback to revert the value
>>> as (0x3ff - raw value).  An decrement value isn't supposed to work.
>
> If you're using one of the SOC_xxx_TLV macros, you would set the 'invert'
> parameter.
>
>> I am getting the expected dB scaling with:
>> DECLARE_TLV_DB_MINMAX_MUTE(vol_tlv, -12800, 0)
>> does it make sense?
>
> Yes.  (-128 would have been -1.28 dB.)
>

Thanks.

Regards,
Sergej

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-06-13 10:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-12 12:02 ASoC: How to declare volume TLV dB scale? Sergej Sawazki
2015-06-12 16:28 ` Clemens Ladisch
2015-06-12 19:26   ` Sergej Sawazki
2015-06-12 19:47     ` Clemens Ladisch
2015-06-13  7:15       ` Takashi Iwai
2015-06-13 10:10         ` Sergej Sawazki
2015-06-13 10:29           ` Clemens Ladisch
2015-06-13 10:45             ` Sergej Sawazki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.