Jump to content

User:Pabloyoyoista/libcamera

From postmarketOS Wiki
  1. libcamera

How to get a working camera in megapixels to work with the libcamera/pipewire stack!

sudo apk add libcamera-tools

`cam -l` tells you if a camera is detected, and gives lots of info about the driver. We should identify the number at the beginning of the camera we want to analyze as "#camera_number" to be used in the following commands

`cam -c #camera_number -p` tells you the properties of the camera. We'll see here common things missing:

Rotation and Location. Rotation is most of the times not 0, but has to be added to the device tree. Location is not there unless has been added to the device tree, which is the case most of the times


The next cool command is

`cam -c #camera_number -I` lists all modes reported by the camera. We see there are a lot of modes reported (different resolutions and formats), so it should have something that libcamera should be able to use

We install `qcam` utility that uses libcamera directly to see if we can get an image. It does not work, but the error reported: `dmaHeap allocation failure`. Then we checked whether the dmahead memory is available, and has the right permissions under `/dev/dma_head`. We see that "reserved" has "rw" for "video" group, all correct. Next we check how much Cma memory is available `cat /proc/meminfo | grep Cma`, which will possibly change in the future. There we see we only get 32Mb, which is too little. We fixed it with kernel_cmdline_append in `/etc/deviceinfo` `cma=300m` (needs mkinitfs run to get updated) but should be changed in the kernel config. With this, `qcam` opens a window (needs whole session, so not from SSH), and it works!!