Skip to contentSkip to conversation

ASoC: add es8316 codec driver

PATCH Superseded Daniel Drake 3 participants 6 messages Jun 5, 2017 – Jun 13, 2017

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 ASoC: add es8316 codec driver

Add a codec driver for the Everest ES8316, based on code provided by David Yang from Everest Semi.

I limited the functionality to items where the vendor code was clear, and things that can be tested on the Weibu F3C (Intel Cherry Trail). As a result the initial implementation only supports running in slave mode at single speed (up to 48kHz sample rate) using I2S. HPD is not supported.

[[email protected]: significant cleanups and simplifications,
remove dead/unclear code]

---

Notes:
v3:
- move to boolean controls where appropriate
- name controls with Volume suffix where appropriate
- clean up probe routine
- control more registers with DAPM, replacing set_bias_level
- improve DAPM widget naming consistency
- fix i2c device id

v2:
- Add sign-off from David Yang
- Only support whole number rates calculated with mclk ratios

 sound/soc/codecs/Kconfig  |   4 +
 sound/soc/codecs/Makefile |   2 +
 sound/soc/codecs/es8316.c | 629 ++++++++++++++++++++++++++++++++++++++++++++++
 sound/soc/codecs/es8316.h | 129 ++++++++++
 4 files changed, 764 insertions(+)
 create mode 100644 sound/soc/codecs/es8316.c
 create mode 100644 sound/soc/codecs/es8316.h
sound/soc/codecs/Kconfig +4 -0
index 883ed4c8a551..c6286e5ba511 100644
@@ -72,6 +72,7 @@ config SND_SOC_ALL_CODECS
 	select SND_SOC_DA9055 if I2C
 	select SND_SOC_DIO2125
 	select SND_SOC_DMIC
+	select SND_SOC_ES8316 if I2C
 	select SND_SOC_ES8328_SPI if SPI_MASTER
 	select SND_SOC_ES8328_I2C if I2C
 	select SND_SOC_ES7134
@@ -543,6 +544,9 @@ config SND_SOC_HDMI_CODEC
 config SND_SOC_ES7134
        tristate "Everest Semi ES7134 CODEC"
 
+config SND_SOC_ES8316
+	tristate "Everest Semi ES8316 CODEC"
+
 config SND_SOC_ES8328
 	tristate
 
sound/soc/codecs/Makefile +2 -0
index 28a63fdaf982..e878306ce46e 100644
@@ -65,6 +65,7 @@ snd-soc-da732x-objs := da732x.o
 snd-soc-da9055-objs := da9055.o
 snd-soc-dmic-objs := dmic.o
 snd-soc-es7134-objs := es7134.o
+snd-soc-es8316-objs := es8316.o
 snd-soc-es8328-objs := es8328.o
 snd-soc-es8328-i2c-objs := es8328-i2c.o
 snd-soc-es8328-spi-objs := es8328-spi.o
@@ -300,6 +301,7 @@ obj-$(CONFIG_SND_SOC_DA732X)	+= snd-soc-da732x.o
 obj-$(CONFIG_SND_SOC_DA9055)	+= snd-soc-da9055.o
 obj-$(CONFIG_SND_SOC_DMIC)	+= snd-soc-dmic.o
 obj-$(CONFIG_SND_SOC_ES7134)	+= snd-soc-es7134.o
+obj-$(CONFIG_SND_SOC_ES8316)    += snd-soc-es8316.o
 obj-$(CONFIG_SND_SOC_ES8328)	+= snd-soc-es8328.o
 obj-$(CONFIG_SND_SOC_ES8328_I2C)+= snd-soc-es8328-i2c.o
 obj-$(CONFIG_SND_SOC_ES8328_SPI)+= snd-soc-es8328-spi.o
sound/soc/codecs/es8316.c new file +629 -0

629 lines not on this page · raw message

sound/soc/codecs/es8316.h new file +129 -0

129 lines not on this page · raw message

Signature · 1 line
2.11.0
#1 lore raw

PATCH v3 2/2 ASoC: Intel: add machine driver for BYT/CHT + ES8316

Add new machine driver, tested with Weibu F3C MiniPC.

Based heavily on code provided by David Yang @ Everest, and other machine drivers in the same directory.

[[email protected]: cleanups and modernization]

---

Notes:
v3:
- fix inverted logic when checking clk_prepare_enable result
- update for recent sst_acpi.c changes

v2:
- add sign-off from David Yang
- fix bytbyt typo
- mention that BYT-CR/SSP0 is not supported
- mention which mic was tested
- setup clocks at init time, avoids need for platform clock control

 sound/soc/intel/Kconfig                |  12 ++
 sound/soc/intel/atom/sst/sst_acpi.c    |   7 +
 sound/soc/intel/boards/Makefile        |   2 +
 sound/soc/intel/boards/bytcht_es8316.c | 300 +++++++++++++++++++++++++++++++++
 4 files changed, 321 insertions(+)
 create mode 100644 sound/soc/intel/boards/bytcht_es8316.c
sound/soc/intel/Kconfig +12 -0
index a9c50d022e73..35a6a5c55914 100644
@@ -214,6 +214,18 @@ config SND_SOC_INTEL_BYT_CHT_DA7213_MACH
 	  platforms with DA7212/7213 audio codec.
 	  If unsure select "N".
 
+config SND_SOC_INTEL_BYT_CHT_ES8316_MACH
+	tristate "ASoC Audio driver for Intel Baytrail & Cherrytrail with ES8316 codec"
+	depends on X86_INTEL_LPSS && I2C && ACPI
+	select SND_SOC_ES8316
+	select SND_SST_ATOM_HIFI2_PLATFORM
+	select SND_SST_IPC_ACPI
+	select SND_SOC_INTEL_SST_MATCH if ACPI
+	help
+	  This adds support for ASoC machine driver for Intel(R) Baytrail &
+	  Cherrytrail platforms with ES8316 audio codec.
+	  If unsure select "N".
+
 config SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH
 	tristate "ASoC Audio driver for Intel Baytrail & Cherrytrail platform with no codec (MinnowBoard MAX, Up)"
 	depends on X86_INTEL_LPSS && I2C && ACPI
sound/soc/intel/atom/sst/sst_acpi.c +7 -0
index 592f6afaf2a5..ff96d1ad3d4e 100644
@@ -625,6 +625,13 @@ static struct sst_acpi_mach sst_acpi_chv[] = {
 		.board = "bytcht_da7213",
 		.pdata = &chv_platform_data
 	},
+	{
+		.id = "ESSX8316",
+		.drv_name = "bytcht_es8316",
+		.fw_filename = "intel/fw_sst_22a8.bin",
+		.board = "bytcht_es8316",
+		.pdata = &chv_platform_data
+	},
 	/* some CHT-T platforms rely on RT5640, use Baytrail machine driver */
 	{
 		.id = "10EC5640",
sound/soc/intel/boards/Makefile +2 -0
index c92ebcac0222..c4e986f03ec9 100644
@@ -11,6 +11,7 @@ snd-soc-sst-cht-bsw-rt5672-objs := cht_bsw_rt5672.o
 snd-soc-sst-cht-bsw-rt5645-objs := cht_bsw_rt5645.o
 snd-soc-sst-cht-bsw-max98090_ti-objs := cht_bsw_max98090_ti.o
 snd-soc-sst-byt-cht-da7213-objs := bytcht_da7213.o
+snd-soc-sst-byt-cht-es8316-objs := bytcht_es8316.o
 snd-soc-sst-byt-cht-nocodec-objs := bytcht_nocodec.o
 snd-soc-kbl_rt5663_max98927-objs := kbl_rt5663_max98927.o
 snd-soc-skl_rt286-objs := skl_rt286.o
@@ -30,6 +31,7 @@ obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_RT5672_MACH) += snd-soc-sst-cht-bsw-rt5672.o
 obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_RT5645_MACH) += snd-soc-sst-cht-bsw-rt5645.o
 obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_MAX98090_TI_MACH) += snd-soc-sst-cht-bsw-max98090_ti.o
 obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_DA7213_MACH) += snd-soc-sst-byt-cht-da7213.o
+obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_ES8316_MACH) += snd-soc-sst-byt-cht-es8316.o
 obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH) += snd-soc-sst-byt-cht-nocodec.o
 obj-$(CONFIG_SND_SOC_INTEL_KBL_RT5663_MAX98927_MACH) += snd-soc-kbl_rt5663_max98927.o
 obj-$(CONFIG_SND_SOC_INTEL_SKL_RT286_MACH) += snd-soc-skl_rt286.o
sound/soc/intel/boards/bytcht_es8316.c new file +300 -0

300 lines not on this page · raw message

Signature · 1 line
2.11.0
maintainer
#2 lore raw

Applied "ASoC: Intel: add machine driver for BYT/CHT + ES8316" to the asoc tree

The patch

ASoC: Intel: add machine driver for BYT/CHT + ES8316

has been applied to the asoc tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From a03bdaa565cbf23fa86697727a7d2bf1465e7a03 Mon Sep 17 00:00:00 2001

From: Daniel Drake <[email protected]>
Date: Mon, 12 Jun 2017 11:01:46 -0600
Subject: [PATCH] ASoC: Intel: add machine driver for BYT/CHT + ES8316

Add new machine driver, tested with Weibu F3C MiniPC.

Based heavily on code provided by David Yang @ Everest, and other machine drivers in the same directory.

---
 sound/soc/intel/Kconfig                |  12 ++
 sound/soc/intel/atom/sst/sst_acpi.c    |   7 +
 sound/soc/intel/boards/Makefile        |   2 +
 sound/soc/intel/boards/bytcht_es8316.c | 300 +++++++++++++++++++++++++++++++++
 4 files changed, 321 insertions(+)
 create mode 100644 sound/soc/intel/boards/bytcht_es8316.c
sound/soc/intel/Kconfig +12 -0
index a9c50d022e73..35a6a5c55914 100644
@@ -214,6 +214,18 @@ config SND_SOC_INTEL_BYT_CHT_DA7213_MACH
 	  platforms with DA7212/7213 audio codec.
 	  If unsure select "N".
 
+config SND_SOC_INTEL_BYT_CHT_ES8316_MACH
+	tristate "ASoC Audio driver for Intel Baytrail & Cherrytrail with ES8316 codec"
+	depends on X86_INTEL_LPSS && I2C && ACPI
+	select SND_SOC_ES8316
+	select SND_SST_ATOM_HIFI2_PLATFORM
+	select SND_SST_IPC_ACPI
+	select SND_SOC_INTEL_SST_MATCH if ACPI
+	help
+	  This adds support for ASoC machine driver for Intel(R) Baytrail &
+	  Cherrytrail platforms with ES8316 audio codec.
+	  If unsure select "N".
+
 config SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH
 	tristate "ASoC Audio driver for Intel Baytrail & Cherrytrail platform with no codec (MinnowBoard MAX, Up)"
 	depends on X86_INTEL_LPSS && I2C && ACPI
sound/soc/intel/atom/sst/sst_acpi.c +7 -0
index cf88cd1865fb..0e928d54305d 100644
@@ -611,6 +611,13 @@ static struct sst_acpi_mach sst_acpi_chv[] = {
 		.board = "bytcht_da7213",
 		.pdata = &chv_platform_data
 	},
+	{
+		.id = "ESSX8316",
+		.drv_name = "bytcht_es8316",
+		.fw_filename = "intel/fw_sst_22a8.bin",
+		.board = "bytcht_es8316",
+		.pdata = &chv_platform_data
+	},
 	/* some CHT-T platforms rely on RT5640, use Baytrail machine driver */
 	{
 		.id = "10EC5640",
sound/soc/intel/boards/Makefile +2 -0
index c92ebcac0222..c4e986f03ec9 100644
@@ -11,6 +11,7 @@ snd-soc-sst-cht-bsw-rt5672-objs := cht_bsw_rt5672.o
 snd-soc-sst-cht-bsw-rt5645-objs := cht_bsw_rt5645.o
 snd-soc-sst-cht-bsw-max98090_ti-objs := cht_bsw_max98090_ti.o
 snd-soc-sst-byt-cht-da7213-objs := bytcht_da7213.o
+snd-soc-sst-byt-cht-es8316-objs := bytcht_es8316.o
 snd-soc-sst-byt-cht-nocodec-objs := bytcht_nocodec.o
 snd-soc-kbl_rt5663_max98927-objs := kbl_rt5663_max98927.o
 snd-soc-skl_rt286-objs := skl_rt286.o
@@ -30,6 +31,7 @@ obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_RT5672_MACH) += snd-soc-sst-cht-bsw-rt5672.o
 obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_RT5645_MACH) += snd-soc-sst-cht-bsw-rt5645.o
 obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_MAX98090_TI_MACH) += snd-soc-sst-cht-bsw-max98090_ti.o
 obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_DA7213_MACH) += snd-soc-sst-byt-cht-da7213.o
+obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_ES8316_MACH) += snd-soc-sst-byt-cht-es8316.o
 obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH) += snd-soc-sst-byt-cht-nocodec.o
 obj-$(CONFIG_SND_SOC_INTEL_KBL_RT5663_MAX98927_MACH) += snd-soc-kbl_rt5663_max98927.o
 obj-$(CONFIG_SND_SOC_INTEL_SKL_RT286_MACH) += snd-soc-skl_rt286.o
sound/soc/intel/boards/bytcht_es8316.c new file +300 -0

300 lines not on this page · raw message

Signature · 1 line
2.11.0
#3 lore raw
In reply to Daniel Drake

Hi,

Quoted 22 lines · Daniel Drake
sound/soc/codecs/es8316.c new file +16 -0
new file mode 100644
index 000000000000..ced60a56b4cb
...
+/*
+ * ES8316 controls
+ */
+static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -9600, 50, 1);
+static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -9600, 50, 1);
+static const DECLARE_TLV_DB_SCALE(alc_max_gain_tlv, -650, 150, 0);
+static const DECLARE_TLV_DB_SCALE(alc_min_gain_tlv, -1200, 150, 0);
+static const DECLARE_TLV_DB_SCALE(alc_target_tlv, -1650, 150, 0);
+static const DECLARE_TLV_DB_SCALE(hpmixer_gain_tlv, -1200, 150, 0);
+
+static unsigned int adc_pga_gain_tlv[] = {
+	TLV_DB_RANGE_HEAD(12),
+	0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
+	1, 1, TLV_DB_SCALE_ITEM(300, 0, 0),
+	2, 2, TLV_DB_SCALE_ITEM(600, 0, 0),
+	3, 3, TLV_DB_SCALE_ITEM(900, 0, 0),

sound/soc/codecs/es8316.c line 66

Quoted 10 lines
sound/soc/codecs/es8316.c new file +10 -0
+	4, 4, TLV_DB_SCALE_ITEM(1200, 0, 0),
+	5, 5, TLV_DB_SCALE_ITEM(1500, 0, 0),
+	6, 6, TLV_DB_SCALE_ITEM(1800, 0, 0),
+	7, 7, TLV_DB_SCALE_ITEM(2100, 0, 0),
+	8, 8, TLV_DB_SCALE_ITEM(2400, 0, 0),
+};
+static unsigned int hpout_vol_tlv[] = {
+	TLV_DB_RANGE_HEAD(1),
+	0, 3, TLV_DB_SCALE_ITEM(-4800, 1200, 0),
+};

To me, the array of 'adc_pga_gain_tlv' includes invalid members as 'SNDRV_CTL_TLVT_DB_RANGE'. In your code, the array represents below table:

Linear range: dB range: coeff: mute
0 <-> 0: 0 <-> 0: 0: 0

1 <-> 1:  300 <->  300: 0: 0
2 <-> 2:  600 <->  600: 0: 0
3 <-> 3:  900 <->  900: 0: 0

4 <-> 4: 1200 <-> 1200: 0: 0
5 <-> 5: 1500 <-> 1500: 0: 0
6 <-> 6: 1800 <-> 1800: 0: 0
7 <-> 7: 2100 <-> 2100: 0: 0
8 <-> 8: 2400 <-> 2400: 0: 0

Can I ask you to ensure that your hardware has jumps for current dB value against given linear value and investigate the reason that maximum value in this table has too large value (2,400) as dB representation.

If you don't have real hardware or don't find the detail in datasheet of ES8316, please inform it. Then, I leave the decision of merging to Mark Brown, a maintainer of ALSA SoC part.

Additionally, these macros are obsoleted. See memo in header[1]. It's better to macros in UAPI header[2] for newer codes. Furthermore, the usage of 'TLV_DB_RANGE_HEAD' is obsoleted with 'DECLARE_TLV_DB_RANGE'. It's better to use 'SNDRV_CTL_TLVD_DECLARE_DB_RANGE', instead. TLV data is exposed to userspace applications as is. It's better to use the same name of macro in UAPI header so that application developers can easily reach your codes.

[1] include/sound/tlv.h
https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git/tree/include/sound/tlv.h#n52
[2] include/uapi/sound/tlv.h
https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git/tree/include/uapi/sound/tlv.h

Regards

Takashi Sakamoto

#4 lore raw

Hi Takashi,

Quoted 14 lines · Takashi Sakamoto

To me, the array of 'adc_pga_gain_tlv' includes invalid members as 'SNDRV_CTL_TLVT_DB_RANGE'. In your code, the array represents below table:

Linear range: dB range: coeff: mute
0 <-> 0: 0 <-> 0: 0: 0

1 <-> 1:  300 <->  300: 0: 0
2 <-> 2:  600 <->  600: 0: 0
3 <-> 3:  900 <->  900: 0: 0

4 <-> 4: 1200 <-> 1200: 0: 0
5 <-> 5: 1500 <-> 1500: 0: 0
6 <-> 6: 1800 <-> 1800: 0: 0
7 <-> 7: 2100 <-> 2100: 0: 0
8 <-> 8: 2400 <-> 2400: 0: 0

Quoted 3 lines

Can I ask you to ensure that your hardware has jumps for current dB value against given linear value and investigate the reason that maximum value in this table has too large value (2,400) as dB representation.

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),

);

I believe the final entry means 24dB and does not have the large value that you have interpreted.
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.

Thanks
Daniel

#5 lore raw

Hi,

Quoted 15 lines · Daniel Drake

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),
Quoted 1 line

);

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

Quoted 2 lines

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.

Quoted 11 lines

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),
Quoted 5 lines

);

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