Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 332129
b: refs/heads/master
c: dffb360
h: refs/heads/master
i:
  332127: 4541e40
v: v3
  • Loading branch information
Peter Ujfalusi authored and Mark Brown committed Sep 22, 2012
1 parent 259f0e9 commit e47a21a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 31 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2dde5b909e117cc95a5e31604f9bfd043e78ad9d
refs/heads/master: dffb360e64968b95a0a0221ca52234a28cc049c9
47 changes: 17 additions & 30 deletions trunk/sound/soc/omap/omap-mcbsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ static void omap_mcbsp_set_threshold(struct snd_pcm_substream *substream)
*/
if (dma_data->packet_size)
words = dma_data->packet_size;
else if (mcbsp->dma_op_mode == MCBSP_DMA_MODE_THRESHOLD)
words = snd_pcm_lib_period_bytes(substream) /
(mcbsp->wlen / 8);
else
words = 1;

Expand Down Expand Up @@ -251,41 +248,31 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
dma_data->set_threshold = omap_mcbsp_set_threshold;
if (mcbsp->dma_op_mode == MCBSP_DMA_MODE_THRESHOLD) {
int period_words, max_thrsh;
int divider = 0;

period_words = params_period_bytes(params) / (wlen / 8);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
max_thrsh = mcbsp->max_tx_thres;
else
max_thrsh = mcbsp->max_rx_thres;
/*
* If the period contains less or equal number of words,
* we are using the original threshold mode setup:
* McBSP threshold = sDMA frame size = period_size
* Otherwise we switch to sDMA packet mode:
* McBSP threshold = sDMA packet size
* sDMA frame size = period size
* Use sDMA packet mode if McBSP is in threshold mode:
* If period words less than the FIFO size the packet
* size is set to the number of period words, otherwise
* Look for the biggest threshold value which divides
* the period size evenly.
*/
if (period_words > max_thrsh) {
int divider = 0;

/*
* Look for the biggest threshold value, which
* divides the period size evenly.
*/
divider = period_words / max_thrsh;
if (period_words % max_thrsh)
divider++;
while (period_words % divider &&
divider < period_words)
divider++;
if (divider == period_words)
return -EINVAL;

pkt_size = period_words / divider;
sync_mode = OMAP_DMA_SYNC_PACKET;
} else {
sync_mode = OMAP_DMA_SYNC_FRAME;
}
divider = period_words / max_thrsh;
if (period_words % max_thrsh)
divider++;
while (period_words % divider &&
divider < period_words)
divider++;
if (divider == period_words)
return -EINVAL;

pkt_size = period_words / divider;
sync_mode = OMAP_DMA_SYNC_PACKET;
} else if (channels > 1) {
/* Use packet mode for non mono streams */
pkt_size = channels;
Expand Down

0 comments on commit e47a21a

Please sign in to comment.