Skip to content

Commit 37a2c94

Browse files
committed
Fixes for McASP and dmaengine_pcm
Merge series from Jai Luthra <[email protected]>: This series fixes two patches: 1. Fix the dmaengine API usage by calling dmaengine_synchronize() after dmaengine_terminate_async() when xrun events occur in application 2. Use the McASP AFIFO property from DT to refine the period size, instead of hardcoding minimum to 64 samples
2 parents 524d3f1 + c5dcf8a commit 37a2c94

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

include/sound/dmaengine_pcm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ snd_pcm_uframes_t snd_dmaengine_pcm_pointer_no_residue(struct snd_pcm_substream
3636
int snd_dmaengine_pcm_open(struct snd_pcm_substream *substream,
3737
struct dma_chan *chan);
3838
int snd_dmaengine_pcm_close(struct snd_pcm_substream *substream);
39+
int snd_dmaengine_pcm_sync_stop(struct snd_pcm_substream *substream);
3940

4041
int snd_dmaengine_pcm_open_request_chan(struct snd_pcm_substream *substream,
4142
dma_filter_fn filter_fn, void *filter_data);

sound/core/pcm_dmaengine.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,16 @@ int snd_dmaengine_pcm_open_request_chan(struct snd_pcm_substream *substream,
349349
}
350350
EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_open_request_chan);
351351

352+
int snd_dmaengine_pcm_sync_stop(struct snd_pcm_substream *substream)
353+
{
354+
struct dmaengine_pcm_runtime_data *prtd = substream_to_prtd(substream);
355+
356+
dmaengine_synchronize(prtd->dma_chan);
357+
358+
return 0;
359+
}
360+
EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_sync_stop);
361+
352362
/**
353363
* snd_dmaengine_pcm_close - Close a dmaengine based PCM substream
354364
* @substream: PCM substream

sound/soc/soc-generic-dmaengine-pcm.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,12 @@ static int dmaengine_copy(struct snd_soc_component *component,
318318
return 0;
319319
}
320320

321+
static int dmaengine_pcm_sync_stop(struct snd_soc_component *component,
322+
struct snd_pcm_substream *substream)
323+
{
324+
return snd_dmaengine_pcm_sync_stop(substream);
325+
}
326+
321327
static const struct snd_soc_component_driver dmaengine_pcm_component = {
322328
.name = SND_DMAENGINE_PCM_DRV_NAME,
323329
.probe_order = SND_SOC_COMP_ORDER_LATE,
@@ -327,6 +333,7 @@ static const struct snd_soc_component_driver dmaengine_pcm_component = {
327333
.trigger = dmaengine_pcm_trigger,
328334
.pointer = dmaengine_pcm_pointer,
329335
.pcm_construct = dmaengine_pcm_new,
336+
.sync_stop = dmaengine_pcm_sync_stop,
330337
};
331338

332339
static const struct snd_soc_component_driver dmaengine_pcm_component_process = {
@@ -339,6 +346,7 @@ static const struct snd_soc_component_driver dmaengine_pcm_component_process = {
339346
.pointer = dmaengine_pcm_pointer,
340347
.copy = dmaengine_copy,
341348
.pcm_construct = dmaengine_pcm_new,
349+
.sync_stop = dmaengine_pcm_sync_stop,
342350
};
343351

344352
static const char * const dmaengine_pcm_dma_channel_names[] = {

sound/soc/ti/davinci-mcasp.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,10 +1472,11 @@ static int davinci_mcasp_hw_rule_min_periodsize(
14721472
{
14731473
struct snd_interval *period_size = hw_param_interval(params,
14741474
SNDRV_PCM_HW_PARAM_PERIOD_SIZE);
1475+
u8 numevt = *((u8 *)rule->private);
14751476
struct snd_interval frames;
14761477

14771478
snd_interval_any(&frames);
1478-
frames.min = 64;
1479+
frames.min = numevt;
14791480
frames.integer = 1;
14801481

14811482
return snd_interval_refine(period_size, &frames);
@@ -1490,6 +1491,7 @@ static int davinci_mcasp_startup(struct snd_pcm_substream *substream,
14901491
u32 max_channels = 0;
14911492
int i, dir, ret;
14921493
int tdm_slots = mcasp->tdm_slots;
1494+
u8 *numevt;
14931495

14941496
/* Do not allow more then one stream per direction */
14951497
if (mcasp->substreams[substream->stream])
@@ -1589,9 +1591,12 @@ static int davinci_mcasp_startup(struct snd_pcm_substream *substream,
15891591
return ret;
15901592
}
15911593

1594+
numevt = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
1595+
&mcasp->txnumevt :
1596+
&mcasp->rxnumevt;
15921597
snd_pcm_hw_rule_add(substream->runtime, 0,
15931598
SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
1594-
davinci_mcasp_hw_rule_min_periodsize, NULL,
1599+
davinci_mcasp_hw_rule_min_periodsize, numevt,
15951600
SNDRV_PCM_HW_PARAM_PERIOD_SIZE, -1);
15961601

15971602
return 0;

0 commit comments

Comments
 (0)