[pvrusb2] How to uniquely identify a device
Carsten Meier
cm at trexity.de
Fri Jan 9 16:45:35 CST 2009
Am Fri, 9 Jan 2009 16:21:48 -0600 (CST)
schrieb Mike Isely <isely at isely.net>:
> On Fri, 9 Jan 2009, Carsten Meier wrote:
>
> > Am Fri, 9 Jan 2009 14:27:43 -0600 (CST)
> > schrieb Mike Isely <isely at isely.net>:
> >
> > > On Fri, 9 Jan 2009, Carsten Meier wrote:
> > >
> > > > Hi again,
> > > >
> > > > I'm currently writing a tool to store video-settings in an
> > > > XML-file (for setting controls on a per-channel basis and for
> > > > storing encoding-profiles). Now I have a problem to uniquely
> > > > identify a device. I first wanted to use the bus-info to
> > > > associate a particular device with a profile (for the case of
> > > > multiple identical devices connected to a system). But this
> > > > changes on reconnect.
> > > >
> > > > If I first print out the bus-info it reports something like
> > > > "usb 7-2 address 7". If I then dis- and reconnect the device
> > > > while it is under operation (streaming to VLC), it creates a
> > > > new device-node (/dev/video1 here, exactly what it should do)
> > > > but reports a bus-info "usb 7-2 address 8" and the profile
> > > > can't be associated to that device. How can I read the
> > > > serial-number which is used by the sysfs-interface through the
> > > > V4L2-API?
> > >
> > > Unfortunately the serial number is not available through the V4L2
> > > API. Last time I researched this (years ago) I could find no legal
> > > way to do this - without defining/abusing a custom V4L control to
> > > read it back. Perhaps that's better now; if you'd like to suggest
> > > something I'll listen. As for the bus info, that's really
> > > supposed to be about "where" the device is, not "who" the device
> > > is :-(
> > >
>
> > If the bus-info is supposed to describe "where" the device is (from
> > a users perspective, not something like kernel-usb-instances),
> > shouldn't it report back the same string if I replug it to same
> > port? Then the config settings remain valid for that device and the
> > user can simply distinguish devices by the place where they are
> > plugged in. (as he already does with PCI cards)
>
> Nice idea, but the concept of "where" in USB-land is also a logical
> thing. It indicates an assigned USB address relative to the hub not
> just the physical port. This (IMHO) makes the information useless to
> just about everyone except someone debugging the USB core. Fun, eh?
>
> I believe for V4L, the bus info concept comes from PCI, where the
> idea of "where" (bus #, device #, function #) is a little more
> concrete and can't change so long as the card is always put into the
> same slot.
>
> For what you're trying to do, you really want an identifier tied to
> the device itself not where it happens to be residing at the moment.
> That technically is more the "USB way" of doing things anyway. And
> that's the serial number...
OK, then simply report back the serial-number to bus-info. The
v4l2-docs explicitly states that this info is intended for users to
select between identical devices:
quote:------
__u8 bus_info[32]:
Location of the device in the system, a
NUL-terminated ASCII string. For example: "PCI Slot 4". This
information is intended for users, to distinguish multiple identical
devices. If no such information is available the field may simply count
the devices controlled by the driver, or contain the empty string
(bus_info[0] = 0).
------------
Users should be enabled to select between multiple, identical
devices and as a logical consequence, this information should be
saveable in some config file. The current bus-info changes even if I my
mini-pc changed to standby-mode and woke up again and is therefore
useless for that purpose.
I hope I convinced you... :)
Carsten
More information about the pvrusb2
mailing list