Commit Graph

64 Commits

Author SHA1 Message Date
YueHaibing 6d6376b143
ASoC: tlv320aic31xx: remove unused variable 'cm_m_enum'
sound/soc/codecs/tlv320aic31xx.c:261:29: warning:
 cm_m_enum defined but not used [-Wunused-const-variable=]

It is never used, so can be removed.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Link: https://lore.kernel.org/r/20190815091738.21680-1-yuehaibing@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-08-15 15:06:13 +01:00
Lucas Stach b7e814deae
ASoC: tlv320aic31xx: suppress error message for EPROBE_DEFER
Both the supplies and reset GPIO might need a probe deferral for the
resource to be available. Don't print a error message in that case, as
it is a normal operating condition.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Acked-by: Andrew F. Davis <afd@ti.com>
Link: https://lore.kernel.org/r/20190719143637.2018-1-l.stach@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-07-22 13:26:16 +01:00
kbuild test robot 7742a5b418
ASoC: tlv320aic31xx: aic31xx_set_jack() can be static
Fixes: ebf3326cd9 ("ASoC: tlv320aic31xx: Add headphone/headset detection")
Signed-off-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-04-03 11:03:52 +07:00
Andrew F. Davis 90f0202bf2
ASoC: tlv320aic31xx: Add button press detection
This device can optionally detect headset or microphone button presses.
Add support for this by passing this event to the jack layer.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-04-02 12:41:40 +07:00
Andrew F. Davis ebf3326cd9
ASoC: tlv320aic31xx: Add headphone/headset detection
This device can detect the insertion/removal of headphones and headsets.
Enable reporting this status by enabling this interrupt and forwarding
this to upper-layers if a jack has been defined.

This jack definition and the resulting operation from a jack detection
event must currently be defined by sound card platform code until CODEC
outputs to jack mappings can be defined generically.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-04-02 12:41:18 +07:00
Guennadi Liakhovetski 0bb423f2ea
ASoC: regulator notifier registration should be managed
Regulator notifiers, that were registered during codec driver probing,
must be unregistered during driver release, or device managed versions
have to be used. This patch fixes codec drivers, that weren't explicitly
unregistering notifiers and simplifies those, that did that manually.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-02-08 16:18:49 +00:00
Colin Ian King 7806869c6e
ASoC: tlv320aic31xx: asihpi: clean up indentation, remove extraneous tab
The return statement is indented too much by one level, fix this by
removing an extraneous tab.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-11-16 19:08:28 -08:00
Andrew F. Davis 18d545bb25
ASoC: tlv320aic31xx: Add overflow detection support
Similar to short circuit detection, when the ADC/DAC is saturated and
overflows poor audio quality can result and should be reported to the
user. This device support Automatic Dynamic Range Compression (DRC)
to reduce this but it is not enabled currently in this driver.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-09-04 16:50:51 +01:00
Andrew F. Davis 80863ee222
ASoC: tlv320aic31xx: Add short circuit detection support
These devices support detecting and reporting short circuits across
the output stages. Add support for reporting these issue. Do this
by registering an interrupt if available and enabling this error
to trigger that interrupt in the device.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-09-03 14:04:03 +01:00
Peter Ujfalusi a16be2a6e2
ASoC: tlv320aic31xx: Do not force power on the DAC/ADC in clock master mode
With P0 R29, Bit2 set the I2S clocks will be running when the DAC/ADC is
powered down, but still the codec need to be powered up by needing at least
one complete DAPM path for the stream.

If the AIF is not needed (analog loopback for example) the I2S clocks will
not run as they are not needed.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Suggested-by: Stefan Müller-Klieser <s.mueller-klieser@phytec.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-02-19 11:35:30 +00:00
Peter Ujfalusi 7d41bc28e9
ASoC: tlv320aic31xx: Rename AIF_IN from 'DAC IN' to 'AIF IN'
The audio interface is not really the DAC input. Use more generic name for
it.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-02-19 11:35:29 +00:00
Peter Ujfalusi d460b3f861
ASoC: tlv320aic31xx: Fix master mode clock I2S bus clocks
In the reset state of the codec we do not have complete playback or capture
routes.

The audio playback/capture will not work due to missing clock signals on
the I2S bus if PLL, MDAC/NDAC/DAC MADC/NADC/ADC is powered down.

To make sure that even if all output/input is disconnected the codec is
generating clocks, we need to have valid DAPM route in every case to power
up the must needed parts of the codec.

I have verified that switching DAC (during playback) or ADC (during
capture) will stop the I2S clocks, so the only solution is to connect the
'Off' routes as well to output/input.

The routes will be only added if the codec is clock master. In case the
role changes runtime, the applied routes are removed.

Tested on am43x-epos-evm with aic3111 codec in master mode.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Reviewed-by: Jyri Sarha <jsarha@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-02-14 13:15:55 +00:00
Kuninori Morimoto f2e6f95b4b
ASoC: tlv320aic31xx: 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 = 0	->	.idle_bias_on = 1
	.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>
2018-02-12 09:52:34 +00:00
Andrew F. Davis 0ce918c9e0
ASoC: tlv320aic31xx: Reset registers during power up
Add a reset function that toggles the reset line if available or uses
the software reset command otherwise. Use this in power up to ensure the
registers are in a sane state. This is useful when the driver module
is reloaded, or after Kexec, warm-reboots, etc..

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-12-07 17:47:18 +00:00
Andrew F. Davis cd15da88c3
ASoC: tlv320aic31xx: Use fwnode APIs over raw OF calls
Use fwnode_* API instead of of_*, the results are the same but
fwnode_* is cleaner and we get ACPI support.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-12-07 17:47:17 +00:00
Andrew F. Davis 283c35062f
ASoC: tlv320aic31xx: Fix GPIO header includes
Use of gpiod_* needs <linux/gpio/consumer.h>, add this here.

Fixes: b6b247cd5e ("ASoC: tlv320aic31xx: Switch GPIO handling to use gpiod_* API")
Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-12-07 17:47:17 +00:00
Andrew F. Davis dcb407b257
ASoC: tlv320aic31xx: Handle inverted BCLK in non-DSP modes
Currently BCLK inverting is only handled when the DAI format is
DSP, but the BCLK may be inverted in any supported mode. Without
this using this CODEC in any other mode than DSP with the BCLK
inverted leads to bad sampling timing and very poor audio quality.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-12-01 13:32:00 +00:00
Andrew F. Davis 77f8b3cfc3
ASoC: tlv320aic31xx: Add CODEC clock slave support
This CODEC supports being the WCLK and/or BCLK slave, add
support for this here.

Also make the alert into an error as alert is more urgent
than needed here and is rarely used.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-12-01 13:31:09 +00:00
Andrew F. Davis c6b8c77921
ASoC: tlv320aic31xx: Check clock and divider before division
If our set_sysclk DAI callback has not been called yet p_div will be 0
and dividing by this will cause an error. Print an error message and
leave before this.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-12-01 13:30:48 +00:00
Andrew F. Davis b6b247cd5e
ASoC: tlv320aic31xx: Switch GPIO handling to use gpiod_* API
Move to using newer gpiod_* GPIO handling functions. This simplifies
the code and eases dropping platform data in the next patch. Also
remember GPIO are active low, so set "1" to reset.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-12-01 13:28:11 +00:00
Andrew F. Davis e88c388136
ASoC: tlv320aic31xx: Merge init function into probe
The function aic31xx_device_init() is only called from probe and
does nothing that logically shouldn't be in probe, remove this
unneeded function call and move its code into probe where it was called.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-12-01 13:28:01 +00:00
Andrew F. Davis ca7840fb47
ASoC: tlv320aic31xx: General source formatting cleanup
Simple non-functional changes including:

 * Fix spelling errors
 * Reformat code for easier reading
 * Remove unneeded code
 * Remove assignments that are always overridden
 * Normalize function return paths

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-12-01 13:26:25 +00:00
Andrew F. Davis 09303601ba
ASoC: tlv320aic31xx: Move ACPI table next to OF table
Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-11-30 12:30:30 +00:00
Andrew F. Davis c7734e8e7e
ASoC: tlv320aic31xx: Change aic31xx_power_off return type to void
The return value is not checked, and even if it was there is nothing
we could do about it and messages are already printed.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-11-30 12:30:26 +00:00
Andrew F. Davis b1c52b7e7c
ASoC: tlv320aic31xx: File header and copyright cleanup
Fix header copyright tags, while we are here, also switch to SPDX
and fixup MODULE tags to match.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-11-30 12:30:23 +00:00
Andrew F. Davis a825f31f93
ASoC: tlv320aic31xx: Use standard reset GPIO OF name
The correct DT property for specifying a GPIO used for reset
is "reset-gpios", fix this here.

[Retitled for accuracy -- broonie]

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-11-30 12:24:22 +00:00
Gustavo A. R. Silva 09fc38c1af
ASoC: tlv320dac31xx: mark expected switch fall-through
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Addresses-Coverity-ID: 1195220
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-11-08 21:28:06 +00:00
Bhumika Goyal a180ba45b1 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>
2017-08-10 16:10:50 +01:00
Tomas Vilda 51827c41c9 ASoC: tlv320dac31xx: Fix mistype in tlv320dac31xx codec
Signed-off-by: Tomas Vilda <tomas.vilda@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-05-14 19:08:16 +09:00
Peter Ujfalusi 4e2cc814eb ASoC: tlv320aic31xx: Add support for tlv320dac3101
The DAC3101 is mostly identical to DAC3100 with the exception that it has
stereo speaker AMP instead of mono used in DAC3100.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2016-11-12 09:56:22 +00:00
Peter Ujfalusi a4a1d79ea7 ASoC: tlv320aic31xx: Add missing of_device_id for dac3100
The compatible table was not updated when the support for DAC3100 was added.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Reviewed-by: Jyri Sarha <jsarha@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2016-11-10 17:55:04 +00:00
Nikita Yushchenko 3520646dbb ASoC: tlv320aic31xx: do not declare support for mono DAI
This hardware supports only 2-channel DAI, even mono ADC digital output
has two channels with the same data.

Having min_channels=1 results in broken playback of mono files in setups
where CPU DAI supports mono.

Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2016-09-27 09:34:48 -07:00
Nikita Yushchenko ef9656b693 ASoC: tlv320aic31xx: add explicit support for tlv320dac31xx
tlv320dac31xx is a subset of tlv320aic31xx:
- it does not have MIC inputs and ADC, thus capture is not supported,
- it has analog inputs AIN1/AIN2 that can be mixed into output.

Although tlv320dac31xx does work with tlv320aic31xx driver, this setup
does register non-existent widgets and non-existent capture stream.
Thus userspace lists non-existent objects in user interfaces, an can
access these, causing operations with device registers that are
declared as "reserved" in tlv320dac31xx datasheet.

This patch fixes this situation by separating controls/widgets/routes
into common, aic31xx-specific, and dac31xx-specific parts. Only parts
that match actual hardware (as declared in "compatible" device tree
property) are registered.

Changes from v1:
- update device tree binding documentation,
- rebased on top of "ASoC: codec duplicated callback function goes to
  component on tlv320aic31xx" commit.

Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2016-09-26 09:42:27 -07:00
Kuninori Morimoto 1bb99f2a00 ASoC: codec duplicated callback function goes to component on tlv320aic31xx
codec driver and component driver has duplicated callback functions,
and codec side functions are just copied to component side when
register timing. This was quick-hack, but no longer needed.
This patch moves these functions from codec driver to component driver.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2016-08-08 11:57:57 +01:00
Bastien Nocera f5cc17720b ASoC: tlv320aix31xx: Add ACPI match for Lenovo 100S
The Lenovo 100S netbook has a codec controller for which there is a
driver, but doesn't know how to access the device. This adds the
necessary ACPI table for the driver to find the device.

Device (TTLV)
{
    Name (_ADR, Zero)  // _ADR: Address
    Name (_HID, "10TI3100")  // _HID: Hardware ID
    Name (_CID, "10TI3100")  // _CID: Compatible ID
    Name (_DDN, "TI TLV320AIC3100 Codec Controller ")  // _DDN: DOS Device Name
    Name (_UID, One)  // _UID: Unique ID

Signed-off-by: Bastien Nocera <hadess@hadess.net>
Tested-by: Jan Schmidt <jan@centricular.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2016-04-19 17:41:15 +01:00
Mark Brown b18fec9fe4 Merge remote-tracking branches 'asoc/topic/const', 'asoc/topic/cs35l32', 'asoc/topic/cs4265' and 'asoc/topic/cs42l52' into asoc-next 2015-08-30 15:52:59 +01:00
Krzysztof Kozlowski 1c07a4de5b ASoC: drivers: Drop owner assignment from i2c_driver
i2c_driver does not need to set an owner because i2c_register_driver()
will set it.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2015-07-15 12:50:43 +01:00
Axel Lin 6479304755 ASoC: Constify snd_soc_dai_ops variables
The snd_soc_dai_ops variables are not modified after initialization in
these drivers, so make them const.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2015-07-15 12:12:46 +01:00
Lars-Peter Clausen 378d1e432d ASoC: tlv320aix31xx: Replace direct snd_soc_codec dapm field access
The dapm field of the snd_soc_codec struct is eventually going to be
removed, in preparation for this replace all manual access to
codec->dapm.bias_level with snd_soc_codec_get_bias_level() and replace all
other manual access to codec->dapm with snd_soc_codec_get_dapm().

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
2015-05-15 16:48:56 +01:00
Lars-Peter Clausen f4bf8d770b ASoC: Move bias level update to the core
All drivers have the same line at the end of the set_bias_level callback to
update the bias_level state. Move this update into
snd_soc_dapm_force_bias_level() and remove them from the drivers.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
2015-04-27 21:34:45 +01:00
Lars-Peter Clausen dd943d36f1 ASoC: tlv320aic31xx: Replace w->codec snd_soc_dapm_to_codec(w->dapm)
The codec field of the snd_soc_widget struct is eventually going to be
removed, use snd_soc_dapm_to_codec(w->dapm) instead.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
2015-01-15 11:57:05 +00:00
Mark Brown 37850831ab Merge remote-tracking branches 'asoc/topic/tas2552', 'asoc/topic/tegra', 'asoc/topic/tfa9879', 'asoc/topic/tlv320aic23' and 'asoc/topic/tlv320aic31xx' into asoc-next 2014-12-08 13:12:16 +00:00
Lars-Peter Clausen a43a262901 ASoC: tlv320aix31xx: Cleanup manual bias level transitions
Set the CODEC driver's suspend_bias_off flag rather than manually going to
SND_SOC_BIAS_OFF in suspend and SND_SOC_BIAS_STANDBY in resume. This makes
the code a bit shorter and cleaner.

Since the ASoC core now takes care of setting the bias level to
SND_SOC_BIAS_OFF when removing the CODEC there is no need to do it manually
anymore either.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Jyri Sarha <jsarha@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2014-11-27 11:16:07 +00:00
Jyri Sarha bbc686b346 ASoC: tlv320aic31xx: Fix off by one error in the loop stucture.
Fix off by one read beyond the end of a table.

Reported-by: David Binderman <dcb314@hotmail.com>
Signed-off-by: Jyri Sarha <jsarha@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
2014-11-24 18:45:57 +00:00
Jyri Sarha 7ed36e96fd ASoC: tlv320aic31xx: Choose PLL p divider automatically
This simplifies aic31xx_divs table. There is no more need for p_val or
separate lines for 12 and 24 MHz mclks.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
Tested-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2014-09-03 15:25:44 +01:00
Mark Brown 94fe356f4c Merge branch 'fix/tlv320aic31xx' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-tlv320aic31xx 2014-09-03 15:25:17 +01:00
Jyri Sarha 03be88ee4a ASoC: tlv320aic31xx: Fix 24bit samples with I2S format and 12MHz mclk
I2S format requires bitclock to have an exact amount of cycles in a
frame for audio to work cleanly. With dsp formats that is not so
important.

Updates aic31xx_setup_pll() to look for a line in aic31xx_divs table
that produces the best match for the bitclock and adds lines to
aic31xx_divs for 12MHz mclk and 24bit samples.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
Tested-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2014-09-03 15:23:56 +01:00
Peter Ujfalusi 085f3ec6fd ASoC: tlv320aic31xx: Correct interface register 2 variable name
Rename iface_reg3 to iface_reg2 since this variable is actually used for
interface register 2.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2014-09-01 10:53:37 +01:00
Mark Brown e99a866c4c Merge remote-tracking branches 'asoc/topic/tlv320aic3x', 'asoc/topic/width', 'asoc/topic/wm0010', 'asoc/topic/wm8904' and 'asoc/topic/wm8962' into asoc-next 2014-08-04 16:32:18 +01:00
Mark Brown c5e64c7636 Merge remote-tracking branches 'asoc/topic/tlv', 'asoc/topic/tlv320aic23', 'asoc/topic/tlv320aic31xx' and 'asoc/topic/tlv320aic32x4' into asoc-next 2014-08-04 16:32:12 +01:00