Rev 4104 | Rev 4539 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4104 | Rev 4293 | ||
---|---|---|---|
Line 82... | Line 82... | ||
82 | { |
82 | { |
83 | int ret; |
83 | int ret; |
84 | unsigned long sh_flags = 0; |
84 | unsigned long sh_flags = 0; |
85 | char *irqname; |
85 | char *irqname; |
Line -... | Line 86... | ||
- | 86 | ||
- | 87 | if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) |
|
Line 86... | Line 88... | ||
86 | 88 | return -EINVAL; |
|
87 | 89 | ||
Line 88... | Line 90... | ||
88 | if (drm_dev_to_irq(dev) == 0) |
90 | if (drm_dev_to_irq(dev) == 0) |
Line 200... | Line 202... | ||
200 | crtc->hwmode.crtc_vtotal, crtc->hwmode.crtc_vdisplay); |
202 | crtc->hwmode.crtc_vtotal, crtc->hwmode.crtc_vdisplay); |
201 | DRM_DEBUG("crtc %d: clock %d kHz framedur %d linedur %d, pixeldur %d\n", |
203 | DRM_DEBUG("crtc %d: clock %d kHz framedur %d linedur %d, pixeldur %d\n", |
202 | crtc->base.id, (int) dotclock/1000, (int) framedur_ns, |
204 | crtc->base.id, (int) dotclock/1000, (int) framedur_ns, |
203 | (int) linedur_ns, (int) pixeldur_ns); |
205 | (int) linedur_ns, (int) pixeldur_ns); |
204 | } |
206 | } |
- | 207 | EXPORT_SYMBOL(drm_calc_timestamping_constants); |
|
- | 208 | ||
- | 209 | /** |
|
- | 210 | * drm_calc_vbltimestamp_from_scanoutpos - helper routine for kms |
|
- | 211 | * drivers. Implements calculation of exact vblank timestamps from |
|
- | 212 | * given drm_display_mode timings and current video scanout position |
|
- | 213 | * of a crtc. This can be called from within get_vblank_timestamp() |
|
- | 214 | * implementation of a kms driver to implement the actual timestamping. |
|
- | 215 | * |
|
- | 216 | * Should return timestamps conforming to the OML_sync_control OpenML |
|
- | 217 | * extension specification. The timestamp corresponds to the end of |
|
- | 218 | * the vblank interval, aka start of scanout of topmost-leftmost display |
|
- | 219 | * pixel in the following video frame. |
|
- | 220 | * |
|
- | 221 | * Requires support for optional dev->driver->get_scanout_position() |
|
- | 222 | * in kms driver, plus a bit of setup code to provide a drm_display_mode |
|
- | 223 | * that corresponds to the true scanout timing. |
|
- | 224 | * |
|
- | 225 | * The current implementation only handles standard video modes. It |
|
- | 226 | * returns as no operation if a doublescan or interlaced video mode is |
|
- | 227 | * active. Higher level code is expected to handle this. |
|
- | 228 | * |
|
- | 229 | * @dev: DRM device. |
|
- | 230 | * @crtc: Which crtc's vblank timestamp to retrieve. |
|
- | 231 | * @max_error: Desired maximum allowable error in timestamps (nanosecs). |
|
- | 232 | * On return contains true maximum error of timestamp. |
|
- | 233 | * @vblank_time: Pointer to struct timeval which should receive the timestamp. |
|
- | 234 | * @flags: Flags to pass to driver: |
|
- | 235 | * 0 = Default. |
|
- | 236 | * DRM_CALLED_FROM_VBLIRQ = If function is called from vbl irq handler. |
|
- | 237 | * @refcrtc: drm_crtc* of crtc which defines scanout timing. |
|
- | 238 | * |
|
- | 239 | * Returns negative value on error, failure or if not supported in current |
|
- | 240 | * video mode: |
|
- | 241 | * |
|
- | 242 | * -EINVAL - Invalid crtc. |
|
- | 243 | * -EAGAIN - Temporary unavailable, e.g., called before initial modeset. |
|
- | 244 | * -ENOTSUPP - Function not supported in current display mode. |
|
- | 245 | * -EIO - Failed, e.g., due to failed scanout position query. |
|
- | 246 | * |
|
- | 247 | * Returns or'ed positive status flags on success: |
|
- | 248 | * |
|
- | 249 | * DRM_VBLANKTIME_SCANOUTPOS_METHOD - Signal this method used for timestamping. |
|
- | 250 | * DRM_VBLANKTIME_INVBL - Timestamp taken while scanout was in vblank interval. |
|
- | 251 | * |
|
- | 252 | */ |
|
- | 253 | int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, int crtc, |
|
- | 254 | int *max_error, |
|
- | 255 | struct timeval *vblank_time, |
|
- | 256 | unsigned flags, |
|
- | 257 | struct drm_crtc *refcrtc) |
|
- | 258 | { |
|
- | 259 | // ktime_t stime, etime, mono_time_offset; |
|
- | 260 | struct timeval tv_etime; |
|
- | 261 | struct drm_display_mode *mode; |
|
- | 262 | int vbl_status, vtotal, vdisplay; |
|
- | 263 | int vpos, hpos, i; |
|
- | 264 | s64 framedur_ns, linedur_ns, pixeldur_ns, delta_ns, duration_ns; |
|
- | 265 | bool invbl; |
|
- | 266 | ||
- | 267 | if (crtc < 0 || crtc >= dev->num_crtcs) { |
|
- | 268 | DRM_ERROR("Invalid crtc %d\n", crtc); |
|
- | 269 | return -EINVAL; |
|
- | 270 | } |
|
- | 271 | ||
- | 272 | /* Scanout position query not supported? Should not happen. */ |
|
- | 273 | if (!dev->driver->get_scanout_position) { |
|
- | 274 | DRM_ERROR("Called from driver w/o get_scanout_position()!?\n"); |
|
- | 275 | return -EIO; |
|
- | 276 | } |
|
- | 277 | ||
- | 278 | mode = &refcrtc->hwmode; |
|
- | 279 | vtotal = mode->crtc_vtotal; |
|
- | 280 | vdisplay = mode->crtc_vdisplay; |
|
- | 281 | ||
- | 282 | /* Durations of frames, lines, pixels in nanoseconds. */ |
|
- | 283 | framedur_ns = refcrtc->framedur_ns; |
|
- | 284 | linedur_ns = refcrtc->linedur_ns; |
|
- | 285 | pixeldur_ns = refcrtc->pixeldur_ns; |
|
- | 286 | ||
- | 287 | /* If mode timing undefined, just return as no-op: |
|
- | 288 | * Happens during initial modesetting of a crtc. |
|
- | 289 | */ |
|
- | 290 | if (vtotal <= 0 || vdisplay <= 0 || framedur_ns == 0) { |
|
- | 291 | DRM_DEBUG("crtc %d: Noop due to uninitialized mode.\n", crtc); |
|
- | 292 | return -EAGAIN; |
|
- | 293 | } |
|
- | 294 | ||
- | 295 | return -EIO; |
|
- | 296 | } |
|
- | 297 | EXPORT_SYMBOL(drm_calc_vbltimestamp_from_scanoutpos); |
|
Line 205... | Line 298... | ||
205 | 298 | ||
206 | 299 | ||
207 | /** |
300 | /** |