[pvrusb2] getting at the serial number
Carsten Meier
cm at trexity.de
Sat Jan 17 11:59:20 CST 2009
Am Sat, 17 Jan 2009 16:57:29 +0100
schrieb Carsten Meier <cm at trexity.de>:
> Am Fri, 16 Jan 2009 22:30:21 -0600 (CST)
> schrieb Mike Isely <isely at isely.net>:
>
> >
> > Carsten:
> >
> > I just learned something interesting that you'll want to know. The
> > serial number *is* in fact already available in the USB
> > configuration data. Thus you can do what Mauro is suggesting to
> > identify the device: Use the bus_info field to find the
> > udev-populated device node in /sys and then walk that to find the
> > serial number.
> >
> > The reason I had never considered this is because the device's
> > serial number is stored in its ROM, encoded in a format that is
> > specific to Hauppauge and has nothing to do with USB. The pvrusb2
> > driver reads this by using the tveeprom module to parse the data.
> > Since the pvrusb2 driver then never does anything with the result
> > except to use it as the root node in its own sysfs interface, I had
> > concluded that it wasn't available any other way.
> >
> > However it is in fact present in the USB configuration data. Just
> > run the usbview generic tool and you'll see it. You'll see a field
> > labeled "Serial Number:" and its value will be of the form
> > "mmmm-xx-yyyyyyyy". The "mmmm" appears to match the model type, but
> > the "yyyyyyyy" is an 8 digit hex number that when converted to
> > decimal will match the number that the pvrusb2 driver puts in its
> > sysfs interface. (The "xx" part appears to just be a pair of
> > constant zeroes.)
> >
> > Why is this? Well I can't prove it, but I can think of two
> > possibilities for how the serial number could have found its way
> > into the USB configuration data without any help from the pvrusb2
> > driver:
> >
> > First the USB config data is also in that ROM - this is where the
> > manufacturer and device ID are initially coded of course. But
> > that's a different part of the ROM, formatted in a manner that the
> > FX2 processor's factory ROM initialization can directly read, i.e.
> > this part is not specific to Hauppauge. So it's possible that the
> > serial number is actually written in two places.
> >
> > A second possibility is that the FX2 is able to directly
> > reinitialize its USB interface as it comes up. It can write its
> > own configuration data. So it's theoretically possible that the
> > Hauppauge-supplied FX2 firmware is itself accessing the nearby
> > Hauppauge ROM, extracting the serial number, and then stuffing it
> > in to the USB configuration data. However until now I've never seen
> > any actual evidence that the FX2 firmware will directly read that
> > ROM (rather, the host driver reads it).
> >
> > But either way that would explain things.
> >
> > -Mike
> >
>
> Hi,
>
> I'm now diving into sysfs and found the info you mentioned in
> "/sys/bus/usb/devices/7-2/" for a bus_info-string of "usb 7-2 address
> 6" The "address 6" part is found in "/sys/bus/usb/devices/7-2/devnum"
> and is the part which causes the trouble with my simple
> bus_info-approach because it always changes. Some questions about now
> two possible approaches::
>
> Approach #1: Direct mapping of card and bus_info to config data (my
> original idea):
>
> - To make the simple bus_info approach work, just the address 6 has to
> be removed from the bus_info-string. Is it neccessary to identify the
> device in sysfs? (should it really be there?)
>
> Approach #2: Use bus_info-string to locate device-information in sysfs
> and read infos like serial from there:
>
> - How does the canonical usb-bus_info-string look like which has
> been suggested by Mauro on the linux-media-list?
> - How to make my app work with PCI-devices? (because I have to look
> in "/sys/bus/usb/" for USB-devices) How to distingish USB- and
> PCI-devices from v4l2?
>
> Of course, both approaches could be combined if bus_info would return
> something like "USB-7-2" which doesn't change and is suitable for
> finding the serial via sysfs.
>
> Sorry for all those questions. I know you are a
> driver-developer, not my personal teacher, but you know about the
> problem I have ;) I already read the sysfs-reference at
> http://www.kernel.org/pub/linux/kernel/people/mochel/doc/papers/ols-2005/
> but it doesn't contain much information for my case.
I just looked at the impl. of usb_make_path() in the
kernel-sources. It constructs names with the format-string "usb-%s-%s",
which, if used by pvrusb2's bus_info-generator, would solve my problems.
bus_info won't change here on reconnect. Could you *please* change the
bus_info-generation to use this function?
Thanks,
Carsten
More information about the pvrusb2
mailing list