Commit f5752b38 authored by Daniel Vetter's avatar Daniel Vetter

drm/irq: kerneldoc polish

- Integrate into the drm DocBook
- Disable kerneldoc for functions not exported to drivers.
- Properly document the new drm_vblank_on|off and add cautious
  comments explaining when drm_vblank_pre|post_modesets shouldn't be
  used.
- General polish and OCD.

v2: Polish as suggested by Thierry.

Cc: Thierry Reding <thierry.reding@gmail.com>
Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 8edffbb9
...@@ -2519,6 +2519,10 @@ void (*disable_vblank) (struct drm_device *dev, int crtc);</synopsis> ...@@ -2519,6 +2519,10 @@ void (*disable_vblank) (struct drm_device *dev, int crtc);</synopsis>
with a call to <function>drm_vblank_cleanup</function> in the driver with a call to <function>drm_vblank_cleanup</function> in the driver
<methodname>unload</methodname> operation handler. <methodname>unload</methodname> operation handler.
</para> </para>
<sect2>
<title>Vertical Blanking and Interrupt Handling Functions Reference</title>
!Edrivers/gpu/drm/drm_irq.c
</sect2>
</sect1> </sect1>
<!-- Internals: open/close, file operations and ioctls --> <!-- Internals: open/close, file operations and ioctls -->
...@@ -2871,7 +2875,6 @@ int num_ioctls;</synopsis> ...@@ -2871,7 +2875,6 @@ int num_ioctls;</synopsis>
</listitem> </listitem>
</varlistentry> </varlistentry>
</variablelist> </variablelist>
<!--!Edrivers/char/drm/drm_irq.c-->
</para> </para>
</sect1> </sect1>
......
/** /*
* \file drm_irq.c * drm_irq.c IRQ and vblank support
* IRQ support
* *
* \author Rickard E. (Rik) Faith <faith@valinux.com> * \author Rickard E. (Rik) Faith <faith@valinux.com>
* \author Gareth Hughes <gareth@valinux.com> * \author Gareth Hughes <gareth@valinux.com>
...@@ -156,6 +155,12 @@ static void vblank_disable_fn(unsigned long arg) ...@@ -156,6 +155,12 @@ static void vblank_disable_fn(unsigned long arg)
spin_unlock_irqrestore(&dev->vbl_lock, irqflags); spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
} }
/**
* drm_vblank_cleanup - cleanup vblank support
* @dev: DRM device
*
* This function cleans up any resources allocated in drm_vblank_init.
*/
void drm_vblank_cleanup(struct drm_device *dev) void drm_vblank_cleanup(struct drm_device *dev)
{ {
int crtc; int crtc;
...@@ -175,6 +180,16 @@ void drm_vblank_cleanup(struct drm_device *dev) ...@@ -175,6 +180,16 @@ void drm_vblank_cleanup(struct drm_device *dev)
} }
EXPORT_SYMBOL(drm_vblank_cleanup); EXPORT_SYMBOL(drm_vblank_cleanup);
/**
* drm_vblank_init - initialize vblank support
* @dev: drm_device
* @num_crtcs: number of crtcs supported by @dev
*
* This function initializes vblank support for @num_crtcs display pipelines.
*
* Returns:
* Zero on success or a negative error code on failure.
*/
int drm_vblank_init(struct drm_device *dev, int num_crtcs) int drm_vblank_init(struct drm_device *dev, int num_crtcs)
{ {
int i, ret = -ENOMEM; int i, ret = -ENOMEM;
...@@ -238,13 +253,21 @@ static void drm_irq_vgaarb_nokms(void *cookie, bool state) ...@@ -238,13 +253,21 @@ static void drm_irq_vgaarb_nokms(void *cookie, bool state)
} }
/** /**
* Install IRQ handler. * drm_irq_install - install IRQ handler
* * @dev: DRM device
* \param dev DRM device. * @irq: IRQ number to install the handler for
* *
* Initializes the IRQ related data. Installs the handler, calling the driver * Initializes the IRQ related data. Installs the handler, calling the driver
* \c irq_preinstall() and \c irq_postinstall() functions * irq_preinstall() and irq_postinstall() functions before and after the
* before and after the installation. * installation.
*
* This is the simplified helper interface provided for drivers with no special
* needs. Drivers which need to install interrupt handlers for multiple
* interrupts must instead set drm_device->irq_enabled to signal the DRM core
* that vblank interrupts are available.
*
* Returns:
* Zero on success or a negative error code on failure.
*/ */
int drm_irq_install(struct drm_device *dev, int irq) int drm_irq_install(struct drm_device *dev, int irq)
{ {
...@@ -304,11 +327,20 @@ int drm_irq_install(struct drm_device *dev, int irq) ...@@ -304,11 +327,20 @@ int drm_irq_install(struct drm_device *dev, int irq)
EXPORT_SYMBOL(drm_irq_install); EXPORT_SYMBOL(drm_irq_install);
/** /**
* Uninstall the IRQ handler. * drm_irq_uninstall - uninstall the IRQ handler
* @dev: DRM device
*
* Calls the driver's irq_uninstall() function and unregisters the IRQ handler.
* This should only be called by drivers which used drm_irq_install() to set up
* their interrupt handler. Other drivers must only reset
* drm_device->irq_enabled to false.
* *
* \param dev DRM device. * Note that for kernel modesetting drivers it is a bug if this function fails.
* The sanity checks are only to catch buggy user modesetting drivers which call
* the same function through an ioctl.
* *
* Calls the driver's \c irq_uninstall() function, and stops the irq. * Returns:
* Zero on success or a negative error code on failure.
*/ */
int drm_irq_uninstall(struct drm_device *dev) int drm_irq_uninstall(struct drm_device *dev)
{ {
...@@ -353,7 +385,7 @@ int drm_irq_uninstall(struct drm_device *dev) ...@@ -353,7 +385,7 @@ int drm_irq_uninstall(struct drm_device *dev)
} }
EXPORT_SYMBOL(drm_irq_uninstall); EXPORT_SYMBOL(drm_irq_uninstall);
/** /*
* IRQ control ioctl. * IRQ control ioctl.
* *
* \param inode device inode. * \param inode device inode.
...@@ -406,15 +438,14 @@ int drm_control(struct drm_device *dev, void *data, ...@@ -406,15 +438,14 @@ int drm_control(struct drm_device *dev, void *data,
} }
/** /**
* drm_calc_timestamping_constants - Calculate vblank timestamp constants * drm_calc_timestamping_constants - calculate vblank timestamp constants
* * @crtc: drm_crtc whose timestamp constants should be updated.
* @crtc drm_crtc whose timestamp constants should be updated. * @mode: display mode containing the scanout timings
* @mode display mode containing the scanout timings
* *
* Calculate and store various constants which are later * Calculate and store various constants which are later
* needed by vblank and swap-completion timestamping, e.g, * needed by vblank and swap-completion timestamping, e.g,
* by drm_calc_vbltimestamp_from_scanoutpos(). They are * by drm_calc_vbltimestamp_from_scanoutpos(). They are
* derived from crtc's true scanout timing, so they take * derived from CRTC's true scanout timing, so they take
* things like panel scaling or other adjustments into account. * things like panel scaling or other adjustments into account.
*/ */
void drm_calc_timestamping_constants(struct drm_crtc *crtc, void drm_calc_timestamping_constants(struct drm_crtc *crtc,
...@@ -459,11 +490,22 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc, ...@@ -459,11 +490,22 @@ 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 - helper routine for kms * drm_calc_vbltimestamp_from_scanoutpos - precise vblank timestamp helper
* drivers. Implements calculation of exact vblank timestamps from * @dev: DRM device
* given drm_display_mode timings and current video scanout position * @crtc: Which CRTC's vblank timestamp to retrieve
* of a crtc. This can be called from within get_vblank_timestamp() * @max_error: Desired maximum allowable error in timestamps (nanosecs)
* implementation of a kms driver to implement the actual timestamping. * 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
*
* 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 * Should return timestamps conforming to the OML_sync_control OpenML
* extension specification. The timestamp corresponds to the end of * extension specification. The timestamp corresponds to the end of
...@@ -478,21 +520,11 @@ EXPORT_SYMBOL(drm_calc_timestamping_constants); ...@@ -478,21 +520,11 @@ EXPORT_SYMBOL(drm_calc_timestamping_constants);
* returns as no operation if a doublescan or interlaced video mode is * returns as no operation if a doublescan or interlaced video mode is
* active. Higher level code is expected to handle this. * active. Higher level code is expected to handle this.
* *
* @dev: DRM device. * Returns:
* @crtc: Which crtc's vblank timestamp to retrieve. * Negative value on error, failure or if not supported in current
* @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: drm_crtc* of crtc which defines scanout timing.
* @mode: mode which defines the scanout timings
*
* Returns negative value on error, failure or if not supported in current
* video mode: * video mode:
* *
* -EINVAL - Invalid crtc. * -EINVAL - Invalid CRTC.
* -EAGAIN - Temporary unavailable, e.g., called before initial modeset. * -EAGAIN - Temporary unavailable, e.g., called before initial modeset.
* -ENOTSUPP - Function not supported in current display mode. * -ENOTSUPP - Function not supported in current display mode.
* -EIO - Failed, e.g., due to failed scanout position query. * -EIO - Failed, e.g., due to failed scanout position query.
...@@ -641,23 +673,23 @@ static struct timeval get_drm_timestamp(void) ...@@ -641,23 +673,23 @@ static struct timeval get_drm_timestamp(void)
/** /**
* drm_get_last_vbltimestamp - retrieve raw timestamp for the most recent * drm_get_last_vbltimestamp - retrieve raw timestamp for the most recent
* vblank interval. * vblank interval
*
* @dev: DRM device * @dev: DRM device
* @crtc: which crtc's vblank timestamp to retrieve * @crtc: which CRTC's vblank timestamp to retrieve
* @tvblank: Pointer to target struct timeval which should receive the timestamp * @tvblank: Pointer to target struct timeval which should receive the timestamp
* @flags: Flags to pass to driver: * @flags: Flags to pass to driver:
* 0 = Default. * 0 = Default,
* DRM_CALLED_FROM_VBLIRQ = If function is called from vbl irq handler. * DRM_CALLED_FROM_VBLIRQ = If function is called from vbl IRQ handler
* *
* Fetches the system timestamp corresponding to the time of the most recent * Fetches the system timestamp corresponding to the time of the most recent
* vblank interval on specified crtc. May call into kms-driver to * vblank interval on specified CRTC. May call into kms-driver to
* compute the timestamp with a high-precision GPU specific method. * compute the timestamp with a high-precision GPU specific method.
* *
* Returns zero if timestamp originates from uncorrected do_gettimeofday() * Returns zero if timestamp originates from uncorrected do_gettimeofday()
* call, i.e., it isn't very precisely locked to the true vblank. * call, i.e., it isn't very precisely locked to the true vblank.
* *
* Returns non-zero if timestamp is considered to be very precise. * Returns:
* Non-zero if timestamp is considered to be very precise, zero otherwise.
*/ */
u32 drm_get_last_vbltimestamp(struct drm_device *dev, int crtc, u32 drm_get_last_vbltimestamp(struct drm_device *dev, int crtc,
struct timeval *tvblank, unsigned flags) struct timeval *tvblank, unsigned flags)
...@@ -692,6 +724,9 @@ EXPORT_SYMBOL(drm_get_last_vbltimestamp); ...@@ -692,6 +724,9 @@ EXPORT_SYMBOL(drm_get_last_vbltimestamp);
* Fetches the "cooked" vblank count value that represents the number of * Fetches the "cooked" vblank count value that represents the number of
* vblank events since the system was booted, including lost events due to * vblank events since the system was booted, including lost events due to
* modesetting activity. * modesetting activity.
*
* Returns:
* The software vblank counter.
*/ */
u32 drm_vblank_count(struct drm_device *dev, int crtc) u32 drm_vblank_count(struct drm_device *dev, int crtc)
{ {
...@@ -710,8 +745,7 @@ EXPORT_SYMBOL(drm_vblank_count); ...@@ -710,8 +745,7 @@ EXPORT_SYMBOL(drm_vblank_count);
* Fetches the "cooked" vblank count value that represents the number of * Fetches the "cooked" vblank count value that represents the number of
* vblank events since the system was booted, including lost events due to * vblank events since the system was booted, including lost events due to
* modesetting activity. Returns corresponding system timestamp of the time * modesetting activity. Returns corresponding system timestamp of the time
* of the vblank interval that corresponds to the current value vblank counter * of the vblank interval that corresponds to the current vblank counter value.
* value.
*/ */
u32 drm_vblank_count_and_time(struct drm_device *dev, int crtc, u32 drm_vblank_count_and_time(struct drm_device *dev, int crtc,
struct timeval *vblanktime) struct timeval *vblanktime)
...@@ -882,7 +916,7 @@ static int drm_vblank_enable(struct drm_device *dev, int crtc) ...@@ -882,7 +916,7 @@ static int drm_vblank_enable(struct drm_device *dev, int crtc)
* Acquire a reference count on vblank events to avoid having them disabled * Acquire a reference count on vblank events to avoid having them disabled
* while in use. * while in use.
* *
* RETURNS * Returns:
* Zero on success, nonzero on failure. * Zero on success, nonzero on failure.
*/ */
int drm_vblank_get(struct drm_device *dev, int crtc) int drm_vblank_get(struct drm_device *dev, int crtc)
...@@ -930,6 +964,13 @@ EXPORT_SYMBOL(drm_vblank_put); ...@@ -930,6 +964,13 @@ EXPORT_SYMBOL(drm_vblank_put);
* drm_vblank_off - disable vblank events on a CRTC * drm_vblank_off - disable vblank events on a CRTC
* @dev: DRM device * @dev: DRM device
* @crtc: CRTC in question * @crtc: CRTC in question
*
* Drivers can use this function to shut down the vblank interrupt handling when
* disabling a crtc. This function ensures that the latest vblank frame count is
* stored so that drm_vblank_on() can restore it again.
*
* Drivers must use this function when the hardware vblank counter can get
* reset, e.g. when suspending.
*/ */
void drm_vblank_off(struct drm_device *dev, int crtc) void drm_vblank_off(struct drm_device *dev, int crtc)
{ {
...@@ -966,6 +1007,11 @@ EXPORT_SYMBOL(drm_vblank_off); ...@@ -966,6 +1007,11 @@ EXPORT_SYMBOL(drm_vblank_off);
* drm_vblank_on - enable vblank events on a CRTC * drm_vblank_on - enable vblank events on a CRTC
* @dev: DRM device * @dev: DRM device
* @crtc: CRTC in question * @crtc: CRTC in question
*
* This functions restores the vblank interrupt state captured with
* drm_vblank_off() again. Note that calls to drm_vblank_on() and
* drm_vblank_off() can be unbalanced and so can also be unconditionaly called
* in driver load code to reflect the current hardware state of the crtc.
*/ */
void drm_vblank_on(struct drm_device *dev, int crtc) void drm_vblank_on(struct drm_device *dev, int crtc)
{ {
...@@ -986,6 +1032,21 @@ EXPORT_SYMBOL(drm_vblank_on); ...@@ -986,6 +1032,21 @@ EXPORT_SYMBOL(drm_vblank_on);
* *
* Account for vblank events across mode setting events, which will likely * Account for vblank events across mode setting events, which will likely
* reset the hardware frame counter. * reset the hardware frame counter.
*
* This is done by grabbing a temporary vblank reference to ensure that the
* vblank interrupt keeps running across the modeset sequence. With this the
* software-side vblank frame counting will ensure that there are no jumps or
* discontinuities.
*
* Unfortunately this approach is racy and also doesn't work when the vblank
* interrupt stops running, e.g. across system suspend resume. It is therefore
* highly recommended that drivers use the newer drm_vblank_off() and
* drm_vblank_on() instead. drm_vblank_pre_modeset() only works correctly when
* using "cooked" software vblank frame counters and not relying on any hardware
* counters.
*
* Drivers must call drm_vblank_post_modeset() when re-enabling the same crtc
* again.
*/ */
void drm_vblank_pre_modeset(struct drm_device *dev, int crtc) void drm_vblank_pre_modeset(struct drm_device *dev, int crtc)
{ {
...@@ -1007,6 +1068,14 @@ void drm_vblank_pre_modeset(struct drm_device *dev, int crtc) ...@@ -1007,6 +1068,14 @@ void drm_vblank_pre_modeset(struct drm_device *dev, int crtc)
} }
EXPORT_SYMBOL(drm_vblank_pre_modeset); EXPORT_SYMBOL(drm_vblank_pre_modeset);
/**
* drm_vblank_post_modeset - undo drm_vblank_pre_modeset changes
* @dev: DRM device
* @crtc: CRTC in question
*
* This function again drops the temporary vblank reference acquired in
* drm_vblank_pre_modeset.
*/
void drm_vblank_post_modeset(struct drm_device *dev, int crtc) void drm_vblank_post_modeset(struct drm_device *dev, int crtc)
{ {
unsigned long irqflags; unsigned long irqflags;
...@@ -1028,7 +1097,7 @@ void drm_vblank_post_modeset(struct drm_device *dev, int crtc) ...@@ -1028,7 +1097,7 @@ void drm_vblank_post_modeset(struct drm_device *dev, int crtc)
} }
EXPORT_SYMBOL(drm_vblank_post_modeset); EXPORT_SYMBOL(drm_vblank_post_modeset);
/** /*
* drm_modeset_ctl - handle vblank event counter changes across mode switch * drm_modeset_ctl - handle vblank event counter changes across mode switch
* @DRM_IOCTL_ARGS: standard ioctl arguments * @DRM_IOCTL_ARGS: standard ioctl arguments
* *
...@@ -1141,7 +1210,7 @@ static int drm_queue_vblank_event(struct drm_device *dev, int pipe, ...@@ -1141,7 +1210,7 @@ static int drm_queue_vblank_event(struct drm_device *dev, int pipe,
return ret; return ret;
} }
/** /*
* Wait for VBLANK. * Wait for VBLANK.
* *
* \param inode device inode. * \param inode device inode.
...@@ -1152,7 +1221,7 @@ static int drm_queue_vblank_event(struct drm_device *dev, int pipe, ...@@ -1152,7 +1221,7 @@ static int drm_queue_vblank_event(struct drm_device *dev, int pipe,
* *
* This function enables the vblank interrupt on the pipe requested, then * This function enables the vblank interrupt on the pipe requested, then
* sleeps waiting for the requested sequence number to occur, and drops * sleeps waiting for the requested sequence number to occur, and drops
* the vblank interrupt refcount afterwards. (vblank irq disable follows that * the vblank interrupt refcount afterwards. (vblank IRQ disable follows that
* after a timeout with no further vblank waits scheduled). * after a timeout with no further vblank waits scheduled).
*/ */
int drm_wait_vblank(struct drm_device *dev, void *data, int drm_wait_vblank(struct drm_device *dev, void *data,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment