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.

AM625: Media-ctl configuration for Multiple-Camera Application

Part Number: AM625


Tool/software:

Hello all,

I developed a MAX96716/ MAX96717 driver by referencing ds90ub960/ds90ub953. The drivers all works as expected and passes their probes, and writes their registers. I created a media-ctl setup script by referencing `setup_cameras.sh` script, please see below:

```

#!/bin/bash

setup_ov2311(){
OV2311_CAM_FMT='[fmt:Y8_1X8/1280x800]'

i=0
for media_id in {0..0}; do
# MAX96717 FORMATS
MAX96716_FMT_STR="["
CSI2RX_FMT_STR="["
for name in `media-ctl -d $media_id -p | grep entity | grep ov2311_mipi | cut -d ' ' -f 5`; do

CAM_SUBDEV=`media-ctl -d $media_id -p -e "ov2311_mipi $name" | grep v4l-subdev | awk '{print $4}'`

MAX96717_NAME=`media-ctl -d $media_id -p -e "ov2311_mipi $name" | grep max96717 | cut -d "\"" -f 2`
media-ctl -d $media_id -V "'$MAX96717_NAME':0 $OV2311_CAM_FMT"

MAX96716_NAME=`media-ctl -d $media_id -p -e "$MAX96717_NAME" | grep max96716 | cut -d "\"" -f 2`
MAX96716_PAD=`media-ctl -d $media_id -p -e "$MAX96717_NAME" | grep max96716 | cut -d : -f 2 | awk '{print $1}'`

CSI_BRIDGE_NAME=`media-ctl -d $media_id -p -e "$MAX96716_NAME" | grep csi-bridge | cut -d "\"" -f 2`

CSI2RX_NAME=`media-ctl -d $media_id -p -e "$CSI_BRIDGE_NAME" | grep "ticsi2rx\"" | cut -d "\"" -f 2`

CSI2RX_CONTEXT_NAME="$CSI2RX_NAME context $MAX96716_PAD"

if [ "$MAX96716_FMT_STR" != "[" ]; then
MAX96716_FMT_STR="${MAX96716_FMT_STR}, "
CSI2RX_FMT_STR="${CSI2RX_FMT_STR}, "
fi
MAX96716_FMT_STR="${MAX96716_FMT_STR}${MAX96716_PAD}/0 -> $(($MAX96716_PAD + 2))/0 [1]"
CSI2RX_FMT_STR="${CSI2RX_FMT_STR}0/${MAX96716_PAD} -> $(($MAX96716_PAD+1))/0 [1]"

echo "OV2311 Camera $i detected"
echo " device = "`media-ctl -d $media_id -p -e "$CSI2RX_CONTEXT_NAME" | grep video | awk '{print $4}'`
echo " name = ov2311"
echo " format = $OV2311_CAM_FMT"
echo " subdev_id = $CAM_SUBDEV"
echo " isp_required = yes"
echo " ldc_required = no"

((i++))
done

MAX96716_FMT_STR="${MAX96716_FMT_STR}]"
CSI2RX_FMT_STR="${CSI2RX_FMT_STR}]"

media-ctl -d $media_id -p | grep entity | grep ov2311_mipi -q
if [ "$?" == "0" ]; then
# MAX96716 ROUTING & FORMATS
echo $MAX96716_NAME $MAX96716_FMT_STR
media-ctl -d $media_id -R "'$MAX96716_NAME' $MAX96716_FMT_STR"
for name in `media-ctl -d $media_id -p | grep entity | grep ov2311_mipi | cut -d ' ' -f 5`; do
MAX96717_NAME=`media-ctl -d $media_id -p -e "ov2311_mipi $name" | grep max96717 | cut -d "\"" -f 2`
MAX96716_NAME=`media-ctl -d $media_id -p -e "$MAX96717_NAME" | grep max96716 | cut -d "\"" -f 2`
MAX96716_PAD=`media-ctl -d $media_id -p -e "$MAX96717_NAME" | grep max96716 | cut -d : -f 2 | awk '{print $1}'`
media-ctl -d $media_id -V "'$MAX96716_NAME':$MAX96716_PAD $OV2311_CAM_FMT"
done

# CSI2RX ROUTING
media-ctl -d $media_id -R "'$CSI2RX_NAME' $CSI2RX_FMT_STR"
fi
done
}

#setup_isx021
setup_ov2311

```

And here is the media-ctl -p output:

```

root@myd-am62x:~# media-ctl -p
Media controller API version 6.1.46

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

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
[stream:0 fmt:UYVY8_1X16/640x480 field:none colorspace:srgb xfer:srgb ycbcr:601 quantization:lim-range]
<- "cdns_csi2rx.30101000.csi-bridge":1 [ENABLED,IMMUTABLE]
pad1: Source
[stream:0 fmt:UYVY8_1X16/640x480 field:none colorspace:srgb xfer:srgb ycbcr:601 quantization:lim-range]
-> "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, 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:UYVY8_1X16/640x480 field:none colorspace:srgb xfer:srgb ycbcr:601 quantization:lim-range]
<- "max96716 1-004c":2 [ENABLED,IMMUTABLE]
pad1: Source
[stream:0 fmt:UYVY8_1X16/640x480 field:none colorspace:srgb xfer:srgb ycbcr:601 quantization:lim-range]
-> "30102000.ticsi2rx":0 [ENABLED,IMMUTABLE]
pad2: Source
pad3: Source
pad4: Source

- entity 13: max96716 1-004c (4 pads, 2 links, 1 route)
type V4L2 subdev subtype Unknown flags 0
device node name /dev/v4l-subdev2
routes:
0/0 -> 2/0 [ACTIVE]
pad0: Sink
[stream:0 fmt:Y8_1X8/1280x800]
<- "max96717 1-0040":1 [ENABLED,IMMUTABLE]
pad1: Sink
pad2: Source
[stream:0 fmt:Y8_1X8/1280x800]
-> "cdns_csi2rx.30101000.csi-bridge":0 [ENABLED,IMMUTABLE]
pad3: Source

- entity 20: max96717 1-0040 (2 pads, 2 links, 1 route)
type V4L2 subdev subtype Unknown flags 0
device node name /dev/v4l-subdev3
routes:
0/0 -> 1/0 [ACTIVE]
pad0: Sink
[stream:0 fmt:Y8_1X8/1280x800]
<- "ov2311_mipi 1-0010":0 [ENABLED,IMMUTABLE]
pad1: Source
[stream:0 fmt:Y8_1X8/1280x800]
-> "max96716 1-004c":0 [ENABLED,IMMUTABLE]

- entity 25: ov2311_mipi 1-0010 (1 pad, 1 link, 0 route)
type V4L2 subdev subtype Sensor flags 0
device node name /dev/v4l-subdev4
pad0: Source
[stream:0 fmt:Y8_1X8/1280x800 field:none colorspace:srgb]
-> "max96717 1-0040":0 [ENABLED,IMMUTABLE]

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

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

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

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

```

When I try to get a stream, using the below code I get an error:

root@myd-am62x:~# v4l2-ctl --device /dev/video0 --set-fmt-video=width=1280,height=800,pixelformat=BA81 --stream-mmap --stream-to=frame.raw --stream-count=1
VIDIOC_STREAMON returned -1 (Broken pipe)

Did I do something wrong with my media-ctl script ? Or this issue is more like driver related ? 

Thanks.

  • Hi, 

    The domain expert is currently out of office. Please expect some delay in response time.

    Thanks,
    Shreyansh

  • Hi Kya,

    Two entities in your "media-ctl -p" output show different formats: 30102000.ticsi2rx and cdns_csi2rx.30101000.csi-bridge. That's the reason why you got "Broken pipe" error.

    You'll need to configure these entities to have the same format: Y8_1X8/1280x800.

    Regards,

    Jianzhong

  • Hi ,

    I did notice that and add the following commands:

        media-ctl -d 0 -R '"cdns_csi2rx.30101000.csi-bridge" [0/0 -> 1/0 [1]]'
        media-ctl -d 0 -V '"cdns_csi2rx.30101000.csi-bridge":0/0 [fmt:Y8_1X8/1280x800 field:none colorspace:srgb]'
        media-ctl -d 0 -R '"30102000.ticsi2rx" [0/0 -> 1/0 [1]]'
        media-ctl -d 0 -V '"30102000.ticsi2rx":0/0 [fmt:Y8_1X8/1280x800 field:none colorspace:srgb]'
    

    And here is the media-ctl -p output:

    root@myd-am62x:~# media-ctl -p
    Media controller API version 6.1.46
    
    Media device information
    ------------------------
    driver          j721e-csi2rx
    model           TI-CSI2RX
    serial          
    bus info        platform:30102000.ticsi2rx
    hw revision     0x1
    driver version  6.1.46
    
    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
    		[stream:0 fmt:Y8_1X8/1280x800 field:none colorspace:srgb]
    		<- "cdns_csi2rx.30101000.csi-bridge":1 [ENABLED,IMMUTABLE]
    	pad1: Source
    		[stream:0 fmt:Y8_1X8/1280x800 field:none colorspace:srgb]
    		-> "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, 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:Y8_1X8/1280x800 field:none colorspace:srgb]
    		<- "max96716 1-004c":2 [ENABLED,IMMUTABLE]
    	pad1: Source
    		[stream:0 fmt:Y8_1X8/1280x800 field:none colorspace:srgb]
    		-> "30102000.ticsi2rx":0 [ENABLED,IMMUTABLE]
    	pad2: Source
    	pad3: Source
    	pad4: Source
    
    - entity 13: max96716 1-004c (4 pads, 2 links, 1 route)
                 type V4L2 subdev subtype Unknown flags 0
                 device node name /dev/v4l-subdev2
    	routes:
    		0/0 -> 2/0 [ACTIVE]
    	pad0: Sink
    		[stream:0 fmt:Y8_1X8/1280x800 field:none]
    		<- "max96717 1-0040":1 [ENABLED,IMMUTABLE]
    	pad1: Sink
    	pad2: Source
    		[stream:0 fmt:Y8_1X8/1280x800 field:none]
    		-> "cdns_csi2rx.30101000.csi-bridge":0 [ENABLED,IMMUTABLE]
    	pad3: Source
    
    - entity 20: max96717 1-0040 (2 pads, 2 links, 1 route)
                 type V4L2 subdev subtype Unknown flags 0
                 device node name /dev/v4l-subdev3
    	routes:
    		0/0 -> 1/0 [ACTIVE]
    	pad0: Sink
    		[stream:0 fmt:Y8_1X8/1280x800 field:none]
    		<- "ov2311_mipi 1-0010":0 [ENABLED,IMMUTABLE]
    	pad1: Source
    		[stream:0 fmt:Y8_1X8/1280x800 field:none]
    		-> "max96716 1-004c":0 [ENABLED,IMMUTABLE]
    
    - entity 25: ov2311_mipi 1-0010 (1 pad, 1 link, 0 route)
                 type V4L2 subdev subtype Sensor flags 0
                 device node name /dev/v4l-subdev4
    	pad0: Source
    		[stream:0 fmt:Y8_1X8/1280x800 field:none colorspace:srgb]
    		-> "max96717 1-0040":0 [ENABLED,IMMUTABLE]
    
    - entity 31: 30102000.ticsi2rx context 0 (1 pad, 1 link, 0 route)
                 type Node subtype V4L flags 0
                 device node name /dev/video0
    	pad0: Sink
    		<- "30102000.ticsi2rx":1 [ENABLED,IMMUTABLE]
    
    - entity 37: 30102000.ticsi2rx context 1 (1 pad, 1 link, 0 route)
                 type Node subtype V4L flags 0
                 device node name /dev/video1
    	pad0: Sink
    		<- "30102000.ticsi2rx":2 [ENABLED,IMMUTABLE]
    
    - entity 43: 30102000.ticsi2rx context 2 (1 pad, 1 link, 0 route)
                 type Node subtype V4L flags 0
                 device node name /dev/video2
    	pad0: Sink
    		<- "30102000.ticsi2rx":3 [ENABLED,IMMUTABLE]
    
    - entity 49: 30102000.ticsi2rx context 3 (1 pad, 1 link, 0 route)
                 type Node subtype V4L flags 0
                 device node name /dev/video3
    	pad0: Sink
    		<- "30102000.ticsi2rx":4 [ENABLED,IMMUTABLE]
    

    However, when I try to get a stream from my camera I get the following error:

    root@myd-am62x:~# v4l2-ctl --device /dev/video0 --set-fmt-video=width=1280,height=800,pixelformat=GREY --stream-mmap --stream-to=frame.raw --stream-count=1
    		VIDIOC_STREAMON returned -1 (Invalid argument)
    

    In dmesg I get this error:

    [69775.626762] max96716 1-004c: Mapping sink 0/0 to output VC 0
    [69775.632694] cdns-csi2rx 30101000.csi-bridge: Failed to configure external DPHY: -22

    Any ideas about why this happens ?

    Thanks.

  • Which SDK version are you using?

    Can you share the log of "uname -a"?

  • ,

    root@myd-am62x:~# uname -r
    6.1.46-g422823f39974-dirty

  • Hi ,

    I had a typo on my device-tree so my link-frequency wasnt passing to my deserializer max96716. Now it fixed but I had another issue:

    [ 37.510811] ov2311_mipi 1-0010: Active format not set, using default
    [ 37.517190] max96716 1-004c: max96716_get_vc_maps: VC map for port 0 is 0x00
    [ 37.524260] ov2311_mipi 1-0010: Active format not set, using default
    [ 37.530673] max96716 1-004c: Mapping sink 0/0 to output VC 0
    [ 37.537126] max96716 1-004c: Prepare for streaming
    [ 37.542075] ov2311_mipi 1-0010: Active format not set, using default
    [ 37.548469] max96716 1-004c: max96716_get_vc_maps: VC map for port 0 is 0x00
    [ 37.555556] cdns-csi2rx 30101000.csi-bridge: Failed to start streams 0x1 on subdev

    Now I think it trys to start stream for wrong subdev somehow ? How can I solve this ?

    Thanks.

  • Hello,

    root@myd-am62x:~# uname -r
    6.1.46-g422823f39974-dirty

    The 6.1.46 kernel (in SDK 9.1) doesn't support Y8_1X8 format in the CSI Rx driver: https://git.ti.com/cgit/ti-linux-kernel/ti-linux-kernel/tree/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c?h=ti-linux-6.1.y#n138

    Please upgrade to SDK 10.1 which supports Y8_1X8: https://git.ti.com/cgit/ti-linux-kernel/ti-linux-kernel/tree/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c?h=ti-linux-6.6.y#n188.

    Regards,

    Jianzhong