[libcamera-devel] utils: ipu3: Use variables for 'yavta' and 'media-ctl'

Message ID 20190111130857.17946-1-jacopo@jmondi.org
State Rejected
Headers show
Series
  • [libcamera-devel] utils: ipu3: Use variables for 'yavta' and 'media-ctl'
Related show

Commit Message

Jacopo Mondi Jan. 11, 2019, 1:08 p.m. UTC
Use variables defined at the beginning of ipu3 helper scripts to call
yavta and media-ctl. This makes easier override them if a locally
compiled version should be used in place of the system-wide installed
ones.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 utils/ipu3/ipu3-capture.sh | 9 ++++++---
 utils/ipu3/ipu3-process.sh | 8 +++++---
 2 files changed, 11 insertions(+), 6 deletions(-)

--
2.20.1

Comments

Laurent Pinchart Jan. 11, 2019, 1:46 p.m. UTC | #1
Hi Jacopo,

Thank you for the patch.

On Friday, 11 January 2019 15:08:57 EET Jacopo Mondi wrote:
> Use variables defined at the beginning of ipu3 helper scripts to call
> yavta and media-ctl. This makes easier override them if a locally
> compiled version should be used in place of the system-wide installed
> ones.

I had this in the first version of the scripts, but then decided it was 
cleaner to select the yavta and media-ctl binaries through PATH instead of 
hacking the script. Would that work for you ?

> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
> ---
>  utils/ipu3/ipu3-capture.sh | 9 ++++++---
>  utils/ipu3/ipu3-process.sh | 8 +++++---
>  2 files changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/utils/ipu3/ipu3-capture.sh b/utils/ipu3/ipu3-capture.sh
> index ba6147b..9d83cd4 100755
> --- a/utils/ipu3/ipu3-capture.sh
> +++ b/utils/ipu3/ipu3-capture.sh
> @@ -13,6 +13,9 @@
>  # - raw2pnm (from nvt https://github.com/intel/nvt.git)
>  # - yavta (from git://git.ideasonboard.org/yavta.git)
> 
> +MEDIACTL=$(which media-ctl)
> +YAVTA=$(which yavta)
> +
>  # Locate the sensor entity
>  find_sensor() {
>  	local bus
> @@ -113,8 +116,8 @@ capture_frames() {
>  		file_op="--file=/tmp/frame-#.bin"
>  	fi
> 
> -	yavta -c$frame_count -n5 -I -f $ipu3_format -s $sensor_size $file_op \
> -		$($mediactl -e "$ipu3_capture")
> +	${YAVTA} -c$frame_count -n5 -I -f $ipu3_format -s $sensor_size $file_op \
> +		   $($mediactl -e "$ipu3_capture")
>  }
> 
>  # Convert captured files to ppm
> @@ -173,7 +176,7 @@ sensor_name=$1
> 
>  sensor=$(find_sensor $sensor_name) || exit
>  mdev=$(find_media_device) || exit
> -mediactl="media-ctl -d $mdev"
> +mediactl="${MEDIACTL} -d $mdev"
> 
>  parse_pipeline $sensor
>  configure_pipeline
> diff --git a/utils/ipu3/ipu3-process.sh b/utils/ipu3/ipu3-process.sh
> index bb4abbe..ccdeb27 100755
> --- a/utils/ipu3/ipu3-process.sh
> +++ b/utils/ipu3/ipu3-process.sh
> @@ -13,6 +13,8 @@
>  # - raw2pnm (from nvt https://github.com/intel/nvt.git)
>  # - yavta (from git://git.ideasonboard.org/yavta.git)
> 
> +MEDIACTL=$(which media-ctl)
> +YAVTA=$(which yavta)
>  imgu_entity="ipu3-imgu 0"
> 
>  # Locate the media device
> @@ -20,7 +22,7 @@ find_media_device() {
>  	local mdev
> 
>  	for mdev in /dev/media* ; do
> -		media-ctl -d $mdev -p | grep -q "^driver[ \t]*ipu3-imgu$" && break
> +		$MEDIACTL -d $mdev -p | grep -q "^driver[ \t]*ipu3-imgu$" && break
>  		mdev=
>  	done
> 
> @@ -62,7 +64,7 @@ configure_pipeline() {
>  process_frames() {
>  	configure_pipeline
> 
> -	local yavta="yavta -n $nbufs -c$frame_count"
> +	local yavta="${YAVTA} -n $nbufs -c$frame_count"
> 
>  	# Save the main and viewfinder outputs to disk, capture and drop 3A
>  	# statistics. Sleep 500ms between each execution of yavta to keep the
> @@ -189,7 +191,7 @@ out_size=${out_size:-$in_size}
>  vf_size=${vf_size:-$in_size}
> 
>  mdev=$(find_media_device) || exit
> -mediactl="media-ctl -d $mdev"
> +mediactl="${MEDIACTL} -d $mdev"
>  echo "Using device $mdev"
> 
>  output_dir="/tmp"
> --
> 2.20.1
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Jacopo Mondi Jan. 11, 2019, 1:53 p.m. UTC | #2
Hi Laurent,

On Fri, Jan 11, 2019 at 03:46:23PM +0200, Laurent Pinchart wrote:
> Hi Jacopo,
>
> Thank you for the patch.
>
> On Friday, 11 January 2019 15:08:57 EET Jacopo Mondi wrote:
> > Use variables defined at the beginning of ipu3 helper scripts to call
> > yavta and media-ctl. This makes easier override them if a locally
> > compiled version should be used in place of the system-wide installed
> > ones.
>
> I had this in the first version of the scripts, but then decided it was
> cleaner to select the yavta and media-ctl binaries through PATH instead of
> hacking the script. Would that work for you ?
>

Sure. Please ignore this patch then.

Thanks
  j

> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
> > ---
> >  utils/ipu3/ipu3-capture.sh | 9 ++++++---
> >  utils/ipu3/ipu3-process.sh | 8 +++++---
> >  2 files changed, 11 insertions(+), 6 deletions(-)
> >
> > diff --git a/utils/ipu3/ipu3-capture.sh b/utils/ipu3/ipu3-capture.sh
> > index ba6147b..9d83cd4 100755
> > --- a/utils/ipu3/ipu3-capture.sh
> > +++ b/utils/ipu3/ipu3-capture.sh
> > @@ -13,6 +13,9 @@
> >  # - raw2pnm (from nvt https://github.com/intel/nvt.git)
> >  # - yavta (from git://git.ideasonboard.org/yavta.git)
> >
> > +MEDIACTL=$(which media-ctl)
> > +YAVTA=$(which yavta)
> > +
> >  # Locate the sensor entity
> >  find_sensor() {
> >  	local bus
> > @@ -113,8 +116,8 @@ capture_frames() {
> >  		file_op="--file=/tmp/frame-#.bin"
> >  	fi
> >
> > -	yavta -c$frame_count -n5 -I -f $ipu3_format -s $sensor_size $file_op \
> > -		$($mediactl -e "$ipu3_capture")
> > +	${YAVTA} -c$frame_count -n5 -I -f $ipu3_format -s $sensor_size $file_op \
> > +		   $($mediactl -e "$ipu3_capture")
> >  }
> >
> >  # Convert captured files to ppm
> > @@ -173,7 +176,7 @@ sensor_name=$1
> >
> >  sensor=$(find_sensor $sensor_name) || exit
> >  mdev=$(find_media_device) || exit
> > -mediactl="media-ctl -d $mdev"
> > +mediactl="${MEDIACTL} -d $mdev"
> >
> >  parse_pipeline $sensor
> >  configure_pipeline
> > diff --git a/utils/ipu3/ipu3-process.sh b/utils/ipu3/ipu3-process.sh
> > index bb4abbe..ccdeb27 100755
> > --- a/utils/ipu3/ipu3-process.sh
> > +++ b/utils/ipu3/ipu3-process.sh
> > @@ -13,6 +13,8 @@
> >  # - raw2pnm (from nvt https://github.com/intel/nvt.git)
> >  # - yavta (from git://git.ideasonboard.org/yavta.git)
> >
> > +MEDIACTL=$(which media-ctl)
> > +YAVTA=$(which yavta)
> >  imgu_entity="ipu3-imgu 0"
> >
> >  # Locate the media device
> > @@ -20,7 +22,7 @@ find_media_device() {
> >  	local mdev
> >
> >  	for mdev in /dev/media* ; do
> > -		media-ctl -d $mdev -p | grep -q "^driver[ \t]*ipu3-imgu$" && break
> > +		$MEDIACTL -d $mdev -p | grep -q "^driver[ \t]*ipu3-imgu$" && break
> >  		mdev=
> >  	done
> >
> > @@ -62,7 +64,7 @@ configure_pipeline() {
> >  process_frames() {
> >  	configure_pipeline
> >
> > -	local yavta="yavta -n $nbufs -c$frame_count"
> > +	local yavta="${YAVTA} -n $nbufs -c$frame_count"
> >
> >  	# Save the main and viewfinder outputs to disk, capture and drop 3A
> >  	# statistics. Sleep 500ms between each execution of yavta to keep the
> > @@ -189,7 +191,7 @@ out_size=${out_size:-$in_size}
> >  vf_size=${vf_size:-$in_size}
> >
> >  mdev=$(find_media_device) || exit
> > -mediactl="media-ctl -d $mdev"
> > +mediactl="${MEDIACTL} -d $mdev"
> >  echo "Using device $mdev"
> >
> >  output_dir="/tmp"
> > --
> > 2.20.1
> >
> > _______________________________________________
> > libcamera-devel mailing list
> > libcamera-devel@lists.libcamera.org
> > https://lists.libcamera.org/listinfo/libcamera-devel
>
>
> --
> Regards,
>
> Laurent Pinchart
>
>
>

Patch

diff --git a/utils/ipu3/ipu3-capture.sh b/utils/ipu3/ipu3-capture.sh
index ba6147b..9d83cd4 100755
--- a/utils/ipu3/ipu3-capture.sh
+++ b/utils/ipu3/ipu3-capture.sh
@@ -13,6 +13,9 @@ 
 # - raw2pnm (from nvt https://github.com/intel/nvt.git)
 # - yavta (from git://git.ideasonboard.org/yavta.git)

+MEDIACTL=$(which media-ctl)
+YAVTA=$(which yavta)
+
 # Locate the sensor entity
 find_sensor() {
 	local bus
@@ -113,8 +116,8 @@  capture_frames() {
 		file_op="--file=/tmp/frame-#.bin"
 	fi

-	yavta -c$frame_count -n5 -I -f $ipu3_format -s $sensor_size $file_op \
-		$($mediactl -e "$ipu3_capture")
+	${YAVTA} -c$frame_count -n5 -I -f $ipu3_format -s $sensor_size $file_op \
+		   $($mediactl -e "$ipu3_capture")
 }

 # Convert captured files to ppm
@@ -173,7 +176,7 @@  sensor_name=$1

 sensor=$(find_sensor $sensor_name) || exit
 mdev=$(find_media_device) || exit
-mediactl="media-ctl -d $mdev"
+mediactl="${MEDIACTL} -d $mdev"

 parse_pipeline $sensor
 configure_pipeline
diff --git a/utils/ipu3/ipu3-process.sh b/utils/ipu3/ipu3-process.sh
index bb4abbe..ccdeb27 100755
--- a/utils/ipu3/ipu3-process.sh
+++ b/utils/ipu3/ipu3-process.sh
@@ -13,6 +13,8 @@ 
 # - raw2pnm (from nvt https://github.com/intel/nvt.git)
 # - yavta (from git://git.ideasonboard.org/yavta.git)

+MEDIACTL=$(which media-ctl)
+YAVTA=$(which yavta)
 imgu_entity="ipu3-imgu 0"

 # Locate the media device
@@ -20,7 +22,7 @@  find_media_device() {
 	local mdev

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

@@ -62,7 +64,7 @@  configure_pipeline() {
 process_frames() {
 	configure_pipeline

-	local yavta="yavta -n $nbufs -c$frame_count"
+	local yavta="${YAVTA} -n $nbufs -c$frame_count"

 	# Save the main and viewfinder outputs to disk, capture and drop 3A
 	# statistics. Sleep 500ms between each execution of yavta to keep the
@@ -189,7 +191,7 @@  out_size=${out_size:-$in_size}
 vf_size=${vf_size:-$in_size}

 mdev=$(find_media_device) || exit
-mediactl="media-ctl -d $mdev"
+mediactl="${MEDIACTL} -d $mdev"
 echo "Using device $mdev"

 output_dir="/tmp"