[libcamera-devel] Getting libcamera to work on PinePhone

Hans de Goede hdegoede at redhat.com
Mon Dec 18 10:40:54 CET 2023


Hi,

On 12/18/23 04:09, Laurent Pinchart via libcamera-devel wrote:
> Hi Pavel,
> 
> On Sun, Dec 17, 2023 at 10:03:55PM +0100, Pavel Machek via libcamera-devel wrote:
>> Hi!
>>
>> I'm trying to get libcamera to work on pinephone. I tried updating
>> ov5640 driver to latest mainline version, but still no luck. gc2145 is
>> out of tree, patches are pending, but lets ignore that one for now.
>>
>> mobian at mobian:~/g/libcamera$  build/src/apps/cam/cam -c 1 -I -C -S
>> [0:22:38.775678493] [1584]  INFO IPAManager ipa_manager.cpp:143 libcamera is not installed. Adding '/my/libcamera/build/src/ipa' to the IPA search path
>> [0:22:38.785258743] [1584]  INFO Camera camera_manager.cpp:284 libcamera v0.1.0+142-1c56d2a2
>> [0:22:38.829487310] [1585]  WARN CameraSensor camera_sensor.cpp:248 'ov5640 3-004c': Recommended V4L2 control 0x009a0922 not supported
>> [0:22:38.829703110] [1585]  WARN CameraSensor camera_sensor.cpp:315 'ov5640 3-004c': The sensor kernel driver needs to be fixed
>> [0:22:38.829761112] [1585]  WARN CameraSensor camera_sensor.cpp:317 'ov5640 3-004c': See Documentation/sensor_driver_requirements.rst in the libcamera sources for more information
>> [0:22:38.842159390] [1585]  WARN CameraSensor camera_sensor.cpp:463 'ov5640 3-004c': Failed to retrieve the camera location
>> [0:22:38.842311854] [1585]  WARN CameraSensor camera_sensor.cpp:485
>> 'ov5640 3-004c': Rotation control not available, default to 0 degrees
>>
>> So we don't have location or orientation, should not matter.
> 
> I believe this is caused by the missing orientation property in the
> device tree. The ov5640 driver from mainline calls
> v4l2_fwnode_device_parse(), which should create the rotation control
> when the device tree property is present. Could you test that ? It would
> then be nice to upstream a patch to add the ov5640 to the pinephone
> device tree.
> 
>> [0:22:38.846151130] [1585]  WARN CameraSensor camera_sensor.cpp:248 'gc2145 3-003c': Recommended V4L2 control 0x009a0922 not supported
>> [0:22:38.846309344] [1585] ERROR V4L2 v4l2_subdevice.cpp:393 'gc2145 3-003c': Unable to get rectangle 2 on pad 0: Inappropriate ioctl for device
>> [0:22:38.846419057] [1585]  WARN CameraSensor camera_sensor.cpp:290 'gc2145 3-003c': The PixelArraySize property has been defaulted to 1600x1200
>> [0:22:38.846484226] [1585] ERROR V4L2 v4l2_subdevice.cpp:393 'gc2145 3-003c': Unable to get rectangle 1 on pad 0: Inappropriate ioctl for device
>> [0:22:38.846543645] [1585]  WARN CameraSensor camera_sensor.cpp:301 'gc2145 3-003c': The PixelArrayActiveAreas property has been defaulted to (0, 0)/1600x1200
>> [0:22:38.846612189] [1585] ERROR V4L2 v4l2_subdevice.cpp:393 'gc2145 3-003c': Unable to get rectangle 0 on pad 0: Inappropriate ioctl for device
>> [0:22:38.846663983] [1585]  WARN CameraSensor camera_sensor.cpp:309 'gc2145 3-003c': Failed to retrieve the sensor crop rectangle
>> [0:22:38.846710735] [1585]  WARN CameraSensor camera_sensor.cpp:315 'gc2145 3-003c': The sensor kernel driver needs to be fixed
>> [0:22:38.846755278] [1585]  WARN CameraSensor camera_sensor.cpp:317 'gc2145 3-003c': See Documentation/sensor_driver_requirements.rst in the libcamera sources for more information
>> [0:22:38.852065445] [1585]  WARN CameraSensorProperties camera_sensor_properties.cpp:249 No static properties available for 'gc2145'
>> [0:22:38.852264952] [1585]  WARN CameraSensorProperties camera_sensor_properties.cpp:251 Please consider updating the camera sensor properties database
>> [0:22:38.852621300] [1585]  WARN CameraSensor camera_sensor.cpp:463 'gc2145 3-003c': Failed to retrieve the camera location
>> [0:22:38.852685261] [1585]  WARN CameraSensor camera_sensor.cpp:485 'gc2145 3-003c': Rotation control not available, default to 0 degrees
>> [0:22:38.852981481] [1585] ERROR V4L2 v4l2_device.cpp:353 'gc2145 3-003c': Unable to set controls: Permission denied
>> [0:22:38.853820305] [1585] ERROR SimplePipeline simple.cpp:1441 No
>> valid pipeline for sensor 'gc2145 3-003c', skipping
>>
>> gc2145... lets ignore that one for now.
>>
>> [0:22:38.860444856] [1585] ERROR V4L2 v4l2_videodevice.cpp:1106
>> /dev/video0[15:cap]: Media bus code filtering not supported by the
>> device
>>
>> I guess that's the real error here? It is
>>
>>         if (code && !caps_.hasMediaController()) {
>>
>> from std::vector<V4L2PixelFormat> V4L2VideoDevice::enumPixelformats(uint32_t code)
>>  . I don't see anything relevant in sensor_driver_requirements.rst .
>>
>> Rest is more of the same. Any ideas?
>>
>> ov5640 does have         .enum_mbus_code = ov5640_enum_mbus_code,
>>
>> . Is this in the sensor driver or should I look somewhere else?
> 
> It's not about the sensor, it's about the video device side. If I'm not
> mistaken, on the pinephone, that would be the sun6i-csi driver. The
> driver needs to implement V4L2_CAP_IO_MC, and in particular, update the
> .vidioc_enum_fmt_vid_cap() handler accordingly. See
> https://docs.kernel.org/userspace-api/media/v4l/vidioc-enum-fmt.html.

Right, I had to do something similar to the ipu6 csi receiver code to make it work
with libcamera, see:

https://github.com/jwrdegoede/linux-sunxi/blob/v6.6-footrail/drivers/media/pci/intel/ipu6/ipu6-isys-video.c#L123

For the enum fmt code I ended up with for the ipu6.

Regards,

Hans



More information about the libcamera-devel mailing list