summaryrefslogtreecommitdiff
path: root/sound/soc/davinci/davinci-mcasp.c
AgeCommit message (Collapse)AuthorFilesLines
2014-11-12ASoC: davinci-mcasp: Add overrun/underrun event handlingMisael Lopez Cruz1-0/+124
An underrun (playback) event occurs when the serializer transfer data from the XRBUF buffer to the XRSR shift register, but the XRBUF hasn't been filled. Similarly, the overrun (capture) event occurs when data from the XRSR shift register is transferred to the XRBUF but it hasn't been read yet. These events are handled as XRUN events that cause the pcm to stop. The stream has to be explicitly restarted by the userspace which ensures that after stopping/starting McASP the data transfer is aligned with DMA. The other possibility was to internally stop and start McASP without DMA even knowing about it. Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2014-11-10ASoC: davinci-mcasp: Active slots depend on active serializersMisael Lopez Cruz1-5/+22
Active slots count depends on the number of channels in the stream and the number of active serializers. Each serializer will handle at most the number of channels specified via 'tdm-slots' parameter in DT. There are two possible scenarios: - Single serializer: channel count fits in the max slots supported by McASP serializers, active slots is same as channel count - Multiple serializers: channel count is bigger than max slots supported by a serializer. Channel count determines how many serializers are needed at their max slot count configuration Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2014-11-10ASoC: davinci-mcasp: Place constraint on number of channelsPeter Ujfalusi1-0/+60
In IIS (I2S, TDM, etc) mode the maximum number of allowed channels for either direction can be: number of serializers for the direction * tdm_slots. This constraint applicable for the first stream, while consequent stream should not have more channels then the first stream. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2014-11-10ASoC: davinci-mcasp: Validate tdm_slots parameter at probe timePeter Ujfalusi1-10/+18
Instead of validating the tdm_slots parameter every time at hw_params we can do it once during probe. If the parameter is not valid (<2 or >32) print an error and fix it up. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2014-11-10ASoC: davinci-mcasp: Fix rx format when more bclk is used on the busPeter Ujfalusi1-2/+11
When the bus is configured to have more BCLK then the data type demands we need to use the rotation to move the data to correct place. Reported-by: Misael Lopez Cruz <misael.lopez@ti.com> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2014-11-10ASoC: davinci-mcasp: Symmetric sample bits for IIS modePeter Ujfalusi1-0/+1
In IIS mode the tx and rx configuration is symmetric, the BCLK and FSYNC is shared. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2014-11-10ASoC: davinvi-mcasp: Balance pm_runtime_enable() on probe failureAnil Kumar1-0/+1
If probe fails then we need to call pm_runtime_disable() to balance out the previous pm_runtime_enable() call. Signed-off-by: Anil Kumar <anilk4.v@gmail.com> Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2014-10-29ASoC: davinci-mcasp: Move the AFIFO related code under start_tx/rx functionsPeter Ujfalusi1-15/+16
In this way the start code for tx/rx going to be located at the same place. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2014-10-29ASoC: davinci-mcasp: When stopping TX/RX stop the AFIFO as the last stepPeter Ujfalusi1-13/+14
The AFIFO should not be stopped (or started for that matter) when McASP is running since it can cause unpredictable issues because we are switching off AFIFO for the direction which was handling the requests from McASP and was generating DMA request toward the system DMA. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2014-10-29ASoC: davinci-mcasp: Correct RX start sequencePeter Ujfalusi1-8/+4
Follow the sequence described in the TRMs when starting RX. Write to RXBUF register was not correct and there is no need to release the RX state machine/Receive frame sync generator twice. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2014-10-29ASoC: davinci-mcasp: Correct TX start sequencePeter Ujfalusi1-16/+9
Follow the sequence described in the TRMs when starting TX. This sequence will make sure that we are not facing with initial channel swap caused by no data available in McASP for transmit. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2014-10-20ASoC: davinci: drop owner assignment from platform_driversWolfram Sang1-1/+0
A platform_driver does not need to set an owner, it will be populated by the driver core. Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2014-10-06Merge remote-tracking branches 'asoc/topic/davinci', 'asoc/topic/dmic', ↵Mark Brown1-21/+58
'asoc/topic/drivers', 'asoc/topic/es8328' and 'asoc/topic/fsl' into asoc-next
2014-10-01ASoC: davinvi-mcasp: Proper suspend/resume support while audio is activePeter Ujfalusi1-0/+41
If the board is sent to suspend (deep sleep) the McASP context will be lost. In case when suspend happens during active audio we need to save and restore more registers, which was configured during hw_param times as well. We need to add more config registers, AFIFO control registers and we also need to save and restore the serializer configuration as well. Since the number of serializers depends on the SoC we need to allocate the memory for it based on the num_serializer for the given McASP instance. With this patch the ongoing stream will resume after resuming from deep sleep. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2014-10-01ASoC: davinci-mcasp: Convert the context save/restore to use arrayPeter Ujfalusi1-21/+17
Instead of individual values use an array to store the registers need to be saved on suspend and restored on resume. It is going to be easier to add more registers to save and restore. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2014-09-16Merge remote-tracking branches 'asoc/fix/cs4265', 'asoc/fix/davinci', ↵Mark Brown1-1/+10
'asoc/fix/rockchip', 'asoc/fix/samsung' and 'asoc/fix/tlv320aic31xx' into asoc-linus
2014-09-04ASoC: davinci-mcasp: Correct rx format unit configurationPeter Ujfalusi1-1/+10
In case of capture we should not use rotation. The reverse and mask is enough to get the data align correctly from the bus to MCU: Format data from bus after reverse (XRBUF) S16_LE: |LSB|MSB|xxx|xxx| |xxx|xxx|MSB|LSB| S24_3LE: |LSB|DAT|MSB|xxx| |xxx|MSB|DAT|LSB| S24_LE: |LSB|DAT|MSB|xxx| |xxx|MSB|DAT|LSB| S32_LE: |LSB|DAT|DAT|MSB| |MSB|DAT|DAT|LSB| With this patch all supported formats will work for playback and capture. Reported-by: Jyri Sarha <jsarha@ti.com> (broken S24_3LE capture) Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org> Cc: stable@vger.kernel.org
2014-08-13ASoC: mcasp: Fix implicit BLCK divider settingJyri Sarha1-3/+11
The implicit BLCK divider setting was broken by "ASoC: mcasp: don't override bclk divider if it was provided by the machine"-patch. After the BCLK divider is implicitly set for the first time the mcasp->bclk_div gets a non zero value and the implicit setting is "turned off". Signed-off-by: Jyri Sarha <jsarha@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-07-17ASoC: mcasp: don't override bclk divider if it was provided by the machineDaniel Mack1-2/+7
If a machine driver provides an BCLK divider to the McASP driver, skip the automatic calculation. This fixes machines on which the physical sample transport always works in 32 bits, even though not all of them are actually used. snd_soc_params_to_bclk() will fail to address such cases properly. Signed-off-by: Daniel Mack <zonque@gmail.com> Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-07-17ASoC: davinci-mcasp: Use dmaengine based platform driver for AM335x/447xPeter Ujfalusi1-2/+9
Use the edma-pcm with AM335x and AM437x SoCs. Keep using the davinci-pcm for daVinci devices, they can be switched to use the dmaengine based driver later when they are verified to work correctly. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Tested-by: Daniel Mack <daniel@zonque.org> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-07-17Merge remote-tracking branch 'asoc/fix/davinci' into asoc-davinciMark Brown1-0/+12
2014-06-30ASoC: davinci-mcasp: Fix S24_LE and U24_LE supportPeter Ujfalusi1-0/+4
In case of S24_LE/U24_LE modes we expect 24bits on the bus while the samples are stored and transferred in memory on 32bits (lower 3 bytes of the 4 bytes). Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Tested-by: Daniel Mack <daniel@zonque.org> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-21ASoC: davinci-mcasp: Allow best effort in selecting BCLK dividerJyri Sarha1-5/+9
Do not fail if the exact BLCK rate can not be produced, just print a warning. Check that sysclk frequency is set before implicitly setting the BCLK divider. Signed-off-by: Jyri Sarha <jsarha@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-21ASoC: davinci-mcasp: Add dependecy to SND_DAVINCI_SOC or SND_OMAP_SOCJyri Sarha1-0/+8
Fixes build with SND_DAVINCI_SOC or SND_OMAP_SOC alone and adds build dependecy to SND_DAVINCI_SOC or SND_OMAP_SOC. Signed-off-by: Jyri Sarha <jsarha@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-18ASoC: davinci-mcasp: set up channel status bits for S/PDIF modeDaniel Mack1-2/+47
In DIT (S/PDIF) mode, program the transmitted user bits to reflect the configured sample rate, along with some other details. Signed-off-by: Daniel Mack <zonque@gmail.com> Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-05-26ASoC: omap-pcm: Move omap-pcm under include/soundJyri Sarha1-1/+1
Make including the omap-pcm.h outside sound/soc/omap more convenient. Signed-off-by: Jyri Sarha <jsarha@ti.com> Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-04-22ASoC: davinci-mcasp: Convert to use devm_snd_soc_register_component()Peter Ujfalusi1-10/+7
It allows to remove code from the cleanup paths. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-04-22ASoC: davinci-pcm: Convert to use devm_snd_soc_register_platform()Peter Ujfalusi1-15/+0
Remove the cleanup code related to the platform from the DAI drivers at the same time to avoid breakage. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-04-18ASoC: davinci-mcasp: Update MCASP_VERSION_4 platform driver registrationPeter Ujfalusi1-6/+31
Version 4 of McASP is using omap-pcm as platform driver and the omap-pcm platform need to be registered using the cpu dai's device. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-04-14ASoC: davinci-mcasp: Do not touch 0x04 register above McASP_VERSION_2Peter Ujfalusi1-1/+1
This register is not defined in TI81xx and on AM335x/AM437x it is the SYSCONFIG register which should not be touched by drivers since it is related to PM and handled by the generic PM code. This register write was there since the first time the davinci-mcasp driver was appeared in the kernel. The reason why it did not caused any issues on AM335x/AM437x is that it sets bit 1 in SYSCONFIG register which in turn will enable the smart-idle mode. This is the default mode and this is the mode McASP should be in also when in use. On TI81xx the register is not defined. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-04-14ASoC: davinci-mcasp: Remove excess empty lines from davinci_mcasp_set_dai_fmt()Peter Ujfalusi1-8/+0
To make the code look uniform. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-04-14ASoC: davinci-mcasp: Support for LEFT_J formatPeter Ujfalusi1-0/+7
Configuration for LEFT_J format. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-04-14ASoC: davinci-mcasp: Add support for I2S formatPeter Ujfalusi1-1/+10
The FS needs to be inverted in McASP compared to other supported formats. Use a flag to indicate if the FS needs to be inverted. At the same time fail when non supported format is asked since the default case was anyways configuring McASP to a not valid format. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-04-14ASoC: davinci-mcasp: Move the FS polarity change out from the switch casePeter Ujfalusi1-13/+14
FS polarity can be either rising or falling edge in McASP. Instead of accessing the registers in every switch/case set a flag and write the registers after the switch for the invert configuration. This change will help when adding support for more formats also. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-04-14ASoC: davinci-mcasp: Support for DSP_A formatPeter Ujfalusi1-0/+7
DSP_A is like DSP_B mode but with one bit delay after the FS. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-04-14ASoC: davinci-mcasp: Format data delay configuration enhancementPeter Ujfalusi1-3/+11
Use intermediate variable for the data delay needed for the specific format and write the register after the format configuration at once. This will help to control the number of lines as support for more formats going to be added. Also fixes a case when we switch between two formats with different delay requirements. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-04-14ASoC: davinci-mcasp: Fine tune and correct the DMA burst configurationPeter Ujfalusi1-2/+15
When the AFIFO is not enabled but more than one serializers are used the DMA need to transfer number of words equal to active serializers when a DMA request is generated. When configuring the burst for the DMA avoid using value '1' for the burst since it is going to enable additional logic in the DMA drivers. Burst '1' means that the DMA should send/receive one word per DMA requests. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-04-14ASoC: davinic-mcasp: Adopt the AFIFO/DMA configuration to the stream ↵Peter Ujfalusi1-7/+23
(dynamic depth) Configure the AFIFO numevt parameter based on the requested tx/rx_numevt, active serializers and period size in words. In this way McASP can adopt it's (and the DMA) configuration runtime and can pick the most optimal setup which satisfy the parameters. This way we do not need to place any constraint on the stream itself, allowing application greater freedom on how they want to set up ALSA. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-04-14ASoC: davinci-mcasp: Configure the AFIFO and DMA burst size at the same placePeter Ujfalusi1-17/+13
Move the dma_params->fifo_level and dma_data->maxburst configuration to the mcasp_common_hw_param() function where we configure the AFIFO registers. It makes the code regarding to AFIFO and DMA configuration more easy to follow since it is now clear how the AFIFO and how the DMA is going to be configured. Previously this has been done in two functions using a bit different calculation form - which ended up with the same result in both case at the end, but it was confusing. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-04-14ASoC: davinci-mcasp: Simplify and clean up the AFIFO configuration codePeter Ujfalusi1-24/+24
We can have more linear code flow by using variables in mcasp_common_hw_param() related to the AFIFO configuration. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-04-14ASoC: davinci-mcasp: Fix debug typo in davinci_mcasp_hw_params()Peter Ujfalusi1-1/+1
requred -> required Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-04-14ASoC: davinci-mcasp: Assign the dma_data earlier in dai_probe callbackPeter Ujfalusi1-15/+21
Set up the playback_dma_data/capture_dma_data for the dai at probe time since the generic dmaengine PCM stack needs to have access to this information early. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-04-08ASoC: davinci-mcasp: Fix bit clock polarity settingsPeter Ujfalusi1-3/+3
IB_NF, NB_IF and IB_IF configured the bc polarity incorrectly. The receive polarity was set to the same edge as the TX in these cases. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-03-17ASoC: davinci-mcasp: Provide correct filter_data for dmaengine for non-DT bootPeter Ujfalusi1-5/+16
When we boot with non-DT mode the damengine will need the channel number and a filter function in order to get the channel. The filter_data is filled in the DAI driver while the filter_function will be provided by the edma-pcm driver. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-03-09ASoC: davinci-mcasp: Rename the pointer to davinci dma_params as dma_paramsPeter Ujfalusi1-22/+22
It is quite confusing to name the pointer to davinci_pcm_dma_params as dma_data. Rename the pointer to avoid confusion. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-02-03ASoC: davinci-mcasp: Remove long lines from suspend/resume callbacksPeter Ujfalusi1-24/+28
Move the context register storage behind of a struct and use a pointer to it in the suspend/resume callbacks to remove the long lines. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-02-03ASoC: davinci-mcasp: Rename platform data structPeter Ujfalusi1-8/+8
Rename the struct for the platform data: snd_platform_data -> davinci_mcasp_pdata Since we have users under arch/arm/mach-davinci/ for this struct add temporary define to avoid breakage. The arch code can be updated later to use the new struct name. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-02-03ASoC: davinci-mcasp: Code cleanup in davinci_mcasp_hw_params()Peter Ujfalusi1-12/+8
Rearrange the code in the function for readability. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-01-31ASoC: davinci-mcasp: Move pm callbacks from platform device to soc_dai_driverPeter Ujfalusi1-37/+37
Handle the PM callbacks via the ASoC core instead of device core. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-01-31ASoC: davinci-mcasp: Return value handling cleanup for mcasp_common_hw_param()Peter Ujfalusi1-2/+4
Take the return value from mcasp_common_hw_param() and use that in case of error. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>