diff options
author | Jean-Francois Moine <moinejf@free.fr> | 2009-03-26 04:03:13 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-30 11:43:41 -0400 |
commit | 67e4542558ee589a5196a29640de1ba1157fb450 (patch) | |
tree | c15a0804b65c0bea1a63d31fe2d27813ed78bf53 /drivers/media/video/gspca/sq905.c | |
parent | f6b8332b5e90a8d9c42f224e60900c7eae474388 (diff) |
V4L/DVB (11219): gspca - sq905: Optimize the resolution setting.
Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/gspca/sq905.c')
-rw-r--r-- | drivers/media/video/gspca/sq905.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/drivers/media/video/gspca/sq905.c b/drivers/media/video/gspca/sq905.c index b1d377e495c2..04e3ae57a2e3 100644 --- a/drivers/media/video/gspca/sq905.c +++ b/drivers/media/video/gspca/sq905.c | |||
@@ -82,8 +82,6 @@ MODULE_LICENSE("GPL"); | |||
82 | struct sd { | 82 | struct sd { |
83 | struct gspca_dev gspca_dev; /* !! must be the first item */ | 83 | struct gspca_dev gspca_dev; /* !! must be the first item */ |
84 | 84 | ||
85 | const struct v4l2_pix_format *cap_mode; | ||
86 | |||
87 | /* | 85 | /* |
88 | * Driver stuff | 86 | * Driver stuff |
89 | */ | 87 | */ |
@@ -218,6 +216,7 @@ static void sq905_dostream(struct work_struct *work) | |||
218 | int header_read; /* true if we have already read the frame header. */ | 216 | int header_read; /* true if we have already read the frame header. */ |
219 | int discarding; /* true if we failed to get space for frame. */ | 217 | int discarding; /* true if we failed to get space for frame. */ |
220 | int packet_type; | 218 | int packet_type; |
219 | int frame_sz; | ||
221 | int ret; | 220 | int ret; |
222 | u8 *data; | 221 | u8 *data; |
223 | u8 *buffer; | 222 | u8 *buffer; |
@@ -229,6 +228,9 @@ static void sq905_dostream(struct work_struct *work) | |||
229 | goto quit_stream; | 228 | goto quit_stream; |
230 | } | 229 | } |
231 | 230 | ||
231 | frame_sz = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].sizeimage | ||
232 | + FRAME_HEADER_LEN; | ||
233 | |||
232 | while (gspca_dev->present && gspca_dev->streaming) { | 234 | while (gspca_dev->present && gspca_dev->streaming) { |
233 | /* Need a short delay to ensure streaming flag was set by | 235 | /* Need a short delay to ensure streaming flag was set by |
234 | * gspca and to make sure gspca can grab the mutex. */ | 236 | * gspca and to make sure gspca can grab the mutex. */ |
@@ -237,7 +239,7 @@ static void sq905_dostream(struct work_struct *work) | |||
237 | 239 | ||
238 | /* request some data and then read it until we have | 240 | /* request some data and then read it until we have |
239 | * a complete frame. */ | 241 | * a complete frame. */ |
240 | bytes_left = dev->cap_mode->sizeimage + FRAME_HEADER_LEN; | 242 | bytes_left = frame_sz; |
241 | header_read = 0; | 243 | header_read = 0; |
242 | discarding = 0; | 244 | discarding = 0; |
243 | 245 | ||
@@ -367,21 +369,18 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
367 | struct sd *dev = (struct sd *) gspca_dev; | 369 | struct sd *dev = (struct sd *) gspca_dev; |
368 | int ret; | 370 | int ret; |
369 | 371 | ||
370 | /* Set capture mode based on selected resolution. */ | ||
371 | dev->cap_mode = gspca_dev->cam.cam_mode; | ||
372 | /* "Open the shutter" and set size, to start capture */ | 372 | /* "Open the shutter" and set size, to start capture */ |
373 | switch (gspca_dev->width) { | 373 | switch (gspca_dev->curr_mode) { |
374 | case 640: | 374 | default: |
375 | /* case 2: */ | ||
375 | PDEBUG(D_STREAM, "Start streaming at high resolution"); | 376 | PDEBUG(D_STREAM, "Start streaming at high resolution"); |
376 | dev->cap_mode += 2; | ||
377 | ret = sq905_command(&dev->gspca_dev, SQ905_CAPTURE_HIGH); | 377 | ret = sq905_command(&dev->gspca_dev, SQ905_CAPTURE_HIGH); |
378 | break; | 378 | break; |
379 | case 320: | 379 | case 1: |
380 | PDEBUG(D_STREAM, "Start streaming at medium resolution"); | 380 | PDEBUG(D_STREAM, "Start streaming at medium resolution"); |
381 | dev->cap_mode++; | ||
382 | ret = sq905_command(&dev->gspca_dev, SQ905_CAPTURE_MED); | 381 | ret = sq905_command(&dev->gspca_dev, SQ905_CAPTURE_MED); |
383 | break; | 382 | break; |
384 | default: | 383 | case 0: |
385 | PDEBUG(D_STREAM, "Start streaming at low resolution"); | 384 | PDEBUG(D_STREAM, "Start streaming at low resolution"); |
386 | ret = sq905_command(&dev->gspca_dev, SQ905_CAPTURE_LOW); | 385 | ret = sq905_command(&dev->gspca_dev, SQ905_CAPTURE_LOW); |
387 | } | 386 | } |