summaryrefslogtreecommitdiff
path: root/sound/usb/usx2y/usb_stream.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/usb/usx2y/usb_stream.c')
-rw-r--r--sound/usb/usx2y/usb_stream.c95
1 files changed, 44 insertions, 51 deletions
diff --git a/sound/usb/usx2y/usb_stream.c b/sound/usb/usx2y/usb_stream.c
index a4d32e8a1d36..3122cf653273 100644
--- a/sound/usb/usx2y/usb_stream.c
+++ b/sound/usb/usx2y/usb_stream.c
@@ -34,14 +34,11 @@ static void playback_prep_freqn(struct usb_stream_kernel *sk, struct urb *urb)
urb->iso_frame_desc[pack].length = l;
lb += l;
}
- snd_printdd(KERN_DEBUG "%i\n", lb);
check:
urb->number_of_packets = pack;
urb->transfer_buffer_length = lb;
s->idle_outsize += lb - s->period_size;
- snd_printdd(KERN_DEBUG "idle=%i ul=%i ps=%i\n", s->idle_outsize,
- lb, s->period_size);
}
static int init_pipe_urbs(struct usb_stream_kernel *sk,
@@ -191,14 +188,14 @@ struct usb_stream *usb_stream_new(struct usb_stream_kernel *sk,
write_size = max_packsize * packets * USB_STREAM_URBDEPTH;
if (read_size >= 256*PAGE_SIZE || write_size >= 256*PAGE_SIZE) {
- snd_printk(KERN_WARNING "a size exceeds 128*PAGE_SIZE\n");
+ dev_warn(&dev->dev, "%s: a size exceeds 128*PAGE_SIZE\n", __func__);
goto out;
}
sk->s = alloc_pages_exact(read_size,
GFP_KERNEL | __GFP_ZERO | __GFP_NOWARN);
if (!sk->s) {
- pr_warn("us122l: couldn't allocate read buffer\n");
+ dev_warn(&dev->dev, "us122l: couldn't allocate read buffer\n");
goto out;
}
sk->s->cfg.version = USB_STREAM_INTERFACE_VERSION;
@@ -217,7 +214,7 @@ struct usb_stream *usb_stream_new(struct usb_stream_kernel *sk,
sk->write_page = alloc_pages_exact(write_size,
GFP_KERNEL | __GFP_ZERO | __GFP_NOWARN);
if (!sk->write_page) {
- pr_warn("us122l: couldn't allocate write buffer\n");
+ dev_warn(&dev->dev, "us122l: couldn't allocate write buffer\n");
usb_stream_free(sk);
return NULL;
}
@@ -246,7 +243,8 @@ static bool balance_check(struct usb_stream_kernel *sk, struct urb *urb)
if (unlikely(urb->status)) {
if (urb->status != -ESHUTDOWN && urb->status != -ENOENT)
- snd_printk(KERN_WARNING "status=%i\n", urb->status);
+ dev_warn(&sk->dev->dev, "%s: status=%i\n", __func__,
+ urb->status);
sk->iso_frame_balance = 0x7FFFFFFF;
return false;
}
@@ -318,17 +316,18 @@ static int usb_stream_prepare_playback(struct usb_stream_kernel *sk,
check_ok:
s->sync_packet -= inurb->number_of_packets;
if (unlikely(s->sync_packet < -2 || s->sync_packet > 0)) {
- snd_printk(KERN_WARNING "invalid sync_packet = %i;"
- " p=%i nop=%i %i %x %x %x > %x\n",
- s->sync_packet, p, inurb->number_of_packets,
- s->idle_outsize + lb + l,
- s->idle_outsize, lb, l,
- s->period_size);
+ dev_warn(&sk->dev->dev,
+ "%s: invalid sync_packet = %i; p=%i nop=%i %i %x %x %x > %x\n",
+ __func__,
+ s->sync_packet, p, inurb->number_of_packets,
+ s->idle_outsize + lb + l,
+ s->idle_outsize, lb, l,
+ s->period_size);
return -1;
}
if (unlikely(lb % s->cfg.frame_size)) {
- snd_printk(KERN_WARNING"invalid outsize = %i\n",
- lb);
+ dev_warn(&sk->dev->dev, "%s: invalid outsize = %i\n",
+ __func__, lb);
return -1;
}
s->idle_outsize += lb - s->period_size;
@@ -337,7 +336,7 @@ check_ok:
if (s->idle_outsize <= 0)
return 0;
- snd_printk(KERN_WARNING "idle=%i\n", s->idle_outsize);
+ dev_warn(&sk->dev->dev, "%s: idle=%i\n", __func__, s->idle_outsize);
return -1;
}
@@ -377,7 +376,7 @@ static int submit_urbs(struct usb_stream_kernel *sk,
return 0;
report_failure:
- snd_printk(KERN_ERR "%i\n", err);
+ dev_err(&sk->dev->dev, "%s error: %i\n", __func__, err);
return err;
}
@@ -424,8 +423,8 @@ loop:
}
if (iu == sk->completed_inurb) {
if (l != s->period_size)
- printk(KERN_DEBUG"%s:%i %i\n", __func__, __LINE__,
- l/(int)s->cfg.frame_size);
+ dev_dbg(&sk->dev->dev, "%s:%i %i\n", __func__, __LINE__,
+ l/(int)s->cfg.frame_size);
return;
}
@@ -460,8 +459,8 @@ static void stream_idle(struct usb_stream_kernel *sk,
l = id[p].actual_length;
if (unlikely(l == 0 || id[p].status)) {
- snd_printk(KERN_WARNING "underrun, status=%u\n",
- id[p].status);
+ dev_warn(&sk->dev->dev, "%s: underrun, status=%u\n",
+ __func__, id[p].status);
goto err_out;
}
s->inpacket_head++;
@@ -482,8 +481,8 @@ static void stream_idle(struct usb_stream_kernel *sk,
}
s->idle_insize += urb_size - s->period_size;
if (s->idle_insize < 0) {
- snd_printk(KERN_WARNING "%i\n",
- (s->idle_insize)/(int)s->cfg.frame_size);
+ dev_warn(&sk->dev->dev, "%s error: %i\n", __func__,
+ (s->idle_insize)/(int)s->cfg.frame_size);
goto err_out;
}
s->insize_done += urb_size;
@@ -558,19 +557,15 @@ static void stream_start(struct usb_stream_kernel *sk,
min_frames += frames_per_packet;
diff = urb_size -
(min_frames >> 8) * s->cfg.frame_size;
- if (diff < max_diff) {
- snd_printdd(KERN_DEBUG "%i %i %i %i\n",
- s->insize_done,
- urb_size / (int)s->cfg.frame_size,
- inurb->number_of_packets, diff);
+ if (diff < max_diff)
max_diff = diff;
- }
}
s->idle_insize -= max_diff - max_diff_0;
s->idle_insize += urb_size - s->period_size;
if (s->idle_insize < 0) {
- snd_printk(KERN_WARNING "%i %i %i\n",
- s->idle_insize, urb_size, s->period_size);
+ dev_warn(&sk->dev->dev, "%s idle_insize: %i %i %i\n",
+ __func__,
+ s->idle_insize, urb_size, s->period_size);
return;
} else if (s->idle_insize == 0) {
s->next_inpacket_split =
@@ -620,7 +615,7 @@ static void i_capture_start(struct urb *urb)
int empty = 0;
if (urb->status) {
- snd_printk(KERN_WARNING "status=%i\n", urb->status);
+ dev_warn(&sk->dev->dev, "%s: status=%i\n", __func__, urb->status);
return;
}
@@ -630,7 +625,7 @@ static void i_capture_start(struct urb *urb)
if (l < s->cfg.frame_size) {
++empty;
if (s->state >= usb_stream_sync0) {
- snd_printk(KERN_WARNING "%i\n", l);
+ dev_warn(&sk->dev->dev, "%s: length %i\n", __func__, l);
return;
}
}
@@ -642,8 +637,8 @@ static void i_capture_start(struct urb *urb)
}
#ifdef SHOW_EMPTY
if (empty) {
- printk(KERN_DEBUG"%s:%i: %i", __func__, __LINE__,
- urb->iso_frame_desc[0].actual_length);
+ dev_dbg(&sk->dev->dev, "%s:%i: %i", __func__, __LINE__,
+ urb->iso_frame_desc[0].actual_length);
for (pack = 1; pack < urb->number_of_packets; ++pack) {
int l = urb->iso_frame_desc[pack].actual_length;
@@ -670,7 +665,7 @@ static void i_playback_start(struct urb *urb)
int usb_stream_start(struct usb_stream_kernel *sk)
{
struct usb_stream *s = sk->s;
- int frame = 0, iters = 0;
+ int frame = 0;
int u, err;
int try = 0;
@@ -705,43 +700,42 @@ dotry:
frame = usb_get_current_frame_number(dev);
do {
now = usb_get_current_frame_number(dev);
- ++iters;
} while (now > -1 && now == frame);
}
err = usb_submit_urb(inurb, GFP_ATOMIC);
if (err < 0) {
- snd_printk(KERN_ERR
- "usb_submit_urb(sk->inurb[%i]) returned %i\n",
- u, err);
+ dev_err(&sk->dev->dev,
+ "%s: usb_submit_urb(sk->inurb[%i]) returned %i\n",
+ __func__, u, err);
return err;
}
err = usb_submit_urb(outurb, GFP_ATOMIC);
if (err < 0) {
- snd_printk(KERN_ERR
- "usb_submit_urb(sk->outurb[%i]) returned %i\n",
- u, err);
+ dev_err(&sk->dev->dev,
+ "%s: usb_submit_urb(sk->outurb[%i]) returned %i\n",
+ __func__, u, err);
return err;
}
if (inurb->start_frame != outurb->start_frame) {
- snd_printd(KERN_DEBUG
- "u[%i] start_frames differ in:%u out:%u\n",
- u, inurb->start_frame, outurb->start_frame);
+ dev_dbg(&sk->dev->dev,
+ "%s: u[%i] start_frames differ in:%u out:%u\n",
+ __func__, u, inurb->start_frame, outurb->start_frame);
goto check_retry;
}
}
- snd_printdd(KERN_DEBUG "%i %i\n", frame, iters);
try = 0;
check_retry:
if (try) {
usb_stream_stop(sk);
if (try < 5) {
msleep(1500);
- snd_printd(KERN_DEBUG "goto dotry;\n");
+ dev_dbg(&sk->dev->dev, "goto dotry;\n");
goto dotry;
}
- snd_printk(KERN_WARNING
- "couldn't start all urbs on the same start_frame.\n");
+ dev_warn(&sk->dev->dev,
+ "%s: couldn't start all urbs on the same start_frame.\n",
+ __func__);
return -EFAULT;
}
@@ -755,7 +749,6 @@ check_retry:
int wait_ms = 3000;
while (s->state != usb_stream_ready && wait_ms > 0) {
- snd_printdd(KERN_DEBUG "%i\n", s->state);
msleep(200);
wait_ms -= 200;
}