工具与软件:
大量数据正在流向 CSI2RX、流 FIFO 溢出。 如何解决此问题?

This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
以下示例基于 SK-AM69 (J784s4)、ti-linux-6.6以及输出 SRGGB10像素的摄像机。
您可以通过读取 CSIRX_error_irqs 寄存器来检查流 FIFO 是否溢出。
以下命令读取的 CSIRX_error_irqs 寄存器 csi_rx_if0:
root@am69a-sk:~# devmem2 0x04504028 /dev/mem opened. Memory mapped at address 0xffff85cd0000. Read at address 0x04504028 (0xffff85cd0028): 0x00030100
寄存器值显示流0和1中存在溢出、因为位16和17已设置。
为了防止出现此问题、流 FIFO 需要更快地清空、因此增大该 NUM_PIXELS 值应该可以解决该问题。 NUM_PIXELS 控制每个周期从 FIFO 中删除的像素数量。
该值可以在 CSIRX_streamx_cfg 寄存器中找到(其中 x 是流编号)。
在这种假设情况下、我们有 RAW10格式的摄像头流像素、这意味着最大值 NUM_PIXELS 可以设置为1 (每个周期2个像素)。 这是因为4个 RAW10像素一次不能在32位内容纳;2是下一个最大的选项。
NUM_PIXELS 可以在 cdns-csi2rx.c 驱动程序中使用以下补丁来设置该值:
From 7df355bf18c4410b260c4d71466582de59b776ca Mon Sep 17 00:00:00 2001 From: Jared McArthur <j-mcarthur@ti.com> Date: Tue, 18 Feb 2025 17:23:52 -0600 Subject: [PATCH] media: cadence: csi2rx: Set NUM_PIXELS to 2 for each stream Signed-off-by: Jared McArthur <j-mcarthur@ti.com> --- drivers/media/platform/cadence/cdns-csi2rx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index 26b83cc47b5d..09e472d471e4 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -53,6 +53,7 @@ #define CSI2RX_STREAM_CFG_REG(n) (CSI2RX_STREAM_BASE(n) + 0x00c) #define CSI2RX_STREAM_CFG_FIFO_MODE_LARGE_BUF (1 << 8) +#define CSI2RX_STREAM_CFG_NUM_PIXELS_2 (1 << 4) #define CSI2RX_LANES_MAX 4 #define CSI2RX_STREAMS_MAX 4 @@ -318,7 +319,8 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx) reset_control_deassert(csi2rx->pixel_rst[i]); - writel(CSI2RX_STREAM_CFG_FIFO_MODE_LARGE_BUF, + writel(CSI2RX_STREAM_CFG_FIFO_MODE_LARGE_BUF + + CSI2RX_STREAM_CFG_NUM_PIXELS_2, csi2rx->base + CSI2RX_STREAM_CFG_REG(i)); writel(csi2rx->vc_select[i], -- 2.34.1
这将导致摄像机的输出每隔一个像素就跳过一次。

发生这种情况、因为您要在每个 PSIL 事务中发送两个像素。 当事务到达 DMA 时、只需要16位(第一个像素)并丢弃其他16位。
它不像素:0、1、2、3、4、 5…
您将得到像素:0、2、4、6、8…
这将导致线条宽度为其应有宽度的一半、并使您在常见问题解答中看到的图像加倍。 如果您的图像是10x10、您实际上会得到5x10的图像。 当输出为10x10格式时、顶部的两个象限中有两个5x5图像、底部的两个象限中没有任何图像。
| Q1:每个偶数行(仅限偶数像素) | Q2:每个奇数行(仅限偶数像素) |
| 问题3:没有 | 问题4:没有问题 |
需要设置另外一个值才能正确解压缩数据。 该值是 SIZE_CFG CSI_RX_IF_CNTX_CNTL_dmaCntx_i 寄存器中的值、用于在解包时控制数据大小移位。
读取 CSI_RX_IF_CNTX_CNTL_dmaCntx_i 寄存器时、您可以看到的值 SIZE_CFG 通常设置为 0b01 (16位)、因为 RAW10像素以16位数据包发送:
root@am69a-sk:~# devmem2 0x04500020
/dev/mem opened.
Memory mapped at address 0xffffa1e4c000.
Read at address 0x04500020 (0xffffa1e4c020): 0x8010002B
0b10 我们对 NUM_PIXEL 该值进行了更改、因此需要将其设置为(32位)。 这可以 j721e-csi2rx.c 通过以下修补程序在垫片内完成:
From cc46fa811f5ac9722cb0b37774d787a185749318 Mon Sep 17 00:00:00 2001
From: Jared McArthur <j-mcarthur@ti.com>
Date: Tue, 18 Feb 2025 17:38:46 -0600
Subject: [PATCH 2/2] media: ti: j721e-csi2rx: Set MEDIA_BUS_FMT_SRGGB10_1X10
size to SHIM_DMACNTX_SIZE_32
Signed-off-by: Jared McArthur <j-mcarthur@ti.com>
---
drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
index 7f239cbcb4f7..a576377f0eff 100644
--- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
+++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
@@ -212,7 +212,7 @@ static const struct ti_csi2rx_fmt ti_csi2rx_formats[] = {
.code = MEDIA_BUS_FMT_SRGGB10_1X10,
.csi_dt = MIPI_CSI2_DT_RAW10,
.bpp = 16,
- .size = SHIM_DMACNTX_SIZE_16,
+ .size = SHIM_DMACNTX_SIZE_32,
}, {
.fourcc = V4L2_PIX_FMT_SRGGI10,
.code = MEDIA_BUS_FMT_SRGGI10_1X10,
--
2.34.1
在这些更改被应用并且内核被重建后、您应该不再观察到流 FIFO 溢出错误。