write_sequnlock(&vblank->seqlock);
}
+static u32 __get_vblank_counter(struct drm_device *dev, unsigned int pipe)
+{
+ if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+ struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
+
+ if (crtc->funcs->get_vblank_counter)
+ return crtc->funcs->get_vblank_counter(crtc);
+ }
+
+ if (dev->driver->get_vblank_counter)
+ return dev->driver->get_vblank_counter(dev, pipe);
+
+ return drm_vblank_no_hw_counter(dev, pipe);
+}
+
/*
* Reset the stored timestamp for the current vblank count to correspond
* to the last vblank occurred.
* when drm_vblank_enable() applies the diff
*/
do {
- cur_vblank = dev->driver->get_vblank_counter(dev, pipe);
+ cur_vblank = __get_vblank_counter(dev, pipe);
rc = drm_get_last_vbltimestamp(dev, pipe, &t_vblank, 0);
- } while (cur_vblank != dev->driver->get_vblank_counter(dev, pipe) && --count > 0);
+ } while (cur_vblank != __get_vblank_counter(dev, pipe) && --count > 0);
/*
* Only reinitialize corresponding vblank timestamp if high-precision query
* corresponding vblank timestamp.
*/
do {
- cur_vblank = dev->driver->get_vblank_counter(dev, pipe);
+ cur_vblank = __get_vblank_counter(dev, pipe);
rc = drm_get_last_vbltimestamp(dev, pipe, &t_vblank, flags);
- } while (cur_vblank != dev->driver->get_vblank_counter(dev, pipe) && --count > 0);
+ } while (cur_vblank != __get_vblank_counter(dev, pipe) && --count > 0);
if (dev->max_vblank_count != 0) {
/* trust the hw counter when it's around */
}
EXPORT_SYMBOL(drm_accurate_vblank_count);
+static void __disable_vblank(struct drm_device *dev, unsigned int pipe)
+{
+ if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+ struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
+
+ if (crtc->funcs->disable_vblank) {
+ crtc->funcs->disable_vblank(crtc);
+ return;
+ }
+ }
+
+ dev->driver->disable_vblank(dev, pipe);
+}
+
/*
* Disable vblank irq's on crtc, make sure that last vblank count
* of hardware and corresponding consistent software vblank counter
* hardware potentially runtime suspended.
*/
if (vblank->enabled) {
- dev->driver->disable_vblank(dev, pipe);
+ __disable_vblank(dev, pipe);
vblank->enabled = false;
}
}
EXPORT_SYMBOL(drm_crtc_send_vblank_event);
+static int __enable_vblank(struct drm_device *dev, unsigned int pipe)
+{
+ if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+ struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
+
+ if (crtc->funcs->enable_vblank)
+ return crtc->funcs->enable_vblank(crtc);
+ }
+
+ return dev->driver->enable_vblank(dev, pipe);
+}
+
/**
* drm_vblank_enable - enable the vblank interrupt on a CRTC
* @dev: DRM device
* timestamps. Filtercode in drm_handle_vblank() will
* prevent double-accounting of same vblank interval.
*/
- ret = dev->driver->enable_vblank(dev, pipe);
+ ret = __enable_vblank(dev, pipe);
DRM_DEBUG("enabling vblank on crtc %u, ret: %d\n", pipe, ret);
if (ret)
atomic_dec(&vblank->refcount);
*/
void (*atomic_print_state)(struct drm_printer *p,
const struct drm_crtc_state *state);
+
+ /**
+ * @get_vblank_counter:
+ *
+ * Driver callback for fetching a raw hardware vblank counter for the
+ * CRTC. It's meant to be used by new drivers as the replacement of
+ * &drm_driver.get_vblank_counter hook.
+ *
+ * This callback is optional. If a device doesn't have a hardware
+ * counter, the driver can simply leave the hook as NULL. The DRM core
+ * will account for missed vblank events while interrupts where disabled
+ * based on system timestamps.
+ *
+ * Wraparound handling and loss of events due to modesetting is dealt
+ * with in the DRM core code, as long as drivers call
+ * drm_crtc_vblank_off() and drm_crtc_vblank_on() when disabling or
+ * enabling a CRTC.
+ *
+ * Returns:
+ *
+ * Raw vblank counter value.
+ */
+ u32 (*get_vblank_counter)(struct drm_crtc *crtc);
+
+ /**
+ * @enable_vblank:
+ *
+ * Enable vblank interrupts for the CRTC. It's meant to be used by
+ * new drivers as the replacement of &drm_driver.enable_vblank hook.
+ *
+ * Returns:
+ *
+ * Zero on success, appropriate errno if the vblank interrupt cannot
+ * be enabled.
+ */
+ int (*enable_vblank)(struct drm_crtc *crtc);
+
+ /**
+ * @disable_vblank:
+ *
+ * Disable vblank interrupts for the CRTC. It's meant to be used by
+ * new drivers as the replacement of &drm_driver.disable_vblank hook.
+ */
+ void (*disable_vblank)(struct drm_crtc *crtc);
};
/**
* drm_crtc_vblank_off() and drm_crtc_vblank_on() when disabling or
* enabling a CRTC.
*
+ * This is deprecated and should not be used by new drivers.
+ * Use &drm_crtc_funcs.get_vblank_counter instead.
+ *
* Returns:
*
* Raw vblank counter value.
* Enable vblank interrupts for the CRTC specified with the pipe
* argument.
*
+ * This is deprecated and should not be used by new drivers.
+ * Use &drm_crtc_funcs.enable_vblank instead.
+ *
* Returns:
*
* Zero on success, appropriate errno if the given @crtc's vblank
*
* Disable vblank interrupts for the CRTC specified with the pipe
* argument.
+ *
+ * This is deprecated and should not be used by new drivers.
+ * Use &drm_crtc_funcs.disable_vblank instead.
*/
void (*disable_vblank) (struct drm_device *dev, unsigned int pipe);