From 67e4542558ee589a5196a29640de1ba1157fb450 Mon Sep 17 00:00:00 2001 From: Jean-Francois Moine Date: Thu, 26 Mar 2009 05:03:13 -0300 Subject: [PATCH] V4L/DVB (11219): gspca - sq905: Optimize the resolution setting. Signed-off-by: Jean-Francois Moine Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/gspca/sq905.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/media/video/gspca/sq905.c b/drivers/media/video/gspca/sq905.c index b1d377e495c..04e3ae57a2e 100644 --- a/drivers/media/video/gspca/sq905.c +++ b/drivers/media/video/gspca/sq905.c @@ -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 */ @@ -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; @@ -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. */ @@ -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; @@ -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); } -- 2.41.1