XenevaOS
Loading...
Searching...
No Matches
drm_modes.h
Go to the documentation of this file.
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
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
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
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
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
421
425#define DRM_MODE_FMT "\"%s\": %d %d %d %d %d %d %d %d %d %d 0x%x 0x%x"
426
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
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
458 const struct drm_display_mode *in);
460 struct drm_display_mode *out,
461 const struct drm_mode_modeinfo *in);
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);
471 int hpref, int vpref);
472
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
491 int hdisplay, int vdisplay, int vrefresh,
492 bool reduced, bool interlaced,
493 bool margins);
495 int hdisplay, int vdisplay, int vrefresh,
496 bool interlaced, int margins);
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);
504 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
533 int *hdisplay, int *vdisplay);
534
536 int adjust_flags);
538 const struct drm_display_mode *src);
540 const struct drm_display_mode *src);
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);
549 const struct drm_display_mode *mode2);
551 const struct drm_display_mode *mode2);
552
553/* for use by the crtc helper probe functions */
555 const struct drm_display_mode *mode);
557 int maxX, int maxY);
560 struct drm_connector *connector);
562 struct list_head *mode_list, bool verbose);
563void drm_mode_sort(struct list_head *mode_list);
565
566/* parsing cmdline modes */
567bool
569 const struct drm_connector *connector,
570 struct drm_cmdline_mode *mode);
571struct drm_display_mode *
573 struct drm_cmdline_mode *cmd);
574
575#endif /* __DRM_MODES_H__ */
#define index(str, chr)
Definition string.h:66
#define out(...)
Definition main.cpp:65
#define EINVAL
Definition acclib.h:198
#define DRM_DISPLAY_MODE_LEN
Definition drm_mode.h:32
#define DRM_MODE_FLAG_3D_MASK
Definition drm_mode.h:75
drm_connector_tv_mode
Definition drm_connector.h:160
@ DRM_MODE_TV_MODE_NTSC
Definition drm_connector.h:165
@ DRM_MODE_TV_MODE_PAL
Definition drm_connector.h:185
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)
bool drm_mode_equal_no_clocks_no_stereo(const struct drm_display_mode *mode1, const struct drm_display_mode *mode2)
void drm_mode_set_name(struct drm_display_mode *mode)
struct drm_display_mode * drm_mode_create_from_cmdline_mode(struct drm_device *dev, struct drm_cmdline_mode *cmd)
enum drm_mode_status drm_mode_validate_driver(struct drm_device *dev, const struct drm_display_mode *mode)
void drm_mode_convert_to_umode(struct drm_mode_modeinfo *out, const struct drm_display_mode *in)
struct drm_display_mode * drm_mode_create(struct drm_device *dev)
void drm_mode_sort(struct list_head *mode_list)
enum drm_mode_status drm_mode_validate_ycbcr420(const struct drm_display_mode *mode, struct drm_connector *connector)
void drm_set_preferred_mode(struct drm_connector *connector, int hpref, int vpref)
bool drm_mode_parse_command_line_for_connector(const char *mode_option, const struct drm_connector *connector, struct drm_cmdline_mode *mode)
struct drm_display_mode * drm_gtf_mode(struct drm_device *dev, int hdisplay, int vdisplay, int vrefresh, bool interlaced, int margins)
void drm_mode_prune_invalid(struct drm_device *dev, struct list_head *mode_list, bool verbose)
bool drm_mode_is_420(const struct drm_display_info *display, const struct drm_display_mode *mode)
void drm_mode_set_crtcinfo(struct drm_display_mode *p, int adjust_flags)
bool drm_mode_is_420_only(const struct drm_display_info *display, const struct drm_display_mode *mode)
enum drm_mode_status drm_mode_validate_size(const struct drm_display_mode *mode, int maxX, int maxY)
bool drm_mode_match(const struct drm_display_mode *mode1, const struct drm_display_mode *mode2, unsigned int match_flags)
void drm_mode_debug_printmodeline(const struct drm_display_mode *mode)
struct drm_display_mode * drm_mode_duplicate(struct drm_device *dev, const struct drm_display_mode *mode)
void drm_bus_flags_from_videomode(const struct videomode *vm, u32 *bus_flags)
bool drm_mode_equal(const struct drm_display_mode *mode1, const struct drm_display_mode *mode2)
int drm_mode_convert_umode(struct drm_device *dev, struct drm_display_mode *out, const struct drm_mode_modeinfo *in)
bool drm_mode_equal_no_clocks(const struct drm_display_mode *mode1, const struct drm_display_mode *mode2)
struct drm_display_mode * drm_cvt_mode(struct drm_device *dev, int hdisplay, int vdisplay, int vrefresh, bool reduced, bool interlaced, bool margins)
void drm_mode_get_hv_timing(const struct drm_display_mode *mode, int *hdisplay, int *vdisplay)
void drm_mode_probed_add(struct drm_connector *connector, struct drm_display_mode *mode)
void drm_display_mode_to_videomode(const struct drm_display_mode *dmode, struct videomode *vm)
bool drm_mode_is_420_also(const struct drm_display_info *display, const struct drm_display_mode *mode)
void drm_connector_list_update(struct drm_connector *connector)
void drm_mode_init(struct drm_display_mode *dst, const struct drm_display_mode *src)
drm_mode_status
Definition drm_modes.h:91
@ MODE_VSYNC
Definition drm_modes.h:94
@ MODE_HBLANK_WIDE
Definition drm_modes.h:116
@ MODE_NOMODE
Definition drm_modes.h:98
@ MODE_HSYNC_WIDE
Definition drm_modes.h:114
@ MODE_MEM
Definition drm_modes.h:102
@ MODE_BAD_WIDTH
Definition drm_modes.h:97
@ MODE_VBLANK_NARROW
Definition drm_modes.h:119
@ MODE_NO_VSCAN
Definition drm_modes.h:101
@ MODE_BAD
Definition drm_modes.h:130
@ MODE_HSYNC
Definition drm_modes.h:93
@ MODE_HBLANK_NARROW
Definition drm_modes.h:115
@ MODE_NO_REDUCED
Definition drm_modes.h:126
@ MODE_NOCLOCK
Definition drm_modes.h:106
@ MODE_CLOCK_HIGH
Definition drm_modes.h:107
@ MODE_OK
Definition drm_modes.h:92
@ MODE_HSYNC_NARROW
Definition drm_modes.h:113
@ MODE_BAD_HVALUE
Definition drm_modes.h:110
@ MODE_BAD_VSCAN
Definition drm_modes.h:112
@ MODE_ONE_HEIGHT
Definition drm_modes.h:124
@ MODE_CLOCK_LOW
Definition drm_modes.h:108
@ MODE_H_ILLEGAL
Definition drm_modes.h:95
@ MODE_ERROR
Definition drm_modes.h:131
@ MODE_BAD_VVALUE
Definition drm_modes.h:111
@ MODE_NO_DBLESCAN
Definition drm_modes.h:100
@ MODE_ONE_SIZE
Definition drm_modes.h:125
@ MODE_VIRTUAL_X
Definition drm_modes.h:103
@ MODE_VBLANK_WIDE
Definition drm_modes.h:120
@ MODE_ONE_WIDTH
Definition drm_modes.h:123
@ MODE_NO_420
Definition drm_modes.h:128
@ MODE_CLOCK_RANGE
Definition drm_modes.h:109
@ MODE_INTERLACE_WIDTH
Definition drm_modes.h:122
@ MODE_MEM_VIRT
Definition drm_modes.h:105
@ MODE_VIRTUAL_Y
Definition drm_modes.h:104
@ MODE_PANEL
Definition drm_modes.h:121
@ MODE_NO_INTERLACE
Definition drm_modes.h:99
@ MODE_STALE
Definition drm_modes.h:129
@ MODE_V_ILLEGAL
Definition drm_modes.h:96
@ MODE_VSYNC_NARROW
Definition drm_modes.h:117
@ MODE_NO_STEREO
Definition drm_modes.h:127
@ MODE_VSYNC_WIDE
Definition drm_modes.h:118
void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode)
void drm_mode_copy(struct drm_display_mode *dst, const struct drm_display_mode *src)
void drm_display_mode_from_videomode(const struct videomode *vm, struct drm_display_mode *dmode)
struct drm_display_mode * drm_analog_tv_mode(struct drm_device *dev, enum drm_connector_tv_mode mode, unsigned long pixel_clock_hz, unsigned int hdisplay, unsigned int vdisplay, bool interlace)
int drm_mode_vrefresh(const struct drm_display_mode *mode)
const struct device * dev
Definition drm_print.h:519
hdmi_picture_aspect
Definition hdmi.h:111
uint8_t u8
Definition kernel.h:14
uint16_t u16
Definition kernel.h:15
uint32_t u32
Definition kernel.h:16
int const struct list_head const struct list_head struct list_head * head
Definition list_sort.h:13
Definition drm_connector.h:1725
Definition drm_connector.h:1998
Definition drm_device.h:75
Definition drm_connector.h:740
Definition drm_modes.h:252
u16 hsync_end
Definition drm_modes.h:261
u16 width_mm
Definition drm_modes.h:341
u16 vsync_end
Definition drm_modes.h:266
u16 crtc_hblank_end
Definition drm_modes.h:323
u16 crtc_hblank_start
Definition drm_modes.h:322
u16 vdisplay
Definition drm_modes.h:264
u16 crtc_vtotal
Definition drm_modes.h:333
u16 hdisplay
Definition drm_modes.h:259
u16 crtc_hsync_start
Definition drm_modes.h:324
int crtc_clock
Definition drm_modes.h:320
u16 crtc_hdisplay
Definition drm_modes.h:321
u16 hskew
Definition drm_modes.h:263
u8 type
Definition drm_modes.h:378
char name[DRM_DISPLAY_MODE_LEN]
Definition drm_modes.h:403
u16 crtc_vdisplay
Definition drm_modes.h:328
u16 crtc_vsync_end
Definition drm_modes.h:332
u16 crtc_htotal
Definition drm_modes.h:326
u16 crtc_hsync_end
Definition drm_modes.h:325
u16 vscan
Definition drm_modes.h:268
u16 height_mm
Definition drm_modes.h:349
bool expose_to_userspace
Definition drm_modes.h:389
u16 htotal
Definition drm_modes.h:262
enum drm_mode_status status
Definition drm_modes.h:411
u16 vsync_start
Definition drm_modes.h:265
u16 hsync_start
Definition drm_modes.h:260
u16 vtotal
Definition drm_modes.h:267
u16 crtc_vsync_start
Definition drm_modes.h:331
u16 crtc_vblank_end
Definition drm_modes.h:330
enum hdmi_picture_aspect picture_aspect_ratio
Definition drm_modes.h:418
u32 flags
Definition drm_modes.h:303
u16 crtc_vblank_start
Definition drm_modes.h:329
u16 crtc_hskew
Definition drm_modes.h:327
int clock
Definition drm_modes.h:258
Definition drm_mode.h:231
Definition list.h:11
Definition videomode.h:18
#define mode(x)
int maxY
Definition virtiotablet.c:53
int maxX
Definition virtiotablet.c:52