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-AM62A-LP: SK-AM62A-LP : Customized sensor driver working

Part Number: SK-AM62A-LP

Hello TI Support Team, 

It was a task to port the ar0323 sensor driver to the CUSTOM-made AM62A board and upload it to the video device. However, the video output doesn't seem to work normally, so I'm asking for a guide.

1) Here is custom ar0323 driver probe , and initialization done. 

[ 2.123775] smhong ar0323_initialize, client->addr value: 0x10
[ 2.129738] smhong ar0323_initialize, client->addr value: 0x10, i2c channel value: 2
[ 2.158569] [+][smhong] message [F: ar0323_set_regs, L:185]: caller:(i2c_device_probe+0xa8/0x2a8)
[ 2.745516] [+][smhong] message [F: to_ar0323, L:171]: caller:(ar0323_otp_id_read+0x38/0x12c)
[ 2.754242] [+][smhong] message [F: ar0323_otp_id_read, L:548]: caller:(ar0323_probe+0x4a4/0x590)
[ 2.789703] ar0323 2-0010: ar0323 PID d56, res 2560x992, OTP_ID 1a:00:18:16:0a:83
[ 2.797357] smhong [5]
[ 2.799856] [smhong] ar0323_initialize done!!
[ 2.804330] [smhong] ar0323_probe done!!
[ 2.808394] omap_i2c 20010000.i2c: bus 2 rev0.12 at 400 kHz
[ 2.820710] omap_i2c 20020000.i2c: bus 3 rev0.12 at 400 kHz

2) check to the video device 

root@am62axx-evm:~# v4l2-ctl --list-devices
j721e-csi2rx (platform:30102000.ticsi2rx):
/dev/video2
/dev/video3
/dev/video4
/dev/video5
/dev/media0

wave5-dec (platform:wave5-dec):
/dev/video0

wave5-enc (platform:wave5-enc):
/dev/video1

3) test video capture using Gstreamer , but not working. video2 seems to be a device driver for our sensor. 

root@am62axx-evm:~# gst-launch-1.0 -v v4l2src device=/dev/video2 ! videoconvert ! v4l2h264enc ! filesink location=out.264
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
/GstPipeline:pipeline0/GstV4l2Src:v4l2src0.GstPad:src: caps = video/x-raw, width=(int)3840, height=(int)2160, framerate=(fraction)120/1, interlace-mode=(string)progressive, format=(string)YUY2, colorimetry=(string)2:6:5:1
/GstPipeline:pipeline0/GstVideoConvert:videoconvert0.GstPad:src: caps = video/x-raw, width=(int)3840,[ 397.593183] [+][smhong] message [F: to_ar0323, L:171]: caller:(call_get_fmt+0x74/0xd0)
height=(int)2160, framerate=(fraction)120/1, interlace-mode=(st[ 397.602689] [+][smhong] message [F: ar0323_get_fmt, L:262]: caller:(call_get_fmt+0x74/0xd0)
ring)progressive, format=(string)I420, colorimetry=(string)bt601[ 397.616582] cdns-csi2rx 30101000.csi-bridge: Failed to configure external DPHY: -2

/GstPipeline:pipeline0/v4l2h264enc:v4l2h264enc0.GstPad:src: caps = video/x-h264, stream-format=(string)byte-stream, alignment=(string)au, profile=(string)baseline, level=(string)1, width=(int)3840, height=(int)2160, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)120/1, interlace-mode=(string)progressive, colorimetry=(string)bt601
/GstPipeline:pipeline0/GstFileSink:filesink0.GstPad:sink: caps = video/x-h264, stream-format=(string)byte-stream, alignment=(string)au, profile=(string)baseline, level=(string)1, width=(int)3840, height=(int)2160, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)120/1, interlace-mode=(string)progressive, colorimetry=(string)bt601
Redistribute latency...
/GstPipeline:pipeline0/v4l2h264enc:v4l2h264enc0.GstPad:sink: caps = video/x-raw, width=(int)3840, height=(int)2160, framerate=(fraction)120/1, interlace-mode=(string)progressive, format=(string)I420, colorimetry=(string)bt601
/GstPipeline:pipeline0/GstVideoConvert:videoconvert0.GstPad:sink: caps = video/x-raw, width=(int)3840, height=(int)2160, framerate=(fraction)120/1, interlace-mode=(string)progressive, format=(string)YUY2, colorimetry=(string)2:6:5:1
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Failed to allocate required memory.
Additional debug info:
../gst-plugins-good-1.16.3/sys/v4l2/gstv4l2src.c(660): gst_v4l2src_decide_allocation (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
Buffer pool activation failed
Execution ended after 0:00:00.076171695
Setting pipeline to NULL ...
Freeing pipeline ...
root@am62axx-evm:~# gst-launch-1.0 -v v4l2src device=/dev/video0 ! videoconvert ! v4l2h264enc ! filesink location=out.264
Setting pipeline to PAUSED ...
ERROR: Pipeline doesn't want to pause.
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Device '/dev/video0' is not a capture device.
Additional debug info:
../gst-plugins-good-1.16.3/sys/v4l2/v4l2_calls.c(628): gst_v4l2_open (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
Capabilities: 0x4204000
Setting pipeline to NULL ...
Freeing pipeline ...

Regards,

  • Can I check if MIPI input is coming to AM62A AP with /proc interrupt?

  • And I also want to 1) review of gstreamer error 2) AM62A Mipi input check method.  

  • Hi Hong,

    In order to support you better with Gstreamer issue, could you share the output of 

    v4l2-ctl -d /dev/video2 --list-formats-ext 

    Also, could you add a caps filter to specify the width & height  (Smaller resolution) and format  to see if it works

    For eg: 

    gst-launch-1.0 -v v4l2src device=/dev/video2 num-buffers=100 ! 'video/x-raw, format=YUY2, width=1280, height=720, framerate=30/1' ! \

     videoconvert ! v4l2h264enc ! filesink location=out-720.264

    I am checking internally on checking MIPI input with /proc/interrrupts. 

    Hope this helps.

    Best Regards,

    Suren

  • Dear Suren 

    Here is a results of v4l2-ctl output. 

    Here is a results of adding caps filter result.

  • Dear suren.

    Here is some debug log of gstreamer. I changed the width and height value by using our sensor information.

    Can you check to the log information ? 

    root@am62axx-evm:~# gst-launch-1.0 -v v4l2src device=/dev/video2 num-buffers=100 ! 'video/x-raw, format=YUY2, width=2880, height=1080, framerate=30/1' ! videoconvert ! v4l2h264enc ! filesink location=out-720.264
    Setting pipeline to PAUSED ...
    0:00:00.157005210 1004 0x18c67f30 WARN v4l2 gstv4l2object.c:4344:gst_v4l2_object_probe_caps:<v4l2h264enc0:src> Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: Invalid argument
    Pipeline is live and does not need PREROLL ...
    Setting pipeline to PLAYING[ 910.993783] [+][smhong] message [F: to_ar0323, L:171]: caller:(call_get_fmt+0x74/0xd0)
    ...
    New clock: GstSystemClock
    /GstPipeline:pipeline0/GstV4l2S[ 911.005588] [+][smhong] message [F: ar0323_get_fmt, L:262]: caller:(call_get_fmt+0x74/0xd0)
    rc:v4l2src0.GstPad:src: caps = video/x-raw, format=(string)YUY2,[ 911.019465] cdns-csi2rx 30101000.csi-bridge: Failed to configure external DPHY: -2
    width=(int)2880, height=(int)1080, framerate=(fraction)30/1, interlace-mode=(string)progressive, colorimetry=(string)bt709
    /GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps = video/x-raw, format=(string)YUY2, width=(int)2880, height=(int)1080, framerate=(fraction)30/1, interlace-mode=(string)progressive, colorimetry=(string)bt709
    /GstPipeline:pipeline0/GstVideoConvert:videoconvert0.GstPad:src: caps = video/x-raw, width=(int)2880, height=(int)1080, framerate=(fraction)30/1, interlace-mode=(string)progressive, format=(string)I420, colorimetry=(string)bt601
    /GstPipeline:pipeline0/v4l2h264enc:v4l2h264enc0.GstPad:src: caps = video/x-h264, stream-format=(string)byte-stream, alignment=(string)au, profile=(string)baseline, level=(string)1, width=(int)2880, height=(int)1080, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1, interlace-mode=(string)progressive, colorimetry=(string)bt601
    /GstPipeline:pipeline0/GstFileSink:filesink0.GstPad:sink: caps = video/x-h264, stream-format=(string)byte-stream, alignment=(string)au, profile=(string)baseline, level=(string)1, width=(int)2880, height=(int)1080, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1, interlace-mode=(string)progressive, colorimetry=(string)bt601
    Redistribute latency...
    /GstPipeline:pipeline0/v4l2h264enc:v4l2h264enc0.GstPad:sink: caps = video/x-raw, width=(int)2880, height=(int)1080, framerate=(fraction)30/1, interlace-mode=(string)progressive, format=(string)I420, colorimetry=(string)bt601
    /GstPipeline:pipeline0/GstVideoConvert:videoconvert0.GstPad:sink: caps = video/x-raw, format=(string)YUY2, width=(int)2880, height=(int)1080, framerate=(fraction)30/1, interlace-mode=(string)progressive, colorimetry=(string)bt709
    /GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:sink: caps = video/x-raw, format=(string)YUY2, width=(int)2880, height=(int)1080, framerate=(fraction)30/1, interlace-mode=(string)progressive, colorimetry=(string)bt709
    0:00:00.224654640 1004 0x18c718a0 ERROR v4l2bufferpool gstv4l2bufferpool.c:689:gst_v4l2_buffer_pool_streamon:<v4l2src0:pool:src> error with STREAMON 2 (No such file or directory)
    0:00:00.224722800 1004 0x18c718a0 ERROR bufferpool gstbufferpool.c:559:gst_buffer_pool_set_active:<v4l2src0:pool:src> start failed
    0:00:00.224766830 1004 0x18c718a0 WARN v4l2src gstv4l2src.c:660:gst_v4l2src_decide_allocation:<v4l2src0> error: Failed to allocate required memory.
    0:00:00.224791655 1004 0x18c718a0 WARN v4l2src gstv4l2src.c:660:gst_v4l2src_decide_allocation:<v4l2src0> error: Buffer pool activation failed
    0:00:00.224971325 1004 0x18c718a0 WARN basesrc gstbasesrc.c:3292:gst_base_src_prepare_allocation:<v4l2src0> Subclass failed to decide allocation
    0:00:00.225036195 1004 0x18c718a0 WARN basesrc gstbasesrc.c:3072:gst_base_src_loop:<v4l2src0> error: Internal data stream error.
    0:00:00.225061270 1004 0x18c718a0 WARN basesrc gstbasesrc.c:3072:gst_base_src_loop:<v4l2src0> error: streaming stopped, reason not-negotiated (-4)
    ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Failed to allocate required memory.
    Additional debug info:
    ../gst-plugins-good-1.16.3/sys/v4l2/gstv4l2src.c(660): gst_v4l2src_decide_allocation (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
    Buffer pool activation failed
    Execution ended after 0:00:00.065620815
    Setting pipeline to NULL ...

    The log which failed to configure external DPHY seems to mean of our configuration problem of sensor driver.

    I think it seems to have a gstreamer invalid argment. Please check to the log. 

    Regards,

    Sungman Hong
     

  • Here is some kernel error log during the gstreamer working. 

  • Hi Hong

    Can you confirm seeing the camera/sensor data displayed on the screen without encoding? 

    I am suspecting enabling of DPHY is unsuccessful. Can you verify the following steps as mentioned here:

    https://software-dl.ti.com/processor-sdk-linux/esd/AM62AX/08_06_00_45/exports/docs/linux/Foundational_Components/Kernel/Kernel_Drivers/Camera/CSI2RX.html

    Best Regards,

    Suren

  • Dear suren. 

    I tested without gstreamer encoding , but same error happened.

    root@am62axx-evm:~# yavta -c -Fcapture -s 2880x1080 -f UYVY /dev/video2
    Device /dev/video2 opened.
    Device `j721e-csi2rx' on `platform:30102000.ticsi2rx' is a video output (without mplanes) device.
    Video format set: UYVY (59565955) 2880x1080 (stride 5760) field none buffer size 6220800
    Video format: UYVY (59565955) 2880x1080 (stride 5760) field none bu[ 566.944173] [+][smhong] width = 2560
    ffer size 6220800
    8 buffers requested.
    length: 6220800 offset:[ 566.944188] [+][smhong] height = 992
    0 timestamp type/source: mono/EoF
    Buffer 0/0 mapped at address[ 566.950728] cdns-csi2rx 30101000.csi-bridge: Failed to configure external DPHY: -2
    0xffffa7925000.
    length: 6220800 offset: 6221824 timestamp type/source: mono/EoF
    Buffer 1/0 mapped at address 0xffffa7336000.
    length: 6220800 offset: 12443648 timestamp type/source: mono/EoF
    Buffer 2/0 mapped at address 0xffffa6d47000.
    length: 6220800 offset: 18665472 timestamp type/source: mono/EoF
    Buffer 3/0 mapped at address 0xffffa6758000.
    length: 6220800 offset: 24887296 timestamp type/source: mono/EoF
    Buffer 4/0 mapped at address 0xffffa6169000.
    length: 6220800 offset: 31109120 timestamp type/source: mono/EoF
    Buffer 5/0 mapped at address 0xffffa5b7a000.
    length: 6220800 offset: 37330944 timestamp type/source: mono/EoF
    Buffer 6/0 mapped at address 0xffffa558b000.
    length: 6220800 offset: 43552768 timestamp type/source: mono/EoF
    Buffer 7/0 mapped at address 0xffffa4f9c000.
    Unable to start streaming: No such file or directory (2).

    I reviewed the web page of your recommendation but I couldn't exactly know how that apply our sensor driver and SW. 

    Please guide more detail and give more information for debugging.  

    https://software-dl.ti.com/processor-sdk-linux/esd/AM62AX/08_06_00_45/exports/docs/linux/Foundational_Components/Kernel/Kernel_Drivers/Camera/CSI2RX.html

  • And Can you share to the init_script.sh as below? 

    The sensor and other subdevs (for example FPDLink ser/deser) should automatically get configured by the initialization script on the SD card:

    [   15.958706] init_script.sh[859]: CSI Camera 0 detected
    [   15.981126] init_script.sh[859]:     device = /dev/video2
    [   15.981439] init_script.sh[859]:     name = imx219
    [   15.981604] init_script.sh[859]:     format = [fmt:SRGGB8_1X8/1920x1080]
    [   15.981740] init_script.sh[859]:     subdev_id = /dev/v4l-subdev2
    [   15.981862] init_script.sh[859]:     isp_required = yes
  • Hi Hong,

    Can you share output of:

    $ media-ctl -p

    Also is your sensor directly connected to CSI-RX or is there an FPDLink (or similar) SerDes setup in between?

    Please note that whatever entity is connected to CSI-RX has to implement Link Frequency (preferred) or Pixel Rate V4L2 controls, so that CSI-RX can configure DPHY for the correct rates.

    This is the place in code where it asks for link frequency from V4L2 framework, and I would guess it is leading to EINVAL because it cannot find it:
    https://git.ti.com/cgit/ti-linux-kernel/ti-linux-kernel/tree/drivers/media/platform/cadence/cdns-csi2rx.c?h=ti-linux-5.10.y#n223

    You can check other supported sensor drivers like IMX219 and OV5640 for how link frequency control is implemented.

    Thanks

  • Dear suren, 

    Here is a output of media-ctl -p. 

    root@am62axx-evm:~# media-ctl -p
    Media controller API version 5.10.120

    Media device informatio[ 52.237029] [+][smhong] width = 2560
    n
    ------------------------
    driver j721e-csi2rx
    model TI-CSI2RX
    serial
    bus info platform:30102000.ticsi2rx
    hw revision 0x1
    driver version 5.10.120

    Device topology
    - entity 1: 30102000.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
    <- "cdns_csi2rx.30101000.csi-bridge":1 [ENABLED,IMMUTABLE]
    pad1: Source
    -> "30102000.ticsi2rx context 0":0 [ENABLED,IMMUTABLE]
    pad2: Source
    -> "30102000.ticsi2rx context 1":0 [ENABLED,IMMUTABLE]
    pad3: Source
    -> "30102000.ticsi2rx context 2":0 [ENABLED,IMMUTABLE]
    pad4: Source
    -> "30102000.ticsi2rx context 3":0 [ENABLED,IMMUTABLE]

    - entity 7: cdns_csi2rx.30101000.csi-bridge (5 pads, 2 links, 0 route)
    type V4L2 subdev subtype Unknown flags 0
    device node name /dev/v4l-subdev1
    pad0: Sink
    <- "ar0323 2-0010":0 [ENABLED,IMMUTABLE]
    pad1: Source
    -> "30102000.ticsi2rx":0 [ENABLED,IMMUTABLE]
    pad2: Source
    pad3: Source
    pad4: Source

    - entity 13: ar0323 2-0010 (1 pad, 1 link, 0 route)
    type V4L2 subdev subtype Unknown flags 20001
    device node name /dev/v4l-subdev2
    pad0: Source
    [stream:0 fmt:SGRBG12_1X12/2560x992 field:none colorspace:smpte170m
    crop.bounds:(0,0)/2560x992
    crop:(0,0)/2560x992]
    -> "cdns_csi2rx.30101000.csi-bridge":0 [ENABLED,IMMUTABLE]

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

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

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

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

  • Also is your sensor directly connected to CSI-RX or is there an FPDLink (or similar) SerDes setup in between?

    --> our sensor directly connected to CSI-RX (there is no FPDLink and SeDes connection in our HW Board)

    I will check to the link frequency and inform to you. 

    Regards,

  • Dear suren. 

     Do I need to set the overlay as below in the device tree file?

  • He Hong,

    And Can you share to the init_script.sh as below? 

    This script is: /opt/edgeai-gst-apps/scripts/setup_cameras.sh.

    - entity 7: cdns_csi2rx.30101000.csi-bridge (5 pads, 2 links, 0 route)
    type V4L2 subdev subtype Unknown flags 0
    device node name /dev/v4l-subdev1
    pad0: Sink
    <- "ar0323 2-0010":0 [ENABLED,IMMUTABLE]
    pad1: Source
    -> "30102000.ticsi2rx":0 [ENABLED,IMMUTABLE]

    This indicates the Cadence CSI2RX bridge is not configured. Can you try the following or similar?

    media-ctl --set-v4l2 '"ar0323 2-0010":0[fmt:SGRBG12_1X12/2560x992]'

    This should configure both the sensor and the Cadence bridge, as mentioned here.

    Please share the log of "media-ctl -p" after running this command.

    Regards,

    Jianzhong

  • Dear Jianzhong , 

    Here is a results of media-ctl cmd. 

    root@am62axx-evm:~# media-ctl --set-v4l2 '"ar0323 2-0010":0[fmt:SGRBG12_1X12/2560x992]'
    root@am62axx-evm:~# media-ctl -p
    Media controller API version 5.10.120

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

    Device topology
    - entity 1: 30102000.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
    <- "cdns_csi2rx.30101000.csi-bridge":1 [ENABLED,IMMUTABLE]
    pad1: Source
    -> "30102000.ticsi2rx context 0":0 [ENABLED,IMMUTABLE]
    pad2: Source
    -> "30102000.ticsi2rx context 1":0 [ENABLED,IMMUTABLE]
    pad3: Source
    -> "30102000.ticsi2rx context 2":0 [ENABLED,IMMUTABLE]
    pad4: Source
    -> "30102000.ticsi2rx context 3":0 [ENABLED,IMMUTABLE]

    - entity 7: cdns_csi2rx.30101000.csi-bridge (5 pads, 2 links, 0 route)
    type V4L2 subdev subtype Unknown flags 0
    device node name /dev/v4l-subdev1
    pad0: Sink
    <- "ar0323 2-0010":0 [ENABLED,IMMUTABLE]
    pad1: Source
    -> "30102000.ticsi2rx":0 [ENABLED,IMMUTABLE]
    pad2: Source
    pad3: Source
    pad4: Source

    - entity 13: ar0323 2-0010 (1 pad, 1 link, 0 route)
    type V4L2 subdev subtype Unknown flags 20001
    device node name /dev/v4l-subdev2
    pad0: Source
    [stream:0 fmt:SGRBG12_1X12/2560x992 field:none colorspace:smpte170m
    crop.bounds:(0,0)/2560x992
    crop:(0,0)/2560x992]
    -> "cdns_csi2rx.30101000.csi-bridge":0 [ENABLED,IMMUTABLE]

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

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

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

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

    Regards

  • Hi Hong,

    Looks like the command didn't change the format for the Cadence CSI2-RX bridge.

    Have you tried any sensor supported by the SDK 8.6 on your custom board, such as the IMX219?

    Regards,

    Jianzhong

  • No. We are currently testing only the usb camera and ar0323 sensor. The ar0323 driver ported the driver code that worked normally on other soc platforms, but it seems that some codes do not work well because they do not match the ti am62a sdk.

  • Ok. Thanks for the information.

    Can you check the AM62A Academy on adding a new sensor to the SDK (scroll to Enable A New CSI-2 Sensor) and see if anything is missed?

    Please implement the Link Frequency V4l2 control as Jai recommended earlier (quoted below) and keep us updated.

    Please note that whatever entity is connected to CSI-RX has to implement Link Frequency (preferred) or Pixel Rate V4L2 controls, so that CSI-RX can configure DPHY for the correct rates.

    This is the place in code where it asks for link frequency from V4L2 framework, and I would guess it is leading to EINVAL because it cannot find it:
    https://git.ti.com/cgit/ti-linux-kernel/ti-linux-kernel/tree/drivers/media/platform/cadence/cdns-csi2rx.c?h=ti-linux-5.10.y#n223

    You can check other supported sensor drivers like IMX219 and OV5640 for how link frequency control is implemented.

    Regards,

    Jianzhong

  • Dear Jianzhong

    I wonder if the MEDIA_CONTROLLER , V4L2_FWNODE, and VIDEO_V4L2_SUBDEV_API settings in the Kconfig file are necessary.
    Only VIDEO_V4L2 && I2C setting in Driver code of other soc platform It is set, so please inquire.

    config VIDEO_OV9281
            tristate "OmniVision OV9281 sensor support"
            depends on GPIOLIB && VIDEO_V4L2 && I2C
            select MEDIA_CONTROLLER
            select VIDEO_V4L2_SUBDEV_API
            select V4L2_FWNODE
            help
              This is a Video4Linux2 sensor driver for the OmniVision
              OV9281 camera sensor.
  • Dear Jianzhong

    If MEDIA_CONTROLLER, V4L2_FWNODE, and VIDEO_V4L2_SUBDEV_API are set in the Kconfig file, the current ar0323 driver probes, but only video1 and video2 are caught as video devices, and they are not properly detected as video devices. I'm checking it because I think I need to add the V4L2 Code used for the imx219 you mentioned while setting up the config above.

  • Hi Hong,

    I would recommend you to follow the steps in AM62A academy to add the driver and implement what Jai recommended. 

    If you don't mind, you can share all your changes (except the sensor driver if that can't be disclosed) after you're finished. We can take a look and provide further comments.

    Regards,

    Jianzhong

  • Dear Jianzhong,

    Here is a example code of sensor probe function. 

    probe function working is finished but If MEDIA_CONTROLLER, V4L2_FWNODE, and VIDEO_V4L2_SUBDEV_API option set,

    but only video1 and video2 are caught as video devices, and they are not properly detected as video devices.

    Please check to the probe function as below. 

    static int ar0323_probe(struct i2c_client *client,
    const struct i2c_device_id *did)
    {
    struct device *dev = &client->dev;
    struct ar0323_priv *priv;
    int ret;
    int tmp_addr;

    priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
    if (!priv)
    return -ENOMEM;

    v4l2_i2c_subdev_init(&priv->sd, client, &ar0323_subdev_ops);

    /* Check the hardware configuration in device tree */
    #if defined(DT_CHECK)
    if (ar0323_check_hwcfg(dev))
    return -EINVAL;
    #endif

    /* Get system clock (xclk) */
    priv->xclk = devm_clk_get(dev, NULL);
    if (IS_ERR(priv->xclk)) {
    dev_err(dev, "failed to get xclk\n");
    return PTR_ERR(priv->xclk);
    }

    priv->xclk_freq = clk_get_rate(priv->xclk);
    if (priv->xclk_freq != AR0323_XCLK_FREQ) {
    printk("xclk frequency not supported: %d Hz\n",priv->xclk_freq);
    return -EINVAL;
    }

    #if 0
    /* By default, PIXEL_RATE is read only */
    priv->pixel_rate = v4l2_ctrl_new_std(&priv->hdl, &ar0323_ctrl_ops,
    V4L2_CID_PIXEL_RATE,
    IMX219_PIXEL_RATE,
    IMX219_PIXEL_RATE, 1,
    IMX219_PIXEL_RATE);

    printk("priv pixel rate frequency : %d Hz\n",priv->pixel_rate);
    #endif

    priv->sd.flags = V4L2_SUBDEV_FL_HAS_DEVNODE;

    v4l2_ctrl_handler_init(&priv->hdl, 4);
    v4l2_ctrl_new_std(&priv->hdl, &ar0323_ctrl_ops,
    V4L2_CID_BRIGHTNESS, 0, 16, 1, 7);
    v4l2_ctrl_new_std(&priv->hdl, &ar0323_ctrl_ops,
    V4L2_CID_CONTRAST, 0, 16, 1, 7);
    v4l2_ctrl_new_std(&priv->hdl, &ar0323_ctrl_ops,
    V4L2_CID_SATURATION, 0, 7, 1, 2);
    v4l2_ctrl_new_std(&priv->hdl, &ar0323_ctrl_ops,
    V4L2_CID_HUE, 0, 23, 1, 12);
    v4l2_ctrl_new_std(&priv->hdl, &ar0323_ctrl_ops,
    V4L2_CID_GAMMA, -128, 128, 1, 0);
    v4l2_ctrl_new_std(&priv->hdl, &ar0323_ctrl_ops,
    V4L2_CID_SHARPNESS, 0, 10, 1, 3);
    v4l2_ctrl_new_std(&priv->hdl, &ar0323_ctrl_ops,
    V4L2_CID_AUTOGAIN, 0, 1, 1, 0);
    v4l2_ctrl_new_std(&priv->hdl, &ar0323_ctrl_ops,
    V4L2_CID_GAIN, 1, 0x7ff, 1, 0x200);
    v4l2_ctrl_new_std(&priv->hdl, &ar0323_ctrl_ops,
    V4L2_CID_ANALOGUE_GAIN, 1, 0xe, 1, 0xa);
    v4l2_ctrl_new_std(&priv->hdl, &ar0323_ctrl_ops,
    V4L2_CID_EXPOSURE, 1, 0x600, 1, 0x144);
    v4l2_ctrl_new_std(&priv->hdl, &ar0323_ctrl_ops,
    V4L2_CID_HFLIP, 0, 1, 1, 0);
    v4l2_ctrl_new_std(&priv->hdl, &ar0323_ctrl_ops,
    V4L2_CID_VFLIP, 0, 1, 1, 0);
    priv->sd.ctrl_handler = &priv->hdl;

    ret = priv->hdl.error;
    if (ret)
    goto cleanup;


    v4l2_ctrl_handler_setup(&priv->hdl);


    priv->pad.flags = MEDIA_PAD_FL_SOURCE;
    priv->sd.entity.flags |= MEDIA_ENT_F_CAM_SENSOR;
    ret = media_entity_pads_init(&priv->sd.entity, 1, &priv->pad);
    if (ret < 0)
    goto cleanup;


    ret = ar0323_initialize(client);
    if (ret < 0)
    goto cleanup;


    priv->rect.left = 0;
    priv->rect.top = 0;
    priv->rect.width = AR0323_MAX_WIDTH;
    priv->rect.height = AR0323_MAX_HEIGHT;

    ret = v4l2_async_register_subdev(&priv->sd);
    if (ret)
    goto cleanup;

    if (device_create_file(&client->dev, &dev_attr_otp_id_ar0323) != 0) {
    dev_err(&client->dev, "sysfs otp_id entry creation failed\n");
    goto cleanup;
    }

    priv->init_complete = 1;


    return 0;

    cleanup:
    media_entity_cleanup(&priv->sd.entity);
    v4l2_ctrl_handler_free(&priv->hdl);
    v4l2_device_unregister_subdev(&priv->sd);
    //#ifdef CONFIG_SOC_CAMERA_AR0323
    v4l_err(client, "failed to probe @ 0x%02x (%s)\n",
    client->addr, client->adapter->name);
    //#endif
    return ret;
    }