aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/easycap/easycap_sound.c
diff options
context:
space:
mode:
authorMike Thomas <rmthomas@sciolus.org>2010-11-07 15:11:36 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2010-11-09 19:31:16 -0500
commit268dfede46e24eef55a2ef7a10a462617936771e (patch)
tree18887c7c87c3c5a512a1fbd55530bf7cf2716e50 /drivers/staging/easycap/easycap_sound.c
parentae59dad4fef271222d65ac6afe2889eb12ea6ca9 (diff)
staging/easycap: Improve interface to the videodev module
The changes here represent an intermediate step towards bringing the driver within the V4L2 framework. Signed-off-by: Mike Thomas <rmthomas@sciolus.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/easycap/easycap_sound.c')
-rw-r--r--drivers/staging/easycap/easycap_sound.c63
1 files changed, 61 insertions, 2 deletions
diff --git a/drivers/staging/easycap/easycap_sound.c b/drivers/staging/easycap/easycap_sound.c
index dc97516cca4..24d8bb4e449 100644
--- a/drivers/staging/easycap/easycap_sound.c
+++ b/drivers/staging/easycap/easycap_sound.c
@@ -64,6 +64,11 @@ if (NULL == peasycap) {
64 SAY("ERROR: peasycap is NULL\n"); 64 SAY("ERROR: peasycap is NULL\n");
65 return; 65 return;
66} 66}
67if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) {
68 SAY("ERROR: bad peasycap\n");
69 return;
70}
71
67much = 0; 72much = 0;
68 73
69if (peasycap->audio_idle) { 74if (peasycap->audio_idle) {
@@ -595,6 +600,13 @@ easysnd_open(struct inode *inode, struct file *file)
595struct usb_interface *pusb_interface; 600struct usb_interface *pusb_interface;
596struct easycap *peasycap; 601struct easycap *peasycap;
597int subminor, rc; 602int subminor, rc;
603/*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
604#if defined(EASYCAP_IS_VIDEODEV_CLIENT)
605#if defined(EASYCAP_NEEDS_V4L2_DEVICE_H)
606struct v4l2_device *pv4l2_device;
607#endif /*EASYCAP_NEEDS_V4L2_DEVICE_H*/
608#endif /*EASYCAP_IS_VIDEODEV_CLIENT*/
609/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
598 610
599JOT(4, "begins\n"); 611JOT(4, "begins\n");
600 612
@@ -612,6 +624,39 @@ if (NULL == peasycap) {
612 SAY("ending unsuccessfully\n"); 624 SAY("ending unsuccessfully\n");
613 return -1; 625 return -1;
614} 626}
627/*---------------------------------------------------------------------------*/
628#if (!defined(EASYCAP_IS_VIDEODEV_CLIENT))
629#
630/*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
631#else
632#if defined(EASYCAP_NEEDS_V4L2_DEVICE_H)
633/*---------------------------------------------------------------------------*/
634/*
635 * SOME VERSIONS OF THE videodev MODULE OVERWRITE THE DATA WHICH HAS
636 * BEEN WRITTEN BY THE CALL TO usb_set_intfdata() IN easycap_usb_probe(),
637 * REPLACING IT WITH A POINTER TO THE EMBEDDED v4l2_device STRUCTURE.
638 * TO DETECT THIS, THE STRING IN THE easycap.telltale[] BUFFER IS CHECKED.
639*/
640/*---------------------------------------------------------------------------*/
641if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) {
642 pv4l2_device = usb_get_intfdata(pusb_interface);
643 if ((struct v4l2_device *)NULL == pv4l2_device) {
644 SAY("ERROR: pv4l2_device is NULL\n");
645 return -EFAULT;
646 }
647 peasycap = (struct easycap *) \
648 container_of(pv4l2_device, struct easycap, v4l2_device);
649}
650#endif /*EASYCAP_NEEDS_V4L2_DEVICE_H*/
651#
652#endif /*EASYCAP_IS_VIDEODEV_CLIENT*/
653/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
654/*---------------------------------------------------------------------------*/
655if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) {
656 SAY("ERROR: bad peasycap: 0x%08lX\n", (unsigned long int) peasycap);
657 return -EFAULT;
658}
659/*---------------------------------------------------------------------------*/
615 660
616file->private_data = peasycap; 661file->private_data = peasycap;
617 662
@@ -624,7 +669,7 @@ JOM(4, "starting initialization\n");
624 669
625if ((struct usb_device *)NULL == peasycap->pusb_device) { 670if ((struct usb_device *)NULL == peasycap->pusb_device) {
626 SAM("ERROR: peasycap->pusb_device is NULL\n"); 671 SAM("ERROR: peasycap->pusb_device is NULL\n");
627 return -EFAULT; 672 return -ENODEV;
628} 673}
629JOM(16, "0x%08lX=peasycap->pusb_device\n", (long int)peasycap->pusb_device); 674JOM(16, "0x%08lX=peasycap->pusb_device\n", (long int)peasycap->pusb_device);
630 675
@@ -641,7 +686,7 @@ if ((struct usb_device *)NULL == peasycap->pusb_device) {
641/*---------------------------------------------------------------------------*/ 686/*---------------------------------------------------------------------------*/
642if ((struct usb_device *)NULL == peasycap->pusb_device) { 687if ((struct usb_device *)NULL == peasycap->pusb_device) {
643 SAM("ERROR: peasycap->pusb_device has become NULL\n"); 688 SAM("ERROR: peasycap->pusb_device has become NULL\n");
644 return -EFAULT; 689 return -ENODEV;
645} 690}
646rc = usb_set_interface(peasycap->pusb_device, peasycap->audio_interface, \ 691rc = usb_set_interface(peasycap->pusb_device, peasycap->audio_interface, \
647 peasycap->audio_altsetting_on); 692 peasycap->audio_altsetting_on);
@@ -678,6 +723,10 @@ if (NULL == peasycap) {
678 SAY("ERROR: peasycap is NULL.\n"); 723 SAY("ERROR: peasycap is NULL.\n");
679 return -EFAULT; 724 return -EFAULT;
680} 725}
726if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) {
727 SAY("ERROR: bad peasycap: 0x%08lX\n", (unsigned long int) peasycap);
728 return -EFAULT;
729}
681if (0 != kill_audio_urbs(peasycap)) { 730if (0 != kill_audio_urbs(peasycap)) {
682 SAM("ERROR: kill_audio_urbs() failed\n"); 731 SAM("ERROR: kill_audio_urbs() failed\n");
683 return -EFAULT; 732 return -EFAULT;
@@ -722,6 +771,10 @@ if (NULL == peasycap) {
722 SAY("ERROR in easysnd_read(): peasycap is NULL\n"); 771 SAY("ERROR in easysnd_read(): peasycap is NULL\n");
723 return -EFAULT; 772 return -EFAULT;
724} 773}
774if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) {
775 SAY("ERROR: bad peasycap: 0x%08lX\n", (unsigned long int) peasycap);
776 return -EFAULT;
777}
725if (NULL == peasycap->pusb_device) { 778if (NULL == peasycap->pusb_device) {
726 SAY("ERROR in easysnd_read(): peasycap->pusb_device is NULL\n"); 779 SAY("ERROR in easysnd_read(): peasycap->pusb_device is NULL\n");
727 return -EFAULT; 780 return -EFAULT;
@@ -753,6 +806,12 @@ if (0 <= kd && DONGLE_MANY > kd) {
753 mutex_unlock(&easycap_dongle[kd].mutex_audio); 806 mutex_unlock(&easycap_dongle[kd].mutex_audio);
754 return -ERESTARTSYS; 807 return -ERESTARTSYS;
755 } 808 }
809 if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) {
810 SAY("ERROR: bad peasycap: 0x%08lX\n", \
811 (unsigned long int) peasycap);
812 mutex_unlock(&easycap_dongle[kd].mutex_audio);
813 return -ERESTARTSYS;
814 }
756 if (NULL == peasycap->pusb_device) { 815 if (NULL == peasycap->pusb_device) {
757 SAM("ERROR: peasycap->pusb_device is NULL\n"); 816 SAM("ERROR: peasycap->pusb_device is NULL\n");
758 mutex_unlock(&easycap_dongle[kd].mutex_audio); 817 mutex_unlock(&easycap_dongle[kd].mutex_audio);