diff options
| author | Ajay Agarwal <ajaya@codeaurora.org> | 2019-01-08 19:26:45 +0530 |
|---|---|---|
| committer | Ajay Agarwal <ajaya@codeaurora.org> | 2019-01-09 10:16:50 +0530 |
| commit | 2b19cf4fb888bf9ba549251c746d3fb61a09b794 (patch) | |
| tree | 60fdf5916aa05e93f98044743b3a41797d0163fa | |
| parent | b79ca632cb30fd9673b4d9459280317664726a72 (diff) | |
Revert "usb: gadget: u_audio: remove caching of stream buffer parameters"
This reverts commit 32c666f9456fdf6b1fcaf87d6e924ae2724ed9ea.
Required for clean picking of UAC opensource changes.
Change-Id: I40d571178823c43126eccc55d11041b1baabc7f8
Signed-off-by: Ajay Agarwal <ajaya@codeaurora.org>
| -rw-r--r-- | drivers/usb/gadget/function/u_audio.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/drivers/usb/gadget/function/u_audio.c b/drivers/usb/gadget/function/u_audio.c index 717656e17afa..725593f7da9b 100644 --- a/drivers/usb/gadget/function/u_audio.c +++ b/drivers/usb/gadget/function/u_audio.c @@ -41,6 +41,9 @@ struct uac_req { struct uac_rtd_params { struct snd_uac_chip *uac; /* parent chip */ bool ep_enabled; /* if the ep is enabled */ + /* Size of the ring buffer */ + size_t dma_bytes; + unsigned char *dma_area; struct snd_pcm_substream *ss; @@ -96,7 +99,6 @@ static void u_audio_iso_complete(struct usb_ep *ep, struct usb_request *req) int status = req->status; struct uac_req *ur = req->context; struct snd_pcm_substream *substream; - struct snd_pcm_runtime *runtime; struct uac_rtd_params *prm = ur->pp; struct snd_uac_chip *uac = prm->uac; @@ -118,7 +120,6 @@ static void u_audio_iso_complete(struct usb_ep *ep, struct usb_request *req) if (!substream) goto exit; - runtime = substream->runtime; spin_lock_irqsave(&prm->lock, flags); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { @@ -155,31 +156,29 @@ static void u_audio_iso_complete(struct usb_ep *ep, struct usb_request *req) spin_unlock_irqrestore(&prm->lock, flags); /* Pack USB load in ALSA ring buffer */ - pending = runtime->dma_bytes - hw_ptr; + pending = prm->dma_bytes - hw_ptr; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { if (unlikely(pending < req->actual)) { - memcpy(req->buf, runtime->dma_area + hw_ptr, pending); - memcpy(req->buf + pending, runtime->dma_area, + memcpy(req->buf, prm->dma_area + hw_ptr, pending); + memcpy(req->buf + pending, prm->dma_area, req->actual - pending); } else { - memcpy(req->buf, runtime->dma_area + hw_ptr, - req->actual); + memcpy(req->buf, prm->dma_area + hw_ptr, req->actual); } } else { if (unlikely(pending < req->actual)) { - memcpy(runtime->dma_area + hw_ptr, req->buf, pending); - memcpy(runtime->dma_area, req->buf + pending, + memcpy(prm->dma_area + hw_ptr, req->buf, pending); + memcpy(prm->dma_area, req->buf + pending, req->actual - pending); } else { - memcpy(runtime->dma_area + hw_ptr, req->buf, - req->actual); + memcpy(prm->dma_area + hw_ptr, req->buf, req->actual); } } spin_lock_irqsave(&prm->lock, flags); /* update hw_ptr after data is copied to memory */ - prm->hw_ptr = (hw_ptr + req->actual) % runtime->dma_bytes; + prm->hw_ptr = (hw_ptr + req->actual) % prm->dma_bytes; spin_unlock_irqrestore(&prm->lock, flags); exit: @@ -261,8 +260,11 @@ static int uac_pcm_hw_params(struct snd_pcm_substream *substream, err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err >= 0) + if (err >= 0) { + prm->dma_bytes = substream->runtime->dma_bytes; + prm->dma_area = substream->runtime->dma_area; prm->period_size = params_period_bytes(hw_params); + } return err; } @@ -277,6 +279,8 @@ static int uac_pcm_hw_free(struct snd_pcm_substream *substream) else prm = &uac->c_prm; + prm->dma_area = NULL; + prm->dma_bytes = 0; prm->period_size = 0; return snd_pcm_lib_free_pages(substream); |
