summaryrefslogtreecommitdiff
path: root/sound/soc/davinci/davinci-mcasp.c
AgeCommit message (Collapse)AuthorFilesLines
2018-08-31ASoC: davinci-mcasp: Add support for FIFO usage caused delay reportingPeter Ujfalusi1-0/+37
McASP have write and read FIFO, each 64 words deep. From the WFIFOS/RFIFOS registers we can read the amount of data currently in the FIFO which can be directly reported as delay. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2018-07-04ASoC: davinci: Use snd_pcm_stop_xrun() helperTakashi Iwai1-12/+4
Replace open-codes with the standard snd_pcm_stop_xrun() helper. It simplifies codes a lot. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Mark Brown <broonie@kernel.org>
2018-06-13treewide: devm_kzalloc() -> devm_kcalloc()Kees Cook1-6/+8
The devm_kzalloc() function has a 2-factor argument form, devm_kcalloc(). This patch replaces cases of: devm_kzalloc(handle, a * b, gfp) with: devm_kcalloc(handle, a * b, gfp) as well as handling cases of: devm_kzalloc(handle, a * b * c, gfp) with: devm_kzalloc(handle, array3_size(a, b, c), gfp) as it's slightly less ugly than: devm_kcalloc(handle, array_size(a, b), c, gfp) This does, however, attempt to ignore constant size factors like: devm_kzalloc(handle, 4 * 1024, gfp) though any constants defined via macros get caught up in the conversion. Any factors with a sizeof() of "unsigned char", "char", and "u8" were dropped, since they're redundant. Some manual whitespace fixes were needed in this patch, as Coccinelle really liked to write "=devm_kcalloc..." instead of "= devm_kcalloc...". The Coccinelle script used for this was: // Fix redundant parens around sizeof(). @@ expression HANDLE; type TYPE; expression THING, E; @@ ( devm_kzalloc(HANDLE, - (sizeof(TYPE)) * E + sizeof(TYPE) * E , ...) | devm_kzalloc(HANDLE, - (sizeof(THING)) * E + sizeof(THING) * E , ...) ) // Drop single-byte sizes and redundant parens. @@ expression HANDLE; expression COUNT; typedef u8; typedef __u8; @@ ( devm_kzalloc(HANDLE, - sizeof(u8) * (COUNT) + COUNT , ...) | devm_kzalloc(HANDLE, - sizeof(__u8) * (COUNT) + COUNT , ...) | devm_kzalloc(HANDLE, - sizeof(char) * (COUNT) + COUNT , ...) | devm_kzalloc(HANDLE, - sizeof(unsigned char) * (COUNT) + COUNT , ...) | devm_kzalloc(HANDLE, - sizeof(u8) * COUNT + COUNT , ...) | devm_kzalloc(HANDLE, - sizeof(__u8) * COUNT + COUNT , ...) | devm_kzalloc(HANDLE, - sizeof(char) * COUNT + COUNT , ...) | devm_kzalloc(HANDLE, - sizeof(unsigned char) * COUNT + COUNT , ...) ) // 2-factor product with sizeof(type/expression) and identifier or constant. @@ expression HANDLE; type TYPE; expression THING; identifier COUNT_ID; constant COUNT_CONST; @@ ( - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(TYPE) * (COUNT_ID) + COUNT_ID, sizeof(TYPE) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(TYPE) * COUNT_ID + COUNT_ID, sizeof(TYPE) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(TYPE) * (COUNT_CONST) + COUNT_CONST, sizeof(TYPE) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(TYPE) * COUNT_CONST + COUNT_CONST, sizeof(TYPE) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(THING) * (COUNT_ID) + COUNT_ID, sizeof(THING) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(THING) * COUNT_ID + COUNT_ID, sizeof(THING) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(THING) * (COUNT_CONST) + COUNT_CONST, sizeof(THING) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(THING) * COUNT_CONST + COUNT_CONST, sizeof(THING) , ...) ) // 2-factor product, only identifiers. @@ expression HANDLE; identifier SIZE, COUNT; @@ - devm_kzalloc + devm_kcalloc (HANDLE, - SIZE * COUNT + COUNT, SIZE , ...) // 3-factor product with 1 sizeof(type) or sizeof(expression), with // redundant parens removed. @@ expression HANDLE; expression THING; identifier STRIDE, COUNT; type TYPE; @@ ( devm_kzalloc(HANDLE, - sizeof(TYPE) * (COUNT) * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | devm_kzalloc(HANDLE, - sizeof(TYPE) * (COUNT) * STRIDE + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | devm_kzalloc(HANDLE, - sizeof(TYPE) * COUNT * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | devm_kzalloc(HANDLE, - sizeof(TYPE) * COUNT * STRIDE + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | devm_kzalloc(HANDLE, - sizeof(THING) * (COUNT) * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | devm_kzalloc(HANDLE, - sizeof(THING) * (COUNT) * STRIDE + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | devm_kzalloc(HANDLE, - sizeof(THING) * COUNT * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | devm_kzalloc(HANDLE, - sizeof(THING) * COUNT * STRIDE + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) ) // 3-factor product with 2 sizeof(variable), with redundant parens removed. @@ expression HANDLE; expression THING1, THING2; identifier COUNT; type TYPE1, TYPE2; @@ ( devm_kzalloc(HANDLE, - sizeof(TYPE1) * sizeof(TYPE2) * COUNT + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2)) , ...) | devm_kzalloc(HANDLE, - sizeof(TYPE1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2)) , ...) | devm_kzalloc(HANDLE, - sizeof(THING1) * sizeof(THING2) * COUNT + array3_size(COUNT, sizeof(THING1), sizeof(THING2)) , ...) | devm_kzalloc(HANDLE, - sizeof(THING1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(THING1), sizeof(THING2)) , ...) | devm_kzalloc(HANDLE, - sizeof(TYPE1) * sizeof(THING2) * COUNT + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2)) , ...) | devm_kzalloc(HANDLE, - sizeof(TYPE1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2)) , ...) ) // 3-factor product, only identifiers, with redundant parens removed. @@ expression HANDLE; identifier STRIDE, SIZE, COUNT; @@ ( devm_kzalloc(HANDLE, - (COUNT) * STRIDE * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | devm_kzalloc(HANDLE, - COUNT * (STRIDE) * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | devm_kzalloc(HANDLE, - COUNT * STRIDE * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | devm_kzalloc(HANDLE, - (COUNT) * (STRIDE) * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | devm_kzalloc(HANDLE, - COUNT * (STRIDE) * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | devm_kzalloc(HANDLE, - (COUNT) * STRIDE * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | devm_kzalloc(HANDLE, - (COUNT) * (STRIDE) * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | devm_kzalloc(HANDLE, - COUNT * STRIDE * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) ) // Any remaining multi-factor products, first at least 3-factor products, // when they're not all constants... @@ expression HANDLE; expression E1, E2, E3; constant C1, C2, C3; @@ ( devm_kzalloc(HANDLE, C1 * C2 * C3, ...) | devm_kzalloc(HANDLE, - (E1) * E2 * E3 + array3_size(E1, E2, E3) , ...) | devm_kzalloc(HANDLE, - (E1) * (E2) * E3 + array3_size(E1, E2, E3) , ...) | devm_kzalloc(HANDLE, - (E1) * (E2) * (E3) + array3_size(E1, E2, E3) , ...) | devm_kzalloc(HANDLE, - E1 * E2 * E3 + array3_size(E1, E2, E3) , ...) ) // And then all remaining 2 factors products when they're not all constants, // keeping sizeof() as the second factor argument. @@ expression HANDLE; expression THING, E1, E2; type TYPE; constant C1, C2, C3; @@ ( devm_kzalloc(HANDLE, sizeof(THING) * C2, ...) | devm_kzalloc(HANDLE, sizeof(TYPE) * C2, ...) | devm_kzalloc(HANDLE, C1 * C2 * C3, ...) | devm_kzalloc(HANDLE, C1 * C2, ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(TYPE) * (E2) + E2, sizeof(TYPE) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(TYPE) * E2 + E2, sizeof(TYPE) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(THING) * (E2) + E2, sizeof(THING) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(THING) * E2 + E2, sizeof(THING) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - (E1) * E2 + E1, E2 , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - (E1) * (E2) + E1, E2 , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - E1 * E2 + E1, E2 , ...) ) Signed-off-by: Kees Cook <keescook@chromium.org>
2018-05-17ASoC: davinci-mcasp: Only disable inactive serializerVishal Thanki1-1/+1
As a side effect of the following commit, the active TX serializer may get disabled which may result in distorted audio output. ASoC: davinci-mcasp: Add support for multichannel playback (2952b27e2e463b28d5c0f04000f96b968137ca42) For example, if a 4 channel I2S playback with two TX serializers is activated. Later on, if a recording of 2 channels, with only 1 RX serializer is started, which will also disable one of the TX serializer because max_active_serializers is only calculated for RX (recording) stream. This patch fixes this issue. Signed-off-by: Vishal Thanki <vishalthanki@gmail.com> Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2018-05-11ASoC: davinci-mcasp: Convert to use the sdma-pcm instead of omap-pcmPeter Ujfalusi1-4/+4
Use the new platform driver in case of sDMA. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2018-01-05ASoC: davinci-mcasp: Add rule to constrain the minimum period sizePeter Ujfalusi1-0/+19
The minimum period size (in frames) must be not lower than the FIFO size of McASP and in general too small period size would easily result underrun in applications as eDMA - the most common DMA servicing McASP have support for limited number of periods. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-09-21ASoC: davinci-mcasp: Handle return value of devm_kasprintfArvind Yadav1-0/+12
devm_kasprintf() can fail here and we must check its return value. Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com> Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-09-20ASoC: davinci: Kill BUG_ON() usageTakashi Iwai1-1/+2
Don't use BUG_ON() for a non-critical sanity check on production systems. This patch replaces with a softer WARN_ON() and an error path. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-09-19ASoC: davinci-mcasp: Fix an error handling path in 'davinci_mcasp_probe()'Christophe Jaillet1-2/+4
All error handling paths in this function 'goto err' except this one. If one of the 2 previous memory allocations fails, we should go through the existing error handling path. Otherwise there is an unbalanced pm_runtime_enable()/pm_runtime_disable(). Fixes: dd55ff8346a9 ("ASoC: davinci-mcasp: Add set_tdm_slots() support") Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-27ASoC: davinci-mcasp: check memory allocation failureChristophe Jaillet1-0/+4
Check memory allocation failures and return -ENOMEM in such cases, as already done above for another memory allocation. This avoids NULL pointers dereference. Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-14ASoC: DaVinci: Delete an error message for a failed memory allocation in two ↵Markus Elfring1-2/+0
functions Omit an extra message for a memory allocation failure in these functions. This issue was detected by using the Coccinelle software. Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-05-14ASoC: davinci-mcasp: Support for one channel (mono) audioPeter Ujfalusi1-6/+6
Mono audio can be achieved by configuring McASP to transmit/receive only during one timeslot. McASP will still going to generate clocks for the other slot(s), but will only use the single slot to transmit/receive. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-09-01ASoC: davinci-mcasp: off-by-one in davinci_mcasp_hw_rule_format()Peter Ujfalusi1-1/+1
The SNDRV_PCM_FORMAT_LAST is valid, we should not skip it. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-06-02ASoC: davinci-mcasp: Use a copy of pdata per instance during DT bootPeter Ujfalusi1-1/+8
Instead of modifying the static pdata struct per McASP instance we need to allocate pdata for each McASP. This way we can avoid configuration leakage from prior McASP to McASP drivers probed at later time. 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>
2016-06-02ASoC: davinci-mcasp: Fix dra7 DMA offset when using CFG portPeter Ujfalusi1-4/+52
The TX and RX offset is different for each serializers when using the CFG port for DMA access. When using the CFG port only one serializer can be used per direction so print error message and only configure the first serializer's offset. Reported-by: Misael Lopez Cruz <misael.lopez@ti.com> Suggested-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>
2016-05-13Merge remote-tracking branches 'asoc/topic/davinci' and 'asoc/topic/dwc' ↵Mark Brown1-32/+58
into asoc-next
2016-05-09ASoC: davinci-mcasp: Calculate AUXCLK divider when setting up master clocksPeter Ujfalusi1-4/+25
If the McASP is used as clock master and the reference clock is AUXCLK we can have additional level of divider. The BCLK divider is limited to maximum 32, if the desired bclk can not be reached with this, the AUXCLK divider also needs to be used. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-05-09ASoC: davinci-mcasp: Restructure the davinci_mcasp_calc_clk_div()Peter Ujfalusi1-19/+19
Change the return value to error_pmm instead of the BCLK div and handle the divider configuration to McASP within the function when the set flag is true. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-05-09ASoC: davinci-mcasp: Change __davinci_mcasp_set_clkdiv() first parameterPeter Ujfalusi1-5/+5
Change the first parameter to struct davinci_mcasp* from struct snd_soc_dai* The function internally does not use or need the DAI information. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-05-09ASoC: davinci-mcasp: Use defines for clkdiv IDsPeter Ujfalusi1-3/+4
Instead of hardwired IDs add defines for the available dividers. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-05-09ASoC: davinci-mcasp: Do not allow multiple streams in one directionPeter Ujfalusi1-2/+6
Make sure that the user can not start multiple streams with the same direction. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-04-29ASoC: davinci-mcasp: Fix overwriting of ahclkxJim Lodes1-1/+1
The mcasp davinci_mcasp_set_dai_fmt function was overriding ahclkx input/output status that had already been set by the davinci_mcasp_set_sysclk function. This commit removes clearing of the ahclkx input/output status from davinci_mcasp_set_dai_fmt. Signed-off-by: Jim Lodes <jim.lodes@garmin.com> Signed-off-by: J.D. Schroeder <jay.schroeder@garmin.com> Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-03-12ASoC: davinci-mcasp: dai format runtime reconfigurationPeter Ujfalusi1-0/+10
In case when the dai format is set via the dai_link the format configuration happens once when the links are probed. If the McASP lose context after this, the information will be lost and McASP will not going to work correctly. To overcome this issue, we save the fmt and set it within hw_params as well. Reported-by: Misael Lopez Cruz <misael.lopez@ti.com> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Jyri Sarha <jsarha@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-01-27ASoC: davinci-mcasp: Discourage use of fck_parent for clock reparentingPeter Ujfalusi1-0/+2
The in-driver clock reparenting had been added when we did not had other means to cleanly set the parent for the fck. Now we can use assigned-clocks/assigned-clock-parents in DT binding. Print warning when the fck_parent is present for McASP and recommend the switch to the proper way to handle the clock selection. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-12-23Merge remote-tracking branches 'asoc/fix/davinci', 'asoc/fix/es8328', ↵Mark Brown1-2/+2
'asoc/fix/fsl-sai', 'asoc/fix/rockchip', 'asoc/fix/sgtl5000' and 'asoc/fix/wm8974' into asoc-linus
2015-12-11ASoC: davinci-mcasp: Fix XDATA check in mcasp_start_txPeter Ujfalusi1-2/+2
The condition for checking for XDAT being cleared was not correct. Fixes: 36bcecd0a73eb ("ASoC: davinci-mcasp: Correct TX start sequence") Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org> Cc: stable@vger.kernel.org
2015-11-23ASoC: davinci-mcasp: Fix master capture only modePeter Ujfalusi1-0/+8
When McASP is used as TX/RX synchronous (TX side generating clocks for RX side also) and only capture is used we need to configure the number of TX slots in order McASP to be able to generate the Frame sync. Fixes: 9273de1940d9e ("ASoC: davinci-mcasp: Add set_tdm_slots() support") Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-11-10ASoC: davinci-mcasp: Fix TDM slot rx/tx mask associationsAndreas Dannenberg1-2/+2
Fixes the associations between the tx_mask and rx_mask and the associated playback / capture streams during setting of the TDM slot. With this patch in place it is now possible for example to only populate tx_mask (leaving rx_mask as 0) for output-only codecs to control the TDM slot(s) the McASP serial port uses for transmit. Before that, this scenario would incorrectly rely on the rx_mask for this. Signed-off-by: Andreas Dannenberg <dannenberg@ti.com> Reviewed-by: Jyri Sarha <jsarha@ti.com> Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-23Merge remote-tracking branches 'asoc/topic/blackfin', 'asoc/topic/davinci', ↵Mark Brown1-103/+202
'asoc/topic/fsl', 'asoc/topic/hdmi' and 'asoc/topic/intel' into asoc-next
2015-09-18ASoC: davinci-mcasp: Fix devm_kasprintf format stringPeter Ujfalusi1-3/+3
The '\n' at the end of the format string is not needed. It adds an extra line break when doing cat /proc/interrupts Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-17ASoC: davinci-mcasp: Get rid of bclk_lrclk_ratio in private dataJyri Sarha1-25/+31
The slot_width is for essentially same thing. Instead of storing bclk_lrclk_ratio, just store the slot_width. Comments has been updated accordingly and some variable names changed to more descriptive. Signed-off-by: Jyri Sarha <jsarha@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-16ASoC: davinci-mcasp: Add set_tdm_slots() supportJyri Sarha1-81/+174
Implements set_tdm_slot() callback for mcasp. Channel constraints are updated according to the configured tdm mask and slots each time set_tdm_slot() is called. The special case when slot width is set to zero is allowed and it means that slot width is the same as the sample width. Signed-off-by: Jyri Sarha <jsarha@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-14ASoC: davinci-mcasp: Set .symmetric_rates = 1 in snd_soc_dai_driverJyri Sarha1-0/+1
The TX and RX direction share the same bit clock and frame sync, so the samplerate must be the same to both directions. Signed-off-by: Jyri Sarha <jsarha@ti.com> Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-14ASoC: davinci-mcasp: Revise the FIFO threshold calculationPeter Ujfalusi1-4/+3
The FIFO threshold for McASP should be <=[tx/rx]numevt so the initial value for the refining should meet this requirement as well. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-08-25ASoC: davinci: Convert to use devm_ioremap_resourceAxel Lin1-14/+4
Use devm_ioremap_resource() instead of open code. Signed-off-by: Axel Lin <axel.lin@ingics.com> Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-06-22Merge remote-tracking branch 'asoc/topic/davinci' into asoc-nextMark Brown1-10/+62
2015-06-09ASoC: davinci-mcasp: Choose PCM driver based on configured DMA controllerJyri Sarha1-10/+60
Find the configured DMA controller by asking for a DMA channel in the probe phase and releasing it right after. The controller device can be found via the dma_chan struct and the controller is recognized from the compatible property of its device node. The patch assumes EDMA if there is no device node. Signed-off-by: Jyri Sarha <jsarha@ti.com> Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-06-08ASoC: davinci-mcasp: Logic low for inactive output slotsMisael Lopez Cruz1-0/+2
The default state when serializers are in inactive slots is Hi-Z. In some cases, there are no additional components driving the data lines to a safe state so they might have noise. While in inactive slots, the McASP AXR pins configured as outputs can be driven low through the serializer pin drive mode setting (DISMOD) to prevent such noise. 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>
2015-06-05Merge remote-tracking branches 'asoc/topic/davinci' and 'asoc/topic/dpcm' ↵Mark Brown1-77/+90
into asoc-next
2015-04-30ASoC: davinci-mcasp: Correct pm status check in suspend callbackPeter Ujfalusi1-1/+1
pm_runtime_enabled() will only tell if the pm runtime has been enabled for the device, which is done at probe time but will not tell the actual power state of the device. pm_runtime_active() provides this information. This patch fixes a kernel crash when doing suspend when McASP is not active. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-04-30ASoC: davinci-macsp: Optimize implicit BLCK sample-rate ruleJyri Sarha1-10/+18
There is no need to copy the list of all supported sample-rates. Finding the supported endpoints within the current range is enough (see snd_interval_list()). Signed-off-by: Jyri Sarha <jsarha@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-04-30ASoC: davinci-mcasp: Channel count constraints for multi-serializer caseJyri Sarha1-0/+63
Set channel count constraints for multiple serializers case. On McASP the active channels mask is the same for all the serializers. With the current implementation this means that if more than one serializers is used, all TDM slots have to be active on all serializers. The patch sets the channel count constraints according to number of RX and TX serializers. Reported-by: Misael Lopez Cruz <misael.lopez@ti.com> Signed-off-by: Jyri Sarha <jsarha@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-04-30ASoC: davinci-mcasp: Calculate BCLK using TDM slots and remove channels ruleJyri Sarha1-70/+12
The McASP driver currently always sends as many slots or channels to a i2s-wire as there are configured tdm_slots (see mcasp_i2s_hw_param()). Thus the BLCK rate does not depend on the amount of channels, just the configure amount of tdm-slots. Reported-by: Misael Lopez Cruz <misael.lopez@ti.com> Signed-off-by: Jyri Sarha <jsarha@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-04-07ASoC: davinci-mcasp: Fix ruledata setup in davinci_mcasp_startupPeter Ujfalusi1-5/+7
Passing &mcasp->ruledata[dir] to snd_pcm_hw_rule_add() is not correct since commit: 7b3d165a2821 ASoC: davinci-mcasp: Index ruledata in drvdata with substream->stream now sets up the struct based on the substream->stream (0 or 1) while we pass a pointer which we take with dir (1 or 2). This will lead kernel crash. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-04-01ASoC: davinci-mcasp: Index ruledata in drvdata with substream->streamJyri Sarha1-2/+2
The serializer direction definitions runs from 1 to 2, which does not suite the purpose. The substream->stream is perfect for the purpose and should have been used from the beginning. Signed-off-by: Jyri Sarha <jsarha@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-03-24ASoC: davinci-mcasp: Set rule constraints if implicit BCLK divider is usedJyri Sarha1-10/+197
Set rule constraints to allow only combinations of sample-rate, sample-format, and channels counts that can be played/captured with reasonable sample-rate accuracy. The logic with tdm-slots and serializers (=i2s data wires) goes like this: The first wire will take all channels up to number of tdm-slots, before following wires (if any) are used. If the first wire is used fully, the remaining wires share the same clocks and the divider can be calculated for the first wire. Also, takes the number of tdm-slots into account when implicitly selecting the BLCK divider. Signed-off-by: Jyri Sarha <jsarha@ti.com> Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-03-06ASoC: davinci-mcasp: Fix compilation errorPeter Ujfalusi1-1/+1
Introduced by commit: 6afda7f50754 ASoC: davinci-mcasp: Allow complete shutdown of McASP when not in use I'm really sorry for this... Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-03-05ASoC: davinci-mcasp: Allow complete shutdown of McASP when not in usePeter Ujfalusi1-10/+17
Rearrange the pm_runtime_get/put_sync calls so the IP will be turned off when it is not in use. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-03-04ASoC: davinci-mcasp: Deprecate the use of davinci-pcm in favor of edma-pcmPeter Ujfalusi1-68/+19
The edma-pcm performs as good as the old davinci-pcm and it's use does not require the 'ping-pong' mode of davinci-pcm, which was introduced to overcome under/over flow issues when using davinci-pcm. Keep the SND_DAVINCI_SOC config option to select the SND_EDMA_SOC to avoid regression in audio support. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-02-14ASoC: davinci-mcasp: Add support for CBS_CFM modePeter Ujfalusi1-0/+12
Support for setups where codec is bitclock slave and frame master. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>