peterbay / uvc-gadget

uvc-gadget with resolution changing and video controls
GNU General Public License v2.0
81 stars 24 forks source link

Enable Exposure and White Balance controls #23

Open friissoren opened 2 years ago

friissoren commented 2 years ago

Correctly handle Exposure mode control. The value definition for the V4L2 interface for exposure mode control does not map directly to the UVC control interface. Add some conversion and configuration fixes.

Also enable AWB control. This is a bit of a hack. The RaspberryPi V4L2 driver exposes only a menu of pre-defined color temperatures and two of those are manual and auto. This control definition does not have any corresponding equivalent in the UVC specification.

Override the UVC color temperature control interface to map directly to the V4L2 AWB interface. This will allow controlling the AWB modes from the host but will only show number values with no explanation of what the numbers refer to.

I don't have any other HW than the RPi 4B + v2 camera so I don't know if these changes are completely valid on other HW combinations.

NOTE: In order to make the exposure and white balance controls visible to the host, changes are needed also for the configuration values for the f_uvc.c kernel driver, as defined by the patch included in the showmewebcam project. https://github.com/showmewebcam/showmewebcam/pull/167

friissoren commented 2 years ago

Hmmm... update. This is working fine when using the camera with an Ubuntu PC and viewing the camera stream and controls using the qv4l2 program.

However, I tried now also on Windows with the e-CAMView application, which allows you to access the UVC controls (Options -> Video Capture Filter menu). The AWB control worked as expected but the exposure control appeared to be stuck in auto mode. I need to check a bit further what is wrong.

friissoren commented 2 years ago

I updated the code. It now works on both Linux and Windows. At least with the qv4l2 and e-CAMView programs that I have tested with.

friissoren commented 2 years ago

I found a RaspberryPi camera v1.3 (the 5 Mpixel one, I guess) and tried the SW with that one. Appears to work just fine. All the same controls were there and were working.

@peterbay : Could you maybe review this PR and PR #24 and merge those if you are happy with the changes? The changes to showmewebcam were already merged in a while ago but those will not work completely unless this PR gets merged as well (and the showmewebcam project updated to point to the merged uvc-gadget changes).