mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-11 15:49:56 +00:00
usb: gadget: u_audio: remove caching of stream buffer parameters
There is no necessity to copy PCM stream ring buffer area and size properties to UAC private data structure, these values can be got from substream itself. The change gives more control on substream and avoid stale caching. Fixes: 132fcb460839 ("usb: gadget: Add Audio Class 2.0 Driver") Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com> Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
This commit is contained in:
parent
6b37bd78d3
commit
96afb54ece
@ -32,9 +32,6 @@ struct uac_req {
|
|||||||
struct uac_rtd_params {
|
struct uac_rtd_params {
|
||||||
struct snd_uac_chip *uac; /* parent chip */
|
struct snd_uac_chip *uac; /* parent chip */
|
||||||
bool ep_enabled; /* if the ep is enabled */
|
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;
|
struct snd_pcm_substream *ss;
|
||||||
|
|
||||||
@ -90,6 +87,7 @@ static void u_audio_iso_complete(struct usb_ep *ep, struct usb_request *req)
|
|||||||
int status = req->status;
|
int status = req->status;
|
||||||
struct uac_req *ur = req->context;
|
struct uac_req *ur = req->context;
|
||||||
struct snd_pcm_substream *substream;
|
struct snd_pcm_substream *substream;
|
||||||
|
struct snd_pcm_runtime *runtime;
|
||||||
struct uac_rtd_params *prm = ur->pp;
|
struct uac_rtd_params *prm = ur->pp;
|
||||||
struct snd_uac_chip *uac = prm->uac;
|
struct snd_uac_chip *uac = prm->uac;
|
||||||
|
|
||||||
@ -111,6 +109,7 @@ static void u_audio_iso_complete(struct usb_ep *ep, struct usb_request *req)
|
|||||||
if (!substream)
|
if (!substream)
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
|
runtime = substream->runtime;
|
||||||
spin_lock_irqsave(&prm->lock, flags);
|
spin_lock_irqsave(&prm->lock, flags);
|
||||||
|
|
||||||
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
|
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
|
||||||
@ -147,29 +146,31 @@ static void u_audio_iso_complete(struct usb_ep *ep, struct usb_request *req)
|
|||||||
spin_unlock_irqrestore(&prm->lock, flags);
|
spin_unlock_irqrestore(&prm->lock, flags);
|
||||||
|
|
||||||
/* Pack USB load in ALSA ring buffer */
|
/* Pack USB load in ALSA ring buffer */
|
||||||
pending = prm->dma_bytes - hw_ptr;
|
pending = runtime->dma_bytes - hw_ptr;
|
||||||
|
|
||||||
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
|
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
|
||||||
if (unlikely(pending < req->actual)) {
|
if (unlikely(pending < req->actual)) {
|
||||||
memcpy(req->buf, prm->dma_area + hw_ptr, pending);
|
memcpy(req->buf, runtime->dma_area + hw_ptr, pending);
|
||||||
memcpy(req->buf + pending, prm->dma_area,
|
memcpy(req->buf + pending, runtime->dma_area,
|
||||||
req->actual - pending);
|
req->actual - pending);
|
||||||
} else {
|
} else {
|
||||||
memcpy(req->buf, prm->dma_area + hw_ptr, req->actual);
|
memcpy(req->buf, runtime->dma_area + hw_ptr,
|
||||||
|
req->actual);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (unlikely(pending < req->actual)) {
|
if (unlikely(pending < req->actual)) {
|
||||||
memcpy(prm->dma_area + hw_ptr, req->buf, pending);
|
memcpy(runtime->dma_area + hw_ptr, req->buf, pending);
|
||||||
memcpy(prm->dma_area, req->buf + pending,
|
memcpy(runtime->dma_area, req->buf + pending,
|
||||||
req->actual - pending);
|
req->actual - pending);
|
||||||
} else {
|
} else {
|
||||||
memcpy(prm->dma_area + hw_ptr, req->buf, req->actual);
|
memcpy(runtime->dma_area + hw_ptr, req->buf,
|
||||||
|
req->actual);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_lock_irqsave(&prm->lock, flags);
|
spin_lock_irqsave(&prm->lock, flags);
|
||||||
/* update hw_ptr after data is copied to memory */
|
/* update hw_ptr after data is copied to memory */
|
||||||
prm->hw_ptr = (hw_ptr + req->actual) % prm->dma_bytes;
|
prm->hw_ptr = (hw_ptr + req->actual) % runtime->dma_bytes;
|
||||||
spin_unlock_irqrestore(&prm->lock, flags);
|
spin_unlock_irqrestore(&prm->lock, flags);
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
@ -251,11 +252,8 @@ static int uac_pcm_hw_params(struct snd_pcm_substream *substream,
|
|||||||
|
|
||||||
err = snd_pcm_lib_malloc_pages(substream,
|
err = snd_pcm_lib_malloc_pages(substream,
|
||||||
params_buffer_bytes(hw_params));
|
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);
|
prm->period_size = params_period_bytes(hw_params);
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -270,8 +268,6 @@ static int uac_pcm_hw_free(struct snd_pcm_substream *substream)
|
|||||||
else
|
else
|
||||||
prm = &uac->c_prm;
|
prm = &uac->c_prm;
|
||||||
|
|
||||||
prm->dma_area = NULL;
|
|
||||||
prm->dma_bytes = 0;
|
|
||||||
prm->period_size = 0;
|
prm->period_size = 0;
|
||||||
|
|
||||||
return snd_pcm_lib_free_pages(substream);
|
return snd_pcm_lib_free_pages(substream);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user