Commit e68703cf authored by Mike Thomas's avatar Mike Thomas Committed by Greg Kroah-Hartman

staging/easycap: Make code re-entrant

In order to allow multiple EasyCAP dongles to operate simultaneously
without mutual interference all static variables have been eliminated
except for a persistent inventory of plugged-in dongles at module level.
Signed-off-by: default avatarMike Thomas <rmthomas@sciolus.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent ce36ceda
...@@ -121,7 +121,7 @@ ...@@ -121,7 +121,7 @@
#define EASYCAP_DRIVER_DESCRIPTION "easycapdc60" #define EASYCAP_DRIVER_DESCRIPTION "easycapdc60"
#define USB_SKEL_MINOR_BASE 192 #define USB_SKEL_MINOR_BASE 192
#define VIDEO_DEVICE_MANY 8 #define DONGLE_MANY 8
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* /*
...@@ -264,6 +264,17 @@ struct v4l2_format v4l2_format; ...@@ -264,6 +264,17 @@ struct v4l2_format v4l2_format;
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
struct easycap { struct easycap {
int isdongle;
/*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
#if defined(EASYCAP_IS_VIDEODEV_CLIENT)
struct video_device video_device;
#if defined(EASYCAP_NEEDS_V4L2_DEVICE_H)
struct v4l2_device v4l2_device;
#endif /*EASYCAP_NEEDS_V4L2_DEVICE_H*/
#endif /*EASYCAP_IS_VIDEODEV_CLIENT*/
/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
unsigned int audio_pages_per_fragment; unsigned int audio_pages_per_fragment;
unsigned int audio_bytes_per_fragment; unsigned int audio_bytes_per_fragment;
unsigned int audio_buffer_page_many; unsigned int audio_buffer_page_many;
...@@ -276,12 +287,6 @@ __s16 oldaudio; ...@@ -276,12 +287,6 @@ __s16 oldaudio;
int ilk; int ilk;
bool microphone; bool microphone;
/*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
#if defined(EASYCAP_IS_VIDEODEV_CLIENT)
struct video_device *pvideo_device;
#endif /*EASYCAP_IS_VIDEODEV_CLIENT*/
/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
struct usb_device *pusb_device; struct usb_device *pusb_device;
struct usb_interface *pusb_interface; struct usb_interface *pusb_interface;
...@@ -306,7 +311,10 @@ int merit[180]; ...@@ -306,7 +311,10 @@ int merit[180];
struct timeval timeval0; struct timeval timeval0;
struct timeval timeval1; struct timeval timeval1;
struct timeval timeval2; struct timeval timeval2;
struct timeval timeval3;
struct timeval timeval6;
struct timeval timeval7; struct timeval timeval7;
struct timeval timeval8;
long long int dnbydt; long long int dnbydt;
int video_interface; int video_interface;
...@@ -332,6 +340,13 @@ struct data_buffer \ ...@@ -332,6 +340,13 @@ struct data_buffer \
struct list_head urb_video_head; struct list_head urb_video_head;
struct list_head *purb_video_head; struct list_head *purb_video_head;
__u8 cache[8];
__u8 *pcache;
int video_mt;
int audio_mt;
long long audio_bytes;
__u32 isequence;
int vma_many; int vma_many;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
...@@ -530,6 +545,7 @@ int set2to93(struct usb_device *); ...@@ -530,6 +545,7 @@ int set2to93(struct usb_device *);
int regset(struct usb_device *, __u16, __u16); int regset(struct usb_device *, __u16, __u16);
int regget(struct usb_device *, __u16, void *); int regget(struct usb_device *, __u16, void *);
int isdongle(struct easycap *);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
struct signed_div_result { struct signed_div_result {
long long int quotient; long long int quotient;
...@@ -557,20 +573,39 @@ unsigned long long int remainder; ...@@ -557,20 +573,39 @@ unsigned long long int remainder;
} \ } \
} while (0) } while (0)
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/*
* MACROS SAM(...) AND JOM(...) ALLOW DIAGNOSTIC OUTPUT TO BE TAGGED WITH
* THE IDENTITY OF THE DONGLE TO WHICH IT APPLIES, BUT IF INVOKED WHEN THE
* POINTER peasycap IS INVALID AN Oops IS LIKELY, AND ITS CAUSE MAY NOT BE
* IMMEDIATELY OBVIOUS FROM A CASUAL READING OF THE SOURCE CODE. BEWARE.
*/
/*---------------------------------------------------------------------------*/
#define SAY(format, args...) do { \ #define SAY(format, args...) do { \
printk(KERN_DEBUG "easycap: %s: " format, __func__, ##args); \ printk(KERN_DEBUG "easycap:: %s: " \
format, __func__, ##args); \
} while (0)
#define SAM(format, args...) do { \
printk(KERN_DEBUG "easycap::%i%s: " \
format, peasycap->isdongle, __func__, ##args);\
} while (0) } while (0)
#if defined(EASYCAP_DEBUG) #if defined(EASYCAP_DEBUG)
#define JOT(n, format, args...) do { \ #define JOT(n, format, args...) do { \
if (n <= debug) { \ if (n <= debug) { \
printk(KERN_DEBUG "easycap: %s: " format, __func__, ##args); \ printk(KERN_DEBUG "easycap:: %s: " \
format, __func__, ##args);\
} \ } \
} while (0) } while (0)
#define JOM(n, format, args...) do { \
if (n <= debug) { \
printk(KERN_DEBUG "easycap::%i%s: " \
format, peasycap->isdongle, __func__, ##args);\
} \
} while (0)
#else #else
#define JOT(n, format, args...) do {} while (0) #define JOT(n, format, args...) do {} while (0)
#define JOM(n, format, args...) do {} while (0)
#endif /*EASYCAP_DEBUG*/ #endif /*EASYCAP_DEBUG*/
#define MICROSECONDS(X, Y) \ #define MICROSECONDS(X, Y) \
......
/***************************************************************************** /*****************************************************************************
* * * *
* debug.h * * easycap_debug.h *
* * * *
*****************************************************************************/ *****************************************************************************/
/* /*
......
This diff is collapsed.
...@@ -783,6 +783,12 @@ return usb_control_msg(pusb_device, usb_sndctrlpipe(pusb_device, 0), \ ...@@ -783,6 +783,12 @@ return usb_control_msg(pusb_device, usb_sndctrlpipe(pusb_device, 0), \
(int)50000); (int)50000);
} }
/*****************************************************************************/ /*****************************************************************************/
int
audio_setup(struct easycap *peasycap)
{
struct usb_device *pusb_device;
unsigned char buffer[1];
int rc, id1, id2;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* /*
* IMPORTANT: * IMPORTANT:
...@@ -791,20 +797,12 @@ return usb_control_msg(pusb_device, usb_sndctrlpipe(pusb_device, 0), \ ...@@ -791,20 +797,12 @@ return usb_control_msg(pusb_device, usb_sndctrlpipe(pusb_device, 0), \
* TO ENABLE AUDIO THE VALUE 0x0200 MUST BE SENT. * TO ENABLE AUDIO THE VALUE 0x0200 MUST BE SENT.
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int const __u8 request = 0x01;
audio_setup(struct easycap *peasycap) const __u8 requesttype = \
{
struct usb_device *pusb_device;
static __u8 request = 0x01;
static __u8 requesttype = \
(__u8)(USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE); (__u8)(USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE);
const __u16 value_unmute = 0x0200;
static __u16 value_unmute = 0x0200; const __u16 index = 0x0301;
static __u16 index = 0x0301; const __u16 length = 1;
static unsigned char buffer[1];
static __u16 length = 1;
int rc, id1, id2;
if (NULL == peasycap) if (NULL == peasycap)
return -EFAULT; return -EFAULT;
......
This diff is collapsed.
This diff is collapsed.
...@@ -157,7 +157,7 @@ for (i1 = 0; i1 <= last; i1++) ...@@ -157,7 +157,7 @@ for (i1 = 0; i1 <= last; i1++)
printf("%6i, ", i2); printf("%6i\n};\n", i2); printf("%6i, ", i2); printf("%6i\n};\n", i2);
} }
} }
return(0); return 0;
} }
-----------------------------------------------------------------------------*/ -----------------------------------------------------------------------------*/
int tones[2048] = { int tones[2048] = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment