[v14,0/7] Add VirtualPipelineHandler
mbox series

Message ID 20240930063342.3014837-1-chenghaoyang@google.com
Headers show
Series
  • Add VirtualPipelineHandler
Related show

Message

Harvey Yang Sept. 30, 2024, 6:29 a.m. UTC
Hi all,

This series adds virtual pipeline handler, which doesn't depend on any
hardware, like camera sensor or ISP. Currently the configuration
supports test patterns and images.

It passed the gitlab pipeline:
https://gitlab.freedesktop.org/chenghaoyang/libcamera/-/pipelines/1280687

I've also checked that it works on qcam.

I failed to pass multi_stream_test when trying to enable multiple
streams though. Please give me some hints what it tests and what I
missed:
```
[295:43:43.910237144] [1441841]  INFO IPAManager ipa_manager.cpp:137 libcamera is not installed. Adding '/usr/local/google/home/chenghaoyang/Workspace/libca
mera/build/src/ipa' to the IPA search path
[295:43:43.914030564] [1441841]  INFO Camera camera_manager.cpp:325 libcamera v0.3.1+79-8ca4f033-dirty (2024-08-29T19:18:51UTC)
[295:43:43.915493754] [1441844] ERROR DmaBufAllocator dma_buf_allocator.cpp:120 Could not open any dma-buf provider
[295:43:43.919118835] [1441841]  INFO IPAManager ipa_manager.cpp:137 libcamera is not installed. Adding '/usr/local/google/home/chenghaoyang/Workspace/libca
mera/build/src/ipa' to the IPA search path
[295:43:43.922245825] [1441841]  INFO Camera camera_manager.cpp:325 libcamera v0.3.1+79-8ca4f033-dirty (2024-08-29T19:18:51UTC)
[295:43:43.922820175] [1441846] ERROR DmaBufAllocator dma_buf_allocator.cpp:120 Could not open any dma-buf provider
Unable to set the pipeline to the playing state.
```

Gitlab pipeline failure:
https://gitlab.freedesktop.org/chenghaoyang/libcamera/-/pipelines/1260412

Updates in v14:
- Refactored ImageFrames to keep a list of filepaths directly.

Updates in v13:
- Returned an errno in `FrameGenerete::generateFrame()`

Updates in v12:
- Added ImageFrameGenerator first, then add Parser.
- Removed ScaleMode argument, as only Fill is supported now.
- Fixed bug of Stream's configuration usage in configure().

Updates in v11:
- Allowed a single value in the config file's frame_rates field.

Updates in v10:
Apply fixes according to Jacopo's and Barnabás' comments.
- Split test_pattern and path fields in the yaml format.
- Let FrameGenerators control frameCount_.
- Fixed match() returning values.

Updates in v9: Allocate contiguous memory for planes in the same
FrameBuffer.

BR,
Harvey

Harvey Yang (6):
  libcamera: add DmaBufAllocator::exportBuffers()
  libcamera: Remove PipelineHandler Fatal check of non-empty
    MediaDevices
  libcamera: virtual: Add VirtualPipelineHandler
  libcamera: virtual: Add ImageFrameGenerator
  libcamera: virtual: Read config and register cameras based on the
    config
  libcamera: software_isp: Refactor SoftwareIsp to use
    DmaBufAllocator::exportBuffers

Konami Shu (1):
  libcamera: pipeline: Add test pattern for VirtualPipelineHandler

 .../libcamera/internal/dma_buf_allocator.h    |  13 +
 meson.build                                   |   1 +
 meson_options.txt                             |   3 +-
 src/android/meson.build                       |  19 -
 src/libcamera/dma_buf_allocator.cpp           |  57 +++
 src/libcamera/pipeline/virtual/README.md      |  48 +++
 .../pipeline/virtual/data/virtual.yaml        |  36 ++
 .../pipeline/virtual/frame_generator.h        |  29 ++
 .../virtual/image_frame_generator.cpp         | 169 ++++++++
 .../pipeline/virtual/image_frame_generator.h  |  50 +++
 src/libcamera/pipeline/virtual/meson.build    |  13 +
 src/libcamera/pipeline/virtual/parser.cpp     | 260 ++++++++++++
 src/libcamera/pipeline/virtual/parser.h       |  39 ++
 .../virtual/test_pattern_generator.cpp        | 137 +++++++
 .../pipeline/virtual/test_pattern_generator.h |  53 +++
 src/libcamera/pipeline/virtual/virtual.cpp    | 382 ++++++++++++++++++
 src/libcamera/pipeline/virtual/virtual.h      |  61 +++
 src/libcamera/pipeline_handler.cpp            |  11 +-
 src/libcamera/software_isp/software_isp.cpp   |  20 +-
 src/meson.build                               |  19 +
 20 files changed, 1378 insertions(+), 42 deletions(-)
 create mode 100644 src/libcamera/pipeline/virtual/README.md
 create mode 100644 src/libcamera/pipeline/virtual/data/virtual.yaml
 create mode 100644 src/libcamera/pipeline/virtual/frame_generator.h
 create mode 100644 src/libcamera/pipeline/virtual/image_frame_generator.cpp
 create mode 100644 src/libcamera/pipeline/virtual/image_frame_generator.h
 create mode 100644 src/libcamera/pipeline/virtual/meson.build
 create mode 100644 src/libcamera/pipeline/virtual/parser.cpp
 create mode 100644 src/libcamera/pipeline/virtual/parser.h
 create mode 100644 src/libcamera/pipeline/virtual/test_pattern_generator.cpp
 create mode 100644 src/libcamera/pipeline/virtual/test_pattern_generator.h
 create mode 100644 src/libcamera/pipeline/virtual/virtual.cpp
 create mode 100644 src/libcamera/pipeline/virtual/virtual.h

Comments

Kieran Bingham Oct. 3, 2024, 9:48 a.m. UTC | #1
Quoting Harvey Yang (2024-09-30 07:29:41)
> Hi all,
> 
> This series adds virtual pipeline handler, which doesn't depend on any
> hardware, like camera sensor or ISP. Currently the configuration
> supports test patterns and images.
> 
> It passed the gitlab pipeline:
> https://gitlab.freedesktop.org/chenghaoyang/libcamera/-/pipelines/1280687
> 
> I've also checked that it works on qcam.
> 
> I failed to pass multi_stream_test when trying to enable multiple
> streams though. Please give me some hints what it tests and what I
> missed:
> ```
> [295:43:43.910237144] [1441841]  INFO IPAManager ipa_manager.cpp:137 libcamera is not installed. Adding '/usr/local/google/home/chenghaoyang/Workspace/libca
> mera/build/src/ipa' to the IPA search path
> [295:43:43.914030564] [1441841]  INFO Camera camera_manager.cpp:325 libcamera v0.3.1+79-8ca4f033-dirty (2024-08-29T19:18:51UTC)
> [295:43:43.915493754] [1441844] ERROR DmaBufAllocator dma_buf_allocator.cpp:120 Could not open any dma-buf provider
> [295:43:43.919118835] [1441841]  INFO IPAManager ipa_manager.cpp:137 libcamera is not installed. Adding '/usr/local/google/home/chenghaoyang/Workspace/libca
> mera/build/src/ipa' to the IPA search path
> [295:43:43.922245825] [1441841]  INFO Camera camera_manager.cpp:325 libcamera v0.3.1+79-8ca4f033-dirty (2024-08-29T19:18:51UTC)
> [295:43:43.922820175] [1441846] ERROR DmaBufAllocator dma_buf_allocator.cpp:120 Could not open any dma-buf provider
> Unable to set the pipeline to the playing state.

Is this the error you get when you enable multiple streams in the
virtual pipeline handler?

I still think that looks like an issue in the configuration of the VM
not having udmabuf which you use.


To fix this, you would probably need to fork the CI scripts:

 - https://gitlab.freedesktop.org/camera/libcamera-ci

And direct your local
https://gitlab.freedesktop.org/chenghaoyang/libcamera to use that while
you work out the issue.

I suspect you need to add something at 

https://gitlab.freedesktop.org/camera/libcamera-ci/-/blob/master/.gitlab-ci/build-kernel.sh?ref_type=heads#L41

to enable the uDMA config options...

--
Kieran



> ```
> 
> Gitlab pipeline failure:
> https://gitlab.freedesktop.org/chenghaoyang/libcamera/-/pipelines/1260412
> 
> Updates in v14:
> - Refactored ImageFrames to keep a list of filepaths directly.
> 
> Updates in v13:
> - Returned an errno in `FrameGenerete::generateFrame()`
> 
> Updates in v12:
> - Added ImageFrameGenerator first, then add Parser.
> - Removed ScaleMode argument, as only Fill is supported now.
> - Fixed bug of Stream's configuration usage in configure().
> 
> Updates in v11:
> - Allowed a single value in the config file's frame_rates field.
> 
> Updates in v10:
> Apply fixes according to Jacopo's and Barnabás' comments.
> - Split test_pattern and path fields in the yaml format.
> - Let FrameGenerators control frameCount_.
> - Fixed match() returning values.
> 
> Updates in v9: Allocate contiguous memory for planes in the same
> FrameBuffer.
> 
> BR,
> Harvey
> 
> Harvey Yang (6):
>   libcamera: add DmaBufAllocator::exportBuffers()
>   libcamera: Remove PipelineHandler Fatal check of non-empty
>     MediaDevices
>   libcamera: virtual: Add VirtualPipelineHandler
>   libcamera: virtual: Add ImageFrameGenerator
>   libcamera: virtual: Read config and register cameras based on the
>     config
>   libcamera: software_isp: Refactor SoftwareIsp to use
>     DmaBufAllocator::exportBuffers
> 
> Konami Shu (1):
>   libcamera: pipeline: Add test pattern for VirtualPipelineHandler
> 
>  .../libcamera/internal/dma_buf_allocator.h    |  13 +
>  meson.build                                   |   1 +
>  meson_options.txt                             |   3 +-
>  src/android/meson.build                       |  19 -
>  src/libcamera/dma_buf_allocator.cpp           |  57 +++
>  src/libcamera/pipeline/virtual/README.md      |  48 +++
>  .../pipeline/virtual/data/virtual.yaml        |  36 ++
>  .../pipeline/virtual/frame_generator.h        |  29 ++
>  .../virtual/image_frame_generator.cpp         | 169 ++++++++
>  .../pipeline/virtual/image_frame_generator.h  |  50 +++
>  src/libcamera/pipeline/virtual/meson.build    |  13 +
>  src/libcamera/pipeline/virtual/parser.cpp     | 260 ++++++++++++
>  src/libcamera/pipeline/virtual/parser.h       |  39 ++
>  .../virtual/test_pattern_generator.cpp        | 137 +++++++
>  .../pipeline/virtual/test_pattern_generator.h |  53 +++
>  src/libcamera/pipeline/virtual/virtual.cpp    | 382 ++++++++++++++++++
>  src/libcamera/pipeline/virtual/virtual.h      |  61 +++
>  src/libcamera/pipeline_handler.cpp            |  11 +-
>  src/libcamera/software_isp/software_isp.cpp   |  20 +-
>  src/meson.build                               |  19 +
>  20 files changed, 1378 insertions(+), 42 deletions(-)
>  create mode 100644 src/libcamera/pipeline/virtual/README.md
>  create mode 100644 src/libcamera/pipeline/virtual/data/virtual.yaml
>  create mode 100644 src/libcamera/pipeline/virtual/frame_generator.h
>  create mode 100644 src/libcamera/pipeline/virtual/image_frame_generator.cpp
>  create mode 100644 src/libcamera/pipeline/virtual/image_frame_generator.h
>  create mode 100644 src/libcamera/pipeline/virtual/meson.build
>  create mode 100644 src/libcamera/pipeline/virtual/parser.cpp
>  create mode 100644 src/libcamera/pipeline/virtual/parser.h
>  create mode 100644 src/libcamera/pipeline/virtual/test_pattern_generator.cpp
>  create mode 100644 src/libcamera/pipeline/virtual/test_pattern_generator.h
>  create mode 100644 src/libcamera/pipeline/virtual/virtual.cpp
>  create mode 100644 src/libcamera/pipeline/virtual/virtual.h
> 
> -- 
> 2.46.1.824.gd892dcdcdd-goog
>
Jacopo Mondi Oct. 3, 2024, 10:06 a.m. UTC | #2
Hi Harvey, Kieran

When enabling virtual explicitly with

$ meson setup -Dpipelines=virtual -Dtest=true build

    Enabled pipelines        : virtual
                               vimc
    Enabled IPA modules      : vimc


I see the gstreamer tests fail

11/76 libcamera:gstreamer / single_stream_test                           FAIL            0.06s   (exit status 255 or signal 127 SIGinvalid)
>>> GST_REGISTRY=libcamera/build/src/gstreamer/registry.data MALLOC_PERTURB_=174 ASAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1 LD_LIBRARY_PATH=libcamera/build/srclibcamera:libcamera/build/srclibcamera/base GST_PLUGIN_PATH=libcamera/build/src/gstreamer MSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 UBSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 libcamera/build/test/gstreamer/single_stream_test
――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ✀  ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
stderr:
[11:00:27.257053299] [96636]  INFO IPAManager ipa_manager.cpp:137 libcamera is not installed. Adding 'libcamera/build/src/ipa' to the IPA search path
[11:00:27.257480798] [96636]  INFO Camera camera_manager.cpp:325 libcamera v0.3.2+43-2024fd3c
[11:00:27.266082509] [96639]  INFO Pipeline pipeline_handler.cpp:607 libcamera is not installed. Loading platform configuration file from 'libcamera/srclibcamera/pipeline/virtual/data/virtual.yaml'
[11:00:27.268681746] [96639]  WARN CameraSensorProperties camera_sensor_properties.cpp:293 No static properties available for 'Sensor B'
[11:00:27.268695222] [96639]  WARN CameraSensorProperties camera_sensor_properties.cpp:295 Please consider updating the camera sensor properties database
[11:00:27.268705582] [96639]  WARN CameraSensor camera_sensor.cpp:477 'Sensor B': Failed to retrieve the camera location
[11:00:27.268712765] [96639]  WARN CameraSensor camera_sensor.cpp:499 'Sensor B': Rotation control not available, default to 0 degrees
[11:00:27.270796605] [96639]  INFO IPAProxy ipa_proxy.cpp:134 libcamera is not installed. Loading IPA configuration from 'libcamera/src/ipa/vimc/data'
[11:00:27.274312097] [96636]  INFO IPAManager ipa_manager.cpp:137 libcamera is not installed. Adding 'libcamera/build/src/ipa' to the IPA search path
[11:00:27.274519725] [96636]  INFO Camera camera_manager.cpp:325 libcamera v0.3.2+43-2024fd3c
[11:00:27.283135212] [96641]  WARN CameraSensorProperties camera_sensor_properties.cpp:293 No static properties available for 'Sensor B'
[11:00:27.283148687] [96641]  WARN CameraSensorProperties camera_sensor_properties.cpp:295 Please consider updating the camera sensor properties database
[11:00:27.283157194] [96641]  WARN CameraSensor camera_sensor.cpp:477 'Sensor B': Failed to retrieve the camera location
[11:00:27.283164107] [96641]  WARN CameraSensor camera_sensor.cpp:499 'Sensor B': Rotation control not available, default to 0 degrees
[11:00:27.284783458] [96641]  INFO IPAProxy ipa_proxy.cpp:134 libcamera is not installed. Loading IPA configuration from 'libcamera/src/ipa/vimc/data'
Unable to set the pipeline to the playing state.


14/76 libcamera:gstreamer / memory_lifetime_test                         FAIL            0.06s   (exit status 255 or signal 127 SIGinvalid)
>>> GST_REGISTRY=libcamera/build/src/gstreamer/registry.data ASAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1 MALLOC_PERTURB_=27 LD_LIBRARY_PATH=libcamera/build/srclibcamera:libcamera/build/srclibcamera/base GST_PLUGIN_PATH=libcamera/build/src/gstreamer MSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 UBSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 libcamera/build/test/gstreamer/memory_lifetime_test
――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ✀  ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
stderr:
[11:00:27.439322563] [96653]  INFO IPAManager ipa_manager.cpp:137 libcamera is not installed. Adding 'libcamera/build/src/ipa' to the IPA search path
[11:00:27.439765441] [96653]  INFO Camera camera_manager.cpp:325 libcamera v0.3.2+43-2024fd3c
[11:00:27.448559711] [96656]  INFO Pipeline pipeline_handler.cpp:607 libcamera is not installed. Loading platform configuration file from 'libcamera/srclibcamera/pipeline/virtual/data/virtual.yaml'
[11:00:27.451117569] [96656]  WARN CameraSensorProperties camera_sensor_properties.cpp:293 No static properties available for 'Sensor B'
[11:00:27.451131004] [96656]  WARN CameraSensorProperties camera_sensor_properties.cpp:295 Please consider updating the camera sensor properties database
[11:00:27.451141464] [96656]  WARN CameraSensor camera_sensor.cpp:477 'Sensor B': Failed to retrieve the camera location
[11:00:27.451148768] [96656]  WARN CameraSensor camera_sensor.cpp:499 'Sensor B': Rotation control not available, default to 0 degrees
[11:00:27.453229513] [96656]  INFO IPAProxy ipa_proxy.cpp:134 libcamera is not installed. Loading IPA configuration from 'libcamera/src/ipa/vimc/data'
[11:00:27.456577003] [96653]  INFO IPAManager ipa_manager.cpp:137 libcamera is not installed. Adding 'libcamera/build/src/ipa' to the IPA search path
[11:00:27.456783358] [96653]  INFO Camera camera_manager.cpp:325 libcamera v0.3.2+43-2024fd3c
[11:00:27.465133517] [96658]  WARN CameraSensorProperties camera_sensor_properties.cpp:293 No static properties available for 'Sensor B'
[11:00:27.465147213] [96658]  WARN CameraSensorProperties camera_sensor_properties.cpp:295 Please consider updating the camera sensor properties database
[11:00:27.465155890] [96658]  WARN CameraSensor camera_sensor.cpp:477 'Sensor B': Failed to retrieve the camera location
[11:00:27.465163013] [96658]  WARN CameraSensor camera_sensor.cpp:499 'Sensor B': Rotation control not available, default to 0 degrees
[11:00:27.466752627] [96658]  INFO IPAProxy ipa_proxy.cpp:134 libcamera is not installed. Loading IPA configuration from 'libcamera/src/ipa/vimc/data'
Unable to set the pipeline to the playing state.

If instead I don't specify any pipeline options but only enable test

$ meson setup -Dtest=true build

    Enabled pipelines        : ipu3
                               simple
                               uvcvideo
                               vimc
                               virtual
    Enabled IPA modules      : ipu3
                               simple
                               vimc
Both tests pass

11/76 libcamera:gstreamer / single_stream_test                           OK              3.84s
14/76 libcamera:gstreamer / memory_lifetime_test                         OK              0.27s

Reasons are not yet clear to me, but it would be helpful if you try to
reproduce locally and confirm it's not my local issue

Thanks
  j

On Thu, Oct 03, 2024 at 10:48:09AM GMT, Kieran Bingham wrote:
> Quoting Harvey Yang (2024-09-30 07:29:41)
> > Hi all,
> >
> > This series adds virtual pipeline handler, which doesn't depend on any
> > hardware, like camera sensor or ISP. Currently the configuration
> > supports test patterns and images.
> >
> > It passed the gitlab pipeline:
> > https://gitlab.freedesktop.org/chenghaoyang/libcamera/-/pipelines/1280687
> >
> > I've also checked that it works on qcam.
> >
> > I failed to pass multi_stream_test when trying to enable multiple
> > streams though. Please give me some hints what it tests and what I
> > missed:
> > ```
> > [295:43:43.910237144] [1441841]  INFO IPAManager ipa_manager.cpp:137 libcamera is not installed. Adding '/usr/local/google/home/chenghaoyang/Workspace/libca
> > mera/build/src/ipa' to the IPA search path
> > [295:43:43.914030564] [1441841]  INFO Camera camera_manager.cpp:325 libcamera v0.3.1+79-8ca4f033-dirty (2024-08-29T19:18:51UTC)
> > [295:43:43.915493754] [1441844] ERROR DmaBufAllocator dma_buf_allocator.cpp:120 Could not open any dma-buf provider
> > [295:43:43.919118835] [1441841]  INFO IPAManager ipa_manager.cpp:137 libcamera is not installed. Adding '/usr/local/google/home/chenghaoyang/Workspace/libca
> > mera/build/src/ipa' to the IPA search path
> > [295:43:43.922245825] [1441841]  INFO Camera camera_manager.cpp:325 libcamera v0.3.1+79-8ca4f033-dirty (2024-08-29T19:18:51UTC)
> > [295:43:43.922820175] [1441846] ERROR DmaBufAllocator dma_buf_allocator.cpp:120 Could not open any dma-buf provider
> > Unable to set the pipeline to the playing state.
>
> Is this the error you get when you enable multiple streams in the
> virtual pipeline handler?
>
> I still think that looks like an issue in the configuration of the VM
> not having udmabuf which you use.
>
>
> To fix this, you would probably need to fork the CI scripts:
>
>  - https://gitlab.freedesktop.org/camera/libcamera-ci
>
> And direct your local
> https://gitlab.freedesktop.org/chenghaoyang/libcamera to use that while
> you work out the issue.
>
> I suspect you need to add something at
>
> https://gitlab.freedesktop.org/camera/libcamera-ci/-/blob/master/.gitlab-ci/build-kernel.sh?ref_type=heads#L41
>
> to enable the uDMA config options...
>
> --
> Kieran
>
>
>
> > ```
> >
> > Gitlab pipeline failure:
> > https://gitlab.freedesktop.org/chenghaoyang/libcamera/-/pipelines/1260412
> >
> > Updates in v14:
> > - Refactored ImageFrames to keep a list of filepaths directly.
> >
> > Updates in v13:
> > - Returned an errno in `FrameGenerete::generateFrame()`
> >
> > Updates in v12:
> > - Added ImageFrameGenerator first, then add Parser.
> > - Removed ScaleMode argument, as only Fill is supported now.
> > - Fixed bug of Stream's configuration usage in configure().
> >
> > Updates in v11:
> > - Allowed a single value in the config file's frame_rates field.
> >
> > Updates in v10:
> > Apply fixes according to Jacopo's and Barnabás' comments.
> > - Split test_pattern and path fields in the yaml format.
> > - Let FrameGenerators control frameCount_.
> > - Fixed match() returning values.
> >
> > Updates in v9: Allocate contiguous memory for planes in the same
> > FrameBuffer.
> >
> > BR,
> > Harvey
> >
> > Harvey Yang (6):
> >   libcamera: add DmaBufAllocator::exportBuffers()
> >   libcamera: Remove PipelineHandler Fatal check of non-empty
> >     MediaDevices
> >   libcamera: virtual: Add VirtualPipelineHandler
> >   libcamera: virtual: Add ImageFrameGenerator
> >   libcamera: virtual: Read config and register cameras based on the
> >     config
> >   libcamera: software_isp: Refactor SoftwareIsp to use
> >     DmaBufAllocator::exportBuffers
> >
> > Konami Shu (1):
> >   libcamera: pipeline: Add test pattern for VirtualPipelineHandler
> >
> >  .../libcamera/internal/dma_buf_allocator.h    |  13 +
> >  meson.build                                   |   1 +
> >  meson_options.txt                             |   3 +-
> >  src/android/meson.build                       |  19 -
> >  src/libcamera/dma_buf_allocator.cpp           |  57 +++
> >  src/libcamera/pipeline/virtual/README.md      |  48 +++
> >  .../pipeline/virtual/data/virtual.yaml        |  36 ++
> >  .../pipeline/virtual/frame_generator.h        |  29 ++
> >  .../virtual/image_frame_generator.cpp         | 169 ++++++++
> >  .../pipeline/virtual/image_frame_generator.h  |  50 +++
> >  src/libcamera/pipeline/virtual/meson.build    |  13 +
> >  src/libcamera/pipeline/virtual/parser.cpp     | 260 ++++++++++++
> >  src/libcamera/pipeline/virtual/parser.h       |  39 ++
> >  .../virtual/test_pattern_generator.cpp        | 137 +++++++
> >  .../pipeline/virtual/test_pattern_generator.h |  53 +++
> >  src/libcamera/pipeline/virtual/virtual.cpp    | 382 ++++++++++++++++++
> >  src/libcamera/pipeline/virtual/virtual.h      |  61 +++
> >  src/libcamera/pipeline_handler.cpp            |  11 +-
> >  src/libcamera/software_isp/software_isp.cpp   |  20 +-
> >  src/meson.build                               |  19 +
> >  20 files changed, 1378 insertions(+), 42 deletions(-)
> >  create mode 100644 src/libcamera/pipeline/virtual/README.md
> >  create mode 100644 src/libcamera/pipeline/virtual/data/virtual.yaml
> >  create mode 100644 src/libcamera/pipeline/virtual/frame_generator.h
> >  create mode 100644 src/libcamera/pipeline/virtual/image_frame_generator.cpp
> >  create mode 100644 src/libcamera/pipeline/virtual/image_frame_generator.h
> >  create mode 100644 src/libcamera/pipeline/virtual/meson.build
> >  create mode 100644 src/libcamera/pipeline/virtual/parser.cpp
> >  create mode 100644 src/libcamera/pipeline/virtual/parser.h
> >  create mode 100644 src/libcamera/pipeline/virtual/test_pattern_generator.cpp
> >  create mode 100644 src/libcamera/pipeline/virtual/test_pattern_generator.h
> >  create mode 100644 src/libcamera/pipeline/virtual/virtual.cpp
> >  create mode 100644 src/libcamera/pipeline/virtual/virtual.h
> >
> > --
> > 2.46.1.824.gd892dcdcdd-goog
> >
Harvey Yang Oct. 3, 2024, 10:06 a.m. UTC | #3
Hi Kieran,

On Thu, Oct 3, 2024 at 5:48 PM Kieran Bingham
<kieran.bingham@ideasonboard.com> wrote:
>
> Quoting Harvey Yang (2024-09-30 07:29:41)
> > Hi all,
> >
> > This series adds virtual pipeline handler, which doesn't depend on any
> > hardware, like camera sensor or ISP. Currently the configuration
> > supports test patterns and images.
> >
> > It passed the gitlab pipeline:
> > https://gitlab.freedesktop.org/chenghaoyang/libcamera/-/pipelines/1280687
> >
> > I've also checked that it works on qcam.
> >
> > I failed to pass multi_stream_test when trying to enable multiple
> > streams though. Please give me some hints what it tests and what I
> > missed:
> > ```
> > [295:43:43.910237144] [1441841]  INFO IPAManager ipa_manager.cpp:137 libcamera is not installed. Adding '/usr/local/google/home/chenghaoyang/Workspace/libca
> > mera/build/src/ipa' to the IPA search path
> > [295:43:43.914030564] [1441841]  INFO Camera camera_manager.cpp:325 libcamera v0.3.1+79-8ca4f033-dirty (2024-08-29T19:18:51UTC)
> > [295:43:43.915493754] [1441844] ERROR DmaBufAllocator dma_buf_allocator.cpp:120 Could not open any dma-buf provider
> > [295:43:43.919118835] [1441841]  INFO IPAManager ipa_manager.cpp:137 libcamera is not installed. Adding '/usr/local/google/home/chenghaoyang/Workspace/libca
> > mera/build/src/ipa' to the IPA search path
> > [295:43:43.922245825] [1441841]  INFO Camera camera_manager.cpp:325 libcamera v0.3.1+79-8ca4f033-dirty (2024-08-29T19:18:51UTC)
> > [295:43:43.922820175] [1441846] ERROR DmaBufAllocator dma_buf_allocator.cpp:120 Could not open any dma-buf provider
> > Unable to set the pipeline to the playing state.
>
> Is this the error you get when you enable multiple streams in the
> virtual pipeline handler?

Correct :)

>
> I still think that looks like an issue in the configuration of the VM
> not having udmabuf which you use.

Hmm, as I shared before, the pipeline unit test still fails when I
support a workaround memfd_create:
https://gitlab.freedesktop.org/chenghaoyang/libcamera/-/pipelines/1279655
, which contains:
https://gitlab.freedesktop.org/chenghaoyang/libcamera/-/commit/9f032290fc97dae1fbace2314420a73251169cee

At least it works on my gLinux environment.
Doesn't that imply that it's not because of DmaBufAllocator?

Also, single_stream_test passed. I assume it also tests on the
buffers if multi_stream_test does?

BR,
Harvey

>
>
> To fix this, you would probably need to fork the CI scripts:
>
>  - https://gitlab.freedesktop.org/camera/libcamera-ci
>
> And direct your local
> https://gitlab.freedesktop.org/chenghaoyang/libcamera to use that while
> you work out the issue.
>
> I suspect you need to add something at
>
> https://gitlab.freedesktop.org/camera/libcamera-ci/-/blob/master/.gitlab-ci/build-kernel.sh?ref_type=heads#L41
>
> to enable the uDMA config options...
>
> --
> Kieran
>
>
>
> > ```
> >
> > Gitlab pipeline failure:
> > https://gitlab.freedesktop.org/chenghaoyang/libcamera/-/pipelines/1260412
> >
> > Updates in v14:
> > - Refactored ImageFrames to keep a list of filepaths directly.
> >
> > Updates in v13:
> > - Returned an errno in `FrameGenerete::generateFrame()`
> >
> > Updates in v12:
> > - Added ImageFrameGenerator first, then add Parser.
> > - Removed ScaleMode argument, as only Fill is supported now.
> > - Fixed bug of Stream's configuration usage in configure().
> >
> > Updates in v11:
> > - Allowed a single value in the config file's frame_rates field.
> >
> > Updates in v10:
> > Apply fixes according to Jacopo's and Barnabás' comments.
> > - Split test_pattern and path fields in the yaml format.
> > - Let FrameGenerators control frameCount_.
> > - Fixed match() returning values.
> >
> > Updates in v9: Allocate contiguous memory for planes in the same
> > FrameBuffer.
> >
> > BR,
> > Harvey
> >
> > Harvey Yang (6):
> >   libcamera: add DmaBufAllocator::exportBuffers()
> >   libcamera: Remove PipelineHandler Fatal check of non-empty
> >     MediaDevices
> >   libcamera: virtual: Add VirtualPipelineHandler
> >   libcamera: virtual: Add ImageFrameGenerator
> >   libcamera: virtual: Read config and register cameras based on the
> >     config
> >   libcamera: software_isp: Refactor SoftwareIsp to use
> >     DmaBufAllocator::exportBuffers
> >
> > Konami Shu (1):
> >   libcamera: pipeline: Add test pattern for VirtualPipelineHandler
> >
> >  .../libcamera/internal/dma_buf_allocator.h    |  13 +
> >  meson.build                                   |   1 +
> >  meson_options.txt                             |   3 +-
> >  src/android/meson.build                       |  19 -
> >  src/libcamera/dma_buf_allocator.cpp           |  57 +++
> >  src/libcamera/pipeline/virtual/README.md      |  48 +++
> >  .../pipeline/virtual/data/virtual.yaml        |  36 ++
> >  .../pipeline/virtual/frame_generator.h        |  29 ++
> >  .../virtual/image_frame_generator.cpp         | 169 ++++++++
> >  .../pipeline/virtual/image_frame_generator.h  |  50 +++
> >  src/libcamera/pipeline/virtual/meson.build    |  13 +
> >  src/libcamera/pipeline/virtual/parser.cpp     | 260 ++++++++++++
> >  src/libcamera/pipeline/virtual/parser.h       |  39 ++
> >  .../virtual/test_pattern_generator.cpp        | 137 +++++++
> >  .../pipeline/virtual/test_pattern_generator.h |  53 +++
> >  src/libcamera/pipeline/virtual/virtual.cpp    | 382 ++++++++++++++++++
> >  src/libcamera/pipeline/virtual/virtual.h      |  61 +++
> >  src/libcamera/pipeline_handler.cpp            |  11 +-
> >  src/libcamera/software_isp/software_isp.cpp   |  20 +-
> >  src/meson.build                               |  19 +
> >  20 files changed, 1378 insertions(+), 42 deletions(-)
> >  create mode 100644 src/libcamera/pipeline/virtual/README.md
> >  create mode 100644 src/libcamera/pipeline/virtual/data/virtual.yaml
> >  create mode 100644 src/libcamera/pipeline/virtual/frame_generator.h
> >  create mode 100644 src/libcamera/pipeline/virtual/image_frame_generator.cpp
> >  create mode 100644 src/libcamera/pipeline/virtual/image_frame_generator.h
> >  create mode 100644 src/libcamera/pipeline/virtual/meson.build
> >  create mode 100644 src/libcamera/pipeline/virtual/parser.cpp
> >  create mode 100644 src/libcamera/pipeline/virtual/parser.h
> >  create mode 100644 src/libcamera/pipeline/virtual/test_pattern_generator.cpp
> >  create mode 100644 src/libcamera/pipeline/virtual/test_pattern_generator.h
> >  create mode 100644 src/libcamera/pipeline/virtual/virtual.cpp
> >  create mode 100644 src/libcamera/pipeline/virtual/virtual.h
> >
> > --
> > 2.46.1.824.gd892dcdcdd-goog
> >
Harvey Yang Oct. 3, 2024, 10:33 a.m. UTC | #4
Hi Jacopo,

On Thu, Oct 3, 2024 at 6:06 PM Jacopo Mondi
<jacopo.mondi@ideasonboard.com> wrote:
>
> Hi Harvey, Kieran
>
> When enabling virtual explicitly with
>
> $ meson setup -Dpipelines=virtual -Dtest=true build
>
>     Enabled pipelines        : virtual
>                                vimc
>     Enabled IPA modules      : vimc
>
>
> I see the gstreamer tests fail
>
> 11/76 libcamera:gstreamer / single_stream_test                           FAIL            0.06s   (exit status 255 or signal 127 SIGinvalid)
> >>> GST_REGISTRY=libcamera/build/src/gstreamer/registry.data MALLOC_PERTURB_=174 ASAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1 LD_LIBRARY_PATH=libcamera/build/srclibcamera:libcamera/build/srclibcamera/base GST_PLUGIN_PATH=libcamera/build/src/gstreamer MSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 UBSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 libcamera/build/test/gstreamer/single_stream_test

Yeah I can reproduce this failure:
```
$ GST_PLUGIN_PATH=build/src/gstreamer
GST_REGISTRY=build/src/gstreamer/registry.data MALLOC_PERTURB_=153
LD_LIBRARY_PATH=build/src/libcamera:build/src/libcamera/base
build/test/gstreamer/single_stream_test

[31:51:17.514101690] [2680981]  INFO IPAManager ipa_manager.cpp:137
libcamera is not installed. Adding
'/usr/local/google/home/chenghaoyang/Workspace/libcamera/build/src/ipa'
to the IPA search path

[31:51:17.517267110] [2680981]  INFO Camera camera_manager.cpp:325
libcamera v0.3.2+51-6f273618

[31:51:17.518210970] [2680984]  INFO DmaBufAllocator
dma_buf_allocator.cpp:99 DmaBufAllocator c'tor

[31:51:17.518301870] [2680984] ERROR DmaBufAllocator
dma_buf_allocator.cpp:122 Could not open any dma-buf provider

[31:51:17.518748059] [2680984]  INFO Pipeline pipeline_handler.cpp:607
libcamera is not installed. Loading platform configuration file from
'/usr/local/google/home/chenghaoyang/Workspace/libcamera/src/libcamera/pipeline/virtual/data/virtual.yaml'

[31:51:17.520074039] [2680984]  INFO DmaBufAllocator
dma_buf_allocator.cpp:99 DmaBufAllocator c'tor

[31:51:17.520130179] [2680984] ERROR DmaBufAllocator
dma_buf_allocator.cpp:122 Could not open any dma-buf provider

[31:51:17.523026569] [2680981]  INFO IPAManager ipa_manager.cpp:137
libcamera is not installed. Adding
'/usr/local/google/home/chenghaoyang/Workspace/libcamera/build/src/ipa'
to the IPA search path

[31:51:17.525582209] [2680981]  INFO Camera camera_manager.cpp:325
libcamera v0.3.2+51-6f273618

[31:51:17.526380639] [2680986]  INFO DmaBufAllocator
dma_buf_allocator.cpp:99 DmaBufAllocator c'tor

[31:51:17.526479529] [2680986] ERROR DmaBufAllocator
dma_buf_allocator.cpp:122 Could not open any dma-buf provider

Unable to set the pipeline to the playing state.

```

Not sure why the gitlab pipeline doesn't catch this...

> ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ✀  ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
> stderr:
> [11:00:27.257053299] [96636]  INFO IPAManager ipa_manager.cpp:137 libcamera is not installed. Adding 'libcamera/build/src/ipa' to the IPA search path
> [11:00:27.257480798] [96636]  INFO Camera camera_manager.cpp:325 libcamera v0.3.2+43-2024fd3c
> [11:00:27.266082509] [96639]  INFO Pipeline pipeline_handler.cpp:607 libcamera is not installed. Loading platform configuration file from 'libcamera/srclibcamera/pipeline/virtual/data/virtual.yaml'
> [11:00:27.268681746] [96639]  WARN CameraSensorProperties camera_sensor_properties.cpp:293 No static properties available for 'Sensor B'
> [11:00:27.268695222] [96639]  WARN CameraSensorProperties camera_sensor_properties.cpp:295 Please consider updating the camera sensor properties database
> [11:00:27.268705582] [96639]  WARN CameraSensor camera_sensor.cpp:477 'Sensor B': Failed to retrieve the camera location
> [11:00:27.268712765] [96639]  WARN CameraSensor camera_sensor.cpp:499 'Sensor B': Rotation control not available, default to 0 degrees
> [11:00:27.270796605] [96639]  INFO IPAProxy ipa_proxy.cpp:134 libcamera is not installed. Loading IPA configuration from 'libcamera/src/ipa/vimc/data'
> [11:00:27.274312097] [96636]  INFO IPAManager ipa_manager.cpp:137 libcamera is not installed. Adding 'libcamera/build/src/ipa' to the IPA search path
> [11:00:27.274519725] [96636]  INFO Camera camera_manager.cpp:325 libcamera v0.3.2+43-2024fd3c
> [11:00:27.283135212] [96641]  WARN CameraSensorProperties camera_sensor_properties.cpp:293 No static properties available for 'Sensor B'
> [11:00:27.283148687] [96641]  WARN CameraSensorProperties camera_sensor_properties.cpp:295 Please consider updating the camera sensor properties database
> [11:00:27.283157194] [96641]  WARN CameraSensor camera_sensor.cpp:477 'Sensor B': Failed to retrieve the camera location
> [11:00:27.283164107] [96641]  WARN CameraSensor camera_sensor.cpp:499 'Sensor B': Rotation control not available, default to 0 degrees
> [11:00:27.284783458] [96641]  INFO IPAProxy ipa_proxy.cpp:134 libcamera is not installed. Loading IPA configuration from 'libcamera/src/ipa/vimc/data'
> Unable to set the pipeline to the playing state.
>
>
> 14/76 libcamera:gstreamer / memory_lifetime_test                         FAIL            0.06s   (exit status 255 or signal 127 SIGinvalid)
> >>> GST_REGISTRY=libcamera/build/src/gstreamer/registry.data ASAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1 MALLOC_PERTURB_=27 LD_LIBRARY_PATH=libcamera/build/srclibcamera:libcamera/build/srclibcamera/base GST_PLUGIN_PATH=libcamera/build/src/gstreamer MSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 UBSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 libcamera/build/test/gstreamer/memory_lifetime_test
> ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ✀  ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
> stderr:
> [11:00:27.439322563] [96653]  INFO IPAManager ipa_manager.cpp:137 libcamera is not installed. Adding 'libcamera/build/src/ipa' to the IPA search path
> [11:00:27.439765441] [96653]  INFO Camera camera_manager.cpp:325 libcamera v0.3.2+43-2024fd3c
> [11:00:27.448559711] [96656]  INFO Pipeline pipeline_handler.cpp:607 libcamera is not installed. Loading platform configuration file from 'libcamera/srclibcamera/pipeline/virtual/data/virtual.yaml'
> [11:00:27.451117569] [96656]  WARN CameraSensorProperties camera_sensor_properties.cpp:293 No static properties available for 'Sensor B'
> [11:00:27.451131004] [96656]  WARN CameraSensorProperties camera_sensor_properties.cpp:295 Please consider updating the camera sensor properties database
> [11:00:27.451141464] [96656]  WARN CameraSensor camera_sensor.cpp:477 'Sensor B': Failed to retrieve the camera location
> [11:00:27.451148768] [96656]  WARN CameraSensor camera_sensor.cpp:499 'Sensor B': Rotation control not available, default to 0 degrees
> [11:00:27.453229513] [96656]  INFO IPAProxy ipa_proxy.cpp:134 libcamera is not installed. Loading IPA configuration from 'libcamera/src/ipa/vimc/data'
> [11:00:27.456577003] [96653]  INFO IPAManager ipa_manager.cpp:137 libcamera is not installed. Adding 'libcamera/build/src/ipa' to the IPA search path
> [11:00:27.456783358] [96653]  INFO Camera camera_manager.cpp:325 libcamera v0.3.2+43-2024fd3c
> [11:00:27.465133517] [96658]  WARN CameraSensorProperties camera_sensor_properties.cpp:293 No static properties available for 'Sensor B'
> [11:00:27.465147213] [96658]  WARN CameraSensorProperties camera_sensor_properties.cpp:295 Please consider updating the camera sensor properties database
> [11:00:27.465155890] [96658]  WARN CameraSensor camera_sensor.cpp:477 'Sensor B': Failed to retrieve the camera location
> [11:00:27.465163013] [96658]  WARN CameraSensor camera_sensor.cpp:499 'Sensor B': Rotation control not available, default to 0 degrees
> [11:00:27.466752627] [96658]  INFO IPAProxy ipa_proxy.cpp:134 libcamera is not installed. Loading IPA configuration from 'libcamera/src/ipa/vimc/data'
> Unable to set the pipeline to the playing state.
>
> If instead I don't specify any pipeline options but only enable test
>
> $ meson setup -Dtest=true build
>
>     Enabled pipelines        : ipu3
>                                simple
>                                uvcvideo
>                                vimc
>                                virtual

This is different from mine:
```
$ meson setup -Dtest=true build --reconfigure
...
    Enabled pipelines        : virtual
                               vimc
...
```



>     Enabled IPA modules      : ipu3
>                                simple
>                                vimc
> Both tests pass
>
> 11/76 libcamera:gstreamer / single_stream_test                           OK              3.84s
> 14/76 libcamera:gstreamer / memory_lifetime_test                         OK              0.27s
>
> Reasons are not yet clear to me, but it would be helpful if you try to
> reproduce locally and confirm it's not my local issue
>
> Thanks
>   j
>
> On Thu, Oct 03, 2024 at 10:48:09AM GMT, Kieran Bingham wrote:
> > Quoting Harvey Yang (2024-09-30 07:29:41)
> > > Hi all,
> > >
> > > This series adds virtual pipeline handler, which doesn't depend on any
> > > hardware, like camera sensor or ISP. Currently the configuration
> > > supports test patterns and images.
> > >
> > > It passed the gitlab pipeline:
> > > https://gitlab.freedesktop.org/chenghaoyang/libcamera/-/pipelines/1280687
> > >
> > > I've also checked that it works on qcam.
> > >
> > > I failed to pass multi_stream_test when trying to enable multiple
> > > streams though. Please give me some hints what it tests and what I
> > > missed:
> > > ```
> > > [295:43:43.910237144] [1441841]  INFO IPAManager ipa_manager.cpp:137 libcamera is not installed. Adding '/usr/local/google/home/chenghaoyang/Workspace/libca
> > > mera/build/src/ipa' to the IPA search path
> > > [295:43:43.914030564] [1441841]  INFO Camera camera_manager.cpp:325 libcamera v0.3.1+79-8ca4f033-dirty (2024-08-29T19:18:51UTC)
> > > [295:43:43.915493754] [1441844] ERROR DmaBufAllocator dma_buf_allocator.cpp:120 Could not open any dma-buf provider
> > > [295:43:43.919118835] [1441841]  INFO IPAManager ipa_manager.cpp:137 libcamera is not installed. Adding '/usr/local/google/home/chenghaoyang/Workspace/libca
> > > mera/build/src/ipa' to the IPA search path
> > > [295:43:43.922245825] [1441841]  INFO Camera camera_manager.cpp:325 libcamera v0.3.1+79-8ca4f033-dirty (2024-08-29T19:18:51UTC)
> > > [295:43:43.922820175] [1441846] ERROR DmaBufAllocator dma_buf_allocator.cpp:120 Could not open any dma-buf provider
> > > Unable to set the pipeline to the playing state.
> >
> > Is this the error you get when you enable multiple streams in the
> > virtual pipeline handler?
> >
> > I still think that looks like an issue in the configuration of the VM
> > not having udmabuf which you use.
> >
> >
> > To fix this, you would probably need to fork the CI scripts:
> >
> >  - https://gitlab.freedesktop.org/camera/libcamera-ci
> >
> > And direct your local
> > https://gitlab.freedesktop.org/chenghaoyang/libcamera to use that while
> > you work out the issue.
> >
> > I suspect you need to add something at
> >
> > https://gitlab.freedesktop.org/camera/libcamera-ci/-/blob/master/.gitlab-ci/build-kernel.sh?ref_type=heads#L41
> >
> > to enable the uDMA config options...
> >
> > --
> > Kieran
> >
> >
> >
> > > ```
> > >
> > > Gitlab pipeline failure:
> > > https://gitlab.freedesktop.org/chenghaoyang/libcamera/-/pipelines/1260412
> > >
> > > Updates in v14:
> > > - Refactored ImageFrames to keep a list of filepaths directly.
> > >
> > > Updates in v13:
> > > - Returned an errno in `FrameGenerete::generateFrame()`
> > >
> > > Updates in v12:
> > > - Added ImageFrameGenerator first, then add Parser.
> > > - Removed ScaleMode argument, as only Fill is supported now.
> > > - Fixed bug of Stream's configuration usage in configure().
> > >
> > > Updates in v11:
> > > - Allowed a single value in the config file's frame_rates field.
> > >
> > > Updates in v10:
> > > Apply fixes according to Jacopo's and Barnabás' comments.
> > > - Split test_pattern and path fields in the yaml format.
> > > - Let FrameGenerators control frameCount_.
> > > - Fixed match() returning values.
> > >
> > > Updates in v9: Allocate contiguous memory for planes in the same
> > > FrameBuffer.
> > >
> > > BR,
> > > Harvey
> > >
> > > Harvey Yang (6):
> > >   libcamera: add DmaBufAllocator::exportBuffers()
> > >   libcamera: Remove PipelineHandler Fatal check of non-empty
> > >     MediaDevices
> > >   libcamera: virtual: Add VirtualPipelineHandler
> > >   libcamera: virtual: Add ImageFrameGenerator
> > >   libcamera: virtual: Read config and register cameras based on the
> > >     config
> > >   libcamera: software_isp: Refactor SoftwareIsp to use
> > >     DmaBufAllocator::exportBuffers
> > >
> > > Konami Shu (1):
> > >   libcamera: pipeline: Add test pattern for VirtualPipelineHandler
> > >
> > >  .../libcamera/internal/dma_buf_allocator.h    |  13 +
> > >  meson.build                                   |   1 +
> > >  meson_options.txt                             |   3 +-
> > >  src/android/meson.build                       |  19 -
> > >  src/libcamera/dma_buf_allocator.cpp           |  57 +++
> > >  src/libcamera/pipeline/virtual/README.md      |  48 +++
> > >  .../pipeline/virtual/data/virtual.yaml        |  36 ++
> > >  .../pipeline/virtual/frame_generator.h        |  29 ++
> > >  .../virtual/image_frame_generator.cpp         | 169 ++++++++
> > >  .../pipeline/virtual/image_frame_generator.h  |  50 +++
> > >  src/libcamera/pipeline/virtual/meson.build    |  13 +
> > >  src/libcamera/pipeline/virtual/parser.cpp     | 260 ++++++++++++
> > >  src/libcamera/pipeline/virtual/parser.h       |  39 ++
> > >  .../virtual/test_pattern_generator.cpp        | 137 +++++++
> > >  .../pipeline/virtual/test_pattern_generator.h |  53 +++
> > >  src/libcamera/pipeline/virtual/virtual.cpp    | 382 ++++++++++++++++++
> > >  src/libcamera/pipeline/virtual/virtual.h      |  61 +++
> > >  src/libcamera/pipeline_handler.cpp            |  11 +-
> > >  src/libcamera/software_isp/software_isp.cpp   |  20 +-
> > >  src/meson.build                               |  19 +
> > >  20 files changed, 1378 insertions(+), 42 deletions(-)
> > >  create mode 100644 src/libcamera/pipeline/virtual/README.md
> > >  create mode 100644 src/libcamera/pipeline/virtual/data/virtual.yaml
> > >  create mode 100644 src/libcamera/pipeline/virtual/frame_generator.h
> > >  create mode 100644 src/libcamera/pipeline/virtual/image_frame_generator.cpp
> > >  create mode 100644 src/libcamera/pipeline/virtual/image_frame_generator.h
> > >  create mode 100644 src/libcamera/pipeline/virtual/meson.build
> > >  create mode 100644 src/libcamera/pipeline/virtual/parser.cpp
> > >  create mode 100644 src/libcamera/pipeline/virtual/parser.h
> > >  create mode 100644 src/libcamera/pipeline/virtual/test_pattern_generator.cpp
> > >  create mode 100644 src/libcamera/pipeline/virtual/test_pattern_generator.h
> > >  create mode 100644 src/libcamera/pipeline/virtual/virtual.cpp
> > >  create mode 100644 src/libcamera/pipeline/virtual/virtual.h
> > >
> > > --
> > > 2.46.1.824.gd892dcdcdd-goog
> > >

BR,
Harvey
Kieran Bingham Oct. 3, 2024, 10:37 a.m. UTC | #5
Quoting Cheng-Hao Yang (2024-10-03 11:06:58)
> Hi Kieran,
> 
> On Thu, Oct 3, 2024 at 5:48 PM Kieran Bingham
> <kieran.bingham@ideasonboard.com> wrote:
> >
> > Quoting Harvey Yang (2024-09-30 07:29:41)
> > > Hi all,
> > >
> > > This series adds virtual pipeline handler, which doesn't depend on any
> > > hardware, like camera sensor or ISP. Currently the configuration
> > > supports test patterns and images.
> > >
> > > It passed the gitlab pipeline:
> > > https://gitlab.freedesktop.org/chenghaoyang/libcamera/-/pipelines/1280687
> > >
> > > I've also checked that it works on qcam.
> > >
> > > I failed to pass multi_stream_test when trying to enable multiple
> > > streams though. Please give me some hints what it tests and what I
> > > missed:
> > > ```
> > > [295:43:43.910237144] [1441841]  INFO IPAManager ipa_manager.cpp:137 libcamera is not installed. Adding '/usr/local/google/home/chenghaoyang/Workspace/libca
> > > mera/build/src/ipa' to the IPA search path
> > > [295:43:43.914030564] [1441841]  INFO Camera camera_manager.cpp:325 libcamera v0.3.1+79-8ca4f033-dirty (2024-08-29T19:18:51UTC)
> > > [295:43:43.915493754] [1441844] ERROR DmaBufAllocator dma_buf_allocator.cpp:120 Could not open any dma-buf provider
> > > [295:43:43.919118835] [1441841]  INFO IPAManager ipa_manager.cpp:137 libcamera is not installed. Adding '/usr/local/google/home/chenghaoyang/Workspace/libca
> > > mera/build/src/ipa' to the IPA search path
> > > [295:43:43.922245825] [1441841]  INFO Camera camera_manager.cpp:325 libcamera v0.3.1+79-8ca4f033-dirty (2024-08-29T19:18:51UTC)
> > > [295:43:43.922820175] [1441846] ERROR DmaBufAllocator dma_buf_allocator.cpp:120 Could not open any dma-buf provider
> > > Unable to set the pipeline to the playing state.
> >
> > Is this the error you get when you enable multiple streams in the
> > virtual pipeline handler?
> 
> Correct :)
> 
> >
> > I still think that looks like an issue in the configuration of the VM
> > not having udmabuf which you use.
> 
> Hmm, as I shared before, the pipeline unit test still fails when I
> support a workaround memfd_create:
> https://gitlab.freedesktop.org/chenghaoyang/libcamera/-/pipelines/1279655
> , which contains:
> https://gitlab.freedesktop.org/chenghaoyang/libcamera/-/commit/9f032290fc97dae1fbace2314420a73251169cee

Your patch tries to use Memfd instead. Did you check if the CI kernel
has support for MEMFD? Is that a configuration option in the kernel ?

Isn't udmabuf constructed from a memfd ultimately ?

If you export a memfd file descriptor - will that break elsewhere
because it's not a DMABuf handle? (That's the whole point of udmabuf
right ?)

I think changing to memfd to test if that's the cause of the udmabuf
issue is just changing one set of issues for another.



> 
> At least it works on my gLinux environment.
> Doesn't that imply that it's not because of DmaBufAllocator?

No ? Maybe your gLinux environment has the appropriate / required
features enabled!


> Also, single_stream_test passed. I assume it also tests on the
> buffers if multi_stream_test does?

I'm not sure I understand this question...

--
Kieran


> 
> BR,
> Harvey
> 
> >
> >
> > To fix this, you would probably need to fork the CI scripts:
> >
> >  - https://gitlab.freedesktop.org/camera/libcamera-ci
> >
> > And direct your local
> > https://gitlab.freedesktop.org/chenghaoyang/libcamera to use that while
> > you work out the issue.
> >
> > I suspect you need to add something at
> >
> > https://gitlab.freedesktop.org/camera/libcamera-ci/-/blob/master/.gitlab-ci/build-kernel.sh?ref_type=heads#L41
> >
> > to enable the uDMA config options...
> >
> > --
> > Kieran
> >
> >
> >
> > > ```
> > >
> > > Gitlab pipeline failure:
> > > https://gitlab.freedesktop.org/chenghaoyang/libcamera/-/pipelines/1260412
> > >
> > > Updates in v14:
> > > - Refactored ImageFrames to keep a list of filepaths directly.
> > >
> > > Updates in v13:
> > > - Returned an errno in `FrameGenerete::generateFrame()`
> > >
> > > Updates in v12:
> > > - Added ImageFrameGenerator first, then add Parser.
> > > - Removed ScaleMode argument, as only Fill is supported now.
> > > - Fixed bug of Stream's configuration usage in configure().
> > >
> > > Updates in v11:
> > > - Allowed a single value in the config file's frame_rates field.
> > >
> > > Updates in v10:
> > > Apply fixes according to Jacopo's and Barnabás' comments.
> > > - Split test_pattern and path fields in the yaml format.
> > > - Let FrameGenerators control frameCount_.
> > > - Fixed match() returning values.
> > >
> > > Updates in v9: Allocate contiguous memory for planes in the same
> > > FrameBuffer.
> > >
> > > BR,
> > > Harvey
> > >
> > > Harvey Yang (6):
> > >   libcamera: add DmaBufAllocator::exportBuffers()
> > >   libcamera: Remove PipelineHandler Fatal check of non-empty
> > >     MediaDevices
> > >   libcamera: virtual: Add VirtualPipelineHandler
> > >   libcamera: virtual: Add ImageFrameGenerator
> > >   libcamera: virtual: Read config and register cameras based on the
> > >     config
> > >   libcamera: software_isp: Refactor SoftwareIsp to use
> > >     DmaBufAllocator::exportBuffers
> > >
> > > Konami Shu (1):
> > >   libcamera: pipeline: Add test pattern for VirtualPipelineHandler
> > >
> > >  .../libcamera/internal/dma_buf_allocator.h    |  13 +
> > >  meson.build                                   |   1 +
> > >  meson_options.txt                             |   3 +-
> > >  src/android/meson.build                       |  19 -
> > >  src/libcamera/dma_buf_allocator.cpp           |  57 +++
> > >  src/libcamera/pipeline/virtual/README.md      |  48 +++
> > >  .../pipeline/virtual/data/virtual.yaml        |  36 ++
> > >  .../pipeline/virtual/frame_generator.h        |  29 ++
> > >  .../virtual/image_frame_generator.cpp         | 169 ++++++++
> > >  .../pipeline/virtual/image_frame_generator.h  |  50 +++
> > >  src/libcamera/pipeline/virtual/meson.build    |  13 +
> > >  src/libcamera/pipeline/virtual/parser.cpp     | 260 ++++++++++++
> > >  src/libcamera/pipeline/virtual/parser.h       |  39 ++
> > >  .../virtual/test_pattern_generator.cpp        | 137 +++++++
> > >  .../pipeline/virtual/test_pattern_generator.h |  53 +++
> > >  src/libcamera/pipeline/virtual/virtual.cpp    | 382 ++++++++++++++++++
> > >  src/libcamera/pipeline/virtual/virtual.h      |  61 +++
> > >  src/libcamera/pipeline_handler.cpp            |  11 +-
> > >  src/libcamera/software_isp/software_isp.cpp   |  20 +-
> > >  src/meson.build                               |  19 +
> > >  20 files changed, 1378 insertions(+), 42 deletions(-)
> > >  create mode 100644 src/libcamera/pipeline/virtual/README.md
> > >  create mode 100644 src/libcamera/pipeline/virtual/data/virtual.yaml
> > >  create mode 100644 src/libcamera/pipeline/virtual/frame_generator.h
> > >  create mode 100644 src/libcamera/pipeline/virtual/image_frame_generator.cpp
> > >  create mode 100644 src/libcamera/pipeline/virtual/image_frame_generator.h
> > >  create mode 100644 src/libcamera/pipeline/virtual/meson.build
> > >  create mode 100644 src/libcamera/pipeline/virtual/parser.cpp
> > >  create mode 100644 src/libcamera/pipeline/virtual/parser.h
> > >  create mode 100644 src/libcamera/pipeline/virtual/test_pattern_generator.cpp
> > >  create mode 100644 src/libcamera/pipeline/virtual/test_pattern_generator.h
> > >  create mode 100644 src/libcamera/pipeline/virtual/virtual.cpp
> > >  create mode 100644 src/libcamera/pipeline/virtual/virtual.h
> > >
> > > --
> > > 2.46.1.824.gd892dcdcdd-goog
> > >
Harvey Yang Oct. 4, 2024, 9:47 a.m. UTC | #6
Hi Kieran and Jacopo,

I found the root cause:
Gstreamer tests seem to create pipeline handlers after
the first CameraManager does. Therefore, previously
we don't allow `match()` to return true after the first one.

However, the first virtual pipeline handler is destructed
when the tests are executed.
The next version fixes it by setting `created_` back to
false when a valid virtual pipeline handler is destructed.

It's a pitfall for a pipeline handler that doesn't need to
actually `match` MediaDevices...

BR,
Harvey

On Thu, Oct 3, 2024 at 6:37 PM Kieran Bingham
<kieran.bingham@ideasonboard.com> wrote:
>
> Quoting Cheng-Hao Yang (2024-10-03 11:06:58)
> > Hi Kieran,
> >
> > On Thu, Oct 3, 2024 at 5:48 PM Kieran Bingham
> > <kieran.bingham@ideasonboard.com> wrote:
> > >
> > > Quoting Harvey Yang (2024-09-30 07:29:41)
> > > > Hi all,
> > > >
> > > > This series adds virtual pipeline handler, which doesn't depend on any
> > > > hardware, like camera sensor or ISP. Currently the configuration
> > > > supports test patterns and images.
> > > >
> > > > It passed the gitlab pipeline:
> > > > https://gitlab.freedesktop.org/chenghaoyang/libcamera/-/pipelines/1280687
> > > >
> > > > I've also checked that it works on qcam.
> > > >
> > > > I failed to pass multi_stream_test when trying to enable multiple
> > > > streams though. Please give me some hints what it tests and what I
> > > > missed:
> > > > ```
> > > > [295:43:43.910237144] [1441841]  INFO IPAManager ipa_manager.cpp:137 libcamera is not installed. Adding '/usr/local/google/home/chenghaoyang/Workspace/libca
> > > > mera/build/src/ipa' to the IPA search path
> > > > [295:43:43.914030564] [1441841]  INFO Camera camera_manager.cpp:325 libcamera v0.3.1+79-8ca4f033-dirty (2024-08-29T19:18:51UTC)
> > > > [295:43:43.915493754] [1441844] ERROR DmaBufAllocator dma_buf_allocator.cpp:120 Could not open any dma-buf provider
> > > > [295:43:43.919118835] [1441841]  INFO IPAManager ipa_manager.cpp:137 libcamera is not installed. Adding '/usr/local/google/home/chenghaoyang/Workspace/libca
> > > > mera/build/src/ipa' to the IPA search path
> > > > [295:43:43.922245825] [1441841]  INFO Camera camera_manager.cpp:325 libcamera v0.3.1+79-8ca4f033-dirty (2024-08-29T19:18:51UTC)
> > > > [295:43:43.922820175] [1441846] ERROR DmaBufAllocator dma_buf_allocator.cpp:120 Could not open any dma-buf provider
> > > > Unable to set the pipeline to the playing state.
> > >
> > > Is this the error you get when you enable multiple streams in the
> > > virtual pipeline handler?
> >
> > Correct :)
> >
> > >
> > > I still think that looks like an issue in the configuration of the VM
> > > not having udmabuf which you use.
> >
> > Hmm, as I shared before, the pipeline unit test still fails when I
> > support a workaround memfd_create:
> > https://gitlab.freedesktop.org/chenghaoyang/libcamera/-/pipelines/1279655
> > , which contains:
> > https://gitlab.freedesktop.org/chenghaoyang/libcamera/-/commit/9f032290fc97dae1fbace2314420a73251169cee
>
> Your patch tries to use Memfd instead. Did you check if the CI kernel
> has support for MEMFD? Is that a configuration option in the kernel ?
>
> Isn't udmabuf constructed from a memfd ultimately ?
>
> If you export a memfd file descriptor - will that break elsewhere
> because it's not a DMABuf handle? (That's the whole point of udmabuf
> right ?)
>
> I think changing to memfd to test if that's the cause of the udmabuf
> issue is just changing one set of issues for another.
>
>
>
> >
> > At least it works on my gLinux environment.
> > Doesn't that imply that it's not because of DmaBufAllocator?
>
> No ? Maybe your gLinux environment has the appropriate / required
> features enabled!
>
>
> > Also, single_stream_test passed. I assume it also tests on the
> > buffers if multi_stream_test does?
>
> I'm not sure I understand this question...
>
> --
> Kieran
>
>
> >
> > BR,
> > Harvey
> >
> > >
> > >
> > > To fix this, you would probably need to fork the CI scripts:
> > >
> > >  - https://gitlab.freedesktop.org/camera/libcamera-ci
> > >
> > > And direct your local
> > > https://gitlab.freedesktop.org/chenghaoyang/libcamera to use that while
> > > you work out the issue.
> > >
> > > I suspect you need to add something at
> > >
> > > https://gitlab.freedesktop.org/camera/libcamera-ci/-/blob/master/.gitlab-ci/build-kernel.sh?ref_type=heads#L41
> > >
> > > to enable the uDMA config options...
> > >
> > > --
> > > Kieran
> > >
> > >
> > >
> > > > ```
> > > >
> > > > Gitlab pipeline failure:
> > > > https://gitlab.freedesktop.org/chenghaoyang/libcamera/-/pipelines/1260412
> > > >
> > > > Updates in v14:
> > > > - Refactored ImageFrames to keep a list of filepaths directly.
> > > >
> > > > Updates in v13:
> > > > - Returned an errno in `FrameGenerete::generateFrame()`
> > > >
> > > > Updates in v12:
> > > > - Added ImageFrameGenerator first, then add Parser.
> > > > - Removed ScaleMode argument, as only Fill is supported now.
> > > > - Fixed bug of Stream's configuration usage in configure().
> > > >
> > > > Updates in v11:
> > > > - Allowed a single value in the config file's frame_rates field.
> > > >
> > > > Updates in v10:
> > > > Apply fixes according to Jacopo's and Barnabás' comments.
> > > > - Split test_pattern and path fields in the yaml format.
> > > > - Let FrameGenerators control frameCount_.
> > > > - Fixed match() returning values.
> > > >
> > > > Updates in v9: Allocate contiguous memory for planes in the same
> > > > FrameBuffer.
> > > >
> > > > BR,
> > > > Harvey
> > > >
> > > > Harvey Yang (6):
> > > >   libcamera: add DmaBufAllocator::exportBuffers()
> > > >   libcamera: Remove PipelineHandler Fatal check of non-empty
> > > >     MediaDevices
> > > >   libcamera: virtual: Add VirtualPipelineHandler
> > > >   libcamera: virtual: Add ImageFrameGenerator
> > > >   libcamera: virtual: Read config and register cameras based on the
> > > >     config
> > > >   libcamera: software_isp: Refactor SoftwareIsp to use
> > > >     DmaBufAllocator::exportBuffers
> > > >
> > > > Konami Shu (1):
> > > >   libcamera: pipeline: Add test pattern for VirtualPipelineHandler
> > > >
> > > >  .../libcamera/internal/dma_buf_allocator.h    |  13 +
> > > >  meson.build                                   |   1 +
> > > >  meson_options.txt                             |   3 +-
> > > >  src/android/meson.build                       |  19 -
> > > >  src/libcamera/dma_buf_allocator.cpp           |  57 +++
> > > >  src/libcamera/pipeline/virtual/README.md      |  48 +++
> > > >  .../pipeline/virtual/data/virtual.yaml        |  36 ++
> > > >  .../pipeline/virtual/frame_generator.h        |  29 ++
> > > >  .../virtual/image_frame_generator.cpp         | 169 ++++++++
> > > >  .../pipeline/virtual/image_frame_generator.h  |  50 +++
> > > >  src/libcamera/pipeline/virtual/meson.build    |  13 +
> > > >  src/libcamera/pipeline/virtual/parser.cpp     | 260 ++++++++++++
> > > >  src/libcamera/pipeline/virtual/parser.h       |  39 ++
> > > >  .../virtual/test_pattern_generator.cpp        | 137 +++++++
> > > >  .../pipeline/virtual/test_pattern_generator.h |  53 +++
> > > >  src/libcamera/pipeline/virtual/virtual.cpp    | 382 ++++++++++++++++++
> > > >  src/libcamera/pipeline/virtual/virtual.h      |  61 +++
> > > >  src/libcamera/pipeline_handler.cpp            |  11 +-
> > > >  src/libcamera/software_isp/software_isp.cpp   |  20 +-
> > > >  src/meson.build                               |  19 +
> > > >  20 files changed, 1378 insertions(+), 42 deletions(-)
> > > >  create mode 100644 src/libcamera/pipeline/virtual/README.md
> > > >  create mode 100644 src/libcamera/pipeline/virtual/data/virtual.yaml
> > > >  create mode 100644 src/libcamera/pipeline/virtual/frame_generator.h
> > > >  create mode 100644 src/libcamera/pipeline/virtual/image_frame_generator.cpp
> > > >  create mode 100644 src/libcamera/pipeline/virtual/image_frame_generator.h
> > > >  create mode 100644 src/libcamera/pipeline/virtual/meson.build
> > > >  create mode 100644 src/libcamera/pipeline/virtual/parser.cpp
> > > >  create mode 100644 src/libcamera/pipeline/virtual/parser.h
> > > >  create mode 100644 src/libcamera/pipeline/virtual/test_pattern_generator.cpp
> > > >  create mode 100644 src/libcamera/pipeline/virtual/test_pattern_generator.h
> > > >  create mode 100644 src/libcamera/pipeline/virtual/virtual.cpp
> > > >  create mode 100644 src/libcamera/pipeline/virtual/virtual.h
> > > >
> > > > --
> > > > 2.46.1.824.gd892dcdcdd-goog
> > > >