Pinephone Pro Camera CLI on mobian

Finally got around to looking at the cli commands and the pinephonepro camera.

the new device, is slightly more complex that the docs I found:
installed utility “dot” ( sudo apt install graphviz ) to view the structure of the settings:
run the commands below to generate the image:

media-ctl -d platform:rkisp1 --print-dot > m-1.dot
dot -T png -o m-1.png m-1.dot

results in

above is at boot, notice the dotted lines between the green settings. they need to be hooked up and configured:
This can be done with media-ctl and v4l2-ctl :

note, these commands should all be on the same line, this editor on my screen wraps some longer lines with

Script below will setup the camera, dump to a “raw” file, and then use ffmpeg to convert the raw file into a jpeg file, in the “Pictures” subdirectory, with the name CLI_{dateandtime}.

#!/bin/bash

# make lines shorter
media_cmd="media-ctl -d platform:rkisp1" 
v4l2_cmd="v4l2-ctl -z platform:rkisp1 -d rkisp1_mainpath"

# create a timestamp for the filename
NAME=$(date +"%Y%m%dT%H%M%S")

$media_cmd "-r"

$media_cmd "--set-v4l2" '"imx258 1-001a":0 [fmt:SRGGB10_1X10/1048x780]'

$media_cmd "--set-v4l2" '"rkisp1_resizer_mainpath":0 [fmt:SRGGB8_1X8/1048x780 crop:(0,0)/1048x780]'

$media_cmd "--set-v4l2" '"rkisp1_resizer_mainpath":1 [fmt:SRGGB8_1X8/1048x780]'

$media_cmd "-l" "'imx258 1-001a':0 -> 'rkisp1_csi':0 [1]"

$media_cmd "-l" "'rkisp1_csi':1 -> 'rkisp1_isp':0 [1]"

$media_cmd "-l" "'rkisp1_isp':2 -> 'rkisp1_resizer_mainpath':0 [1]"

$media_cmd "--set-v4l2" '"rkisp1_isp":0 [fmt:SRGGB10_1X10/1048x780 crop:(0,0)/1048x780]'

$media_cmd "--set-v4l2" '"rkisp1_csi":0 [fmt:SRGGB10_1X10/1048x780 ]'

$media_cmd "--set-v4l2" '"rkisp1_isp":2 [fmt:YUYV8_2X8/1048x780 crop:(0,0)/1048x780]'

$v4l2_cmd  "-v" "width=1048,height=780,"

$v4l2_cmd  "-v" "width=1048,height=780,pixelformat=YM61"

### different v4l2 node for camera controls!
v4l2-ctl -z platform:rkisp1 -d "imx258 1-001a" -c exposure=33000

v4l2-ctl -z platform:rkisp1 -d "imx258 1-001a" -c analogue_gain=100

### yet another for focus
v4l2-ctl -z platform:rkisp1 -d "dw9714 1-000c" -c focus_absolute=256

## stream image to raw file
$v4l2_cmd  "--stream-mmap" "--stream-count" "1" "--stream-to=frame.raw"

## convert raw file to jpg in Pictures dir
ffmpeg -y -hide_banner -loglevel error -s:v 1048x780 -pix_fmt yuv422p -i frame.raw ~/Pictures/CLI_${NAME}_%03d.jpg

resulting setup is now below (regenerated with same commands as above). The solid lines show the connection settings from the nodes in the commands above.
I found the exposure was needed to be so large, otherwise the image was very dark. Found the focus_absolute setting did change the image for me (pointing the phone at the pinebook pro screen very near). Will now move the camera farther away and see if the focus control works better.

This entry was posted in tech. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s