From a9855917290fc40dbfd67d3ee06c190667d6c5b5 Mon Sep 17 00:00:00 2001 From: Mike Thomas Date: Mon, 10 Jan 2011 18:41:11 +0000 Subject: staging: easycap: add ALSA support This is necessary because some distributions are disabling OSS entirely. Signed-off-by: Mike Thomas Signed-off-by: Greg Kroah-Hartman --- drivers/staging/easycap/Kconfig | 2 +- drivers/staging/easycap/Makefile | 11 +- drivers/staging/easycap/easycap.h | 84 +- drivers/staging/easycap/easycap_debug.h | 29 - drivers/staging/easycap/easycap_ioctl.c | 272 ++++--- drivers/staging/easycap/easycap_ioctl.h | 9 + drivers/staging/easycap/easycap_low.c | 17 +- drivers/staging/easycap/easycap_low.h | 34 + drivers/staging/easycap/easycap_main.c | 394 +++++---- drivers/staging/easycap/easycap_main.h | 43 + drivers/staging/easycap/easycap_settings.c | 2 +- drivers/staging/easycap/easycap_settings.h | 34 + drivers/staging/easycap/easycap_sound.c | 1214 ++++++++++++++++++++++++---- drivers/staging/easycap/easycap_sound.h | 14 + drivers/staging/easycap/easycap_standard.h | 27 - drivers/staging/easycap/easycap_testcard.c | 4 +- drivers/staging/easycap/easycap_testcard.h | 34 + 17 files changed, 1673 insertions(+), 551 deletions(-) delete mode 100644 drivers/staging/easycap/easycap_debug.h create mode 100644 drivers/staging/easycap/easycap_low.h create mode 100644 drivers/staging/easycap/easycap_main.h create mode 100644 drivers/staging/easycap/easycap_settings.h delete mode 100644 drivers/staging/easycap/easycap_standard.h create mode 100644 drivers/staging/easycap/easycap_testcard.h (limited to 'drivers/staging') diff --git a/drivers/staging/easycap/Kconfig b/drivers/staging/easycap/Kconfig index bd96f39f2735..eaa8a86e183b 100644 --- a/drivers/staging/easycap/Kconfig +++ b/drivers/staging/easycap/Kconfig @@ -1,6 +1,6 @@ config EASYCAP tristate "EasyCAP USB ID 05e1:0408 support" - depends on USB && VIDEO_DEV + depends on USB && VIDEO_DEV && SND ---help--- This is an integrated audio/video driver for EasyCAP cards with diff --git a/drivers/staging/easycap/Makefile b/drivers/staging/easycap/Makefile index f1f2fbebf8f6..977e1535667d 100644 --- a/drivers/staging/easycap/Makefile +++ b/drivers/staging/easycap/Makefile @@ -1,14 +1,13 @@ +easycap-objs := easycap_main.o easycap_low.o easycap_sound.o \ + easycap_ioctl.o easycap_settings.o easycap_testcard.o -obj-$(CONFIG_EASYCAP) += easycap.o - -easycap-y := easycap_main.o easycap_low.o easycap_sound.o -easycap-y += easycap_ioctl.o easycap_settings.o -easycap-y += easycap_testcard.o +obj-$(CONFIG_EASYCAP) += easycap.o ccflags-y := -Wall -# Impose all or none of the following: ccflags-y += -DEASYCAP_IS_VIDEODEV_CLIENT ccflags-y += -DEASYCAP_NEEDS_V4L2_DEVICE_H ccflags-y += -DEASYCAP_NEEDS_V4L2_FOPS ccflags-y += -DEASYCAP_NEEDS_UNLOCKED_IOCTL +ccflags-y += -DEASYCAP_NEEDS_ALSA +ccflags-y += -DEASYCAP_NEEDS_CARD_CREATE diff --git a/drivers/staging/easycap/easycap.h b/drivers/staging/easycap/easycap.h index 063d44718d8d..111f53c33229 100644 --- a/drivers/staging/easycap/easycap.h +++ b/drivers/staging/easycap/easycap.h @@ -34,6 +34,8 @@ * EASYCAP_NEEDS_V4L2_DEVICE_H * EASYCAP_NEEDS_V4L2_FOPS * EASYCAP_NEEDS_UNLOCKED_IOCTL + * EASYCAP_NEEDS_ALSA + * EASYCAP_SILENT * * IF REQUIRED THEY MUST BE EXTERNALLY DEFINED, FOR EXAMPLE AS COMPILER * OPTIONS. @@ -57,9 +59,9 @@ */ /*---------------------------------------------------------------------------*/ #undef EASYCAP_TESTCARD +#if (!defined(EASYCAP_NEEDS_ALSA)) #undef EASYCAP_TESTTONE -#undef NOREADBACK -#undef AUDIOTIME +#endif /*EASYCAP_NEEDS_ALSA*/ /*---------------------------------------------------------------------------*/ #include #include @@ -79,6 +81,16 @@ #include #include +#if defined(EASYCAP_NEEDS_ALSA) +#include +#include +#include +#include +#include +#include +#include +#include +#endif /*EASYCAP_NEEDS_ALSA*/ /*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ #if defined(EASYCAP_IS_VIDEODEV_CLIENT) #include @@ -112,7 +124,7 @@ #define USB_EASYCAP_VENDOR_ID 0x05e1 #define USB_EASYCAP_PRODUCT_ID 0x0408 -#define EASYCAP_DRIVER_VERSION "0.8.41" +#define EASYCAP_DRIVER_VERSION "0.9.01" #define EASYCAP_DRIVER_DESCRIPTION "easycapdc60" #define USB_SKEL_MINOR_BASE 192 @@ -158,7 +170,8 @@ */ /*---------------------------------------------------------------------------*/ #define AUDIO_ISOC_BUFFER_MANY 16 -#define AUDIO_ISOC_ORDER 3 +#define AUDIO_ISOC_ORDER 1 +#define AUDIO_ISOC_FRAMESPERDESC 32 #define AUDIO_ISOC_BUFFER_SIZE (PAGE_SIZE << AUDIO_ISOC_ORDER) /*---------------------------------------------------------------------------*/ /* @@ -166,6 +179,7 @@ */ /*---------------------------------------------------------------------------*/ #define AUDIO_FRAGMENT_MANY 32 +#define PAGES_PER_AUDIO_FRAGMENT 4 /*---------------------------------------------------------------------------*/ /* * IT IS ESSENTIAL THAT EVEN-NUMBERED STANDARDS ARE 25 FRAMES PER SECOND, @@ -296,6 +310,7 @@ struct easycap { #define TELLTALE "expectedstring" char telltale[16]; int isdongle; +int minor; /*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ #if defined(EASYCAP_IS_VIDEODEV_CLIENT) @@ -328,6 +343,7 @@ int done[FRAME_BUFFER_MANY]; wait_queue_head_t wq_video; wait_queue_head_t wq_audio; +wait_queue_head_t wq_trigger; int input; int polled; @@ -428,6 +444,20 @@ int allocation_video_page; int allocation_video_struct; int registered_video; /*---------------------------------------------------------------------------*/ +/* + * ALSA + */ +/*---------------------------------------------------------------------------*/ +#if defined(EASYCAP_NEEDS_ALSA) +struct snd_pcm_hardware alsa_hardware; +struct snd_card *psnd_card; +struct snd_pcm *psnd_pcm; +struct snd_pcm_substream *psubstream; +int dma_fill; +int dma_next; +int dma_read; +#endif /*EASYCAP_NEEDS_ALSA*/ +/*---------------------------------------------------------------------------*/ /* * SOUND PROPERTIES */ @@ -455,10 +485,10 @@ struct list_head *purb_audio_head; * BUFFER INDICATORS */ /*---------------------------------------------------------------------------*/ -int audio_fill; /* Audio buffer being filled by easysnd_complete(). */ - /* Bumped only by easysnd_complete(). */ -int audio_read; /* Audio buffer page being read by easysnd_read(). */ - /* Set by easysnd_read() to trail audio_fill by */ +int audio_fill; /* Audio buffer being filled by easycap_complete(). */ + /* Bumped only by easycap_complete(). */ +int audio_read; /* Audio buffer page being read by easycap_read(). */ + /* Set by easycap_read() to trail audio_fill by */ /* one fragment. */ /*---------------------------------------------------------------------------*/ /* @@ -532,19 +562,39 @@ int adjust_volume(struct easycap *, int); * AUDIO FUNCTION PROTOTYPES */ /*---------------------------------------------------------------------------*/ -void easysnd_complete(struct urb *); -ssize_t easysnd_read(struct file *, char __user *, size_t, loff_t *); -int easysnd_open(struct inode *, struct file *); -int easysnd_release(struct inode *, struct file *); -long easysnd_ioctl_noinode(struct file *, unsigned int, \ +#if defined(EASYCAP_NEEDS_ALSA) +int easycap_alsa_probe(struct easycap *); + +void easycap_alsa_complete(struct urb *); +int easycap_alsa_open(struct snd_pcm_substream *); +int easycap_alsa_close(struct snd_pcm_substream *); +int easycap_alsa_hw_params(struct snd_pcm_substream *, \ + struct snd_pcm_hw_params *); +int easycap_alsa_vmalloc(struct snd_pcm_substream *, size_t); +int easycap_alsa_hw_free(struct snd_pcm_substream *); +int easycap_alsa_prepare(struct snd_pcm_substream *); +int easycap_alsa_ack(struct snd_pcm_substream *); +int easycap_alsa_trigger(struct snd_pcm_substream *, int); +snd_pcm_uframes_t \ + easycap_alsa_pointer(struct snd_pcm_substream *); +struct page *easycap_alsa_page(struct snd_pcm_substream *, unsigned long); + +#else +void easyoss_complete(struct urb *); +ssize_t easyoss_read(struct file *, char __user *, size_t, loff_t *); +int easyoss_open(struct inode *, struct file *); +int easyoss_release(struct inode *, struct file *); +long easyoss_ioctl_noinode(struct file *, unsigned int, \ unsigned long); -int easysnd_ioctl(struct inode *, struct file *, unsigned int, \ +int easyoss_ioctl(struct inode *, struct file *, unsigned int, \ unsigned long); -unsigned int easysnd_poll(struct file *, poll_table *); -void easysnd_delete(struct kref *); +unsigned int easyoss_poll(struct file *, poll_table *); +void easyoss_delete(struct kref *); +#endif /*EASYCAP_NEEDS_ALSA*/ +int easycap_sound_setup(struct easycap *); int submit_audio_urbs(struct easycap *); int kill_audio_urbs(struct easycap *); -void easysnd_testtone(struct easycap *, int); +void easyoss_testtone(struct easycap *, int); int audio_setup(struct easycap *); /*---------------------------------------------------------------------------*/ /* diff --git a/drivers/staging/easycap/easycap_debug.h b/drivers/staging/easycap/easycap_debug.h deleted file mode 100644 index b6b571843125..000000000000 --- a/drivers/staging/easycap/easycap_debug.h +++ /dev/null @@ -1,29 +0,0 @@ -/***************************************************************************** -* * -* easycap_debug.h * -* * -*****************************************************************************/ -/* - * - * Copyright (C) 2010 R.M. Thomas - * - * - * This is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * The software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * -*/ -/*****************************************************************************/ -extern int easycap_debug; -extern int easycap_gain; -extern struct easycap_dongle easycap_dongle[]; diff --git a/drivers/staging/easycap/easycap_ioctl.c b/drivers/staging/easycap/easycap_ioctl.c index 447953a4e80c..20d30334233e 100644 --- a/drivers/staging/easycap/easycap_ioctl.c +++ b/drivers/staging/easycap/easycap_ioctl.c @@ -27,8 +27,6 @@ #include #include "easycap.h" -#include "easycap_debug.h" -#include "easycap_standard.h" #include "easycap_ioctl.h" /*--------------------------------------------------------------------------*/ @@ -910,7 +908,7 @@ return -ENOENT; * peasycap->audio_interface, \ * peasycap->audio_altsetting_off); * HOWEVER, AFTER THIS COMMAND IS ISSUED ALL SUBSEQUENT URBS RECEIVE STATUS - * -ESHUTDOWN. THE HANDLER ROUTINE easysnd_complete() DECLINES TO RESUBMIT + * -ESHUTDOWN. THE HANDLER ROUTINE easyxxx_complete() DECLINES TO RESUBMIT * THE URB AND THE PIPELINE COLLAPSES IRRETRIEVABLY. BEWARE. */ /*---------------------------------------------------------------------------*/ @@ -991,11 +989,12 @@ if (NULL == p) { } kd = isdongle(peasycap); if (0 <= kd && DONGLE_MANY > kd) { - if (mutex_lock_interruptible(&easycap_dongle[kd].mutex_video)) { - SAY("ERROR: cannot lock easycap_dongle[%i].mutex_video\n", kd); + if (mutex_lock_interruptible(&easycapdc60_dongle[kd].mutex_video)) { + SAY("ERROR: cannot lock " \ + "easycapdc60_dongle[%i].mutex_video\n", kd); return -ERESTARTSYS; } - JOM(4, "locked easycap_dongle[%i].mutex_video\n", kd); + JOM(4, "locked easycapdc60_dongle[%i].mutex_video\n", kd); /*---------------------------------------------------------------------------*/ /* * MEANWHILE, easycap_usb_disconnect() MAY HAVE FREED POINTER peasycap, @@ -1007,24 +1006,24 @@ if (0 <= kd && DONGLE_MANY > kd) { return -ERESTARTSYS; if (NULL == file) { SAY("ERROR: file is NULL\n"); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -ERESTARTSYS; } peasycap = file->private_data; if (NULL == peasycap) { SAY("ERROR: peasycap is NULL\n"); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -ERESTARTSYS; } if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { SAY("ERROR: bad peasycap\n"); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } p = peasycap->pusb_device; if (NULL == peasycap->pusb_device) { SAM("ERROR: peasycap->pusb_device is NULL\n"); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -ERESTARTSYS; } } else { @@ -1048,7 +1047,7 @@ case VIDIOC_QUERYCAP: { if (16 <= strlen(EASYCAP_DRIVER_VERSION)) { SAM("ERROR: bad driver version string\n"); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EINVAL; } strcpy(&version[0], EASYCAP_DRIVER_VERSION); @@ -1066,7 +1065,8 @@ case VIDIOC_QUERYCAP: { if (0 != rc) { SAM("ERROR: %i=strict_strtol(%s,.,,)\n", \ rc, p1); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].\ + mutex_video); return -EINVAL; } k[i] = (int)lng; @@ -1097,7 +1097,7 @@ case VIDIOC_QUERYCAP: { } if (0 != copy_to_user((void __user *)arg, &v4l2_capability, \ sizeof(struct v4l2_capability))) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } break; @@ -1111,7 +1111,7 @@ case VIDIOC_ENUMINPUT: { if (0 != copy_from_user(&v4l2_input, (void __user *)arg, \ sizeof(struct v4l2_input))) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } @@ -1193,14 +1193,14 @@ case VIDIOC_ENUMINPUT: { } default: { JOM(8, "%i=index: exhausts inputs\n", index); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EINVAL; } } if (0 != copy_to_user((void __user *)arg, &v4l2_input, \ sizeof(struct v4l2_input))) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } break; @@ -1213,7 +1213,7 @@ case VIDIOC_G_INPUT: { index = (__u32)peasycap->input; JOM(8, "user is told: %i\n", index); if (0 != copy_to_user((void __user *)arg, &index, sizeof(__u32))) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } break; @@ -1227,7 +1227,7 @@ case VIDIOC_S_INPUT: JOM(8, "VIDIOC_S_INPUT\n"); if (0 != copy_from_user(&index, (void __user *)arg, sizeof(__u32))) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } @@ -1240,7 +1240,7 @@ case VIDIOC_S_INPUT: if ((0 > index) || (INPUT_MANY <= index)) { JOM(8, "ERROR: bad requested input: %i\n", index); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EINVAL; } @@ -1249,7 +1249,7 @@ case VIDIOC_S_INPUT: JOM(8, "newinput(.,%i) OK\n", (int)index); } else { SAM("ERROR: newinput(.,%i) returned %i\n", (int)index, rc); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } break; @@ -1257,7 +1257,7 @@ case VIDIOC_S_INPUT: /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ case VIDIOC_ENUMAUDIO: { JOM(8, "VIDIOC_ENUMAUDIO\n"); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EINVAL; } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ @@ -1268,12 +1268,12 @@ case VIDIOC_ENUMAUDOUT: { if (0 != copy_from_user(&v4l2_audioout, (void __user *)arg, \ sizeof(struct v4l2_audioout))) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } if (0 != v4l2_audioout.index) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EINVAL; } memset(&v4l2_audioout, 0, sizeof(struct v4l2_audioout)); @@ -1282,7 +1282,7 @@ case VIDIOC_ENUMAUDOUT: { if (0 != copy_to_user((void __user *)arg, &v4l2_audioout, \ sizeof(struct v4l2_audioout))) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } break; @@ -1296,7 +1296,7 @@ case VIDIOC_QUERYCTRL: { if (0 != copy_from_user(&v4l2_queryctrl, (void __user *)arg, \ sizeof(struct v4l2_queryctrl))) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } @@ -1313,12 +1313,12 @@ case VIDIOC_QUERYCTRL: { } if (0xFFFFFFFF == easycap_control[i1].id) { JOM(8, "%i=index: exhausts controls\n", i1); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EINVAL; } if (0 != copy_to_user((void __user *)arg, &v4l2_queryctrl, \ sizeof(struct v4l2_queryctrl))) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } break; @@ -1326,7 +1326,7 @@ case VIDIOC_QUERYCTRL: { /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ case VIDIOC_QUERYMENU: { JOM(8, "VIDIOC_QUERYMENU unsupported\n"); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EINVAL; } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ @@ -1337,13 +1337,13 @@ case VIDIOC_G_CTRL: { pv4l2_control = kzalloc(sizeof(struct v4l2_control), GFP_KERNEL); if (!pv4l2_control) { SAM("ERROR: out of memory\n"); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -ENOMEM; } if (0 != copy_from_user(pv4l2_control, (void __user *)arg, \ sizeof(struct v4l2_control))) { kfree(pv4l2_control); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } @@ -1385,14 +1385,14 @@ case VIDIOC_G_CTRL: { SAM("ERROR: unknown V4L2 control: 0x%08X=id\n", \ pv4l2_control->id); kfree(pv4l2_control); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EINVAL; } } if (0 != copy_to_user((void __user *)arg, pv4l2_control, \ sizeof(struct v4l2_control))) { kfree(pv4l2_control); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } kfree(pv4l2_control); @@ -1412,7 +1412,7 @@ case VIDIOC_S_CTRL: if (0 != copy_from_user(&v4l2_control, (void __user *)arg, \ sizeof(struct v4l2_control))) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } @@ -1463,7 +1463,7 @@ case VIDIOC_S_CTRL: default: { SAM("ERROR: unknown V4L2 control: 0x%08X=id\n", \ v4l2_control.id); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EINVAL; } } @@ -1472,7 +1472,7 @@ case VIDIOC_S_CTRL: /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ case VIDIOC_S_EXT_CTRLS: { JOM(8, "VIDIOC_S_EXT_CTRLS unsupported\n"); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EINVAL; } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ @@ -1484,7 +1484,7 @@ case VIDIOC_ENUM_FMT: { if (0 != copy_from_user(&v4l2_fmtdesc, (void __user *)arg, \ sizeof(struct v4l2_fmtdesc))) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } @@ -1539,13 +1539,13 @@ case VIDIOC_ENUM_FMT: { } default: { JOM(8, "%i=index: exhausts formats\n", index); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EINVAL; } } if (0 != copy_to_user((void __user *)arg, &v4l2_fmtdesc, \ sizeof(struct v4l2_fmtdesc))) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } break; @@ -1564,7 +1564,7 @@ case VIDIOC_ENUM_FRAMESIZES: { if (0 != copy_from_user(&v4l2_frmsizeenum, (void __user *)arg, \ sizeof(struct v4l2_frmsizeenum))) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } @@ -1616,7 +1616,7 @@ case VIDIOC_ENUM_FRAMESIZES: { } default: { JOM(8, "%i=index: exhausts framesizes\n", index); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EINVAL; } } @@ -1674,14 +1674,14 @@ case VIDIOC_ENUM_FRAMESIZES: { } default: { JOM(8, "%i=index: exhausts framesizes\n", index); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EINVAL; } } } if (0 != copy_to_user((void __user *)arg, &v4l2_frmsizeenum, \ sizeof(struct v4l2_frmsizeenum))) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } break; @@ -1710,7 +1710,7 @@ case VIDIOC_ENUM_FRAMEINTERVALS: { if (0 != copy_from_user(&v4l2_frmivalenum, (void __user *)arg, \ sizeof(struct v4l2_frmivalenum))) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } @@ -1737,13 +1737,13 @@ case VIDIOC_ENUM_FRAMEINTERVALS: { } default: { JOM(8, "%i=index: exhausts frameintervals\n", index); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EINVAL; } } if (0 != copy_to_user((void __user *)arg, &v4l2_frmivalenum, \ sizeof(struct v4l2_frmivalenum))) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } break; @@ -1757,28 +1757,28 @@ case VIDIOC_G_FMT: { pv4l2_format = kzalloc(sizeof(struct v4l2_format), GFP_KERNEL); if (!pv4l2_format) { SAM("ERROR: out of memory\n"); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -ENOMEM; } pv4l2_pix_format = kzalloc(sizeof(struct v4l2_pix_format), GFP_KERNEL); if (!pv4l2_pix_format) { SAM("ERROR: out of memory\n"); kfree(pv4l2_format); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -ENOMEM; } if (0 != copy_from_user(pv4l2_format, (void __user *)arg, \ sizeof(struct v4l2_format))) { kfree(pv4l2_format); kfree(pv4l2_pix_format); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } if (pv4l2_format->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { kfree(pv4l2_format); kfree(pv4l2_pix_format); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EINVAL; } @@ -1794,7 +1794,7 @@ case VIDIOC_G_FMT: { sizeof(struct v4l2_format))) { kfree(pv4l2_format); kfree(pv4l2_pix_format); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } kfree(pv4l2_format); @@ -1819,7 +1819,7 @@ case VIDIOC_S_FMT: { if (0 != copy_from_user(&v4l2_format, (void __user *)arg, \ sizeof(struct v4l2_format))) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } @@ -1831,11 +1831,11 @@ case VIDIOC_S_FMT: { try); if (0 > best_format) { if (-EBUSY == best_format) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EBUSY; } JOM(8, "WARNING: adjust_format() returned %i\n", best_format); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -ENOENT; } /*...........................................................................*/ @@ -1848,7 +1848,7 @@ case VIDIOC_S_FMT: { if (0 != copy_to_user((void __user *)arg, &v4l2_format, \ sizeof(struct v4l2_format))) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } break; @@ -1861,7 +1861,7 @@ case VIDIOC_CROPCAP: { if (0 != copy_from_user(&v4l2_cropcap, (void __user *)arg, \ sizeof(struct v4l2_cropcap))) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } @@ -1885,7 +1885,7 @@ case VIDIOC_CROPCAP: { if (0 != copy_to_user((void __user *)arg, &v4l2_cropcap, \ sizeof(struct v4l2_cropcap))) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } break; @@ -1894,14 +1894,14 @@ case VIDIOC_CROPCAP: { case VIDIOC_G_CROP: case VIDIOC_S_CROP: { JOM(8, "VIDIOC_G_CROP|VIDIOC_S_CROP unsupported\n"); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EINVAL; } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ case VIDIOC_QUERYSTD: { JOM(8, "VIDIOC_QUERYSTD: " \ "EasyCAP is incapable of detecting standard\n"); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EINVAL; break; } @@ -1923,7 +1923,7 @@ case VIDIOC_ENUMSTD: { if (0 != copy_from_user(&v4l2_standard, (void __user *)arg, \ sizeof(struct v4l2_standard))) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } index = v4l2_standard.index; @@ -1945,7 +1945,7 @@ case VIDIOC_ENUMSTD: { } if (0xFFFF == peasycap_standard->mask) { JOM(8, "%i=index: exhausts standards\n", index); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EINVAL; } JOM(8, "%i=index: %s\n", index, \ @@ -1957,7 +1957,7 @@ case VIDIOC_ENUMSTD: { if (0 != copy_to_user((void __user *)arg, &v4l2_standard, \ sizeof(struct v4l2_standard))) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } break; @@ -1972,13 +1972,13 @@ case VIDIOC_G_STD: { if (0 > peasycap->standard_offset) { JOM(8, "%i=peasycap->standard_offset\n", \ peasycap->standard_offset); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EBUSY; } if (0 != copy_from_user(&std_id, (void __user *)arg, \ sizeof(v4l2_std_id))) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } @@ -1990,7 +1990,7 @@ case VIDIOC_G_STD: { if (0 != copy_to_user((void __user *)arg, &std_id, \ sizeof(v4l2_std_id))) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } break; @@ -2004,7 +2004,7 @@ case VIDIOC_S_STD: { if (0 != copy_from_user(&std_id, (void __user *)arg, \ sizeof(v4l2_std_id))) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } @@ -2015,7 +2015,7 @@ case VIDIOC_S_STD: { rc = adjust_standard(peasycap, std_id); if (0 > rc) { JOM(8, "WARNING: adjust_standard() returned %i\n", rc); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -ENOENT; } break; @@ -2029,16 +2029,16 @@ case VIDIOC_REQBUFS: { if (0 != copy_from_user(&v4l2_requestbuffers, (void __user *)arg, \ sizeof(struct v4l2_requestbuffers))) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } if (v4l2_requestbuffers.type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EINVAL; } if (v4l2_requestbuffers.memory != V4L2_MEMORY_MMAP) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EINVAL; } nbuffers = v4l2_requestbuffers.count; @@ -2059,7 +2059,7 @@ case VIDIOC_REQBUFS: { if (0 != copy_to_user((void __user *)arg, &v4l2_requestbuffers, \ sizeof(struct v4l2_requestbuffers))) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } break; @@ -2074,18 +2074,18 @@ case VIDIOC_QUERYBUF: { if (peasycap->video_eof) { JOM(8, "returning -EIO because %i=video_eof\n", \ peasycap->video_eof); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EIO; } if (0 != copy_from_user(&v4l2_buffer, (void __user *)arg, \ sizeof(struct v4l2_buffer))) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } if (v4l2_buffer.type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EINVAL; } index = v4l2_buffer.index; @@ -2117,7 +2117,7 @@ case VIDIOC_QUERYBUF: { if (0 != copy_to_user((void __user *)arg, &v4l2_buffer, \ sizeof(struct v4l2_buffer))) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } break; @@ -2130,21 +2130,21 @@ case VIDIOC_QBUF: { if (0 != copy_from_user(&v4l2_buffer, (void __user *)arg, \ sizeof(struct v4l2_buffer))) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } if (v4l2_buffer.type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EINVAL; } if (v4l2_buffer.memory != V4L2_MEMORY_MMAP) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EINVAL; } if (v4l2_buffer.index < 0 || \ (v4l2_buffer.index >= peasycap->frame_buffer_many)) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EINVAL; } v4l2_buffer.flags = V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_QUEUED; @@ -2154,7 +2154,7 @@ case VIDIOC_QBUF: { if (0 != copy_to_user((void __user *)arg, &v4l2_buffer, \ sizeof(struct v4l2_buffer))) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } @@ -2187,18 +2187,18 @@ case VIDIOC_DQBUF: JOM(8, "returning -EIO because " \ "%i=video_idle %i=video_eof\n", \ peasycap->video_idle, peasycap->video_eof); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EIO; } if (0 != copy_from_user(&v4l2_buffer, (void __user *)arg, \ sizeof(struct v4l2_buffer))) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } if (v4l2_buffer.type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EINVAL; } @@ -2222,7 +2222,7 @@ case VIDIOC_DQBUF: if (!peasycap->video_isoc_streaming) { JOM(16, "returning -EIO because video urbs not streaming\n"); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EIO; } /*---------------------------------------------------------------------------*/ @@ -2239,18 +2239,19 @@ case VIDIOC_DQBUF: if (-EIO == rcdq) { JOM(8, "returning -EIO because " \ "dqbuf() returned -EIO\n"); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].\ + mutex_video); return -EIO; } } while (0 != rcdq); } else { if (peasycap->video_eof) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EIO; } } if (V4L2_BUF_FLAG_DONE != peasycap->done[peasycap->frame_read]) { - SAM("ERROR: V4L2_BUF_FLAG_DONE != 0x%08X\n", \ + JOM(8, "V4L2_BUF_FLAG_DONE != 0x%08X\n", \ peasycap->done[peasycap->frame_read]); } peasycap->polled = 0; @@ -2337,7 +2338,7 @@ case VIDIOC_DQBUF: if (0 != copy_to_user((void __user *)arg, &v4l2_buffer, \ sizeof(struct v4l2_buffer))) { - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } @@ -2370,7 +2371,7 @@ case VIDIOC_STREAMON: { peasycap->merit[i] = 0; if ((struct usb_device *)NULL == peasycap->pusb_device) { SAM("ERROR: peasycap->pusb_device is NULL\n"); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } submit_video_urbs(peasycap); @@ -2386,7 +2387,7 @@ case VIDIOC_STREAMOFF: { if ((struct usb_device *)NULL == peasycap->pusb_device) { SAM("ERROR: peasycap->pusb_device is NULL\n"); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } @@ -2400,7 +2401,12 @@ case VIDIOC_STREAMOFF: { /*---------------------------------------------------------------------------*/ JOM(8, "calling wake_up on wq_video and wq_audio\n"); wake_up_interruptible(&(peasycap->wq_video)); +#if defined(EASYCAP_NEEDS_ALSA) + if (NULL != peasycap->psubstream) + snd_pcm_period_elapsed(peasycap->psubstream); +#else wake_up_interruptible(&(peasycap->wq_audio)); +#endif /*EASYCAP_NEEDS_ALSA*/ /*---------------------------------------------------------------------------*/ break; } @@ -2412,19 +2418,19 @@ case VIDIOC_G_PARM: { pv4l2_streamparm = kzalloc(sizeof(struct v4l2_streamparm), GFP_KERNEL); if (!pv4l2_streamparm) { SAM("ERROR: out of memory\n"); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -ENOMEM; } if (0 != copy_from_user(pv4l2_streamparm, (void __user *)arg, \ sizeof(struct v4l2_streamparm))) { kfree(pv4l2_streamparm); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } if (pv4l2_streamparm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { kfree(pv4l2_streamparm); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EINVAL; } pv4l2_streamparm->parm.capture.capability = 0; @@ -2450,7 +2456,7 @@ case VIDIOC_G_PARM: { if (0 != copy_to_user((void __user *)arg, pv4l2_streamparm, \ sizeof(struct v4l2_streamparm))) { kfree(pv4l2_streamparm); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT; } kfree(pv4l2_streamparm); @@ -2459,25 +2465,25 @@ case VIDIOC_G_PARM: { /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ case VIDIOC_S_PARM: { JOM(8, "VIDIOC_S_PARM unsupported\n"); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EINVAL; } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ case VIDIOC_G_AUDIO: { JOM(8, "VIDIOC_G_AUDIO unsupported\n"); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EINVAL; } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ case VIDIOC_S_AUDIO: { JOM(8, "VIDIOC_S_AUDIO unsupported\n"); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EINVAL; } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ case VIDIOC_S_TUNER: { JOM(8, "VIDIOC_S_TUNER unsupported\n"); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EINVAL; } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ @@ -2485,45 +2491,46 @@ case VIDIOC_G_FBUF: case VIDIOC_S_FBUF: case VIDIOC_OVERLAY: { JOM(8, "VIDIOC_G_FBUF|VIDIOC_S_FBUF|VIDIOC_OVERLAY unsupported\n"); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EINVAL; } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ case VIDIOC_G_TUNER: { JOM(8, "VIDIOC_G_TUNER unsupported\n"); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EINVAL; } case VIDIOC_G_FREQUENCY: case VIDIOC_S_FREQUENCY: { JOM(8, "VIDIOC_G_FREQUENCY|VIDIOC_S_FREQUENCY unsupported\n"); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EINVAL; } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ default: { JOM(8, "ERROR: unrecognized V4L2 IOCTL command: 0x%08X\n", cmd); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -ENOIOCTLCMD; } } -mutex_unlock(&easycap_dongle[kd].mutex_video); -JOM(4, "unlocked easycap_dongle[%i].mutex_video\n", kd); +mutex_unlock(&easycapdc60_dongle[kd].mutex_video); +JOM(4, "unlocked easycapdc60_dongle[%i].mutex_video\n", kd); return 0; } /*****************************************************************************/ +#if !defined(EASYCAP_NEEDS_ALSA) /*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ #if ((defined(EASYCAP_IS_VIDEODEV_CLIENT)) || \ (defined(EASYCAP_NEEDS_UNLOCKED_IOCTL))) long -easysnd_ioctl_noinode(struct file *file, unsigned int cmd, unsigned long arg) { - return (long)easysnd_ioctl((struct inode *)NULL, file, cmd, arg); +easyoss_ioctl_noinode(struct file *file, unsigned int cmd, unsigned long arg) { + return (long)easyoss_ioctl((struct inode *)NULL, file, cmd, arg); } #endif /*EASYCAP_IS_VIDEODEV_CLIENT||EASYCAP_NEEDS_UNLOCKED_IOCTL*/ /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ /*---------------------------------------------------------------------------*/ int -easysnd_ioctl(struct inode *inode, struct file *file, +easyoss_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { struct easycap *peasycap; @@ -2550,11 +2557,12 @@ if (NULL == p) { } kd = isdongle(peasycap); if (0 <= kd && DONGLE_MANY > kd) { - if (mutex_lock_interruptible(&easycap_dongle[kd].mutex_audio)) { - SAY("ERROR: cannot lock easycap_dongle[%i].mutex_audio\n", kd); + if (mutex_lock_interruptible(&easycapdc60_dongle[kd].mutex_audio)) { + SAY("ERROR: cannot lock " + "easycapdc60_dongle[%i].mutex_audio\n", kd); return -ERESTARTSYS; } - JOM(4, "locked easycap_dongle[%i].mutex_audio\n", kd); + JOM(4, "locked easycapdc60_dongle[%i].mutex_audio\n", kd); /*---------------------------------------------------------------------------*/ /* * MEANWHILE, easycap_usb_disconnect() MAY HAVE FREED POINTER peasycap, @@ -2566,24 +2574,24 @@ if (0 <= kd && DONGLE_MANY > kd) { return -ERESTARTSYS; if (NULL == file) { SAY("ERROR: file is NULL\n"); - mutex_unlock(&easycap_dongle[kd].mutex_audio); + mutex_unlock(&easycapdc60_dongle[kd].mutex_audio); return -ERESTARTSYS; } peasycap = file->private_data; if (NULL == peasycap) { SAY("ERROR: peasycap is NULL\n"); - mutex_unlock(&easycap_dongle[kd].mutex_audio); + mutex_unlock(&easycapdc60_dongle[kd].mutex_audio); return -ERESTARTSYS; } if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { SAY("ERROR: bad peasycap\n"); - mutex_unlock(&easycap_dongle[kd].mutex_audio); + mutex_unlock(&easycapdc60_dongle[kd].mutex_audio); return -EFAULT; } p = peasycap->pusb_device; if (NULL == peasycap->pusb_device) { SAM("ERROR: peasycap->pusb_device is NULL\n"); - mutex_unlock(&easycap_dongle[kd].mutex_audio); + mutex_unlock(&easycapdc60_dongle[kd].mutex_audio); return -ERESTARTSYS; } } else { @@ -2614,7 +2622,7 @@ case SNDCTL_DSP_GETCAPS: { #endif /*UPSAMPLE*/ if (0 != copy_to_user((void __user *)arg, &caps, sizeof(int))) { - mutex_unlock(&easycap_dongle[kd].mutex_audio); + mutex_unlock(&easycapdc60_dongle[kd].mutex_audio); return -EFAULT; } break; @@ -2636,7 +2644,7 @@ case SNDCTL_DSP_GETFMTS: { #endif /*UPSAMPLE*/ if (0 != copy_to_user((void __user *)arg, &incoming, sizeof(int))) { - mutex_unlock(&easycap_dongle[kd].mutex_audio); + mutex_unlock(&easycapdc60_dongle[kd].mutex_audio); return -EFAULT; } break; @@ -2645,7 +2653,7 @@ case SNDCTL_DSP_SETFMT: { int incoming, outgoing; JOM(8, "SNDCTL_DSP_SETFMT\n"); if (0 != copy_from_user(&incoming, (void __user *)arg, sizeof(int))) { - mutex_unlock(&easycap_dongle[kd].mutex_audio); + mutex_unlock(&easycapdc60_dongle[kd].mutex_audio); return -EFAULT; } JOM(8, "........... %i=incoming\n", incoming); @@ -2668,10 +2676,10 @@ case SNDCTL_DSP_SETFMT: { JOM(8, " cf. %i=AFMT_U8\n", AFMT_U8); if (0 != copy_to_user((void __user *)arg, &outgoing, \ sizeof(int))) { - mutex_unlock(&easycap_dongle[kd].mutex_audio); + mutex_unlock(&easycapdc60_dongle[kd].mutex_audio); return -EFAULT; } - mutex_unlock(&easycap_dongle[kd].mutex_audio); + mutex_unlock(&easycapdc60_dongle[kd].mutex_audio); return -EINVAL ; } break; @@ -2680,7 +2688,7 @@ case SNDCTL_DSP_STEREO: { int incoming; JOM(8, "SNDCTL_DSP_STEREO\n"); if (0 != copy_from_user(&incoming, (void __user *)arg, sizeof(int))) { - mutex_unlock(&easycap_dongle[kd].mutex_audio); + mutex_unlock(&easycapdc60_dongle[kd].mutex_audio); return -EFAULT; } JOM(8, "........... %i=incoming\n", incoming); @@ -2698,7 +2706,7 @@ case SNDCTL_DSP_STEREO: { #endif /*UPSAMPLE*/ if (0 != copy_to_user((void __user *)arg, &incoming, sizeof(int))) { - mutex_unlock(&easycap_dongle[kd].mutex_audio); + mutex_unlock(&easycapdc60_dongle[kd].mutex_audio); return -EFAULT; } break; @@ -2707,7 +2715,7 @@ case SNDCTL_DSP_SPEED: { int incoming; JOM(8, "SNDCTL_DSP_SPEED\n"); if (0 != copy_from_user(&incoming, (void __user *)arg, sizeof(int))) { - mutex_unlock(&easycap_dongle[kd].mutex_audio); + mutex_unlock(&easycapdc60_dongle[kd].mutex_audio); return -EFAULT; } JOM(8, "........... %i=incoming\n", incoming); @@ -2725,7 +2733,7 @@ case SNDCTL_DSP_SPEED: { #endif /*UPSAMPLE*/ if (0 != copy_to_user((void __user *)arg, &incoming, sizeof(int))) { - mutex_unlock(&easycap_dongle[kd].mutex_audio); + mutex_unlock(&easycapdc60_dongle[kd].mutex_audio); return -EFAULT; } break; @@ -2734,14 +2742,14 @@ case SNDCTL_DSP_GETTRIGGER: { int incoming; JOM(8, "SNDCTL_DSP_GETTRIGGER\n"); if (0 != copy_from_user(&incoming, (void __user *)arg, sizeof(int))) { - mutex_unlock(&easycap_dongle[kd].mutex_audio); + mutex_unlock(&easycapdc60_dongle[kd].mutex_audio); return -EFAULT; } JOM(8, "........... %i=incoming\n", incoming); incoming = PCM_ENABLE_INPUT; if (0 != copy_to_user((void __user *)arg, &incoming, sizeof(int))) { - mutex_unlock(&easycap_dongle[kd].mutex_audio); + mutex_unlock(&easycapdc60_dongle[kd].mutex_audio); return -EFAULT; } break; @@ -2750,7 +2758,7 @@ case SNDCTL_DSP_SETTRIGGER: { int incoming; JOM(8, "SNDCTL_DSP_SETTRIGGER\n"); if (0 != copy_from_user(&incoming, (void __user *)arg, sizeof(int))) { - mutex_unlock(&easycap_dongle[kd].mutex_audio); + mutex_unlock(&easycapdc60_dongle[kd].mutex_audio); return -EFAULT; } JOM(8, "........... %i=incoming\n", incoming); @@ -2767,13 +2775,13 @@ case SNDCTL_DSP_GETBLKSIZE: { int incoming; JOM(8, "SNDCTL_DSP_GETBLKSIZE\n"); if (0 != copy_from_user(&incoming, (void __user *)arg, sizeof(int))) { - mutex_unlock(&easycap_dongle[kd].mutex_audio); + mutex_unlock(&easycapdc60_dongle[kd].mutex_audio); return -EFAULT; } JOM(8, "........... %i=incoming\n", incoming); incoming = peasycap->audio_bytes_per_fragment; if (0 != copy_to_user((void __user *)arg, &incoming, sizeof(int))) { - mutex_unlock(&easycap_dongle[kd].mutex_audio); + mutex_unlock(&easycapdc60_dongle[kd].mutex_audio); return -EFAULT; } break; @@ -2790,7 +2798,7 @@ case SNDCTL_DSP_GETISPACE: { if (0 != copy_to_user((void __user *)arg, &audio_buf_info, \ sizeof(int))) { - mutex_unlock(&easycap_dongle[kd].mutex_audio); + mutex_unlock(&easycapdc60_dongle[kd].mutex_audio); return -EFAULT; } break; @@ -2802,18 +2810,18 @@ case 0x00005404: case 0x00005405: case 0x00005406: { JOM(8, "SNDCTL_TMR_...: 0x%08X unsupported\n", cmd); - mutex_unlock(&easycap_dongle[kd].mutex_audio); + mutex_unlock(&easycapdc60_dongle[kd].mutex_audio); return -ENOIOCTLCMD; } default: { JOM(8, "ERROR: unrecognized DSP IOCTL command: 0x%08X\n", cmd); - mutex_unlock(&easycap_dongle[kd].mutex_audio); + mutex_unlock(&easycapdc60_dongle[kd].mutex_audio); return -ENOIOCTLCMD; } } -mutex_unlock(&easycap_dongle[kd].mutex_audio); +mutex_unlock(&easycapdc60_dongle[kd].mutex_audio); return 0; } +#endif /*EASYCAP_NEEDS_ALSA*/ /*****************************************************************************/ - diff --git a/drivers/staging/easycap/easycap_ioctl.h b/drivers/staging/easycap/easycap_ioctl.h index 210cd627235f..938de375efab 100644 --- a/drivers/staging/easycap/easycap_ioctl.h +++ b/drivers/staging/easycap/easycap_ioctl.h @@ -24,5 +24,14 @@ * */ /*****************************************************************************/ +#if !defined(EASYCAP_IOCTL_H) +#define EASYCAP_IOCTL_H + +extern int easycap_debug; +extern int easycap_gain; +extern struct easycap_dongle easycapdc60_dongle[]; +extern struct easycap_standard easycap_standard[]; extern struct easycap_format easycap_format[]; extern struct v4l2_queryctrl easycap_control[]; + +#endif /*EASYCAP_IOCTL_H*/ diff --git a/drivers/staging/easycap/easycap_low.c b/drivers/staging/easycap/easycap_low.c index 28c4d1e3c02f..b618d4be3e5c 100644 --- a/drivers/staging/easycap/easycap_low.c +++ b/drivers/staging/easycap/easycap_low.c @@ -39,7 +39,7 @@ /****************************************************************************/ #include "easycap.h" -#include "easycap_debug.h" +#include "easycap_low.h" /*--------------------------------------------------------------------------*/ const struct stk1160config { int reg; int set; } stk1160configPAL[256] = { @@ -1052,9 +1052,18 @@ rc = usb_control_msg(pusb_device, usb_sndctrlpipe(pusb_device, 0), \ (int)50000); JOT(8, "0x%02X=buffer\n", *((__u8 *) &buffer[0])); -if (rc != (int)length) - SAY("ERROR: usb_control_msg returned %i\n", rc); - +if (rc != (int)length) { + switch (rc) { + case -EPIPE: { + SAY("usb_control_msg returned -EPIPE\n"); + break; + } + default: { + SAY("ERROR: usb_control_msg returned %i\n", rc); + break; + } + } +} /*--------------------------------------------------------------------------*/ /* * REGISTER 500: SETTING VALUE TO 0x0094 RESETS AUDIO CONFIGURATION ??? diff --git a/drivers/staging/easycap/easycap_low.h b/drivers/staging/easycap/easycap_low.h new file mode 100644 index 000000000000..d2b69e9c6b30 --- /dev/null +++ b/drivers/staging/easycap/easycap_low.h @@ -0,0 +1,34 @@ +/***************************************************************************** +* * +* easycap_low.h * +* * +*****************************************************************************/ +/* + * + * Copyright (C) 2010 R.M. Thomas + * + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * The software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * +*/ +/*****************************************************************************/ +#if !defined(EASYCAP_LOW_H) +#define EASYCAP_LOW_H + +extern int easycap_debug; +extern int easycap_gain; +extern struct easycap_dongle easycapdc60_dongle[]; + +#endif /*EASYCAP_LOW_H*/ diff --git a/drivers/staging/easycap/easycap_main.c b/drivers/staging/easycap/easycap_main.c index 22cf02b9e9d5..84128cf90007 100644 --- a/drivers/staging/easycap/easycap_main.c +++ b/drivers/staging/easycap/easycap_main.c @@ -29,30 +29,17 @@ /*****************************************************************************/ #include "easycap.h" -#include "easycap_standard.h" -#include "easycap_ioctl.h" +#include "easycap_main.h" int easycap_debug; -static int easycap_bars; +static int easycap_bars = 1; int easycap_gain = 16; module_param_named(debug, easycap_debug, int, S_IRUGO | S_IWUSR); module_param_named(bars, easycap_bars, int, S_IRUGO | S_IWUSR); module_param_named(gain, easycap_gain, int, S_IRUGO | S_IWUSR); -/*---------------------------------------------------------------------------*/ -/* - * dongle_this IS INDISPENSIBLY static BECAUSE FUNCTION easycap_usb_probe() - * IS CALLED SUCCESSIVELY FOR INTERFACES 0, 1, 2 AND THE POINTER peasycap - * ALLOCATED DURING THE PROBING OF INTERFACE 0 MUST BE REMEMBERED WHEN - * PROBING INTERFACES 1 AND 2. - * - * IOCTL LOCKING IS DONE AT MODULE LEVEL, NOT DEVICE LEVEL. -*/ -/*---------------------------------------------------------------------------*/ - -struct easycap_dongle easycap_dongle[DONGLE_MANY]; -static int dongle_this; -static int dongle_done; +struct easycap_dongle easycapdc60_dongle[DONGLE_MANY]; +static struct mutex mutex_dongle; /*---------------------------------------------------------------------------*/ /* @@ -120,28 +107,6 @@ const struct v4l2_file_operations v4l2_fops = { #endif /*EASYCAP_NEEDS_V4L2_FOPS*/ #endif /*EASYCAP_IS_VIDEODEV_CLIENT*/ /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ -/*--------------------------------------------------------------------------*/ -/* - * PARAMETERS USED WHEN REGISTERING THE AUDIO INTERFACE - */ -/*--------------------------------------------------------------------------*/ -const struct file_operations easysnd_fops = { - .owner = THIS_MODULE, - .open = easysnd_open, - .release = easysnd_release, -#if defined(EASYCAP_NEEDS_UNLOCKED_IOCTL) - .unlocked_ioctl = easysnd_ioctl_noinode, -#else - .ioctl = easysnd_ioctl, -#endif /*EASYCAP_NEEDS_UNLOCKED_IOCTL*/ - .read = easysnd_read, - .llseek = no_llseek, -}; -struct usb_class_driver easysnd_class = { -.name = "usb/easysnd%d", -.fops = &easysnd_fops, -.minor_base = USB_SKEL_MINOR_BASE, -}; /****************************************************************************/ /*---------------------------------------------------------------------------*/ /* @@ -155,7 +120,7 @@ int k; if (NULL == peasycap) return -2; for (k = 0; k < DONGLE_MANY; k++) { - if (easycap_dongle[k].peasycap == peasycap) { + if (easycapdc60_dongle[k].peasycap == peasycap) { peasycap->isdongle = k; return k; } @@ -1055,9 +1020,10 @@ for (k = 0; k < AUDIO_ISOC_BUFFER_MANY; k++) { m++; } } -JOM(4, "easysnd_delete(): isoc audio buffers freed: %i pages\n", \ +JOM(4, "easyoss_delete(): isoc audio buffers freed: %i pages\n", \ m * (0x01 << AUDIO_ISOC_ORDER)); /*---------------------------------------------------------------------------*/ +#if !defined(EASYCAP_NEEDS_ALSA) JOM(4, "freeing audio buffers.\n"); gone = 0; for (k = 0; k < peasycap->audio_buffer_page_many; k++) { @@ -1068,7 +1034,8 @@ for (k = 0; k < peasycap->audio_buffer_page_many; k++) { gone++; } } -JOM(4, "easysnd_delete(): audio buffers freed: %i pages\n", gone); +JOM(4, "easyoss_delete(): audio buffers freed: %i pages\n", gone); +#endif /*!EASYCAP_NEEDS_ALSA*/ /*---------------------------------------------------------------------------*/ JOM(4, "freeing easycap structure.\n"); allocation_video_urb = peasycap->allocation_video_urb; @@ -1081,12 +1048,20 @@ allocation_audio_struct = peasycap->allocation_audio_struct; registered_audio = peasycap->registered_audio; kfree(peasycap); + if (0 <= kd && DONGLE_MANY > kd) { - easycap_dongle[kd].peasycap = (struct easycap *)NULL; - JOT(4, " null-->easycap_dongle[%i].peasycap\n", kd); - allocation_video_struct -= sizeof(struct easycap); + if (mutex_lock_interruptible(&mutex_dongle)) { + SAY("ERROR: cannot down mutex_dongle\n"); + } else { + JOM(4, "locked mutex_dongle\n"); + easycapdc60_dongle[kd].peasycap = (struct easycap *)NULL; + mutex_unlock(&mutex_dongle); + JOM(4, "unlocked mutex_dongle\n"); + JOT(4, " null-->easycapdc60_dongle[%i].peasycap\n", kd); + allocation_video_struct -= sizeof(struct easycap); + } } else { - SAY("ERROR: cannot purge easycap_dongle[].peasycap"); + SAY("ERROR: cannot purge easycapdc60_dongle[].peasycap"); } /*---------------------------------------------------------------------------*/ SAY("%8i= video urbs after all deletions\n", allocation_video_urb); @@ -1131,11 +1106,12 @@ if (NULL == peasycap->pusb_device) { /*---------------------------------------------------------------------------*/ kd = isdongle(peasycap); if (0 <= kd && DONGLE_MANY > kd) { - if (mutex_lock_interruptible(&easycap_dongle[kd].mutex_video)) { - SAY("ERROR: cannot down easycap_dongle[%i].mutex_video\n", kd); + if (mutex_lock_interruptible(&easycapdc60_dongle[kd].mutex_video)) { + SAY("ERROR: cannot down " + "easycapdc60_dongle[%i].mutex_video\n", kd); return -ERESTARTSYS; } - JOM(4, "locked easycap_dongle[%i].mutex_video\n", kd); + JOM(4, "locked easycapdc60_dongle[%i].mutex_video\n", kd); /*-------------------------------------------------------------------*/ /* * MEANWHILE, easycap_usb_disconnect() MAY HAVE FREED POINTER @@ -1147,24 +1123,24 @@ if (0 <= kd && DONGLE_MANY > kd) { return -ERESTARTSYS; if (NULL == file) { SAY("ERROR: file is NULL\n"); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -ERESTARTSYS; } peasycap = file->private_data; if (NULL == peasycap) { SAY("ERROR: peasycap is NULL\n"); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -ERESTARTSYS; } if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { SAY("ERROR: bad peasycap: 0x%08lX\n", \ (unsigned long int) peasycap); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -ERESTARTSYS; } if (NULL == peasycap->pusb_device) { SAM("ERROR: peasycap->pusb_device is NULL\n"); - mutex_unlock(&easycap_dongle[kd].mutex_video); + mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -ERESTARTSYS; } } else @@ -1179,7 +1155,7 @@ if (0 <= kd && DONGLE_MANY > kd) { /*---------------------------------------------------------------------------*/ rc = easycap_dqbuf(peasycap, 0); peasycap->polled = 1; -mutex_unlock(&easycap_dongle[kd].mutex_video); +mutex_unlock(&easycapdc60_dongle[kd].mutex_video); if (0 == rc) return POLLIN | POLLRDNORM; else @@ -3391,20 +3367,13 @@ return; /*****************************************************************************/ /*---------------------------------------------------------------------------*/ /* - * - * FIXME - * - * - * THIS FUNCTION ASSUMES THAT, ON EACH AND EVERY OCCASION THAT THE EasyCAP - * IS PHYSICALLY PLUGGED IN, INTERFACE 0 IS PROBED FIRST. - * IF THIS IS NOT TRUE, THERE IS THE POSSIBILITY OF AN Oops. - * - * THIS HAS NEVER BEEN A PROBLEM IN PRACTICE, BUT SOMETHING SEEMS WRONG HERE. + * WHEN THE EasyCAP IS PHYSICALLY PLUGGED IN, THIS FUNCTION IS CALLED THREE + * TIMES, ONCE FOR EACH OF THE THREE INTERFACES. BEWARE. */ /*---------------------------------------------------------------------------*/ int easycap_usb_probe(struct usb_interface *pusb_interface, \ - const struct usb_device_id *id) + const struct usb_device_id *pusb_device_id) { struct usb_device *pusb_device, *pusb_device1; struct usb_host_interface *pusb_host_interface; @@ -3413,6 +3382,7 @@ struct usb_interface_descriptor *pusb_interface_descriptor; struct usb_interface_assoc_descriptor *pusb_interface_assoc_descriptor; struct urb *purb; struct easycap *peasycap; +int ndong; struct data_urb *pdata_urb; size_t wMaxPacketSize; int ISOCwMaxPacketSize; @@ -3434,24 +3404,19 @@ int maxpacketsize; __u16 mask; __s32 value; struct easycap_format *peasycap_format; - -JOT(4, "\n"); - -if (!dongle_done) { - dongle_done = 1; - for (k = 0; k < DONGLE_MANY; k++) { - easycap_dongle[k].peasycap = (struct easycap *)NULL; - mutex_init(&easycap_dongle[k].mutex_video); - mutex_init(&easycap_dongle[k].mutex_audio); - } -} - -peasycap = (struct easycap *)NULL; +/*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ +#if defined(EASYCAP_IS_VIDEODEV_CLIENT) +#if defined(EASYCAP_NEEDS_V4L2_DEVICE_H) +struct v4l2_device *pv4l2_device; +#endif /*EASYCAP_NEEDS_V4L2_DEVICE_H*/ +#endif /*EASYCAP_IS_VIDEODEV_CLIENT*/ +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ if ((struct usb_interface *)NULL == pusb_interface) { SAY("ERROR: pusb_interface is NULL\n"); return -EFAULT; } +peasycap = (struct easycap *)NULL; /*---------------------------------------------------------------------------*/ /* * GET POINTER TO STRUCTURE usb_device @@ -3472,9 +3437,7 @@ if ((unsigned long int)pusb_device1 != (unsigned long int)pusb_device) { JOT(4, "ERROR: pusb_device1 != pusb_device\n"); return -EFAULT; } - JOT(4, "bNumConfigurations=%i\n", pusb_device->descriptor.bNumConfigurations); - /*---------------------------------------------------------------------------*/ pusb_host_interface = pusb_interface->cur_altsetting; if (NULL == pusb_host_interface) { @@ -3553,9 +3516,6 @@ JOT(4, "intf[%i]: pusb_interface_assoc_descriptor is NULL\n", \ * * THE POINTER peasycap TO THE struct easycap IS REMEMBERED WHEN * INTERFACES 1 AND 2 ARE PROBED. - * - * IF TWO EasyCAPs ARE PLUGGED IN NEARLY SIMULTANEOUSLY THERE WILL - * BE TROUBLE. BEWARE. */ /*---------------------------------------------------------------------------*/ if (0 == bInterfaceNumber) { @@ -3580,6 +3540,7 @@ if (0 == bInterfaceNumber) { * PERFORM URGENT INTIALIZATIONS ... */ /*---------------------------------------------------------------------------*/ + peasycap->minor = -1; strcpy(&peasycap->telltale[0], TELLTALE); kref_init(&peasycap->kref); JOM(8, "intf[%i]: after kref_init(..._video) " \ @@ -3588,29 +3549,43 @@ if (0 == bInterfaceNumber) { init_waitqueue_head(&peasycap->wq_video); init_waitqueue_head(&peasycap->wq_audio); + init_waitqueue_head(&peasycap->wq_trigger); - for (dongle_this = 0; dongle_this < DONGLE_MANY; dongle_this++) { - if (NULL == easycap_dongle[dongle_this].peasycap) { - if (0 == mutex_is_locked(&easycap_dongle\ - [dongle_this].mutex_video)) { - if (0 == mutex_is_locked(&easycap_dongle\ - [dongle_this].mutex_audio)) { - easycap_dongle\ - [dongle_this].peasycap = \ - peasycap; - JOM(8, "intf[%i]: peasycap-->easycap" \ + if (mutex_lock_interruptible(&mutex_dongle)) { + SAY("ERROR: cannot down mutex_dongle\n"); + return -ERESTARTSYS; + } else { +/*---------------------------------------------------------------------------*/ + /* + * FOR INTERFACES 1 AND 2 THE POINTER peasycap WILL NEED TO + * TO BE THE SAME AS THAT ALLOCATED NOW FOR INTERFACE 0. + * + * NORMALLY ndong WILL NOT HAVE CHANGED SINCE INTERFACE 0 WAS + * PROBED, BUT THIS MAY NOT BE THE CASE IF, FOR EXAMPLE, TWO + * EASYCAPs ARE PLUGGED IN SIMULTANEOUSLY. + */ +/*---------------------------------------------------------------------------*/ + for (ndong = 0; ndong < DONGLE_MANY; ndong++) { + if ((NULL == easycapdc60_dongle[ndong].peasycap) && \ + (!mutex_is_locked(&easycapdc60_dongle\ + [ndong].mutex_video)) && \ + (!mutex_is_locked(&easycapdc60_dongle\ + [ndong].mutex_audio))) { + easycapdc60_dongle[ndong].peasycap = peasycap; + peasycap->isdongle = ndong; + JOM(8, "intf[%i]: peasycap-->easycap" \ "_dongle[%i].peasycap\n", \ - bInterfaceNumber, dongle_this); - break; - } + bInterfaceNumber, ndong); + break; } } + if (DONGLE_MANY <= ndong) { + SAM("ERROR: too many dongles\n"); + mutex_unlock(&mutex_dongle); + return -ENOMEM; + } + mutex_unlock(&mutex_dongle); } - if (DONGLE_MANY <= dongle_this) { - SAM("ERROR: too many dongles\n"); - return -ENOMEM; - } - peasycap->allocation_video_struct = sizeof(struct easycap); peasycap->allocation_video_page = 0; peasycap->allocation_video_urb = 0; @@ -3778,26 +3753,56 @@ if (0 == bInterfaceNumber) { JOM(4, "finished initialization\n"); } else { /*---------------------------------------------------------------------------*/ - /* - * FOR INTERFACES 1 AND 2 THE POINTER peasycap IS OBTAINED BY ASSUMING - * THAT dongle_this HAS NOT CHANGED SINCE INTERFACE 0 WAS PROBED. IF - * THIS IS NOT THE CASE, FOR EXAMPLE WHEN TWO EASYCAPs ARE PLUGGED IN - * SIMULTANEOUSLY, THERE WILL BE SERIOUS TROUBLE. - */ +/* + * FIXME + * + * IDENTIFY THE APPROPRIATE POINTER peasycap FOR INTERFACES 1 AND 2. + * THE ADDRESS OF peasycap->pusb_device IS RELUCTANTLY USED FOR THIS PURPOSE. + */ /*---------------------------------------------------------------------------*/ - if ((0 > dongle_this) || (DONGLE_MANY <= dongle_this)) { - SAY("ERROR: bad dongle count\n"); - return -EFAULT; + for (ndong = 0; ndong < DONGLE_MANY; ndong++) { + if (pusb_device == easycapdc60_dongle[ndong].peasycap->\ + pusb_device) { + peasycap = easycapdc60_dongle[ndong].peasycap; + JOT(8, "intf[%i]: easycapdc60_dongle[%i].peasycap-->" \ + "peasycap\n", bInterfaceNumber, ndong); + break; + } } - peasycap = easycap_dongle[dongle_this].peasycap; -