Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixups for ADV7180/728x on Pi5 #5806

Merged
merged 5 commits into from
Jan 4, 2024
Merged

Conversation

6by9
Copy link
Contributor

@6by9 6by9 commented Dec 21, 2023

@naushir for error handling on CFE.

The others add the required information for ADV7180, but I've not got it streaming yet (yes I have set all the media-ctl links, just no buffers).

@6by9 6by9 requested a review from naushir December 21, 2023 19:16
@6by9 6by9 force-pushed the rpi-6.6.y-adv7180 branch from 8157ef5 to 6ff067e Compare December 21, 2023 19:37
@6by9
Copy link
Contributor Author

6by9 commented Dec 22, 2023

Added a couple of other patches for cleaning up the CFE formats table.

16bit formats is being queried on raspberrypi/libcamera#99 and looks to be missing the csi_dt value, so presumably metadata will be dropping into the CFE.

@6by9
Copy link
Contributor Author

6by9 commented Dec 22, 2023

Not setting the csi_dt for 16bit formats does appear to be an issue. Hacking imx708 to say that it produces RGGB16 produces random noise with the current kernel tree, and the anticipated kernel WARN from cfe.c:855 of WARN_ON(!fmt->csi_dt);

[   41.261207] source of link 'rp1-cfe-fe_config':0->'pisp-fe':1 is not a V4L2 sub-device, driver bug!
[   41.261257] ------------[ cut here ]------------
[   41.261259] WARNING: CPU: 0 PID: 986 at drivers/media/platform/raspberrypi/rp1_cfe/cfe.c:855 cfe_start_streaming+0x860/0x8c8 [rp1_cfe]
[   41.261272] Modules linked in: rfcomm snd_seq_dummy snd_hrtimer snd_seq snd_seq_device algif_hash algif_skcipher af_alg bnep vc4 dw9807_vcm imx708 spidev snd_soc_hdmi_codec drm_display_helper binfmt_misc brcmfmac_wcc hci_uart cec btbcm drm_dma_helper aes_ce_blk brcmfmac bluetooth drm_kms_helper aes_ce_cipher brcmutil ghash_ce gf128mul sha2_ce sha256_arm64 snd_soc_core rp1_cfe sha1_ce ecdh_generic cfg80211 rpivid_hevc(C) pisp_be v4l2_mem2mem snd_compress v4l2_fwnode ecc snd_pcm_dmaengine v4l2_async videobuf2_dma_contig raspberrypi_hwmon snd_pcm libaes videobuf2_memops videobuf2_v4l2 videodev rfkill snd_timer videobuf2_common snd v3d mc gpio_keys spi_bcm2835 i2c_brcmstb gpu_sched i2c_designware_platform raspberrypi_gpiomem i2c_designware_core drm_shmem_helper rp1_adc nvmem_rmem uio_pdrv_genirq uio i2c_dev drm fuse drm_panel_orientation_quirks backlight dm_mod ip_tables x_tables ipv6
[   41.261341] CPU: 0 PID: 986 Comm: rpicam-hello Tainted: G         C         6.6.8-v8+ #2
[   41.261345] Hardware name: Raspberry Pi 5 Model B Rev 1.0 (DT)
[   41.261346] pstate: 60400009 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[   41.261350] pc : cfe_start_streaming+0x860/0x8c8 [rp1_cfe]
[   41.261356] lr : cfe_start_streaming+0x3c4/0x8c8 [rp1_cfe]
[   41.261361] sp : ffffffc081bc3aa0
[   41.261363] x29: ffffffc081bc3aa0 x28: ffffff81046df480 x27: ffffff8104524000
[   41.261367] x26: ffffff8104521508 x25: ffffff810314b480 x24: ffffff8104520000
[   41.261370] x23: ffffff8104524000 x22: ffffff810391be00 x21: 0000000000000000
[   41.261374] x20: ffffff8104520c90 x19: ffffff8104520000 x18: 0000000000000000
[   41.261377] x17: 0000000000000000 x16: ffffffd084cff668 x15: 0000007f6c047f30
[   41.261381] x14: 0000000000000000 x13: 0000000000000000 x12: 0000000000000000
[   41.261384] x11: 0000000000000000 x10: 0000000000000000 x9 : ffffffd016e377a4
[   41.261387] x8 : 0000000000000000 x7 : 0000000000000001 x6 : 0000000000000510
[   41.261390] x5 : 0000000000000900 x4 : 000000000000301d x3 : ffffffd016e40478
[   41.261394] x2 : ffffffd016e40700 x1 : 0000000000000018 x0 : 0000000000000000
[   41.261397] Call trace:
[   41.261399]  cfe_start_streaming+0x860/0x8c8 [rp1_cfe]
[   41.261405]  vb2_start_streaming+0x74/0x170 [videobuf2_common]
[   41.261415]  vb2_core_streamon+0x120/0x1e8 [videobuf2_common]
[   41.261423]  vb2_streamon+0x24/0x80 [videobuf2_v4l2]
[   41.261432]  vb2_ioctl_streamon+0x58/0x70 [videobuf2_v4l2]
[   41.261438]  v4l_streamon+0x2c/0x40 [videodev]
[   41.261462]  __video_do_ioctl+0x18c/0x408 [videodev]
[   41.261478]  video_usercopy+0x334/0x768 [videodev]
[   41.261495]  video_ioctl2+0x20/0x40 [videodev]
[   41.261511]  v4l2_ioctl+0x48/0x70 [videodev]
[   41.261527]  __arm64_sys_ioctl+0xb0/0x100
[   41.261533]  invoke_syscall+0x4c/0x118
[   41.261538]  el0_svc_common.constprop.0+0x48/0xf0
[   41.261542]  do_el0_svc+0x24/0x38
[   41.261545]  el0_svc+0x48/0x100
[   41.261549]  el0t_64_sync_handler+0xc0/0xc8
[   41.261551]  el0t_64_sync+0x190/0x198
[   41.261553] ---[ end trace 0000000000000000 ]---

Adding the csi_dt value gives me an error within libcamera of

rpicam-hello: ../src/ipa/rpi/controller/histogram.cpp:50: double RPiController::Histogram::interBinMean(double, double) const: Assertion `binHi > binLo' failed.

binHi = 1023, binHi = 1023.
It still has the kernel message

[   32.645447] source of link 'rp1-cfe-fe_config':0->'pisp-fe':1 is not a V4L2 sub-device, driver bug!

This has been introduced by 55f1ecb.

@naushir
Copy link
Contributor

naushir commented Dec 23, 2023

No objections to the changes, LGTM.

@naushir
Copy link
Contributor

naushir commented Dec 23, 2023

Adding the csi_dt value gives me an error within libcamera of

rpicam-hello: ../src/ipa/rpi/controller/histogram.cpp:50: double RPiController::Histogram::interBinMean(double, double) const: Assertion `binHi > binLo' failed.

binHi = 1023, binHi = 1023.

This may be explained by the CSI2/FE thinking things are 16-bits and doing no shifts on the pixel data causing the stats to not add up correctly.

@naushir
Copy link
Contributor

naushir commented Dec 23, 2023

It still has the kernel message

[   32.645447] source of link 'rp1-cfe-fe_config':0->'pisp-fe':1 is not a V4L2 sub-device, driver bug!

This has been introduced by 55f1ecb.

But the link here is between a device node entity and a v4l2-subdev entity IIRC. Surely that has to be a valid configuration?

@6by9
Copy link
Contributor Author

6by9 commented Dec 23, 2023

It still has the kernel message

[   32.645447] source of link 'rp1-cfe-fe_config':0->'pisp-fe':1 is not a V4L2 sub-device, driver bug!

This has been introduced by 55f1ecb.

But the link here is between a device node and a v4l2-subdev entity IIRC. Surely that has to be a valid configuration?

I'd agree, but the core code is currently objecting to it since 6.4.

6by9 added 5 commits January 2, 2024 15:16
Noted that if we get "node link is not enabled", then we also
get the videobuf2 splat for the driver not cleaning up correctly
on a failed start_streaming, and indeed we weren't returning the
buffers.

Checking the other error paths, noted that the "FE enabled, but
FE_CONFIG node is not" path was not calling pm_runtime_put.

Fix both paths.

Signed-off-by: Dave Stevenson <[email protected]>
CSI2 devices are meant to use the 1Xnn formats rather than 2Xnn
such as MEDIA_BUS_FMT_UYVY8_2X8.

For devices with ADV7180_FLAG_MIPI_CSI2 set, use
MEDIA_BUS_FMT_UYVY8_1X16.

Signed-off-by: Dave Stevenson <[email protected]>
For CSI2 receivers that need to know the link frequency,
add it as a control to the driver.
Interlaced modes are 216Mbp/s or 108MHz, whilst going through
the I2P to deinterlace gives 432Mb/s or 216MHz.

Signed-off-by: Dave Stevenson <[email protected]>
Seeing as we now have the CSI2 data types defined, make use of
them instead of hardcoding the values.

Signed-off-by: Dave Stevenson <[email protected]>
Raw 16bit formats didn't have a csi_dt value defined, which
presumably would trip the WARN_ON(!fmt->csi_dt); in
cfe_start_channel.

The value is defined in CSI2 v2.0 as 0x2e, so set it accordingly.

Signed-off-by: Dave Stevenson <[email protected]>
@6by9 6by9 force-pushed the rpi-6.6.y-adv7180 branch from a866c35 to 09a022a Compare January 2, 2024 15:19
@6by9
Copy link
Contributor Author

6by9 commented Jan 4, 2024

@naushir Any other comments on this one, or can we merge?

@naushir
Copy link
Contributor

naushir commented Jan 4, 2024

Nope, LGTM. Happy to merge it.

@pelwell pelwell merged commit 5007002 into raspberrypi:rpi-6.6.y Jan 4, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants