[PATCH 009/113] usb: gadget: use snd_pcm_is_playback/capture()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We can use snd_pcm_is_playback/capture(). Let's use it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@xxxxxxxxxxx>
---
 drivers/usb/gadget/function/u_audio.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/gadget/function/u_audio.c b/drivers/usb/gadget/function/u_audio.c
index 40093fa1093d3..09fbae35aea25 100644
--- a/drivers/usb/gadget/function/u_audio.c
+++ b/drivers/usb/gadget/function/u_audio.c
@@ -190,7 +190,7 @@ static void u_audio_iso_complete(struct usb_ep *ep, struct usb_request *req)
 		goto exit;
 	}
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(substream)) {
 		/*
 		 * For each IN packet, take the quotient of the current data
 		 * rate and the endpoint's interval as the base packet size.
@@ -244,7 +244,7 @@ static void u_audio_iso_complete(struct usb_ep *ep, struct usb_request *req)
 	/* Pack USB load in ALSA ring buffer */
 	pending = runtime->dma_bytes - hw_ptr;
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(substream)) {
 		if (unlikely(pending < req->actual)) {
 			memcpy(req->buf, runtime->dma_area + hw_ptr, pending);
 			memcpy(req->buf + pending, runtime->dma_area,
@@ -322,7 +322,7 @@ static int uac_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
 	audio_dev = uac->audio_dev;
 	params = &audio_dev->params;
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(substream))
 		prm = &uac->p_prm;
 	else
 		prm = &uac->c_prm;
@@ -344,7 +344,7 @@ static int uac_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
 	}
 
 	/* Clear buffer after Play stops */
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && !prm->ss)
+	if (snd_pcm_is_playback(substream) && !prm->ss)
 		memset(prm->rbuf, 0, prm->max_psize * params->req_number);
 
 	return err;
@@ -355,7 +355,7 @@ static snd_pcm_uframes_t uac_pcm_pointer(struct snd_pcm_substream *substream)
 	struct snd_uac_chip *uac = snd_pcm_substream_chip(substream);
 	struct uac_rtd_params *prm;
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(substream))
 		prm = &uac->p_prm;
 	else
 		prm = &uac->c_prm;
@@ -402,7 +402,7 @@ static int uac_pcm_open(struct snd_pcm_substream *substream)
 
 	runtime->hw = uac_pcm_hardware;
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(substream)) {
 		runtime->hw.formats = uac_ssize_to_fmt(p_ssize);
 		runtime->hw.channels_min = num_channels(p_chmask);
 		prm = &uac->p_prm;
@@ -1299,7 +1299,7 @@ int g_audio_setup(struct g_audio *g_audio, const char *pcm_name,
 		if (!pcm->streams[i].substream_count)
 			continue;
 
-		if (i == SNDRV_PCM_STREAM_PLAYBACK) {
+		if (snd_pcm_is_playback(i)) {
 			prm = &uac->p_prm;
 			fu = &params->p_fu;
 			direction = "Playback";
-- 
2.43.0




[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux