v4l2 error:ctrl Gain range update failed

Hello all,

I am using TX2 with Jetpack4.2-R32.1,Want to driver a pre-configured csi video without I2C.and I have done this before on Jetpack3.1, and it’s ok to grab the video stream:
https://devtalk.nvidia.com/default/topic/1025863/jetson-tx2/how-to-grab-pre-configured-csi-video-stream-without-i2c-/1

The input video stream is generated by a SDI-to-CSI2 adapter, it’s a 4-lane, 1920x1080@60, YUV422 signal. And I connected the input MIPI-CSI data and clk lines directly to the CSI port of tx2.

We use the ov5693.c as template to implement the sensor driver.

But when I modify the kernel source code on R32.1, The error has occurred:
[ 4.374937] OV5693_sdi1 2-0036: ctrl Gain range update failed
[ 4.374942] OV5693_sdi1 2-0036: Error -34 updating mode specific control ranges
[ 4.374945] OV5693_sdi1 2-0036: Error -34 updating control ranges
[ 4.374964] OV5693_sdi1 2-0036: Failed to init ctrls ov5693
[ 4.374967] OV5693_sdi1 2-0036: tegra camera subdev registration failed

I found the code between the r28.1 and r32.1 is very different.

How to fix this error?

Hello,I really need some help…

hello suchb,

we had update linux kernel version to kernel-4.9 for JetPack-4.x
suggest you refer to [Sensor Driver Programming Guide]-> Camera Sensor Drivers Porting Guide for porting your sensor driver.
thanks

@JerryChang, Many thanks

According to your suggestion I modify the device tree and ov5693.c,looks csi sensor driver being probed successfully.

But I have missing /dev/video0 and there is no error in dmesg log.

err = of_property_read_string(client->dev.of_node, “devnode”, &devnode);

I got the right devnode “video0” and ov5693_debugfs_create is success:

#root@nvidia-desktop:/sys/kernel/debug/camera-video0# ls
#streaming

My modifications are based on R32.1 original source code and original dtsi, I think this ov5693.c is compatible with kernel 4.9.

What are we missing?

hello suchb,

you need to have kernel drive update to extend YUV format support,
please check the attachment of the r32.1 patch to add YUV format for VI drivers.
thanks

Topic1050578_Apr24_patch.tar.gz (1.23 KB)

Thanks JerryChang,

I found bellow massage when tx2 booting:

[ 4.409941] isp 15600000.isp: initialized
[ 4.414812] nvcsi 150c0000.nvcsi: initialized
[ 4.421049] gpio tegra-gpio-aon wake29 for gpio=56(FF:0)
[ 4.421124] gpio tegra-gpio-aon wake67 for gpio=57(FF:1)
[ 4.421203] gpio tegra-gpio-aon wake68 for gpio=58(FF:2)
[ 4.421351] input: gpio-keys as /devices/gpio-keys/input/input2
[ 4.421813] tegra-vi4 15700000.vi: initialized
[ 4.422785] tegra-vi4 15700000.vi: ep of_device is not enabled /host1x/vi@15700000/ports/port@0/endpoint.
[ 4.422789] tegra-vi4 15700000.vi: ep of_device is not enabled /host1x/vi@15700000/ports/port@1/endpoint.
[ 4.422792] tegra-vi4 15700000.vi: ep of_device is not enabled /host1x/vi@15700000/ports/port@2/endpoint.

It looks unusual. Where I should modify to enable host1x/vi@15700000 on R32.1?

Looking forward to your reply, Thanks

Thanks JerryChang,

I found bellow massage when tx2 booting:

[ 4.409941] isp 15600000.isp: initialized
[ 4.414812] nvcsi 150c0000.nvcsi: initialized
[ 4.421049] gpio tegra-gpio-aon wake29 for gpio=56(FF:0)
[ 4.421124] gpio tegra-gpio-aon wake67 for gpio=57(FF:1)
[ 4.421203] gpio tegra-gpio-aon wake68 for gpio=58(FF:2)
[ 4.421351] input: gpio-keys as /devices/gpio-keys/input/input2
[ 4.421813] tegra-vi4 15700000.vi: initialized
[ 4.422785] tegra-vi4 15700000.vi: ep of_device is not enabled /host1x/vi@15700000/ports/port@0/endpoint.
[ 4.422789] tegra-vi4 15700000.vi: ep of_device is not enabled /host1x/vi@15700000/ports/port@1/endpoint.
[ 4.422792] tegra-vi4 15700000.vi: ep of_device is not enabled /host1x/vi@15700000/ports/port@2/endpoint.

It looks unusual. Where I should modify to enable host1x/vi@15700000 on R32.1?

Looking forward to your reply, Thanks

hello suchb,

you should disable plugin manager if your camera board don’t have EEPROM.
please also refer to [Sensor Driver Programming Guide]-> Using Plugin Manager session.
thanks

Thanks JerryChang,

I have already disable plugin manager dtsi in tegra186-quill-p3310-1000-a00-00-base.dts

I want to confirm if the following changes are correct:


#include <t18x-common-platforms/tegra186-quill-common-p3310-1000-a00.dtsi>
#include <t18x-common-platforms/tegra186-quill-power-tree-p3310-1000-a00-00.dtsi>
#include <t18x-common-platforms/tegra186-quill-camera-modules.dtsi>
#include <t18x-common-modules/tegra186-display-e3320-1000-a00.dtsi>
#include <t18x-common-platforms/tegra186-quill-camera-e3326-a00.dtsi>

/* comms dtsi file should be included after gpio dtsi file */
#include <t18x-common-platforms/tegra186-quill-comms.dtsi>
#include <t18x-common-plugin-manager/tegra186-quill-p3310-1000-a00-plugin-manager.dtsi>
#include <t18x-common-modules/tegra186-super-module-e2614-p2597-1000-a00.dtsi>
#include <t18x-common-plugin-manager/tegra186-quill-display-plugin-manager.dtsi>
#include <t18x-common-prod/tegra186-priv-quill-p3310-1000-a00-prod.dtsi>
//#include <t18x-common-plugin-manager/tegra186-quill-camera-plugin-manager.dtsi>

/ {
model = “quill”;
compatible = “nvidia,quill”, “nvidia,tegra186”;

hello suchb,

all these dtsi files combine and build into signal dtb file for Jetson platform.
suggest you have an alternative way to check if all your configuration included in the final dtb file.
here’s commands to disassembler the dtb file into txt file for your quick checking.
thanks

$ dtc -I dtb -O dts -o temp.txt tegra186-quill-p3310-1000-c03-00-base.dtb

Thank you JerryChang,

I have sloved the video0 problem with delete this line:
#include <t18x-common-platforms/tegra186-quill-camera-modules.dtsi>

But when I use qv4l2 to get video stream, update contorl ranges error has occurred:
[ 107.609613] ov5693_sdi1 2-0036: Error updating control ranges -22
[ 107.684435] ov5693_sdi1 2-0036: Error updating control ranges
[ 127.782079] ----->suchb:ov5693_stop_streaming

bellow is my dtsi code for 1080p30fps pre-configured mipi csi video:

compatible = "nvidia,ov5693_sdi1";
			/* I2C device address */
			reg = <0x36>;

			/* V4L2 device node location */
			devnode = "video0";

			/* Physical dimensions of sensor */
			physical_w = "3.674";
			physical_h = "2.738";

			/* Define any required hw resources needed by driver */
			/* ie. clocks, io pins, power sources */
			avdd-reg = "vana";
			iovdd-reg = "vif";

			/* Sensor output flip settings */
			vertical-flip = "true";

			mode0 { // OV5693_MODE_1920x1080
				mclk_khz = "24000";
				num_lanes = "4";
				tegra_sinterface = "serial_c";
				phy_mode = "DPHY";
				discontinuous_clk = "no";
				dpcm_enable = "false";
				cil_settletime = "0";

				active_w = "1920";
				active_h = "1080";
				mode_type = "bayer";
				pixel_phase = "bggr";
				csi_pixel_bit_depth = "10";
				readout_orientation = "90";
				line_length = "2200";
				inherent_gain = "1";
				mclk_multiplier = "6.67";
				pix_clk_hz = "160000000";

				gain_factor = "10";
				min_gain_val = "10";/* 1DB*/
				max_gain_val = "160";/* 16DB*/
				step_gain_val = "1";
				default_gain = "10";
				min_hdr_ratio = "1";
				max_hdr_ratio = "1";
				framerate_factor = "1000000";
				min_framerate = "1816577";/*1.816577 */
				max_framerate = "30000000";/*30*/
				step_framerate = "1";
				default_framerate = "30000000";
				exposure_factor = "1000000";
				min_exp_time = "34";/* us */
				max_exp_time = "550385";/* us */
				step_exp_time = "1";
				default_exp_time = "33334";/* us */
				embedded_metadata_height = "1";
			};

could you please point me is there any wrong parameter.

Many thanks

hello suchb,

please check your control range settings of below CID controls,
you may also add some debug message to check which control caused the failure.
TEGRA_CAMERA_CID_GAIN
TEGRA_CAMERA_CID_FRAME_RATE
TEGRA_CAMERA_CID_EXPOSURE
TEGRA_CAMERA_CID_EXPOSURE_SHORT

please note that there are two V4L2 Kernel Driver versions if you’re working with JetPack-4.2
please refer to Sensor Driver Programming Guide, and check the [V4L2 Kernel Driver (Version 2.0)] for details.
thanks

Hi JerryChang,

int tegracam_init_ctrl_ranges_by_mode(
struct tegracam_ctrl_handler *handler,
u32 modeidx)
{
struct tegracam_device *tc_dev = handler->tc_dev;
struct camera_common_data *s_data = tc_dev->s_data;
struct sensor_control_properties *ctrlprops = NULL;
int i;

if (modeidx >= s_data->sensor_props.num_modes)
	return -EINVAL;

error occurred in here when update control ranges based on mode settings,modeidx >= s_data->sensor_props.num_modes

hello suchb,

this error means no sensor modes available, could you please check your kernel driver header.
you should follow the camera_common_frmfmt structure and report your sensor modes.
please also refer to below for an example,

$TOP/kernel_src/public_sources/kernel/nvidia/drivers/media/i2c/imx185_mode_tbls.h

static const struct camera_common_frmfmt imx185_frmfmt[] = {
...
};

yes JerryChang,

I’m working on this.

I found some other Frame Size can be set successful but 1080P is not ok.

Thank you.

Hello JerryChang,

I have merge the Topic1050578_Apr24_patch.tar.gz patch, and made the vo5693_frmfmt only have one frameformat OV5693_MODE_1920X1080.

But when i use qv4l2 to grab video stream, the Capture Image Formats can’t be set to YU12 or YUV422,it always be BG10 as default, and dmesg is no error line.

when run :v4l2-ctl -d /dev/video0 --set-ctrl bypass_mode=0 --stream-mmap --stream-count=1 --stream-to=test.raw

I got bellow info:

#dmesg

[ 1899.321714] tegra-vi4 15700000.vi: tegra_channel_error_recovery: attempting to reset the capture channel
[ 1899.539226] tegra-vi4 15700000.vi: PXL_SOF syncpt timeout! err = -11
[ 1899.545843] tegra-vi4 15700000.vi: tegra_channel_error_recovery: attempting to reset the capture channel
[ 1899.557674] nvcsi 150c0000.nvcsi: csi4_stream_check_status (0) INTR_STATUS 0x00000004
[ 1899.565802] nvcsi 150c0000.nvcsi: csi4_stream_check_status (0) ERR_INTR_STATUS 0x00000004
[ 1899.779228] tegra-vi4 15700000.vi: PXL_SOF syncpt timeout! err = -11
[ 1899.785688] tegra-vi4 15700000.vi: tegra_channel_error_recovery: attempting to reset the capture channel
[ 1899.798060] nvcsi 150c0000.nvcsi: csi4_stream_check_status (0) INTR_STATUS 0x00000004
[ 1899.805987] nvcsi 150c0000.nvcsi: csi4_stream_check_status (0) ERR_INTR_STATUS 0x00000004

#cat /sys/kernel/debug/tracing/trace

kworker/5:3-4702  [005] ....  1872.339055: rtcpu_vinotify_event: tstamp:58894581000 tag:CSIMUX_STREAM channel:0xff frame:0 vi_tstamp:58894580623 data:0x00000001
kworker/5:3-4702  [005] ....  1872.394990: rtcpu_vinotify_event: tstamp:58895951494 tag:CHANSEL_SHORT_FRAME channel:0x01 frame:22110 vi_tstamp:58895950908 data:0x00000001
kworker/5:3-4702  [005] ....  1872.394997: rtcpu_vinotify_event: tstamp:58895951630 tag:ATOMP_FE channel:0x00 frame:22110 vi_tstamp:58895950910 data:0x00000001

kworker/5:3-4702  [005] ....  1899.847314: rtos_queue_send_failed: tstamp:59753796623 queue:0x0b4a7258
kworker/5:3-4702  [005] ....  1899.847317: rtcpu_vinotify_event: tstamp:59753798206 tag:CSIMUX_STREAM channel:0xff frame:0 vi_tstamp:59753795981 data:0x00000001

could you please point me how to fix this.

Thanks!

hello suchb,

  1. since you refer to bayer sensor device tree and have modification to yours.
    had you also update sensor device tree to report pixel format as YUV format.
    for example,
mode0 {
                                ...
                                active_w = "1920";
                                active_h = "1080";
                                ...
                                pixel_t = "yuv_yuyv16"

suggest you check below kernel sources for complete pixel format types.

$TOP/kernel_src/kernel/nvidia/drivers/media/platform/tegra/camera/sensor_common.c

static int extract_pixel_format(const char *pixel_t, u32 *format)
{...}
  1. also, please given complete options to v4l2 standard controls.
    for example,
$ v4l2-ctl -d /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat=UYVY --set-ctrl bypass_mode=0 --stream-mmap --stream-count=1
  1. your error message might be related to not complete hardware signaling.
[ 1899.539226] tegra-vi4 15700000.vi: PXL_SOF syncpt timeout! err = -11
  1. if you still meet failure by correcting sensor device tree and using complete commands to access the camera sensor.
    could you please enable VI tracing logs as below to gather more details.
    thanks
echo 1 > /sys/kernel/debug/tracing/tracing_on
echo 30720 > /sys/kernel/debug/tracing/buffer_size_kb
echo 1 > /sys/kernel/debug/tracing/events/tegra_rtcpu/enable
echo 1 > /sys/kernel/debug/tracing/events/freertos/enable
echo 2 > /sys/kernel/debug/camrtc/log-level
echo > /sys/kernel/debug/tracing/trace
cat /sys/kernel/debug/tracing/trace

THANK YOU JerryChang,

It’s worked.