Bug 36152

Summary: iSight (uvcvideo) VIDIOC_TRY_FMT has side-effects
Product: v4l-dvb Reporter: Dave Vasilevsky (dave)
Component: webcamAssignee: webcam (v4l-dvb_webcam)
Status: RESOLVED OBSOLETE    
Severity: normal CC: alan, diegoe, filmor, t.matsuu
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 2.6.38.6 Subsystem:
Regression: No Bisected commit-id:
Attachments: Test case

Description Dave Vasilevsky 2011-05-29 10:36:37 UTC
Created attachment 59952 [details]
Test case

The ioctl VIDIOC_TRY_FMT is supposed to modify its argument, and make no changes to the video driver. However, on my MacBook4,1 with the built-in iSight, invoking TRY_FMT causes the video capture output to change mysteriously.

The attached test case performs the following steps:
1. Sets the format to UYVY 640 x 480
2. Uses TRY_FMT to check if 320 x 240 would work
3. Verifies that the format is still 640 x 480
4. Captures frames, but they are not of the expected size

Output is:
	Set 640 x 480
	Driver claims 640 x 480, image size 614400
	Tried 320 x 240
	Driver claims 640 x 480, image size 614400
	Actual image size 262477
	Actual image size 262692
	Actual image size 262908
	Actual image size 262102
	Actual image size 262144
	Actual image size 262144
	Actual image size 262144
	Actual image size 262144
	Actual image size 262144
	Actual image size 262144

Expected output would have actual size 614400, the same as the driver claims it should be.

I have no idea what the ~256k buffer being received actually is, it's not the proper size for 320 x 240 either!
Comment 1 Diego Escalante Urrelo 2011-07-14 19:09:38 UTC
I can confirm, your testcase "works" here too:

diego:downloads$ ./isight 
Set 640 x 480
Driver claims 640 x 480, image size 614400
Tried 320 x 240
Driver claims 640 x 480, image size 614400
Actual image size 262144
Actual image size 262371
Actual image size 262145
Actual image size 262144
Actual image size 262803
Actual image size 262144
Actual image size 262144
Actual image size 262463
Actual image size 262144
Actual image size 262144

I first saw this with GNOME's Cheese, where I have to go to preferences and switch back and forth to another video format before I actually see something (640x480 -> 320x240 -> 640x480)
Comment 2 Diego Escalante Urrelo 2011-07-14 19:10:11 UTC
GNOME bugzilla btw: https://bugzilla.gnome.org/show_bug.cgi?id=649067