@@ -689,6 +689,92 @@ int PipelineHandlerIPU3::start(Camera *camera)
ImgUDevice *imgu = data->imgu_;
int ret;
+ /* --- Get control values --- */
+ std::vector<unsigned int> controlIds = {
+ V4L2_CID_EXPOSURE, V4L2_CID_ANALOGUE_GAIN,
+ };
+ std::vector<V4L2Control *> controls =
+ cio2->sensor_->dev()->getControls(controlIds);
+ if (controls.empty()) {
+ LOG(Error) << "Failed to get control values";
+ return -EINVAL;
+ }
+
+ for (V4L2Control *ctrl : controls) {
+ unsigned int id = ctrl->id();
+
+ switch(ctrl->type()) {
+ case V4L2_CTRL_TYPE_INTEGER:
+ case V4L2_CTRL_TYPE_BOOLEAN:
+ {
+ V4L2IntControl *c = static_cast<V4L2IntControl *>(ctrl);
+ uint32_t val = c->value();
+ LOG(Error) << "Control : " << id
+ << " - value: " << val;
+ }
+ break;
+ case V4L2_CTRL_TYPE_INTEGER64:
+ {
+ V4L2Int64Control *c = static_cast<V4L2Int64Control *>(ctrl);
+ uint64_t val = c->value();
+ LOG(Error) << "Control : " << id
+ << " - value: " << val;
+ }
+ break;
+ default:
+ LOG(Error) << "Unsupported type: " << ctrl->type();
+ return -EINVAL;
+ }
+ }
+
+ /* --- Set control values --- */
+ V4L2IntControl exposureControl(V4L2_CID_EXPOSURE, 2046);
+ V4L2IntControl gainControl(V4L2_CID_ANALOGUE_GAIN, 1024);
+ std::vector<V4L2Control *> sensorControls = {
+ &exposureControl, &gainControl,
+ };
+
+ ret = cio2->sensor_->dev()->setControls(sensorControls);
+ if (ret) {
+ LOG(IPU3, Error) << "Failed to set controls";
+ return ret;
+ }
+
+ /* --- Get control values back again and verify they have changed --- */
+ std::vector<V4L2Control *> newcontrols =
+ cio2->sensor_->dev()->getControls(controlIds);
+ if (newcontrols.empty()) {
+ LOG(Error) << "Failed to get control values";
+ return -EINVAL;
+ }
+
+ for (V4L2Control *ctrl : newcontrols) {
+ unsigned int id = ctrl->id();
+
+ switch(ctrl->type()) {
+ case V4L2_CTRL_TYPE_INTEGER:
+ case V4L2_CTRL_TYPE_BOOLEAN:
+ {
+ V4L2IntControl *c = static_cast<V4L2IntControl *>(ctrl);
+ uint32_t val = c->value();
+ LOG(Error) << "Control : " << id
+ << " - value: " << val;
+ }
+ break;
+ case V4L2_CTRL_TYPE_INTEGER64:
+ {
+ V4L2Int64Control *c = static_cast<V4L2Int64Control *>(ctrl);
+ uint64_t val = c->value();
+ LOG(Error) << "Control : " << id
+ << " - value: " << val;
+ }
+ break;
+ default:
+ LOG(Error) << "Unsupported type: " << ctrl->type();
+ return -EINVAL;
+ }
+ }
+
/*
* Start the ImgU video devices, buffers will be queued to the
* ImgU output and viewfinder when requests will be queued.