mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-09 23:00:21 +00:00
drm: Clean-up VBLANK-related callbacks in struct drm_driver
All non-legacy users of VBLANK functions in struct drm_driver have been converted to use the respective interfaces in struct drm_crtc_funcs. The remaining users of VBLANK callbacks in struct drm_driver are legacy drivers with userspace modesetting. All users of struct drm_driver.get_scanout_position() have been converted to the respective CRTC helper function. Remove the callback from struct drm_driver. There are no users left of get_vblank_timestamp(), so the callback is being removed. The other VBLANK callbacks are being moved to the legacy section at the end of struct drm_driver. Also removed is drm_calc_vbltimestamp_from_scanoutpos(). Callers of this function have been converted to use the CRTC instead. v4: * more readable code for setting high_prec (Ville, Jani) v2: * merge with removal of struct drm_driver.get_scanout_position() * remove drm_calc_vbltimestamp_from_scanoutpos() Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Tested-by: Yannick Fertré <yannick.fertre@st.com> Link: https://patchwork.freedesktop.org/patch/msgid/20200123135943.24140-22-tzimmermann@suse.de
This commit is contained in:
parent
4bebe91adb
commit
f397d66b31
@ -144,10 +144,9 @@ static u32 __get_vblank_counter(struct drm_device *dev, unsigned int pipe)
|
|||||||
|
|
||||||
if (crtc->funcs->get_vblank_counter)
|
if (crtc->funcs->get_vblank_counter)
|
||||||
return crtc->funcs->get_vblank_counter(crtc);
|
return crtc->funcs->get_vblank_counter(crtc);
|
||||||
}
|
} else if (dev->driver->get_vblank_counter) {
|
||||||
|
|
||||||
if (dev->driver->get_vblank_counter)
|
|
||||||
return dev->driver->get_vblank_counter(dev, pipe);
|
return dev->driver->get_vblank_counter(dev, pipe);
|
||||||
|
}
|
||||||
|
|
||||||
return drm_vblank_no_hw_counter(dev, pipe);
|
return drm_vblank_no_hw_counter(dev, pipe);
|
||||||
}
|
}
|
||||||
@ -340,8 +339,7 @@ u64 drm_crtc_accurate_vblank_count(struct drm_crtc *crtc)
|
|||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
WARN_ONCE(drm_debug_enabled(DRM_UT_VBL) &&
|
WARN_ONCE(drm_debug_enabled(DRM_UT_VBL) &&
|
||||||
!crtc->funcs->get_vblank_timestamp &&
|
!crtc->funcs->get_vblank_timestamp,
|
||||||
!dev->driver->get_vblank_timestamp,
|
|
||||||
"This function requires support for accurate vblank timestamps.");
|
"This function requires support for accurate vblank timestamps.");
|
||||||
|
|
||||||
spin_lock_irqsave(&dev->vblank_time_lock, flags);
|
spin_lock_irqsave(&dev->vblank_time_lock, flags);
|
||||||
@ -363,13 +361,11 @@ static void __disable_vblank(struct drm_device *dev, unsigned int pipe)
|
|||||||
if (WARN_ON(!crtc))
|
if (WARN_ON(!crtc))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (crtc->funcs->disable_vblank) {
|
if (crtc->funcs->disable_vblank)
|
||||||
crtc->funcs->disable_vblank(crtc);
|
crtc->funcs->disable_vblank(crtc);
|
||||||
return;
|
} else {
|
||||||
}
|
dev->driver->disable_vblank(dev, pipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
dev->driver->disable_vblank(dev, pipe);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -593,62 +589,6 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc,
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(drm_calc_timestamping_constants);
|
EXPORT_SYMBOL(drm_calc_timestamping_constants);
|
||||||
|
|
||||||
/**
|
|
||||||
* drm_calc_vbltimestamp_from_scanoutpos - precise vblank timestamp helper
|
|
||||||
* @dev: DRM device
|
|
||||||
* @pipe: index of CRTC whose 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 time which should receive the timestamp
|
|
||||||
* @in_vblank_irq:
|
|
||||||
* True when called from drm_crtc_handle_vblank(). Some drivers
|
|
||||||
* need to apply some workarounds for gpu-specific vblank irq quirks
|
|
||||||
* if flag is set.
|
|
||||||
*
|
|
||||||
* Implements calculation of exact vblank timestamps from given drm_display_mode
|
|
||||||
* timings and current video scanout position of a CRTC. This can be directly
|
|
||||||
* used as the &drm_crtc_funcs.get_vblank_timestamp implementation of a kms
|
|
||||||
* driver if &drm_crtc_helper_funcs.get_scanout_position or
|
|
||||||
* &drm_driver.get_scanout_position is implemented.
|
|
||||||
*
|
|
||||||
* The current implementation only handles standard video modes. For double scan
|
|
||||||
* and interlaced modes the driver is supposed to adjust the hardware mode
|
|
||||||
* (taken from &drm_crtc_state.adjusted mode for atomic modeset drivers) to
|
|
||||||
* match the scanout position reported.
|
|
||||||
*
|
|
||||||
* Note that atomic drivers must call drm_calc_timestamping_constants() before
|
|
||||||
* enabling a CRTC. The atomic helpers already take care of that in
|
|
||||||
* drm_atomic_helper_update_legacy_modeset_state().
|
|
||||||
*
|
|
||||||
* Returns:
|
|
||||||
*
|
|
||||||
* Returns true on success, and false on failure, i.e. when no accurate
|
|
||||||
* timestamp could be acquired.
|
|
||||||
*/
|
|
||||||
bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
|
|
||||||
unsigned int pipe,
|
|
||||||
int *max_error,
|
|
||||||
ktime_t *vblank_time,
|
|
||||||
bool in_vblank_irq)
|
|
||||||
{
|
|
||||||
struct drm_crtc *crtc;
|
|
||||||
|
|
||||||
if (!drm_core_check_feature(dev, DRIVER_MODESET))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
crtc = drm_crtc_from_index(dev, pipe);
|
|
||||||
if (!crtc)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return drm_crtc_vblank_helper_get_vblank_timestamp_internal(crtc,
|
|
||||||
max_error,
|
|
||||||
vblank_time,
|
|
||||||
in_vblank_irq,
|
|
||||||
crtc->helper_private->get_scanout_position,
|
|
||||||
dev->driver->get_scanout_position);
|
|
||||||
}
|
|
||||||
EXPORT_SYMBOL(drm_calc_vbltimestamp_from_scanoutpos);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* drm_crtc_vblank_helper_get_vblank_timestamp_internal - precise vblank
|
* drm_crtc_vblank_helper_get_vblank_timestamp_internal - precise vblank
|
||||||
* timestamp helper
|
* timestamp helper
|
||||||
@ -884,9 +824,6 @@ drm_get_last_vbltimestamp(struct drm_device *dev, unsigned int pipe,
|
|||||||
|
|
||||||
ret = crtc->funcs->get_vblank_timestamp(crtc, &max_error,
|
ret = crtc->funcs->get_vblank_timestamp(crtc, &max_error,
|
||||||
tvblank, in_vblank_irq);
|
tvblank, in_vblank_irq);
|
||||||
} else if (dev->driver->get_vblank_timestamp && max_error > 0) {
|
|
||||||
ret = dev->driver->get_vblank_timestamp(dev, pipe, &max_error,
|
|
||||||
tvblank, in_vblank_irq);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* GPU high precision timestamp query unsupported or failed.
|
/* GPU high precision timestamp query unsupported or failed.
|
||||||
@ -1109,9 +1046,11 @@ static int __enable_vblank(struct drm_device *dev, unsigned int pipe)
|
|||||||
|
|
||||||
if (crtc->funcs->enable_vblank)
|
if (crtc->funcs->enable_vblank)
|
||||||
return crtc->funcs->enable_vblank(crtc);
|
return crtc->funcs->enable_vblank(crtc);
|
||||||
|
} else if (dev->driver->enable_vblank) {
|
||||||
|
return dev->driver->enable_vblank(dev, pipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
return dev->driver->enable_vblank(dev, pipe);
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int drm_vblank_enable(struct drm_device *dev, unsigned int pipe)
|
static int drm_vblank_enable(struct drm_device *dev, unsigned int pipe)
|
||||||
@ -1896,8 +1835,6 @@ static void drm_handle_vblank_events(struct drm_device *dev, unsigned int pipe)
|
|||||||
|
|
||||||
if (crtc && crtc->funcs->get_vblank_timestamp)
|
if (crtc && crtc->funcs->get_vblank_timestamp)
|
||||||
high_prec = true;
|
high_prec = true;
|
||||||
else if (dev->driver->get_vblank_timestamp)
|
|
||||||
high_prec = true;
|
|
||||||
|
|
||||||
trace_drm_vblank_event(pipe, seq, now, high_prec);
|
trace_drm_vblank_event(pipe, seq, now, high_prec);
|
||||||
}
|
}
|
||||||
|
@ -268,156 +268,6 @@ struct drm_driver {
|
|||||||
*/
|
*/
|
||||||
void (*release) (struct drm_device *);
|
void (*release) (struct drm_device *);
|
||||||
|
|
||||||
/**
|
|
||||||
* @get_vblank_counter:
|
|
||||||
*
|
|
||||||
* Driver callback for fetching a raw hardware vblank counter for the
|
|
||||||
* CRTC specified with the pipe argument. 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.
|
|
||||||
*
|
|
||||||
* This is deprecated and should not be used by new drivers.
|
|
||||||
* Use &drm_crtc_funcs.get_vblank_counter instead.
|
|
||||||
*
|
|
||||||
* Returns:
|
|
||||||
*
|
|
||||||
* Raw vblank counter value.
|
|
||||||
*/
|
|
||||||
u32 (*get_vblank_counter) (struct drm_device *dev, unsigned int pipe);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @enable_vblank:
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
* interrupt cannot be enabled.
|
|
||||||
*/
|
|
||||||
int (*enable_vblank) (struct drm_device *dev, unsigned int pipe);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @disable_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);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @get_scanout_position:
|
|
||||||
*
|
|
||||||
* Called by vblank timestamping code.
|
|
||||||
*
|
|
||||||
* Returns the current display scanout position from a crtc, and an
|
|
||||||
* optional accurate ktime_get() timestamp of when position was
|
|
||||||
* measured. Note that this is a helper callback which is only used if a
|
|
||||||
* driver uses drm_calc_vbltimestamp_from_scanoutpos() for the
|
|
||||||
* @get_vblank_timestamp callback.
|
|
||||||
*
|
|
||||||
* Parameters:
|
|
||||||
*
|
|
||||||
* dev:
|
|
||||||
* DRM device.
|
|
||||||
* pipe:
|
|
||||||
* Id of the crtc to query.
|
|
||||||
* in_vblank_irq:
|
|
||||||
* True when called from drm_crtc_handle_vblank(). Some drivers
|
|
||||||
* need to apply some workarounds for gpu-specific vblank irq quirks
|
|
||||||
* if flag is set.
|
|
||||||
* vpos:
|
|
||||||
* Target location for current vertical scanout position.
|
|
||||||
* hpos:
|
|
||||||
* Target location for current horizontal scanout position.
|
|
||||||
* stime:
|
|
||||||
* Target location for timestamp taken immediately before
|
|
||||||
* scanout position query. Can be NULL to skip timestamp.
|
|
||||||
* etime:
|
|
||||||
* Target location for timestamp taken immediately after
|
|
||||||
* scanout position query. Can be NULL to skip timestamp.
|
|
||||||
* mode:
|
|
||||||
* Current display timings.
|
|
||||||
*
|
|
||||||
* Returns vpos as a positive number while in active scanout area.
|
|
||||||
* Returns vpos as a negative number inside vblank, counting the number
|
|
||||||
* of scanlines to go until end of vblank, e.g., -1 means "one scanline
|
|
||||||
* until start of active scanout / end of vblank."
|
|
||||||
*
|
|
||||||
* Returns:
|
|
||||||
*
|
|
||||||
* True on success, false if a reliable scanout position counter could
|
|
||||||
* not be read out.
|
|
||||||
*
|
|
||||||
* This is deprecated and should not be used by new drivers.
|
|
||||||
* Use &drm_crtc_helper_funcs.get_scanout_position instead.
|
|
||||||
*/
|
|
||||||
bool (*get_scanout_position) (struct drm_device *dev, unsigned int pipe,
|
|
||||||
bool in_vblank_irq, int *vpos, int *hpos,
|
|
||||||
ktime_t *stime, ktime_t *etime,
|
|
||||||
const struct drm_display_mode *mode);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @get_vblank_timestamp:
|
|
||||||
*
|
|
||||||
* Called by drm_get_last_vbltimestamp(). Should return a precise
|
|
||||||
* timestamp when the most recent VBLANK interval ended or will end.
|
|
||||||
*
|
|
||||||
* Specifically, the timestamp in @vblank_time should correspond as
|
|
||||||
* closely as possible to the time when the first video scanline of
|
|
||||||
* the video frame after the end of VBLANK will start scanning out,
|
|
||||||
* the time immediately after end of the VBLANK interval. If the
|
|
||||||
* @crtc is currently inside VBLANK, this will be a time in the future.
|
|
||||||
* If the @crtc is currently scanning out a frame, this will be the
|
|
||||||
* past start time of the current scanout. This is meant to adhere
|
|
||||||
* to the OpenML OML_sync_control extension specification.
|
|
||||||
*
|
|
||||||
* Paramters:
|
|
||||||
*
|
|
||||||
* dev:
|
|
||||||
* dev DRM device handle.
|
|
||||||
* pipe:
|
|
||||||
* crtc for which timestamp should be returned.
|
|
||||||
* max_error:
|
|
||||||
* Maximum allowable timestamp error in nanoseconds.
|
|
||||||
* Implementation should strive to provide timestamp
|
|
||||||
* with an error of at most max_error nanoseconds.
|
|
||||||
* Returns true upper bound on error for timestamp.
|
|
||||||
* vblank_time:
|
|
||||||
* Target location for returned vblank timestamp.
|
|
||||||
* in_vblank_irq:
|
|
||||||
* True when called from drm_crtc_handle_vblank(). Some drivers
|
|
||||||
* need to apply some workarounds for gpu-specific vblank irq quirks
|
|
||||||
* if flag is set.
|
|
||||||
*
|
|
||||||
* Returns:
|
|
||||||
*
|
|
||||||
* True on success, false on failure, which means the core should
|
|
||||||
* fallback to a simple timestamp taken in drm_crtc_handle_vblank().
|
|
||||||
*
|
|
||||||
* FIXME:
|
|
||||||
*
|
|
||||||
* We should move this hook to &struct drm_crtc_funcs like all the other
|
|
||||||
* vblank hooks.
|
|
||||||
*/
|
|
||||||
bool (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe,
|
|
||||||
int *max_error,
|
|
||||||
ktime_t *vblank_time,
|
|
||||||
bool in_vblank_irq);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @irq_handler:
|
* @irq_handler:
|
||||||
*
|
*
|
||||||
@ -758,6 +608,9 @@ struct drm_driver {
|
|||||||
int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv);
|
int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv);
|
||||||
int (*dma_quiescent) (struct drm_device *);
|
int (*dma_quiescent) (struct drm_device *);
|
||||||
int (*context_dtor) (struct drm_device *dev, int context);
|
int (*context_dtor) (struct drm_device *dev, int context);
|
||||||
|
u32 (*get_vblank_counter)(struct drm_device *dev, unsigned int pipe);
|
||||||
|
int (*enable_vblank)(struct drm_device *dev, unsigned int pipe);
|
||||||
|
void (*disable_vblank)(struct drm_device *dev, unsigned int pipe);
|
||||||
int dev_priv_size;
|
int dev_priv_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -230,10 +230,6 @@ u64 drm_crtc_accurate_vblank_count(struct drm_crtc *crtc);
|
|||||||
void drm_vblank_restore(struct drm_device *dev, unsigned int pipe);
|
void drm_vblank_restore(struct drm_device *dev, unsigned int pipe);
|
||||||
void drm_crtc_vblank_restore(struct drm_crtc *crtc);
|
void drm_crtc_vblank_restore(struct drm_crtc *crtc);
|
||||||
|
|
||||||
bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
|
|
||||||
unsigned int pipe, int *max_error,
|
|
||||||
ktime_t *vblank_time,
|
|
||||||
bool in_vblank_irq);
|
|
||||||
void drm_calc_timestamping_constants(struct drm_crtc *crtc,
|
void drm_calc_timestamping_constants(struct drm_crtc *crtc,
|
||||||
const struct drm_display_mode *mode);
|
const struct drm_display_mode *mode);
|
||||||
wait_queue_head_t *drm_crtc_vblank_waitqueue(struct drm_crtc *crtc);
|
wait_queue_head_t *drm_crtc_vblank_waitqueue(struct drm_crtc *crtc);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user