[alsa-devel] [PATCH v3 1/2] ASoC: add es8316 codec driver
Takashi Sakamoto
o-takashi at sakamocchi.jp
Tue Jun 6 02:30:25 CEST 2017
Hi,
On Jun 6 2017 05:16, Daniel Drake wrote:
> diff --git a/sound/soc/codecs/es8316.c b/sound/soc/codecs/es8316.c
> new file mode 100644
> index 000000000000..ced60a56b4cb
> --- /dev/null
> +++ b/sound/soc/codecs/es8316.c
> ...
> +/*
> + * 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),
> + 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
More information about the Alsa-devel
mailing list