[libcamera-devel,v3,0/6] Add support for V4L2 Controls
mbox series

Message ID 20190613112046.25260-1-jacopo@jmondi.org
Headers show
Series
  • Add support for V4L2 Controls
Related show

Message

Jacopo Mondi June 13, 2019, 11:20 a.m. UTC
Hello,
   new V4L2 controls support iteration.

The patches are based on the in-review:
[PATCH v4 0/2] libcamera: Introduce V4L2Device base class

This new version changes quite a few things, and is the result of the combined
review effort from everyone! Thanks a lot.

Most notable changes:
- Drop the support for compound and string controls
- As a consequence drop template control values: everything is now stored
  in a long int
- Decouple the control value from its information as Kieran has done for the
  libcamera control
- Cache all controls info at V4L2 device open time to avoid extra calls to
  VIDIOC_QUERY_EXT_CTRL
- Support creation on controls without value to be provided to getControls
- Change V4L2Device::getControls() to accept a V4L2Controls as setControls()
  does.

The new interface is demonstrated by the last patch, and I report it here
a snippet:

	/* --- Get control values --- */
	V4L2Controls controls;
	controls.add(V4L2_CID_EXPOSURE);
	controls.add(V4L2_CID_ANALOGUE_GAIN);
	cio2->sensor_->getControls(&controls);

	for (const V4L2Control &ctrl : controls) {
		unsigned int id = ctrl.id();
		V4L2ControlInfo *info = cio2->sensor_->getControlInfo(id);
		if (!info)
			continue;

		int val = controls.get(id);
		LOG(Error) << "Control : " << id << " - name : " << info->name()
			   << " - value: " << val;
	}

	/* --- Set control values --- */
	controls.set(V4L2_CID_EXPOSURE, 2046);
	controls.set(V4L2_CID_ANALOGUE_GAIN, 1024);
	cio2->sensor_->setControls(&controls);

	/* --- Get control values back again and verify they have changed --- */
	cio2->sensor_->getControls(&controls);
	for (const V4L2Control &ctrl : controls) {
		unsigned int id = ctrl.id();
		V4L2ControlInfo *info = cio2->sensor_->getControlInfo(id);
		if (!info)
			continue;

		int val = controls.get(id);
		LOG(Error) << "Control : " << id << " - name : " << info->name()
			   << " - value: " << val;
	}

Thanks
   j

Jacopo Mondi (6):
  libcamera: Add V4L2Controls
  libcamera: v4l2_device: List controls at device open
  libcamera: v4l2_device: Implement get and set controls
  libcamera: camera_sensor: Add V4L2 control operations
  libcamera: ipu3: Set pipe_mode based on stream configuration
  [HACK] ipu3: Set and get a few sensor controls

 src/libcamera/camera_sensor.cpp       |  58 +++++
 src/libcamera/include/camera_sensor.h |   6 +
 src/libcamera/include/v4l2_controls.h |  96 ++++++++
 src/libcamera/include/v4l2_device.h   |  14 +-
 src/libcamera/meson.build             |   1 +
 src/libcamera/pipeline/ipu3/ipu3.cpp  |  78 ++++++
 src/libcamera/v4l2_controls.cpp       | 337 ++++++++++++++++++++++++++
 src/libcamera/v4l2_device.cpp         | 219 +++++++++++++++++
 8 files changed, 808 insertions(+), 1 deletion(-)
 create mode 100644 src/libcamera/include/v4l2_controls.h
 create mode 100644 src/libcamera/v4l2_controls.cpp

--
2.21.0

Comments

Kieran Bingham June 13, 2019, 11:24 a.m. UTC | #1
Hi Jacopo,

On 13/06/2019 12:20, Jacopo Mondi wrote:
> Hello,
>    new V4L2 controls support iteration.
> 
> The patches are based on the in-review:
> [PATCH v4 0/2] libcamera: Introduce V4L2Device base class
> 
> This new version changes quite a few things, and is the result of the combined
> review effort from everyone! Thanks a lot.
> 
> Most notable changes:
> - Drop the support for compound and string controls
> - As a consequence drop template control values: everything is now stored
>   in a long int
> - Decouple the control value from its information as Kieran has done for the
>   libcamera control
> - Cache all controls info at V4L2 device open time to avoid extra calls to
>   VIDIOC_QUERY_EXT_CTRL
> - Support creation on controls without value to be provided to getControls
> - Change V4L2Device::getControls() to accept a V4L2Controls as setControls()
>   does.
> 

Ohh - excellent lots to look at.

I've run out of time to rebase my work on top of this for this week, but
I'll certainly do that next week.


> The new interface is demonstrated by the last patch, and I report it here
> a snippet:
> 
> 	/* --- Get control values --- */
> 	V4L2Controls controls;
> 	controls.add(V4L2_CID_EXPOSURE);
> 	controls.add(V4L2_CID_ANALOGUE_GAIN);
> 	cio2->sensor_->getControls(&controls);
> 
> 	for (const V4L2Control &ctrl : controls) {
> 		unsigned int id = ctrl.id();
> 		V4L2ControlInfo *info = cio2->sensor_->getControlInfo(id);
> 		if (!info)
> 			continue;
> 
> 		int val = controls.get(id);
> 		LOG(Error) << "Control : " << id << " - name : " << info->name()
> 			   << " - value: " << val;
> 	}
> 
> 	/* --- Set control values --- */
> 	controls.set(V4L2_CID_EXPOSURE, 2046);
> 	controls.set(V4L2_CID_ANALOGUE_GAIN, 1024);
> 	cio2->sensor_->setControls(&controls);
> 
> 	/* --- Get control values back again and verify they have changed --- */
> 	cio2->sensor_->getControls(&controls);
> 	for (const V4L2Control &ctrl : controls) {
> 		unsigned int id = ctrl.id();
> 		V4L2ControlInfo *info = cio2->sensor_->getControlInfo(id);
> 		if (!info)
> 			continue;
> 
> 		int val = controls.get(id);
> 		LOG(Error) << "Control : " << id << " - name : " << info->name()
> 			   << " - value: " << val;
> 	}
> 

That could looks a lot more friendly now :D

> Thanks
>    j
> 
> Jacopo Mondi (6):
>   libcamera: Add V4L2Controls
>   libcamera: v4l2_device: List controls at device open
>   libcamera: v4l2_device: Implement get and set controls
>   libcamera: camera_sensor: Add V4L2 control operations
>   libcamera: ipu3: Set pipe_mode based on stream configuration
>   [HACK] ipu3: Set and get a few sensor controls
> 
>  src/libcamera/camera_sensor.cpp       |  58 +++++
>  src/libcamera/include/camera_sensor.h |   6 +
>  src/libcamera/include/v4l2_controls.h |  96 ++++++++
>  src/libcamera/include/v4l2_device.h   |  14 +-
>  src/libcamera/meson.build             |   1 +
>  src/libcamera/pipeline/ipu3/ipu3.cpp  |  78 ++++++
>  src/libcamera/v4l2_controls.cpp       | 337 ++++++++++++++++++++++++++
>  src/libcamera/v4l2_device.cpp         | 219 +++++++++++++++++
>  8 files changed, 808 insertions(+), 1 deletion(-)
>  create mode 100644 src/libcamera/include/v4l2_controls.h
>  create mode 100644 src/libcamera/v4l2_controls.cpp
> 
> --
> 2.21.0
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
>