---
name: "drm_calc_vbltimestamp_from_scanoutpos"
section: "9"
platform: "linux"
package: "linux-manual-3.16"
version: "3.16.56-1+deb8u1"
release: "Debian 8 (Jessie)"
platforms: ["linux"]
url: "https://new.carta.tech/drm_calc_vbltimestamp_from_scanoutpos"
---

# drm\_calc\_vbltimestamp\_from\_scanoutpos(9)

precise vblank timestamp helper

## NAME

drm\_calc\_vbltimestamp\_from\_scanoutpos - precise vblank timestamp helper

## SYNOPSIS

**int drm\_calc\_vbltimestamp\_from\_scanoutpos(struct drm\_device \*** *dev***, int** *crtc***, int \*** *max\_error***, struct timeval \*** *vblank\_time***, unsigned** *flags***, const struct drm\_crtc \*** *refcrtc***, const struct drm\_display\_mode \*** *mode***);**

## ARGUMENTS

*dev*

DRM device

*crtc*

Which CRTC's vblank timestamp to retrieve

*max\_error*

Desired maximum allowable error in timestamps (nanosecs) On return contains true maximum error of timestamp

*vblank\_time*

Pointer to struct timeval which should receive the timestamp

*flags*

Flags to pass to driver: 0 = Default, DRM\_CALLED\_FROM\_VBLIRQ = If function is called from vbl IRQ handler

*refcrtc*

CRTC which defines scanout timing

*mode*

mode which defines the scanout timings

## DESCRIPTION

Implements calculation of exact vblank timestamps from given drm\_display\_mode timings and current video scanout position of a CRTC. This can be called from within **get\_vblank\_timestamp** implementation of a kms driver to implement the actual timestamping.

Should return timestamps conforming to the OML\_sync\_control OpenML extension specification. The timestamp corresponds to the end of the vblank interval, aka start of scanout of topmost-leftmost display pixel in the following video frame.

Requires support for optional dev-\>driver-\>**get\_scanout\_position** in kms driver, plus a bit of setup code to provide a drm\_display\_mode that corresponds to the true scanout timing.

The current implementation only handles standard video modes. It returns as no operation if a doublescan or interlaced video mode is active. Higher level code is expected to handle this.

## RETURNS

Negative value on error, failure or if not supported in current

## VIDEO MODE

\-EINVAL - Invalid CRTC. -EAGAIN - Temporary unavailable, e.g., called before initial modeset. -ENOTSUPP - Function not supported in current display mode. -EIO - Failed, e.g., due to failed scanout position query.

Returns or'ed positive status flags on success:

DRM\_VBLANKTIME\_SCANOUTPOS\_METHOD - Signal this method used for timestamping. DRM\_VBLANKTIME\_INVBL - Timestamp taken while scanout was in vblank interval.

## AUTHORS

**Jesse Barnes** \<jesse.barnes@intel.com\>\
 Intel Corporation,

Initial version

**Laurent Pinchart** \<laurent.pinchart@ideasonboard.com\>\
 Ideas on board SPRL,

Driver internals

**Daniel Vetter** \<daniel.vetter@ffwll.ch\>\
 Intel Corporation,

Contributions all over the place

## COPYRIGHT
