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

staging/easycap: Improve hardware initialization

Sometimes at startup the video urbs consistently and persistently deliver
bad data, each video frame (not isoc frame) containing an excess of
precisely two bytes.  A brute-force cure implemented here is to
repeatedly reinitialize the registers of the SAA7113H chip and the
STK1160 USB bridge until good behaviour is obtained.
Signed-off-by: default avatarMike Thomas <rmthomas@sciolus.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent e68703cf
......@@ -44,10 +44,17 @@
/*---------------------------------------------------------------------------*/
/*
* THESE ARE FOR MAINTENANCE ONLY - NORMALLY UNDEFINED:
* THESE ARE NORMALLY DEFINED
*/
/*---------------------------------------------------------------------------*/
#define PATIENCE 500
#undef PREFER_NTSC
#define PERSEVERE
/*---------------------------------------------------------------------------*/
/*
* THESE ARE FOR MAINTENANCE ONLY - NORMALLY UNDEFINED:
*/
/*---------------------------------------------------------------------------*/
#undef EASYCAP_TESTCARD
#undef EASYCAP_TESTTONE
#undef NOREADBACK
......@@ -122,7 +129,7 @@
#define USB_SKEL_MINOR_BASE 192
#define DONGLE_MANY 8
#define INPUT_MANY 6
/*---------------------------------------------------------------------------*/
/*
* DEFAULT LUMINANCE, CONTRAST, SATURATION AND HUE
......@@ -146,6 +153,7 @@
#if (USB_2_0_MAXPACKETSIZE > PAGE_SIZE)
#error video_isoc_buffer[.] will not be big enough
#endif
#define VIDEO_JUNK_TOLERATE VIDEO_ISOC_BUFFER_MANY
/*---------------------------------------------------------------------------*/
/*
* VIDEO BUFFERS
......@@ -238,6 +246,7 @@ struct list_head list_head;
void *pgo;
void *pto;
__u16 kount;
__u16 input;
};
/*---------------------------------------------------------------------------*/
struct data_urb {
......@@ -256,6 +265,22 @@ __u16 mask;
char name[128];
struct v4l2_format v4l2_format;
};
struct inputset {
int input;
int input_ok;
int standard_offset;
int standard_offset_ok;
int format_offset;
int format_offset_ok;
int brightness;
int brightness_ok;
int contrast;
int contrast_ok;
int saturation;
int saturation_ok;
int hue;
int hue_ok;
};
/*---------------------------------------------------------------------------*/
/*
* easycap.ilk == 0 => CVBS+S-VIDEO HARDWARE, AUDIO wMaxPacketSize=256
......@@ -274,7 +299,7 @@ struct v4l2_device v4l2_device;
#endif /*EASYCAP_NEEDS_V4L2_DEVICE_H*/
#endif /*EASYCAP_IS_VIDEODEV_CLIENT*/
/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
int status;
unsigned int audio_pages_per_fragment;
unsigned int audio_bytes_per_fragment;
unsigned int audio_buffer_page_many;
......@@ -302,7 +327,9 @@ int input;
int polled;
int standard_offset;
int format_offset;
struct inputset inputset[INPUT_MANY];
bool ntsc;
int fps;
int usec;
int tolerate;
......@@ -480,6 +507,8 @@ int redaub(struct easycap *, void *, void *, \
int, int, __u8, __u8, bool);
void easycap_testcard(struct easycap *, int);
int fillin_formats(void);
int reset(struct easycap *);
int newinput(struct easycap *, int);
int adjust_standard(struct easycap *, v4l2_std_id);
int adjust_format(struct easycap *, __u32, __u32, __u32, \
int, bool);
......@@ -517,11 +546,11 @@ int wakeup_device(struct usb_device *);
int confirm_resolution(struct usb_device *);
int confirm_stream(struct usb_device *);
int setup_stk(struct usb_device *);
int setup_saa(struct usb_device *);
int setup_stk(struct usb_device *, bool);
int setup_saa(struct usb_device *, bool);
int setup_vt(struct usb_device *);
int check_stk(struct usb_device *);
int check_saa(struct usb_device *);
int check_stk(struct usb_device *, bool);
int check_saa(struct usb_device *, bool);
int ready_saa(struct usb_device *);
int merit_saa(struct usb_device *);
int check_vt(struct usb_device *);
......@@ -539,10 +568,6 @@ int stop_100(struct usb_device *);
int write_300(struct usb_device *);
int read_vt(struct usb_device *, __u16);
int write_vt(struct usb_device *, __u16, __u16);
int set2to78(struct usb_device *);
int set2to93(struct usb_device *);
int regset(struct usb_device *, __u16, __u16);
int regget(struct usb_device *, __u16, void *);
int isdongle(struct easycap *);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -638,11 +638,6 @@ if ((struct usb_device *)NULL == peasycap->pusb_device) {
SAM("ERROR: peasycap->pusb_device has become NULL\n");
return -EFAULT;
}
rc = adjust_volume(peasycap, -8192);
if (0 != rc) {
SAM("ERROR: adjust_volume(default) returned %i\n", rc);
return -EFAULT;
}
/*---------------------------------------------------------------------------*/
if ((struct usb_device *)NULL == peasycap->pusb_device) {
SAM("ERROR: peasycap->pusb_device has become NULL\n");
......@@ -653,26 +648,20 @@ rc = usb_set_interface(peasycap->pusb_device, peasycap->audio_interface, \
JOM(8, "usb_set_interface(.,%i,%i) returned %i\n", peasycap->audio_interface, \
peasycap->audio_altsetting_on, rc);
if ((struct usb_device *)NULL == peasycap->pusb_device) {
SAM("ERROR: peasycap->pusb_device has become NULL\n");
return -EFAULT;
}
rc = wakeup_device(peasycap->pusb_device);
if (0 == rc)
JOM(8, "wakeup_device() returned %i\n", rc);
else
JOM(8, "easysnd open(): ERROR: wakeup_device() returned %i\n", rc);
JOM(8, "ERROR: wakeup_device() returned %i\n", rc);
if ((struct usb_device *)NULL == peasycap->pusb_device) {
SAM("ERROR: peasycap->pusb_device has become NULL\n");
return -EFAULT;
}
submit_audio_urbs(peasycap);
peasycap->audio_eof = 0;
peasycap->audio_idle = 0;
peasycap->timeval1.tv_sec = 0;
peasycap->timeval1.tv_usec = 0;
submit_audio_urbs(peasycap);
JOM(4, "finished initialization\n");
return 0;
}
......@@ -764,7 +753,6 @@ while ((fragment == (peasycap->audio_fill / \
JOM(8, "returning 0 because %i=audio_eof\n", \
peasycap->audio_eof);
kill_audio_urbs(peasycap);
msleep(500);
return 0;
}
if (peasycap->audio_idle) {
......
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