Skip to contentSkip to conversation

Fix module unloading, vimc device naming

PATCH Superseded Sakari Ailus 2 participants 4 messages Aug 4, 2025 Media (V4L/DVB)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Fix module unloading, vimc device naming

Hi all,

This set fixes test driver module unloading and vimc device naming (see <[email protected]> on LMML).

Sakari Ailus (2):
contrib/test/test-media: Fix module unloading in error handling contrib/test/test-media: Probe the vimc device

 contrib/test/test-media | 61 ++++++++++++++++++++++++-----------------
 1 file changed, 36 insertions(+), 25 deletions(-)
Signature · 1 line
2.39.5
#1 lore raw

PATCH 1/2 contrib/test/test-media: Fix module unloading in error handling

Modules are unloaded in case of errors but alas, in all cases the module being unloaded is vivid, not the one that was just loaded. Fix this.

---
 contrib/test/test-media | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
contrib/test/test-media +5 -5
index 68fe48f947f3..dda7ff44075b 100755
@@ -417,7 +417,7 @@ if [ $vim2m -eq 1 ]; then
 		echo "FAIL: the vim2m module failed to load" | tee -a $tmp
 		echo "Grand Total for vim2m: Succeeded: 0, Failed: 1, Warnings: 0" | tee -a $tmp
 		echo "Final Summary: 1, Succeeded: 0, Failed: 1, Warnings: 0"
-		rmmod vivid
+		rmmod vim2m
 		exit 0
 	fi
 fi
@@ -453,7 +453,7 @@ if [ $vim2m -eq 1 -a $setup -eq 0 ]; then
 		echo "FAIL: the vim2m module failed to load" | tee -a $tmp
 		echo "Grand Total for vim2m: Succeeded: 0, Failed: 1, Warnings: 0" | tee -a $tmp
 		echo "Final Summary: 1, Succeeded: 0, Failed: 1, Warnings: 0"
-		rmmod vivid
+		rmmod vim2m
 		exit 0
 	fi
 
@@ -525,7 +525,7 @@ if [ $vimc -eq 1 ]; then
 		echo "FAIL: the vimc module failed to load" | tee -a $tmp
 		echo "Grand Total for vimc: Succeeded: 0, Failed: 1, Warnings: 0" | tee -a $tmp
 		echo "Final Summary: 1, Succeeded: 0, Failed: 1, Warnings: 0"
-		rmmod vivid
+		rmmod vimc
 		exit 0
 	fi
 
@@ -627,7 +627,7 @@ if [ $vicodec -eq 1 ]; then
 		echo "FAIL: the vicodec module failed to load" | tee -a $tmp
 		echo "Grand Total for vicodec: Succeeded: 0, Failed: 1, Warnings: 0" | tee -a $tmp
 		echo "Final Summary: 1, Succeeded: 0, Failed: 1, Warnings: 0"
-		rmmod vivid
+		rmmod vicodec
 		exit 0
 	fi
 
@@ -812,7 +812,7 @@ if [ $visl -eq 1 ]; then
 		echo "FAIL: the visl module failed to load" | tee -a $tmp
 		echo "Grand Total for visl: Succeeded: 0, Failed: 1, Warnings: 0" | tee -a $tmp
 		echo "Final Summary: 1, Succeeded: 0, Failed: 1, Warnings: 0"
-		rmmod vivid
+		rmmod visl
 		exit 0
 	fi
 fi
Signature · 1 line
2.39.5
#2 lore raw

Re: [v4l-utils PATCH 1/2] contrib/test/test-media: Fix module unloading in error handling

Quoted 13 lines · Sakari Ailus

Modules are unloaded in case of errors but alas, in all cases the module being unloaded is vivid, not the one that was just loaded. Fix this.

---
 contrib/test/test-media | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
contrib/test/test-media +0 -0
index 68fe48f947f3..dda7ff44075b 100755

contrib/test/test-media if [ $vim2m -eq 1 ]; then · line 420

Quoted 5 lines
contrib/test/test-media +1 -1
@@ -417,7 +417,7 @@ if [ $vim2m -eq 1 ]; then
 		echo "FAIL: the vim2m module failed to load" | tee -a $tmp
 		echo "Grand Total for vim2m: Succeeded: 0, Failed: 1, Warnings: 0" | tee -a $tmp
 		echo "Final Summary: 1, Succeeded: 0, Failed: 1, Warnings: 0"
-		rmmod vivid
+		rmmod vim2m

Actually, vivid still needs to be rmmod'ed as well since it is always modprobe'd first.

The idea behind this was that vim2m didn't load (e.g. it was never compiled in), so there is no need to rmmod it. But of course, if vim2m was compiled in, and it fails to initiate the vim2m device, then you would come here and you still want to rmmod vim2m, since it did load, it just didn't instantiate the device for some reason.

So this patch should add 'rmmod vim2m' and not replace 'rmmod vivid' with it.

Regards,

Hans

Quoted 39 lines
contrib/test/test-media +4 -4
 		exit 0
 	fi
 fi
@@ -453,7 +453,7 @@ if [ $vim2m -eq 1 -a $setup -eq 0 ]; then
 		echo "FAIL: the vim2m module failed to load" | tee -a $tmp
 		echo "Grand Total for vim2m: Succeeded: 0, Failed: 1, Warnings: 0" | tee -a $tmp
 		echo "Final Summary: 1, Succeeded: 0, Failed: 1, Warnings: 0"
-		rmmod vivid
+		rmmod vim2m
 		exit 0
 	fi
 
@@ -525,7 +525,7 @@ if [ $vimc -eq 1 ]; then
 		echo "FAIL: the vimc module failed to load" | tee -a $tmp
 		echo "Grand Total for vimc: Succeeded: 0, Failed: 1, Warnings: 0" | tee -a $tmp
 		echo "Final Summary: 1, Succeeded: 0, Failed: 1, Warnings: 0"
-		rmmod vivid
+		rmmod vimc
 		exit 0
 	fi
 
@@ -627,7 +627,7 @@ if [ $vicodec -eq 1 ]; then
 		echo "FAIL: the vicodec module failed to load" | tee -a $tmp
 		echo "Grand Total for vicodec: Succeeded: 0, Failed: 1, Warnings: 0" | tee -a $tmp
 		echo "Final Summary: 1, Succeeded: 0, Failed: 1, Warnings: 0"
-		rmmod vivid
+		rmmod vicodec
 		exit 0
 	fi
 
@@ -812,7 +812,7 @@ if [ $visl -eq 1 ]; then
 		echo "FAIL: the visl module failed to load" | tee -a $tmp
 		echo "Grand Total for visl: Succeeded: 0, Failed: 1, Warnings: 0" | tee -a $tmp
 		echo "Final Summary: 1, Succeeded: 0, Failed: 1, Warnings: 0"
-		rmmod vivid
+		rmmod visl
 		exit 0
 	fi
 fi
#3 lore raw

PATCH 2/2 contrib/test/test-media: Probe the vimc device

In reply to Sakari Ailus

The vimc platform device is called platform:vimc.0 after kernel patch "media: vimc: Don't explicitly set bus_info". Adapt to possible different naming of the vimc device.

---
 contrib/test/test-media | 51 +++++++++++++++++++++++++----------------
 1 file changed, 31 insertions(+), 20 deletions(-)
contrib/test/test-media +31 -20
index dda7ff44075b..c3691ab32ca9 100755
@@ -521,7 +521,18 @@ if [ $vimc -eq 1 ]; then
 	rmmod vimc 2&>/dev/null
 	run_modprobe vimc
 
-	if ! $v4l2_ctl -z platform:vimc -d "Sensor A" ; then
+	for i in vimc vimc.0; do
+		if media-ctl -d platform:$i > /dev/null; then
+			vimc_device=platform:$i
+		fi
+	done
+	if [ "$vimc_device" -eq "" ]; then
+		echo "FAIL: can't find vimc device" | tee -a $tmp
+		rmmod vimc
+		exit 0
+	fi
+
+	if ! $v4l2_ctl -z $vimc_device -d "Sensor A" ; then
 		echo "FAIL: the vimc module failed to load" | tee -a $tmp
 		echo "Grand Total for vimc: Succeeded: 0, Failed: 1, Warnings: 0" | tee -a $tmp
 		echo "Final Summary: 1, Succeeded: 0, Failed: 1, Warnings: 0"
@@ -529,14 +540,14 @@ if [ $vimc -eq 1 ]; then
 		exit 0
 	fi
 
-	media-ctl -d platform:vimc -V '"Sensor A":0[fmt:SBGGR8_1X8/640x480]'
-	media-ctl -d platform:vimc -V '"Debayer A":0[fmt:SBGGR8_1X8/640x480]'
-	media-ctl -d platform:vimc -V '"Sensor B":0[fmt:SBGGR8_1X8/640x480]'
-	media-ctl -d platform:vimc -V '"Debayer B":0[fmt:SBGGR8_1X8/640x480]'
-	media-ctl -d platform:vimc -V '"Scaler":1[fmt:RGB888_1X24/1920x1440]'
-	$v4l2_ctl -z platform:vimc -d "RGB/YUV Capture" -v width=1920,height=1440
-	$v4l2_ctl -z platform:vimc -d "Raw Capture 0" -v pixelformat=BA81
-	$v4l2_ctl -z platform:vimc -d "Raw Capture 1" -v pixelformat=BA81
+	media-ctl -d $vimc_device -V '"Sensor A":0[fmt:SBGGR8_1X8/640x480]'
+	media-ctl -d $vimc_device -V '"Debayer A":0[fmt:SBGGR8_1X8/640x480]'
+	media-ctl -d $vimc_device -V '"Sensor B":0[fmt:SBGGR8_1X8/640x480]'
+	media-ctl -d $vimc_device -V '"Debayer B":0[fmt:SBGGR8_1X8/640x480]'
+	media-ctl -d $vimc_device -V '"Scaler":1[fmt:RGB888_1X24/1920x1440]'
+	$v4l2_ctl -z $vimc_device -d "RGB/YUV Capture" -v width=1920,height=1440
+	$v4l2_ctl -z $vimc_device -d "Raw Capture 0" -v pixelformat=BA81
+	$v4l2_ctl -z $vimc_device -d "Raw Capture 1" -v pixelformat=BA81
 fi
 
 if [ $vimc -eq 1 -a $setup -eq 0 ]; then
@@ -545,7 +556,7 @@ if [ $vimc -eq 1 -a $setup -eq 0 ]; then
 	echo vimc compliance tests | tee /dev/kmsg
 	echo
 	date
-	stdbuf -oL $v4l2_compliance -m platform:vimc -z platform:vivid-002 -e vivid-002-vid-cap -s10 -P -a 2>&1 | tee -a $tmp
+	stdbuf -oL $v4l2_compliance -m $vimc_device -z platform:vivid-002 -e vivid-002-vid-cap -s10 -P -a 2>&1 | tee -a $tmp
 	echo
 	echo
 	echo
@@ -565,24 +576,24 @@ if [ $vimc -eq 1 -a $setup -eq 0 ]; then
 	echo
 	echo -n vimc.0 >/sys/bus/platform/drivers/vimc/bind
 	sleep 1
-	media-ctl -d platform:vimc -V '"Sensor A":0[fmt:SBGGR8_1X8/640x480]'
-	media-ctl -d platform:vimc -V '"Debayer A":0[fmt:SBGGR8_1X8/640x480]'
-	media-ctl -d platform:vimc -V '"Sensor B":0[fmt:SBGGR8_1X8/640x480]'
-	media-ctl -d platform:vimc -V '"Debayer B":0[fmt:SBGGR8_1X8/640x480]'
-	media-ctl -d platform:vimc -V '"Scaler":1[fmt:RGB888_1X24/1920x1440]'
-	$v4l2_ctl -z platform:vimc -d "RGB/YUV Capture" -v width=1920,height=1440
-	$v4l2_ctl -z platform:vimc -d "Raw Capture 0" -v pixelformat=BA81
-	$v4l2_ctl -z platform:vimc -d "Raw Capture 1" -v pixelformat=BA81
+	media-ctl -d $vimc_device -V '"Sensor A":0[fmt:SBGGR8_1X8/640x480]'
+	media-ctl -d $vimc_device -V '"Debayer A":0[fmt:SBGGR8_1X8/640x480]'
+	media-ctl -d $vimc_device -V '"Sensor B":0[fmt:SBGGR8_1X8/640x480]'
+	media-ctl -d $vimc_device -V '"Debayer B":0[fmt:SBGGR8_1X8/640x480]'
+	media-ctl -d $vimc_device -V '"Scaler":1[fmt:RGB888_1X24/1920x1440]'
+	$v4l2_ctl -z $vimc_device -d "RGB/YUV Capture" -v width=1920,height=1440
+	$v4l2_ctl -z $vimc_device -d "Raw Capture 0" -v pixelformat=BA81
+	$v4l2_ctl -z $vimc_device -d "Raw Capture 1" -v pixelformat=BA81
 	echo
 	echo second unbind vimc | tee /dev/kmsg
 	echo
 	# Max sleep time is 6 + 8 = 14s
-	for i in `$v4l2_ctl -z platform:vimc --list-devices`; do
+	for i in `$v4l2_ctl -z $vimc_device --list-devices`; do
 		let "t = 6 + $RANDOM / 4096"
 		echo $i: sleep ${t}s
 		sleep $t <$i &
 	done
-	$v4l2_ctl -z platform:vimc -d "Raw Capture 0" --stream-mmap --sleep 5 &
+	$v4l2_ctl -z $vimc_device -d "Raw Capture 0" --stream-mmap --sleep 5 &
 	sleep 1
 	echo -n vimc.0 >/sys/bus/platform/drivers/vimc/unbind
 	sleep 14
Signature · 1 line
2.39.5