summaryrefslogtreecommitdiff
path: root/sound/soc/codecs/sgtl5000.c
AgeCommit message (Collapse)Author
2014-09-16ASoC: sgtl5000: Fix the cache handlingFabio Estevam
Since commit e5d80e82e32e (ASoC: sgtl5000: Convert to use regmap directly) a kernel oops is observed after a suspend/resume sequence. The kernel oops happens inside sgtl5000_restore_regs() as codec->reg_cache is no longer a valid pointer. Add the remaining register entries into sgtl5000_reg_defaults[] and remove sgtl5000_restore_regs() completely, which allows suspend/resume to work fine and make the code simpler. Tested on a im53-qsb board. Reported-by: Shawn Guo <shawn.guo@freescale.com> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Tested-by: Shawn Guo <shawn.guo@freescale.com> Signed-off-by: Mark Brown <broonie@linaro.org> (cherry picked from commit 29aa37cddfb9b721013ff28608200d73a9426368)
2014-09-16ASoC: sgtl5000: fix codec clock source transition to avoid clockless momentOskar Schirmer
Powering down PLL before switching to a mode that does not use it is a bad idea. It would cause the SGTL5000 be without internal clock supply, especially on the I2C interface, which would make subsequent access to it fail. Thus, in case of not using PLL any longer, first set the mode control, then power down PLL. Signed-off-by: Oskar Schirmer <oskar@scara.com> Signed-off-by: Mark Brown <broonie@linaro.org> (cherry picked from commit e06e4c2d530fd4995c41083009647263ccd77d3b)
2014-09-16ASoC: sgtl5000: fix buggy 'Capture Attenuate Switch' controlLothar Waßmann
The SGTL5000 Capture Attenuate Switch (or "ADC Volume Range Reduction" as it is called in the manual) is single bit only. Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de> Reviewed-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Mark Brown <broonie@linaro.org> (cherry picked from commit 65f2b226763bc348a9b9145aa5e17e7e3f6d8c35)
2014-09-16ASoC: sgtl5000: prevent playback to be muted when terminating concurrent captureLothar Waßmann
When a sound capture/playback is terminated while a playback/capture is running, power_vag_event() will clear SGTL5000_CHIP_ANA_POWER in the SND_SOC_DAPM_PRE_PMD event, thus muting the respective other channel. Don't clear SGTL5000_CHIP_ANA_POWER when both DAC and ADC are active to prevent this. Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de> Reviewed-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Mark Brown <broonie@linaro.org> (cherry picked from commit f091f3f07328f75d20a2a5970d1f8b58d95fc990)
2014-09-16ASoC: sglt5000: Fix the default value of CHIP_SSS_CTRLFabio Estevam
According to the sgtl5000 reference manual, the default value of CHIP_SSS_CTRL is 0x10. Reported-by: Oskar Schirmer <oskar@scara.com> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Mark Brown <broonie@linaro.org> Cc: stable@vger.kernel.org (cherry picked from commit 016fcab8ff46fca29375d484226ec91932aa4a07)
2014-09-16ASoC: sgtl5000: Fix VAG_POWER enabling/disabling orderMarek Vasut
The VAG_POWER must be enabled after all other bits in CHIP_ANA_POWER and disabled before any other bit in CHIP_ANA_POWER. See the SGTL5000 datasheet (Table 31, BIT 7, page 42-43). Failing to follow this order will result in ugly loud "POP" noise at the end of playback. To achieve such order, use the _PRE and _POST DAPM widgets to trigger the power_vag_event, where the event type check has to be fixed accordingly as well. Signed-off-by: Marek Vasut <marex@denx.de> Signed-off-by: Mark Brown <broonie@linaro.org> (cherry picked from commit dd4d2d6dfb49e8916064f2cb07f0ad7b32a82fb7)
2014-09-16ASoC: sgtl5000: Fix driver probe after resetFabio Estevam
After a 'reboot' command in Linux or after pressing the system's reset button the sgtl5000 driver fails to probe: sgtl5000 0-000a: Device with ID register ffff is not a sgtl5000 sgtl5000 0-000a: ASoC: failed to probe CODEC -19 imx-sgtl5000 sound.12: ASoC: failed to instantiate card -19 imx-sgtl5000 sound.12: snd_soc_register_card failed (-19) sgtl5000 codec does not have a reset line, nor a reset command in software, so after a system reset the codec does not contain the default register values from sgtl5000_reg_defaults[] anymore, as these are only valid after a power-on-reset cycle. Fix this issue by explicitly reading all the reset register values from sgtl5000_reg_defaults[] and writing them back into sgtl5000 to ensure a sane state. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Tested-by: Eric Nelson <eric.nelson@boundarydevices.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> (cherry picked from commit af8ee11209e749c75eabf32b2a4ca631f396acf8) Conflicts: sound/soc/codecs/sgtl5000.c
2013-01-21ASoC: sgtl5000: Fix maximum value for microphone gainT30_LinuxImageV2.0Alpha1_20130122Fabio Estevam
sgtl5000 microphone gain only has 2 bits of resolution, so maximum value is 3. From Eric Nelson: "We also found that for the microphones we have here (commodity PC boom mics) a default value of 2 for the gain gives the best results." So change the default microphone gain as well. Signed-off-by: Eric Nelson <eric.nelson@boundarydevices.com> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-01-21ASoC: sgtl5000: enable VAG_POWER for LINE_INDong Aisheng
LINE_IN also needs VAG_POWER on or we may hear noise when directly route LINE_IN to Headphone Mux. Tested on imx28evk. Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-01-21ASoC: sgtl5000: Fix wrong register name in restoreZeng Zhaoming
Correct SGTL5000_CHIP_CLK_CTRL to SGTL5000_CHIP_REF_CTRL in sgtl5000_restore_regs(), and add comment to explain the restore order. Reported-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Zeng Zhaoming <zengzm.kernel@gmail.com> Acked-by: Dong Aisheng <dong.aisheng@linaro.org> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-01-21ASoC: sgtl5000: Enable VAG when DAC/ADC upZeng Zhaoming
As manual described, VAG is an internal voltage reference of DAC/ADC, So enabled it before DAC/ADC up. One more thing should care about is VAG fully ramped down requires 400ms, wait it to avoid pop. Signed-off-by: Zeng Zhaoming <zengzm.kernel@gmail.com> Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-01-21ASoC: sgtl5000: fix DB_RANGE sizeClemens Ladisch
Give the correct number of entries to TLV_DB_RANGE_HEAD to prevent reading more data than actually is in the array. Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2013-01-21ASoC: sgtl5000: Fix wrong mask in some snd_soc_update_bits callsAxel Lin
Ensure all mask bits are clear before setting new value. Signed-off-by: Axel Lin <axel.lin@gmail.com> Acked-by: Dong Aisheng <b29396@freescale.com> Acked-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-01-21ASoC: Use SGTL5000_LINREG_VDDD_MASK instead of hardcoded mask valueAxel Lin
We have defined SGTL5000_LINREG_VDDD_MASK in sgtl5000.h, use it instead of hardcoded (0x1 << 4) - 1 for the mask. Signed-off-by: Axel Lin <axel.lin@gmail.com> Acked-by: Wolfram Sang <w.sang@pengutronix.de> Acked-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-01-21ASoC: Set sgtl5000->ldo in ldo_regulator_registerAxel Lin
Otherwise calling ldo_regulator_remove() does not unregister regulator and free memories. Signed-off-by: Axel Lin <axel.lin@gmail.com> Acked-by: Wolfram Sang <w.sang@pengutronix.de> Acked-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-01-21ASoC: sgtl5000: Fix setting mic bias resistorAxel Lin
According to the datasheet: CHIP_MIC_CTRL 0x002A BITS[9:8] BIAS_RESISTOR 0x0 = Powerd off 0x1 = 2.0 kohm 0x2 = 4.0 kohm 0x3 = 8.0 kohm To set mic bias resistor, we need to update bits[9:8] of SGTL5000_CHIP_MIC_CTRL register. Signed-off-by: Axel Lin <axel.lin@gmail.com> Acked-by: Wolfram Sang <w.sang@pengutronix.de> Acked-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-01-21ASoC: sgtl5000: fix module device table type for sgtl5000_dt_idsAxel Lin
The module device table for of_device_id should use "of" type. Signed-off-by: Axel Lin <axel.lin@gmail.com> Acked-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-01-21Conflict due to the fix for the register map failure - taken the for-3.1 ↵Mark Brown
version. Conflicts: sound/soc/codecs/sgtl5000.c
2011-08-03ASoC: sgtl5000: fix cache handlingWolfram Sang
Cache handling in this driver is broken. The chip has 16-bit registers, yet the register numbers also increase by 2 per register, i.e. there are only even-numbered registers. The cache in this driver, though, simply increments register numbers, so it does need some mapping as seen in sgtl5000_restore_regs(), note the '>> 1': snd_soc_write(codec, SGTL5000_CHIP_LINREG_CTRL, cache[SGTL5000_CHIP_LINREG_CTRL >> 1]); That, of course, won't work with snd_soc_update_bits(). (Thus, we won't even notice the missing register 0x1c in the default regs which shifted all follwing registers to wrong values.) Noticed on the MX28EVK where enabling the regulators simply locked up the chip. Refactor the routines and use a properly sized default_regs array which matches the register layout of the underlying chip, i.e. create a truly flat cache. This also saves some code which should make up for the bigger array a little. When soc-core will somewhen have another cache type which handles a step size, this conversion will also ease the transition. Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Tested-by: Dong Aisheng <b29396@freescale.com> Tested-by: Shawn Guo <shawn.guo@linaro.org> Acked-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Cc: stable@kernel.org
2011-07-19ASoC: sgtl5000: guide user when regulator support is neededWolfram Sang
Print a hint when the user has a setup where CONFIG_REGULATOR is really needed to make the driver work. Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Tested-by: Dong Aisheng <b29396@freescale.com> Tested-by: Shawn Guo <shawn.guo@freescale.com> Acked-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2011-07-19ASoC: sgtl5000: refactor registering internal ldoWolfram Sang
The code for registering the internal ldo was present twice. Turn it into a function instead. Also, inform the user if LDO is used now. Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Tested-by: Dong Aisheng <b29396@freescale.com> Tested-by: Shawn Guo <shawn.guo@freescale.com> Acked-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2011-03-22ASoC: Support !REGULATOR build for sgtl5000Mark Brown
The regulator is optional depending on board design. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
2011-03-08ASoC: sgtl5000: use after free in ldo_regulator_register()Dan Carpenter
The "ldo" variable was dereferenced after free on the error path. Signed-off-by: Dan Carpenter <error27@gmail.com> Acked-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2011-02-28ASoC: Staticise non-exported symbols in SGTL5000Mark Brown
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2011-02-28ASoC: remove unnecessary header including in SGTL5000 codec driverZeng Zhaoming
Remove unnecessary headers: - mach/hardware.h in sgtl5000.c - linux/i2c.h in sgtl5000.h Signed-off-by: Zeng Zhaoming <b32542@freescale.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2011-02-25ASoC: Add Freescale SGTL5000 codec supportZeng Zhaoming
Add Freescale SGTL5000 codec support. Supported features: - line-in and mic input - headphone and line-out output - line-in bypass ADC and DAC to headphone - 16, 20, 24, 32 bit audio - 8 ~ 96k sample rates Signed-off-by: Zeng Zhaoming <zhaoming.zeng@freescale.com> Acked-by: Liam Girdwood <lrg@slimlogic.co.uk> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>