summaryrefslogtreecommitdiff
path: root/sound/soc/codecs/nau8825.c
AgeCommit message (Collapse)Author
2016-09-29Merge remote-tracking branches 'asoc/topic/ac97', 'asoc/topic/ak4104', ↵Mark Brown
'asoc/topic/arizona', 'asoc/topic/atmel' and 'asoc/topic/codec-component' into asoc-next
2016-09-29Merge remote-tracking branches 'asoc/fix/arizona', 'asoc/fix/da7219', ↵Mark Brown
'asoc/fix/nau8825', 'asoc/fix/rt5514' and 'asoc/fix/shift' into asoc-linus
2016-09-14ASoC: nau8825: fix bug in FLL parameterJohn Hsu
In the FLL parameter calculation, the FVCO should choose the maximum one. The patch is to fix the bug about the wrong FVCO chosen. Signed-off-by: John Hsu <KCHSU0@nuvoton.com> Signed-off-by: Mark Brown <broonie@kernel.org> Cc: stable@vger.kernel.org
2016-08-08ASoC: codec duplicated callback function goes to component on nau8825Kuninori Morimoto
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-04ASoC: nau8825: fix static check error about semaphone controlJohn Hsu
The patch is to fix the static check error as the following. The patch commit b50455fab459 ("ASoC: nau8825: cross talk suppression measurement function") from Jun 7, 2016, leads to the following static checker warning: sound/soc/codecs/nau8825.c:265 nau8825_sema_acquire() warn: 'sem:&nau8825->xtalk_sem' is sometimes locked here and sometimes unlocked. The semaphone acquire function has return value, and some callers can do error handling when lock fails. Signed-off-by: John Hsu <KCHSU0@nuvoton.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-08-04ASoC: nau8825: fix bug in playback when suspendJohn Hsu
In chromium, the following steps will make codec function fail. \1. plug in headphones, Play music \2. run "powerd_dbus_suspend" \3. resume from S3 After resume, the jack detection will restart and make configuration for the headset. Meanwhile, the playback prepares and starts to work. The two sequences will conflict and make wrong register configuration. Originally, the driver adds protection for the case when it finds the playback is active. But the "powerd_dbus_suspend" command will close the pcm stream before suspend. Therefore, the driver can't detect the playback after resume, and the protection not works. For the issue, the driver raises protection every time after resume. The protection will release after jack detection and configuration completes, and then the playback just will goes on. Signed-off-by: John Hsu <KCHSU0@nuvoton.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-07-15ASoC: nau8825: drop redundant idiom when converting integer to booleanJohn Hsu
Thanks Mark and Anatol for the discussion. According to the result, the standard C will translate any non-zero value into true, or false otherwise. QUOTE: "6.3.1.2 Boolean type When any scalar value is converted to _Bool, the result is 0 if the value compares equal to 0; otherwise, the result is 1 " Thus, the "!!" idiom is removed. Signed-off-by: John Hsu <KCHSU0@nuvoton.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-07-14ASoC: nau8825: jack connection decision with different insertion logicJohn Hsu
The original design only covers the jack insertion logic is active low. Add more condition to cover no matter the logic is active low and high. Signed-off-by: John Hsu <KCHSU0@nuvoton.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-06-14ASoC: nau8825: mark pm functions __maybe_unusedArnd Bergmann
The newly added nau8825_dai_is_active() function is only called from the PM logic that is build-time conditional in this driver, so we get a warning when CONFIG_PM is disabled: sound/soc/codecs/nau8825.c:229:13: error: 'nau8825_dai_is_active' defined but not used [-Werror=unused-function] static bool nau8825_dai_is_active(struct nau8825 *nau8825) By replacing the #ifdef around the functions with a __maybe_unused annotation, the code becomes more robust to this kind of problem and we no longer get the warning while also slightly improving readability. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Fixes: b50455fab459 ("ASoC: nau8825: cross talk suppression measurement function") Signed-off-by: Mark Brown <broonie@kernel.org>
2016-06-13ASoC: nau8825: cross talk suppression measurement functionJohn Hsu
The cross talk measurement function can reduce cross talk across the JKTIP HPL) and JKR1(HPR) outputs which measures the cross talk signal level to determine what is the cross talk reduction gain. This system works by sending a 23Hz -24dBV sine wave into the headset output DAC and through the PGA. The output of the PGA is then connected to an internal current sense which measures the attenuated 23Hz signal and passing the output to an ADC which converts the measurement to a binary code. With two separated measurement, one for JKR1(HPR) and the other JKTIP(HPL), measurement data can be separated read in IMM_RMS_L for HSR and HSL after each measurement. Thus, the measurement function has four states to complete whole sequence. (1)Prepare state : Prepare the resource for detection and transfer to HPR IMM stat to make JKR1(HPR) impedance measure. (2)HPR IMM state : Read out orignal signal level of JKR1(HPR) and transfer to HPL IMM state to make JKTIP(HPL) impedance measure. (3)HPL IMM state : Read out cross talk signal level of JKTIP(HPL) and transfer to IMM state to determine suppression sidetone gain. (4)IMM state : Computes cross talk suppression sidetone gain with orignal and cross talk signal level. Apply this gain and then restore codec con- figuration. Then transfer to Done state for ending. In order to get the cross talk suppression sidetone gain, we need the function to compute log10 value and the result is round off to 3 decimal. This function takes reference to dvb-math. The source code locates as the following. "Linux/drivers/media/dvb-core/dvb_math.c" Then, the orignal and cross talk signal vlues need to be characterized. The sidetone value can be converted to decibel with the equation below. sidetone = 20 * log (original signal level / crosstalk signal level) Besides, the state machine for cross talk process needs interruptions to trigger worked. We have the RMS intrruption enabled with the internal VCO clock when headset connected. In the interrupt handler, the driver will judge the headset is high impedance or not. If yes, the cross talk supp- ression shouldn't apply and do nothing but relieve the protection raised before. Otherwise, apply the cross talk suppression in the headset and start the process. Because the process spends a lot of time, there is an resource race issue easily between the application and interruption. They will control codec power and clock concurrently. In one situaiton, the jack is inserted when playback, and then the application changes to headset device. The applica- tion prepares the playback and interrupt handler raises work for cross talk process together. For this case, the solution is that driver delays soc jack report until cross talk process completes. The mechanism can avoid application to do playback preparation before cross talk detection is still working. In another situaiton, the system suspends when playback. After resume, the system restarts playback, and meanwhile jack detection restarts. The play- back preparation and cross talk process triggered by interruptions happens concurrently. For the case, the driver provides the semaphone to syn- chronize the playback and interrupt handler. In order to avoid the play- back interfered by cross talk process, the driver make the playback prepa- ration halted until cross talk process finish. After codec resume, the driver finds the codec dai is active, and then the driver raises the pro- tection for cross talk function to avoid the playback recovers before cross talk process finish. The driver also provides cancel method to forcely cancel the cross talk task and restores the configuration to original status. Before the codec remove, ejection, or suspend, the driver is obliged to cancel the cross talk detection process. It can reduce the risk of failure when quickly and continually doing jack insertion and ejection. Signed-off-by: John Hsu <KCHSU0@nuvoton.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-06-03ASoC: nau8825: correct typo in biquad filter coefficientsJohn Hsu
There is typo in the name of biquad filter coefficients control. The patch is to fix the typo. Signed-off-by: John Hsu <KCHSU0@nuvoton.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-05-31ASoC: nau8825: non-clock jack detection for power saving at standbyJohn Hsu
The driver changes jack type detection interruption to non-clock archi- tecture for less 1mW power saving. The architecture is called manual mode jack detection. It has no hardware debounce, no jack type detection, but only detecting jack insertion. After jack insertion, the driver will switch to auto mode jack detection with internal clock which can detect microphone, jack type and do hardware debounce. The manual architecture has these main changes including codec initiation, interruption, clock control, and power management. When codec initiation or system resume, the clock is closed as jack insertion detection at man- ual mode, and bypass debounce circuit. These configurations move to resume setup function when setup bias level after resume. When jack insertion detection happens, the manual mode turns off and make configuration about jack type detection interruption at auto mode in auto irq setup function which can detect microphone and jack type. The inter- ruption will switch to manual mode again with clock free until jack ejec- tion happens. The system clock configuration adds clock disable option which can disable internal VCO clock. Before the system clock change, there is an restric- tion added to make sure clock disabled and not config any clock when no headset connected. In power management, we involve the solution about races and jack detec- tion in resume from Ben Zhang in the following patch and list his comment. [PATCH] ASoC: nau8825: Fix jack detection across suspend "Jack plug status is rechecked at resume to handle plug/unplug in S3 when the chip has no power." "Suspend/resume callbacks are moved from the i2c dev_pm_ops to snd_soc_codec_driver. soc_resume_deferred is a delayed work which may trigger nau8825_set_bias_level. The bias change races against dev_pm_ops, causing jack detection issues. soc_resume_deferred ensures bias change and snd_soc_codec_driver suspend/resume are sequenced correctly." Change SAR widget to supply type which can prevent the codec keeping at SND_SOC_BIAS_ON during suspend. The codec suspend function can just invoke normally. Before the system suspends, the driver turns off all interruptions. Keep the interruption quiet before resume setup completes. The ADC channel will be disabled which is needed for interruptions at audo mode. Signed-off-by: John Hsu <KCHSU0@nuvoton.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-05-31ASoC: nau8825: add programmable biquad filter controlJohn Hsu
Add programmable biquad filter configuration control for user space. The filter is configurable for low pass filters, high pass filters, Notch filter, etc in the ADC and DAC path. Signed-off-by: John Hsu <KCHSU0@nuvoton.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-05-30ASoC: nau8825: Export I2C module alias informationJavier Martinez Canillas
The I2C driver has an i2c_device_id array but that information isn't exported to the module using the MODULE_DEVICE_TABLE() macro. So the module autoloading won't work if the I2C device is registered using OF or legacy board files due missing alias information in the module. The issue was found using Kieran Bingham's coccinelle semantic patch: https://lkml.org/lkml/2016/5/10/520 Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-05-30ASoC: nau8825: assign DAC Ch to match headset L/RJohn Hsu
The default value of DAC channel select is reverse in codec. For normal usage, switch the channel select when codec bootup. Signed-off-by: John Hsu <KCHSU0@nuvoton.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-05-30ASoC: nau8825: change output power for interruptJohn Hsu
The interrupt clock is gated by x1[10:8], one of them needs to be enabled all the time for interrupts to happen. We change codec to enable ADC because it's helpful to reduce playback pop noise. Don't use force enable pin to enable ADC instead of ADC widget event. That won't interfere DAPM operation and let bias work normally. Signed-off-by: John Hsu <KCHSU0@nuvoton.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-05-30ASoC: nau8825: reduce standby power consumptionJohn Hsu
Decrease internal clock frequency for power saving when standby. But clock divider needs restore when MCLK as system clock in playback. Signed-off-by: John Hsu <KCHSU0@nuvoton.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-05-30ASoC: nau8825: improve FLL function for better performanceJohn Hsu
In FLL calculation, increase VCO/DCO frequency for better performance. Besides, have different register configuration according to fraction or not when apply FLL parameters. Signed-off-by: John Hsu <KCHSU0@nuvoton.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-05-30ASoC: nau8825: support different clock source for FLL functionJohn Hsu
Extend FLL clock source selection. The source can be from MCLK, BCLK or FS. Signed-off-by: John Hsu <KCHSU0@nuvoton.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-03-28ASoC: nau8825: Fix jack detection across suspendBen Zhang
Jack plug status is rechecked at resume to handle plug/unplug in S3 when the chip has no power. Suspend/resume callbacks are moved from the i2c dev_pm_ops to snd_soc_codec_driver. soc_resume_deferred is a delayed work which may trigger nau8825_set_bias_level. The bias change races against dev_pm_ops, causing jack detection issues. soc_resume_deferred ensures bias change and snd_soc_codec_driver suspend/resume are sequenced correctly. Signed-off-by: Ben Zhang <benzh@chromium.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-03-12ASoC: nau8825: fix issue that pop noise when start playbackJohn Hsu
Reduce pop noise in power up and down sequence when playback. The DAPM widgets graph is reconstructed to ensure the register write sequence at playback matches exactly to the v5 clickless sequence provided by Nuvoton. Signed-off-by: John Hsu <KCHSU0@nuvoton.com> Signed-off-by: Ben Zhang <benzh@chromium.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-11-16ASoC: nau8825: add pm functionYong Zhi
This patch adds pm function and fixes following issues 1.i2c timeout after resume, after resume we saw interrupt handler is called prior to i2c controller is resumed.This causes i2c timeout 2.no audio after resume Signed-off-by: Fang, Yang A <yang.a.fang@intel.com> Signed-off-by: Yong Zhi <yong.zhi@intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-10-23ASoC: nau8825: Show device propertiesBen Zhang
The codec device properties are printed for debugging. Signed-off-by: Ben Zhang <benzh@chromium.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-10-23ASoC: nau8825: Add FLL configurationBen Zhang
snd_soc_codec_driver.set_pll is implemented to configure the FLL. The codec internal SYSCLK can be from either the MCLK pin directly, or the FLL. This is configured by snd_soc_codec_driver.set_pll. Signed-off-by: Ben Zhang <benzh@chromium.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-10-08ASoC: nau8825: add acpi match IDFang, Yang A
This patch adds the acpi match ID for nau8825 codec Signed-off-by: Fang, Yang A <yang.a.fang@intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-10-07ASoC: nau8825: fix platform_no_drv_owner.cocci warningskbuild test robot
sound/soc/codecs/nau8825.c:1096:3-8: No need to set .owner here. The core will do it. Remove .owner field if calls are used which set it automatically Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci CC: Anatol Pomozov <anatol.pomozov@gmail.com> Signed-off-by: Fengguang Wu <fengguang.wu@intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-10-07ASoC: nau8825: Add driver for headset chip Nuvoton 8825Anatol Pomozov
Sponsored-by: Google Chromium project Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>