Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
drm_modes.c File Reference
#include <linux/list.h>
#include <linux/list_sort.h>
#include <linux/export.h>
#include <drm/drmP.h>
#include <drm/drm_crtc.h>

Go to the source code of this file.

Macros

#define HV_FACTOR   1000
 
#define CVT_MARGIN_PERCENTAGE   18
 
#define CVT_H_GRANULARITY   8
 
#define CVT_MIN_V_PORCH   3
 
#define CVT_MIN_V_BPORCH   6
 
#define CVT_CLOCK_STEP   250
 
#define CVT_MIN_VSYNC_BP   550
 
#define CVT_HSYNC_PERCENTAGE   8
 
#define CVT_M_FACTOR   600
 
#define CVT_C_FACTOR   40
 
#define CVT_K_FACTOR   128
 
#define CVT_J_FACTOR   20
 
#define CVT_M_PRIME   (CVT_M_FACTOR * CVT_K_FACTOR / 256)
 
#define CVT_C_PRIME
 
#define CVT_RB_MIN_VBLANK   460
 
#define CVT_RB_H_SYNC   32
 
#define CVT_RB_H_BLANK   160
 
#define CVT_RB_VFPORCH   3
 
#define GTF_MARGIN_PERCENTAGE   18
 
#define GTF_CELL_GRAN   8
 
#define GTF_MIN_V_PORCH   1
 
#define V_SYNC_RQD   3
 
#define H_SYNC_PERCENT   8
 
#define MIN_VSYNC_PLUS_BP   550
 
#define GTF_C_PRIME   ((((GTF_2C - GTF_2J) * GTF_K / 256) + GTF_2J) / 2)
 
#define GTF_M_PRIME   (GTF_K * GTF_M / 256)
 

Functions

void drm_mode_debug_printmodeline (struct drm_display_mode *mode)
 
 EXPORT_SYMBOL (drm_mode_debug_printmodeline)
 
struct drm_display_modedrm_cvt_mode (struct drm_device *dev, int hdisplay, int vdisplay, int vrefresh, bool reduced, bool interlaced, bool margins)
 
 EXPORT_SYMBOL (drm_cvt_mode)
 
struct drm_display_modedrm_gtf_mode_complex (struct drm_device *dev, int hdisplay, int vdisplay, int vrefresh, bool interlaced, int margins, int GTF_M, int GTF_2C, int GTF_K, int GTF_2J)
 
 EXPORT_SYMBOL (drm_gtf_mode_complex)
 
struct drm_display_modedrm_gtf_mode (struct drm_device *dev, int hdisplay, int vdisplay, int vrefresh, bool lace, int margins)
 
 EXPORT_SYMBOL (drm_gtf_mode)
 
void drm_mode_set_name (struct drm_display_mode *mode)
 
 EXPORT_SYMBOL (drm_mode_set_name)
 
void drm_mode_list_concat (struct list_head *head, struct list_head *new)
 
 EXPORT_SYMBOL (drm_mode_list_concat)
 
int drm_mode_width (struct drm_display_mode *mode)
 
 EXPORT_SYMBOL (drm_mode_width)
 
int drm_mode_height (struct drm_display_mode *mode)
 
 EXPORT_SYMBOL (drm_mode_height)
 
int drm_mode_hsync (const struct drm_display_mode *mode)
 
 EXPORT_SYMBOL (drm_mode_hsync)
 
int drm_mode_vrefresh (const struct drm_display_mode *mode)
 
 EXPORT_SYMBOL (drm_mode_vrefresh)
 
void drm_mode_set_crtcinfo (struct drm_display_mode *p, int adjust_flags)
 
 EXPORT_SYMBOL (drm_mode_set_crtcinfo)
 
void drm_mode_copy (struct drm_display_mode *dst, const struct drm_display_mode *src)
 
 EXPORT_SYMBOL (drm_mode_copy)
 
struct drm_display_modedrm_mode_duplicate (struct drm_device *dev, const struct drm_display_mode *mode)
 
 EXPORT_SYMBOL (drm_mode_duplicate)
 
bool drm_mode_equal (struct drm_display_mode *mode1, struct drm_display_mode *mode2)
 
 EXPORT_SYMBOL (drm_mode_equal)
 
void drm_mode_validate_size (struct drm_device *dev, struct list_head *mode_list, int maxX, int maxY, int maxPitch)
 
 EXPORT_SYMBOL (drm_mode_validate_size)
 
void drm_mode_validate_clocks (struct drm_device *dev, struct list_head *mode_list, int *min, int *max, int n_ranges)
 
 EXPORT_SYMBOL (drm_mode_validate_clocks)
 
void drm_mode_prune_invalid (struct drm_device *dev, struct list_head *mode_list, bool verbose)
 
 EXPORT_SYMBOL (drm_mode_prune_invalid)
 
void drm_mode_sort (struct list_head *mode_list)
 
 EXPORT_SYMBOL (drm_mode_sort)
 
void drm_mode_connector_list_update (struct drm_connector *connector)
 
 EXPORT_SYMBOL (drm_mode_connector_list_update)
 
bool drm_mode_parse_command_line_for_connector (const char *mode_option, struct drm_connector *connector, struct drm_cmdline_mode *mode)
 
 EXPORT_SYMBOL (drm_mode_parse_command_line_for_connector)
 
struct drm_display_modedrm_mode_create_from_cmdline_mode (struct drm_device *dev, struct drm_cmdline_mode *cmd)
 
 EXPORT_SYMBOL (drm_mode_create_from_cmdline_mode)
 

Macro Definition Documentation

#define CVT_C_FACTOR   40
#define CVT_C_PRIME
Value:
((CVT_C_FACTOR - CVT_J_FACTOR) * CVT_K_FACTOR / 256 + \
CVT_J_FACTOR)
#define CVT_CLOCK_STEP   250
#define CVT_H_GRANULARITY   8
#define CVT_HSYNC_PERCENTAGE   8
#define CVT_J_FACTOR   20
#define CVT_K_FACTOR   128
#define CVT_M_FACTOR   600
#define CVT_M_PRIME   (CVT_M_FACTOR * CVT_K_FACTOR / 256)
#define CVT_MARGIN_PERCENTAGE   18
#define CVT_MIN_V_BPORCH   6
#define CVT_MIN_V_PORCH   3
#define CVT_MIN_VSYNC_BP   550
#define CVT_RB_H_BLANK   160
#define CVT_RB_H_SYNC   32
#define CVT_RB_MIN_VBLANK   460
#define CVT_RB_VFPORCH   3
#define GTF_C_PRIME   ((((GTF_2C - GTF_2J) * GTF_K / 256) + GTF_2J) / 2)
#define GTF_CELL_GRAN   8
#define GTF_M_PRIME   (GTF_K * GTF_M / 256)
#define GTF_MARGIN_PERCENTAGE   18
#define GTF_MIN_V_PORCH   1
#define H_SYNC_PERCENT   8
#define HV_FACTOR   1000

drm_cvt_mode -create a modeline based on CVT algorithm : DRM device : hdisplay size : vdisplay size : vrefresh rate : Whether the GTF calculation is simplified :Whether the interlace is supported

LOCKING: none.

return the modeline based on CVT algorithm

This function is called to generate the modeline based on CVT algorithm according to the hdisplay, vdisplay, vrefresh. It is based from the VESA(TM) Coordinated Video Timing Generator by Graham Loveridge April 9, 2003 available at http://www.elo.utfsm.cl/~elo212/docs/CVTd6r1.xls

And it is copied from xf86CVTmode in xserver/hw/xfree86/modes/xf86cvt.c. What I have done is to translate it by using integer calculation.

Definition at line 84 of file drm_modes.c.

#define MIN_VSYNC_PLUS_BP   550
#define V_SYNC_RQD   3

Function Documentation

struct drm_display_mode* drm_cvt_mode ( struct drm_device dev,
int  hdisplay,
int  vdisplay,
int  vrefresh,
bool  reduced,
bool  interlaced,
bool  margins 
)
read

Definition at line 85 of file drm_modes.c.

struct drm_display_mode* drm_gtf_mode ( struct drm_device dev,
int  hdisplay,
int  vdisplay,
int  vrefresh,
bool  lace,
int  margins 
)
read

drm_gtf_mode - create the modeline based on GTF algorithm

:drm device :hdisplay size :vdisplay size :vrefresh rate. :whether the interlace is supported :whether the margin is supported

LOCKING. none.

return the modeline based on GTF algorithm

This function is to create the modeline based on the GTF algorithm. Generalized Timing Formula is derived from: GTF Spreadsheet by Andy Morrish (1/5/97) available at http://www.vesa.org

And it is copied from the file of xserver/hw/xfree86/modes/xf86gtf.c. What I have done is to translate it by using integer calculation. I also refer to the function of fb_get_mode in the file of drivers/video/fbmon.c

Standard GTF parameters: M = 600 C = 40 K = 128 J = 20

Definition at line 499 of file drm_modes.c.

struct drm_display_mode* drm_gtf_mode_complex ( struct drm_device dev,
int  hdisplay,
int  vdisplay,
int  vrefresh,
bool  interlaced,
int  margins,
int  GTF_M,
int  GTF_2C,
int  GTF_K,
int  GTF_2J 
)
read

drm_gtf_mode_complex - create the modeline based on full GTF algorithm

:drm device :hdisplay size :vdisplay size :vrefresh rate. :whether the interlace is supported :desired margin size [MCKJ] :extended GTF formula parameters

LOCKING. none.

return the modeline based on full GTF algorithm.

GTF feature blocks specify C and J in multiples of 0.5, so we pass them in here multiplied by two. For a C of 40, pass in 80.

Definition at line 301 of file drm_modes.c.

void drm_mode_connector_list_update ( struct drm_connector connector)

drm_mode_connector_list_update - update the mode list for the connector : the connector to update

LOCKING: Caller must hold a lock protecting .

This moves the modes from the probed_modes list to the actual mode list. It compares the probed mode against the current list and only adds different modes. All modes unverified after this point will be removed by the prune invalid modes.

Definition at line 961 of file drm_modes.c.

void drm_mode_copy ( struct drm_display_mode dst,
const struct drm_display_mode src 
)

drm_mode_copy - copy the mode : mode to overwrite : mode to copy

LOCKING: None.

Copy an existing mode into another mode, preserving the object id of the destination mode.

Definition at line 723 of file drm_modes.c.

struct drm_display_mode* drm_mode_create_from_cmdline_mode ( struct drm_device dev,
struct drm_cmdline_mode *  cmd 
)
read

Definition at line 1155 of file drm_modes.c.

void drm_mode_debug_printmodeline ( struct drm_display_mode mode)

drm_mode_debug_printmodeline - debug print a mode : DRM device : mode to print

LOCKING: None.

Describe using DRM_DEBUG.

Definition at line 49 of file drm_modes.c.

struct drm_display_mode* drm_mode_duplicate ( struct drm_device dev,
const struct drm_display_mode mode 
)
read

drm_mode_duplicate - allocate and duplicate an existing mode : mode to duplicate

LOCKING: None.

Just allocate a new mode, copy the existing mode into it, and return a pointer to it. Used to create new instances of established modes.

Definition at line 743 of file drm_modes.c.

bool drm_mode_equal ( struct drm_display_mode mode1,
struct drm_display_mode mode2 
)

drm_mode_equal - test modes for equality : first mode : second mode

LOCKING: None.

Check to see if and are equivalent.

RETURNS: True if the modes are equal, false otherwise.

Definition at line 771 of file drm_modes.c.

int drm_mode_height ( struct drm_display_mode mode)

drm_mode_height - get the height of a mode : mode

LOCKING: None.

Return 's height (vdisplay) value.

FIXME: is this needed?

RETURNS: ->vdisplay

Definition at line 582 of file drm_modes.c.

int drm_mode_hsync ( const struct drm_display_mode mode)

drm_mode_hsync - get the hsync of a mode : mode

LOCKING: None.

Return 's hsync rate in kHz, rounded to the nearest int.

Definition at line 596 of file drm_modes.c.

void drm_mode_list_concat ( struct list_head head,
struct list_head new 
)

drm_mode_list_concat - move modes from one list to another : source list : dst list

LOCKING: Caller must ensure both lists are locked.

Move all the modes from to .

Definition at line 536 of file drm_modes.c.

bool drm_mode_parse_command_line_for_connector ( const char mode_option,
struct drm_connector connector,
struct drm_cmdline_mode *  mode 
)

drm_mode_parse_command_line_for_connector - parse command line for connector - per connector mode option - connector to parse line for

This parses the connector specific then generic command lines for modes and options to configure the connector.

This uses the same parameters as the fb modedb.c, except for extra <xres>x<yres>[M][R][-<bpp>][<refresh>][i][m][eDd]

enable/enable Digital/disable bit at the end

Definition at line 1004 of file drm_modes.c.

void drm_mode_prune_invalid ( struct drm_device dev,
struct list_head mode_list,
bool  verbose 
)

drm_mode_prune_invalid - remove invalid modes from mode list : DRM device : list of modes to check : be verbose about it

LOCKING: Caller must hold a lock protecting .

Once mode list generation is complete, a caller can use this routine to remove invalid modes from a mode list. If any of the modes have a status other than MODE_OK, they are removed from and freed.

Definition at line 882 of file drm_modes.c.

void drm_mode_set_crtcinfo ( struct drm_display_mode p,
int  adjust_flags 
)

drm_mode_set_crtcinfo - set CRTC modesetting parameters : mode : unused? (FIXME)

LOCKING: None.

Setup the CRTC modesetting parameters for , adjusting if necessary.

Definition at line 666 of file drm_modes.c.

void drm_mode_set_name ( struct drm_display_mode mode)

drm_mode_set_name - set the name on a mode : name will be set in this mode

LOCKING: None.

Set the name of to a standard format.

Definition at line 516 of file drm_modes.c.

void drm_mode_sort ( struct list_head mode_list)

drm_mode_sort - sort mode list : list to sort

LOCKING: Caller must hold a lock protecting .

Sort by favorability, putting good modes first.

Definition at line 943 of file drm_modes.c.

void drm_mode_validate_clocks ( struct drm_device dev,
struct list_head mode_list,
int min,
int max,
int  n_ranges 
)

drm_mode_validate_clocks - validate modes against clock limits : DRM device : list of modes to check : minimum clock rate array : maximum clock rate array : number of clock ranges (size of arrays)

LOCKING: Caller must hold a lock protecting .

Some code may need to check a mode list against the clock limits of the device in question. This function walks the mode list, testing to make sure each mode falls within a given range (defined by and arrays) and sets ->status as needed.

Definition at line 848 of file drm_modes.c.

void drm_mode_validate_size ( struct drm_device dev,
struct list_head mode_list,
int  maxX,
int  maxY,
int  maxPitch 
)

drm_mode_validate_size - make sure modes adhere to size constraints : DRM device : list of modes to check : maximum width : maximum height : max pitch

LOCKING: Caller must hold a lock protecting .

The DRM device () has size and pitch limits. Here we validate the modes we probed for against those limits and set their status as necessary.

Definition at line 813 of file drm_modes.c.

int drm_mode_vrefresh ( const struct drm_display_mode mode)

drm_mode_vrefresh - get the vrefresh of a mode : mode

LOCKING: None.

Return 's vrefresh rate in Hz or calculate it if necessary.

FIXME: why is this needed? shouldn't vrefresh be set already?

RETURNS: Vertical refresh rate. It will be the result of actual value plus 0.5. If it is 70.288, it will return 70Hz. If it is 59.6, it will return 60Hz.

Definition at line 630 of file drm_modes.c.

int drm_mode_width ( struct drm_display_mode mode)

drm_mode_width - get the width of a mode : mode

LOCKING: None.

Return 's width (hdisplay) value.

FIXME: is this needed?

RETURNS: ->hdisplay

Definition at line 561 of file drm_modes.c.

EXPORT_SYMBOL ( drm_mode_debug_printmodeline  )
EXPORT_SYMBOL ( drm_cvt_mode  )
EXPORT_SYMBOL ( drm_gtf_mode_complex  )
EXPORT_SYMBOL ( drm_gtf_mode  )
EXPORT_SYMBOL ( drm_mode_set_name  )
EXPORT_SYMBOL ( drm_mode_list_concat  )
EXPORT_SYMBOL ( drm_mode_width  )
EXPORT_SYMBOL ( drm_mode_height  )
EXPORT_SYMBOL ( drm_mode_hsync  )
EXPORT_SYMBOL ( drm_mode_vrefresh  )
EXPORT_SYMBOL ( drm_mode_set_crtcinfo  )
EXPORT_SYMBOL ( drm_mode_copy  )
EXPORT_SYMBOL ( drm_mode_duplicate  )
EXPORT_SYMBOL ( drm_mode_equal  )
EXPORT_SYMBOL ( drm_mode_validate_size  )
EXPORT_SYMBOL ( drm_mode_validate_clocks  )
EXPORT_SYMBOL ( drm_mode_prune_invalid  )
EXPORT_SYMBOL ( drm_mode_sort  )
EXPORT_SYMBOL ( drm_mode_connector_list_update  )
EXPORT_SYMBOL ( drm_mode_create_from_cmdline_mode  )