Skip to content

Commit

Permalink
ALSA: asihpi - Improve non-busmaster adapter operation
Browse files Browse the repository at this point in the history
Make playback silence callback a no-op, card automatically outputs
silence when written data runs out.
Increasing update interval and thus minimum period avoids xrun on startup
or because of timer jitter.

Signed-off-by: Eliot Blennerhassett <eblennerhassett@audioscience.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Eliot Blennerhassett authored and Takashi Iwai committed Mar 25, 2011
1 parent 7bf76c3 commit 26aebef
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions sound/pci/asihpi/asihpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,7 @@ static int snd_card_asihpi_playback_open(struct snd_pcm_substream *substream)

snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
card->update_interval_frames);

snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
card->update_interval_frames * 2, UINT_MAX);

Expand Down Expand Up @@ -1054,7 +1055,7 @@ static int snd_card_asihpi_playback_copy(struct snd_pcm_substream *substream,
hpi_handle_error(hpi_outstream_write_buf(dpcm->h_stream,
runtime->dma_area, len, &dpcm->format));

dpcm->pcm_buf_host_rw_ofs = dpcm->pcm_buf_host_rw_ofs + len;
dpcm->pcm_buf_host_rw_ofs += len;

return 0;
}
Expand All @@ -1064,16 +1065,11 @@ static int snd_card_asihpi_playback_silence(struct snd_pcm_substream *
snd_pcm_uframes_t pos,
snd_pcm_uframes_t count)
{
unsigned int len;
struct snd_pcm_runtime *runtime = substream->runtime;
struct snd_card_asihpi_pcm *dpcm = runtime->private_data;

len = frames_to_bytes(runtime, count);
VPRINTK1(KERN_INFO "playback silence %u bytes\n", len);

memset(runtime->dma_area, 0, len);
hpi_handle_error(hpi_outstream_write_buf(dpcm->h_stream,
runtime->dma_area, len, &dpcm->format));
/* Usually writes silence to DMA buffer, which should be overwritten
by real audio later. Our fifos cannot be overwritten, and are not
free-running DMAs. Silence is output on fifo underflow.
This callback is still required to allow the copy callback to be used.
*/
return 0;
}

Expand Down Expand Up @@ -2885,6 +2881,9 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev,
if (err)
asihpi->update_interval_frames = 512;

if (!asihpi->support_mmap)
asihpi->update_interval_frames *= 2;

hpi_handle_error(hpi_instream_open(asihpi->adapter_index,
0, &h_stream));

Expand Down

0 comments on commit 26aebef

Please sign in to comment.