From 1957aa641dc9bb635fbedf28c44215ddc496c006 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 24 Apr 2020 19:52:16 +0300 Subject: libcamera: pipeline: uvcvideo: Add support for AeEnable UVC devices support auto-exposure, expose the feature through the AeEnable control. Reviewed-by: Jacopo Mondi Signed-off-by: Laurent Pinchart --- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 38 +++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index 7a703509..b040f246 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -252,6 +252,8 @@ int PipelineHandlerUVC::processControl(ControlList *controls, unsigned int id, cid = V4L2_CID_CONTRAST; else if (id == controls::Saturation) cid = V4L2_CID_SATURATION; + else if (id == controls::AeEnable) + cid = V4L2_CID_EXPOSURE_AUTO; else if (id == controls::ManualExposure) cid = V4L2_CID_EXPOSURE_ABSOLUTE; else if (id == controls::ManualGain) @@ -259,12 +261,21 @@ int PipelineHandlerUVC::processControl(ControlList *controls, unsigned int id, else return -EINVAL; - if (cid == V4L2_CID_EXPOSURE_ABSOLUTE) - controls->set(V4L2_CID_EXPOSURE_AUTO, static_cast(1)); - - int32_t ivalue = value.get(); + switch (cid) { + case V4L2_CID_EXPOSURE_AUTO: { + int32_t ivalue = value.get() + ? V4L2_EXPOSURE_APERTURE_PRIORITY + : V4L2_EXPOSURE_MANUAL; + controls->set(V4L2_CID_EXPOSURE_AUTO, ivalue); + break; + } - controls->set(cid, ivalue); + default: { + int32_t ivalue = value.get(); + controls->set(cid, ivalue); + break; + } + } return 0; } @@ -385,6 +396,7 @@ void UVCCameraData::addControl(uint32_t cid, const ControlInfo &v4l2Info, ControlInfoMap::Map *ctrls) { const ControlId *id; + ControlInfo info; /* Map the control ID. */ switch (cid) { @@ -397,6 +409,9 @@ void UVCCameraData::addControl(uint32_t cid, const ControlInfo &v4l2Info, case V4L2_CID_SATURATION: id = &controls::Saturation; break; + case V4L2_CID_EXPOSURE_AUTO: + id = &controls::AeEnable; + break; case V4L2_CID_EXPOSURE_ABSOLUTE: id = &controls::ManualExposure; break; @@ -407,7 +422,18 @@ void UVCCameraData::addControl(uint32_t cid, const ControlInfo &v4l2Info, return; } - ctrls->emplace(id, v4l2Info); + /* Map the control info. */ + switch (cid) { + case V4L2_CID_EXPOSURE_AUTO: + info = ControlInfo{ false, true, true }; + break; + + default: + info = v4l2Info; + break; + } + + ctrls->emplace(id, info); } void UVCCameraData::bufferReady(FrameBuffer *buffer) -- cgit v1.2.1