[libcamera-devel] [PATCH v2] libcamera: Test sensor's ability to discover ancillary devices

Kieran Bingham kieran.bingham at ideasonboard.com
Thu Apr 21 14:02:07 CEST 2022


Quoting Yunke Cao (2022-04-21 10:53:20)
> Use vimc lens to test sensor's ability to discover ancillary lens.
> 
> Tested with/without the recent kernel patch for vimc lens:
> https://lore.kernel.org/linux-media/20220415023855.2568366-1-yunkec@google.com/
> 
> Signed-off-by: Yunke Cao <yunkec at google.com>
> ---
> Changelog since v1:
>  - Dont fail test when lens is not present.
>  - Remove lens from dm.
>  - Tested on both kernels with/without the vimc lens patch.
> 
>  src/libcamera/camera_sensor.cpp |  5 +++++
>  test/camera-sensor.cpp          | 12 ++++++++++++
>  2 files changed, 17 insertions(+)
> 
> diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp
> index eaa2da6b..fe366267 100644
> --- a/src/libcamera/camera_sensor.cpp
> +++ b/src/libcamera/camera_sensor.cpp
> @@ -152,6 +152,11 @@ int CameraSensor::init()
>          */
>         if (entity_->device()->driver() == "vimc") {
>                 initVimcDefaultProperties();
> +
> +               ret = discoverAncillaryDevices();
> +               if (ret)
> +                       return ret;
> +

I think we could also move the discoverAncillaryDevices() call to be
before the VIMC handling.

But I'm not too worried here - the vimc handling already has a todo to
clean this up when we can validate vimc like a normal sensor/camera ...


>                 return initProperties();
>         }
>  
> diff --git a/test/camera-sensor.cpp b/test/camera-sensor.cpp
> index 372ee4af..d1bb639a 100644
> --- a/test/camera-sensor.cpp
> +++ b/test/camera-sensor.cpp
> @@ -12,6 +12,7 @@
>  
>  #include <libcamera/base/utils.h>
>  
> +#include "libcamera/internal/camera_lens.h"
>  #include "libcamera/internal/camera_sensor.h"
>  #include "libcamera/internal/device_enumerator.h"
>  #include "libcamera/internal/media_device.h"
> @@ -57,6 +58,11 @@ protected:
>                         return TestFail;
>                 }
>  
> +               lens_ = sensor_->focusLens();
> +               if (lens_) {
> +                       cout << "Found lens" << endl;
> +               }

No need for scope braces on a single line if, (could be removed while
applying). I'm not sure if the print statement helps in the test though
- we don't normally print other messages during tests - but it is useful
to know that it was detected for now I guess.

Lets see what others say on that.


But either way, with those resolved or updated while applying :


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

> +
>                 return TestPass;
>         }
>  
> @@ -104,6 +110,11 @@ protected:
>                         return TestFail;
>                 }
>  
> +               if (lens_ && lens_->setFocusPosition(10)) {
> +                       cerr << "Failed to set lens focus position" << endl;
> +                       return TestFail;
> +               }
> +
>                 return TestPass;
>         }
>  
> @@ -116,6 +127,7 @@ private:
>         std::unique_ptr<DeviceEnumerator> enumerator_;
>         std::shared_ptr<MediaDevice> media_;
>         CameraSensor *sensor_;
> +       CameraLens *lens_;
>  };
>  
>  TEST_REGISTER(CameraSensorTest)
> -- 
> 2.36.0.rc0.470.gd361397f0d-goog
>


More information about the libcamera-devel mailing list