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.

[参考译文] J722SXH01EVM:添加了对新 v4l2子器件驱动程序的支持

Guru**** 2333840 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1506437/j722sxh01evm-adding-support-for-a-new-v4l2-sub-device-driver

器件型号:J722SXH01EVM

工具/软件:

尊敬的 TI 专家:

我正在努力通过 MIPI/SCI2连接全新的 OnSemi ToF 传感器。

使用 TISDK 中的示例驱动程序(imx219.c)、我能够通过 i2c 成功地加载驱动程序和探头。

我修改了/opt/edgeai-gst-apps/scripts/setup_cameras.sh 脚本、以便为我的器件设置媒体流水线。

Pegasus ToF Camera 1 detected
    device = /dev/video-pegasustof-cam0
    name = Pegasus ToF
    format = [fmt:SRGGB12_1X12/1280x960]
    subdev_id = /dev/v4l-pegasustof-subdev0
    isp_required = yes

下面的 media-ctl -d 1 -p 的输出:

media-ctl -d 1 -p
Media controller API version 6.6.44

Media device information
------------------------
driver          j721e-csi2rx
model           TI-CSI2RX
serial
bus info        platform:30122000.ticsi2rx
hw revision     0x1
driver version  6.6.44

Device topology
- entity 1: 30122000.ticsi2rx (5 pads, 5 links, 1 route)
            type V4L2 subdev subtype Unknown flags 0
            device node name /dev/v4l-subdev0
        routes:
                0/0 -> 1/0 [ACTIVE]
        pad0: Sink
                [stream:0 fmt:SRGGB12_1X12/1280x960 field:none]
                <- "cdns_csi2rx.30121000.csi-bridge":1 [ENABLED,IMMUTABLE]
        pad1: Source
                [stream:0 fmt:SRGGB12_1X12/1280x960 field:none]
                -> "30122000.ticsi2rx context 0":0 [ENABLED,IMMUTABLE]
        pad2: Source
                -> "30122000.ticsi2rx context 1":0 [ENABLED,IMMUTABLE]
        pad3: Source
                -> "30122000.ticsi2rx context 2":0 [ENABLED,IMMUTABLE]
        pad4: Source
                -> "30122000.ticsi2rx context 3":0 [ENABLED,IMMUTABLE]

- entity 7: cdns_csi2rx.30121000.csi-bridge (5 pads, 2 links, 1 route)
            type V4L2 subdev subtype Unknown flags 0
            device node name /dev/v4l-subdev1
        routes:
                0/0 -> 1/0 [ACTIVE]
        pad0: Sink
                [stream:0 fmt:SRGGB12_1X12/1280x960 field:none]
                <- "pegasustof 6-003c":0 [ENABLED,IMMUTABLE]
        pad1: Source
                [stream:0 fmt:SRGGB12_1X12/1280x960 field:none]
                -> "30122000.ticsi2rx":0 [ENABLED,IMMUTABLE]
        pad2: Source
        pad3: Source
        pad4: Source

- entity 13: pegasustof 6-003c (1 pad, 1 link, 0 routes)
             type V4L2 subdev subtype Sensor flags 0
             device node name /dev/v4l-subdev2
        pad0: Source
                [stream:0 fmt:SRGGB12_1X12/1280x960 field:none colorspace:raw xfer:none quantization:full-range
                 crop.bounds:(64,44)/1280x960
                 crop:(64,44)/1280x960]
                -> "cdns_csi2rx.30121000.csi-bridge":0 [ENABLED,IMMUTABLE]

- entity 19: 30122000.ticsi2rx context 0 (1 pad, 1 link)
             type Node subtype V4L flags 0
             device node name /dev/video2
        pad0: Sink
                <- "30122000.ticsi2rx":1 [ENABLED,IMMUTABLE]

- entity 25: 30122000.ticsi2rx context 1 (1 pad, 1 link)
             type Node subtype V4L flags 0
             device node name /dev/video3
        pad0: Sink
                <- "30122000.ticsi2rx":2 [ENABLED,IMMUTABLE]

- entity 31: 30122000.ticsi2rx context 2 (1 pad, 1 link)
             type Node subtype V4L flags 0
             device node name /dev/video4
        pad0: Sink
                <- "30122000.ticsi2rx":3 [ENABLED,IMMUTABLE]

- entity 37: 30122000.ticsi2rx context 3 (1 pad, 1 link)
             type Node subtype V4L flags 0
             device node name /dev/video5
        pad0: Sink
                <- "30122000.ticsi2rx":4 [ENABLED,IMMUTABLE]

到目前为止的一切似乎都可以(就我所能说的而言)。

我的器件报告一个源板 SRGGB12_1x12/1280x960、介质流水线中的所有其他器件均使用此格式设置。

现在、当我调用: v4l2-ctl -d /dev/video-pegasustof-cam0 --get-fmt-video

我得到640x480 UYVY 4:2:2、而不是预期的1280x960  SRGGB12。

v4l2-ctl -d /dev/video-pegasustof-cam0 --get-fmt-video
Format Video Capture:
        Width/Height      : 640/480
        Pixel Format      : 'UYVY' (UYVY 4:2:2)
        Field             : None
        Bytes per Line    : 1280
        Size Image        : 614400
        Colorspace        : sRGB
        Transfer Function : sRGB
        YCbCr/HSV Encoding: ITU-R 601
        Quantization      : Limited Range
        Flags             :

我的子设备格式不会传播到视频设备驱动程序。

如果我尝试运行打开 /dev/video-pegasustof-cam0的用户空间应用程序(如 app_tiovx_v4l2_capture_module_test.c)、我会看到在应用程序中启动流成功、但从未调用我驱动程序的 s_stream 例程。

int v4l2_capture_start(v4l2CaptureHandle *handle)
{
    int status = 0;
    enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;

    if (-1 == xioctl(handle->fd, VIDIOC_STREAMON, &type))
    {
        TIOVX_MODULE_ERROR("[V4L2_CAPTURE] VIDIOC_STREAMON failed\n");
        status = -1;
    }

    sleep(V4L2_CAPTURE_STREAMON_DELAY);

    return status;
}

当我使用 imx219传感器执行相同操作时、我可以看到 imx219.c 驱动程序的 s_stream routtime 被调用。

由于我的驱动程序基于 imx219.c、因此我预计会调用我的 s_stream 例程、但很遗憾、它不会被调用。

 /dev/video-pegasustof-cam0和 /dev/v4l-pegasustof-subdev0之间的链接似乎并不完整、因为/dev/video-pegasustof-cam0格式不是/dev/v4l-pegasustof-subdev0的格式、并且从未调用过我的 s_stream 例程这一事实表明了这一点。

欢迎您在此处提供任何帮助。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 St é phane:

    在深入探讨 TIOVX 捕获应用之前、 您能否先 通过使用 v4l2-ctl 或 yavta 捕获数据来验证传感器是否已成功启用?

    [报价 userid="652076" url="~/support/processors-group/processors/f/processors-forum/1506437/j722sxh01evm-adding-support-for-a-new-v4l2-sub-device-driver

    我的器件报告一个源板 SRGGB12_1x12/1280x960、介质流水线中的所有其他器件均使用此格式设置。

    现在、当我调用: v4l2-ctl -d /dev/video-pegasustof-cam0 --get-fmt-video

    我得到640x480 UYVY 4:2:2、而不是预期的1280x960  SRGGB12。

    [/报价]

    如果 在启动 EVM 后未从视频器件捕获、则这是预期的输出。 如果您  使用 GStreamer (gst-launch-1.0)从视频设备捕获 、然后使用 v4l2-ctl 检查格式、您将找到您使用 media-ctl (setup_cameras.sh)设置的格式。 请参阅下面使用 imx219的示例。

    IMX219 Camera 0 detected
        device = /dev/video-imx219-cam0
        name = imx219
        format = [fmt:SRGGB8_1X8/1920x1080]
        subdev_id = /dev/v4l-imx219-subdev0
        isp_required = yes
    root@j722s-evm:/opt/edgeai-gst-apps# v4l2-ctl -d /dev/video-imx219-cam0 --get-fmt-video
    Format Video Capture:
            Width/Height      : 640/480
            Pixel Format      : 'UYVY' (UYVY 4:2:2)
            Field             : None
            Bytes per Line    : 1280
            Size Image        : 614400
            Colorspace        : sRGB
            Transfer Function : sRGB
            YCbCr/HSV Encoding: ITU-R 601
            Quantization      : Limited Range
            Flags             :
    root@j722s-evm:/opt/edgeai-gst-apps# gst-launch-1.0 v4l2src device=/dev/video-imx219-cam0 io-mode=5 ! queue leaky=2 ! video/x-bayer, width=1920, height=1080, framerate=30/1, format=rggb ! tiovxisp sink_0::device=/dev/v4l-subdev2 sensor-name="SENSOR_SONY_IMX219_RPI" dcc-isp-file=/opt/imaging/imx219/linear/dcc_viss_1920x1080.bin sink_0::dcc-2a-file=/opt/imaging/imx219/linear/dcc_2a_1920x1080.bin format-msb=7 ! video/x-raw, format=NV12, width=1920, height=1080, framerate=30/1 ! kmssink driver-name=tidss sync=false
    APP: Init ... !!!
       179.744986 s: MEM: Init ... !!!
       179.745058 s: MEM: Initialized DMA HEAP (fd=8) !!!
       179.745260 s: MEM: Init ... Done !!!
       179.745276 s: IPC: Init ... !!!
       179.813538 s: IPC: Init ... Done !!!
    REMOTE_SERVICE: Init ... !!!
    REMOTE_SERVICE: Init ... Done !!!
       179.825794 s: GTC Frequency = 200 MHz
    APP: Init ... Done !!!
       179.830015 s:  VX_ZONE_INFO: Globally Enabled VX_ZONE_ERROR
       179.830073 s:  VX_ZONE_INFO: Globally Enabled VX_ZONE_WARNING
       179.830085 s:  VX_ZONE_INFO: Globally Enabled VX_ZONE_INFO
       179.831857 s:  VX_ZONE_INFO: [tivxPlatformCreateTargetId:134] Added target MPU-0
       179.832075 s:  VX_ZONE_INFO: [tivxPlatformCreateTargetId:134] Added target MPU-1
       179.832204 s:  VX_ZONE_INFO: [tivxPlatformCreateTargetId:134] Added target MPU-2
       179.832317 s:  VX_ZONE_INFO: [tivxPlatformCreateTargetId:134] Added target MPU-3
       179.832334 s:  VX_ZONE_INFO: [tivxInitLocal:126] Initialization Done !!!
       179.832349 s:  VX_ZONE_INFO: Globally Disabled VX_ZONE_INFO
    Setting pipeline to PAUSED ...
    Pipeline is live and does not need PREROLL ...
    Pipeline is PREROLLED ...
    Setting pipeline to PLAYING ...
    New clock: GstSystemClock
    Redistribute latency...
    handling interrupt.:99.
    Interrupt: Stopping pipeline ...
    Execution ended after 0:00:02.834775715
    Setting pipeline to NULL ...
    Freeing pipeline ...
    APP: Deinit ... !!!
    REMOTE_SERVICE: Deinit ... !!!
    REMOTE_SERVICE: Deinit ... Done !!!
       182.916727 s: IPC: Deinit ... !!!
       182.919655 s: IPC: DeInit ... Done !!!
       182.919722 s: MEM: Deinit ... !!!
       182.919832 s: DDR_SHARED_MEM: Alloc's: 25 alloc's of 24308559 bytes
       182.919850 s: DDR_SHARED_MEM: Free's : 25 free's  of 24308559 bytes
       182.919861 s: DDR_SHARED_MEM: Open's : 0 allocs  of 0 bytes
       182.919877 s: MEM: Deinit ... Done !!!
    APP: Deinit ... Done !!!
    root@j722s-evm:/opt/edgeai-gst-apps# v4l2-ctl -d /dev/video-imx219-cam0 --get-fmt-video
    Format Video Capture:
            Width/Height      : 1920/1080
            Pixel Format      : 'RGGB' (8-bit Bayer RGRG/GBGB)
            Field             : None
            Bytes per Line    : 1920
            Size Image        : 2073600
            Colorspace        : Default
            Transfer Function : Default (maps to Rec. 709)
            YCbCr/HSV Encoding: Default (maps to ITU-R 601)
            Quantization      : Default (maps to Full Range)
            Flags             :
    

    以下常见问题解答可能会有所帮助:

    谢谢您、

    法比亚纳  

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    你好 Fabiana ,对不起晚回复。 我终于能够使它工作,并从我的 ToF 传感器采集图像。  我通过使用 v4l2-ctl -v 'width=1280、height=960、pixelformat=RG12'将视频设备(/dev/video-pegasustof-cam0)的格式设置为正确的格式来解决问题。

    谢谢您、

    Stephane