diff options
author | Hans de Goede <hdegoede@redhat.com> | 2012-01-10 11:01:41 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-01-16 08:08:26 -0500 |
commit | d167a85c5fb45b1ecdacdb9b7733833a9af78da8 (patch) | |
tree | bc04587bbd8d77b7a7d4eeea3e8ebb9007ae6e75 /drivers/media/video/pwc | |
parent | 56ae24aad8f9e25dfef995c3e898e5f394cf0beb (diff) |
[media] pwc: Fix pixfmt handling
Before this patch various code in the mode setting patch checked
pdev->pixfmt, but that was not set until the mode setting succeeded, so
it was looking at the old pixfmt! This patch fixes this by making the
pixfmt a parameter to set_video_mode, and setting it from set_video_mode
on success.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/pwc')
-rw-r--r-- | drivers/media/video/pwc/pwc-ctrl.c | 39 | ||||
-rw-r--r-- | drivers/media/video/pwc/pwc-if.c | 5 | ||||
-rw-r--r-- | drivers/media/video/pwc/pwc-misc.c | 1 | ||||
-rw-r--r-- | drivers/media/video/pwc/pwc-v4l.c | 13 | ||||
-rw-r--r-- | drivers/media/video/pwc/pwc.h | 2 |
5 files changed, 28 insertions, 32 deletions
diff --git a/drivers/media/video/pwc/pwc-ctrl.c b/drivers/media/video/pwc/pwc-ctrl.c index 34a01b209251..51ab4c570d0b 100644 --- a/drivers/media/video/pwc/pwc-ctrl.c +++ b/drivers/media/video/pwc/pwc-ctrl.c | |||
@@ -168,8 +168,8 @@ int send_control_msg(struct pwc_device *pdev, | |||
168 | request, value, pdev->vcinterface, buf, buflen); | 168 | request, value, pdev->vcinterface, buf, buflen); |
169 | } | 169 | } |
170 | 170 | ||
171 | static int set_video_mode_Nala(struct pwc_device *pdev, int size, int frames, | 171 | static int set_video_mode_Nala(struct pwc_device *pdev, int size, int pixfmt, |
172 | int *compression) | 172 | int frames, int *compression) |
173 | { | 173 | { |
174 | unsigned char buf[3]; | 174 | unsigned char buf[3]; |
175 | int ret, fps; | 175 | int ret, fps; |
@@ -212,14 +212,14 @@ static int set_video_mode_Nala(struct pwc_device *pdev, int size, int frames, | |||
212 | PWC_DEBUG_MODULE("Failed to send video command... %d\n", ret); | 212 | PWC_DEBUG_MODULE("Failed to send video command... %d\n", ret); |
213 | return ret; | 213 | return ret; |
214 | } | 214 | } |
215 | if (pEntry->compressed && pdev->pixfmt == V4L2_PIX_FMT_YUV420) { | 215 | if (pEntry->compressed && pixfmt == V4L2_PIX_FMT_YUV420) |
216 | pwc_dec1_init(pdev, buf); | 216 | pwc_dec1_init(pdev, buf); |
217 | } | ||
218 | 217 | ||
219 | pdev->cmd_len = 3; | 218 | pdev->cmd_len = 3; |
220 | memcpy(pdev->cmd_buf, buf, 3); | 219 | memcpy(pdev->cmd_buf, buf, 3); |
221 | 220 | ||
222 | /* Set various parameters */ | 221 | /* Set various parameters */ |
222 | pdev->pixfmt = pixfmt; | ||
223 | pdev->vframes = frames; | 223 | pdev->vframes = frames; |
224 | pdev->valternate = pEntry->alternate; | 224 | pdev->valternate = pEntry->alternate; |
225 | pdev->width = pwc_image_sizes[size][0]; | 225 | pdev->width = pwc_image_sizes[size][0]; |
@@ -245,8 +245,8 @@ static int set_video_mode_Nala(struct pwc_device *pdev, int size, int frames, | |||
245 | } | 245 | } |
246 | 246 | ||
247 | 247 | ||
248 | static int set_video_mode_Timon(struct pwc_device *pdev, int size, int frames, | 248 | static int set_video_mode_Timon(struct pwc_device *pdev, int size, int pixfmt, |
249 | int *compression) | 249 | int frames, int *compression) |
250 | { | 250 | { |
251 | unsigned char buf[13]; | 251 | unsigned char buf[13]; |
252 | const struct Timon_table_entry *pChoose; | 252 | const struct Timon_table_entry *pChoose; |
@@ -278,14 +278,14 @@ static int set_video_mode_Timon(struct pwc_device *pdev, int size, int frames, | |||
278 | if (ret < 0) | 278 | if (ret < 0) |
279 | return ret; | 279 | return ret; |
280 | 280 | ||
281 | if (pChoose->bandlength > 0 && pdev->pixfmt == V4L2_PIX_FMT_YUV420) { | 281 | if (pChoose->bandlength > 0 && pixfmt == V4L2_PIX_FMT_YUV420) |
282 | pwc_dec23_init(pdev, buf); | 282 | pwc_dec23_init(pdev, buf); |
283 | } | ||
284 | 283 | ||
285 | pdev->cmd_len = 13; | 284 | pdev->cmd_len = 13; |
286 | memcpy(pdev->cmd_buf, buf, 13); | 285 | memcpy(pdev->cmd_buf, buf, 13); |
287 | 286 | ||
288 | /* Set various parameters */ | 287 | /* Set various parameters */ |
288 | pdev->pixfmt = pixfmt; | ||
289 | pdev->vframes = (fps + 1) * 5; | 289 | pdev->vframes = (fps + 1) * 5; |
290 | pdev->valternate = pChoose->alternate; | 290 | pdev->valternate = pChoose->alternate; |
291 | pdev->width = pwc_image_sizes[size][0]; | 291 | pdev->width = pwc_image_sizes[size][0]; |
@@ -299,8 +299,8 @@ static int set_video_mode_Timon(struct pwc_device *pdev, int size, int frames, | |||
299 | } | 299 | } |
300 | 300 | ||
301 | 301 | ||
302 | static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int frames, | 302 | static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int pixfmt, |
303 | int *compression) | 303 | int frames, int *compression) |
304 | { | 304 | { |
305 | const struct Kiara_table_entry *pChoose = NULL; | 305 | const struct Kiara_table_entry *pChoose = NULL; |
306 | int fps, ret; | 306 | int fps, ret; |
@@ -336,13 +336,13 @@ static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int frames, | |||
336 | if (ret < 0) | 336 | if (ret < 0) |
337 | return ret; | 337 | return ret; |
338 | 338 | ||
339 | if (pChoose->bandlength > 0 && pdev->pixfmt == V4L2_PIX_FMT_YUV420) { | 339 | if (pChoose->bandlength > 0 && pixfmt == V4L2_PIX_FMT_YUV420) |
340 | pwc_dec23_init(pdev, buf); | 340 | pwc_dec23_init(pdev, buf); |
341 | } | ||
342 | 341 | ||
343 | pdev->cmd_len = 12; | 342 | pdev->cmd_len = 12; |
344 | memcpy(pdev->cmd_buf, buf, 12); | 343 | memcpy(pdev->cmd_buf, buf, 12); |
345 | /* All set and go */ | 344 | /* All set and go */ |
345 | pdev->pixfmt = pixfmt; | ||
346 | pdev->vframes = (fps + 1) * 5; | 346 | pdev->vframes = (fps + 1) * 5; |
347 | pdev->valternate = pChoose->alternate; | 347 | pdev->valternate = pChoose->alternate; |
348 | pdev->width = pwc_image_sizes[size][0]; | 348 | pdev->width = pwc_image_sizes[size][0]; |
@@ -358,23 +358,24 @@ static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int frames, | |||
358 | } | 358 | } |
359 | 359 | ||
360 | int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, | 360 | int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, |
361 | int frames, int *compression) | 361 | int pixfmt, int frames, int *compression) |
362 | { | 362 | { |
363 | int ret, size; | 363 | int ret, size; |
364 | 364 | ||
365 | PWC_DEBUG_FLOW("set_video_mode(%dx%d @ %d, pixfmt %08x).\n", | 365 | PWC_DEBUG_FLOW("set_video_mode(%dx%d @ %d, pixfmt %08x).\n", |
366 | width, height, frames, pdev->pixfmt); | 366 | width, height, frames, pixfmt); |
367 | size = pwc_get_size(pdev, width, height); | 367 | size = pwc_get_size(pdev, width, height); |
368 | PWC_TRACE("decode_size = %d.\n", size); | 368 | PWC_TRACE("decode_size = %d.\n", size); |
369 | 369 | ||
370 | if (DEVICE_USE_CODEC1(pdev->type)) { | 370 | if (DEVICE_USE_CODEC1(pdev->type)) { |
371 | ret = set_video_mode_Nala(pdev, size, frames, compression); | 371 | ret = set_video_mode_Nala(pdev, size, pixfmt, frames, |
372 | 372 | compression); | |
373 | } else if (DEVICE_USE_CODEC3(pdev->type)) { | 373 | } else if (DEVICE_USE_CODEC3(pdev->type)) { |
374 | ret = set_video_mode_Kiara(pdev, size, frames, compression); | 374 | ret = set_video_mode_Kiara(pdev, size, pixfmt, frames, |
375 | 375 | compression); | |
376 | } else { | 376 | } else { |
377 | ret = set_video_mode_Timon(pdev, size, frames, compression); | 377 | ret = set_video_mode_Timon(pdev, size, pixfmt, frames, |
378 | compression); | ||
378 | } | 379 | } |
379 | if (ret < 0) { | 380 | if (ret < 0) { |
380 | PWC_ERROR("Failed to set video mode %s@%d fps; return code = %d\n", size2name[size], frames, ret); | 381 | 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 250ad4c3e9d8..1f3386da05fa 100644 --- a/drivers/media/video/pwc/pwc-if.c +++ b/drivers/media/video/pwc/pwc-if.c | |||
@@ -386,7 +386,7 @@ 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, |
389 | pdev->vframes, &compression); | 389 | pdev->pixfmt, pdev->vframes, &compression); |
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); |
@@ -1128,7 +1128,8 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id | |||
1128 | pwc_set_leds(pdev, 0, 0); | 1128 | pwc_set_leds(pdev, 0, 0); |
1129 | 1129 | ||
1130 | /* Setup intial videomode */ | 1130 | /* Setup intial videomode */ |
1131 | rc = pwc_set_video_mode(pdev, MAX_WIDTH, MAX_HEIGHT, 30, &compression); | 1131 | rc = pwc_set_video_mode(pdev, MAX_WIDTH, MAX_HEIGHT, |
1132 | V4L2_PIX_FMT_YUV420, 30, &compression); | ||
1132 | if (rc) | 1133 | if (rc) |
1133 | goto err_free_mem; | 1134 | goto err_free_mem; |
1134 | 1135 | ||
diff --git a/drivers/media/video/pwc/pwc-misc.c b/drivers/media/video/pwc/pwc-misc.c index 23a55b5814fc..9be5adffa874 100644 --- a/drivers/media/video/pwc/pwc-misc.c +++ b/drivers/media/video/pwc/pwc-misc.c | |||
@@ -90,5 +90,4 @@ void pwc_construct(struct pwc_device *pdev) | |||
90 | pdev->frame_header_size = 0; | 90 | pdev->frame_header_size = 0; |
91 | pdev->frame_trailer_size = 0; | 91 | pdev->frame_trailer_size = 0; |
92 | } | 92 | } |
93 | pdev->pixfmt = V4L2_PIX_FMT_YUV420; /* default */ | ||
94 | } | 93 | } |
diff --git a/drivers/media/video/pwc/pwc-v4l.c b/drivers/media/video/pwc/pwc-v4l.c index ef422d0ac599..b275fad2927b 100644 --- a/drivers/media/video/pwc/pwc-v4l.c +++ b/drivers/media/video/pwc/pwc-v4l.c | |||
@@ -493,16 +493,11 @@ 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 | 30, &compression); | 496 | pixelformat, 30, &compression); |
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 | ||
500 | if (ret == 0) { | 500 | pwc_vidioc_fill_fmt(f, pdev->width, pdev->height, pdev->pixfmt); |
501 | pdev->pixfmt = pixelformat; | ||
502 | pwc_vidioc_fill_fmt(f, pdev->width, pdev->height, | ||
503 | pdev->pixfmt); | ||
504 | } | ||
505 | |||
506 | leave: | 501 | leave: |
507 | mutex_unlock(&pdev->udevlock); | 502 | mutex_unlock(&pdev->udevlock); |
508 | return ret; | 503 | return ret; |
@@ -1141,8 +1136,8 @@ static int pwc_s_parm(struct file *file, void *fh, | |||
1141 | goto leave; | 1136 | goto leave; |
1142 | } | 1137 | } |
1143 | 1138 | ||
1144 | ret = pwc_set_video_mode(pdev, pdev->width, pdev->height, fps, | 1139 | ret = pwc_set_video_mode(pdev, pdev->width, pdev->height, pdev->pixfmt, |
1145 | &compression); | 1140 | fps, &compression); |
1146 | 1141 | ||
1147 | pwc_g_parm(file, fh, parm); | 1142 | pwc_g_parm(file, fh, parm); |
1148 | 1143 | ||
diff --git a/drivers/media/video/pwc/pwc.h b/drivers/media/video/pwc/pwc.h index 0f3bc1b3a971..29b6d3dca83b 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 frames, int *compression); | 372 | int pixfmt, int frames, int *compression); |
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); |