Home | History | Annotate | Download | only in dvr
      1 #ifndef ANDROID_DVR_VSYNC_CLIENT_H_
      2 #define ANDROID_DVR_VSYNC_CLIENT_H_
      3 
      4 #include <stdint.h>
      5 
      6 #include <pdx/client.h>
      7 
      8 struct dvr_vsync_client {};
      9 
     10 namespace android {
     11 namespace dvr {
     12 
     13 /*
     14  * VSyncClient is a remote interface to the vsync service in displayd.
     15  * This class is used to wait for and retrieve information about the
     16  * display vsync.
     17  */
     18 class VSyncClient : public pdx::ClientBase<VSyncClient>,
     19                     public dvr_vsync_client {
     20  public:
     21   /*
     22    * Wait for the next vsync signal.
     23    * The timestamp (in ns) is written into *ts when ts is non-NULL.
     24    */
     25   int Wait(int64_t* timestamp_ns);
     26 
     27   /*
     28    * Returns the file descriptor used to communicate with the vsync system
     29    * service or -1 on error.
     30    */
     31   int GetFd();
     32 
     33   /*
     34    * Clears the select/poll/epoll event so that subsequent calls to
     35    * these will not signal until the next vsync.
     36    */
     37   int Acknowledge();
     38 
     39   /*
     40    * Get the timestamp of the last vsync event in ns. This call has
     41    * the same side effect on events as Acknowledge(), which saves
     42    * an IPC message.
     43    */
     44   int GetLastTimestamp(int64_t* timestamp_ns);
     45 
     46   /*
     47    * Get vsync scheduling info.
     48    * Get the estimated timestamp of the next GPU lens warp preemption event in
     49    * ns. Also returns the corresponding vsync count that the next lens warp
     50    * operation will target. This call has the same side effect on events as
     51    * Acknowledge(), which saves an IPC message.
     52    */
     53   int GetSchedInfo(int64_t* vsync_period_ns, int64_t* next_timestamp_ns,
     54                    uint32_t* next_vsync_count);
     55 
     56  private:
     57   friend BASE;
     58 
     59   VSyncClient();
     60   explicit VSyncClient(long timeout_ms);
     61 
     62   VSyncClient(const VSyncClient&) = delete;
     63   void operator=(const VSyncClient&) = delete;
     64 };
     65 
     66 }  // namespace dvr
     67 }  // namespace android
     68 
     69 #endif  // ANDROID_DVR_VSYNC_CLIENT_H_
     70