Porting a Custom Camera from AGX Xavier to Orin NX

You can add message to print the width/height in camera_common.c/vi5_fops.c and sensor driver to make sure to select correct size(sensor mode).

Thanks, ShaneCCC. I had added printing of width, height and other parameters to vi5_setup_surface() in vi5_fops.c. Was that where you meant?

In our sensor driver file (in drivers/media/i2c/) I had added printing such parameters to the .set_mode function and the .start_streaming functions. Are those sufficient locations?

Here’s a snippet of the results when running at 1280x720:

[   39.675116]  In vi5_setup_surface(index = 0, port = 0)
[   39.675123]  height = 720, 0x2d0
[   39.675125]  width = 1280, 0x500
[   39.675126]  format = 19, 0x13
[   39.675127]  bpl = 2560, 0xa00
[   39.675128]  data_type = 30, 0x1e
[   39.675128]  nvcsi_stream = 2, 0x2
[   39.675129]  offset = 549686607872, 7ffbe00000
[   39.675131]  desc->sequence = 0
[   39.675131]  desc->ch_cfg.match.stream = 4
[   39.675132]  desc->ch_cfg.match.vc = 1
[   39.675133]  desc_memoryinfo->surface[0].size = 1843200, 1c2000
[   39.675144] In vi5_setup_surface(index = 1, port = 0)
[   39.675145]  height = 720, 0x2d0
[   39.675146]  width = 1280, 0x500
[   39.675146]  format = 19, 0x13
[   39.675147]  bpl = 2560, 0xa00
[   39.675148]  data_type = 30, 0x1e
[   39.675149]  nvcsi_stream = 2, 0x2
[   39.675150]  offset = 549684510720, 7ffbc00000
[   39.675151]  desc->sequence = 1
[   39.675151]  desc->ch_cfg.match.stream = 4
[   39.675152]  desc->ch_cfg.match.vc = 1
[   39.675152]  desc_memoryinfo->surface[0].size = 1843200, 1c2000
[   39.675161] In vi5_setup_surface(index = 2, port = 0)
[   39.675162]  height = 720, 0x2d0
[   39.675162]  width = 1280, 0x500
[   39.675163]  format = 19, 0x13
[   39.675164]  bpl = 2560, 0xa00
[   39.675165]  data_type = 30, 0x1e
[   39.675165]  nvcsi_stream = 2, 0x2
[   39.675166]  offset = 549682413568, 7ffba00000
[   39.675167]  desc->sequence = 2
[   39.675168]  desc->ch_cfg.match.stream = 4
[   39.675168]  desc->ch_cfg.match.vc = 1
[   39.675169]  desc_memoryinfo->surface[0].size = 1843200, 1c2000
[   39.675170] In vi5_setup_surface(index = 3, port = 0)
[   39.675171]  height = 720, 0x2d0
[   39.675172]  width = 1280, 0x500
[   39.675172]  format = 19, 0x13
[   39.675173]  bpl = 2560, 0xa00
[   39.675174]  data_type = 30, 0x1e
[   39.675174]  nvcsi_stream = 2, 0x2
[   39.675175]  offset = 549680316416, 7ffb800000
[   39.675176]  desc->sequence = 3
[   39.675176]  desc->ch_cfg.match.stream = 4
[   39.675177]  desc->ch_cfg.match.vc = 1
[   39.675177]  desc_memoryinfo->surface[0].size = 1843200, 1c2000
[   39.678720] fury_video 2-0054: fury_video_set_mode() name=fury_video
[   39.678728] fury_video 2-0054:       s_data->colorfmt->code = 8207
[   39.678731] fury_video 2-0054:       Formats:
[   39.678734] fury_video 2-0054:               0: 720x480
[   39.678738] fury_video 2-0054:                       Frame Rates:
[   39.678741] fury_video 2-0054:                       0: 60
[   39.678744] fury_video 2-0054:               1: 720x576
[   39.678747] fury_video 2-0054:                       Frame Rates:
[   39.678750] fury_video 2-0054:                       0: 50
[   39.678753] fury_video 2-0054:               2: 1280x720
[   39.678757] fury_video 2-0054:                       Frame Rates:
[   39.678759] fury_video 2-0054:                       0: 60
[   39.678762] fury_video 2-0054:       s_data->csi_port = 2
[   39.678765] fury_video 2-0054:       s_data->numlanes = 4
[   39.678767] fury_video 2-0054:       s_data->mode = 2
[   39.678768] fury_video 2-0054:       s_data->mode_prop_idx = 2
[   39.678770] fury_video 2-0054:       s_data->numfmts = 3
[   39.678771] fury_video 2-0054:       s_data->fmt_width = 1280
[   39.678772] fury_video 2-0054:       s_data->fmt_height = 720
[   39.678774] fury_video 2-0054:       s_data->sensor_mode_id = 0
[   39.678775] fury_video 2-0054:       s_data->use_sensor_mode_id = 0
[   39.678776] fury_video 2-0054:       s_data->override_enable = 0
[   39.678778] fury_video 2-0054:       s_data->version = 131078
[   39.678989] fury_video 2-0054: In fury_video_read_reg(, 7 0x7,) got 22 0x16
[   39.678997] fury_video 2-0054: fury_video_start_streaming() name=fury_video
[   39.679000] fury_video 2-0054:       s_data->colorfmt->code = 8207
[   39.679003] fury_video 2-0054:       Formats:
[   39.679006] fury_video 2-0054:               0: 720x480
[   39.679009] fury_video 2-0054:                       Frame Rates:
[   39.679012] fury_video 2-0054:                       0: 60
[   39.679015] fury_video 2-0054:               1: 720x576
[   39.679018] fury_video 2-0054:                       Frame Rates:
[   39.679021] fury_video 2-0054:                       0: 50
[   39.679024] fury_video 2-0054:               2: 1280x720
[   39.679027] fury_video 2-0054:                       Frame Rates:
[   39.679028] fury_video 2-0054:                       0: 60
[   39.679030] fury_video 2-0054:       s_data->csi_port = 2
[   39.679031] fury_video 2-0054:       s_data->numlanes = 4
[   39.679032] fury_video 2-0054:       s_data->mode = 2
[   39.679033] fury_video 2-0054:       s_data->mode_prop_idx = 2
[   39.679034] fury_video 2-0054:       s_data->numfmts = 3
[   39.679035] fury_video 2-0054:       s_data->fmt_width = 1280
[   39.679036] fury_video 2-0054:       s_data->fmt_height = 720
[   39.679038] fury_video 2-0054:       s_data->sensor_mode_id = 0
[   39.679039] fury_video 2-0054:       s_data->use_sensor_mode_id = 0
[   39.679040] fury_video 2-0054:       s_data->override_enable = 0
[   39.679041] fury_video 2-0054:       s_data->version = 131078
[   39.679332] fury_video 2-0054: In fury_video_write_reg(, 7 0x7, 150 0x96), returning 0
[   39.737704] tegra-camrtc-capture-vi tegra-capture-vi: corr_err: discarding frame 256, flags: 0, err_data 131072, status = 14, notify_bits = 40000000004
[   39.737746] In vi5_setup_surface(index = 0, port = 0)
[   39.737749]  height = 720, 0x2d0
[   39.737751]  width = 1280, 0x500
[   39.737752]  format = 19, 0x13
[   39.737754]  bpl = 2560, 0xa00
[   39.737755]  data_type = 30, 0x1e
[   39.737756]  nvcsi_stream = 2, 0x2
[   39.737757]  offset = 549686607872, 7ffbe00000
[   39.737759]  desc->sequence = 4
[   39.737760]  desc->ch_cfg.match.stream = 4
[   39.737761]  desc->ch_cfg.match.vc = 1
[   39.737762]  desc_memoryinfo->surface[0].size = 1843200, 1c2000
[   39.804421] tegra-camrtc-capture-vi tegra-capture-vi: corr_err: discarding frame 256, flags: 0, err_data 131072, status = 14, notify_bits = 40000000004
[   39.804463] In vi5_setup_surface(index = 1, port = 0)
[   39.804466]  height = 720, 0x2d0
[   39.804468]  width = 1280, 0x500
[   39.804469]  format = 19, 0x13
[   39.804471]  bpl = 2560, 0xa00
[   39.804472]  data_type = 30, 0x1e
[   39.804473]  nvcsi_stream = 2, 0x2
[   39.804475]  offset = 549684510720, 7ffbc00000
[   39.804476]  desc->sequence = 5
[   39.804477]  desc->ch_cfg.match.stream = 4
[   39.804478]  desc->ch_cfg.match.vc = 1
[   39.804479]  desc_memoryinfo->surface[0].size = 1843200, 1c2000

So you can see the rejected frames and the reason notify_bits = 40000000004, being bits 42 and 2, as described earlier. This is in response to the command:

v4l2-ctl  --set-fmt-video=width=1280,height=720 --stream-mmap

The desired height and width seem to be getting there just fine, but the frames are still rejected.

The virtual channel ID is 1?
Could you get the trace log.

desc->ch_cfg.match.vc = 1

Here is some updated status, trace output.
2025-03-24.log (18.2 KB)

Could you print the data_type in the vi5_fops.c also.

I think it was there already:
[ 39.675164] bpl = 2560, 0xa00
[ 39.675165] data_type = 30, 0x1e
[ 39.675165] nvcsi_stream = 2, 0x2

With further experimentation the 1280x720 resolution started working without having the 3840x2160 resolution enabled when I set the clocks to max_rate. However, setting the clocks to max didn’t help with the 720x480 resolution. That’s still being rejected with a line-too-long error.

Hi ShaneCCC!

I had printed the data_type in vi5_fops.c as you had requested: 30 (0x1e).
You seemed to express concern about desc->ch_cfg.match.vc = 1

Do either of those point you at something else for me to check or test?

Thanks,

Chris

Could you check the vc for the working size?

Both working and non-working show desc->ch_cfg.match.vc = 1. I have attached a working 1080p log and a failing 480p log. Thanks!
Failing480p.txt (30.3 KB)
Working1080p.txt (25.6 KB)

Any other ideas?

I noticed in here that there’s a debug version of the camera firmware for JP5. Is there a debug version for JP6 that I could try? Would that help?

For 720x480 the bpl should be 1440?

Thanks for taking another look.

The bpl = 2560, 0xa00 was from the log running at 1280x720, which was correctly 2560.

The log I posted above on March 31st, Failing480p.txt, is 720x480 and it does show the expected 1440 for bpl.

Chris

Any other suggestions?

Sorry, I am run out of idea now.
Will update to you if any finding later.

Thanks

There are apparently some debug versions of the camera FW as cited here: Request debug RTCPU image for JP5.1. Is such a version available for Orin NX and JP6.4?