Skip to content

Draft: use upstream camera drivers

this switches our whole camera driver stack to use as much mainline drivers as possible:

the mipi driver is WIP but currently being publically reviewed for upstream. please test it, see below.

the devkit is completely untested and most likely doesn't yet work with this. I'll look at it later.

how to test on the L5:

by now the kernel creates 3+ /dev/media devices, so first of all you probably want to decide which of the 2 sensors you want to test this stack with and find out which /dev/media device it got assigned. that number can always change after rebooting.

#!/bin/bash
echo "media dev 0"
media-ctl -p -d 0 | grep -C 1 -i sensor
echo "media dev 1"
media-ctl -p -d 1 | grep -C 1 -i sensor
echo "media dev 2"
media-ctl -p -d 2 | grep -C 1 -i sensor

with that number: DEV(0..2) you can use a script like this to set formats and stream frames from the selfie cam:

#!/bin/bash
DEV=$1
WIDTH=$2
HEIGHT=$3
SKIP=$4

media-ctl -d $DEV --set-v4l2 "'csi':0 [fmt:SGBRG10/${WIDTH}x${HEIGHT} colorspace:raw]"
media-ctl -d $DEV --set-v4l2 "'imx8mq-mipi-csi2 30a70000.csi':0 [fmt:SGBRG10/${WIDTH}x${HEIGHT} colorspace:raw]"
media-ctl -d $DEV --set-v4l2 "'hi846 2-0020':0 [fmt:SGBRG10/${WIDTH}x${HEIGHT} colorspace:raw]"
media-ctl -d $DEV -l "'hi846 2-0020':0 -> 'imx8mq-mipi-csi2 30a70000.csi':0 [1]"
v4l2-ctl -d "/dev/v4l/by-path/platform-30a90000.csi-video-index0" --set-fmt-video=width=${WIDTH},height=${HEIGHT},pixelformat=GB16 --stream-mmap --stream-to=$WIDTH.raw --stream-skip=$SKIP --stream-count=1

for the big cam try the following with 4208x3120:

#!/bin/bash
DEV=$1
WIDTH=$2
HEIGHT=$3
SKIP=$4

media-ctl -d $DEV --set-v4l2 "'csi':0 [fmt:SGRBG8/${WIDTH}x${HEIGHT} colorspace:raw]"
media-ctl -d $DEV --set-v4l2 "'imx8mq-mipi-csi2 30b60000.csi':0 [fmt:SGRBG8/${WIDTH}x${HEIGHT} colorspace:raw]"
media-ctl -d $DEV --set-v4l2 "'S5K3L6-CIS 3-002d':0 [fmt:SGRBG8/${WIDTH}x${HEIGHT} colorspace:raw]"
media-ctl -d $DEV -l "'S5K3L6-CIS 3-002d':0 -> 'imx8mq-mipi-csi2 30b60000.csi':0 [1]"
v4l2-ctl -d "/dev/v4l/by-path/platform-30a90000.csi-video-index0" --set-fmt-video=width=${WIDTH},height=${HEIGHT},pixelformat=GRBG --stream-mmap --stream-to=$WIDTH.raw --stream-skip=$SKIP --stream-count=1

but for the big cam we still have a pixelformat issue I'll look into soon:

imx7-csi 30a90000.csi: capture format not valid

we want to have a patch for megapixels so that it works with these drivers, see https://source.puri.sm/Librem5/megapixels/-/issues/13 and this MR should help developing that. (A megapixels .ini file that only includes the seflie cam would be OK for first tests).

but for merging this, we need

  • a working (streaming) big-cam with this (and the currect old CSI stack first)
  • know how controls are used and a working megapixels patchset that works with this
  • a working devkit cam with the new drivers(nice to have at least)
Edited by Martin Kepplinger

Merge request reports