Home | History | Annotate | Line # | Download | only in drm
      1  1.6  riastrad /*	$NetBSD: drm_modes.h,v 1.6 2021/12/19 01:55:52 riastradh Exp $	*/
      2  1.4  riastrad 
      3  1.1  riastrad /*
      4  1.1  riastrad  * Copyright  2006 Keith Packard
      5  1.1  riastrad  * Copyright  2007-2008 Dave Airlie
      6  1.1  riastrad  * Copyright  2007-2008 Intel Corporation
      7  1.1  riastrad  *   Jesse Barnes <jesse.barnes (at) intel.com>
      8  1.1  riastrad  * Copyright  2014 Intel Corporation
      9  1.1  riastrad  *   Daniel Vetter <daniel.vetter (at) ffwll.ch>
     10  1.1  riastrad  *
     11  1.1  riastrad  * Permission is hereby granted, free of charge, to any person obtaining a
     12  1.1  riastrad  * copy of this software and associated documentation files (the "Software"),
     13  1.1  riastrad  * to deal in the Software without restriction, including without limitation
     14  1.1  riastrad  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     15  1.1  riastrad  * and/or sell copies of the Software, and to permit persons to whom the
     16  1.1  riastrad  * Software is furnished to do so, subject to the following conditions:
     17  1.1  riastrad  *
     18  1.1  riastrad  * The above copyright notice and this permission notice shall be included in
     19  1.1  riastrad  * all copies or substantial portions of the Software.
     20  1.1  riastrad  *
     21  1.1  riastrad  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     22  1.1  riastrad  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     23  1.1  riastrad  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     24  1.1  riastrad  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
     25  1.1  riastrad  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
     26  1.1  riastrad  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     27  1.1  riastrad  * OTHER DEALINGS IN THE SOFTWARE.
     28  1.1  riastrad  */
     29  1.1  riastrad #ifndef __DRM_MODES_H__
     30  1.1  riastrad #define __DRM_MODES_H__
     31  1.1  riastrad 
     32  1.5  riastrad #include <linux/hdmi.h>
     33  1.5  riastrad 
     34  1.5  riastrad #include <drm/drm_mode_object.h>
     35  1.5  riastrad #include <drm/drm_connector.h>
     36  1.3  riastrad 
     37  1.3  riastrad struct videomode;
     38  1.6  riastrad struct device_node;
     39  1.3  riastrad 
     40  1.1  riastrad /*
     41  1.1  riastrad  * Note on terminology:  here, for brevity and convenience, we refer to connector
     42  1.1  riastrad  * control chips as 'CRTCs'.  They can control any type of connector, VGA, LVDS,
     43  1.1  riastrad  * DVI, etc.  And 'screen' refers to the whole of the visible display, which
     44  1.1  riastrad  * may span multiple monitors (and therefore multiple CRTC and connector
     45  1.1  riastrad  * structures).
     46  1.1  riastrad  */
     47  1.1  riastrad 
     48  1.5  riastrad /**
     49  1.5  riastrad  * enum drm_mode_status - hardware support status of a mode
     50  1.5  riastrad  * @MODE_OK: Mode OK
     51  1.5  riastrad  * @MODE_HSYNC: hsync out of range
     52  1.5  riastrad  * @MODE_VSYNC: vsync out of range
     53  1.5  riastrad  * @MODE_H_ILLEGAL: mode has illegal horizontal timings
     54  1.5  riastrad  * @MODE_V_ILLEGAL: mode has illegal horizontal timings
     55  1.5  riastrad  * @MODE_BAD_WIDTH: requires an unsupported linepitch
     56  1.5  riastrad  * @MODE_NOMODE: no mode with a matching name
     57  1.5  riastrad  * @MODE_NO_INTERLACE: interlaced mode not supported
     58  1.5  riastrad  * @MODE_NO_DBLESCAN: doublescan mode not supported
     59  1.5  riastrad  * @MODE_NO_VSCAN: multiscan mode not supported
     60  1.5  riastrad  * @MODE_MEM: insufficient video memory
     61  1.5  riastrad  * @MODE_VIRTUAL_X: mode width too large for specified virtual size
     62  1.5  riastrad  * @MODE_VIRTUAL_Y: mode height too large for specified virtual size
     63  1.5  riastrad  * @MODE_MEM_VIRT: insufficient video memory given virtual size
     64  1.5  riastrad  * @MODE_NOCLOCK: no fixed clock available
     65  1.5  riastrad  * @MODE_CLOCK_HIGH: clock required is too high
     66  1.5  riastrad  * @MODE_CLOCK_LOW: clock required is too low
     67  1.5  riastrad  * @MODE_CLOCK_RANGE: clock/mode isn't in a ClockRange
     68  1.5  riastrad  * @MODE_BAD_HVALUE: horizontal timing was out of range
     69  1.5  riastrad  * @MODE_BAD_VVALUE: vertical timing was out of range
     70  1.5  riastrad  * @MODE_BAD_VSCAN: VScan value out of range
     71  1.5  riastrad  * @MODE_HSYNC_NARROW: horizontal sync too narrow
     72  1.5  riastrad  * @MODE_HSYNC_WIDE: horizontal sync too wide
     73  1.5  riastrad  * @MODE_HBLANK_NARROW: horizontal blanking too narrow
     74  1.5  riastrad  * @MODE_HBLANK_WIDE: horizontal blanking too wide
     75  1.5  riastrad  * @MODE_VSYNC_NARROW: vertical sync too narrow
     76  1.5  riastrad  * @MODE_VSYNC_WIDE: vertical sync too wide
     77  1.5  riastrad  * @MODE_VBLANK_NARROW: vertical blanking too narrow
     78  1.5  riastrad  * @MODE_VBLANK_WIDE: vertical blanking too wide
     79  1.5  riastrad  * @MODE_PANEL: exceeds panel dimensions
     80  1.5  riastrad  * @MODE_INTERLACE_WIDTH: width too large for interlaced mode
     81  1.5  riastrad  * @MODE_ONE_WIDTH: only one width is supported
     82  1.5  riastrad  * @MODE_ONE_HEIGHT: only one height is supported
     83  1.5  riastrad  * @MODE_ONE_SIZE: only one resolution is supported
     84  1.5  riastrad  * @MODE_NO_REDUCED: monitor doesn't accept reduced blanking
     85  1.5  riastrad  * @MODE_NO_STEREO: stereo modes not supported
     86  1.5  riastrad  * @MODE_NO_420: ycbcr 420 modes not supported
     87  1.5  riastrad  * @MODE_STALE: mode has become stale
     88  1.5  riastrad  * @MODE_BAD: unspecified reason
     89  1.5  riastrad  * @MODE_ERROR: error condition
     90  1.5  riastrad  *
     91  1.5  riastrad  * This enum is used to filter out modes not supported by the driver/hardware
     92  1.5  riastrad  * combination.
     93  1.5  riastrad  */
     94  1.1  riastrad enum drm_mode_status {
     95  1.5  riastrad 	MODE_OK = 0,
     96  1.5  riastrad 	MODE_HSYNC,
     97  1.5  riastrad 	MODE_VSYNC,
     98  1.5  riastrad 	MODE_H_ILLEGAL,
     99  1.5  riastrad 	MODE_V_ILLEGAL,
    100  1.5  riastrad 	MODE_BAD_WIDTH,
    101  1.5  riastrad 	MODE_NOMODE,
    102  1.5  riastrad 	MODE_NO_INTERLACE,
    103  1.5  riastrad 	MODE_NO_DBLESCAN,
    104  1.5  riastrad 	MODE_NO_VSCAN,
    105  1.5  riastrad 	MODE_MEM,
    106  1.5  riastrad 	MODE_VIRTUAL_X,
    107  1.5  riastrad 	MODE_VIRTUAL_Y,
    108  1.5  riastrad 	MODE_MEM_VIRT,
    109  1.5  riastrad 	MODE_NOCLOCK,
    110  1.5  riastrad 	MODE_CLOCK_HIGH,
    111  1.5  riastrad 	MODE_CLOCK_LOW,
    112  1.5  riastrad 	MODE_CLOCK_RANGE,
    113  1.5  riastrad 	MODE_BAD_HVALUE,
    114  1.5  riastrad 	MODE_BAD_VVALUE,
    115  1.5  riastrad 	MODE_BAD_VSCAN,
    116  1.5  riastrad 	MODE_HSYNC_NARROW,
    117  1.5  riastrad 	MODE_HSYNC_WIDE,
    118  1.5  riastrad 	MODE_HBLANK_NARROW,
    119  1.5  riastrad 	MODE_HBLANK_WIDE,
    120  1.5  riastrad 	MODE_VSYNC_NARROW,
    121  1.5  riastrad 	MODE_VSYNC_WIDE,
    122  1.5  riastrad 	MODE_VBLANK_NARROW,
    123  1.5  riastrad 	MODE_VBLANK_WIDE,
    124  1.5  riastrad 	MODE_PANEL,
    125  1.5  riastrad 	MODE_INTERLACE_WIDTH,
    126  1.5  riastrad 	MODE_ONE_WIDTH,
    127  1.5  riastrad 	MODE_ONE_HEIGHT,
    128  1.5  riastrad 	MODE_ONE_SIZE,
    129  1.5  riastrad 	MODE_NO_REDUCED,
    130  1.5  riastrad 	MODE_NO_STEREO,
    131  1.5  riastrad 	MODE_NO_420,
    132  1.5  riastrad 	MODE_STALE = -3,
    133  1.5  riastrad 	MODE_BAD = -2,
    134  1.5  riastrad 	MODE_ERROR = -1
    135  1.1  riastrad };
    136  1.1  riastrad 
    137  1.1  riastrad #define DRM_MODE(nm, t, c, hd, hss, hse, ht, hsk, vd, vss, vse, vt, vs, f) \
    138  1.1  riastrad 	.name = nm, .status = 0, .type = (t), .clock = (c), \
    139  1.1  riastrad 	.hdisplay = (hd), .hsync_start = (hss), .hsync_end = (hse), \
    140  1.1  riastrad 	.htotal = (ht), .hskew = (hsk), .vdisplay = (vd), \
    141  1.1  riastrad 	.vsync_start = (vss), .vsync_end = (vse), .vtotal = (vt), \
    142  1.5  riastrad 	.vscan = (vs), .flags = (f)
    143  1.5  riastrad 
    144  1.5  riastrad /**
    145  1.5  riastrad  * DRM_SIMPLE_MODE - Simple display mode
    146  1.5  riastrad  * @hd: Horizontal resolution, width
    147  1.5  riastrad  * @vd: Vertical resolution, height
    148  1.5  riastrad  * @hd_mm: Display width in millimeters
    149  1.5  riastrad  * @vd_mm: Display height in millimeters
    150  1.5  riastrad  *
    151  1.5  riastrad  * This macro initializes a &drm_display_mode that only contains info about
    152  1.5  riastrad  * resolution and physical size.
    153  1.5  riastrad  */
    154  1.5  riastrad #define DRM_SIMPLE_MODE(hd, vd, hd_mm, vd_mm) \
    155  1.5  riastrad 	.type = DRM_MODE_TYPE_DRIVER, .clock = 1 /* pass validation */, \
    156  1.5  riastrad 	.hdisplay = (hd), .hsync_start = (hd), .hsync_end = (hd), \
    157  1.5  riastrad 	.htotal = (hd), .vdisplay = (vd), .vsync_start = (vd), \
    158  1.5  riastrad 	.vsync_end = (vd), .vtotal = (vd), .width_mm = (hd_mm), \
    159  1.5  riastrad 	.height_mm = (vd_mm)
    160  1.1  riastrad 
    161  1.1  riastrad #define CRTC_INTERLACE_HALVE_V	(1 << 0) /* halve V values for interlacing */
    162  1.1  riastrad #define CRTC_STEREO_DOUBLE	(1 << 1) /* adjust timings for stereo modes */
    163  1.4  riastrad #define CRTC_NO_DBLSCAN		(1 << 2) /* don't adjust doublescan */
    164  1.4  riastrad #define CRTC_NO_VSCAN		(1 << 3) /* don't adjust doublescan */
    165  1.4  riastrad #define CRTC_STEREO_DOUBLE_ONLY	(CRTC_STEREO_DOUBLE | CRTC_NO_DBLSCAN | CRTC_NO_VSCAN)
    166  1.1  riastrad 
    167  1.1  riastrad #define DRM_MODE_FLAG_3D_MAX	DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF
    168  1.1  riastrad 
    169  1.5  riastrad #define DRM_MODE_MATCH_TIMINGS (1 << 0)
    170  1.5  riastrad #define DRM_MODE_MATCH_CLOCK (1 << 1)
    171  1.5  riastrad #define DRM_MODE_MATCH_FLAGS (1 << 2)
    172  1.5  riastrad #define DRM_MODE_MATCH_3D_FLAGS (1 << 3)
    173  1.5  riastrad #define DRM_MODE_MATCH_ASPECT_RATIO (1 << 4)
    174  1.5  riastrad 
    175  1.5  riastrad /**
    176  1.5  riastrad  * struct drm_display_mode - DRM kernel-internal display mode structure
    177  1.5  riastrad  * @hdisplay: horizontal display size
    178  1.5  riastrad  * @hsync_start: horizontal sync start
    179  1.5  riastrad  * @hsync_end: horizontal sync end
    180  1.5  riastrad  * @htotal: horizontal total size
    181  1.5  riastrad  * @hskew: horizontal skew?!
    182  1.5  riastrad  * @vdisplay: vertical display size
    183  1.5  riastrad  * @vsync_start: vertical sync start
    184  1.5  riastrad  * @vsync_end: vertical sync end
    185  1.5  riastrad  * @vtotal: vertical total size
    186  1.5  riastrad  * @vscan: vertical scan?!
    187  1.5  riastrad  * @crtc_hdisplay: hardware mode horizontal display size
    188  1.5  riastrad  * @crtc_hblank_start: hardware mode horizontal blank start
    189  1.5  riastrad  * @crtc_hblank_end: hardware mode horizontal blank end
    190  1.5  riastrad  * @crtc_hsync_start: hardware mode horizontal sync start
    191  1.5  riastrad  * @crtc_hsync_end: hardware mode horizontal sync end
    192  1.5  riastrad  * @crtc_htotal: hardware mode horizontal total size
    193  1.5  riastrad  * @crtc_hskew: hardware mode horizontal skew?!
    194  1.5  riastrad  * @crtc_vdisplay: hardware mode vertical display size
    195  1.5  riastrad  * @crtc_vblank_start: hardware mode vertical blank start
    196  1.5  riastrad  * @crtc_vblank_end: hardware mode vertical blank end
    197  1.5  riastrad  * @crtc_vsync_start: hardware mode vertical sync start
    198  1.5  riastrad  * @crtc_vsync_end: hardware mode vertical sync end
    199  1.5  riastrad  * @crtc_vtotal: hardware mode vertical total size
    200  1.5  riastrad  *
    201  1.5  riastrad  * The horizontal and vertical timings are defined per the following diagram.
    202  1.5  riastrad  *
    203  1.5  riastrad  * ::
    204  1.5  riastrad  *
    205  1.5  riastrad  *
    206  1.5  riastrad  *               Active                 Front           Sync           Back
    207  1.5  riastrad  *              Region                 Porch                          Porch
    208  1.5  riastrad  *     <-----------------------><----------------><-------------><-------------->
    209  1.5  riastrad  *       //////////////////////|
    210  1.5  riastrad  *      ////////////////////// |
    211  1.5  riastrad  *     //////////////////////  |..................               ................
    212  1.5  riastrad  *                                                _______________
    213  1.5  riastrad  *     <----- [hv]display ----->
    214  1.5  riastrad  *     <------------- [hv]sync_start ------------>
    215  1.5  riastrad  *     <--------------------- [hv]sync_end --------------------->
    216  1.5  riastrad  *     <-------------------------------- [hv]total ----------------------------->*
    217  1.5  riastrad  *
    218  1.5  riastrad  * This structure contains two copies of timings. First are the plain timings,
    219  1.5  riastrad  * which specify the logical mode, as it would be for a progressive 1:1 scanout
    220  1.5  riastrad  * at the refresh rate userspace can observe through vblank timestamps. Then
    221  1.5  riastrad  * there's the hardware timings, which are corrected for interlacing,
    222  1.5  riastrad  * double-clocking and similar things. They are provided as a convenience, and
    223  1.5  riastrad  * can be appropriately computed using drm_mode_set_crtcinfo().
    224  1.5  riastrad  *
    225  1.5  riastrad  * For printing you can use %DRM_MODE_FMT and DRM_MODE_ARG().
    226  1.5  riastrad  */
    227  1.1  riastrad struct drm_display_mode {
    228  1.5  riastrad 	/**
    229  1.5  riastrad 	 * @head:
    230  1.5  riastrad 	 *
    231  1.5  riastrad 	 * struct list_head for mode lists.
    232  1.5  riastrad 	 */
    233  1.1  riastrad 	struct list_head head;
    234  1.1  riastrad 
    235  1.5  riastrad 	/**
    236  1.5  riastrad 	 * @name:
    237  1.5  riastrad 	 *
    238  1.5  riastrad 	 * Human-readable name of the mode, filled out with drm_mode_set_name().
    239  1.5  riastrad 	 */
    240  1.1  riastrad 	char name[DRM_DISPLAY_MODE_LEN];
    241  1.1  riastrad 
    242  1.5  riastrad 	/**
    243  1.5  riastrad 	 * @status:
    244  1.5  riastrad 	 *
    245  1.5  riastrad 	 * Status of the mode, used to filter out modes not supported by the
    246  1.5  riastrad 	 * hardware. See enum &drm_mode_status.
    247  1.5  riastrad 	 */
    248  1.1  riastrad 	enum drm_mode_status status;
    249  1.5  riastrad 
    250  1.5  riastrad 	/**
    251  1.5  riastrad 	 * @type:
    252  1.5  riastrad 	 *
    253  1.5  riastrad 	 * A bitmask of flags, mostly about the source of a mode. Possible flags
    254  1.5  riastrad 	 * are:
    255  1.5  riastrad 	 *
    256  1.5  riastrad 	 *  - DRM_MODE_TYPE_PREFERRED: Preferred mode, usually the native
    257  1.5  riastrad 	 *    resolution of an LCD panel. There should only be one preferred
    258  1.5  riastrad 	 *    mode per connector at any given time.
    259  1.5  riastrad 	 *  - DRM_MODE_TYPE_DRIVER: Mode created by the driver, which is all of
    260  1.5  riastrad 	 *    them really. Drivers must set this bit for all modes they create
    261  1.5  riastrad 	 *    and expose to userspace.
    262  1.5  riastrad 	 *  - DRM_MODE_TYPE_USERDEF: Mode defined via kernel command line
    263  1.5  riastrad 	 *
    264  1.5  riastrad 	 * Plus a big list of flags which shouldn't be used at all, but are
    265  1.5  riastrad 	 * still around since these flags are also used in the userspace ABI.
    266  1.5  riastrad 	 * We no longer accept modes with these types though:
    267  1.5  riastrad 	 *
    268  1.5  riastrad 	 *  - DRM_MODE_TYPE_BUILTIN: Meant for hard-coded modes, unused.
    269  1.5  riastrad 	 *    Use DRM_MODE_TYPE_DRIVER instead.
    270  1.5  riastrad 	 *  - DRM_MODE_TYPE_DEFAULT: Again a leftover, use
    271  1.5  riastrad 	 *    DRM_MODE_TYPE_PREFERRED instead.
    272  1.5  riastrad 	 *  - DRM_MODE_TYPE_CLOCK_C and DRM_MODE_TYPE_CRTC_C: Define leftovers
    273  1.5  riastrad 	 *    which are stuck around for hysterical raisins only. No one has an
    274  1.5  riastrad 	 *    idea what they were meant for. Don't use.
    275  1.5  riastrad 	 */
    276  1.1  riastrad 	unsigned int type;
    277  1.1  riastrad 
    278  1.5  riastrad 	/**
    279  1.5  riastrad 	 * @clock:
    280  1.5  riastrad 	 *
    281  1.5  riastrad 	 * Pixel clock in kHz.
    282  1.5  riastrad 	 */
    283  1.1  riastrad 	int clock;		/* in kHz */
    284  1.1  riastrad 	int hdisplay;
    285  1.1  riastrad 	int hsync_start;
    286  1.1  riastrad 	int hsync_end;
    287  1.1  riastrad 	int htotal;
    288  1.1  riastrad 	int hskew;
    289  1.1  riastrad 	int vdisplay;
    290  1.1  riastrad 	int vsync_start;
    291  1.1  riastrad 	int vsync_end;
    292  1.1  riastrad 	int vtotal;
    293  1.1  riastrad 	int vscan;
    294  1.5  riastrad 	/**
    295  1.5  riastrad 	 * @flags:
    296  1.5  riastrad 	 *
    297  1.5  riastrad 	 * Sync and timing flags:
    298  1.5  riastrad 	 *
    299  1.5  riastrad 	 *  - DRM_MODE_FLAG_PHSYNC: horizontal sync is active high.
    300  1.5  riastrad 	 *  - DRM_MODE_FLAG_NHSYNC: horizontal sync is active low.
    301  1.5  riastrad 	 *  - DRM_MODE_FLAG_PVSYNC: vertical sync is active high.
    302  1.5  riastrad 	 *  - DRM_MODE_FLAG_NVSYNC: vertical sync is active low.
    303  1.5  riastrad 	 *  - DRM_MODE_FLAG_INTERLACE: mode is interlaced.
    304  1.5  riastrad 	 *  - DRM_MODE_FLAG_DBLSCAN: mode uses doublescan.
    305  1.5  riastrad 	 *  - DRM_MODE_FLAG_CSYNC: mode uses composite sync.
    306  1.5  riastrad 	 *  - DRM_MODE_FLAG_PCSYNC: composite sync is active high.
    307  1.5  riastrad 	 *  - DRM_MODE_FLAG_NCSYNC: composite sync is active low.
    308  1.5  riastrad 	 *  - DRM_MODE_FLAG_HSKEW: hskew provided (not used?).
    309  1.5  riastrad 	 *  - DRM_MODE_FLAG_BCAST: <deprecated>
    310  1.5  riastrad 	 *  - DRM_MODE_FLAG_PIXMUX: <deprecated>
    311  1.5  riastrad 	 *  - DRM_MODE_FLAG_DBLCLK: double-clocked mode.
    312  1.5  riastrad 	 *  - DRM_MODE_FLAG_CLKDIV2: half-clocked mode.
    313  1.5  riastrad 	 *
    314  1.5  riastrad 	 * Additionally there's flags to specify how 3D modes are packed:
    315  1.5  riastrad 	 *
    316  1.5  riastrad 	 *  - DRM_MODE_FLAG_3D_NONE: normal, non-3D mode.
    317  1.5  riastrad 	 *  - DRM_MODE_FLAG_3D_FRAME_PACKING: 2 full frames for left and right.
    318  1.5  riastrad 	 *  - DRM_MODE_FLAG_3D_FIELD_ALTERNATIVE: interleaved like fields.
    319  1.5  riastrad 	 *  - DRM_MODE_FLAG_3D_LINE_ALTERNATIVE: interleaved lines.
    320  1.5  riastrad 	 *  - DRM_MODE_FLAG_3D_SIDE_BY_SIDE_FULL: side-by-side full frames.
    321  1.5  riastrad 	 *  - DRM_MODE_FLAG_3D_L_DEPTH: ?
    322  1.5  riastrad 	 *  - DRM_MODE_FLAG_3D_L_DEPTH_GFX_GFX_DEPTH: ?
    323  1.5  riastrad 	 *  - DRM_MODE_FLAG_3D_TOP_AND_BOTTOM: frame split into top and bottom
    324  1.5  riastrad 	 *    parts.
    325  1.5  riastrad 	 *  - DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF: frame split into left and
    326  1.5  riastrad 	 *    right parts.
    327  1.5  riastrad 	 */
    328  1.1  riastrad 	unsigned int flags;
    329  1.1  riastrad 
    330  1.5  riastrad 	/**
    331  1.5  riastrad 	 * @width_mm:
    332  1.5  riastrad 	 *
    333  1.5  riastrad 	 * Addressable size of the output in mm, projectors should set this to
    334  1.5  riastrad 	 * 0.
    335  1.5  riastrad 	 */
    336  1.1  riastrad 	int width_mm;
    337  1.5  riastrad 
    338  1.5  riastrad 	/**
    339  1.5  riastrad 	 * @height_mm:
    340  1.5  riastrad 	 *
    341  1.5  riastrad 	 * Addressable size of the output in mm, projectors should set this to
    342  1.5  riastrad 	 * 0.
    343  1.5  riastrad 	 */
    344  1.1  riastrad 	int height_mm;
    345  1.1  riastrad 
    346  1.5  riastrad 	/**
    347  1.5  riastrad 	 * @crtc_clock:
    348  1.5  riastrad 	 *
    349  1.5  riastrad 	 * Actual pixel or dot clock in the hardware. This differs from the
    350  1.5  riastrad 	 * logical @clock when e.g. using interlacing, double-clocking, stereo
    351  1.5  riastrad 	 * modes or other fancy stuff that changes the timings and signals
    352  1.5  riastrad 	 * actually sent over the wire.
    353  1.5  riastrad 	 *
    354  1.5  riastrad 	 * This is again in kHz.
    355  1.5  riastrad 	 *
    356  1.5  riastrad 	 * Note that with digital outputs like HDMI or DP there's usually a
    357  1.5  riastrad 	 * massive confusion between the dot clock and the signal clock at the
    358  1.5  riastrad 	 * bit encoding level. Especially when a 8b/10b encoding is used and the
    359  1.5  riastrad 	 * difference is exactly a factor of 10.
    360  1.5  riastrad 	 */
    361  1.5  riastrad 	int crtc_clock;
    362  1.1  riastrad 	int crtc_hdisplay;
    363  1.1  riastrad 	int crtc_hblank_start;
    364  1.1  riastrad 	int crtc_hblank_end;
    365  1.1  riastrad 	int crtc_hsync_start;
    366  1.1  riastrad 	int crtc_hsync_end;
    367  1.1  riastrad 	int crtc_htotal;
    368  1.1  riastrad 	int crtc_hskew;
    369  1.1  riastrad 	int crtc_vdisplay;
    370  1.1  riastrad 	int crtc_vblank_start;
    371  1.1  riastrad 	int crtc_vblank_end;
    372  1.1  riastrad 	int crtc_vsync_start;
    373  1.1  riastrad 	int crtc_vsync_end;
    374  1.1  riastrad 	int crtc_vtotal;
    375  1.1  riastrad 
    376  1.5  riastrad 	/**
    377  1.5  riastrad 	 * @private:
    378  1.5  riastrad 	 *
    379  1.5  riastrad 	 * Pointer for driver private data. This can only be used for mode
    380  1.5  riastrad 	 * objects passed to drivers in modeset operations. It shouldn't be used
    381  1.5  riastrad 	 * by atomic drivers since they can store any additional data by
    382  1.5  riastrad 	 * subclassing state structures.
    383  1.5  riastrad 	 */
    384  1.1  riastrad 	int *private;
    385  1.5  riastrad 
    386  1.5  riastrad 	/**
    387  1.5  riastrad 	 * @private_flags:
    388  1.5  riastrad 	 *
    389  1.5  riastrad 	 * Similar to @private, but just an integer.
    390  1.5  riastrad 	 */
    391  1.1  riastrad 	int private_flags;
    392  1.1  riastrad 
    393  1.5  riastrad 	/**
    394  1.5  riastrad 	 * @vrefresh:
    395  1.5  riastrad 	 *
    396  1.5  riastrad 	 * Vertical refresh rate, for debug output in human readable form. Not
    397  1.5  riastrad 	 * used in a functional way.
    398  1.5  riastrad 	 *
    399  1.5  riastrad 	 * This value is in Hz.
    400  1.5  riastrad 	 */
    401  1.5  riastrad 	int vrefresh;
    402  1.5  riastrad 
    403  1.5  riastrad 	/**
    404  1.5  riastrad 	 * @hsync:
    405  1.5  riastrad 	 *
    406  1.5  riastrad 	 * Horizontal refresh rate, for debug output in human readable form. Not
    407  1.5  riastrad 	 * used in a functional way.
    408  1.5  riastrad 	 *
    409  1.5  riastrad 	 * This value is in kHz.
    410  1.5  riastrad 	 */
    411  1.5  riastrad 	int hsync;
    412  1.5  riastrad 
    413  1.5  riastrad 	/**
    414  1.5  riastrad 	 * @picture_aspect_ratio:
    415  1.5  riastrad 	 *
    416  1.5  riastrad 	 * Field for setting the HDMI picture aspect ratio of a mode.
    417  1.5  riastrad 	 */
    418  1.1  riastrad 	enum hdmi_picture_aspect picture_aspect_ratio;
    419  1.5  riastrad 
    420  1.5  riastrad 	/**
    421  1.5  riastrad 	 * @export_head:
    422  1.5  riastrad 	 *
    423  1.5  riastrad 	 * struct list_head for modes to be exposed to the userspace.
    424  1.5  riastrad 	 * This is to maintain a list of exposed modes while preparing
    425  1.5  riastrad 	 * user-mode's list in drm_mode_getconnector ioctl. The purpose of this
    426  1.5  riastrad 	 * list_head only lies in the ioctl function, and is not expected to be
    427  1.5  riastrad 	 * used outside the function.
    428  1.5  riastrad 	 * Once used, the stale pointers are not reset, but left as it is, to
    429  1.5  riastrad 	 * avoid overhead of protecting it by mode_config.mutex.
    430  1.5  riastrad 	 */
    431  1.5  riastrad 	struct list_head export_head;
    432  1.1  riastrad };
    433  1.1  riastrad 
    434  1.5  riastrad /**
    435  1.5  riastrad  * DRM_MODE_FMT - printf string for &struct drm_display_mode
    436  1.5  riastrad  */
    437  1.5  riastrad #define DRM_MODE_FMT    "\"%s\": %d %d %d %d %d %d %d %d %d %d 0x%x 0x%x"
    438  1.5  riastrad 
    439  1.5  riastrad /**
    440  1.5  riastrad  * DRM_MODE_ARG - printf arguments for &struct drm_display_mode
    441  1.5  riastrad  * @m: display mode
    442  1.5  riastrad  */
    443  1.5  riastrad #define DRM_MODE_ARG(m) \
    444  1.5  riastrad 	(m)->name, (m)->vrefresh, (m)->clock, \
    445  1.5  riastrad 	(m)->hdisplay, (m)->hsync_start, (m)->hsync_end, (m)->htotal, \
    446  1.5  riastrad 	(m)->vdisplay, (m)->vsync_start, (m)->vsync_end, (m)->vtotal, \
    447  1.5  riastrad 	(m)->type, (m)->flags
    448  1.5  riastrad 
    449  1.5  riastrad #define obj_to_mode(x) container_of(x, struct drm_display_mode, base)
    450  1.1  riastrad 
    451  1.1  riastrad /**
    452  1.1  riastrad  * drm_mode_is_stereo - check for stereo mode flags
    453  1.1  riastrad  * @mode: drm_display_mode to check
    454  1.1  riastrad  *
    455  1.1  riastrad  * Returns:
    456  1.1  riastrad  * True if the mode is one of the stereo modes (like side-by-side), false if
    457  1.1  riastrad  * not.
    458  1.1  riastrad  */
    459  1.1  riastrad static inline bool drm_mode_is_stereo(const struct drm_display_mode *mode)
    460  1.1  riastrad {
    461  1.1  riastrad 	return mode->flags & DRM_MODE_FLAG_3D_MASK;
    462  1.1  riastrad }
    463  1.1  riastrad 
    464  1.1  riastrad struct drm_connector;
    465  1.1  riastrad struct drm_cmdline_mode;
    466  1.1  riastrad 
    467  1.1  riastrad struct drm_display_mode *drm_mode_create(struct drm_device *dev);
    468  1.1  riastrad void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode);
    469  1.4  riastrad void drm_mode_convert_to_umode(struct drm_mode_modeinfo *out,
    470  1.5  riastrad 			       const struct drm_display_mode *in);
    471  1.5  riastrad int drm_mode_convert_umode(struct drm_device *dev,
    472  1.5  riastrad 			   struct drm_display_mode *out,
    473  1.4  riastrad 			   const struct drm_mode_modeinfo *in);
    474  1.1  riastrad void drm_mode_probed_add(struct drm_connector *connector, struct drm_display_mode *mode);
    475  1.1  riastrad void drm_mode_debug_printmodeline(const struct drm_display_mode *mode);
    476  1.5  riastrad bool drm_mode_is_420_only(const struct drm_display_info *display,
    477  1.5  riastrad 			  const struct drm_display_mode *mode);
    478  1.5  riastrad bool drm_mode_is_420_also(const struct drm_display_info *display,
    479  1.5  riastrad 			  const struct drm_display_mode *mode);
    480  1.5  riastrad bool drm_mode_is_420(const struct drm_display_info *display,
    481  1.5  riastrad 		     const struct drm_display_mode *mode);
    482  1.1  riastrad 
    483  1.1  riastrad struct drm_display_mode *drm_cvt_mode(struct drm_device *dev,
    484  1.1  riastrad 				      int hdisplay, int vdisplay, int vrefresh,
    485  1.1  riastrad 				      bool reduced, bool interlaced,
    486  1.1  riastrad 				      bool margins);
    487  1.1  riastrad struct drm_display_mode *drm_gtf_mode(struct drm_device *dev,
    488  1.1  riastrad 				      int hdisplay, int vdisplay, int vrefresh,
    489  1.1  riastrad 				      bool interlaced, int margins);
    490  1.1  riastrad struct drm_display_mode *drm_gtf_mode_complex(struct drm_device *dev,
    491  1.1  riastrad 					      int hdisplay, int vdisplay,
    492  1.1  riastrad 					      int vrefresh, bool interlaced,
    493  1.1  riastrad 					      int margins,
    494  1.1  riastrad 					      int GTF_M, int GTF_2C,
    495  1.1  riastrad 					      int GTF_K, int GTF_2J);
    496  1.1  riastrad void drm_display_mode_from_videomode(const struct videomode *vm,
    497  1.1  riastrad 				     struct drm_display_mode *dmode);
    498  1.4  riastrad void drm_display_mode_to_videomode(const struct drm_display_mode *dmode,
    499  1.4  riastrad 				   struct videomode *vm);
    500  1.5  riastrad void drm_bus_flags_from_videomode(const struct videomode *vm, u32 *bus_flags);
    501  1.1  riastrad int of_get_drm_display_mode(struct device_node *np,
    502  1.5  riastrad 			    struct drm_display_mode *dmode, u32 *bus_flags,
    503  1.1  riastrad 			    int index);
    504  1.1  riastrad 
    505  1.1  riastrad void drm_mode_set_name(struct drm_display_mode *mode);
    506  1.1  riastrad int drm_mode_hsync(const struct drm_display_mode *mode);
    507  1.1  riastrad int drm_mode_vrefresh(const struct drm_display_mode *mode);
    508  1.5  riastrad void drm_mode_get_hv_timing(const struct drm_display_mode *mode,
    509  1.5  riastrad 			    int *hdisplay, int *vdisplay);
    510  1.1  riastrad 
    511  1.1  riastrad void drm_mode_set_crtcinfo(struct drm_display_mode *p,
    512  1.1  riastrad 			   int adjust_flags);
    513  1.1  riastrad void drm_mode_copy(struct drm_display_mode *dst,
    514  1.1  riastrad 		   const struct drm_display_mode *src);
    515  1.1  riastrad struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev,
    516  1.1  riastrad 					    const struct drm_display_mode *mode);
    517  1.5  riastrad bool drm_mode_match(const struct drm_display_mode *mode1,
    518  1.5  riastrad 		    const struct drm_display_mode *mode2,
    519  1.5  riastrad 		    unsigned int match_flags);
    520  1.1  riastrad bool drm_mode_equal(const struct drm_display_mode *mode1,
    521  1.1  riastrad 		    const struct drm_display_mode *mode2);
    522  1.5  riastrad bool drm_mode_equal_no_clocks(const struct drm_display_mode *mode1,
    523  1.5  riastrad 			      const struct drm_display_mode *mode2);
    524  1.1  riastrad bool drm_mode_equal_no_clocks_no_stereo(const struct drm_display_mode *mode1,
    525  1.1  riastrad 					const struct drm_display_mode *mode2);
    526  1.1  riastrad 
    527  1.1  riastrad /* for use by the crtc helper probe functions */
    528  1.5  riastrad enum drm_mode_status drm_mode_validate_driver(struct drm_device *dev,
    529  1.5  riastrad 					      const struct drm_display_mode *mode);
    530  1.4  riastrad enum drm_mode_status drm_mode_validate_size(const struct drm_display_mode *mode,
    531  1.4  riastrad 					    int maxX, int maxY);
    532  1.5  riastrad enum drm_mode_status
    533  1.5  riastrad drm_mode_validate_ycbcr420(const struct drm_display_mode *mode,
    534  1.5  riastrad 			   struct drm_connector *connector);
    535  1.1  riastrad void drm_mode_prune_invalid(struct drm_device *dev,
    536  1.1  riastrad 			    struct list_head *mode_list, bool verbose);
    537  1.1  riastrad void drm_mode_sort(struct list_head *mode_list);
    538  1.5  riastrad void drm_connector_list_update(struct drm_connector *connector);
    539  1.1  riastrad 
    540  1.1  riastrad /* parsing cmdline modes */
    541  1.1  riastrad bool
    542  1.1  riastrad drm_mode_parse_command_line_for_connector(const char *mode_option,
    543  1.5  riastrad 					  const struct drm_connector *connector,
    544  1.1  riastrad 					  struct drm_cmdline_mode *mode);
    545  1.1  riastrad struct drm_display_mode *
    546  1.1  riastrad drm_mode_create_from_cmdline_mode(struct drm_device *dev,
    547  1.1  riastrad 				  struct drm_cmdline_mode *cmd);
    548  1.1  riastrad 
    549  1.1  riastrad #endif /* __DRM_MODES_H__ */
    550