diff options
author | Hans de Goede <hdegoede@redhat.com> | 2012-01-10 11:14:46 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-01-16 08:08:57 -0500 |
commit | 938d5b9e7c2e20a7e609ad5874c6e7d8d391e6e9 (patch) | |
tree | ccd8b97d63894834c3ee7778ce10491ca27edffc /drivers/media | |
parent | d167a85c5fb45b1ecdacdb9b7733833a9af78da8 (diff) |
[media] pwc: Avoid sending mode info to the camera when it is not needed
Since we always do a set_video_mode on stream start, there is no need
to actually send the mode info to the device on a s_fmt / s_parm ioctl.
Not doing this saves us doing (slow) usb io.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/pwc/pwc-ctrl.c | 29 | ||||
-rw-r--r-- | drivers/media/video/pwc/pwc-if.c | 6 | ||||
-rw-r--r-- | drivers/media/video/pwc/pwc-v4l.c | 4 | ||||
-rw-r--r-- | drivers/media/video/pwc/pwc.h | 2 |
4 files changed, 22 insertions, 19 deletions
diff --git a/drivers/media/video/pwc/pwc-ctrl.c b/drivers/media/video/pwc/pwc-ctrl.c index 51ab4c570d0b..9c1fb3f07dee 100644 --- a/drivers/media/video/pwc/pwc-ctrl.c +++ b/drivers/media/video/pwc/pwc-ctrl.c | |||
@@ -169,10 +169,10 @@ int send_control_msg(struct pwc_device *pdev, | |||
169 | } | 169 | } |
170 | 170 | ||
171 | static int set_video_mode_Nala(struct pwc_device *pdev, int size, int pixfmt, | 171 | static int set_video_mode_Nala(struct pwc_device *pdev, int size, int pixfmt, |
172 | int frames, int *compression) | 172 | int frames, int *compression, int send_to_cam) |
173 | { | 173 | { |
174 | unsigned char buf[3]; | 174 | unsigned char buf[3]; |
175 | int ret, fps; | 175 | int fps, ret = 0; |
176 | struct Nala_table_entry *pEntry; | 176 | struct Nala_table_entry *pEntry; |
177 | int frames2frames[31] = | 177 | int frames2frames[31] = |
178 | { /* closest match of framerate */ | 178 | { /* closest match of framerate */ |
@@ -207,7 +207,8 @@ static int set_video_mode_Nala(struct pwc_device *pdev, int size, int pixfmt, | |||
207 | return -EINVAL; | 207 | return -EINVAL; |
208 | 208 | ||
209 | memcpy(buf, pEntry->mode, 3); | 209 | memcpy(buf, pEntry->mode, 3); |
210 | ret = send_video_command(pdev, pdev->vendpoint, buf, 3); | 210 | if (send_to_cam) |
211 | ret = send_video_command(pdev, pdev->vendpoint, buf, 3); | ||
211 | if (ret < 0) { | 212 | if (ret < 0) { |
212 | PWC_DEBUG_MODULE("Failed to send video command... %d\n", ret); | 213 | PWC_DEBUG_MODULE("Failed to send video command... %d\n", ret); |
213 | return ret; | 214 | return ret; |
@@ -246,11 +247,11 @@ static int set_video_mode_Nala(struct pwc_device *pdev, int size, int pixfmt, | |||
246 | 247 | ||
247 | 248 | ||
248 | static int set_video_mode_Timon(struct pwc_device *pdev, int size, int pixfmt, | 249 | static int set_video_mode_Timon(struct pwc_device *pdev, int size, int pixfmt, |
249 | int frames, int *compression) | 250 | int frames, int *compression, int send_to_cam) |
250 | { | 251 | { |
251 | unsigned char buf[13]; | 252 | unsigned char buf[13]; |
252 | const struct Timon_table_entry *pChoose; | 253 | const struct Timon_table_entry *pChoose; |
253 | int ret, fps; | 254 | int fps, ret = 0; |
254 | 255 | ||
255 | if (size >= PSZ_MAX || *compression < 0 || *compression > 3) | 256 | if (size >= PSZ_MAX || *compression < 0 || *compression > 3) |
256 | return -EINVAL; | 257 | return -EINVAL; |
@@ -274,7 +275,8 @@ static int set_video_mode_Timon(struct pwc_device *pdev, int size, int pixfmt, | |||
274 | return -ENOENT; /* Not supported. */ | 275 | return -ENOENT; /* Not supported. */ |
275 | 276 | ||
276 | memcpy(buf, pChoose->mode, 13); | 277 | memcpy(buf, pChoose->mode, 13); |
277 | ret = send_video_command(pdev, pdev->vendpoint, buf, 13); | 278 | if (send_to_cam) |
279 | ret = send_video_command(pdev, pdev->vendpoint, buf, 13); | ||
278 | if (ret < 0) | 280 | if (ret < 0) |
279 | return ret; | 281 | return ret; |
280 | 282 | ||
@@ -300,10 +302,10 @@ static int set_video_mode_Timon(struct pwc_device *pdev, int size, int pixfmt, | |||
300 | 302 | ||
301 | 303 | ||
302 | static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int pixfmt, | 304 | static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int pixfmt, |
303 | int frames, int *compression) | 305 | int frames, int *compression, int send_to_cam) |
304 | { | 306 | { |
305 | const struct Kiara_table_entry *pChoose = NULL; | 307 | const struct Kiara_table_entry *pChoose = NULL; |
306 | int fps, ret; | 308 | int fps, ret = 0; |
307 | unsigned char buf[12]; | 309 | unsigned char buf[12]; |
308 | 310 | ||
309 | if (size >= PSZ_MAX || *compression < 0 || *compression > 3) | 311 | if (size >= PSZ_MAX || *compression < 0 || *compression > 3) |
@@ -332,7 +334,8 @@ static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int pixfmt, | |||
332 | memcpy(buf, pChoose->mode, 12); | 334 | memcpy(buf, pChoose->mode, 12); |
333 | 335 | ||
334 | /* Firmware bug: video endpoint is 5, but commands are sent to endpoint 4 */ | 336 | /* Firmware bug: video endpoint is 5, but commands are sent to endpoint 4 */ |
335 | ret = send_video_command(pdev, 4 /* pdev->vendpoint */, buf, 12); | 337 | if (send_to_cam) |
338 | ret = send_video_command(pdev, 4, buf, 12); | ||
336 | if (ret < 0) | 339 | if (ret < 0) |
337 | return ret; | 340 | return ret; |
338 | 341 | ||
@@ -358,7 +361,7 @@ static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int pixfmt, | |||
358 | } | 361 | } |
359 | 362 | ||
360 | int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, | 363 | int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, |
361 | int pixfmt, int frames, int *compression) | 364 | int pixfmt, int frames, int *compression, int send_to_cam) |
362 | { | 365 | { |
363 | int ret, size; | 366 | int ret, size; |
364 | 367 | ||
@@ -369,13 +372,13 @@ int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, | |||
369 | 372 | ||
370 | if (DEVICE_USE_CODEC1(pdev->type)) { | 373 | if (DEVICE_USE_CODEC1(pdev->type)) { |
371 | ret = set_video_mode_Nala(pdev, size, pixfmt, frames, | 374 | ret = set_video_mode_Nala(pdev, size, pixfmt, frames, |
372 | compression); | 375 | compression, send_to_cam); |
373 | } else if (DEVICE_USE_CODEC3(pdev->type)) { | 376 | } else if (DEVICE_USE_CODEC3(pdev->type)) { |
374 | ret = set_video_mode_Kiara(pdev, size, pixfmt, frames, | 377 | ret = set_video_mode_Kiara(pdev, size, pixfmt, frames, |
375 | compression); | 378 | compression, send_to_cam); |
376 | } else { | 379 | } else { |
377 | ret = set_video_mode_Timon(pdev, size, pixfmt, frames, | 380 | ret = set_video_mode_Timon(pdev, size, pixfmt, frames, |
378 | compression); | 381 | compression, send_to_cam); |
379 | } | 382 | } |
380 | if (ret < 0) { | 383 | if (ret < 0) { |
381 | PWC_ERROR("Failed to set video mode %s@%d fps; return code = %d\n", size2name[size], frames, ret); | 384 | PWC_ERROR("Failed to set video mode %s@%d fps; return code = %d\n", size2name[size], frames, ret); |
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c index 1f3386da05fa..23eaceea4862 100644 --- a/drivers/media/video/pwc/pwc-if.c +++ b/drivers/media/video/pwc/pwc-if.c | |||
@@ -385,8 +385,8 @@ static int pwc_isoc_init(struct pwc_device *pdev) | |||
385 | retry: | 385 | retry: |
386 | /* We first try with low compression and then retry with a higher | 386 | /* We first try with low compression and then retry with a higher |
387 | compression setting if there is not enough bandwidth. */ | 387 | compression setting if there is not enough bandwidth. */ |
388 | ret = pwc_set_video_mode(pdev, pdev->width, pdev->height, | 388 | ret = pwc_set_video_mode(pdev, pdev->width, pdev->height, pdev->pixfmt, |
389 | pdev->pixfmt, pdev->vframes, &compression); | 389 | pdev->vframes, &compression, 1); |
390 | 390 | ||
391 | /* Get the current alternate interface, adjust packet size */ | 391 | /* Get the current alternate interface, adjust packet size */ |
392 | intf = usb_ifnum_to_if(udev, 0); | 392 | intf = usb_ifnum_to_if(udev, 0); |
@@ -1129,7 +1129,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id | |||
1129 | 1129 | ||
1130 | /* Setup intial videomode */ | 1130 | /* Setup intial videomode */ |
1131 | rc = pwc_set_video_mode(pdev, MAX_WIDTH, MAX_HEIGHT, | 1131 | rc = pwc_set_video_mode(pdev, MAX_WIDTH, MAX_HEIGHT, |
1132 | V4L2_PIX_FMT_YUV420, 30, &compression); | 1132 | V4L2_PIX_FMT_YUV420, 30, &compression, 1); |
1133 | if (rc) | 1133 | if (rc) |
1134 | goto err_free_mem; | 1134 | goto err_free_mem; |
1135 | 1135 | ||
diff --git a/drivers/media/video/pwc/pwc-v4l.c b/drivers/media/video/pwc/pwc-v4l.c index b275fad2927b..46feece38852 100644 --- a/drivers/media/video/pwc/pwc-v4l.c +++ b/drivers/media/video/pwc/pwc-v4l.c | |||
@@ -493,7 +493,7 @@ static int pwc_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f) | |||
493 | (pixelformat>>24)&255); | 493 | (pixelformat>>24)&255); |
494 | 494 | ||
495 | ret = pwc_set_video_mode(pdev, f->fmt.pix.width, f->fmt.pix.height, | 495 | ret = pwc_set_video_mode(pdev, f->fmt.pix.width, f->fmt.pix.height, |
496 | pixelformat, 30, &compression); | 496 | pixelformat, 30, &compression, 0); |
497 | 497 | ||
498 | PWC_DEBUG_IOCTL("pwc_set_video_mode(), return=%d\n", ret); | 498 | PWC_DEBUG_IOCTL("pwc_set_video_mode(), return=%d\n", ret); |
499 | 499 | ||
@@ -1137,7 +1137,7 @@ static int pwc_s_parm(struct file *file, void *fh, | |||
1137 | } | 1137 | } |
1138 | 1138 | ||
1139 | ret = pwc_set_video_mode(pdev, pdev->width, pdev->height, pdev->pixfmt, | 1139 | ret = pwc_set_video_mode(pdev, pdev->width, pdev->height, pdev->pixfmt, |
1140 | fps, &compression); | 1140 | fps, &compression, 0); |
1141 | 1141 | ||
1142 | pwc_g_parm(file, fh, parm); | 1142 | pwc_g_parm(file, fh, parm); |
1143 | 1143 | ||
diff --git a/drivers/media/video/pwc/pwc.h b/drivers/media/video/pwc/pwc.h index 29b6d3dca83b..f441999e5bd1 100644 --- a/drivers/media/video/pwc/pwc.h +++ b/drivers/media/video/pwc/pwc.h | |||
@@ -369,7 +369,7 @@ void pwc_construct(struct pwc_device *pdev); | |||
369 | /** Functions in pwc-ctrl.c */ | 369 | /** Functions in pwc-ctrl.c */ |
370 | /* Request a certain video mode. Returns < 0 if not possible */ | 370 | /* Request a certain video mode. Returns < 0 if not possible */ |
371 | extern int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, | 371 | extern int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, |
372 | int pixfmt, int frames, int *compression); | 372 | int pixfmt, int frames, int *compression, int send_to_cam); |
373 | extern unsigned int pwc_get_fps(struct pwc_device *pdev, unsigned int index, unsigned int size); | 373 | extern unsigned int pwc_get_fps(struct pwc_device *pdev, unsigned int index, unsigned int size); |
374 | extern int pwc_set_leds(struct pwc_device *pdev, int on_value, int off_value); | 374 | extern int pwc_set_leds(struct pwc_device *pdev, int on_value, int off_value); |
375 | extern int pwc_get_cmos_sensor(struct pwc_device *pdev, int *sensor); | 375 | extern int pwc_get_cmos_sensor(struct pwc_device *pdev, int *sensor); |