[libcamera-devel] libcamera on pinephone

Laurent Pinchart laurent.pinchart at ideasonboard.com
Tue Jun 21 09:44:19 CEST 2022


On Tue, Jun 21, 2022 at 09:40:25AM +0200, Jacopo Mondi wrote:
> Hi Pavel,
> 
> On Mon, Jun 20, 2022 at 11:28:34PM +0200, Pavel Machek wrote:
> > Hi!
> >
> > > > However cam recently gained support for an SDL output which might be
> > > > easier to exercize.
> > > >
> > > > > build/test/camera/capture -- sounds like something suitable for basic
> > > > > testing? But it has "platform/vimc.0 Sensor B" hardcoded and that's
> > > > > not present.
> > > >
> > > > test/ contains the library unit tests, not something that is interesting
> > > > for users
> > > >
> > > > > Are there tools such as list sensors, acquire one frame for testing,
> > > > > ...?
> > > >
> > > > Yes, cam does that.
> > >
> > > `cam -l` to list cameras
> > > `cam -c 1 -C 10` to capture 10 frames from the first camera
> > > `cam -h` for more :-)
> >
> > Thanks for pointers. It seems that pinephone's drivers are not nearly
> > good enough to work with libcamera. (And fixing kernel is hard ATM,
> > plus I'd really like something working, first).
> >
> > ffmpeg works with same drivers, so I short-circuited most of the
> > checks to get libcamera to try to use similar config.
> >
> > ffmpeg -s 1280x720 -f video4linux2 -i /dev/video2 -vframes 5
> > /tmp/photo%d.jpg
> > ...
> >   Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1280x720, 331776 kb/s, 30 fps, 30 tbr, 1000k tbn, 1000k tbc
> > Stream mapping:
> >   Stream #0:0 -> #0:0 (rawvideo (native) -> mjpeg (native))
> > ...
> >
> > mobian at mobian:~/g/libcamera$ cat run
> > LIBCAMERA_LOG_FILE=/tmp/camera.log LIBCAMERA_LOG_LEVELS=*:DEBUG build/src/cam/cam -c 1 -I --capture=10 --file=/tmp/
> > mobian at mobian:~/g/libcamera$ ./run
> > Using camera /base/i2c-csi/rear-camera at 4c as cam0
> > 0: 1280x720-YUV420
> >  * Pixelformat: YUV420 (1280x720)-(1280x720)/(+1,+1)
> >   - 1280x720
> >  fd 14 fd 14plane is out of buffer: buffer length=1384448, plane offset=1382400, plane length=345600
> >
> > I'm attaching my hacks and debug output... if you have idea what is
> > wrong there, please help. I guess I broke something because "plane out
> > of buffer" does not seem right.
> 
> Could you share a pointer to the pinephone BSP to see how the driver
> handles YUV420 ?
> 
> Libcamera maps YUV420 to either V4L2_PIX_FMT_YUV420 for driver using the
> single-planar V4L2 API or V4L2_PIX_FMT_YUV420M for the multi-planar
> version. As far as I understand it this is not exactly precise as the
> YUV420 and YUV420M formats differ because for the former  the planes are
> contiguous while in the M version they live at different memory
> locations. Depending how a driver maps the single/multi API it implements
> to one of the two format versions, libcamera might be picking
> the wrong one.
> 
> Could you print the length of all planes and see how they look like in
> memory ? Also note that the two planes have the same fd so they
> seem to be contiguous in memory if I'm not mistaken ?

We really need data offset support for V4L2 buffer planes in the V4L2
API :-S See http://lore.kernel.org/linux-media/20200804192939.2251988-3-helen.koike@collabora.com/

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list