megi's PinePhone Development Log RSS

+972

2022–05–22: Pinephone Pro cameras kernel support

5.18 is to be released imminently, so to add a bit more motivation for people to update this release cycle, I've fixed up support for world facing camera on Pinephone Pro, and I also forward ported the BSP driver for the user facing camera and integrated it into my kernel tree, along with proper DT changes.

It involved debugging two issues. One stemming from a confusing Pinephone Pro schematic, and the other from me using Levinboot and having drivers built-in into my kernel builds that I use for development.

Pinephone Pro schematic names signals incorrectly in a bunch of places, which did hinder the development effort. From the schematic it appears that world facing camera is connected to ISP0, but it's in reality connected to ISP1. The schematic also names powerdown signal for user facing camera as active high, but it's in reality active low. So that camera was also failing when DT faithfully followed the schematic. While fun figuring that out, it took half a year for someone to notice, lol.

As for the Levinboot issue… Levinboot doesn't set I/O volatge levels for the I2C-1 bus to 1.8V, so they remained at default 3.0V which caused camera sensor probe failures on all my PPP prototypes ever since I first added the DT bindings for the cameras last year to my kernel tree. I thought my early prototype is different from the explorer batch, and left development to people who reported working IMX258 probe on their devices. U-Boot is not affected, which is why probe worked for other people.

I've patched my Levinboot branch to pre-configure the correct I/O voltage levels, and you can find camera support integrated here. It's also present in my pre-built kernels along with other changes, which you can read about in a release log.

Both cameras should now work as far as kernel is concerned.

Potential issues that remain to be fixed

Each sensor driver uses different master clock frequency while they share the same clock line.

User facing camera driver will set its desired frequency (24 MHz) when powered up, world facing driver will set its own (19.2 MHz) on powerup.

It's thus currently not possible to use both cameras at once. That would require for both drivers to use the same clock frequency. So don't enable both cameras at once. If you do, the sensor which was powered up first will have master clock frequency changed unexpectedly while it's operating. It will probably not work correctly afterwards.

Userspace

It should now be possible for interested people to start working on userspace support for the cameras in apps like megapixels, and libraries like libcamera.

Until then, you can use anteater's guide to play with the cameras from command line and discover new bugs and issues to be hunted down and solved. :)

There's also some useful documentation on Rockchip ISP in the kernel tree.

Have fun hacking! :-)

Sample photos

Selfie camera:

World camera: