Clock synchronisation using the frame counter

Laurent Pinchart <[email protected]>
Newsgroups gmane.linux.usb.devel
Message-ID <[email protected]>
Hi everybody,

I'm trying to find a way to synchronise the Linux system clock with a device 
clock using the USB frame counter as a shared clock.

My USB device has an internal clock, called the device clock. Its frequency is 
reported in the USB descriptors. When streaming data (video), every video 
frame (made of multiple bulk or isochronous transfers) reports the 
Presentation Time Stamp, which is the video frame acquisition time in device 
clock units. I need to convert the PTS into a Linux system clock timestamp.

Has the device clock and the Linux system clock are not synchronised, the 
device provides a Source Clock Reference at regular intervals (100ms max). 
The SCR contains a clock value sampled from the device clock, and a SOF 
counter value representing the frame number at the time the device clock was 
sampled (the SOF counter value is not required to match the current frame 
number, it can be an internal counter in the device).

I end up with three time sources: the device clock, the USB clock (through the 
SOF counter), and the Linux system clock. The jitter between the device clock 
and the USB clock is reported in the Source Clock Reference, and the jitter 
between the USB clock and the Linux system clock should be computed somehow. 
I then need to use all those parameters to estimate the jitter between the 
device clock and the Linux system clock, to convert the PTS values into Linux 
system clock units.

I'd like to know if anyone has ever solved the same problem, or thought about 
how to solve it. I know there's a way to retrieve the current SOF counter, 
but there doesn't seem to be a way to get the Linux system clock at the time 
the SOF packet is sent.

Any help would be appreciated.

Laurent Pinchart

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.