Mark Vojkovich ([EMAIL PROTECTED]):

> > I would like to see:
> > 
> > 1) A call returning the refresh rate and status.  This way I can
> >    calculate a playback strategy.  It seems like it would be trivial
> >    to implement for the i810 (good, cause I have one), and I'm sure
> >    for many other drivers.  Can we throw a func in somewhere, maybe
> >    into Xv?
> 
>    The XF86VidMode extension is a more appropriate place, however, I'm
> not sure how you can make use of this.  All the driver can basically
> tell you is a timestamp (millisecond accuracy is the best you'll get)
> and what line it was on at that time.   And not all drivers will be
> able to tell you what line you're on.

  I don't understand your pessimism.  Using the VGA port and an nVidia
TNT2 card I was able to get sufficent accuracy.  The problem, I guess,
is in the latency of an X call.  How bad do you think this is?  Is there
some way around it?  Can the driver perform the hard work for me (it
probably can, but not as SCHED_FIFO).

  Understandably, some drivers will suck.  But I don't think this means
we should ever limit ourselves.

  My strategy with the VGA port is as follows.  Spawn a thread, set it
SCHED_FIFO, execute the following:

  /* Spin until the refresh. */
  while( !inb( 0x3da ) & 8 );

  /* Spin until it ends.  Now we're synced. */
  while( inb( 0x3da ) & 8 );

  /* Spin until the next refresh starts. */
  while( !inb( 0x3da ) & 8 );

  /* Get the time of day, this is our base time. */
  gettimeofday( &basetime, 0 );

  for( i = 0; i < bignumber; i++ ) {
      /* Grab bignumber refreshes and mark their times using
       * gettimeofday() or rdtsc.  Use these to estimate the refresh
       * rate.
       */
  }

  This gives us a time reference point of when a refresh occurred (+
some small error).  We also have the refresh rate which is pretty
accurate.  We can now use these to estimate when refreshes will occur in
the future, our accuracy hindered by our estimate of the refresh rate
and the assumption that it remains constant.  However, during the
running of our program we can trivially spin and resync ourselves again
by finding a new basetime.

  To port this to the X world, maybe:

  o  Can the driver tell me an exact value of the refresh rate?  I bet
     most cards can.  Does xvidtune display that information?  It must
     get it from somewhere.
  o  Why would the timestamps from X be with only millisecond accuracy?
     I'm sure most video cards can trigger an interrupt on the vertical
     refresh, that would be pretty accurate.  Even if I could just query
     the state: am I during a refresh or not, and have an accurate
     timestamp for that, then I think I could probe this enough to get
     some notion of a reference point.

-- 
Billy Biggs
[EMAIL PROTECTED]
_______________________________________________
Xpert mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/xpert

Reply via email to