DEMO: CAMERA: adapt to several dcmipp camera topology
Auto-detection of media device to use for camera handling. Auto-detection of bridge and interface subdevices to configure by checking media device topology. Change the way subdev are configured for better handling of various topologies. Ensure that GStreamer pixel format used in output of v4l2src (RGB16 here) fit exactly the media bus format used on subdevices side (RGB565_2X8_LE here). Nevertheless, in case of USB camera, keep GStreamer pixel format auto-negotiated between v4l2src and waylandsink. Signed-off-by: Hugues Fruchet <hugues.fruchet@foss.st.com> Change-Id: I49c4200d8edb3b4556f5dd348ce78651926d0cc5
This commit is contained in:
committed by
bernard PUEL
parent
151061fb64
commit
3d51badd5c
@ -22,12 +22,26 @@ is_dcmipp_present() {
|
||||
for video in $(find /sys/class/video4linux -name "video*" -type l);
|
||||
do
|
||||
if [ "$(cat $video/name)" = "dcmipp_dump_capture" ]; then
|
||||
cd $video/device/
|
||||
mediadev=/dev/$(ls -d media*)
|
||||
cd -
|
||||
for sub in $(find /sys/class/video4linux -name "v4l-subdev*" -type l);
|
||||
do
|
||||
subdev_name=$(tr -d '\0' < $sub/name | awk '{print $1}')
|
||||
if [ "$subdev_name" = "gc2145" ] || [ "$subdev_name" = "ov5640" ]; then
|
||||
DCMIPP_SENSOR=$subdev_name
|
||||
V4L_DEVICE="device=/dev/$(basename $video)"
|
||||
sensorsubdev=$(tr -d '\0' < $sub/name)
|
||||
#bridge is connected to output of sensor (":0 [ENABLED" with media-ctl -p)
|
||||
bridgesubdev=$(media-ctl -d $mediadev -p -e "$sensorsubdev" | grep ":0 \[ENABLED" | awk -F\" '{print $2}')
|
||||
#interface is connected to input of postproc (":1 [ENABLED" with media-ctl -p)
|
||||
interfacesubdev=$(media-ctl -d $mediadev -p -e "dcmipp_dump_postproc" | grep ":1 \[ENABLED" | awk -F\" '{print $2}')
|
||||
echo "media device: "$mediadev
|
||||
echo "video device: "$V4L_DEVICE
|
||||
echo "sensor subdev: " $sensorsubdev
|
||||
echo "bridge subdev: " $bridgesubdev
|
||||
echo "interface subdev: " $interfacesubdev
|
||||
|
||||
return
|
||||
fi
|
||||
done
|
||||
@ -75,15 +89,16 @@ if [ "$DCMIPP_SENSOR" != "NOTFOUND" ]; then
|
||||
elif [ "$DCMIPP_SENSOR" = "ov5640" ]; then
|
||||
sensorbuscode="RGB565_2X8_LE"
|
||||
fi
|
||||
media-ctl -d /dev/media0 --set-v4l2 "'$DCMIPP_SENSOR 1-003c':0[fmt:$sensorbuscode/${WIDTH}x${HEIGHT}@1/${FPS} field:none]"
|
||||
media-ctl -d /dev/media0 --set-v4l2 "'dcmipp_parallel':0[fmt:$sensorbuscode/${WIDTH}x${HEIGHT}]"
|
||||
media-ctl -d /dev/media0 --set-v4l2 "'dcmipp_parallel':1[fmt:RGB565_2X8_LE/${WIDTH}x${HEIGHT}]"
|
||||
media-ctl -d /dev/media0 --set-v4l2 "'dcmipp_dump_postproc':1[fmt:RGB565_2X8_LE/${WIDTH}x${HEIGHT}]" -v
|
||||
media-ctl -d /dev/media0 --set-v4l2 "'dcmipp_dump_postproc':1[crop:(0,0)/${WIDTH}x${HEIGHT}]" -v
|
||||
media-ctl -d $mediadev --set-v4l2 "'$sensorsubdev':0[fmt:$sensorbuscode/${WIDTH}x${HEIGHT}@1/${FPS} field:none]"
|
||||
media-ctl -d $mediadev --set-v4l2 "'$bridgesubdev':2[fmt:$sensorbuscode/${WIDTH}x${HEIGHT}]"
|
||||
media-ctl -d $mediadev --set-v4l2 "'$interfacesubdev':1[fmt:RGB565_2X8_LE/${WIDTH}x${HEIGHT}]"
|
||||
media-ctl -d $mediadev --set-v4l2 "'dcmipp_dump_postproc':1[fmt:RGB565_2X8_LE/${WIDTH}x${HEIGHT}]"
|
||||
V4L2_CAPS="video/x-raw, format=RGB16, width=$WIDTH, height=$HEIGHT"
|
||||
V4L_OPT=""
|
||||
else
|
||||
get_webcam_device
|
||||
# suppose we have a webcam
|
||||
V4L2_CAPS="video/x-raw, width=$WIDTH, height=$HEIGHT"
|
||||
V4L_OPT="io-mode=4"
|
||||
v4l2-ctl --set-parm=20
|
||||
fi
|
||||
@ -93,7 +108,7 @@ SCREEN_WIDTH=$(weston-info | grep logical_width | sed -r "s/logical_width: ([0-9
|
||||
SCREEN_HEIGHT=$(weston-info | grep logical_width | sed -r "s/.*logical_height: ([0-9]+).*/\1/")
|
||||
|
||||
echo "Gstreamer graph:"
|
||||
GRAPH="v4l2src $V4L_DEVICE $V4L_OPT ! video/x-raw,width=$WIDTH,height=$HEIGHT ! queue ! $ADDONS waylandsink fullscreen=true"
|
||||
GRAPH="v4l2src $V4L_DEVICE $V4L_OPT ! $V4L2_CAPS ! queue ! $ADDONS waylandsink fullscreen=true"
|
||||
|
||||
echo " $GRAPH"
|
||||
pty_exec "$GRAPH"
|
||||
|
||||
Reference in New Issue
Block a user