Alignment issue in camera frame in Jetson TX2 NX

We have an alignment issue when trying with the Sony imx296 monochrome RAW10 camera when capturing frames in Jetson TX2 NX. We are capturing the raw frames using v4l2-ctl.

Our camera resolution is 1456x1088, but with the captured frame, the resolution is 1536x1088. We tried with some other camera resolution such as 1440x1080, then also the resolution of the captured frame is 1536x1080, and the pixels after 1440 are filled with black.

We went into the kernel code for identifying these width alignment issues and found the following

in channel.c

static void tegra_channel_fmt_align(struct tegra_channel *chan,
const struct tegra_video_format *vfmt,
u32 *width, u32 *height, u32 bytesperline)
{
unsigned int min_bpl;
unsigned int max_bpl;


/
Align stride */
if (chan->vi->fops->vi_stride_align)
chan->vi->fops->vi_stride_align(&bpl);

}

on vi4_fops.c

#define RM_SURFACE_ALIGNMENT 256


static void vi4_stride_align(unsigned int *bpl)
{
*bpl = ((*bpl + (RM_SURFACE_ALIGNMENT) - 1) &
~((RM_SURFACE_ALIGNMENT) - 1));
}

From this, the width is aligned to the multiple of RM_SURFACE_ALIGNMENT. So I tried reducing the value of RM_SURFACE_ALIGNMENT to 64, then the width is changed to 1472 (multiple of 64) with black pixels from 1456 to 1472.
So my questions are

  1. Can I change the RM_SURFACE_ALIGNMENT to any value? My intention is to set the camera resolution to 1440x1080 so that I can get proper resolution on the recorded frmae if I set RM_SURFACE_ALIGNMENT to 32[for example, If I set RM_SURFACE_ALIGNMENT as 32, and 1440 is a multiple of 32, I will get proper resolution in output]. But when I set RM_SURFACE_ALIGNMENT to 32, the recorded frames are not proper.
  2. Is there any way to get the same output resolution as input for raw capturing in Jetson TX2 NX (if the resolution is 1456x1088 or 1440x1080) (As I can see the driver calling vi4_stride_align() function in all cases)

Thanks

hello akesh.chacko,

we should have follow VI’s 64 byte aligned to set the correct stride, set the width alignment to 64.

so, this resolution doesn’t follow the alignment, you may adjust the width as 1472x1088 to follow the alignment,
the surface has allocate to 1472 for VI’s alignment, since the active region is only 1456, you’ll have 16 pixels padding with zeros.
furthermore,
you may enable v4l2-ctl command-line, adding the controls preferred_stride=<> to adjust the stride settings.

Q1
you can change the RM_SURFACE_ALIGNMENT to any value, however, it’s due to hardware limitation VI requirements that must be atom (64-byte) aligned.

Q2
as VI allocated buffer should follow 64-alignment, the capture raw already include those zero paddings, the solution is using gst pipeline with nvarguscamerasrc plugin to use nvvidconv cropping frames.

hello @JerryChang,
I already tried preferred_stride=<> and as per the code, if I call referred_stride, eventually it will call tegra_channel_fmt_align() function and then it will call vi_stride_align(). So I need to hardcode RM_SURFACE_ALIGNMENT with 64.

Q1
When I went through the VI5 source code, vi_stride_align() function is missing in vi5_fops.c file. So if I use Xavier NX, can I use stride alignment as 32? (If I use stride alignment 32, then I can make sensor resolution as 1440x1080 and save the frames without any padding)

Q2
Does gst pipeline with nvarguscamerasrc plugin support RAW10 monochrome data? I suppose it will support only format: { (string)NV12, (string)P010_10LE } formats

hello akesh.chacko,

can I use stride alignment as 32?

you may have a try, we did not test that since we don’t have camera with that resolution.

RAW10 monochrome data

it needs ISP configuration file settings to support monochrome, however, we don’t public support that.

hello akesh.chacko,

you may have a try to create camera_overrides file, and add below contents to support monochrome sensors.
please put the file under… /var/nvidia/nvcam/settings/camera_overrides.isp
for example,

defaults.yuvMatrix[0] = {0.3333, 0.3333, 0.3333, 0};
defaults.yuvMatrix[1] = {0, 0, 0, 0};
defaults.yuvMatrix[2] = {0, 0, 0, 0};
defaults.yuvMatrix[3] = {0, 0, 0, 1};

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.