OV5645 - Trying to get scaling to work


#1

I’m trying to get scaling to work on my camera so that I can decrease the resolution output by the camera to save on bandwidth used by an RTSP stream. I’m attempting to follow the guide for scaling the output from the camera the github pages located here: https://github.com/96boards/documentation/blob/master/ConsumerEdition/DragonBoard-410c/Guides/CameraModule.md

However when using the following media-ctl pipeline:
media-ctl -d /dev/media1 -v -V '"ov5645 1-0078":0[fmt:UYVY2X8/1280x960 field:none],"msm_csiphy0":0[fmt:UYVY2X8/1280x960 field:none],"msm_csid0":0[fmt:UYVY2X8/1280x960 field:none],"msm_ispif0":0[fmt:UYVY2X8/1280x960 field:none],"msm_vfe0_pix":0[fmt:UYVY2X8/1280x960 field:none compose:(0,0)/1280x720],"msm_vfe0_pix":1[fmt:UYVY8_1_5X8/1280x720 field:none]'

I get the following error:
Opening media device /dev/media1
Enumerating entities
Found 15 entities
Enumerating pads and links
Setting up format UYVY2X8 1280x960 on pad ov5645 1-0078/0
Format set: UYVY2X8 1280x960
Setting up format UYVY2X8 1280x960 on pad msm_csiphy0/0
Format set: UYVY2X8 1280x960
Setting up format UYVY2X8 1280x960 on pad msm_csiphy0/0
Format set: UYVY2X8 1280x960
Setting up format UYVY2X8 1280x960 on pad msm_csid0/0
Format set: UYVY2X8 1280x960
Setting up format UYVY2X8 1280x960 on pad msm_ispif0/0
Format set: UYVY2X8 1280x960
Setting up format UYVY2X8 1280x960 on pad msm_vfe0_pix/0
Format set: UYVY2X8 1280x960
Setting up selection target 256 rectangle (0,0)/1280x720 on pad msm_vfe0_pix/0
Unable to set selection rectangle: Inappropriate ioctl for device (-25)
Unable to setup formats: Inappropriate ioctl for device (25)

Am I missing anything here?


#2

Hi Rob,

The VFE hardware can only do fixed ratio scaling of the image by downsampling in steps of 2x to 16x. So it’s likely that the error you see is caused by the ratio change in the last step (960 vs 720 with unmodified width).

In order to get the output image of 1280x720 you would need to apply cropping, as described in the documentation you linked to.

Regards,
Bjorn


#3

Hi Rob,

Sorry, I have missed that.
Inappropriate ioctl for device (-25) - this sounds to me as a version of the camera driver which is older and does not support scale and crop. Could you please check this? When you do
media-ctl -d /dev/media1 -p
do you see any compose and crop rectangle information on msm_vfe0_pix, e.g.:

- entity 61: msm_vfe0_pix (2 pads, 5 links)
             type V4L2 subdev subtype Unknown flags 0
             device node name /dev/v4l-subdev14
        pad0: Sink
                [fmt:UYVY8_2X8/1280x960 field:none
                 compose.bounds:(0,0)/1280x960
                 compose:(0,0)/1280x720]
                <- "msm_ispif0":1 []
                <- "msm_ispif1":1 [ENABLED]
                <- "msm_ispif2":1 []
                <- "msm_ispif3":1 []
        pad1: Source
                [fmt:UYVY8_1_5X8/1280x720 field:none
                 crop.bounds:(0,0)/1280x720
                 crop:(0,0)/1280x720]
                -> "msm_vfe0_video3":0 [ENABLED,IMMUTABLE]

Otherwise the VFE scaler actually supports any downscale ratio between 1x and 16x, however as the hardware can write to memory in multiple of 16 bytes (horizontally) additional crop will be applied after the scaler if the scaler output is not multiple of 16.

Also horizontal and vertical scaling are independent so you can scale in only one dimension or use different scaling ratio for horizontal and vertical dimension - this will result in distorted image off course but there is no limitation to be configured and used.

So in your case you would probably want to either crop the vertical dimension as Bjorn suggested or scale both dimensions with the same ratio.

Best regards,
Todor


#4

Hello Todor,

Can you point me to a build has this feature built into it? Is it the latest stable #283 or a snapshot? Currently I’m on an OpenEmbedded build from CAF the manifest version is IMM.LE.1.0-33400 and I seem to be missing scaling support.

There is a new manifest version out there but I haven’t integrated it yet - the new manifest version is IMM.LE.1.0-36900. If you have a specific set of commits in mind, I can see if the latest CAF manifest has support for it. If it doesn’t I can apply those directly and see what happens.

Thanks for your expertise,
Rob


#5

Hello,

Yes, the #283 has this functionality in the kernel.
Do you have this kernel already?

Best regards,
Todor