@@ -119,9 +119,9 @@ static struct pcm_substream *usb6fire_pcm_get_substream(
{
struct pcm_runtime *rt = snd_pcm_substream_chip(alsa_sub);
- if (alsa_sub->stream == SNDRV_PCM_STREAM_PLAYBACK)
+ if (snd_pcm_is_playback(alsa_sub))
return &rt->playback;
- else if (alsa_sub->stream == SNDRV_PCM_STREAM_CAPTURE)
+ else if (snd_pcm_is_capture(alsa_sub))
return &rt->capture;
dev_err(&rt->chip->dev->dev, "error getting pcm substream slot.\n");
return NULL;
@@ -395,12 +395,12 @@ static int usb6fire_pcm_open(struct snd_pcm_substream *alsa_sub)
mutex_lock(&rt->stream_mutex);
alsa_rt->hw = pcm_hw;
- if (alsa_sub->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+ if (snd_pcm_is_playback(alsa_sub)) {
if (rt->rate < ARRAY_SIZE(rates))
alsa_rt->hw.rates = rates_alsaid[rt->rate];
alsa_rt->hw.channels_max = OUT_N_CHANNELS;
sub = &rt->playback;
- } else if (alsa_sub->stream == SNDRV_PCM_STREAM_CAPTURE) {
+ } else if (snd_pcm_is_capture(alsa_sub)) {
if (rt->rate < ARRAY_SIZE(rates))
alsa_rt->hw.rates = rates_alsaid[rt->rate];
alsa_rt->hw.channels_max = IN_N_CHANNELS;
@@ -53,7 +53,7 @@ activate_substream(struct snd_usb_caiaqdev *cdev,
{
spin_lock(&cdev->spinlock);
- if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK)
+ if (snd_pcm_is_playback(sub))
cdev->sub_playback[sub->number] = sub;
else
cdev->sub_capture[sub->number] = sub;
@@ -68,7 +68,7 @@ deactivate_substream(struct snd_usb_caiaqdev *cdev,
unsigned long flags;
spin_lock_irqsave(&cdev->spinlock, flags);
- if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK)
+ if (snd_pcm_is_playback(sub))
cdev->sub_playback[sub->number] = NULL;
else
cdev->sub_capture[sub->number] = NULL;
@@ -192,7 +192,7 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream)
dev_dbg(dev, "%s(%p)\n", __func__, substream);
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+ if (snd_pcm_is_playback(substream)) {
int out_pos;
switch (cdev->spec.data_alignment) {
@@ -305,7 +305,7 @@ snd_usb_caiaq_pcm_pointer(struct snd_pcm_substream *sub)
goto unlock;
}
- if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK)
+ if (snd_pcm_is_playback(sub))
ptr = bytes_to_frames(sub->runtime,
cdev->audio_out_buf_pos[index]);
else
@@ -339,7 +339,7 @@ static void check_for_elapsed_periods(struct snd_usb_caiaqdev *cdev,
continue;
pb = snd_pcm_lib_period_bytes(sub);
- cnt = (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
+ cnt = snd_pcm_is_playback(sub) ?
&cdev->period_out_count[stream] :
&cdev->period_in_count[stream];
@@ -701,7 +701,7 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *cdev, int dir, int *ret)
struct usb_device *usb_dev = cdev->chip.dev;
unsigned int pipe;
- pipe = (dir == SNDRV_PCM_STREAM_PLAYBACK) ?
+ pipe = snd_pcm_is_playback(dir) ?
usb_sndisocpipe(usb_dev, ENDPOINT_PLAYBACK) :
usb_rcvisocpipe(usb_dev, ENDPOINT_CAPTURE);
@@ -741,7 +741,7 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *cdev, int dir, int *ret)
urbs[i]->context = &cdev->data_cb_info[i];
urbs[i]->interval = 1;
urbs[i]->number_of_packets = FRAMES_PER_URB;
- urbs[i]->complete = (dir == SNDRV_PCM_STREAM_CAPTURE) ?
+ urbs[i]->complete = snd_pcm_is_capture(dir) ?
read_completed : write_completed;
}
@@ -172,7 +172,7 @@ static struct pcm_substream *hiface_pcm_get_substream(struct snd_pcm_substream
struct pcm_runtime *rt = snd_pcm_substream_chip(alsa_sub);
struct device *device = &rt->chip->dev->dev;
- if (alsa_sub->stream == SNDRV_PCM_STREAM_PLAYBACK)
+ if (snd_pcm_is_playback(alsa_sub))
return &rt->playback;
dev_err(device, "Error getting pcm substream slot.\n");
@@ -359,7 +359,7 @@ static int hiface_pcm_open(struct snd_pcm_substream *alsa_sub)
mutex_lock(&rt->stream_mutex);
alsa_rt->hw = pcm_hw;
- if (alsa_sub->stream == SNDRV_PCM_STREAM_PLAYBACK)
+ if (snd_pcm_is_playback(alsa_sub))
sub = &rt->playback;
if (!sub) {
@@ -137,7 +137,7 @@ static void line6_wait_clear_audio_urbs(struct snd_line6_pcm *line6pcm,
static inline struct line6_pcm_stream *
get_stream(struct snd_line6_pcm *line6pcm, int direction)
{
- return (direction == SNDRV_PCM_STREAM_PLAYBACK) ?
+ return (snd_pcm_is_playback(direction)) ?
&line6pcm->out : &line6pcm->in;
}
@@ -148,7 +148,7 @@ static int line6_buffer_acquire(struct snd_line6_pcm *line6pcm,
struct line6_pcm_stream *pstr, int direction, int type)
{
const int pkt_size =
- (direction == SNDRV_PCM_STREAM_PLAYBACK) ?
+ snd_pcm_is_playback(direction) ?
line6pcm->max_packet_size_out :
line6pcm->max_packet_size_in;
@@ -191,7 +191,7 @@ static int line6_stream_start(struct snd_line6_pcm *line6pcm, int direction,
!(pstr->active_urbs || pstr->unlink_urbs)) {
pstr->count = 0;
/* Submit all currently available URBs */
- if (direction == SNDRV_PCM_STREAM_PLAYBACK)
+ if (snd_pcm_is_playback(direction))
ret = line6_submit_audio_out_all_urbs(line6pcm);
else
ret = line6_submit_audio_in_all_urbs(line6pcm);
@@ -216,7 +216,7 @@ static void line6_stream_stop(struct snd_line6_pcm *line6pcm, int direction,
spin_unlock_irqrestore(&pstr->lock, flags);
line6_unlink_audio_urbs(line6pcm, pstr);
spin_lock_irqsave(&pstr->lock, flags);
- if (direction == SNDRV_PCM_STREAM_CAPTURE) {
+ if (snd_pcm_is_capture(direction)) {
line6pcm->prev_fbuf = NULL;
line6pcm->prev_fsize = 0;
}
@@ -240,7 +240,7 @@ int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd)
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_RESUME:
- if (s->stream == SNDRV_PCM_STREAM_CAPTURE &&
+ if (snd_pcm_is_capture(s) &&
(line6pcm->line6->properties->capabilities &
LINE6_CAP_IN_NEEDS_OUT)) {
err = line6_stream_start(line6pcm, SNDRV_PCM_STREAM_PLAYBACK,
@@ -256,7 +256,7 @@ int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd)
case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_SUSPEND:
- if (s->stream == SNDRV_PCM_STREAM_CAPTURE &&
+ if (snd_pcm_is_capture(s) &&
(line6pcm->line6->properties->capabilities &
LINE6_CAP_IN_NEEDS_OUT)) {
line6_stream_stop(line6pcm, SNDRV_PCM_STREAM_PLAYBACK,
@@ -267,13 +267,13 @@ int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd)
break;
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
- if (s->stream != SNDRV_PCM_STREAM_PLAYBACK)
+ if (!snd_pcm_is_playback(s))
return -EINVAL;
set_bit(LINE6_FLAG_PAUSE_PLAYBACK, &line6pcm->flags);
break;
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
- if (s->stream != SNDRV_PCM_STREAM_PLAYBACK)
+ if (!snd_pcm_is_playback(s))
return -EINVAL;
clear_bit(LINE6_FLAG_PAUSE_PLAYBACK, &line6pcm->flags);
break;
@@ -54,7 +54,7 @@ int snd_media_stream_init(struct snd_usb_substream *subs, struct snd_pcm *pcm,
return -ENOMEM;
mctl->media_dev = mdev;
- if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
+ if (snd_pcm_is_playback(stream)) {
intf_type = MEDIA_INTF_T_ALSA_PCM_PLAYBACK;
mctl->media_entity.function = MEDIA_ENT_F_AUDIO_PLAYBACK;
mctl->media_pad.flags = MEDIA_PAD_FL_SOURCE;
@@ -37,7 +37,7 @@ static snd_pcm_uframes_t snd_usb_pcm_delay(struct snd_usb_substream *subs,
int est_delay;
int queued;
- if (subs->direction == SNDRV_PCM_STREAM_PLAYBACK) {
+ if (snd_pcm_is_playback(subs->direction)) {
queued = bytes_to_frames(runtime, subs->inflight_bytes);
if (!queued)
return 0;
@@ -57,7 +57,7 @@ static snd_pcm_uframes_t snd_usb_pcm_delay(struct snd_usb_substream *subs,
some truncation for 44.1 but the estimate is good enough */
est_delay = frame_diff * runtime->rate / 1000;
- if (subs->direction == SNDRV_PCM_STREAM_PLAYBACK) {
+ if (snd_pcm_is_playback(subs->direction)) {
est_delay = queued - est_delay;
if (est_delay < 0)
est_delay = 0;
@@ -126,14 +126,14 @@ find_format(struct list_head *fmt_list_head, snd_pcm_format_t format,
*/
if (subs && attr != cur_attr) {
if ((attr == USB_ENDPOINT_SYNC_ASYNC &&
- subs->direction == SNDRV_PCM_STREAM_PLAYBACK) ||
+ snd_pcm_is_playback(subs->direction)) ||
(attr == USB_ENDPOINT_SYNC_ADAPTIVE &&
- subs->direction == SNDRV_PCM_STREAM_CAPTURE))
+ snd_pcm_is_capture(subs->direction)))
continue;
if ((cur_attr == USB_ENDPOINT_SYNC_ASYNC &&
- subs->direction == SNDRV_PCM_STREAM_PLAYBACK) ||
+ snd_pcm_is_playback(subs->direction)) ||
(cur_attr == USB_ENDPOINT_SYNC_ADAPTIVE &&
- subs->direction == SNDRV_PCM_STREAM_CAPTURE)) {
+ snd_pcm_is_capture(subs->direction))) {
found = fp;
cur_attr = attr;
continue;
@@ -616,7 +616,7 @@ static int lowlatency_playback_available(struct snd_pcm_runtime *runtime,
{
struct snd_usb_audio *chip = subs->stream->chip;
- if (subs->direction == SNDRV_PCM_STREAM_CAPTURE)
+ if (snd_pcm_is_capture(subs->direction))
return false;
/* disabled via module option? */
if (!chip->lowlatency)
@@ -678,7 +678,7 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream)
runtime->delay = 0;
subs->lowlatency_playback = lowlatency_playback_available(runtime, subs);
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
+ if (snd_pcm_is_playback(substream) &&
!subs->lowlatency_playback) {
ret = start_endpoints(subs);
/* if XRUN happens at starting streams (possibly with implicit
@@ -1212,7 +1212,7 @@ static int snd_usb_pcm_open(struct snd_pcm_substream *substream)
runtime->hw = snd_usb_hardware;
/* need an explicit sync to catch applptr update in low-latency mode */
- if (direction == SNDRV_PCM_STREAM_PLAYBACK &&
+ if (snd_pcm_is_playback(direction) &&
as->chip->lowlatency)
runtime->hw.info |= SNDRV_PCM_INFO_SYNC_APPLPTR;
runtime->private_data = subs;
@@ -1770,7 +1770,7 @@ void snd_usb_set_pcm_ops(struct snd_pcm *pcm, int stream)
{
const struct snd_pcm_ops *ops;
- ops = stream == SNDRV_PCM_STREAM_PLAYBACK ?
+ ops = snd_pcm_is_playback(stream) ?
&snd_usb_playback_ops : &snd_usb_capture_ops;
snd_pcm_set_ops(pcm, stream, ops);
}
@@ -1685,7 +1685,7 @@ static void set_format_emu_quirk(struct snd_usb_substream *subs,
* sample rate shouldn't be changed
* by playback substream
*/
- if (subs->direction == SNDRV_PCM_STREAM_PLAYBACK) {
+ if (snd_pcm_is_playback(subs->direction)) {
if (subs->stream->substream[SNDRV_PCM_STREAM_CAPTURE].cur_audiofmt)
return;
}
@@ -2017,7 +2017,7 @@ void snd_usb_audioformat_attributes_quirk(struct snd_usb_audio *chip,
* although it's really not...
*/
fp->ep_attr &= ~USB_ENDPOINT_SYNCTYPE;
- if (stream == SNDRV_PCM_STREAM_PLAYBACK)
+ if (snd_pcm_is_playback(stream))
fp->ep_attr |= USB_ENDPOINT_SYNC_ADAPTIVE;
else
fp->ep_attr |= USB_ENDPOINT_SYNC_SYNC;
@@ -2036,7 +2036,7 @@ void snd_usb_audioformat_attributes_quirk(struct snd_usb_audio *chip,
break;
case USB_ID(0x3511, 0x2b1e): /* Opencomm2 UC USB Bluetooth dongle */
/* mic works only when ep pitch control is not set */
- if (stream == SNDRV_PCM_STREAM_CAPTURE)
+ if (snd_pcm_is_capture(stream))
fp->attributes &= ~UAC_EP_CS_ATTR_PITCH_CONTROL;
break;
}
@@ -524,8 +524,8 @@ static int __snd_usb_add_audio_stream(struct snd_usb_audio *chip,
as->chip = chip;
as->fmt_type = fp->fmt_type;
err = snd_pcm_new(chip->card, "USB Audio", chip->pcm_devs,
- stream == SNDRV_PCM_STREAM_PLAYBACK ? 1 : 0,
- stream == SNDRV_PCM_STREAM_PLAYBACK ? 0 : 1,
+ snd_pcm_is_playback(stream),
+ !snd_pcm_is_playback(stream),
&pcm);
if (err < 0) {
kfree(as);
@@ -1058,7 +1058,7 @@ snd_usb_get_audioformat_uac3(struct snd_usb_audio *chip,
audioformat_free(fp);
return NULL;
}
- pd->pd_id = (stream == SNDRV_PCM_STREAM_PLAYBACK) ?
+ pd->pd_id = snd_pcm_is_playback(stream) ?
UAC3_BADD_PD_ID10 : UAC3_BADD_PD_ID11;
pd->pd_d1d0_rec = UAC3_BADD_PD_RECOVER_D1D0;
pd->pd_d2d0_rec = UAC3_BADD_PD_RECOVER_D2D0;
@@ -816,7 +816,7 @@ static int snd_usx2y_pcm_hw_free(struct snd_pcm_substream *substream)
mutex_lock(&subs->usx2y->pcm_mutex);
snd_printdd("snd_usx2y_hw_free(%p)\n", substream);
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+ if (snd_pcm_is_playback(substream)) {
cap_subs = subs->usx2y->subs[SNDRV_PCM_STREAM_CAPTURE];
atomic_set(&subs->state, STATE_STOPPED);
usx2y_urbs_release(subs);
@@ -368,7 +368,7 @@ static int snd_usx2y_usbpcm_hw_free(struct snd_pcm_substream *substream)
snd_printdd("%s(%p)\n", __func__, substream);
cap_subs2 = subs->usx2y->subs[SNDRV_PCM_STREAM_CAPTURE + 2];
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+ if (snd_pcm_is_playback(substream)) {
cap_subs = subs->usx2y->subs[SNDRV_PCM_STREAM_CAPTURE];
atomic_set(&subs->state, STATE_STOPPED);
usx2y_usbpcm_urbs_release(subs);
@@ -414,7 +414,7 @@ static int usx2y_usbpcm_urbs_start(struct snd_usx2y_substream *subs)
struct urb *urb;
unsigned long pack;
- if (stream == SNDRV_PCM_STREAM_CAPTURE) {
+ if (snd_pcm_is_capture(stream)) {
usx2y->hwdep_pcm_shm->captured_iso_head = -1;
usx2y->hwdep_pcm_shm->captured_iso_frames = 0;
}
@@ -592,7 +592,7 @@ static int snd_usx2y_usbpcm_open(struct snd_pcm_substream *substream)
if (!(subs->usx2y->chip_status & USX2Y_STAT_CHIP_MMAP_PCM_URBS))
return -EBUSY;
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+ if (snd_pcm_is_playback(substream))
runtime->hw = snd_usx2y_2c;
else
runtime->hw = (subs->usx2y->subs[3] ? snd_usx2y_4c : snd_usx2y_2c);
We can use snd_pcm_is_playback/capture(). Let's use it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> --- sound/usb/6fire/pcm.c | 8 ++++---- sound/usb/caiaq/audio.c | 14 +++++++------- sound/usb/hiface/pcm.c | 4 ++-- sound/usb/line6/pcm.c | 16 ++++++++-------- sound/usb/media.c | 2 +- sound/usb/pcm.c | 20 ++++++++++---------- sound/usb/quirks.c | 6 +++--- sound/usb/stream.c | 6 +++--- sound/usb/usx2y/usbusx2yaudio.c | 2 +- sound/usb/usx2y/usx2yhwdeppcm.c | 6 +++--- 10 files changed, 42 insertions(+), 42 deletions(-)