summaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/cs42l42.c
Commit message (Collapse)AuthorAgeFilesLines
* ASoC: cs42l42: Use two thresholds and increased wait time for manual type ↵Stefan Binding2021-09-271-23/+61
| | | | | | | | | | | | | | | detection Some headsets require very different comparator thresholds for type detection, as well as longer settling times. In order to detect a larger number of headsets, use 2 thresholds to give maximum coverage (1.25V and 1.75V), as well as a longer settling time of 100ms. This will not affect default audotodetect mode and applies to manual mode type detection only. Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com> Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com> Link: https://lore.kernel.org/r/20210927111437.18113-1-vitalyr@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* Merge series "ASoC: cs42l42: Implement Manual Type detection as fallback" ↵Mark Brown2021-09-161-12/+92
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | from Vitaly Rodionov <vitalyr@opensource.cirrus.com>: For some headsets CS42L42 autodetect mode is not working correctly. They will be detected as unknown types or as headphones. According to the CS42L42 datasheet, if the headset autodetect failed, then the driver should switch to manual mode and perform a manual steps sequence. These steps were missing in the current driver code. This patch will add manual mode fallback steps in case autodetect failed. The default behavior is not affected, manual mode runs only when autodetect failed. Tested for regression with autodetect with all known headsets - no regression. Tested with all headsets customers reported as false detected: Gumdrop DropTech B1 - detected as headset OK HUAWEI AM115 - detected as headset OK UGREEN EP103 - detected as headset OK HONOR AM116 - detected as headset OK Stefan Binding (1): ASoC: cs42l42: Implement Manual Type detection as fallback sound/soc/codecs/cs42l42.c | 104 ++++++++++++++++++++++++++++++++----- sound/soc/codecs/cs42l42.h | 54 +++++++++++++++++++ 2 files changed, 146 insertions(+), 12 deletions(-) -- 2.25.1
| * ASoC: cs42l42: Implement Manual Type detection as fallbackStefan Binding2021-09-161-12/+92
| | | | | | | | | | | | | | | | | | | | | | Some headsets are not detected correctly by Automatic Type Detection on cs42l42. Instead, Manual Type Detection can be used to give a more accurate value. Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com> Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com> Link: https://lore.kernel.org/r/20210916102750.9212-2-vitalyr@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* | ASoC: cs42l42: Minor fix all errors reported by checkpatch.pl scriptVitaly Rodionov2021-09-161-5/+5
|/ | | | | | Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com> Link: https://lore.kernel.org/r/20210916110932.10293-1-vitalyr@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: cs42l42: Update module authorsRichard Fitzgerald2021-08-051-0/+3
| | | | | | | | Add the current authors of this module. Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://lore.kernel.org/r/20210805161111.10410-8-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: cs42l42: Assume 24-bit samples are in 32-bit slotsRichard Fitzgerald2021-08-051-0/+7
| | | | | | | | | | | | | | | | | | | | | If the machine driver doesn't call snd_soc_dai_set_sysclk() the SCLK is assumed to be sample_rate * sample_bits * 2 (that is, the rate necessary for a standard I2S frame). But 24-bit samples can be sent in either a 24-bit slot or a 32-bit slot. If the PLL is configured for a 24-bit slot, but a 32-bit slot is used, cs42l42 will be overclocked. Ultimately it is the machine driver's responsibilty to call snd_soc_dai_set_sysclk() if SLK will be different from the standard I2S rate. However, it is convenient to assume 32-bit slots to allow this common case without needing special machine driver support. The machine driver then only has to set SCLK if the slots are 24-bit, but if it fails to do this cs42l42 won't be overclocked. Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://lore.kernel.org/r/20210805161111.10410-7-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: cs42l42: Validate dai_set_sysclk() frequencyRichard Fitzgerald2021-08-051-2/+15
| | | | | | | | | If the machine driver calls snd_set_sysclk() with an unsupported SCLK frequency, return an error instead of letting hw_params() fail. Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://lore.kernel.org/r/20210805161111.10410-6-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: cs42l42: Add PLL configuration for 44.1kHz/16-bitRichard Fitzgerald2021-08-051-0/+1
| | | | | | | | | 44.1kHz 16-bit standard I2S gives a SCLK of 1.4112 MHz. Add a PLL configuration for this. Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://lore.kernel.org/r/20210805161111.10410-5-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: cs42l42: Fix mono playbackRichard Fitzgerald2021-08-051-2/+13
| | | | | | | | | | | | | | | | I2S always has two LRCLK phases and both CH1 and CH2 of the RX must be enabled (corresponding to the low and high phases of LRCLK.) The selection of the valid data channels is done by setting the DAC CHA_SEL and CHB_SEL. CHA_SEL is always the first (left) channel, CHB_SEL depends on the number of active channels. Previously for mono ASP CH2 was not enabled, the result was playing mono data would not produce any audio output. Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Fixes: 621d65f3b868 ("ASoC: cs42l42: Provide finer control on playback path") Link: https://lore.kernel.org/r/20210805161111.10410-4-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: cs42l42: Constrain sample rate to prevent illegal SCLKRichard Fitzgerald2021-08-051-1/+20
| | | | | | | | | | | | | | | | The lowest valid SCLK corresponds to 44.1 kHz at 16-bit. Sample rates less than this would produce SCLK below the minimum when using a normal I2S frame. A constraint must be applied to prevent this. The constraint is not applied if the machine driver sets SCLK, to allow setups where the host generates additional bits per LRCLK phase to increase the SCLK frequency. In these cases the machine driver would always have to inform this driver of the actual SCLK, and it must select a legal SCLK. Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://lore.kernel.org/r/20210805161111.10410-3-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: cs42l42: Fix LRCLK frame start edgeRichard Fitzgerald2021-08-051-9/+12
| | | | | | | | | | | | | | An I2S frame starts on the falling edge of LRCLK so ASP_STP must be 0. At the same time, move other format settings in the same register from cs42l42_pll_config() to cs42l42_set_dai_fmt() where you'd expect to find them, and merge into a single write. Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Fixes: 2c394ca79604 ("ASoC: Add support for CS42L42 codec") Link: https://lore.kernel.org/r/20210805161111.10410-2-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: cs42l42: PLL must be running when changing MCLK_SRC_SELRichard Fitzgerald2021-08-051-7/+18
| | | | | | | | | | | | | | | Both SCLK and PLL clocks must be running to drive the glitch-free mux behind MCLK_SRC_SEL and complete the switchover. This patch moves the writing of MCLK_SRC_SEL to when the PLL is started and stopped, so that it only transitions while the PLL is running. The unconditional write MCLK_SRC_SEL=0 in cs42l42_mute_stream() is safe because if the PLL is not running MCLK_SRC_SEL is already 0. Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Fixes: 43fc357199f9 ("ASoC: cs42l42: Set clock source for both ways of stream") Link: https://lore.kernel.org/r/20210805161111.10410-1-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: cs42l42: Remove duplicate control for WNF filter frequencyRichard Fitzgerald2021-08-031-10/+0
| | | | | | | | | | | | | | | | | | | | | The driver was defining two ALSA controls that both change the same register field for the wind noise filter corner frequency. The filter response has two corners, at different frequencies, and the duplicate controls most likely were an attempt to be able to set the value using either of the frequencies. However, having two controls changing the same field can be problematic and it is unnecessary. Both frequencies are related to each other so setting one implies exactly what the other would be. Removing a control affects user-side code, but there is currently no known use of the removed control so it would be best to remove it now before it becomes a problem. Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Fixes: 2c394ca79604 ("ASoC: Add support for CS42L42 codec") Link: https://lore.kernel.org/r/20210803160834.9005-2-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: cs42l42: Fix inversion of ADC Notch Switch controlRichard Fitzgerald2021-08-031-1/+1
| | | | | | | | | | The underlying register field has inverted sense (0 = enabled) so the control definition must be marked as inverted. Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Fixes: 2c394ca79604 ("ASoC: Add support for CS42L42 codec") Link: https://lore.kernel.org/r/20210803160834.9005-1-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: cs42l42: Fix bclk calculation for monoRichard Fitzgerald2021-07-291-0/+4
| | | | | | | | | | | An I2S frame always has a left and right channel slot even if mono data is being sent. So if channels==1 the actual bitclock frequency is 2 * snd_soc_params_to_bclk(params). Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Fixes: 2cdba9b045c7 ("ASoC: cs42l42: Use bclk from hw_params if set_sysclk was not called") Link: https://lore.kernel.org/r/20210729170929.6589-3-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: cs42l42: Don't allow SND_SOC_DAIFMT_LEFT_JRichard Fitzgerald2021-07-291-1/+0
| | | | | | | | | | The driver has no support for left-justified protocol so it should not have been allowing this to be passed to cs42l42_set_dai_fmt(). Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Fixes: 2c394ca79604 ("ASoC: Add support for CS42L42 codec") Link: https://lore.kernel.org/r/20210729170929.6589-2-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: cs42l42: Correct definition of ADC Volume controlRichard Fitzgerald2021-07-291-3/+2
| | | | | | | | | | | | The ADC volume is a signed 8-bit number with range -97 to +12, with -97 being mute. Use a SOC_SINGLE_S8_TLV() to define this and fix the DECLARE_TLV_DB_SCALE() to have the correct start and mute flag. Fixes: 2c394ca79604 ("ASoC: Add support for CS42L42 codec") Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://lore.kernel.org/r/20210729170929.6589-1-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: cs42l42: Check jack status before reporting button eventsLucas Tanure2021-05-251-1/+5
| | | | | | | | | | Jack must be connected before reporting button events and if the jack is disconnected button release must be reported Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com> Reviewed-by: Richard Fitzgerald <rf@opensource.cirrus.com> Message-Id: <20210525090822.64577-4-tanureal@opensource.cirrus.com> Signed-off-by: Mark Brown <broonie@sirena.org.uk>
* ASoC: cs42l42: Add support for 2400000 Bit clockLucas Tanure2021-05-251-0/+1
| | | | | | | | | Add support for 2.4MHz clock source Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com> Reviewed-by: Richard Fitzgerald <rf@opensource.cirrus.com> Message-Id: <20210525090822.64577-3-tanureal@opensource.cirrus.com> Signed-off-by: Mark Brown <broonie@sirena.org.uk>
* ASoC: cs42l42: Add support for 2304000 Bit clockLucas Tanure2021-05-251-0/+1
| | | | | | | | | Add support for 24bits, 2 channels, 48k Sample rate bit clock Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com> Reviewed-by: Richard Fitzgerald <rf@opensource.cirrus.com> Message-Id: <20210525090822.64577-2-tanureal@opensource.cirrus.com> Signed-off-by: Mark Brown <broonie@sirena.org.uk>
* ASoC: cs42l42: Fix 1536000 Bit Clock instabilityLucas Tanure2021-05-251-16/+31
| | | | | | | | | | | | The 16 Bits, 2 channels, 48K sample rate use case needs to configure a safer pll_divout during the start of PLL After 800us from the start of PLL the correct pll_divout can be set Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com> Reviewed-by: Richard Fitzgerald <rf@opensource.cirrus.com> Message-Id: <20210525090822.64577-1-tanureal@opensource.cirrus.com> Signed-off-by: Mark Brown <broonie@sirena.org.uk>
* Merge branch 'for-5.13' of ↵Mark Brown2021-05-251-0/+3
|\ | | | | | | https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-5.14
| * ASoC: cs42l42: Regmap must use_single_read/writeRichard Fitzgerald2021-05-111-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | cs42l42 does not support standard burst transfers so the use_single_read and use_single_write flags must be set in the regmap config. Because of this bug, the patch: commit 0a0eb567e1d4 ("ASoC: cs42l42: Minor error paths fixups") broke cs42l42 probe() because without the use_single_* flags it causes regmap to issue a burst read. However, the missing use_single_* could cause problems anyway because the regmap cache can attempt burst transfers if these flags are not set. Fixes: 2c394ca79604 ("ASoC: Add support for CS42L42 codec") Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://lore.kernel.org/r/20210511132855.27159-1-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* | ASoC: cs42l42: make HSBIAS_SENSE_EN optionalVitaly Rodionov2021-05-121-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | HSBIAS_SENSE_EN configures HSBIAS output current sense through the external 2.21-k resistor. HSBIAS_SENSE is hardware feature to reduce the potential pop noise during the headset plug out slowly. But on some platforms ESD voltage will affect it causing test to fail, especially with CTIA headset type. For different hardware setups, a designer might want to tweak default behavior. Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com> Link: https://lore.kernel.org/r/20210511145220.125760-1-vitalyr@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* | Merge series "Tidy up device ID reading on legacy Cirrus parts" from Charles ↵Mark Brown2021-05-111-10/+8
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Keepax <ckeepax@opensource.cirrus.com>: Pierre requested I have a look at some cppcheck warnings in the cs42l42 driver, since it is reassigning the ret variable without ever checking the result. Looking a bit more broadly this happens in quite a few legacy Cirrus parts, as they all use the same process to read the ID, factor out a small helper so they can all share the same code. Whilst in there fix up a couple of other trivial error path issues as well. Thanks, Charles Charles Keepax (10): ASoC: cirrus: Add helper function for reading the device ID ASoC: cs35l32: Minor error paths fixups ASoC: cs35l33: Minor error paths fixups ASoC: cs35l34: Minor error paths fixups ASoC: cs35l35: Minor error paths fixups ASoC: cs35l35: Correct errata handling ASoC: cs42l42: Minor error paths fixups ASoC: cs42l73: Minor error paths fixups ASoC: cs43130: Minor error paths fixups ASoC: cs53l30: Minor error paths fixups sound/soc/codecs/cirrus_legacy.h | 21 +++++++++++++++++++++ sound/soc/codecs/cs35l32.c | 34 ++++++++++++++++++---------------- sound/soc/codecs/cs35l33.c | 15 +++++++++------ sound/soc/codecs/cs35l34.c | 39 ++++++++++++++++++++++----------------- sound/soc/codecs/cs35l35.c | 21 ++++++++++----------- sound/soc/codecs/cs35l35.h | 1 + sound/soc/codecs/cs42l42.c | 18 ++++++++---------- sound/soc/codecs/cs42l73.c | 30 +++++++++++++++++------------- sound/soc/codecs/cs43130.c | 31 +++++++++++++++++++------------ sound/soc/codecs/cs53l30.c | 22 +++++++++++----------- 10 files changed, 136 insertions(+), 96 deletions(-) create mode 100644 sound/soc/codecs/cirrus_legacy.h -- 2.11.0
| * | ASoC: cs42l42: Minor error paths fixupsCharles Keepax2021-05-101-10/+8
| |/ | | | | | | | | | | | | | | | | | | | | Correct some unchecked re-allocations of ret whilst reading the device ID and ensure the hardware state is returned to off on the error paths. Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://lore.kernel.org/r/20210510131357.17170-8-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* | ASoC: cs42l42: Add support for ACPI table match entryVitaly Rodionov2021-05-101-2/+13
| | | | | | | | | | | | | | | | | | Adding support for ACPI-based systems. Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com> Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com> Link: https://lore.kernel.org/r/20210426155303.853236-3-tanureal@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* | ASoC: cs42l42: Use device_property API instead of of_propertyRichard Fitzgerald2021-05-101-36/+24
| | | | | | | | | | | | | | | | | | | | Use the device_property APIs so that the code will work on devicetree and ACPI systems. Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com> Link: https://lore.kernel.org/r/20210426155303.853236-2-tanureal@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* | ASoC: cs42l42: Add support for set_jack callsLucas Tanure2021-05-101-18/+25
|/ | | | | | | | | | Replace the internal jack creation by set_jack call, so users can map buttons in their machine driver Also only enable jack detection IRQ after set_jack call Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com> Link: https://lore.kernel.org/r/20210426155303.853236-1-tanureal@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: cs42l42: Wait for PLL to lock before switching to itRichard Fitzgerald2021-03-101-1/+11
| | | | | | | | | The PLL should have locked before using it to supply MCLK. Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com> Link: https://lore.kernel.org/r/20210306185553.62053-16-tanureal@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: cs42l42: Only start PLL if it is neededRichard Fitzgerald2021-03-101-2/+3
| | | | | | | | | | | The PLL is only needed for sclk < 11289600 Hz and cs42l42_pll_config() will not configure it for higher rates. So it must only be enabled when it is needed. Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com> Link: https://lore.kernel.org/r/20210306185553.62053-15-tanureal@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: cs42l42: Wait at least 150us after writing SCLK_PRESENTRichard Fitzgerald2021-03-101-5/+22
| | | | | | | | | | | | | There must be a delay of at least 150us after writing SCLK_PRESENT before issuing another I2C write. This is done using struct reg_sequence because it can specify a delay after the write and the whole sequence is written atomically. Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com> Link: https://lore.kernel.org/r/20210306185553.62053-14-tanureal@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: cs42l42: Use bclk from hw_params if set_sysclk was not calledLucas Tanure2021-03-101-4/+13
| | | | | | | | | Add support for reading the source clock from snd_soc_params_to_bclk so the machine driver is not required to call cs42l42_set_sysclk Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com> Link: https://lore.kernel.org/r/20210306185553.62053-13-tanureal@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: cs42l42: Report jack and button detectionLucas Tanure2021-03-101-14/+56
| | | | | | | | | | Report the Jack events to the user space through ALSA. Also moves request_threaded_irq() to component_probe so it don't get interrupts before the initialization the struct snd_soc_jack. Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com> Link: https://lore.kernel.org/r/20210306185553.62053-12-tanureal@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: cs42l42: Add Capture SupportLucas Tanure2021-03-101-0/+39
| | | | | | | | Add support for capture path on headseat pins Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com> Link: https://lore.kernel.org/r/20210306185553.62053-11-tanureal@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: cs42l42: Set clock source for both ways of streamLucas Tanure2021-03-101-38/+48
| | | | | | | | | Move the enable/disable of clocks to cs42l42_mute_stream so the record path also get clocks. Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com> Link: https://lore.kernel.org/r/20210306185553.62053-10-tanureal@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: cs42l42: Provide finer control on playback pathLucas Tanure2021-03-101-43/+22
| | | | | | | | | Removing cs42l42_hpdrv_evt that enables the entire chain and replace by a set of widgets that can better define the codec Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com> Link: https://lore.kernel.org/r/20210306185553.62053-9-tanureal@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: cs42l42: Disable regulators if probe failsLucas Tanure2021-03-101-5/+7
| | | | | | | | In case of cs42l42_i2c_probe() fail, the regulators were left enabled. Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com> Link: https://lore.kernel.org/r/20210306185553.62053-8-tanureal@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: cs42l42: Remove power if the driver is being removedLucas Tanure2021-03-101-2/+4
| | | | | | | | Ensure the power supplies are turned off when removing the driver Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com> Link: https://lore.kernel.org/r/20210306185553.62053-7-tanureal@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: cs42l42: Always wait at least 3ms after resetLucas Tanure2021-03-101-1/+2
| | | | | | | | | This delay is part of the power-up sequence defined in the datasheet. A runtime_resume is a power-up so must also include the delay. Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com> Link: https://lore.kernel.org/r/20210305173442.195740-6-tanureal@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: cs42l42: Don't enable/disable regulator at Bias LevelLucas Tanure2021-03-101-38/+0
| | | | | | | | dev_pm_ops already enable/disable the codec if not in use Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com> Link: https://lore.kernel.org/r/20210305173442.195740-5-tanureal@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: cs42l42: Fix mixer volume controlLucas Tanure2021-03-101-2/+2
| | | | | | | | The minimum value is 0x3f (-63dB), which also is mute Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com> Link: https://lore.kernel.org/r/20210305173442.195740-4-tanureal@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: cs42l42: Fix channel width supportLucas Tanure2021-03-101-25/+22
| | | | | | | | | Remove the hard coded 32 bits width and replace with the correct width calculated by params_width. Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com> Link: https://lore.kernel.org/r/20210305173442.195740-3-tanureal@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: cs42l42: Fix Bitclock polarity inversionLucas Tanure2021-03-101-12/+8
| | | | | | | | | | The driver was setting bit clock polarity opposite to intended polarity. Also simplify the code by grouping ADC and DAC clock configurations into a single field. Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com> Link: https://lore.kernel.org/r/20210305173442.195740-2-tanureal@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: codecs: cs*: merge .digital_mute() into .mute_stream()Kuninori Morimoto2020-07-161-2/+3
| | | | | | | | | | | | | | | | | | | | | | | 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/87r1tlwiwe.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: codecs: cs42l42: remove always-true comparisonsPierre-Louis Bossart2020-07-021-6/+3
| | | | | | | | | | | | | | | | | | | | | | Fix W=1 warnings: cs42l42.c: In function 'cs42l42_handle_device_data': cs42l42.c:1661:12: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits] 1661 | if ((val >= CS42L42_BTN_DET_INIT_DBNCE_MIN) && | ^~ cs42l42.c:1679:12: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits] 1679 | if ((val >= CS42L42_BTN_DET_EVENT_DBNCE_MIN) && | ^~ cs42l42.c:1698:23: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits] 1698 | if ((thresholds[i] >= CS42L42_HS_DET_LEVEL_MIN) && | ^~ Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20200701181320.80848-3-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: codecs: cs*: rename to snd_soc_component_read()Kuninori Morimoto2020-06-221-1/+1
| | | | | | | | | | | We need to use snd_soc_component_read() instead of snd_soc_component_read32() This patch renames _read32() to _read() Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87a7134mc4.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
* treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500Thomas Gleixner2019-06-191-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* ASoC: cs42l42: replace codec to componentKuninori Morimoto2018-02-121-79/+75
| | | | | | | | | | | | | | 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 = 1 -> .use_pmdown_time = 0 - -> .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>
* ASoC: cs42l42: constify snd_soc_dai_ops structureGustavo A. R. Silva2017-07-171-1/+1
| | | | | | | | | This structure is only stored in the ops field of a snd_soc_dai_driver structure. That field is declared const, so snd_soc_dai_ops structures that have this property can be declared as const also. Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com> Signed-off-by: Mark Brown <broonie@kernel.org>