You are not logged in.
I have a hauppauge winTV dualHD usb dvb tuner. For purposes of creating uniquely named /dev/dvb/adapterX/dvr0 devices I tried to separate the dvr0 devices using rules like this
SUBSYSTEM=="dvb", KERNEL=="dvb0.*0", ATTRS{manufacturer}=="HCW", ATTRS{product}=="dualHD", PROGRAM="/bin/sh -c 'K=%k; K=$${K#dvb}; printf dvb/adapter%%s/%%s 110 $${K#*.}'", SYMLINK+="%c"
SUBSYSTEM=="dvb", KERNEL=="dvb1.*0", ATTRS{manufacturer}=="HCW", ATTRS{product}=="dualHD", PROGRAM="/bin/sh -c 'K=%k; K=$${K#dvb}; printf dvb/adapter%%s/%%s 111 $${K#*.}'", SYMLINK+="%c"and this works when the device is plugged in first so I get /dev/dvb/adapter110 and /dev/dvb/adapter111
However, if other dvb device(s) are scanned first the dual device can have other numbers eg adapter1 and adapter2 (instead of adapter0/1). so only one of the rules above will happen as the KERNEL value is dvb<n>.dvr0
I looked at udevadm info -a /dev/dvb/adapter*/dvr0, but cannot find anything obvious that separates the two devices. There is a serial number, but it is at the usb level and doesn't vary between udevadm info -a /dev/dvb/adapter{0,1}/dvr0. The KERNEL name does vary, but is affected by previously active dvb adapters.
Is there some way I can create two devices with know names?
Last edited by replabrobin (2026-07-24 11:04:05)
Offline
However, if other dvb device(s) are scanned first the dual device can have other numbers eg adapter1 and adapter2 (instead of adapter0/1).
Are target devices distinguishable from "other" DVB devices by manufacturer and product strings?
I think it is possible to implement, but only with PROGRAM which tracks a pool of indicies for matched devices. This pool should be stored globally, e.g. in file somewhere in /run/. In your case that pool will contain only two indicies: 0 and 1.
Last edited by dimich (2026-07-24 12:41:09)
Offline
I think you are probably right. The device has manufacturer and product that distinguish it.
A helper program could check for the linked devices and provide a sequence of them.
I'm never sure if I can get the same rule to fire more than once, but I suppose a simple experiment will tell me.
Last edited by replabrobin (2026-07-24 13:58:59)
Offline
I'm never sure if I can get the same rule to fire more than once
I don't know if udev can emit "add" event for already present device in normal operation, but it is definitely possible to trigger "add" on purpose with udevadm. Udev may emit "change" event, so ACTION=="add" is required.
Also if you want to allocate first free index rather than sequential numbering, ACTION=="remove" should return index to the pool and reuse it on next "add" action.
I mean there are two options. Let adapter0 and adapter1 are already plugged. Let adapter0 is unplugged and plugged back again. You may want it to appear as adapter0 or adapter2.
Offline
I made a fairly complex bash PROGRAM to map the device(s) into adapter110 .. adapter119. Provided we have less than 6 of these devices this seems to work
ACTION=="add", SUBSYSTEM=="dvb", ATTRS{manufacturer}=="HCW", ATTRS{product}=="dualHD", ATTRS{serial}=="0014462805", PROGRAM="/bin/bash -c 'K=%k; I=$${K#*.}; for x in {110..119}; do if [ ! -e /dev/dvb/adapter$${x}/$${I} ]; then printf dvb/adapter%%s/%%s $${x} $${I}; break; fi; done'", SYMLINK+="%c"This extracts the interface name from the KERNEL value in $$K using I=$${K#*.}. Then we loop through possible linked interfaces /dev/dvb/adapter$${x}/$${I} where x is looped from 110 .. 119. The first interface that doesn't exist is the one we assume should be linked.
This seems a bit fragile to me, but seems to work for me with or without earlier dvb adapters.
Last edited by replabrobin (Yesterday 12:59:24)
Offline