Linux Audio

Check our new training course

In-person Linux kernel drivers training

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