Commit 4aa0d037 authored by Jean-Francois Moine's avatar Jean-Francois Moine Committed by Mauro Carvalho Chehab

V4L/DVB (8154): Fix protection problems in the main driver.

- Protect format change when streaming active.
- Protect USB exchanges on close.
- Set a timeout in frame wait.
- Have only one capture file and free the resources when closing this file.
- Simplify the URB buffer.
- Don't reset the control values at open time in pac207.
- Fix compilation warnings of stk014.
Signed-off-by: default avatarJean-Francois Moine <moinejf@free.fr>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent e2997a72
This diff is collapsed.
...@@ -108,11 +108,6 @@ struct sd_desc { ...@@ -108,11 +108,6 @@ struct sd_desc {
cam_qmnu_op querymenu; cam_qmnu_op querymenu;
}; };
struct gspca_pktbuf {
char *data;
struct urb *urb;
};
/* packet types when moving from iso buf to frame buf */ /* packet types when moving from iso buf to frame buf */
#define DISCARD_PACKET 0 #define DISCARD_PACKET 0
#define FIRST_PACKET 1 #define FIRST_PACKET 1
...@@ -121,7 +116,7 @@ struct gspca_pktbuf { ...@@ -121,7 +116,7 @@ struct gspca_pktbuf {
struct gspca_frame { struct gspca_frame {
unsigned char *data; /* frame buffer */ unsigned char *data; /* frame buffer */
unsigned char *data_end; /* current end of frame while filling */ unsigned char *data_end; /* end of frame while filling */
int vma_use_count; int vma_use_count;
struct v4l2_buffer v4l2_buf; struct v4l2_buffer v4l2_buf;
}; };
...@@ -129,11 +124,12 @@ struct gspca_frame { ...@@ -129,11 +124,12 @@ struct gspca_frame {
struct gspca_dev { struct gspca_dev {
struct video_device vdev; /* !! must be the first item */ struct video_device vdev; /* !! must be the first item */
struct usb_device *dev; struct usb_device *dev;
struct file *capt_file; /* file doing video capture */
struct cam cam; /* device information */ struct cam cam; /* device information */
const struct sd_desc *sd_desc; /* subdriver description */ const struct sd_desc *sd_desc; /* subdriver description */
struct gspca_pktbuf pktbuf[NURBS]; struct urb *urb[NURBS];
__u8 *frbuf; /* buffer for nframes */ __u8 *frbuf; /* buffer for nframes */
struct gspca_frame frame[GSPCA_MAX_FRAMES]; struct gspca_frame frame[GSPCA_MAX_FRAMES];
...@@ -147,7 +143,7 @@ struct gspca_dev { ...@@ -147,7 +143,7 @@ struct gspca_dev {
__u8 iface; /* USB interface number */ __u8 iface; /* USB interface number */
__u8 alt; /* USB alternate setting */ __u8 alt; /* USB alternate setting */
char curr_mode; /* current camera mode */ unsigned char curr_mode; /* current camera mode */
__u32 pixfmt; /* current mode parameters */ __u32 pixfmt; /* current mode parameters */
short width; short width;
short height; short height;
...@@ -158,7 +154,7 @@ struct gspca_dev { ...@@ -158,7 +154,7 @@ struct gspca_dev {
struct mutex read_lock; /* read protection */ struct mutex read_lock; /* read protection */
struct mutex queue_lock; /* ISOC queue protection */ struct mutex queue_lock; /* ISOC queue protection */
__u32 sequence; /* frame sequence number */ __u32 sequence; /* frame sequence number */
signed char streaming; char streaming;
char users; /* # open */ char users; /* # open */
char present; /* device connected */ char present; /* device connected */
char nbufread; /* number of buffers for read() */ char nbufread; /* number of buffers for read() */
......
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
#include "gspca.h" #include "gspca.h"
#define DRIVER_VERSION_NUMBER KERNEL_VERSION(0, 0, 30) #define DRIVER_VERSION_NUMBER KERNEL_VERSION(0, 1, 1)
static const char version[] = "0.0.30"; static const char version[] = "0.1.1";
MODULE_AUTHOR("Hans de Goede <j.w.r.degoede@hhs.nl>"); MODULE_AUTHOR("Hans de Goede <j.w.r.degoede@hhs.nl>");
MODULE_DESCRIPTION("Pixart PAC207"); MODULE_DESCRIPTION("Pixart PAC207");
...@@ -251,6 +251,7 @@ int pac207_read_reg(struct gspca_dev *gspca_dev, u16 index) ...@@ -251,6 +251,7 @@ int pac207_read_reg(struct gspca_dev *gspca_dev, u16 index)
static int sd_config(struct gspca_dev *gspca_dev, static int sd_config(struct gspca_dev *gspca_dev,
const struct usb_device_id *id) const struct usb_device_id *id)
{ {
struct sd *sd = (struct sd *) gspca_dev;
struct cam *cam; struct cam *cam;
u8 idreg[2]; u8 idreg[2];
...@@ -282,6 +283,9 @@ static int sd_config(struct gspca_dev *gspca_dev, ...@@ -282,6 +283,9 @@ static int sd_config(struct gspca_dev *gspca_dev,
cam->epaddr = 0x05; cam->epaddr = 0x05;
cam->cam_mode = sif_mode; cam->cam_mode = sif_mode;
cam->nmodes = ARRAY_SIZE(sif_mode); cam->nmodes = ARRAY_SIZE(sif_mode);
sd->brightness = PAC207_BRIGHTNESS_DEFAULT;
sd->exposure = PAC207_EXPOSURE_DEFAULT;
sd->gain = PAC207_GAIN_DEFAULT;
return 0; return 0;
} }
...@@ -291,9 +295,6 @@ static int sd_open(struct gspca_dev *gspca_dev) ...@@ -291,9 +295,6 @@ static int sd_open(struct gspca_dev *gspca_dev)
{ {
struct sd *sd = (struct sd *) gspca_dev; struct sd *sd = (struct sd *) gspca_dev;
sd->brightness = PAC207_BRIGHTNESS_DEFAULT;
sd->exposure = PAC207_EXPOSURE_DEFAULT;
sd->gain = PAC207_GAIN_DEFAULT;
sd->autogain = 1; sd->autogain = 1;
return 0; return 0;
......
...@@ -24,8 +24,8 @@ ...@@ -24,8 +24,8 @@
#include "gspca.h" #include "gspca.h"
#include "jpeg.h" #include "jpeg.h"
#define DRIVER_VERSION_NUMBER KERNEL_VERSION(0, 0, 22) #define DRIVER_VERSION_NUMBER KERNEL_VERSION(0, 1, 0)
static const char version[] = "0.0.22"; static const char version[] = "0.1.0";
MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>"); MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>");
MODULE_DESCRIPTION("Syntek DV4000 (STK014) USB Camera Driver"); MODULE_DESCRIPTION("Syntek DV4000 (STK014) USB Camera Driver");
...@@ -390,6 +390,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, ...@@ -390,6 +390,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
int len) /* iso packet length */ int len) /* iso packet length */
{ {
int l; int l;
static unsigned char ffd9[] = {0xff, 0xd9};
/* a frame starts with: /* a frame starts with:
* - 0xff 0xfe * - 0xff 0xfe
...@@ -445,7 +446,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, ...@@ -445,7 +446,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
if (len > frame->v4l2_buf.bytesused - 2 - l) if (len > frame->v4l2_buf.bytesused - 2 - l)
len = frame->v4l2_buf.bytesused - 2 - l; len = frame->v4l2_buf.bytesused - 2 - l;
gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len);
gspca_frame_add(gspca_dev, LAST_PACKET, frame, "\xff\xd9", 2); gspca_frame_add(gspca_dev, LAST_PACKET, frame, ffd9, 2);
} }
static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
......
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