All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: Daniel Drake <drake@endlessm.com>
Cc: alsa-devel@alsa-project.org, Liam Girdwood <lgirdwood@gmail.com>,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
	Mark Brown <broonie@kernel.org>,
	Linux Upstreaming Team <linux@endlessm.com>,
	yangxiaohua <yangxiaohua@everest-semi.com>
Subject: Re: [PATCH v3 1/2] ASoC: add es8316 codec driver
Date: Wed, 7 Jun 2017 00:02:28 +0900	[thread overview]
Message-ID: <f49354f4-3705-681c-d52d-709c9a25c8a2@sakamocchi.jp> (raw)
In-Reply-To: <CAD8Lp47tmZUa6MiMs2nf_mHRv0+x1ktobamXKjbTQzb37Kg9-Q@mail.gmail.com>

Hi,

On Jul 6 2017 22:59, Daniel Drake wrote:
> Thanks for the the info here! Based on the datasheet and newer headers
> I have updated it to:
> 
> static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(adc_pga_gain_tlv,
>      0, 0, TLV_DB_SCALE_ITEM(-3500, 0, 0),
>      1, 1, TLV_DB_SCALE_ITEM(0, 0, 0),
>      2, 2, TLV_DB_SCALE_ITEM(250, 0, 0),
>      3, 3, TLV_DB_SCALE_ITEM(450, 0, 0),
>      4, 4, TLV_DB_SCALE_ITEM(700, 0, 0),
>      5, 5, TLV_DB_SCALE_ITEM(1000, 0, 0),
>      6, 6, TLV_DB_SCALE_ITEM(1300, 0, 0),
>      7, 7, TLV_DB_SCALE_ITEM(1600, 0, 0),
>      8, 8, TLV_DB_SCALE_ITEM(1800, 0, 0),
>      9, 9, TLV_DB_SCALE_ITEM(2100, 0, 0),
>      10, 10, TLV_DB_SCALE_ITEM(2400, 0, 0),
> );

This is valid data as TLV of DB_RANGE type (11 entries).

> I believe the final entry means 24dB and does not have the large value
> that you have interpreted.

Exactly. I sent my previous message with the mistake. Unit of the first 
field of SNDRV_CTL_TLVD_DB_SCALE_ITEM is 0.01 dB, therefore it's 24.0 
dB, as you realized.

> There are many other drivers using similar values like this from rt5616.c:
> 
> /* {0, +20, +24, +30, +35, +40, +44, +50, +52} dB */
> static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(bst_tlv,
>      0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
>      1, 1, TLV_DB_SCALE_ITEM(2000, 0, 0),
>      2, 2, TLV_DB_SCALE_ITEM(2400, 0, 0),
>      3, 5, TLV_DB_SCALE_ITEM(3000, 500, 0),
>      6, 6, TLV_DB_SCALE_ITEM(4400, 0, 0),
>      7, 7, TLV_DB_SCALE_ITEM(5000, 0, 0),
>      8, 8, TLV_DB_SCALE_ITEM(5200, 0, 0),
> );
> 
> I'll test this change and wait for any further review comments before
> sending a v4. I've also noticed that hpout_vol_tlv can be corrected
> and simplified.

The data is valid. In this case, the table is:

Linear range: dB range: coeff: mute
  0 <-> 0:    0 <->    0:   0: 0
(0 <-> 1:    0 <-> 2000:2000: 0)
  1 <-> 1: 2000 <-> 2000:   0: 0
(1 <-> 2: 2000 <-> 2400: 400: 0)
  2 <-> 2: 2400 <-> 2400:   0: 0
(2 <-> 3: 2400 <-> 3000: 600: 0)
  3 <-> 5: 3000 <-> 4000: 500: 0
(5 <-> 6: 4000 <-> 4400: 400: 0)
  6 <-> 6: 4400 <-> 4400:   0: 0
(6 <-> 7: 4400 <-> 5000: 600: 0)
  7 <-> 7: 5000 <-> 5000:   0: 0
(7 <-> 8: 5000 <-> 5200: 200: 0)
  8 <-> 8: 5200 <-> 5299:   0: 0

We can use an alternate representation of the TLV data with brackets, like:

static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(bst_tlv,
      0, 1, SNDRV_CTL_TLVD_DB_SCALE_ITEM(0,    1000, 0),
      1, 2, SNDRV_CTL_TLVD_DB_SCALE_ITEM(2000,  400, 0),
      2, 3, SNDRV_CTL_TLVD_DB_SCALE_ITEM(2400,  600, 0),
      3, 5, SNDRV_CTL_TLVD_DB_SCALE_ITEM(3000,  500, 0),
      5, 6, SNDRV_CTL_TLVD_DB_SCALE_ITEM(4000,  400, 0), 

      6, 7, SNDRV_CTL_TLVD_DB_SCALE_ITEM(4400,  600, 0), 

      7, 8, SNDRV_CTL_TLVD_DB_SCALE_ITEM(5000,  200, 0), 

);


Well, in your case, the hardware supports between -35 dB and 24 dB with 
variable 10 steps and the table can also be:

0 <->  1: -3500 <->    0: 3500: 0
1 <->  2:     0 <->  250:  250: 0
2 <->  3:   250 <->  450:  200: 0
3 <->  4:   450 <->  700:  250: 0
4 <->  7:   700 <-> 1600:  300: 0
7 <->  8:  1600 <-> 1800:  200: 0
8 <-> 10:  1800 <-> 2400:  300: 0

Therefore, we can also use an alternate representation, below.

static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(adc_pga_gain_tlv,
     0,  1, SNDRV_CTL_TLVD_DB_SCALE_ITEM(-3500, 3500, 0),
     1,  2, SNDRV_CTL_TLVD_DB_SCALE_ITEM(    0,  250, 0),
     2,  3, SNDRV_CTL_TLVD_DB_SCALE_ITEM(  250,  200, 0),
     3,  4, SNDRV_CTL_TLVD_DB_SCALE_ITEM(  450,  250, 0),
     4,  7, SNDRV_CTL_TLVD_DB_SCALE_ITEM(  700,  300, 0),
     7,  8, SNDRV_CTL_TLVD_DB_SCALE_ITEM( 1600,  200, 0),
     8, 10, SNDRV_CTL_TLVD_DB_SCALE_ITEM( 1800,  300, 0),
);

In alsa-lib, there's a sample program for user-defined control element 
set[1]. It includes some examples of TLV data. 
allocate_int64_elem_set_tlv() adds TLV data similar to your case. This 
data can be parsed by alsa-lib, like:

$ amixer contents
...
numid=4566,iface=MIXER,name='userspace-control-element-INTEGER64',index=896
   ; type=INTEGER64,access=rw---RW-,values=64,min=0,max=10000,step=1
   : 
values=1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
   | dBrange-
     rangemin=0,,rangemax=4
       | dBscale-min=-59.40dB,step=0.44dB,mute=1
     rangemin=4,,rangemax=22
       | dBscale-min=-56.36dB,step=0.60dB,mute=0
     rangemin=22,,rangemax=33
       | dBscale-min=-45.56dB,step=0.76dB,mute=0
     rangemin=33,,rangemax=37
       | dBscale-min=-40.72dB,step=0.44dB,mute=0
     rangemin=37,,rangemax=48
       | dBscale-min=-38.32dB,step=0.76dB,mute=0
     rangemin=48,,rangemax=66
       | dBscale-min=-29.96dB,step=0.60dB,mute=0
     rangemin=66,,rangemax=84
       | dBscale-min=-22.04dB,step=0.44dB,mute=0
     rangemin=84,,rangemax=95
       | dBscale-min=-8.36dB,step=0.60dB,mute=0
     rangemin=95,,rangemax=99
       | dBscale-min=-1.76dB,step=0.76dB,mute=0
     rangemin=100,,rangemax=10000
       | dBscale-min=0.00dB,step=0.00dB,mute=0
...

Both way of representation is valid. For your information.


[1] user-ctl-element-set.c
http://git.alsa-project.org/?p=alsa-lib.git;a=blob;f=test/user-ctl-element-set.c


Regards

Takashi Sakamoto

      reply	other threads:[~2017-06-06 15:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-05 20:16 [PATCH v3 1/2] ASoC: add es8316 codec driver Daniel Drake
2017-06-05 20:16 ` [PATCH v3 2/2] ASoC: Intel: add machine driver for BYT/CHT + ES8316 Daniel Drake
2017-06-13 21:08   ` Applied "ASoC: Intel: add machine driver for BYT/CHT + ES8316" to the asoc tree Mark Brown
2017-06-06  0:30 ` [PATCH v3 1/2] ASoC: add es8316 codec driver Takashi Sakamoto
2017-06-06 13:59   ` Daniel Drake
2017-06-06 15:02     ` Takashi Sakamoto [this message]

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=f49354f4-3705-681c-d52d-709c9a25c8a2@sakamocchi.jp \
    --to=o-takashi@sakamocchi.jp \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=drake@endlessm.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux@endlessm.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=yangxiaohua@everest-semi.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 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.