fix capture in non jack use
This commit is contained in:
parent
8b92eb2724
commit
a5f095d871
13
us144mkii.c
13
us144mkii.c
|
|
@ -263,10 +263,15 @@ void tascam_stop_work_handler(struct work_struct *work)
|
||||||
struct tascam_card *tascam =
|
struct tascam_card *tascam =
|
||||||
container_of(work, struct tascam_card, stop_work);
|
container_of(work, struct tascam_card, stop_work);
|
||||||
|
|
||||||
usb_kill_anchored_urbs(&tascam->playback_anchor);
|
if (!atomic_read(&tascam->playback_active)) {
|
||||||
usb_kill_anchored_urbs(&tascam->feedback_anchor);
|
usb_kill_anchored_urbs(&tascam->playback_anchor);
|
||||||
usb_kill_anchored_urbs(&tascam->capture_anchor);
|
usb_kill_anchored_urbs(&tascam->feedback_anchor);
|
||||||
atomic_set(&tascam->active_urbs, 0);
|
}
|
||||||
|
if (!atomic_read(&tascam->capture_active))
|
||||||
|
usb_kill_anchored_urbs(&tascam->capture_anchor);
|
||||||
|
|
||||||
|
if (!atomic_read(&tascam->playback_active) && !atomic_read(&tascam->capture_active))
|
||||||
|
atomic_set(&tascam->active_urbs, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
143
us144mkii_pcm.c
143
us144mkii_pcm.c
|
|
@ -282,97 +282,74 @@ int tascam_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
|
||||||
struct tascam_card *tascam = snd_pcm_substream_chip(substream);
|
struct tascam_card *tascam = snd_pcm_substream_chip(substream);
|
||||||
int err = 0;
|
int err = 0;
|
||||||
int i;
|
int i;
|
||||||
bool do_start = false;
|
|
||||||
bool do_stop = false;
|
|
||||||
|
|
||||||
scoped_guard(spinlock_irqsave, &tascam->lock) {
|
switch (cmd) {
|
||||||
switch (cmd) {
|
case SNDRV_PCM_TRIGGER_START:
|
||||||
case SNDRV_PCM_TRIGGER_START:
|
case SNDRV_PCM_TRIGGER_RESUME:
|
||||||
case SNDRV_PCM_TRIGGER_RESUME:
|
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
|
||||||
if (!atomic_read(&tascam->playback_active)) {
|
if (atomic_xchg(&tascam->playback_active, 1) == 0) {
|
||||||
atomic_set(&tascam->playback_active, 1);
|
for (i = 0; i < NUM_PLAYBACK_URBS; i++) {
|
||||||
atomic_set(&tascam->capture_active, 1);
|
usb_get_urb(tascam->playback_urbs[i]);
|
||||||
do_start = true;
|
usb_anchor_urb(tascam->playback_urbs[i], &tascam->playback_anchor);
|
||||||
|
err = usb_submit_urb(tascam->playback_urbs[i], GFP_ATOMIC);
|
||||||
|
if (err < 0) {
|
||||||
|
usb_unanchor_urb(tascam->playback_urbs[i]);
|
||||||
|
usb_put_urb(tascam->playback_urbs[i]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
atomic_inc(&tascam->active_urbs);
|
||||||
|
}
|
||||||
|
for (i = 0; i < NUM_FEEDBACK_URBS; i++) {
|
||||||
|
usb_get_urb(tascam->feedback_urbs[i]);
|
||||||
|
usb_anchor_urb(tascam->feedback_urbs[i],
|
||||||
|
&tascam->feedback_anchor);
|
||||||
|
err = usb_submit_urb(tascam->feedback_urbs[i],
|
||||||
|
GFP_ATOMIC);
|
||||||
|
if (err < 0) {
|
||||||
|
usb_unanchor_urb(tascam->feedback_urbs[i]);
|
||||||
|
usb_put_urb(tascam->feedback_urbs[i]);
|
||||||
|
atomic_dec(&tascam->active_urbs);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
atomic_inc(&tascam->active_urbs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
} else {
|
||||||
case SNDRV_PCM_TRIGGER_STOP:
|
if (atomic_xchg(&tascam->capture_active, 1) == 0) {
|
||||||
case SNDRV_PCM_TRIGGER_SUSPEND:
|
for (i = 0; i < NUM_CAPTURE_URBS; i++) {
|
||||||
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
|
usb_get_urb(tascam->capture_urbs[i]);
|
||||||
if (atomic_read(&tascam->playback_active)) {
|
usb_anchor_urb(tascam->capture_urbs[i], &tascam->capture_anchor);
|
||||||
atomic_set(&tascam->playback_active, 0);
|
err = usb_submit_urb(tascam->capture_urbs[i], GFP_ATOMIC);
|
||||||
atomic_set(&tascam->capture_active, 0);
|
if (err < 0) {
|
||||||
do_stop = true;
|
usb_unanchor_urb(tascam->capture_urbs[i]);
|
||||||
|
usb_put_urb(tascam->capture_urbs[i]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
atomic_inc(&tascam->active_urbs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
default:
|
|
||||||
err = -EINVAL;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case SNDRV_PCM_TRIGGER_STOP:
|
||||||
|
case SNDRV_PCM_TRIGGER_SUSPEND:
|
||||||
|
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
|
||||||
|
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
|
||||||
|
if (atomic_xchg(&tascam->playback_active, 0) == 1) {
|
||||||
|
schedule_work(&tascam->stop_work);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (atomic_xchg(&tascam->capture_active, 0) == 1) {
|
||||||
|
schedule_work(&tascam->stop_work);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
err = -EINVAL;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (do_start) {
|
|
||||||
if (atomic_read(&tascam->active_urbs) > 0) {
|
|
||||||
dev_warn(tascam->card->dev,
|
|
||||||
"Cannot start, URBs still active.\n");
|
|
||||||
return -EAGAIN;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < NUM_FEEDBACK_URBS; i++) {
|
|
||||||
usb_get_urb(tascam->feedback_urbs[i]);
|
|
||||||
usb_anchor_urb(tascam->feedback_urbs[i],
|
|
||||||
&tascam->feedback_anchor);
|
|
||||||
err = usb_submit_urb(tascam->feedback_urbs[i],
|
|
||||||
GFP_ATOMIC);
|
|
||||||
if (err < 0) {
|
|
||||||
usb_unanchor_urb(tascam->feedback_urbs[i]);
|
|
||||||
usb_put_urb(tascam->feedback_urbs[i]);
|
|
||||||
atomic_dec(&tascam->active_urbs);
|
|
||||||
goto start_rollback;
|
|
||||||
}
|
|
||||||
atomic_inc(&tascam->active_urbs);
|
|
||||||
}
|
|
||||||
for (i = 0; i < NUM_PLAYBACK_URBS; i++) {
|
|
||||||
usb_get_urb(tascam->playback_urbs[i]);
|
|
||||||
usb_anchor_urb(tascam->playback_urbs[i],
|
|
||||||
&tascam->playback_anchor);
|
|
||||||
err = usb_submit_urb(tascam->playback_urbs[i],
|
|
||||||
GFP_ATOMIC);
|
|
||||||
if (err < 0) {
|
|
||||||
usb_unanchor_urb(tascam->playback_urbs[i]);
|
|
||||||
usb_put_urb(tascam->playback_urbs[i]);
|
|
||||||
atomic_dec(&tascam->active_urbs);
|
|
||||||
goto start_rollback;
|
|
||||||
}
|
|
||||||
atomic_inc(&tascam->active_urbs);
|
|
||||||
}
|
|
||||||
for (i = 0; i < NUM_CAPTURE_URBS; i++) {
|
|
||||||
usb_get_urb(tascam->capture_urbs[i]);
|
|
||||||
usb_anchor_urb(tascam->capture_urbs[i],
|
|
||||||
&tascam->capture_anchor);
|
|
||||||
err = usb_submit_urb(tascam->capture_urbs[i],
|
|
||||||
GFP_ATOMIC);
|
|
||||||
if (err < 0) {
|
|
||||||
usb_unanchor_urb(tascam->capture_urbs[i]);
|
|
||||||
usb_put_urb(tascam->capture_urbs[i]);
|
|
||||||
atomic_dec(&tascam->active_urbs);
|
|
||||||
goto start_rollback;
|
|
||||||
}
|
|
||||||
atomic_inc(&tascam->active_urbs);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
start_rollback:
|
|
||||||
dev_err(tascam->card->dev,
|
|
||||||
"Failed to submit URBs to start stream: %d\n", err);
|
|
||||||
do_stop = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (do_stop)
|
|
||||||
schedule_work(&tascam->stop_work);
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tascam_init_pcm(struct snd_pcm *pcm)
|
int tascam_init_pcm(struct snd_pcm *pcm)
|
||||||
{
|
{
|
||||||
struct tascam_card *tascam = pcm->private_data;
|
struct tascam_card *tascam = pcm->private_data;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue