[libcamera-devel] [PATCH] pipeline: uvcvideo: Implement AeFlickerMode

Kieran Bingham kieran.bingham at ideasonboard.com
Wed Jan 25 23:08:26 CET 2023


Implement the mapping for AeFlickerMode support.
Custom flicker modes are not supported by UVC devices.

Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
---

RFC: An untested implementation of the AeFlickerMode control in the UVC
pipeline handler.

Any particularly easy way to test this ?

Perhaps we should be adding tests to lc-compliance for new control
definitions? - Though I'm not sure how easily we can validate the
operation of the control. But at least if it's present we can test that
setting it doesn't crash the pipeline or cause errors for instance.

 src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 38 ++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp
index 3afa1f8e4bc7..3a18f624a30a 100644
--- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp
+++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp
@@ -277,6 +277,8 @@ int PipelineHandlerUVC::processControl(ControlList *controls, unsigned int id,
 		cid = V4L2_CID_EXPOSURE_ABSOLUTE;
 	else if (id == controls::AnalogueGain)
 		cid = V4L2_CID_GAIN;
+	else if (id == controls::AeFlickerMode)
+		cid = V4L2_CID_POWER_LINE_FREQUENCY;
 	else
 		return -EINVAL;
 
@@ -331,6 +333,30 @@ int PipelineHandlerUVC::processControl(ControlList *controls, unsigned int id,
 		break;
 	}
 
+	case V4L2_CID_POWER_LINE_FREQUENCY: {
+		enum v4l2_power_line_frequency mode;
+		switch (value.get<int32_t>()) {
+		default:
+		case controls::FlickerCustom:
+			LOG(UVC, Warning) << "Unsupported AeflickerMode";
+			[[fallthrough]];
+		case controls::FlickerOff:
+			mode = V4L2_CID_POWER_LINE_FREQUENCY_DISABLED;
+			break;
+		case controls::Flicker50Hz:
+			mode = V4L2_CID_POWER_LINE_FREQUENCY_50HZ;
+			break;
+		case controls::Flicker60Hz:
+			mode = V4L2_CID_POWER_LINE_FREQUENCY_60HZ;
+			break;
+		case controls::FlickerAuto:
+			mode = V4L2_CID_POWER_LINE_FREQUENCY_AUTO;
+			break;
+		}
+		controls->set(cid, static_cast<int32_t>(mode));
+		break;
+	}
+
 	default: {
 		int32_t ivalue = value.get<int32_t>();
 		controls->set(cid, ivalue);
@@ -605,6 +631,9 @@ void UVCCameraData::addControl(uint32_t cid, const ControlInfo &v4l2Info,
 	case V4L2_CID_GAIN:
 		id = &controls::AnalogueGain;
 		break;
+	case V4L2_CID_POWER_LINE_FREQUENCY:
+		id = &controls::AeFlickerMode;
+		break;
 	default:
 		return;
 	}
@@ -689,6 +718,15 @@ void UVCCameraData::addControl(uint32_t cid, const ControlInfo &v4l2Info,
 		break;
 	}
 
+	case V4L2_CID_POWER_LINE_FREQUENCY: {
+		info = ControlInfo{
+			{ static_cast<int>(controls::FlickerOff) },
+			{ static_cast<int>(controls::FlickerAuto) },
+			{ static_cast<int>(controls::FlickerOff) }
+		};
+		break;
+	}
+
 	default:
 		info = v4l2Info;
 		break;
-- 
2.34.1



More information about the libcamera-devel mailing list