[libcamera-devel] Pinephone 1.2 and libcamera

Laurent Pinchart laurent.pinchart at ideasonboard.com
Wed Jun 29 10:40:04 CEST 2022


Hi Rafael,

On Wed, Jun 29, 2022 at 04:14:26AM -0300, Rafael Diniz wrote:
> Thanks Laurent.
> 
> I'm not sure if I have all the information about the PinePhone hardware 
> to really implement this.

It should be doable with hardware documentation. The kernel driver
already contains information about how media bus codes map to pixel
formats (see sun6i_csi_is_format_supported()), needed to implement
support for IO_MC, and about the supported sizes (see the
{MIN,MAX}_{WIDTH,HEIGHT} macros), needed to implement
.vidioc_enum_framesizes().

> On 6/28/22 17:10, Laurent Pinchart wrote:
> > On Tue, Jun 28, 2022 at 04:22:06PM -0300, Rafael Diniz via libcamera-devel wrote:
> >> Just adding V4L2_CAP_IO_MC to device_caps of the sun6i-csi driver
> >> without really implementing it
> > 
> > It can help moving one step forward, but will come to bite you back
> > pretty soon :-)
> > 
> >> now gives me this error (as expected I think):
> >>
> >> ERROR V4L2 v4l2_videodevice.cpp:1153 /dev/video2[10:cap]: Unable to
> >> enumerate frame sizes: Inappropriate ioctl for device
> > 
> > I've just checked, and the sun6i-csi driver is also missing support for
> > the VIDIOC_ENUM_FRAMESIZES ioctl (.vidioc_enum_framesizes() operation in
> > struct v4l2_ioctl_ops) :-S A bit more work seems to be needed in the
> > driver.
> > 
> > It makes me wonder why we list sun6i-csi as supported in the pipeline
> > handler. Maybe libcamera has evolved to require the above since then ?
> > We don't test on that platform internally.
> > 
> >> On 6/28/22 07:54, Rafael Diniz via libcamera-devel wrote:
> >>> Hi Jacopo, sorry I was not clear.
> >>>
> >>> I mean, support in:
> >>> drivers/media/platform/sunxi/sun6i-csi/sun6i_video.c
> >>> V4L2_CAP_IO_MC is not there.
> >>>
> >>> Rafael
> >>>
> >>> On 6/28/22 07:40, Jacopo Mondi wrote:
> >>>> Hi Rafael,
> >>>>
> >>>> On Tue, Jun 28, 2022 at 07:26:42AM -0300, Rafael Diniz wrote:
> >>>>> Thanks Laurent and Jacopo.
> >>>>>
> >>>>> This is the commit to be used as reference, right?
> >>>>>
> >>>>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fc929ae516537720d61139df92fa89ac4989c7b
> >>>>>
> >>>>>
> >>>>> I took a look in different PP kernel branches, and it seems such v4l
> >>>>> V4L2_CAP_IO_MC is not present nowhere.
> >>>>
> >>>> I'm not sure I got wha you mean here...
> >>>>
> >>>> V4L2_CAP_IO_MC has been introduced by
> >>>> f645e6256bd1 ("media: v4l2-dev/ioctl: Add V4L2_CAP_IO_MC")
> >>>> and it seems to be in since v5.8 ?
> >>>>
> >>>>>
> >>>>> Rafael
> >>>>>
> >>>>> On 6/28/22 07:04, Laurent Pinchart wrote:
> >>>>>> On Tue, Jun 28, 2022 at 12:02:52PM +0200, Jacopo Mondi wrote:
> >>>>>>> Hi Rafael,
> >>>>>>>
> >>>>>>> On Tue, Jun 28, 2022 at 06:02:28AM -0300, Rafael Diniz wrote:
> >>>>>>>> I tried to first just copy the ov5640.c to my 5.15 branch, and the
> >>>>>>>> error
> >>>>>>>> message from libcamera changed. Now I get:
> >>>>>>>>
> >>>>>>>> WARN CameraSensor camera_sensor.cpp:212 'ov5640 3-004c':
> >>>>>>>> Recommended V4L2
> >>>>>>>> control 0x009a0922 not supported
> >>>>>>>> WARN CameraSensor camera_sensor.cpp:264 'ov5640 3-004c': The
> >>>>>>>> sensor kernel
> >>>>>>>> driver needs to be fixed
> >>>>>>>> WARN CameraSensor camera_sensor.cpp:266 'ov5640 3-004c': See
> >>>>>>>> Documentation/sensor_driver_requirements.rst in the libcamera
> >>>>>>>> sources for
> >>>>>>>> more information
> >>>>>>>> WARN CameraSensor camera_sensor.cpp:411 'ov5640 3-004c': Failed to
> >>>>>>>> retrieve
> >>>>>>>> the camera location
> >>>>>>>
> >>>>>>> You're missing V4L2_CID_CAMERA_ORIENTATION, don't worry it's not
> >>>>>>> anything fatal, simply your camera won't report it's orientation.
> >>>>>>>
> >>>>>>> The ov5640 driver is already instrumented to register such control if
> >>>>>>> the corresponding DT property is in your DTS
> >>>>>>>
> >>>>>>> References:
> >>>>>>> Documentation/devicetree/bindings/media/video-interface-devices.yaml
> >>>>>>>
> >>>>>>> TL;DR your DTS does not register any "orientation" property.
> >>>>>>>
> >>>>>>>>
> >>>>>>>> ERROR V4L2 v4l2_videodevice.cpp:1076 /dev/video2[10:cap]: Media
> >>>>>>>> bus code
> >>>>>>>> filtering not supported by the device
> >>>>>>>> (this last error repeats more than 50 times ^^^^)
> >>>>>>>>
> >>>>>>>> ERROR SimplePipeline simple.cpp:490 No valid configuration found
> >>>>>>>
> >>>>>>> This is not related to the sensor driver but rather to your receiver
> >>>>>>> driver that does not support media bus code filtering.
> >>>>>>>
> >>>>>>> https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/vidioc-enum-fmt.html
> >>>>>>>
> >>>>>>>
> >>>>>>> -------------------------------------------------------------------------------
> >>>>>>>
> >>>>>>> V4L2_CAP_IO_MC is set (also known as an ‘MC-centric’ driver)
> >>>>>>>
> >>>>>>> If the mbus_code field is initialized to a valid (non-zero) media bus
> >>>>>>> format code, then drivers shall restrict enumeration to only the image
> >>>>>>> formats that can produce (for video output devices) or be produced
> >>>>>>> from (for video capture devices) that media bus code. If the mbus_code
> >>>>>>> is unsupported by the driver, then EINVAL shall be returned.
> >>>>>>> -------------------------------------------------------------------------------
> >>>>>>>
> >>>>>>>
> >>>>>>> libcamera requires driver to support CAP_IO_MC and implement the
> >>>>>>> media-controller API for topology enumeration and device discovery.
> >>>>>>>
> >>>>>>> I asked Pavel a reference to the Pinephone BSP kernel to check what is
> >>>>>>> the status, but looking at the error there it seems some work is
> >>>>>>> required.
> >>>>>>
> >>>>>> It looks like thse sun6i-csi driver doesn't support CAP_IO_MC in
> >>>>>> mainline either.
> >>>>>>
> >>>>>>>> May be I'm missing something in order to backport the ov5640
> >>>>>>>> driver to the
> >>>>>>>> 5.15 branch?
> >>>>>>>>
> >>>>>>>> Thanks,
> >>>>>>>> Rafael Diniz
> >>>>>>>>
> >>>>>>>> On 6/27/22 05:05, Jacopo Mondi wrote:
> >>>>>>>>> Hi Rafael,
> >>>>>>>>>
> >>>>>>>>> On Mon, Jun 27, 2022 at 03:46:02AM -0300, Rafael Diniz wrote:
> >>>>>>>>>> That is wonderful. Thanks for pointing me the OV5640 patches.
> >>>>>>>>>> And before I
> >>>>>>>>>> start back-porting these patches to my 5.15 branch, is there any
> >>>>>>>>>> git repo I
> >>>>>>>>>> can clone just to give a first try (with these modifications
> >>>>>>>>>> already
> >>>>>>>>>> inside)?
> >>>>>>>>>
> >>>>>>>>> I just pushed
> >>>>>>>>> https://git.sr.ht/~jmondi_/linux/tree/jmondi/media-master/ov5640-v7
> >>>>>>>>>
> >>>>>>>>> which contains the last version of the 5640 patches on top of
> >>>>>>>>> linux-media master.
> >>>>>>>>>
> >>>>>>>>> Thanks
> >>>>>>>>>        j
> >>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>> Rafael
> >>>>>>>>>>
> >>>>>>>>>> On 6/26/22 20:29, Laurent Pinchart wrote:
> >>>>>>>>>>> Hi Rafael,
> >>>>>>>>>>>
> >>>>>>>>>>> On Fri, Jun 24, 2022 at 05:24:06AM -0300, Rafael Diniz via
> >>>>>>>>>>> libcamera-devel wrote:
> >>>>>>>>>>>> Hi Jocopo,
> >>>>>>>>>>>>
> >>>>>>>>>>>> Thanks. I'm interested to know which kernel version / source
> >>>>>>>>>>>> people are
> >>>>>>>>>>>> using to test libcamera on the PinePhone. Indeed, I read all
> >>>>>>>>>>>> the thread
> >>>>>>>>>>>> about libcamera in PinePhone in the e-maill archives.
> >>>>>>>>>>>> "lc-compliance"
> >>>>>>>>>>>> says drivers I'm using have no proper support for the features
> >>>>>>>>>>>> needed by
> >>>>>>>>>>>> libcamera.
> >>>>>>>>>>>
> >>>>>>>>>>> Those issues are actually not reported by lc-compliance, but by
> >>>>>>>>>>> libcamera itself. For the OV5640 camera sensor, the fixes have
> >>>>>>>>>>> been
> >>>>>>>>>>> posted to the linux-media mailing list (see [3], and in particular
> >>>>>>>>>>> patches 15/28, 16/28 and 21/28), but not merged yet.
> >>>>>>>>>>>
> >>>>>>>>>>> The gc2145 driver will need more work.
> >>>>>>>>>>>
> >>>>>>>>>>> [3]
> >>>>>>>>>>> https://lore.kernel.org/linux-media/20220513141548.6344-1-sakari.ailus@linux.intel.com
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>> On 6/24/22 04:46, Jacopo Mondi wrote:
> >>>>>>>>>>>>> Hello Rafael
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>         No longer than a few days ago Pavel sent this message
> >>>>>>>>>>>>> https://lists.libcamera.org/pipermail/libcamera-devel/2022-June/031340.html
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> Hope the two of you can synch
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> On Thu, Jun 23, 2022 at 04:37:32PM -0300, Rafael Diniz via
> >>>>>>>>>>>>> libcamera-devel wrote:
> >>>>>>>>>>>>>> Hi everybody,
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> I'm working on bringing PinePhone cameras support to
> >>>>>>>>>>>>>> Maemo-Leste system
> >>>>>>>>>>>>>> applications, and I opted for libcamera.
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> I posted some messages here:
> >>>>>>>>>>>>>> https://github.com/kbingham/libcamera/issues/28
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> With the kernel 5.15 with pinephone patches [1] imported
> >>>>>>>>>>>>>> from Mobian, I get
> >>>>>>>>>>>>>> some missing features in both cameras drivers [2]. Before I
> >>>>>>>>>>>>>> duplicate
> >>>>>>>>>>>>>> someone's work - did anyone manage to get a kernel which
> >>>>>>>>>>>>>> works with current
> >>>>>>>>>>>>>> libcamera for Pinephone 1 (not the Pro)?
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> Cheers,
> >>>>>>>>>>>>>> Rafael
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> [1]
> >>>>>>>>>>>>>> https://github.com/maemo-leste/pine64-kernel/tree/maemo/beowulf-devel
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> [2] ./lc-compliance
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> [6:03:22.948763728] [16718] INFO Camera
> >>>>>>>>>>>>>> camera_manager.cpp:293 libcamera v0.0.0+3665-bb84fc6a
> >>>>>>>>>>>>>> [6:03:22.976465603] [16719] WARN CameraSensor
> >>>>>>>>>>>>>> camera_sensor.cpp:212 'gc2145 3-003c': Recommended V4L2
> >>>>>>>>>>>>>> control 0x009a0922 not supported
> >>>>>>>>>>>>>> [6:03:22.978480561] [16719] ERROR V4L2
> >>>>>>>>>>>>>> v4l2_subdevice.cpp:318 'gc2145 3-003c': Unable to get
> >>>>>>>>>>>>>> rectangle 2 on pad 0: Inappropriate ioctl for device
> >>>>>>>>>>>>>> [6:03:22.979363603] [16719] WARN CameraSensor
> >>>>>>>>>>>>>> camera_sensor.cpp:239 'gc2145 3-003c': The PixelArraySize
> >>>>>>>>>>>>>> property has been defaulted to 1600x1200
> >>>>>>>>>>>>>> [6:03:22.979433394] [16719] ERROR V4L2
> >>>>>>>>>>>>>> v4l2_subdevice.cpp:318 'gc2145 3-003c': Unable to get
> >>>>>>>>>>>>>> rectangle 1 on pad 0: Inappropriate ioctl for device
> >>>>>>>>>>>>>> [6:03:22.979499686] [16719] WARN CameraSensor
> >>>>>>>>>>>>>> camera_sensor.cpp:250 'gc2145 3-003c': The
> >>>>>>>>>>>>>> PixelArrayActiveAreas property has been defaulted to (0,
> >>>>>>>>>>>>>> 0)/1600x1200
> >>>>>>>>>>>>>> [6:03:22.979599769] [16719] ERROR V4L2
> >>>>>>>>>>>>>> v4l2_subdevice.cpp:318 'gc2145 3-003c': Unable to get
> >>>>>>>>>>>>>> rectangle 0 on pad 0: Inappropriate ioctl for device
> >>>>>>>>>>>>>> [6:03:22.979663478] [16719] WARN CameraSensor
> >>>>>>>>>>>>>> camera_sensor.cpp:258 'gc2145 3-003c': Failed to retrieve
> >>>>>>>>>>>>>> the sensor crop rectangle
> >>>>>>>>>>>>>> [6:03:22.979719186] [16719] WARN CameraSensor
> >>>>>>>>>>>>>> camera_sensor.cpp:264 'gc2145 3-003c': The sensor kernel
> >>>>>>>>>>>>>> driver needs to be fixed
> >>>>>>>>>>>>>> [6:03:22.979773644] [16719] WARN CameraSensor
> >>>>>>>>>>>>>> camera_sensor.cpp:266 'gc2145 3-003c': See
> >>>>>>>>>>>>>> Documentation/sensor_driver_requirements.rst in the
> >>>>>>>>>>>>>> libcamera sources for more information
> >>>>>>>>>>>>>> [6:03:22.979853436] [16719] ERROR CameraSensor
> >>>>>>>>>>>>>> camera_sensor.cpp:287 'gc2145 3-003c': Mandatory V4L2
> >>>>>>>>>>>>>> control 0x009e0902 not available
> >>>>>>>>>>>>>> [6:03:22.979915686] [16719] ERROR CameraSensor
> >>>>>>>>>>>>>> camera_sensor.cpp:287 'gc2145 3-003c': Mandatory V4L2
> >>>>>>>>>>>>>> control 0x009f0902 not available
> >>>>>>>>>>>>>> [6:03:22.979973686] [16719] ERROR CameraSensor
> >>>>>>>>>>>>>> camera_sensor.cpp:287 'gc2145 3-003c': Mandatory V4L2
> >>>>>>>>>>>>>> control 0x009e0901 not available
> >>>>>>>>>>>>>> [6:03:22.980280644] [16719] ERROR CameraSensor
> >>>>>>>>>>>>>> camera_sensor.cpp:295 'gc2145 3-003c': The sensor kernel
> >>>>>>>>>>>>>> driver needs to be fixed
> >>>>>>>>>>>>>> [6:03:22.980343811] [16719] ERROR CameraSensor
> >>>>>>>>>>>>>> camera_sensor.cpp:297 'gc2145 3-003c': See
> >>>>>>>>>>>>>> Documentation/sensor_driver_requirements.rst in the
> >>>>>>>>>>>>>> libcamera sources for more information
> >>>>>>>>>>>>>> [6:03:22.981451561] [16719] ERROR SimplePipeline
> >>>>>>>>>>>>>> simple.cpp:1309 No valid pipeline for sensor 'gc2145
> >>>>>>>>>>>>>> 3-003c', skipping
> >>>>>>>>>>>>>> [6:03:22.986176478] [16719] WARN CameraSensor
> >>>>>>>>>>>>>> camera_sensor.cpp:212 'ov5640 3-004c': Recommended V4L2
> >>>>>>>>>>>>>> control 0x009a0922 not supported
> >>>>>>>>>>>>>> [6:03:22.986392019] [16719] ERROR V4L2
> >>>>>>>>>>>>>> v4l2_subdevice.cpp:318 'ov5640 3-004c': Unable to get
> >>>>>>>>>>>>>> rectangle 2 on pad 0: Inappropriate ioctl for device
> >>>>>>>>>>>>>> [6:03:22.986487478] [16719] WARN CameraSensor
> >>>>>>>>>>>>>> camera_sensor.cpp:239 'ov5640 3-004c': The PixelArraySize
> >>>>>>>>>>>>>> property has been defaulted to 2592x1944
> >>>>>>>>>>>>>> [6:03:22.986555228] [16719] ERROR V4L2
> >>>>>>>>>>>>>> v4l2_subdevice.cpp:318 'ov5640 3-004c': Unable to get
> >>>>>>>>>>>>>> rectangle 1 on pad 0: Inappropriate ioctl for device
> >>>>>>>>>>>>>> [6:03:22.986618769] [16719] WARN CameraSensor
> >>>>>>>>>>>>>> camera_sensor.cpp:250 'ov5640 3-004c': The
> >>>>>>>>>>>>>> PixelArrayActiveAreas property has been defaulted to (0,
> >>>>>>>>>>>>>> 0)/2592x1944
> >>>>>>>>>>>>>> [6:03:22.986690769] [16719] ERROR V4L2
> >>>>>>>>>>>>>> v4l2_subdevice.cpp:318 'ov5640 3-004c': Unable to get
> >>>>>>>>>>>>>> rectangle 0 on pad 0: Inappropriate ioctl for device
> >>>>>>>>>>>>>> [6:03:22.986751686] [16719] WARN CameraSensor
> >>>>>>>>>>>>>> camera_sensor.cpp:258 'ov5640 3-004c': Failed to retrieve
> >>>>>>>>>>>>>> the sensor crop rectangle
> >>>>>>>>>>>>>> [6:03:22.986807353] [16719] WARN CameraSensor
> >>>>>>>>>>>>>> camera_sensor.cpp:264 'ov5640 3-004c': The sensor kernel
> >>>>>>>>>>>>>> driver needs to be fixed
> >>>>>>>>>>>>>> [6:03:22.988926894] [16719] WARN CameraSensor
> >>>>>>>>>>>>>> camera_sensor.cpp:266 'ov5640 3-004c': See
> >>>>>>>>>>>>>> Documentation/sensor_driver_requirements.rst in the
> >>>>>>>>>>>>>> libcamera sources for more information
> >>>>>>>>>>>>>> [6:03:22.990680353] [16719] ERROR CameraSensor
> >>>>>>>>>>>>>> camera_sensor.cpp:287 'ov5640 3-004c': Mandatory V4L2
> >>>>>>>>>>>>>> control 0x009e0902 not available
> >>>>>>>>>>>>>> [6:03:22.990761353] [16719] ERROR CameraSensor
> >>>>>>>>>>>>>> camera_sensor.cpp:287 'ov5640 3-004c': Mandatory V4L2
> >>>>>>>>>>>>>> control 0x009e0901 not available
> >>>>>>>>>>>>>> [6:03:22.990816561] [16719] ERROR CameraSensor
> >>>>>>>>>>>>>> camera_sensor.cpp:295 'ov5640 3-004c': The sensor kernel
> >>>>>>>>>>>>>> driver needs to be fixed
> >>>>>>>>>>>>>> [6:03:22.990869519] [16719] ERROR CameraSensor
> >>>>>>>>>>>>>> camera_sensor.cpp:297 'ov5640 3-004c': See
> >>>>>>>>>>>>>> Documentation/sensor_driver_requirements.rst in the
> >>>>>>>>>>>>>> libcamera sources for more information
> >>>>>>>>>>>>>> [6:03:22.991348436] [16719] ERROR SimplePipeline
> >>>>>>>>>>>>>> simple.cpp:1309 No valid pipeline for sensor 'ov5640
> >>>>>>>>>>>>>> 3-004c', skipping

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list