summaryrefslogtreecommitdiff
path: root/src/py/cam
diff options
context:
space:
mode:
Diffstat (limited to 'src/py/cam')
0 files changed, 0 insertions, 0 deletions
117'>117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2018, Google Inc.
#
# Author: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
#
# ipu3-capture.sh - Capture raw frames from cameras based on the Intel IPU3
#
# The scripts makes use of the following tools, which are expected to be
# executable from the system-wide path or from the local directory:
#
# - media-ctl (from v4l-utils git://linuxtv.org/v4l-utils.git)
# - raw2pnm (from nvt https://github.com/intel/nvt.git)
# - yavta (from git://git.ideasonboard.org/yavta.git)

# Locate the sensor entity
find_sensor() {
	local bus
	local sensor_name=$1

	bus=$(grep "$sensor_name" /sys/class/video4linux/v4l-subdev*/name | cut -d ' ' -f 2)
	if [[ -z $bus ]]; then
		echo "Sensor '$sensor_name' not found." >&2
		exit 1
	fi

	echo "$sensor_name $bus"
}

# Locate the media device
find_media_device() {
	local mdev

	for mdev in /dev/media* ; do
		media-ctl -d $mdev -p | grep -q "^driver[ \t]*ipu3-cio2$" && break
		mdev=
	done

	if [[ -z $mdev ]] ; then
		echo "IPU3 media device not found." >&2
		exit 1
	fi

	echo $mdev
}

# Locate the CSI2 and CIO2 and get the sensor format
parse_pipeline() {
	local cio2_queue
	local resolution
	local sensor=$1

	read cio2_queue bus_format sensor_size <<< $($mediactl -p | awk "
	/^- entity [0-9]*:/ {
		sensor=0;
	}

	/^- entity [0-9]*: $sensor/ {
		sensor=1;
	}

	/^[ \t]*(stream:0)?\[fmt:/ {
		if (sensor) {
			gsub(\".*fmt:\", \"\");
			gsub(\"[] ].*\", \"\");
			sub(\"/\", \" \");
			sub(\"@[0-9]+/[0-9]+\", \"\");
			format=\$0;
		}
	}

	/^[ \t]*->/ {