Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
drm_irq.c File Reference
#include <drm/drmP.h>
#include "drm_trace.h"
#include <linux/interrupt.h>
#include <linux/slab.h>
#include <linux/vgaarb.h>
#include <linux/export.h>

Go to the source code of this file.

Macros

#define vblanktimestamp(dev, crtc, count)
 
#define DRM_TIMESTAMP_MAXRETRIES   3
 
#define DRM_REDUNDANT_VBLIRQ_THRESH_NS   1000000
 

Functions

int drm_irq_by_busid (struct drm_device *dev, void *data, struct drm_file *file_priv)
 
void drm_vblank_cleanup (struct drm_device *dev)
 
 EXPORT_SYMBOL (drm_vblank_cleanup)
 
int drm_vblank_init (struct drm_device *dev, int num_crtcs)
 
 EXPORT_SYMBOL (drm_vblank_init)
 
int drm_irq_install (struct drm_device *dev)
 
 EXPORT_SYMBOL (drm_irq_install)
 
int drm_irq_uninstall (struct drm_device *dev)
 
 EXPORT_SYMBOL (drm_irq_uninstall)
 
int drm_control (struct drm_device *dev, void *data, struct drm_file *file_priv)
 
void drm_calc_timestamping_constants (struct drm_crtc *crtc)
 
 EXPORT_SYMBOL (drm_calc_timestamping_constants)
 
int drm_calc_vbltimestamp_from_scanoutpos (struct drm_device *dev, int crtc, int *max_error, struct timeval *vblank_time, unsigned flags, struct drm_crtc *refcrtc)
 
 EXPORT_SYMBOL (drm_calc_vbltimestamp_from_scanoutpos)
 
u32 drm_get_last_vbltimestamp (struct drm_device *dev, int crtc, struct timeval *tvblank, unsigned flags)
 
 EXPORT_SYMBOL (drm_get_last_vbltimestamp)
 
u32 drm_vblank_count (struct drm_device *dev, int crtc)
 
 EXPORT_SYMBOL (drm_vblank_count)
 
u32 drm_vblank_count_and_time (struct drm_device *dev, int crtc, struct timeval *vblanktime)
 
 EXPORT_SYMBOL (drm_vblank_count_and_time)
 
int drm_vblank_get (struct drm_device *dev, int crtc)
 
 EXPORT_SYMBOL (drm_vblank_get)
 
void drm_vblank_put (struct drm_device *dev, int crtc)
 
 EXPORT_SYMBOL (drm_vblank_put)
 
void drm_vblank_off (struct drm_device *dev, int crtc)
 
 EXPORT_SYMBOL (drm_vblank_off)
 
void drm_vblank_pre_modeset (struct drm_device *dev, int crtc)
 
 EXPORT_SYMBOL (drm_vblank_pre_modeset)
 
void drm_vblank_post_modeset (struct drm_device *dev, int crtc)
 
 EXPORT_SYMBOL (drm_vblank_post_modeset)
 
int drm_modeset_ctl (struct drm_device *dev, void *data, struct drm_file *file_priv)
 
int drm_wait_vblank (struct drm_device *dev, void *data, struct drm_file *file_priv)
 
bool drm_handle_vblank (struct drm_device *dev, int crtc)
 
 EXPORT_SYMBOL (drm_handle_vblank)
 

Detailed Description

IRQ support

Author
Rickard E. (Rik) Faith faith.nosp@m.@val.nosp@m.inux..nosp@m.com
Gareth Hughes garet.nosp@m.h@va.nosp@m.linux.nosp@m..com

Definition in file drm_irq.c.

Macro Definition Documentation

#define DRM_REDUNDANT_VBLIRQ_THRESH_NS   1000000

Definition at line 58 of file drm_irq.c.

#define DRM_TIMESTAMP_MAXRETRIES   3

Definition at line 53 of file drm_irq.c.

#define vblanktimestamp (   dev,
  crtc,
  count 
)
Value:
( \
(dev)->_vblank_time[(crtc) * DRM_VBLANKTIME_RBSIZE + \
((count) % DRM_VBLANKTIME_RBSIZE)])

Definition at line 46 of file drm_irq.c.

Function Documentation

void drm_calc_timestamping_constants ( struct drm_crtc crtc)

drm_calc_timestamping_constants - Calculate and store various constants which are later needed by vblank and swap-completion timestamping, e.g, by drm_calc_vbltimestamp_from_scanoutpos(). They are derived from crtc's true scanout timing, so they take things like panel scaling or other adjustments into account.

drm_crtc whose timestamp constants should be updated.

Definition at line 488 of file drm_irq.c.

int drm_calc_vbltimestamp_from_scanoutpos ( struct drm_device dev,
int  crtc,
int max_error,
struct timeval vblank_time,
unsigned  flags,
struct drm_crtc refcrtc 
)

drm_calc_vbltimestamp_from_scanoutpos - helper routine for kms drivers. 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.

: DRM device. : Which crtc's vblank timestamp to retrieve. : Desired maximum allowable error in timestamps (nanosecs). On return contains true maximum error of timestamp. : Pointer to struct timeval which should receive the timestamp. : Flags to pass to driver: 0 = Default. DRM_CALLED_FROM_VBLIRQ = If function is called from vbl irq handler. : drm_crtc* of crtc which defines scanout timing.

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.

Definition at line 573 of file drm_irq.c.

int drm_control ( struct drm_device dev,
void data,
struct drm_file *  file_priv 
)

IRQ control ioctl.

Parameters
inodedevice inode.
file_privDRM file private.
cmdcommand.
arguser argument, pointing to a drm_control structure.
Returns
zero on success or a negative number on failure.

Calls irq_install() or irq_uninstall() according to arg.

Definition at line 445 of file drm_irq.c.

u32 drm_get_last_vbltimestamp ( struct drm_device dev,
int  crtc,
struct timeval tvblank,
unsigned  flags 
)

drm_get_last_vbltimestamp - retrieve raw timestamp for the most recent vblank interval.

: DRM device : which crtc's vblank timestamp to retrieve : Pointer to target struct timeval which should receive the timestamp : Flags to pass to driver: 0 = Default. DRM_CALLED_FROM_VBLIRQ = If function is called from vbl irq handler.

Fetches the system timestamp corresponding to the time of the most recent vblank interval on specified crtc. May call into kms-driver to compute the timestamp with a high-precision GPU specific method.

Returns zero if timestamp originates from uncorrected do_gettimeofday() call, i.e., it isn't very precisely locked to the true vblank.

Returns non-zero if timestamp is considered to be very precise.

Definition at line 731 of file drm_irq.c.

bool drm_handle_vblank ( struct drm_device dev,
int  crtc 
)

drm_handle_vblank - handle a vblank event : DRM device : where this event occurred

Drivers should call this routine in their vblank interrupt handlers to update the vblank counter and send any signals that may be pending.

Definition at line 1282 of file drm_irq.c.

int drm_irq_by_busid ( struct drm_device dev,
void data,
struct drm_file *  file_priv 
)

Get interrupt from bus id.

Parameters
inodedevice inode.
file_privDRM file private.
cmdcommand.
arguser argument, pointing to a drm_irq_busid structure.
Returns
zero on success or a negative number on failure.

Finds the PCI device with the specified bus id and gets its IRQ number. This IOCTL is deprecated, and will now return EINVAL for any busid not equal to that of the device that this DRM instance attached to.

Definition at line 73 of file drm_irq.c.

int drm_irq_install ( struct drm_device dev)

Install IRQ handler.

Parameters
devDRM device.

Initializes the IRQ related data. Installs the handler, calling the driver irq_preinstall() and irq_postinstall() functions before and after the installation.

Definition at line 311 of file drm_irq.c.

int drm_irq_uninstall ( struct drm_device dev)

Uninstall the IRQ handler.

Parameters
devDRM device.

Calls the driver's irq_uninstall() function, and stops the irq.

Definition at line 390 of file drm_irq.c.

int drm_modeset_ctl ( struct drm_device dev,
void data,
struct drm_file *  file_priv 
)

drm_modeset_ctl - handle vblank event counter changes across mode switch : standard ioctl arguments

Applications should call the _DRM_PRE_MODESET and _DRM_POST_MODESET ioctls around modesetting so that any lost vblank events are accounted for.

Generally the counter will reset across mode sets. If interrupts are enabled around this call, we don't have to do anything since the counter will have already been incremented.

Definition at line 1029 of file drm_irq.c.

void drm_vblank_cleanup ( struct drm_device dev)

Definition at line 186 of file drm_irq.c.

u32 drm_vblank_count ( struct drm_device dev,
int  crtc 
)

drm_vblank_count - retrieve "cooked" vblank counter value : DRM device : which counter to retrieve

Fetches the "cooked" vblank count value that represents the number of vblank events since the system was booted, including lost events due to modesetting activity.

Definition at line 765 of file drm_irq.c.

u32 drm_vblank_count_and_time ( struct drm_device dev,
int  crtc,
struct timeval vblanktime 
)

drm_vblank_count_and_time - retrieve "cooked" vblank counter value and the system timestamp corresponding to that vblank counter value.

: DRM device : which counter to retrieve : Pointer to struct timeval to receive the vblank timestamp.

Fetches the "cooked" vblank count value that represents the number of vblank events since the system was booted, including lost events due to modesetting activity. Returns corresponding system timestamp of the time of the vblank interval that corresponds to the current value vblank counter value.

Definition at line 785 of file drm_irq.c.

int drm_vblank_get ( struct drm_device dev,
int  crtc 
)

drm_vblank_get - get a reference count on vblank events : DRM device : which CRTC to own

Acquire a reference count on vblank events to avoid having them disabled while in use.

RETURNS Zero on success, nonzero on failure.

Definition at line 880 of file drm_irq.c.

int drm_vblank_init ( struct drm_device dev,
int  num_crtcs 
)

Definition at line 209 of file drm_irq.c.

void drm_vblank_off ( struct drm_device dev,
int  crtc 
)

Definition at line 939 of file drm_irq.c.

void drm_vblank_post_modeset ( struct drm_device dev,
int  crtc 
)

Definition at line 1001 of file drm_irq.c.

void drm_vblank_pre_modeset ( struct drm_device dev,
int  crtc 
)

drm_vblank_pre_modeset - account for vblanks across mode sets : DRM device : CRTC in question

Account for vblank events across mode setting events, which will likely reset the hardware frame counter.

Definition at line 981 of file drm_irq.c.

void drm_vblank_put ( struct drm_device dev,
int  crtc 
)

drm_vblank_put - give up ownership of vblank events : DRM device : which counter to give up

Release ownership of a given vblank counter, turning off interrupts if possible. Disable interrupts after drm_vblank_offdelay milliseconds.

Definition at line 927 of file drm_irq.c.

int drm_wait_vblank ( struct drm_device dev,
void data,
struct drm_file *  file_priv 
)

Wait for VBLANK.

Parameters
inodedevice inode.
file_privDRM file private.
cmdcommand.
datauser argument, pointing to a drm_wait_vblank structure.
Returns
zero on success or a negative number on failure.

This function enables the vblank interrupt on the pipe requested, then sleeps waiting for the requested sequence number to occur, and drops the vblank interrupt refcount afterwards. (vblank irq disable follows that after a timeout with no further vblank waits scheduled).

Definition at line 1151 of file drm_irq.c.

EXPORT_SYMBOL ( drm_vblank_cleanup  )
EXPORT_SYMBOL ( drm_vblank_init  )
EXPORT_SYMBOL ( drm_irq_install  )
EXPORT_SYMBOL ( drm_irq_uninstall  )
EXPORT_SYMBOL ( drm_calc_timestamping_constants  )
EXPORT_SYMBOL ( drm_get_last_vbltimestamp  )
EXPORT_SYMBOL ( drm_vblank_count  )
EXPORT_SYMBOL ( drm_vblank_count_and_time  )
EXPORT_SYMBOL ( drm_vblank_get  )
EXPORT_SYMBOL ( drm_vblank_put  )
EXPORT_SYMBOL ( drm_vblank_off  )
EXPORT_SYMBOL ( drm_vblank_pre_modeset  )
EXPORT_SYMBOL ( drm_vblank_post_modeset  )
EXPORT_SYMBOL ( drm_handle_vblank  )