<div dir='auto'><div><br><div class="gmail_extra"><br><div class="gmail_quote">Le 5 sept. 2021 19 h 40, Laurent Pinchart <laurent.pinchart@ideasonboard.com> a écrit :<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Hi Martin,
<br>

<br>
(CC'ing Nicolas)
<br>

<br>
On Fri, Sep 03, 2021 at 09:28:10AM +0200, Martin Kepplinger wrote:
<br>
> Am Donnerstag, dem 02.09.2021 um 17:48 +0300 schrieb Laurent Pinchart:
<br>
> > On Thu, Sep 02, 2021 at 10:56:41AM +0200, Martin Kepplinger wrote:
<br>
> > > hi all,
<br>
> > > 
<br>
> > > I'm starting to use libcamera with the hi846 camera on imx8mq. (The
<br>
> > > following all works on my laptop btw, where there's only 1 camera.)
<br>
> > > 
<br>
> > > I test using the "libaperture" gstreamer app with the libcamera gst src element
<br>
> > > (https://gitlab.gnome.org/jwestman/libaperture/-/issues/14 ).
<br>
> > > But it doesn't work on imx8mq where I have 2 cameras (and 1 is working
<br>
> > > with libcamera currently, but that shouldn't matter I think).
<br>
> > > 
<br>
> > > Here's the end of the logs. earlier logs seem to be the same as the
<br>
> > > successful case with qcam, see below.
<br>
> > > 
<br>
> > > 
<br>
> > > [1:57:12.541751844] [3187] DEBUG Camera camera_manager.cpp:150
<br>
> > > Found registered pipeline handler 'PipelineHandlerUVC'
<br>
> > > [1:57:12.541817127] [3187] DEBUG Camera camera_manager.cpp:150
<br>
> > > Found registered pipeline handler 'PipelineHandlerVimc'
<br>
> > > [1:57:12.542646484] [3180] DEBUG Camera camera.cpp:878 streams
<br>
> > > configuration: (0) 1632x1224-SGBRG16
<br>
> > > [1:57:12.543146546] [3187] DEBUG V4L2 v4l2_videodevice.cpp:1423
<br>
> > > /dev/video0[32:cap]: Releasing buffers
<br>
> > > [1:57:12.543212069] [3187] DEBUG V4L2 v4l2_videodevice.cpp:1160
<br>
> > > /dev/video0[32:cap]: 0 buffers requested.
<br>

<br>
> [snip]
<br>

<br>
> > > what does libcamerasrc do wrong? Why isn't it configuring the stream?
<br>
> > > What config options do I have for the gstreamer element to play with?
<br>
> > 
<br>
> > Have you tried using libcamerasrc with a simple gst-launch pipeline
<br>
> > first ? That could give us additional feedback from GStreamer itself.
<br>

<br>
> thanks. first, verified that the gstreamer test src works:
<br>

<br>
> LANG=C LIBCAMERA_LOG_FILE=/home/purism/lc.log LIBCAMERA_LOG_LEVELS=0
<br>
> GST_PLUGIN_PATH=/usr/local/lib/aarch64-linux-gnu/gstreamer-1.0/
<br>
> gst-launch-1.0 videotestsrc ! glimagesink
<br>

<br>
> one appearent problem: gstreamer and libcamerasrc don't know about the
<br>
> SGBRG16 format I'm receiving. Tried to workaround that like so (?):</p></blockquote></div></div></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">
<br>

<br>
> --- a/src/gstreamer/gstlibcamera-utils.cpp
<br>
> +++ b/src/gstreamer/gstlibcamera-utils.cpp
<br>
> @@ -30,6 +30,8 @@ static struct {
<br>
>         { GST_VIDEO_FORMAT_YUY2, formats::YUYV },
<br>
>         { GST_VIDEO_FORMAT_YVYU, formats::YVYU },
<br>
>         /* \todo NV42 is used in libcamera but is not mapped in
<br>
> GStreamer yet. */
<br>
> +       { GST_VIDEO_FORMAT_GRAY16_BE, formats::SGBRG16 },
<br>

<br>
I think this should be GST_VIDEO_FORMAT_GRAY16_LE.
<br>

<br>
We should also add support for the other Bayer patterns, but it won't be
<br>
as trivial as adding the SBGGR, SGRBG and SRGGB entries here, as
<br>
gst_format_to_pixel_format() won't necessarily pick the right format in
<br>
that case.
<br>

<br>
This reminds me that I think we should decouple the CFA pattern from the
<br>
format in libcamera, but that's for later. Nicolas, do I understand
<br>
correctly that GStreamer uses x-bayer instead of x-raw for Bayer formats
<br>
? I can't see a bit depth being specified by x-bayer, does it mean it
<br>
supports 8bpp only ?</p></blockquote></div></div></div><div dir="auto"><div dir="auto" style="font-family: sans-serif;">Correct, x-bayer and all defined formats are currently 8 bits. The bayer support is also missing stride support (missing equivalent of GstVideoFromat).</div><div dir="auto" style="font-family: sans-serif;"><br></div><div dir="auto" style="font-family: sans-serif;">Bayer formats do not fit generically with x-raw, as the concept of pixels is very different. This is why it's not integrated into libgstvideo.</div><div dir="auto" style="font-family: sans-serif;"><br></div><div dir="auto" style="font-family: sans-serif;">There is very little users for Bayer in GStreamer, but also in most applications. No one actually even spent the time or had the need for a proper integration. I wonder how usable this is, I know this SoC is missing an ISP, but it might be better to use a software or GPU ISP inside libcamera.</div></div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">
<br>

<br>
> +       /* 16bit bayer not supported by gstreamer yet (?) */
<br>
>  };</p></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">Correct, but in absence of supporting library, adding support is just about adding the format string for it. Of course having minimal debayering support for that would be a plus.</div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">
<br>
>  
<br>

<br>
> but that results in:
<br>

<br>
> purism@pureos:~$ GST_DEBUG=3 LANG=C
<br>
> LIBCAMERA_LOG_FILE=/home/purism/lc.log LIBCAMERA_LOG_LEVELS=0
<br>
> GST_PLUGIN_PATH=/usr/local/lib/aarch64-linux-gnu/gstreamer-1.0/
<br>
> gst-launch-1.0 libcamerasrc ! videoconvert ! glimagesink
<br>
> Setting pipeline to PAUSED ...
<br>
> Pipeline is live and does not need PREROLL ...
<br>
> 0:00:01.793370564  3386 0xaaaaddf97760 FIXME                default gstutils.c:4025:gst_pad_create_stream_id_internal:<libcamerasrc0:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id
<br>
> Got context from element 'sink': gst.gl.GLDisplay=context, gst.gl.GLDisplay=(GstGLDisplay)"\(GstGLDisplayWayland\)\gldisplaywayland0";
<br>
> Pipeline is PREROLLED ...
<br>
> Setting pipeline to PLAYING ...
<br>
> New clock: GstSystemClock
<br>

<br>
> (gst-launch-1.0:3386): GStreamer-CRITICAL **: 09:20:50.114: gst_value_set_int_range_step: assertion 'start < end' failed
<br>

<br>
> (gst-launch-1.0:3386): GStreamer-CRITICAL **: 09:20:50.116: gst_value_set_int_range_step: assertion 'start < end' failed</p><p dir="ltr"></p></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">This is an assertion, don't expect anything to work when such assertion pops. (They are only there for crash avoidance). Can you generate a backtrack with env G_DEBUG=fatal_criticals and share ?</div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr"><br></p><p dir="ltr"><br></p><p dir="ltr"><br>
> ^Chandling interrupt.
<br>
> Interrupt: Stopping pipeline ...
<br>
> Execution ended after 0:00:05.128408250
<br>
> Setting pipeline to NULL ...
<br>
> Freeing pipeline ...
<br>

<br>

<br>
> the clock is *not* running. it just shows how long it ran after killing
<br>
> it.
<br>

<br>
> not sure what my specific question is but in case you've seen this
<br>
> before and have an idea, just say so :)
<br>

<br>
I haven't tried to capture raw data using libcamerasrc yet, so I'm not
<br>
sure what to advise :-S
<br>

<br>
-- 
<br>
Regards,
<br>

<br>
Laurent Pinchart
<br>
</p>
</blockquote></div><br></div></div></div>