History log of /linux-master/sound/soc/codecs/es8316.c
Revision Date Author Comments
# 869f3078 29-Aug-2023 Marian Postevca <posteuca@mutex.one>

ASoC: es8316: Enable support for MCLK div by 2

To properly support a line of Huawei laptops with an AMD CPU
and an ES8336 codec connected to the ACP3X module, we need
to enable the codec option to divide the MCLK by 2.
This is needed because for at least one SKU that has a 48Mhz
MCLK the sound is distorted unless the MCLK div by 2 option
is enabled.

The option to divide the MCLK will first be tried. If no suitable
clocking can be generated from this frequency, then the normal
non-halved MCLK frequency will be tried.

Signed-off-by: Marian Postevca <posteuca@mutex.one>
Link: https://lore.kernel.org/r/20230829220116.1159-4-posteuca@mutex.one
Signed-off-by: Mark Brown <broonie@kernel.org>


# a43c0dc1 29-Aug-2023 Marian Postevca <posteuca@mutex.one>

ASoC: es8316: Replace NR_SUPPORTED_MCLK_LRCK_RATIOS with ARRAY_SIZE()

No need for a special define since we can use ARRAY_SIZE() directly,
and won't need to worry to keep it in sync.

Signed-off-by: Marian Postevca <posteuca@mutex.one>
Link: https://lore.kernel.org/r/20230829220116.1159-3-posteuca@mutex.one
Signed-off-by: Mark Brown <broonie@kernel.org>


# 2f06f231 29-Aug-2023 Marian Postevca <posteuca@mutex.one>

ASoC: es8316: Enable support for S32 LE format

This CODEC does support the S32 LE format in es8316_pcm_hw_params(),
but doesn't have it enabled in ES8316_FORMATS. Enable it so that we
have more options to match with components.

Signed-off-by: Marian Postevca <posteuca@mutex.one>
Link: https://lore.kernel.org/r/20230829220116.1159-2-posteuca@mutex.one
Signed-off-by: Mark Brown <broonie@kernel.org>


# c30d10ae 29-Jun-2023 Cezary Rojewski <cezary.rojewski@intel.com>

ASoC: codecs: es8316: Add support for S24_3LE format

Codec supports words that are 16/18/20/24/32 bits long. In case of 24,
it should be treated as 24/24 not 24/32 i.e.: 24 valid bit-depth in 24
bit-depth container.

For compatibility reasons, S24_LE is left as is.

Cc: Zhu Ning <zhuning@everest-semi.com>
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20230629112449.1755928-3-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# be7dc10a 29-Jun-2023 Cezary Rojewski <cezary.rojewski@intel.com>

ASoC: codecs: es8316: Add support for 24 MHz MCLK

MCLK operates on 24MHz on Intel KabyLake-based platforms. To support
that frequency add new MCLK-LRCK ratio.

While at it, utilize ARRAY_SIZE rather than hardcode to improve
robustness.

Cc: Zhu Ning <zhuning@everest-semi.com>
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20230629112449.1755928-2-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# d20d35d1 18-Jul-2023 Edgar <ljijcj@163.com>

ASoc: codecs: ES8316: Fix DMIC config

According to the datasheet, the DMIC config should
be changed to { 0, 2 ,3 }

Signed-off-by: Edgar <ljijcj@163.com>
Link: https://lore.kernel.org/r/20230719054722.401954-1-ljijcj@163.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 7ae8039f 09-Jun-2023 Mark Brown <broonie@kernel.org>

ASoC: es8316: Use maple tree register cache

The es8316 can only support single register read and write operations
so does not benefit from block writes. This means it gets no benefit from
using the rbtree register cache over the maple tree register cache so
convert it to use maple trees instead, it is more modern.

Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20230609-asoc-es-maple-v1-1-45ada77f5643@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# 60413129 30-May-2023 Cristian Ciocaltea <cristian.ciocaltea@collabora.com>

ASoC: es8316: Do not set rate constraints for unsupported MCLKs

When using the codec through the generic audio graph card, there are at
least two calls of es8316_set_dai_sysclk(), with the effect of limiting
the allowed sample rates according to the MCLK/LRCK ratios supported by
the codec:

1. During audio card setup, to set the initial MCLK - see
asoc_simple_init_dai().

2. Before opening a stream, to update MCLK, according to the stream
sample rate and the multiplication factor - see
asoc_simple_hw_params().

In some cases the initial MCLK might be set to a frequency that doesn't
match any of the supported ratios, e.g. 12287999 instead of 12288000,
which is only 1 Hz below the supported clock, as that is what the
hardware reports. This creates an empty list of rate constraints, which
is further passed to snd_pcm_hw_constraint_list() via
es8316_pcm_startup(), and causes the following error on the very first
access of the sound card:

$ speaker-test -D hw:Analog,0 -F S16_LE -c 2 -t wav
Broken configuration for playback: no configurations available: Invalid argument
Setting of hwparams failed: Invalid argument

Note that all subsequent retries succeed thanks to the updated MCLK set
at point 2 above, which uses a computed frequency value instead of a
reading from the hardware registers. Normally this would have mitigated
the issue, but es8316_pcm_startup() executes before the 2nd call to
es8316_set_dai_sysclk(), hence it cannot make use of the updated
constraints.

Since es8316_pcm_hw_params() performs anyway a final validation of MCLK
against the stream sample rate and the supported MCLK/LRCK ratios, fix
the issue by ensuring that sysclk_constraints list is only set when at
least one supported sample rate is autodetected by the codec.

Fixes: b8b88b70875a ("ASoC: add es8316 codec driver")
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
Link: https://lore.kernel.org/r/20230530181140.483936-3-cristian.ciocaltea@collabora.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 6f073429 30-May-2023 Cristian Ciocaltea <cristian.ciocaltea@collabora.com>

ASoC: es8316: Increment max value for ALC Capture Target Volume control

The following error occurs when trying to restore a previously saved
ALSA mixer state (tested on a Rock 5B board):

$ alsactl --no-ucm -f /tmp/asound.state store hw:Analog
$ alsactl --no-ucm -I -f /tmp/asound.state restore hw:Analog
alsactl: set_control:1475: Cannot write control '2:0:0:ALC Capture Target Volume:0' : Invalid argument

According to ES8316 datasheet, the register at address 0x2B, which is
related to the above mixer control, contains by default the value 0xB0.
Considering the corresponding ALC target bits (ALCLVL) are 7:4, the
control is initialized with 11, which is one step above the maximum
value allowed by the driver:

ALCLVL | dB gain
-------+--------
0000 | -16.5
0001 | -15.0
0010 | -13.5
.... | .....
0111 | -6.0
1000 | -4.5
1001 | -3.0
1010 | -1.5
.... | .....
1111 | -1.5

The tests performed using the VU meter feature (--vumeter=TYPE) of
arecord/aplay confirm the specs are correct and there is no measured
gain if the 1011-1111 range would have been mapped to 0 dB:

dB gain | VU meter %
--------+-----------
-6.0 | 30-31
-4.5 | 35-36
-3.0 | 42-43
-1.5 | 50-51
0.0 | 50-51

Increment the max value allowed for ALC Capture Target Volume control,
so that it matches the hardware default. Additionally, update the
related TLV to prevent an artificial extension of the dB gain range.

Fixes: b8b88b70875a ("ASoC: add es8316 codec driver")
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
Link: https://lore.kernel.org/r/20230530181140.483936-2-cristian.ciocaltea@collabora.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 9abcd240 25-Apr-2023 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

ASoC: Switch i2c drivers back to use .probe()

After commit b8a1a4cd5a98 ("i2c: Provide a temporary .probe_new()
call-back type"), all drivers being converted to .probe_new() and then
03c835f498b5 ("i2c: Switch .probe() to not take an id parameter") convert
back to (the new) .probe() to be able to eventually drop .probe_new() from
struct i2c_driver.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de
Link: https://lore.kernel.org/r/20230425095716.331419-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org


# 2cc3fdcd 19-Apr-2023 Mark Brown <broonie@kernel.org>

ASoC: es8316: Don't use ranges based register lookup for a single register

The es8316 driver uses a register range to specify the single volatile
register it has. While the cost will be in the noise this is a bunch of
overhead compared to just having a volatile_reg() callback so switch to
the callback.

Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20230419-asoc-es8316-volatile-v1-1-2074ec93d8f1@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# 39db65a0 27-Mar-2023 Cristian Ciocaltea <cristian.ciocaltea@collabora.com>

ASoC: es8316: Handle optional IRQ assignment

The driver is able to work fine without relying on a mandatory interrupt
being assigned to the I2C device. This is only needed when making use of
the jack-detect support.

However, the following warning message is always emitted when there is
no such interrupt available:

es8316 0-0011: Failed to get IRQ 0: -22

Do not attempt to request an IRQ if it is not available/valid. This also
ensures the rather misleading message is not displayed anymore.

Also note the IRQ validation relies on commit dab472eb931bc291 ("i2c /
ACPI: Use 0 to indicate that device does not have interrupt assigned").

Fixes: 822257661031 ("ASoC: es8316: Add jack-detect support")
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20230328094901.50763-1-cristian.ciocaltea@collabora.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 6de0b029 22-Sep-2022 Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

ASoC: es8316: fix register sync error in suspend/resume tests

The SOF CI tests report failures with the following error thrown

kernel: es8316 i2c-ESSX8336:00: Unable to sync registers 0x0-0x1. -121

ES8336 only supports I2C read/write one byte a time, so we do need to
set the .use_single_read and .use_single_write flags to avoid this
sync issue.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: FRED OH <fred.oh@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20220922095912.27010-1-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 4bac47a7 24-Aug-2022 Zhu Ning <zhuning0077@gmail.com>

ASoC: codecs: add suspend and resume for ES8316

The registers may be lost after suspend due to powerdown.
regcache_sync solves this issue.

Signed-off-by: Zhu Ning <zhuning@everest-semi.com>
Link: https://lore.kernel.org/r/20220825014952.1038508-1-zhuning0077@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 3684020a 03-Jul-2022 Zhu Ning <zhuning0077@gmail.com>

ASoC: codes: Add support for ES8316 producer mode

The AMD acp-es8336 machine driver requires ES8316 run in producer
mode, which is not supported previously.

Signed-off-by: David Yang <yangxiaohua@everest-semi.com>
Signed-off-by: Zhu Ning <zhuning0077@gmail.com>
Link: https://lore.kernel.org/r/20220704012416.3165-1-zhuning0077@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# f0b163b4 23-Jun-2022 Charles Keepax <ckeepax@opensource.cirrus.com>

ASoC: es*: Remove now redundant non_legacy_dai_naming flag

The ASoC core has now been changed to default to the non-legacy DAI
naming, as such drivers using the new scheme no longer need to specify
the non_legacy_dai_naming flag.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220623125250.2355471-52-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# a327bdc6 05-Apr-2022 Stephen Kitt <steve@sk2.org>

ASoC: es83*: use simple i2c probe function

The i2c probe functions here don't use the id information provided in
their second argument, so the single-parameter i2c probe function
("probe_new") can be used instead.

This avoids scanning the identifier tables during probes.

Signed-off-by: Stephen Kitt <steve@sk2.org>
Link: https://lore.kernel.org/r/20220405165836.2165310-4-steve@sk2.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# b6be2012 22-Feb-2022 Mark Brown <broonie@kernel.org>

ASoC: es8316: Use modern ASoC DAI format terminology

As part of moving to remove the old style defines for the bus clocks update
the es8316 driver to use more modern terminology for clocking.

Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20220222223453.3190333-1-broonie@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# 986c5b0a 28-Oct-2021 Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

ASoC: es8316: add support for ESSX8336 ACPI _HID

The same codec seems to have different personalities. ESSX8316 was
used for Baytrail/CherryTrail, ESSX8336 seems to be used for AppoloLake,
GeminiLake, JasperLake and TigerLake devices.

BugLink: https://github.com/thesofproject/linux/issues/2955
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>-e
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20211029011109.23633-1-yung-chuan.liao@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 1cf2aa66 03-Oct-2021 Hans de Goede <hdegoede@redhat.com>

ASoC: es8316: Use IRQF_NO_AUTOEN when requesting the IRQ

Use the new IRQF_NO_AUTOEN flag when requesting the IRQ, rather then
disabling it immediately after requesting it.

This fixes a possible race where the IRQ might trigger between requesting
and disabling it; and this also leads to a small code cleanup.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211003132255.31743-1-hdegoede@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 4d4e677a 28-Feb-2021 Hans de Goede <hdegoede@redhat.com>

ASoC: es8316: Simplify adc_pga_gain_tlv table

Most steps in this table are steps of 3dB (300 centi-dB), so we can
simplify the table.

This not only reduces the amount of space it takes inside the kernel,
this also makes alsa-lib's mixer code actually accept the table, where
as before this change alsa-lib saw the "ADC PGA Gain" control as a
control without a dB scale.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20210228160441.241110-1-hdegoede@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# bb18c678 28-Feb-2021 Hans de Goede <hdegoede@redhat.com>

ASoC: es8316: Simplify adc_pga_gain_tlv table

Most steps in this table are steps of 3dB (300 centi-dB), so we can
simplify the table.

This not only reduces the amount of space it takes inside the kernel,
this also makes alsa-lib's mixer code actually accept the table, where
as before this change alsa-lib saw the "ADC PGA Gain" control as a
control without a dB scale.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20210228160441.241110-1-hdegoede@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 4060064e 14-Jan-2021 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: es*: sync parameter naming (rate/sample_bits)

This patch syncs naming rule.

- xxx_rates;
+ xxx_rate;

- xxx_samplebits;
+ xxx_sample_bits;

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/874kjiolga.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# f2973a1d 12-Jan-2021 Hans de Goede <hdegoede@redhat.com>

ASoC: es8316: Fix possible NULL pointer deref in es8316_disable_jack_detect()

sound/soc/soc-core.c: soc_remove_component() unconditionally calls
snd_soc_component_set_jack(component, NULL, NULL); on any components
being removed.

This means that on machines where the machine-driver does not provide
a jack through snd_soc_component_set_jack() es8316_disable_jack_detect()
will still get called and at this time es8316->jack will be NULL and
the es8316->jack->status check in es8316_disable_jack_detect() will
lead to a NULL pointer deref.

Fix this by checking for es8316->jack bein NULL at the start of
es8316_disable_jack_detect() and turn the function into a no-op in
that case.

Cc: russianneuromancer <russianneuromancer@ya.ru>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20210112101725.44200-1-hdegoede@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 75333af4 25-Nov-2020 Krzysztof Kozlowski <krzk@kernel.org>

ASoC: es8316: skip of_device_id table when !CONFIG_OF

The driver can match by multiple methods. Its of_device_id table is
referenced via of_match_ptr() so it will be unused for !CONFIG_OF
builds:

sound/soc/codecs/es8316.c:837:34: warning: ‘es8316_of_match’ defined but not used [-Wunused-const-variable=]

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Link: https://lore.kernel.org/r/20201125164452.89239-21-krzk@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# 8667d948 08-Jul-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: codecs: es*: merge .digital_mute() into .mute_stream()

snd_soc_dai_digital_mute() is internally using both
mute_stream() (1) or digital_mute() (2), but the difference between
these 2 are only handling direction.
We can merge digital_mute() into mute_stream

int snd_soc_dai_digital_mute(xxx, int direction)
{
...
else if (dai->driver->ops->mute_stream)
(1) return dai->driver->ops->mute_stream(xxx, direction);
else if (direction == SNDRV_PCM_STREAM_PLAYBACK &&
dai->driver->ops->digital_mute)
(2) return dai->driver->ops->digital_mute(xxx);
...
}

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Link: https://lore.kernel.org/r/87tuyhwiwm.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 07ac6709 07-Jul-2020 Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

ASoC: codecs: es8316: fix 'defined but not used' warning

Fix W=1 warning

sound/soc/codecs/es8316.c:842:36: warning: 'es8316_acpi_match' defined
but not used [-Wunused-const-variable=]
842 | static const struct acpi_device_id es8316_acpi_match[] = {
| ^~~~~~~~~~~~~~~~~

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20200707190612.97799-12-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# ebe02a5b 07-Sep-2019 Katsuhiro Suzuki <katsuhiro@katsuster.net>

ASoC: es8316: support fixed and variable both clock rates

This patch supports some type of machine drivers that set 0 to mclk
when sound device goes to idle state. After applied this patch,
sysclk == 0 means there is no constraint of sound rate and other
values will set constraints which is derived by sysclk setting.

Original code refuses sysclk == 0 setting. But some boards and SoC
(such as RockPro64 and RockChip I2S) has connected SoC MCLK out to
ES8316 MCLK in. In this case, SoC side I2S will choose suitable
frequency of MCLK such as fs * mclk-fs when user starts playing or
capturing.

Bad scenario as follows (mclk-fs = 256):
- Initialize sysclk by correct value (Ex. 12.288MHz)
- ES8316 set constraints of PCM rate by sysclk
48kHz (1/256), 32kHz (1/384), 30.720kHz (1/400),
24kHz (1/512), 16kHz (1/768), 12kHz (1/1024)
- Play 48kHz sound, it's acceptable
- Sysclk is not changed

- Play 32kHz sound, it's acceptable
- Set sysclk by 8.192MHz (= fs * mclk-fs = 32k * 256)
- ES8316 set constraints of PCM rate by sysclk
32kHz (1/256), 21.33kHz (1/384), 20.48kHz (1/400),
16kHz (1/512), 10.66kHz (1/768), 8kHz (1/1024)

- Play 48kHz again, but it's NOT acceptable because constraints
list does not allow 48kHz

Signed-off-by: Katsuhiro Suzuki <katsuhiro@katsuster.net>
Link: https://lore.kernel.org/r/20190907163653.9382-2-katsuhiro@katsuster.net
Signed-off-by: Mark Brown <broonie@kernel.org>


# 0db0c62c 07-Sep-2019 Katsuhiro Suzuki <katsuhiro@katsuster.net>

ASoC: es8316: fix redundant codes of clock

This patch removes redundant null checks for optional MCLK clock.
And fix DT binding document for changing clock property to optional
from required.

Signed-off-by: Katsuhiro Suzuki <katsuhiro@katsuster.net>
Link: https://lore.kernel.org/r/20190907163653.9382-1-katsuhiro@katsuster.net
Signed-off-by: Mark Brown <broonie@kernel.org>


# 6dd567dc 03-Sep-2019 Katsuhiro Suzuki <katsuhiro@katsuster.net>

ASoC: es8316: add clock control of MCLK

This patch introduce clock property for MCLK master freq control.
Driver will set rate of MCLK master if set_sysclk is called and
changing sysclk by board driver.

[Modified slightly to apply without an earlier patch in the series due
to context diffs -- broonie]

Signed-off-by: Katsuhiro Suzuki <katsuhiro@katsuster.net>
Link: https://lore.kernel.org/r/20190903165322.20791-2-katsuhiro@katsuster.net
Signed-off-by: Mark Brown <broonie@kernel.org>


# f6e77921 26-Aug-2019 Katsuhiro Suzuki <katsuhiro@katsuster.net>

ASoC: es8316: fix inverted L/R of headphone mixer volume

This patch fixes inverted Left-Right channel of headphone mixer
volume by wrong shift_left, shift_right values.

Signed-off-by: Katsuhiro Suzuki <katsuhiro@katsuster.net>
Reviewed-by: Daniel Drake <drake@endlessm.com>
Link: https://lore.kernel.org/r/20190826153900.25969-2-katsuhiro@katsuster.net
Signed-off-by: Mark Brown <broonie@kernel.org>


# f972d02f 26-Aug-2019 Katsuhiro Suzuki <katsuhiro@katsuster.net>

ASoC: es8316: fix headphone mixer volume table

This patch fix setting table of Headphone mixer volume.
Current code uses 4 ... 7 values but these values are prohibited.

Correct settings are the following:
0000 -12dB
0001 -10.5dB
0010 -9dB
0011 -7.5dB
0100 -6dB
1000 -4.5dB
1001 -3dB
1010 -1.5dB
1011 0dB

Signed-off-by: Katsuhiro Suzuki <katsuhiro@katsuster.net>
Reviewed-by: Daniel Drake <drake@endlessm.com>
Link: https://lore.kernel.org/r/20190826153900.25969-1-katsuhiro@katsuster.net
Signed-off-by: Mark Brown <broonie@kernel.org>


# d2912cb1 04-Jun-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500

Based on 2 normalized pattern(s):

this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license version 2 as
published by the free software foundation

this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license version 2 as
published by the free software foundation #

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-only

has been chosen to replace the boilerplate/reference in 4122 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Enrico Weigelt <info@metux.net>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190604081206.933168790@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 0bbcedd6 29-Mar-2019 Paul Cercueil <paul@crapouillou.net>

ASoC: es8316: Add support for inverted jack detect

On some devices (Teclast X98+ II tablet, maybe others), the jack
detection has been wired backwards, so when the ES8316 reports
headphones being present it means they are actually not plugged.

Use a quirk around this incorrect behaviour, which can be enabled
through the 'everest,jack-detect-inverted' boolean device property.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 37b6f035 04-Jan-2019 Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

ASoC: es8316: remove unused constant variables

Fix warnings with W=1

If these variables are useful this driver should be modified to expose
them.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 24b53f17 03-Jan-2019 Hans de Goede <hdegoede@redhat.com>

ASoC: es8316: Add DAC mono mix switch mixer control

Export the DAC functionality to mix left + right together and then output
the same (mixed) signal on both outputs.

Various (x86) tablets with an ES8316 codec use a single speaker
connected between the headhpone LOUT and ROUT pins, expecting the output
to be in a mono differential mode. Presumably this is done to use the
power of both the left and right outputs to allow the speaker to be
louder.

The ES8316 codec does not have a differential output mode, but we can
emulate this by making both channels output the same through the mono mix
switch, combined with setting the Playback Polarity control to "R Invert",
which applias a 180 degrees phase inversion to the right channel.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 82225766 03-Jan-2019 Hans de Goede <hdegoede@redhat.com>

ASoC: es8316: Add jack-detect support

Adding jack-detect support may seem weird for a codec with only
a single output, but it is necessary. The ES8316 appnote showing
the intended usage uses a jack-receptacle which physically disconnects
the speakers from the output when a jack is plugged in.

But all 3 devices using the es8316 which I have (2 Cherry Trail
devices and one Bay Trail CR device), use an analog mux to disconnect
the speakers, driven by a GPIO. In order to enable/disable the speakers
at the right time, we need jack-detect.

The same goes for the microphone where we must correctly set the mux
for the single ADC to either the internal or the headset microphone.

All devices I have support the es8316's builtin jack-detect functionality.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 2ff52976 28-Jan-2018 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: es8316: replace codec to component

Now we can replace Codec to Component. Let's do it.

Note:
xxx_codec_xxx() -> xxx_component_xxx()
.idle_bias_off = 1 -> .idle_bias_on = 0
.ignore_pmdown_time = 0 -> .use_pmdown_time = 1
- -> .endianness = 1
- -> .non_legacy_dai_naming = 1

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# eb59d73c 18-Aug-2017 Arvind Yadav <arvind.yadav.cs@gmail.com>

ASoC: codecs: constify snd_soc_dai_ops structures

snd_soc_dai_ops are not supposed to change at runtime. All functions
working with snd_soc_dai_ops provided by <sound/soc-dai.h> work with
const snd_soc_dai_ops. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 728c4a87 18-Aug-2017 Arvind Yadav <arvind.yadav.cs@gmail.com>

ASoC: codecs: constify snd_soc_dai_ops structures

snd_soc_dai_ops are not supposed to change at runtime. All functions
working with snd_soc_dai_ops provided by <sound/soc-dai.h> work with
const snd_soc_dai_ops. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# a6a67da3 15-Aug-2017 Julia Lawall <Julia.Lawall@lip6.fr>

ASoC: codecs: es8316: constify snd_soc_dai_ops structures

These snd_soc_dai_ops structures are only stored in the ops field of
a snd_soc_dai_driver structure, which is const. Thus, the
snd_soc_dai_ops structures can be const too.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Mark Brown <broonie@kernel.org>


# a180ba45 03-Aug-2017 Bhumika Goyal <bhumirks@gmail.com>

ASoC: codecs: add const to snd_soc_codec_driver structures

Declare snd_soc_codec_driver structures as const as they are only passed
as an argument to the function snd_soc_register_codec. This argument is
of type const, so declare the structures with this property as const.
In file codecs/sn95031.c, snd_soc_codec_driver structure is also used in
a copy operation along with getting passed to snd_soc_register_codec.
So, it can be made const too.
Done using Coccinelle:

@match disable optional_qualifier@
identifier s;
position p;
@@
static struct snd_soc_codec_driver s@p={...};

@good1@
identifier match.s;
position p;
@@
snd_soc_register_codec(...,&s@p,...)

@bad@
identifier match.s;
position p!={match.p,good1.p};
@@
s@p

@depends on !bad disable optional_qualifier@
identifier match.s;
@@
static
+const
struct snd_soc_codec_driver s={...};

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# b8b88b70 12-Jun-2017 Daniel Drake <drake@endlessm.com>

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.

Signed-off-by: David Yang <yangxiaohua@everest-semi.com>
[drake@endlessm.com: significant cleanups and simplifications,
remove dead/unclear code]
Signed-off-by: Daniel Drake <drake@endlessm.com>
Signed-off-by: Mark Brown <broonie@kernel.org>