diff options
author | Eliot Blennerhassett <eblennerhassett@audioscience.com> | 2010-03-24 10:23:34 +1300 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2010-03-24 07:41:02 +0100 |
commit | 41ec1a81a8370ca42e8560532dff417a54f843fd (patch) | |
tree | e7e8e5c5989749183ca96cb66104738f87bcbf61 | |
parent | 104569eaa8e7618fdf1aae616d2993f67cec82c0 (diff) | |
download | alsa-driver-build-unstable-41ec1a81a8370ca42e8560532dff417a54f843fd.tar.gz |
snd-asihpi: Keep HPI buffer pointers in sync with ALSA after rewrite.
Fixes problem where alsa overwrote buffered data before it had been read.
Signed-off-by: Eliot Blennerhassett <eblennerhassett@audioscience.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | pci/asihpi/hpi6205.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/pci/asihpi/hpi6205.c b/pci/asihpi/hpi6205.c index a8a84b3e2..6db1c58d1 100644 --- a/pci/asihpi/hpi6205.c +++ b/pci/asihpi/hpi6205.c @@ -1051,26 +1051,18 @@ static void OutStreamWrite( struct bus_master_interface *interface = phw->pInterfaceBuffer; struct hpi_hostbuffer_status *status; long dwSpaceAvailable; + if (!phw->OutStreamHostBufferSize[phm->wObjIndex]) { - /* there is no BBM buffer */ + /* there is no BBM buffer, write via message */ HW_Message(pao, phm, phr); return; } - HPI_InitResponse(phr, phm->wObject, phm->wFunction, 0); + HPI_InitResponse(phr, phm->wObject, phm->wFunction, 0); status = &interface->aOutStreamHostBufferStatus[phm->wObjIndex]; -/* Set this to 1 to force this OutStremWrite() call to write data to the */ -/* adapter's buffers for the first write following stream reset. */ -#define OLD_STYLE_PREWRITE (1) - - /* check whether we need to send the format to the DSP */ if (phw->flagOStreamJustReset[phm->wObjIndex]) { -#if OLD_STYLE_PREWRITE - int nPartialWrite = 0; - unsigned int nOriginalSize = 0; -#endif - + /* Format can only change after reset. Must tell DSP. */ u16 wFunction = phm->wFunction; phw->flagOStreamJustReset[phm->wObjIndex] = 0; phm->wFunction = HPI_OSTREAM_SET_FORMAT; @@ -1078,11 +1070,18 @@ static void OutStreamWrite( phm->wFunction = wFunction; if (phr->wError) return; + } +#if 1 + if (phw->flagOStreamJustReset[phm->wObjIndex]) { + /* First OutStremWrite() call following reset will write data to the + adapter's buffers, reducing delay before stream can start + */ + int nPartialWrite = 0; + unsigned int nOriginalSize = 0; -#if OLD_STYLE_PREWRITE /* Send the first buffer to the DSP the old way. */ /* Limit size of first transfer - */ - /* hopefully this will not not be triggered. */ + /* expect that this will not usually be triggered. */ if (phm->u.d.u.Data.dwDataSize > HPI6205_SIZEOF_DATA) { nPartialWrite = 1; nOriginalSize = phm->u.d.u.Data.dwDataSize; @@ -1096,6 +1095,8 @@ static void OutStreamWrite( * buffer update task reads data from the host BBM buffer) */ status->dwAuxiliaryDataAvailable = phm->u.d.u.Data.dwDataSize; + status->dwHostIndex += phm->u.d.u.Data.dwDataSize; + status->dwDSPIndex += phm->u.d.u.Data.dwDataSize; /* if we did a full write, we can return from here. */ if (!nPartialWrite) @@ -1106,8 +1107,8 @@ static void OutStreamWrite( phm->u.d.u.Data.dwDataSize = nOriginalSize - HPI6205_SIZEOF_DATA; phm->u.d.u.Data.pbData += HPI6205_SIZEOF_DATA; -#endif } +#endif dwSpaceAvailable = OutStreamGetSpaceAvailable(status); if (dwSpaceAvailable < (long)phm->u.d.u.Data.dwDataSize) { |