All of lore.kernel.org
 help / color / mirror / Atom feed
* Cleanup patches for snd-usb-caiaq
@ 2009-03-18 10:03 Daniel Mack
  2009-03-18 10:03 ` [PATCH 1/3] snd-usb-caiaq: only warn once on streaming errors Daniel Mack
  2009-03-18 10:34 ` Cleanup patches for snd-usb-caiaq Takashi Iwai
  0 siblings, 2 replies; 5+ messages in thread
From: Daniel Mack @ 2009-03-18 10:03 UTC (permalink / raw)
  To: alsa-devel

Following up to this mail are 3 patches to clean up the snd-usb-caiaq
driver.

[PATCH 1/3] snd-usb-caiaq: only warn once on streaming errors
[PATCH 2/3] snd-usb-caiaq: drop bogus iso packets
[PATCH 3/3] snd-usb-caiaq: bump version number

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] snd-usb-caiaq: only warn once on streaming errors
  2009-03-18 10:03 Cleanup patches for snd-usb-caiaq Daniel Mack
@ 2009-03-18 10:03 ` Daniel Mack
  2009-03-18 10:03   ` [PATCH 2/3] snd-usb-caiaq: drop bogus iso packets Daniel Mack
  2009-03-18 10:34 ` Cleanup patches for snd-usb-caiaq Takashi Iwai
  1 sibling, 1 reply; 5+ messages in thread
From: Daniel Mack @ 2009-03-18 10:03 UTC (permalink / raw)
  To: alsa-devel

Limit the number of printed warnings to one in case of streaming errors.
printk() happens to be expensive, especially in code called as often as
here.

Signed-off-by: Daniel Mack <daniel@caiaq.de>
---
 sound/usb/caiaq/caiaq-audio.c  |    4 +++-
 sound/usb/caiaq/caiaq-device.h |    2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/sound/usb/caiaq/caiaq-audio.c b/sound/usb/caiaq/caiaq-audio.c
index fc6d571..577b112 100644
--- a/sound/usb/caiaq/caiaq-audio.c
+++ b/sound/usb/caiaq/caiaq-audio.c
@@ -114,6 +114,7 @@ static int stream_start(struct snd_usb_caiaqdev *dev)
 	dev->output_panic = 0;
 	dev->first_packet = 1;
 	dev->streaming = 1;
+	dev->warned = 0;
 
 	for (i = 0; i < N_URBS; i++) {
 		ret = usb_submit_urb(dev->data_urbs_in[i], GFP_ATOMIC);
@@ -406,10 +407,11 @@ static void read_in_urb(struct snd_usb_caiaqdev *dev,
 		break;
 	}
 
-	if (dev->input_panic || dev->output_panic) {
+	if ((dev->input_panic || dev->output_panic) && !dev->warned) {
 		debug("streaming error detected %s %s\n", 
 				dev->input_panic ? "(input)" : "",
 				dev->output_panic ? "(output)" : "");
+		dev->warned = 1;
 	}
 }
 
diff --git a/sound/usb/caiaq/caiaq-device.h b/sound/usb/caiaq/caiaq-device.h
index 3edd94d..4aa8631 100644
--- a/sound/usb/caiaq/caiaq-device.h
+++ b/sound/usb/caiaq/caiaq-device.h
@@ -90,7 +90,7 @@ struct snd_usb_caiaqdev {
 	int audio_out_buf_pos[MAX_STREAMS];
 	int period_in_count[MAX_STREAMS];
 	int period_out_count[MAX_STREAMS];
-	int input_panic, output_panic;
+	int input_panic, output_panic, warned;
 	char *audio_in_buf, *audio_out_buf;
 	unsigned int samplerates;
 
-- 
1.6.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] snd-usb-caiaq: drop bogus iso packets
  2009-03-18 10:03 ` [PATCH 1/3] snd-usb-caiaq: only warn once on streaming errors Daniel Mack
@ 2009-03-18 10:03   ` Daniel Mack
  2009-03-18 10:03     ` [PATCH 3/3] snd-usb-caiaq: bump version number Daniel Mack
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Mack @ 2009-03-18 10:03 UTC (permalink / raw)
  To: alsa-devel

Drop inbound packets that are smaller than expected. This has been
observed at the very beginning of the streaming transaction.

And when the hardware is in panic mode (which can only very rarely
happen in case of massive EMI chaos), mute the input channels.

Signed-off-by: Daniel Mack <daniel@caiaq.de>
Tested-by: Mark Hills <mark@pogo.org.uk>
---
 sound/usb/caiaq/caiaq-audio.c  |    6 ++++++
 sound/usb/caiaq/caiaq-device.c |    2 ++
 sound/usb/caiaq/caiaq-device.h |    2 +-
 3 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/sound/usb/caiaq/caiaq-audio.c b/sound/usb/caiaq/caiaq-audio.c
index 577b112..08d51e0 100644
--- a/sound/usb/caiaq/caiaq-audio.c
+++ b/sound/usb/caiaq/caiaq-audio.c
@@ -377,6 +377,9 @@ static void read_in_urb_mode2(struct snd_usb_caiaqdev *dev,
 
 		for (stream = 0; stream < dev->n_streams; stream++, i++) {
 			sub = dev->sub_capture[stream];
+			if (dev->input_panic)
+				usb_buf[i] = 0;
+
 			if (sub) {
 				struct snd_pcm_runtime *rt = sub->runtime;
 				char *audio_buf = rt->dma_area;
@@ -398,6 +401,9 @@ static void read_in_urb(struct snd_usb_caiaqdev *dev,
 	if (!dev->streaming)
 		return;
 
+	if (iso->actual_length < dev->bpp)
+		return;
+
 	switch (dev->spec.data_alignment) {
 	case 0:
 		read_in_urb_mode0(dev, urb, iso);
diff --git a/sound/usb/caiaq/caiaq-device.c b/sound/usb/caiaq/caiaq-device.c
index 5cf841e..8af47c2 100644
--- a/sound/usb/caiaq/caiaq-device.c
+++ b/sound/usb/caiaq/caiaq-device.c
@@ -251,6 +251,8 @@ int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev,
 		
 	if (dev->audio_parm_answer != 1) 
 		debug("unable to set the device's audio params\n");
+	else
+		dev->bpp = bpp;
 
 	return dev->audio_parm_answer == 1 ? 0 : -EINVAL;
 }
diff --git a/sound/usb/caiaq/caiaq-device.h b/sound/usb/caiaq/caiaq-device.h
index 4aa8631..1a2a21d 100644
--- a/sound/usb/caiaq/caiaq-device.h
+++ b/sound/usb/caiaq/caiaq-device.h
@@ -92,7 +92,7 @@ struct snd_usb_caiaqdev {
 	int period_out_count[MAX_STREAMS];
 	int input_panic, output_panic, warned;
 	char *audio_in_buf, *audio_out_buf;
-	unsigned int samplerates;
+	unsigned int samplerates, bpp;
 
 	struct snd_pcm_substream *sub_playback[MAX_STREAMS];
 	struct snd_pcm_substream *sub_capture[MAX_STREAMS];
-- 
1.6.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] snd-usb-caiaq: bump version number
  2009-03-18 10:03   ` [PATCH 2/3] snd-usb-caiaq: drop bogus iso packets Daniel Mack
@ 2009-03-18 10:03     ` Daniel Mack
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Mack @ 2009-03-18 10:03 UTC (permalink / raw)
  To: alsa-devel


Signed-off-by: Daniel Mack <daniel@caiaq.de>
---
 sound/usb/caiaq/caiaq-device.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/sound/usb/caiaq/caiaq-device.c b/sound/usb/caiaq/caiaq-device.c
index 8af47c2..cf573a9 100644
--- a/sound/usb/caiaq/caiaq-device.c
+++ b/sound/usb/caiaq/caiaq-device.c
@@ -42,7 +42,7 @@
 #endif
 
 MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>");
-MODULE_DESCRIPTION("caiaq USB audio, version 1.3.12");
+MODULE_DESCRIPTION("caiaq USB audio, version 1.3.13");
 MODULE_LICENSE("GPL");
 MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2},"
 			 "{Native Instruments, RigKontrol3},"
-- 
1.6.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: Cleanup patches for snd-usb-caiaq
  2009-03-18 10:03 Cleanup patches for snd-usb-caiaq Daniel Mack
  2009-03-18 10:03 ` [PATCH 1/3] snd-usb-caiaq: only warn once on streaming errors Daniel Mack
@ 2009-03-18 10:34 ` Takashi Iwai
  1 sibling, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2009-03-18 10:34 UTC (permalink / raw)
  To: Daniel Mack; +Cc: alsa-devel

At Wed, 18 Mar 2009 11:03:52 +0100,
Daniel Mack wrote:
> 
> Following up to this mail are 3 patches to clean up the snd-usb-caiaq
> driver.
> 
> [PATCH 1/3] snd-usb-caiaq: only warn once on streaming errors
> [PATCH 2/3] snd-usb-caiaq: drop bogus iso packets
> [PATCH 3/3] snd-usb-caiaq: bump version number

All look good and are applied now.  Thanks!


Takashi

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-03-18 10:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-18 10:03 Cleanup patches for snd-usb-caiaq Daniel Mack
2009-03-18 10:03 ` [PATCH 1/3] snd-usb-caiaq: only warn once on streaming errors Daniel Mack
2009-03-18 10:03   ` [PATCH 2/3] snd-usb-caiaq: drop bogus iso packets Daniel Mack
2009-03-18 10:03     ` [PATCH 3/3] snd-usb-caiaq: bump version number Daniel Mack
2009-03-18 10:34 ` Cleanup patches for snd-usb-caiaq Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.