Skip to contentSkip to conversation

V4L: add "function" sysfs attribute to v4l devices

PATCH In review Kees Cook 1 participant 2 messages Apr 17, 2008 Media (V4L/DVB)

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

cover V4L: add "function" sysfs attribute to v4l devices

Hello!

Two patches follow, related to discussions[1][2] on the hotplug mailing list, in an attempt to solve enumeration problems when multiple v4l devices are present in a system and the resulting init order was not guaranteed to be the same from boot-to-boot (video0 isn't always the same device). The goal is to create things like this with udev:

    pci-0000:01:06.0-video-mpeg-cap -> ../../video0
    pci-0000:01:07.0-video-yuv-cap -> ../../video1
    pci-0000:01:06.0-video-yuv-cap -> ../../video24

First patch is the sysfs infrastructure to support exporting a "function" string. This value is related to the existing "type" field, but is singular in use and not designed for internal driver use, as "type" seems to be.

Second patch is a first stab at providing "function" entries for hardware I have access to.

Thanks,

-Kees

[1] http://marc.info/?t=118591155400012&r=1&w=2
[2] some recent discussion on the new hotplug list, but I can't find an archive link since it moved to vger...

Signature · 6 lines
Kees Cook                                            @outflux.net

--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
author
#1 lore raw
Quoted 2 lines · Kees Cook

[2] some recent discussion on the new hotplug list, but I can't find an archive link since it moved to vger...

Since I can't link to it, I'll just include the udev patches here too. :)

---
Update of path_id and example symlink-creation update for udev to take advantage of the new "function" string exported from video4linux devices.

---
 debian/rules.d/60-symlinks.rules |    9 +++++++++
 extras/path_id/path_id           |   14 ++++++++++++++
 2 files changed, 23 insertions(+)
debian/rules.d/60-symlinks.rules renamed from debian/rules.d/60-symlinks.rules~ +9 -0
@@ -14,3 +14,12 @@
 # Create /dev/pilot symlink for Palm Pilots
 KERNEL=="ttyUSB*", ATTRS{product}=="Palm Handheld*|Handspring *|palmOne Handheld", \
 					SYMLINK+="pilot"
+
+# Create video4linux PCI path symlinks
+ACTION!="add", GOTO="video4linux_path_end"
+SUBSYSTEM!="video4linux", GOTO="video4linux_path_end"
+
+IMPORT{program}="path_id %p"
+ENV{ID_PATH}=="?*", KERNEL=="video*", SYMLINK+="v4l/by-path/$env{ID_PATH}"
+
+LABEL="video4linux_path_end"
extras/path_id/path_id renamed from extras/path_id/path_id~ +14 -0
@@ -462,6 +462,10 @@
 	full_sysfs_device_path="`pwd -P`"
 	cd "$OPWD"
 
+	if [ "$TYPE" = "video4linux" ] ; then
+		d="video"
+	fi
+
 	D=$full_sysfs_device_path
 	while [ ! -z "$D" ] ; do
 		case "$D" in
@@ -566,6 +570,16 @@
 		handle_device
 		echo "ID_PATH=$d"
 		;;
+	video4linux)
+		handle_device
+		if [ "$d" ]; then
+			# Only report v4l devices that have a "function" defined
+			func=$(cat $SYSFS$DEVPATH/function 2>/dev/null ||true)
+			if [ "$func" ]; then
+				echo "ID_PATH=$d-$func"
+			fi
+		fi
+		;;
 	*)
 		RESULT=1
 		;;
Signature · 6 lines
Kees Cook                                            @outflux.net

--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list