From 2f8e6c790e74ada20db6965056476d944041fdfa Mon Sep 17 00:00:00 2001 From: Douglas Schilling Landgraf Date: Sun, 8 Feb 2009 11:45:34 -0200 Subject: em28xx: remove bad check (changeset a31c595188af) From: Douglas Schilling Landgraf Removed bad check. Thanks to Robert Krakora to report that. Priority: high Signed-off-by: Douglas Schilling Landgraf --- linux/drivers/media/video/em28xx/em28xx-audio.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'linux/drivers/media/video/em28xx/em28xx-audio.c') diff --git a/linux/drivers/media/video/em28xx/em28xx-audio.c b/linux/drivers/media/video/em28xx/em28xx-audio.c index fcf21a614..ebbc64b3a 100644 --- a/linux/drivers/media/video/em28xx/em28xx-audio.c +++ b/linux/drivers/media/video/em28xx/em28xx-audio.c @@ -62,7 +62,7 @@ static int em28xx_isoc_audio_deinit(struct em28xx *dev) int i; dprintk("Stopping isoc\n"); - for (i = 0; i < dev->isoc_ctl.num_bufs; i++) { + for (i = 0; i < EM28XX_AUDIO_BUFS; i++) { if (!irqs_disabled()) usb_kill_urb(dev->adev.urb[i]); else @@ -74,7 +74,6 @@ static int em28xx_isoc_audio_deinit(struct em28xx *dev) dev->adev.transfer_buffer[i] = NULL; } - dev->isoc_ctl.num_bufs = 0; return 0; } @@ -179,8 +178,6 @@ static int em28xx_init_audio_isoc(struct em28xx *dev) dprintk("Starting isoc transfers\n"); - dev->isoc_ctl.num_bufs = 0; - for (i = 0; i < EM28XX_AUDIO_BUFS; i++) { struct urb *urb; int j, k; @@ -222,19 +219,10 @@ static int em28xx_init_audio_isoc(struct em28xx *dev) for (i = 0; i < EM28XX_AUDIO_BUFS; i++) { errCode = usb_submit_urb(dev->adev.urb[i], GFP_ATOMIC); if (errCode) { - if (dev->isoc_ctl.num_bufs == 0) { - usb_free_urb(dev->adev.urb[i]); - dev->adev.urb[i] = NULL; - kfree(dev->adev.transfer_buffer[i]); - dev->adev.transfer_buffer[i] = NULL; - } else - em28xx_isoc_audio_deinit(dev); + em28xx_isoc_audio_deinit(dev); return errCode; } - mutex_lock(&dev->lock); - dev->isoc_ctl.num_bufs++; - mutex_unlock(&dev->lock); } return 0; -- cgit v1.2.3 From 2bd11adc025f4c324d0eb2a9861bdf7589e3b74e Mon Sep 17 00:00:00 2001 From: Douglas Schilling Landgraf Date: Sun, 8 Feb 2009 14:09:11 -0200 Subject: em28xx: Fix for em28xx memory leak and function rename From: Robert Krakora Fix for em28xx memory leak and function rename Priority: high Signed-off-by: Robert Krakora Signed-off-by: Douglas Schilling Landgraf --- linux/drivers/media/video/em28xx/em28xx-audio.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'linux/drivers/media/video/em28xx/em28xx-audio.c') diff --git a/linux/drivers/media/video/em28xx/em28xx-audio.c b/linux/drivers/media/video/em28xx/em28xx-audio.c index ebbc64b3a..8753398b0 100644 --- a/linux/drivers/media/video/em28xx/em28xx-audio.c +++ b/linux/drivers/media/video/em28xx/em28xx-audio.c @@ -57,7 +57,7 @@ MODULE_PARM_DESC(debug, "activates debug info"); static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; -static int em28xx_isoc_audio_deinit(struct em28xx *dev) +static int em28xx_deinit_isoc_audio(struct em28xx *dev) { int i; @@ -67,6 +67,7 @@ static int em28xx_isoc_audio_deinit(struct em28xx *dev) usb_kill_urb(dev->adev.urb[i]); else usb_unlink_urb(dev->adev.urb[i]); + usb_free_urb(dev->adev.urb[i]); dev->adev.urb[i] = NULL; @@ -100,6 +101,20 @@ static void em28xx_audio_isocirq(struct urb *urb) struct snd_pcm_substream *substream; struct snd_pcm_runtime *runtime; #endif + + switch (urb->status) { + case 0: /* success */ + case -ETIMEDOUT: /* NAK */ + break; + case -ECONNRESET: /* kill */ + case -ENOENT: + case -ESHUTDOWN: + return; + default: /* error */ + dprintk("urb completition error %d.\n", urb->status); + break; + } + if (dev->adev.capture_pcm_substream) { substream = dev->adev.capture_pcm_substream; runtime = substream->runtime; @@ -219,8 +234,7 @@ static int em28xx_init_audio_isoc(struct em28xx *dev) for (i = 0; i < EM28XX_AUDIO_BUFS; i++) { errCode = usb_submit_urb(dev->adev.urb[i], GFP_ATOMIC); if (errCode) { - em28xx_isoc_audio_deinit(dev); - + em28xx_deinit_isoc_audio(dev); return errCode; } } @@ -240,7 +254,7 @@ static int em28xx_cmd(struct em28xx *dev, int cmd, int arg) em28xx_init_audio_isoc(dev); } else if (dev->adev.capture_stream == STREAM_ON && arg == 0) { dev->adev.capture_stream = STREAM_OFF; - em28xx_isoc_audio_deinit(dev); + em28xx_deinit_isoc_audio(dev); } else { printk(KERN_ERR "An underrun very likely occurred. " "Ignoring it.\n"); -- cgit v1.2.3 From 96f4a3677c2e17fe91f9956779fad977ec6a8f8c Mon Sep 17 00:00:00 2001 From: Douglas Schilling Landgraf Date: Sun, 8 Feb 2009 14:10:39 -0200 Subject: em28xx: Fix for em28xx audio startup From: Robert Krakora Essentially if a snd_em28xx_capture_trigger() stop followed by a snd_em28xx_capture_trigger() start would not yield any data because there was some logic put in with an adev->shutdown variable which did not seem warranted in my humble opinion. It would cause snd_em28xx_capture_trigger start never to start up the audio stream until the device was closed and reopened again. Upon re-opening the device adev->shutdown is reset and audio data would again flow. Priority: high Signed-off-by: Robert Krakora Signed-off-by: Douglas Schilling Landgraf --- linux/drivers/media/video/em28xx/em28xx-audio.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'linux/drivers/media/video/em28xx/em28xx-audio.c') diff --git a/linux/drivers/media/video/em28xx/em28xx-audio.c b/linux/drivers/media/video/em28xx/em28xx-audio.c index 8753398b0..921ec190d 100644 --- a/linux/drivers/media/video/em28xx/em28xx-audio.c +++ b/linux/drivers/media/video/em28xx/em28xx-audio.c @@ -174,9 +174,6 @@ static void em28xx_audio_isocirq(struct urb *urb) } urb->status = 0; - if (dev->adev.shutdown) - return; - status = usb_submit_urb(urb, GFP_ATOMIC); if (status < 0) { em28xx_errdev("resubmit of audio urb failed (error=%i)\n", @@ -387,13 +384,6 @@ static int snd_em28xx_pcm_close(struct snd_pcm_substream *substream) em28xx_audio_analog_set(dev); mutex_unlock(&dev->lock); - if (dev->adev.users == 0 && dev->adev.shutdown == 1) { - dprintk("audio users: %d\n", dev->adev.users); - dprintk("disabling audio stream!\n"); - dev->adev.shutdown = 0; - dprintk("released lock\n"); - em28xx_cmd(dev, EM28XX_CAPTURE_STREAM_EN, 0); - } return 0; } @@ -463,7 +453,7 @@ static int snd_em28xx_capture_trigger(struct snd_pcm_substream *substream, em28xx_cmd(dev, EM28XX_CAPTURE_STREAM_EN, 1); return 0; case SNDRV_PCM_TRIGGER_STOP: - dev->adev.shutdown = 1; + em28xx_cmd(dev, EM28XX_CAPTURE_STREAM_EN, 0); return 0; default: return -EINVAL; -- cgit v1.2.3 From c06f528a6de5324f104965c8a90907211963e29e Mon Sep 17 00:00:00 2001 From: Douglas Schilling Landgraf Date: Sun, 8 Feb 2009 15:17:15 -0200 Subject: em28xx-audio: Add spinlock for trigger From: Douglas Schilling Landgraf Added spinlock for trigger session Priority: high Signed-off-by: Douglas Schilling Landgraf --- linux/drivers/media/video/em28xx/em28xx-audio.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'linux/drivers/media/video/em28xx/em28xx-audio.c') diff --git a/linux/drivers/media/video/em28xx/em28xx-audio.c b/linux/drivers/media/video/em28xx/em28xx-audio.c index 921ec190d..a5a28eb19 100644 --- a/linux/drivers/media/video/em28xx/em28xx-audio.c +++ b/linux/drivers/media/video/em28xx/em28xx-audio.c @@ -445,19 +445,27 @@ static int snd_em28xx_capture_trigger(struct snd_pcm_substream *substream, #endif { struct em28xx *dev = snd_pcm_substream_chip(substream); + int retval; dprintk("Should %s capture\n", (cmd == SNDRV_PCM_TRIGGER_START)? "start": "stop"); + + spin_lock(&dev->adev.slock); switch (cmd) { case SNDRV_PCM_TRIGGER_START: em28xx_cmd(dev, EM28XX_CAPTURE_STREAM_EN, 1); - return 0; + retval = 0; + break; case SNDRV_PCM_TRIGGER_STOP: em28xx_cmd(dev, EM28XX_CAPTURE_STREAM_EN, 0); - return 0; + retval = 0; + break; default: - return -EINVAL; + retval = -EINVAL; } + + spin_unlock(&dev->adev.slock); + return retval; } #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 16) -- cgit v1.2.3 From 88f9e29eb77d77129e59b899af1ef9e462997409 Mon Sep 17 00:00:00 2001 From: Douglas Schilling Landgraf Date: Sun, 8 Feb 2009 02:11:13 -0200 Subject: em28xx-audio: Add lock for users From: Douglas Schilling Landgraf Added lock for users count Priority: high Signed-off-by: Douglas Schilling Landgraf --- linux/drivers/media/video/em28xx/em28xx-audio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'linux/drivers/media/video/em28xx/em28xx-audio.c') diff --git a/linux/drivers/media/video/em28xx/em28xx-audio.c b/linux/drivers/media/video/em28xx/em28xx-audio.c index a5a28eb19..5102ff75f 100644 --- a/linux/drivers/media/video/em28xx/em28xx-audio.c +++ b/linux/drivers/media/video/em28xx/em28xx-audio.c @@ -356,7 +356,9 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream) dprintk("changing alternate number to 7\n"); } + mutex_lock(&dev->lock); dev->adev.users++; + mutex_unlock(&dev->lock); snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); dev->adev.capture_pcm_substream = substream; @@ -375,12 +377,12 @@ static int snd_em28xx_pcm_close(struct snd_pcm_substream *substream) #endif { struct em28xx *dev = snd_pcm_substream_chip(substream); - dev->adev.users--; dprintk("closing device\n"); dev->mute = 1; mutex_lock(&dev->lock); + dev->adev.users--; em28xx_audio_analog_set(dev); mutex_unlock(&dev->lock); -- cgit v1.2.3 From a24b83e8ea0f14b0f879c03a8d9547b6cb06e7e4 Mon Sep 17 00:00:00 2001 From: Douglas Schilling Landgraf Date: Sun, 8 Feb 2009 02:16:32 -0200 Subject: em28xx-audio: replace printk with em28xx_errdev From: Alexey Klimov Patch removes printk and place em28xx_errdev macros to provide information about driver name to dmesg. Priority: normal Signed-off-by: Alexey Klimov Signed-off-by: Douglas Schilling Landgraf --- linux/drivers/media/video/em28xx/em28xx-audio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'linux/drivers/media/video/em28xx/em28xx-audio.c') diff --git a/linux/drivers/media/video/em28xx/em28xx-audio.c b/linux/drivers/media/video/em28xx/em28xx-audio.c index 5102ff75f..1d665ba27 100644 --- a/linux/drivers/media/video/em28xx/em28xx-audio.c +++ b/linux/drivers/media/video/em28xx/em28xx-audio.c @@ -253,7 +253,7 @@ static int em28xx_cmd(struct em28xx *dev, int cmd, int arg) dev->adev.capture_stream = STREAM_OFF; em28xx_deinit_isoc_audio(dev); } else { - printk(KERN_ERR "An underrun very likely occurred. " + em28xx_errdev("An underrun very likely occurred. " "Ignoring it.\n"); } return 0; -- cgit v1.2.3 From 46b15827cbd9a9297b369049585c78e6e685aacd Mon Sep 17 00:00:00 2001 From: Douglas Schilling Landgraf Date: Sun, 8 Feb 2009 02:38:10 -0200 Subject: em28xx-audio: Add macros EM28XX_START_AUDIO / EM28XX_STOP_AUDIO From: Douglas Schilling Landgraf Added macros EM28XX_START_AUDIO and EM28XX_STOP_AUDIO for em28xx_cmd(). Priority: normal Signed-off-by: Douglas Schilling Landgraf --- linux/drivers/media/video/em28xx/em28xx-audio.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'linux/drivers/media/video/em28xx/em28xx-audio.c') diff --git a/linux/drivers/media/video/em28xx/em28xx-audio.c b/linux/drivers/media/video/em28xx/em28xx-audio.c index 1d665ba27..e7dfebd7b 100644 --- a/linux/drivers/media/video/em28xx/em28xx-audio.c +++ b/linux/drivers/media/video/em28xx/em28xx-audio.c @@ -246,10 +246,10 @@ static int em28xx_cmd(struct em28xx *dev, int cmd, int arg) switch (cmd) { case EM28XX_CAPTURE_STREAM_EN: - if (dev->adev.capture_stream == STREAM_OFF && arg == 1) { + if (dev->adev.capture_stream == STREAM_OFF && arg == EM28XX_START_AUDIO) { dev->adev.capture_stream = STREAM_ON; em28xx_init_audio_isoc(dev); - } else if (dev->adev.capture_stream == STREAM_ON && arg == 0) { + } else if (dev->adev.capture_stream == STREAM_ON && arg == EM28XX_STOP_AUDIO) { dev->adev.capture_stream = STREAM_OFF; em28xx_deinit_isoc_audio(dev); } else { @@ -425,7 +425,7 @@ static int snd_em28xx_hw_capture_free(struct snd_pcm_substream *substream) dprintk("Stop capture, if needed\n"); if (dev->adev.capture_stream == STREAM_ON) - em28xx_cmd(dev, EM28XX_CAPTURE_STREAM_EN, 0); + em28xx_cmd(dev, EM28XX_CAPTURE_STREAM_EN, EM28XX_STOP_AUDIO); return 0; } @@ -455,11 +455,11 @@ static int snd_em28xx_capture_trigger(struct snd_pcm_substream *substream, spin_lock(&dev->adev.slock); switch (cmd) { case SNDRV_PCM_TRIGGER_START: - em28xx_cmd(dev, EM28XX_CAPTURE_STREAM_EN, 1); + em28xx_cmd(dev, EM28XX_CAPTURE_STREAM_EN, EM28XX_START_AUDIO); retval = 0; break; case SNDRV_PCM_TRIGGER_STOP: - em28xx_cmd(dev, EM28XX_CAPTURE_STREAM_EN, 0); + em28xx_cmd(dev, EM28XX_CAPTURE_STREAM_EN, EM28XX_STOP_AUDIO); retval = 0; break; default: -- cgit v1.2.3 From c6fd49ac8accb7a3252958a16ddf87fd216e694e Mon Sep 17 00:00:00 2001 From: Douglas Schilling Landgraf Date: Wed, 11 Feb 2009 00:28:24 -0200 Subject: em28xx: Coding style fixes and a typo correction From: Nicola Soranzo Lots of coding style fixes and a typo correction for em28xx. Priority: normal Signed-off-by: Nicola Soranzo [dougsland@redhat.com: fixed a reject due to a change on em28xx-audio.c] Signed-off-by: Douglas Schilling Landgraf --- linux/drivers/media/video/em28xx/em28xx-audio.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'linux/drivers/media/video/em28xx/em28xx-audio.c') diff --git a/linux/drivers/media/video/em28xx/em28xx-audio.c b/linux/drivers/media/video/em28xx/em28xx-audio.c index e7dfebd7b..f37abcffa 100644 --- a/linux/drivers/media/video/em28xx/em28xx-audio.c +++ b/linux/drivers/media/video/em28xx/em28xx-audio.c @@ -263,8 +263,7 @@ static int em28xx_cmd(struct em28xx *dev, int cmd, int arg) } #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 16) -static int snd_pcm_alloc_vmalloc_buffer(snd_pcm_substream_t *subs, - size_t size) +static int snd_pcm_alloc_vmalloc_buffer(snd_pcm_substream_t *subs, size_t size) #else static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, size_t size) @@ -276,7 +275,7 @@ static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, struct snd_pcm_runtime *runtime = subs->runtime; #endif - dprintk("Alocating vbuffer\n"); + dprintk("Allocating vbuffer\n"); if (runtime->dma_area) { if (runtime->dma_bytes > size) return 0; @@ -478,8 +477,7 @@ static snd_pcm_uframes_t snd_em28xx_capture_pointer(struct snd_pcm_substream *substream) #endif { - unsigned long flags; - + unsigned long flags; struct em28xx *dev; snd_pcm_uframes_t hwptr_done; -- cgit v1.2.3 From 6cd9330d1dfb971343c26b47a5658bd108a38fe4 Mon Sep 17 00:00:00 2001 From: Douglas Schilling Landgraf Date: Thu, 12 Feb 2009 15:21:52 -0200 Subject: em28xx: CodingStyle fixes From: Nicola Soranzo Coding style fixes for recent changesets in em28xx. Priority: normal Signed-off-by: Nicola Soranzo Signed-off-by: Douglas Schilling Landgraf --- linux/drivers/media/video/em28xx/em28xx-audio.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'linux/drivers/media/video/em28xx/em28xx-audio.c') diff --git a/linux/drivers/media/video/em28xx/em28xx-audio.c b/linux/drivers/media/video/em28xx/em28xx-audio.c index f37abcffa..bfa3986f5 100644 --- a/linux/drivers/media/video/em28xx/em28xx-audio.c +++ b/linux/drivers/media/video/em28xx/em28xx-audio.c @@ -246,10 +246,12 @@ static int em28xx_cmd(struct em28xx *dev, int cmd, int arg) switch (cmd) { case EM28XX_CAPTURE_STREAM_EN: - if (dev->adev.capture_stream == STREAM_OFF && arg == EM28XX_START_AUDIO) { + if (dev->adev.capture_stream == STREAM_OFF && + arg == EM28XX_START_AUDIO) { dev->adev.capture_stream = STREAM_ON; em28xx_init_audio_isoc(dev); - } else if (dev->adev.capture_stream == STREAM_ON && arg == EM28XX_STOP_AUDIO) { + } else if (dev->adev.capture_stream == STREAM_ON && + arg == EM28XX_STOP_AUDIO) { dev->adev.capture_stream = STREAM_OFF; em28xx_deinit_isoc_audio(dev); } else { @@ -448,8 +450,8 @@ static int snd_em28xx_capture_trigger(struct snd_pcm_substream *substream, struct em28xx *dev = snd_pcm_substream_chip(substream); int retval; - dprintk("Should %s capture\n", (cmd == SNDRV_PCM_TRIGGER_START)? - "start": "stop"); + dprintk("Should %s capture\n", (cmd == SNDRV_PCM_TRIGGER_START) ? + "start" : "stop"); spin_lock(&dev->adev.slock); switch (cmd) { -- cgit v1.2.3