Skip to content

Commit

Permalink
V4L/DVB (11219): gspca - sq905: Optimize the resolution setting.
Browse files Browse the repository at this point in the history
Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Jean-Francois Moine authored and Mauro Carvalho Chehab committed Mar 30, 2009
1 parent f6b8332 commit 67e4542
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions drivers/media/video/gspca/sq905.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ MODULE_LICENSE("GPL");
struct sd {
struct gspca_dev gspca_dev; /* !! must be the first item */

const struct v4l2_pix_format *cap_mode;

/*
* Driver stuff
*/
Expand Down Expand Up @@ -218,6 +216,7 @@ static void sq905_dostream(struct work_struct *work)
int header_read; /* true if we have already read the frame header. */
int discarding; /* true if we failed to get space for frame. */
int packet_type;
int frame_sz;
int ret;
u8 *data;
u8 *buffer;
Expand All @@ -229,6 +228,9 @@ static void sq905_dostream(struct work_struct *work)
goto quit_stream;
}

frame_sz = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].sizeimage
+ FRAME_HEADER_LEN;

while (gspca_dev->present && gspca_dev->streaming) {
/* Need a short delay to ensure streaming flag was set by
* gspca and to make sure gspca can grab the mutex. */
Expand All @@ -237,7 +239,7 @@ static void sq905_dostream(struct work_struct *work)

/* request some data and then read it until we have
* a complete frame. */
bytes_left = dev->cap_mode->sizeimage + FRAME_HEADER_LEN;
bytes_left = frame_sz;
header_read = 0;
discarding = 0;

Expand Down Expand Up @@ -367,21 +369,18 @@ static int sd_start(struct gspca_dev *gspca_dev)
struct sd *dev = (struct sd *) gspca_dev;
int ret;

/* Set capture mode based on selected resolution. */
dev->cap_mode = gspca_dev->cam.cam_mode;
/* "Open the shutter" and set size, to start capture */
switch (gspca_dev->width) {
case 640:
switch (gspca_dev->curr_mode) {
default:
/* case 2: */
PDEBUG(D_STREAM, "Start streaming at high resolution");
dev->cap_mode += 2;
ret = sq905_command(&dev->gspca_dev, SQ905_CAPTURE_HIGH);
break;
case 320:
case 1:
PDEBUG(D_STREAM, "Start streaming at medium resolution");
dev->cap_mode++;
ret = sq905_command(&dev->gspca_dev, SQ905_CAPTURE_MED);
break;
default:
case 0:
PDEBUG(D_STREAM, "Start streaming at low resolution");
ret = sq905_command(&dev->gspca_dev, SQ905_CAPTURE_LOW);
}
Expand Down

0 comments on commit 67e4542

Please sign in to comment.